diff --git a/demo/gpio2/main.go b/demo/gpio2/main.go new file mode 100644 index 0000000..c675f19 --- /dev/null +++ b/demo/gpio2/main.go @@ -0,0 +1,48 @@ +package main + +import ( + "fmt" + "game-driver/internal/routes/play/card_pusher" + "game-driver/logger" + "github.com/warthog618/go-gpiocdev/device/rpi" + "time" +) + +func main() { + logger.DefaultLogger() + defer logger.Sync() + + device, err := card_pusher.New(&card_pusher.LineGroup{ + Name: "gpiochip0", + OutOK: rpi.GPIO6, + Lower: rpi.GPIO13, + Error: rpi.GPIO19, + Empty: rpi.GPIO26, + Push: rpi.GPIO11, + Reset: rpi.GPIO22, + Pull: rpi.GPIO27, + }) + if err != nil { + fmt.Println("打开 GPIO 设备失败:", err) + return + } + defer device.Close() + + for { + var userInput string + fmt.Println("按 o/p/r 发送信号") + _, _ = fmt.Scanln(&userInput) + + if userInput == "o" { + device.PushCard() + } + if userInput == "p" { + device.PullCard() + } + if userInput == "r" { + device.Reset() + } + + time.Sleep(1 * time.Second) + } +} diff --git a/docs/继电器LH-04.zip b/docs/继电器LH-04.zip new file mode 100755 index 0000000..4782d55 Binary files /dev/null and b/docs/继电器LH-04.zip differ