Browse Source

added support for color correction

master
Giovanni Harting 1 year ago
parent
commit
eb2a0e7a98
3 changed files with 5 additions and 5 deletions
  1. +3
    -3
      main.go
  2. +1
    -1
      pca9685.go
  3. +1
    -1
      proto

+ 3
- 3
main.go View File

@@ -91,7 +91,7 @@ func (daemon *LedDaemon) receive() {
daemon.name = msg.MLedd.Name
log.Infof("Connection with %s established; backend registered", msg.MLedd.Name)
case *ledd.BackendWrapperMessage_MSetChannel:
for c, v := range msg.MSetChannel.NewChannelValues {
for c, v := range msg.MSetChannel.Values {
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
@@ -100,10 +100,10 @@ func (daemon *LedDaemon) receive() {
v = math.Pow(v, 1/readConfig.Pca9685.Gamma)

if pwm, ok := pwmMap[c]; ok {
pwm.setPercentage(float32(v * 100))
pwm.setPercentage(float32(v) * 100 * msg.MSetChannel.Correction[c])
} else {
pwmMap[c] = pca9685.NewPwm(int(c))
pwmMap[c].setPercentage(float32(v * 100))
pwm.setPercentage(float32(v) * 100 * msg.MSetChannel.Correction[c])
}
}
}


+ 1
- 1
pca9685.go View File

@@ -180,7 +180,7 @@ func (pwm *Pwm) setPercentage(percentage float32) error {
return errors.New(fmt.Sprintf("Percentage must be between 0.0 and 100.0. Got %v.", percentage))
}

pwm.pca.log.Info(fmt.Sprintf("Setting pwm #%v to %v%% at \"%v\" device.", pwm.pin, percentage, pwm.pca.name))
pwm.pca.log.Info(fmt.Sprintf("Setting pwm #%v to %v%% (%v) at \"%v\" device.", pwm.pin, percentage, uint16((percentage/100)*float32(pwm.pca.maxPulse)), pwm.pca.name))
pwm.pca.setPwm(pwm.pin, 0, uint16((percentage/100)*float32(pwm.pca.maxPulse)))

return nil


+ 1
- 1
proto

@@ -1 +1 @@
Subproject commit 3d37eb67b3f0ba5a411f0e7f50257f27a3d19c48
Subproject commit bb16464756d0abb4c147ef8f17eac8064342c2c9

Loading…
Cancel
Save