crazy shit.
This commit is contained in:
1 parent
d57a00bbc8
commit
7bf9a0398f
356 files changed
+196503
-3
No files matched your search
@@ -1,18 +1,25 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"periph.io/x/conn/v3/gpio"
|
||||
"periph.io/x/host/v3"
|
||||
"periph.io/x/host/v3/orangepi/zero3"
|
||||
"time"
|
||||
)
|
||||
|
||||
func init() {
|
||||
log.SetFormatter(&log.JSONFormatter{})
|
||||
log.SetLevel(log.DebugLevel)
|
||||
}
|
||||
|
||||
func blinkLight(d time.Duration, pin gpio.PinIO) {
|
||||
t := time.NewTicker(d)
|
||||
for {
|
||||
log.WithField("pin", pin.String()).Debug("Turning ON")
|
||||
pin.Out(true)
|
||||
<-t.C
|
||||
log.WithField("pin", pin.String()).Debug("Turning OFF")
|
||||
pin.Out(false)
|
||||
<-t.C
|
||||
}
|
||||
@@ -20,10 +27,11 @@ func blinkLight(d time.Duration, pin gpio.PinIO) {
|
||||
|
||||
func main() {
|
||||
s, err := host.Init()
|
||||
log.Infof("hello wprld")
|
||||
if err != nil {
|
||||
fmt.Printf("%s", err)
|
||||
log.Fatal("periph not loaded", err)
|
||||
} else {
|
||||
fmt.Printf("OK: %s\n\n", s.Loaded)
|
||||
log.Infof("periph loaded with", s.Loaded)
|
||||
}
|
||||
|
||||
go blinkLight(500*time.Millisecond, zero3.PA1_3)
|
||||
|
||||
Reference in new issue
Block a user