Open joeblew99 opened 5 years ago
@joeblew99 Thanks for your suggestion.
Would you help raise a PR to fix it? :)
@fisherxu I can find an exact example for it.
The code is here: https://periph.io/device/led/
package main
import (
"log"
"time"
"periph.io/x/periph/conn/gpio"
"periph.io/x/periph/host"
"periph.io/x/periph/host/rpi"
)
func main() {
// Load all the drivers:
if _, err := host.Init(); err != nil {
log.Fatal(err)
}
t := time.NewTicker(500 * time.Millisecond)
for l := gpio.Low; ; l = !l {
// Lookup a pin by its location on the board:
if err := rpi.P1_33.Out(l); err != nil {
log.Fatal(err)
}
<-t.C
}
}
Also you need a button for your demo: https://periph.io/device/button/
package main
import (
"fmt"
"log"
"periph.io/x/periph/conn/gpio"
"periph.io/x/periph/conn/gpio/gpioreg"
"periph.io/x/periph/host"
)
func main() {
// Load all the drivers:
if _, err := host.Init(); err != nil {
log.Fatal(err)
}
// Lookup a pin by its number:
p := gpioreg.ByName("GPIO2")
if p == nil {
log.Fatal("Failed to find GPIO2")
}
fmt.Printf("%s: %s\n", p, p.Function())
// Set it as input, with an internal pull down resistor:
if err = p.In(gpio.PullDown, gpio.BothEdges); err != nil {
log.Fatal(err)
}
// Wait for edges as detected by the hardware, and print the value read:
for {
p.WaitForEdge(-1)
fmt.Printf("-> %s\n", p.Read())
}
}
can i get access to slack ?
Have you been in the kubedge slack workspace? can ping me xufei
@joeblew99
no because i dont have an invite to that slack workspace. I cant ping you because i dont have an invite to slack.
@joeblew99 This is the invite link. Thanks for join :)
thanks !
@joeblew99 any update for this?
The code here https://github.com/kubeedge/examples/blob/master/led-raspberrypi/light_driver/light_driver.go
can be upgraded to use periph here: https://github.com/google/periph
It now supports rasp pi v4 rasp pi v4 has a new Virtualisation instruction set ISA and so is muh faster running docker machines also btw.