diff options
| author | Selene ToyKeeper | 2019-05-11 00:49:11 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2019-05-11 00:49:11 -0600 |
| commit | 55ba91304062deed35199b43c0d17b611218eec8 (patch) | |
| tree | 1fdf8995748be1298785c97813d2ce9d7f09e588 /spaghetti-monster/fsm-ramping.c | |
| parent | attempt to reduce mid-ramp "pop" (diff) | |
| parent | Increased default candle magnitude to better fit recent changes (diff) | |
| download | anduril-55ba91304062deed35199b43c0d17b611218eec8.tar.gz anduril-55ba91304062deed35199b43c0d17b611218eec8.tar.bz2 anduril-55ba91304062deed35199b43c0d17b611218eec8.zip | |
merged from lantern branch, to get candle mode updates
Diffstat (limited to 'spaghetti-monster/fsm-ramping.c')
| -rw-r--r-- | spaghetti-monster/fsm-ramping.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/spaghetti-monster/fsm-ramping.c b/spaghetti-monster/fsm-ramping.c index 6cdf5e6..ee816dd 100644 --- a/spaghetti-monster/fsm-ramping.c +++ b/spaghetti-monster/fsm-ramping.c @@ -25,9 +25,11 @@ void set_level(uint8_t level) { actual_level = level; + #ifdef USE_SET_LEVEL_GRADUALLY gradual_target = level; #endif + #ifdef USE_INDICATOR_LED #ifdef USE_INDICATOR_LED_WHILE_RAMPING if (! go_to_standby) @@ -40,6 +42,7 @@ void set_level(uint8_t level) { indicator_led(0); #endif #endif + //TCCR0A = PHASE; if (level == 0) { #if PWM_CHANNELS >= 1 @@ -56,6 +59,19 @@ void set_level(uint8_t level) { #endif } else { 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 + #if PWM_CHANNELS >= 1 PWM1_LVL = pgm_read_byte(pwm1_levels + level); #endif @@ -68,6 +84,8 @@ void set_level(uint8_t level) { #if PWM_CHANNELS >= 4 PWM4_LVL = pgm_read_byte(pwm4_levels + level); #endif + + #endif // ifdef USE_TINT_RAMPING } #ifdef USE_DYNAMIC_UNDERCLOCKING auto_clock_speed(); |
