- fix RPI crash when changing state of output pin

(reason: DetectAnyEdge() was also configured for output pins)
- version string has now also build date
- updated golang dependencies
This commit is contained in:
2023-01-08 11:09:25 +01:00
parent 735087eb17
commit a450f3162b
7 changed files with 62 additions and 31 deletions

View File

@@ -70,22 +70,8 @@ func (p *Pin) Command(cmd PinCommand) error {
}
func (p *Pin) Configure() {
if p.Direction == Input {
log.Infof("configuring pin %s (pin no: %d) as Input", p.Name, p.Id)
p.PinHandle.Input()
} else if p.Direction == Output {
log.Infof("configuring pin %s (pin no: %d) as Output", p.Name, p.Id)
p.PinHandle.Output()
if p.InitialState != nil {
log.Infof("set initial state \"%s\" for pin %s (pin no: %d)", *p.InitialState, p.Name, p.Id)
_ = p.Command(*p.InitialState)
}
}
p.PinHandle.Detect(AnyEdge)
if p.PullConfig != nil {
log.Infof("configuring Pull Resistor for pin %s (pin no: %d) as %s", p.Name, p.Id, *p.PullConfig)
if *p.PullConfig == PullUp {
p.PinHandle.PullUp()
} else if *p.PullConfig == PullDown {
@@ -97,6 +83,18 @@ func (p *Pin) Configure() {
}
}
if p.Direction == Input {
log.Infof("configuring pin %s (pin no: %d) as Input", p.Name, p.Id)
p.PinHandle.Input()
p.PinHandle.Detect(AnyEdge)
} else if p.Direction == Output {
log.Infof("configuring pin %s (pin no: %d) as Output", p.Name, p.Id)
p.PinHandle.Output()
if p.InitialState != nil {
log.Infof("set initial state \"%s\" for pin %s (pin no: %d)", *p.InitialState, p.Name, p.Id)
_ = p.Command(*p.InitialState)
}
}
}
func (p *Pin) Changed() bool {