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)
	}
}
