|
|
|
@ -5,30 +5,18 @@ import (
|
|
|
|
|
"os"
|
|
|
|
|
"os/signal"
|
|
|
|
|
|
|
|
|
|
"github.com/davecheney/gpio"
|
|
|
|
|
"github.com/fulr/rfm69"
|
|
|
|
|
"github.com/kidoman/embd"
|
|
|
|
|
|
|
|
|
|
_ "github.com/kidoman/embd/host/rpi"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
log.Print("Start")
|
|
|
|
|
|
|
|
|
|
if err := embd.InitGPIO(); err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
defer embd.CloseGPIO()
|
|
|
|
|
|
|
|
|
|
gpio, err := embd.NewDigitalPin(25)
|
|
|
|
|
pin, err := gpio.OpenPin(gpio.GPIO25, gpio.ModeInput)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
defer gpio.Close()
|
|
|
|
|
|
|
|
|
|
if err := gpio.SetDirection(embd.In); err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
gpio.ActiveLow(false)
|
|
|
|
|
defer pin.Close()
|
|
|
|
|
|
|
|
|
|
spiBus, err := rfm69.NewSPIDevice()
|
|
|
|
|
if err != nil {
|
|
|
|
@ -36,7 +24,7 @@ func main() {
|
|
|
|
|
}
|
|
|
|
|
defer spiBus.Close()
|
|
|
|
|
|
|
|
|
|
rfm, err := rfm69.NewDevice(spiBus, gpio, 1, 10, true)
|
|
|
|
|
rfm, err := rfm69.NewDevice(spiBus, pin, 1, 10, true)
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Fatal(err)
|
|
|
|
|
}
|
|
|
|
@ -50,7 +38,7 @@ func main() {
|
|
|
|
|
quit := rfm.Loop()
|
|
|
|
|
|
|
|
|
|
sigint := make(chan os.Signal, 1)
|
|
|
|
|
signal.Notify(sigint, os.Interrupt)
|
|
|
|
|
signal.Notify(sigint, os.Interrupt, os.Kill)
|
|
|
|
|
|
|
|
|
|
for {
|
|
|
|
|
select {
|
|
|
|
|