- add Makefile
- improve README.md - smaller fixes regarding configuration
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user