将指针配置name也设定为可配置
This commit is contained in:
@@ -19,7 +19,8 @@ aliyun:
|
||||
game:
|
||||
maxTimeout: 60 # 单位 s
|
||||
cardGroups:
|
||||
- outOK: 6
|
||||
- name: gpiochip0
|
||||
outOK: 6
|
||||
lower: 13
|
||||
error: 19
|
||||
empty: 26
|
||||
|
||||
@@ -123,12 +123,12 @@ func (d *Device) GetEmpty() int {
|
||||
return d.status[d.lines.Empty].Get()
|
||||
}
|
||||
|
||||
func New(name string, lines *LineGroup) (*Device, error) {
|
||||
func New(lines *LineGroup) (*Device, error) {
|
||||
if !lines.Ok() {
|
||||
return nil, fmt.Errorf("针脚配置错误")
|
||||
}
|
||||
|
||||
chip, err := gpiocdev.NewChip(name, gpiocdev.AsActiveLow)
|
||||
chip, err := gpiocdev.NewChip(lines.Name, gpiocdev.AsActiveLow)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("打开 GPIO 设备失败: %w", err)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package card_device
|
||||
|
||||
type LineGroup struct {
|
||||
Name string
|
||||
OutOK int
|
||||
Lower int
|
||||
Error int
|
||||
|
||||
@@ -28,7 +28,7 @@ func PushCard(ctx context.Context) leaf.HandlerFunc {
|
||||
gv, _ := json.Marshal(group)
|
||||
zap.S().Info("发卡指针初始化:", string(gv))
|
||||
|
||||
device, err := card_device.New("gpiochip0", group)
|
||||
device, err := card_device.New(group)
|
||||
if err != nil {
|
||||
zap.S().Panicln("初始化发卡器失败: ", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user