2024-03-30 18:31:00 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-03-30 18:33:19 +01:00
|
|
|
"github.com/rileys-trash-can/rs8"
|
2024-03-30 18:31:00 +01:00
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
if len(os.Args) < 2 {
|
|
|
|
log.Fatalf("Usage: log <serial>")
|
|
|
|
}
|
|
|
|
|
|
|
|
port := os.Args[1]
|
2024-03-30 18:33:19 +01:00
|
|
|
conn, err := rs8.Open(port)
|
2024-03-30 18:31:00 +01:00
|
|
|
if err != nil {
|
|
|
|
log.Fatalf("Failed to connect: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
conn.InitBlynk()
|
|
|
|
|
|
|
|
ch := conn.ReadCh()
|
|
|
|
|
|
|
|
for {
|
|
|
|
e := <-ch
|
|
|
|
|
|
|
|
switch event := e.(type) {
|
2024-03-30 18:33:19 +01:00
|
|
|
case *rs8.EventButton:
|
2024-03-30 18:31:00 +01:00
|
|
|
log.Printf("%T %#v", event, event)
|
|
|
|
|
2024-03-30 18:33:19 +01:00
|
|
|
case *rs8.EventSlider:
|
2024-03-30 18:31:00 +01:00
|
|
|
log.Printf("%X %3d", event.Type, event.Value)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|