mirror of
https://github.com/kidoman/embd
synced 2025-07-03 20:07:40 +02:00
OneWire bus impl
This commit is contained in:
parent
bfcd1345fe
commit
82f119fadb
72 changed files with 568 additions and 174 deletions
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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 (
|
||||
|
|
|
@ -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
72
samples/onewire.go
Normal 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")
|
||||
}
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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 (
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue