added more debug out and channel max logic
This commit is contained in:
10
main.go
10
main.go
@@ -18,7 +18,7 @@ import (
|
||||
// CONSTANTS
|
||||
|
||||
const VERSION = "0.1"
|
||||
const RESOLUTION = 4096
|
||||
const RESOLUTION = 4095
|
||||
const CHANNEL = 16
|
||||
|
||||
// STRUCTS
|
||||
@@ -88,7 +88,13 @@ func (daemon *LedDaemon) receive() {
|
||||
daemon.name = msg.MLedd.Name
|
||||
log.Infof("Connection with %s etablished; backend registered", msg.MLedd.Name)
|
||||
case *ledd.BackendWrapperMessage_MSetChannel:
|
||||
log.Debug(msg.MSetChannel.NewChannelValues)
|
||||
for c, v := range msg.MSetChannel.NewChannelValues {
|
||||
if c > CHANNEL {
|
||||
log.Warningf("[%s] Channel index %d is higher then this device's max channel index %d. Skipping.", daemon.name, c, CHANNEL)
|
||||
continue
|
||||
}
|
||||
|
||||
if pwm, ok := pwmMap[c]; ok {
|
||||
pwm.setPercentage(float32(v) / RESOLUTION * 100)
|
||||
} else {
|
||||
@@ -141,7 +147,7 @@ func main() {
|
||||
pca9685 = createPCA9685(i2cDevice, config.Name, config.Pca9685.MinPulse, config.Pca9685.MaxPulse, logging.MustGetLogger("PCA9685"))
|
||||
pca9685.Init()
|
||||
|
||||
pwmMap = make(map[int32]*Pwm, 1)
|
||||
pwmMap = make(map[int32]*Pwm, 0)
|
||||
|
||||
conn, err := net.Dial("tcp4", fmt.Sprintf("%s:%d", config.Ledd.Host, config.Ledd.Port))
|
||||
check(err)
|
||||
|
Reference in New Issue
Block a user