- fix PinPull optional configuration

This commit is contained in:
Thomas Vogl 2022-12-31 17:30:22 +01:00
parent 851e1c0ffb
commit 78c9247396
2 changed files with 12 additions and 10 deletions

View File

@ -9,7 +9,7 @@ type Pin struct {
Id int Id int
Name string Name string
Direction PinDirection Direction PinDirection
PullConfig PinPull PullConfig *PinPull
InitialState *PinCommand InitialState *PinCommand
PinHandle HardwarePinInterface PinHandle HardwarePinInterface
SendPollingEvents bool SendPollingEvents bool
@ -85,14 +85,16 @@ func (p *Pin) Configure() {
p.PinHandle.Detect(AnyEdge) p.PinHandle.Detect(AnyEdge)
if p.PullConfig == PullUp { if p.PullConfig != nil {
p.PinHandle.PullUp() if *p.PullConfig == PullUp {
} else if p.PullConfig == PullDown { p.PinHandle.PullUp()
p.PinHandle.PullDown() } else if *p.PullConfig == PullDown {
} else if p.PullConfig == PullOff { p.PinHandle.PullDown()
p.PinHandle.PullOff() } else if *p.PullConfig == PullOff {
} else { p.PinHandle.PullOff()
log.Errorf("unknown config value \"%s\" for pull-config", p.PullConfig) } else {
log.Errorf("unknown config value \"%s\" for pull-config", *p.PullConfig)
}
} }
} }

View File

@ -4,7 +4,7 @@ type PinConfig struct {
PinNumber int `yaml:"number"` PinNumber int `yaml:"number"`
Name string `yaml:"name"` Name string `yaml:"name"`
Direction PinDirection `yaml:"direction"` Direction PinDirection `yaml:"direction"`
PullConfig PinPull `yaml:"pull-config"` PullConfig *PinPull `yaml:"pull-config"`
InitialState *PinCommand `yaml:"initial-state"` InitialState *PinCommand `yaml:"initial-state"`
SendPollingEvents *bool `yaml:"send-polling-events"` SendPollingEvents *bool `yaml:"send-polling-events"`
SendChangeEvents *bool `yaml:"send-change-events"` SendChangeEvents *bool `yaml:"send-change-events"`