- add Makefile

- improve README.md
- smaller fixes regarding configuration
This commit is contained in:
2022-12-31 17:04:35 +01:00
parent 586a657674
commit e8c46c43f6
14 changed files with 216 additions and 41 deletions

View File

@@ -10,7 +10,7 @@ type Pin struct {
Name string
Direction PinDirection
PullConfig PinPull
InitialState PinCommand
InitialState *PinCommand
PinHandle HardwarePinInterface
SendPollingEvents bool
SendChangeEvents bool
@@ -37,11 +37,7 @@ func NewPin(config PinConfig) Pin {
p.SendChangeEvents = true
}
if config.InitialState != "" {
p.InitialState = PinCommand(config.InitialState)
} else {
p.InitialState = Off
}
p.InitialState = config.InitialState
return p
}
@@ -80,8 +76,11 @@ func (p *Pin) Configure() {
} else if p.Direction == Output {
log.Infof("configuring pin %s (pin no: %d) as Output", p.Name, p.Id)
p.PinHandle.Output()
log.Infof("set initial state \"%s\" for pin %s (pin no: %d)", p.InitialState, p.Name, p.Id)
_ = p.Command(p.InitialState)
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)
@@ -92,6 +91,8 @@ func (p *Pin) Configure() {
p.PinHandle.PullDown()
} else if p.PullConfig == PullOff {
p.PinHandle.PullOff()
} else {
log.Errorf("unknown config value \"%s\" for pull-config", p.PullConfig)
}
}