1
0
Fork 0
mirror of https://github.com/kidoman/embd synced 2025-07-03 20:07:40 +02:00

OneWire bus impl

This commit is contained in:
Max Matveev 2016-02-05 22:16:51 -08:00
parent bfcd1345fe
commit 82f119fadb
72 changed files with 568 additions and 174 deletions

View file

@ -18,8 +18,8 @@ import (
"os/signal"
"time"
"github.com/kidoman/embd"
_ "github.com/kidoman/embd/host/rpi"
"github.com/zlowred/embd"
_ "github.com/zlowred/embd/host/rpi"
)
func main() {

View file

@ -9,9 +9,9 @@ import (
"os/signal"
"time"
"github.com/kidoman/embd"
"github.com/zlowred/embd"
_ "github.com/kidoman/embd/host/all"
_ "github.com/zlowred/embd/host/all"
)
func main() {

View file

@ -6,9 +6,9 @@ import (
"flag"
"fmt"
"github.com/kidoman/embd"
"github.com/zlowred/embd"
_ "github.com/kidoman/embd/host/all"
_ "github.com/zlowred/embd/host/all"
)
func main() {

View file

@ -7,10 +7,10 @@ import (
"fmt"
"time"
"github.com/kidoman/embd"
"github.com/kidoman/embd/sensor/bh1750fvi"
"github.com/zlowred/embd"
"github.com/zlowred/embd/sensor/bh1750fvi"
_ "github.com/kidoman/embd/host/all"
_ "github.com/zlowred/embd/host/all"
)
func main() {

View file

@ -7,10 +7,10 @@ import (
"fmt"
"time"
"github.com/kidoman/embd"
"github.com/kidoman/embd/sensor/bmp085"
"github.com/zlowred/embd"
"github.com/zlowred/embd/sensor/bmp085"
_ "github.com/kidoman/embd/host/all"
_ "github.com/zlowred/embd/host/all"
)
func main() {

View file

@ -7,10 +7,10 @@ import (
"fmt"
"time"
"github.com/kidoman/embd"
"github.com/kidoman/embd/sensor/bmp180"
"github.com/zlowred/embd"
"github.com/zlowred/embd/sensor/bmp180"
_ "github.com/kidoman/embd/host/all"
_ "github.com/zlowred/embd/host/all"
)
func main() {

View file

@ -6,11 +6,11 @@ import (
"flag"
"time"
"github.com/kidoman/embd"
"github.com/kidoman/embd/controller/hd44780"
"github.com/kidoman/embd/interface/display/characterdisplay"
"github.com/zlowred/embd"
"github.com/zlowred/embd/controller/hd44780"
"github.com/zlowred/embd/interface/display/characterdisplay"
_ "github.com/kidoman/embd/host/all"
_ "github.com/zlowred/embd/host/all"
)
func main() {

View file

@ -11,8 +11,8 @@ import (
"os/signal"
"time"
"github.com/kidoman/embd"
_ "github.com/kidoman/embd/host/rpi"
"github.com/zlowred/embd"
_ "github.com/zlowred/embd/host/rpi"
)
func main() {

View file

@ -6,9 +6,9 @@ import (
"flag"
"time"
"github.com/kidoman/embd"
"github.com/zlowred/embd"
_ "github.com/kidoman/embd/host/all"
_ "github.com/zlowred/embd/host/all"
)
func main() {

View file

@ -6,9 +6,9 @@ import (
"flag"
"time"
"github.com/kidoman/embd"
"github.com/zlowred/embd"
_ "github.com/kidoman/embd/host/all"
_ "github.com/zlowred/embd/host/all"
)
func main() {

View file

@ -6,9 +6,9 @@ import (
"flag"
"time"
"github.com/kidoman/embd"
"github.com/zlowred/embd"
_ "github.com/kidoman/embd/host/all"
_ "github.com/zlowred/embd/host/all"
)
func main() {

View file

@ -6,9 +6,9 @@ import (
"flag"
"fmt"
"github.com/kidoman/embd"
"github.com/zlowred/embd"
_ "github.com/kidoman/embd/host/all"
_ "github.com/zlowred/embd/host/all"
)
func main() {

View file

@ -5,9 +5,9 @@ package main
import (
"flag"
"github.com/kidoman/embd"
"github.com/zlowred/embd"
_ "github.com/kidoman/embd/host/all"
_ "github.com/zlowred/embd/host/all"
)
func main() {

View file

@ -6,10 +6,10 @@ import (
"flag"
"time"
"github.com/kidoman/embd"
"github.com/kidoman/embd/controller/hd44780"
"github.com/zlowred/embd"
"github.com/zlowred/embd/controller/hd44780"
_ "github.com/kidoman/embd/host/all"
_ "github.com/zlowred/embd/host/all"
)
func main() {

View file

@ -5,8 +5,8 @@ package main
import (
"fmt"
"time"
"github.com/kidoman/embd"
"github.com/kidoman/embd/interface/keypad/matrix4x3"
"github.com/zlowred/embd"
"github.com/zlowred/embd/interface/keypad/matrix4x3"
)
func main() {

View file

@ -9,10 +9,10 @@ import (
"os/signal"
"time"
"github.com/kidoman/embd"
"github.com/kidoman/embd/sensor/l3gd20"
"github.com/zlowred/embd"
"github.com/zlowred/embd/sensor/l3gd20"
_ "github.com/kidoman/embd/host/all"
_ "github.com/zlowred/embd/host/all"
)
func main() {

View file

@ -11,9 +11,9 @@ import (
"os/signal"
"time"
"github.com/kidoman/embd"
"github.com/zlowred/embd"
_ "github.com/kidoman/embd/host/bbb"
_ "github.com/zlowred/embd/host/bbb"
)
func main() {

View file

@ -8,9 +8,9 @@ import (
"flag"
"time"
"github.com/kidoman/embd"
"github.com/zlowred/embd"
_ "github.com/kidoman/embd/host/bbb"
_ "github.com/zlowred/embd/host/bbb"
)
func main() {

View file

@ -7,10 +7,10 @@ import (
"fmt"
"time"
"github.com/kidoman/embd"
"github.com/kidoman/embd/sensor/lsm303"
"github.com/zlowred/embd"
"github.com/zlowred/embd/sensor/lsm303"
_ "github.com/kidoman/embd/host/all"
_ "github.com/zlowred/embd/host/all"
)
func main() {

View file

@ -8,9 +8,9 @@ import (
"fmt"
"time"
"github.com/kidoman/embd"
"github.com/kidoman/embd/convertors/mcp3008"
_ "github.com/kidoman/embd/host/all"
"github.com/zlowred/embd"
"github.com/zlowred/embd/convertors/mcp3008"
_ "github.com/zlowred/embd/host/all"
)
const (

View file

@ -9,10 +9,10 @@ import (
"os"
"os/signal"
"github.com/kidoman/embd"
"github.com/kidoman/embd/controller/mcp4725"
"github.com/zlowred/embd"
"github.com/zlowred/embd/controller/mcp4725"
_ "github.com/kidoman/embd/host/all"
_ "github.com/zlowred/embd/host/all"
)
func main() {

72
samples/onewire.go Normal file
View file

@ -0,0 +1,72 @@
// +build ignore
package main
import (
"fmt"
"github.com/zlowred/embd"
_ "github.com/zlowred/embd/host/all"
)
func main() {
if err := embd.InitW1(); err != nil {
panic(err)
}
defer embd.CloseW1()
w1 := embd.NewW1Bus(0)
devs, err := w1.ListDevices()
if err != nil {
panic(err)
}
for _, dev := range devs {
fmt.Println("OneWire device: %s", dev)
}
w1d, err := w1.Open("28-011572120bff")
if err != nil {
panic(err)
}
fmt.Printf("%v\n", w1d)
err = w1d.WriteByte(0x44)
if err != nil {
panic(err)
}
for ret, err := w1d.ReadByte(); ret == 0 && err != nil; {}
if err != nil {
panic(err)
}
err = w1d.WriteByte(0xBE)
if err != nil {
panic(err)
}
res, err := w1d.ReadBytes(9)
if err != nil {
panic(err)
}
fmt.Print("res: ")
for _, val := range res {
fmt.Printf("0x%02X ", val)
}
fmt.Println()
var temp float64 = float64(float64(res[1]) * 256. + float64(res[0])) / 16.
fmt.Printf("%f\n", temp)
fmt.Println("Done")
}

View file

@ -8,10 +8,10 @@ import (
"os/signal"
"time"
"github.com/kidoman/embd"
"github.com/kidoman/embd/controller/pca9685"
"github.com/zlowred/embd"
"github.com/zlowred/embd/controller/pca9685"
_ "github.com/kidoman/embd/host/all"
_ "github.com/zlowred/embd/host/all"
)
func main() {

View file

@ -8,10 +8,10 @@ import (
"flag"
"time"
"github.com/kidoman/embd"
"github.com/kidoman/embd/host/bbb"
"github.com/zlowred/embd"
"github.com/zlowred/embd/host/bbb"
_ "github.com/kidoman/embd/host/all"
_ "github.com/zlowred/embd/host/all"
)
func main() {

View file

@ -8,11 +8,11 @@ import (
"os/signal"
"time"
"github.com/kidoman/embd"
"github.com/kidoman/embd/controller/pca9685"
"github.com/kidoman/embd/motion/servo"
"github.com/zlowred/embd"
"github.com/zlowred/embd/controller/pca9685"
"github.com/zlowred/embd/motion/servo"
_ "github.com/kidoman/embd/host/all"
_ "github.com/zlowred/embd/host/all"
)
func main() {

View file

@ -8,10 +8,10 @@ import (
"os/signal"
"time"
"github.com/kidoman/embd"
"github.com/kidoman/embd/motion/servo"
"github.com/zlowred/embd"
"github.com/zlowred/embd/motion/servo"
_ "github.com/kidoman/embd/host/all"
_ "github.com/zlowred/embd/host/all"
)
func main() {

View file

@ -8,10 +8,10 @@ import (
"os/signal"
"time"
"github.com/kidoman/embd/controller/servoblaster"
"github.com/kidoman/embd/motion/servo"
"github.com/zlowred/embd/controller/servoblaster"
"github.com/zlowred/embd/motion/servo"
_ "github.com/kidoman/embd/host/all"
_ "github.com/zlowred/embd/host/all"
)
func main() {

View file

@ -8,8 +8,8 @@ package main
import (
"time"
"github.com/kidoman/embd"
_ "github.com/kidoman/embd/host/rpi" // This loads the RPi driver
"github.com/zlowred/embd"
_ "github.com/zlowred/embd/host/rpi" // This loads the RPi driver
)
func main() {

View file

@ -5,8 +5,8 @@ package main
import (
"fmt"
"github.com/kidoman/embd"
_ "github.com/kidoman/embd/host/all"
"github.com/zlowred/embd"
_ "github.com/zlowred/embd/host/all"
)
func main() {

View file

@ -7,8 +7,8 @@ import (
"fmt"
"time"
"github.com/kidoman/embd"
_ "github.com/kidoman/embd/host/all"
"github.com/zlowred/embd"
_ "github.com/zlowred/embd/host/all"
)
const (

View file

@ -8,10 +8,10 @@ import (
"os"
"os/signal"
"github.com/kidoman/embd"
"github.com/kidoman/embd/sensor/tmp006"
"github.com/zlowred/embd"
"github.com/zlowred/embd/sensor/tmp006"
_ "github.com/kidoman/embd/host/all"
_ "github.com/zlowred/embd/host/all"
)
func main() {

View file

@ -10,8 +10,8 @@ import (
"os/signal"
"time"
"github.com/kidoman/embd"
_ "github.com/kidoman/embd/host/all"
"github.com/zlowred/embd"
_ "github.com/zlowred/embd/host/all"
)
func main() {

View file

@ -9,10 +9,10 @@ import (
"os/signal"
"time"
"github.com/kidoman/embd"
"github.com/kidoman/embd/sensor/us020"
"github.com/zlowred/embd"
"github.com/zlowred/embd/sensor/us020"
_ "github.com/kidoman/embd/host/all"
_ "github.com/zlowred/embd/host/all"
)
func main() {

View file

@ -7,10 +7,10 @@ import (
"time"
"github.com/golang/glog"
"github.com/kidoman/embd"
"github.com/kidoman/embd/sensor/watersensor"
"github.com/zlowred/embd"
"github.com/zlowred/embd/sensor/watersensor"
_ "github.com/kidoman/embd/host/all"
_ "github.com/zlowred/embd/host/all"
)
func main() {