使用设计模式优化发卡机

This commit is contained in:
2024-11-20 13:54:05 +08:00
parent 480e9ab6d5
commit 4ea0af5bd7
8 changed files with 249 additions and 105 deletions

View File

@@ -0,0 +1,35 @@
package card_device
import (
"fmt"
"github.com/warthog618/go-gpiocdev/device/rpi"
)
type outGpioLine int
const (
PushLine outGpioLine = rpi.GPIO11
ResetLine outGpioLine = rpi.GPIO22
PullLine outGpioLine = rpi.GPIO27
)
func (g outGpioLine) String() string {
switch g {
case PushLine:
return "PushLine"
case ResetLine:
return "ResetLine"
case PullLine:
return "PullLine"
default:
return fmt.Sprint(int(g))
}
}
func allOutGpio() []outGpioLine {
return []outGpioLine{PushLine, ResetLine, PullLine}
}
func allOutGpioInt() []int {
return []int{int(PushLine), int(ResetLine), int(PullLine)}
}