diff options
| author | Selene ToyKeeper | 2018-09-13 04:30:02 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2018-09-13 04:30:02 -0600 |
| commit | 4b93b02d6d966f4bda4ea90499601b52430c62f8 (patch) | |
| tree | 261467268a0a12c28c4b95dcadffb410c041704c | |
| parent | made tint ramping actually work (diff) | |
| download | anduril-4b93b02d6d966f4bda4ea90499601b52430c62f8.tar.gz anduril-4b93b02d6d966f4bda4ea90499601b52430c62f8.tar.bz2 anduril-4b93b02d6d966f4bda4ea90499601b52430c62f8.zip | |
fixed tint ramp brightness being off by one level,
and eliminated bias toward first PWM channel
| -rw-r--r-- | spaghetti-monster/fsm-ramping.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/spaghetti-monster/fsm-ramping.c b/spaghetti-monster/fsm-ramping.c index 0492943..ee816dd 100644 --- a/spaghetti-monster/fsm-ramping.c +++ b/spaghetti-monster/fsm-ramping.c @@ -26,15 +26,6 @@ void set_level(uint8_t level) { actual_level = level; - #ifdef USE_TINT_RAMPING - // calculate actual PWM levels based on a single-channel ramp - // and a global tint value - uint8_t brightness = pgm_read_byte(pwm1_levels + level); - uint8_t warm_PWM, cool_PWM; - cool_PWM = (uint16_t)tint * brightness / 255; - warm_PWM = brightness - cool_PWM; - #endif - #ifdef USE_SET_LEVEL_GRADUALLY gradual_target = level; #endif @@ -70,6 +61,13 @@ void set_level(uint8_t level) { level --; #ifdef USE_TINT_RAMPING + // calculate actual PWM levels based on a single-channel ramp + // and a global tint value + uint8_t brightness = pgm_read_byte(pwm1_levels + level); + uint8_t warm_PWM, cool_PWM; + cool_PWM = (((uint16_t)tint * (uint16_t)brightness) + 127) / 255; + warm_PWM = brightness - cool_PWM; + PWM1_LVL = warm_PWM; PWM2_LVL = cool_PWM; #else |
