diff options
| author | Selene ToyKeeper | 2019-05-14 00:25:18 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2019-05-14 00:25:18 -0600 |
| commit | a337ca16cf33f9e7e0747a1ea0af53930ec47318 (patch) | |
| tree | a3008180eb2eec89f1e4087e02680c00452b4b4e /spaghetti-monster/fsm-ramping.c | |
| parent | made tint ramping blink at ends of ramp, made lantern default to stepped mode... (diff) | |
| download | anduril-a337ca16cf33f9e7e0747a1ea0af53930ec47318.tar.gz anduril-a337ca16cf33f9e7e0747a1ea0af53930ec47318.tar.bz2 anduril-a337ca16cf33f9e7e0747a1ea0af53930ec47318.zip | |
added auto-tint modes, refactored some indicator blinks into "blip()", enabled blink at ceiling for lantern
Diffstat (limited to 'spaghetti-monster/fsm-ramping.c')
| -rw-r--r-- | spaghetti-monster/fsm-ramping.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/spaghetti-monster/fsm-ramping.c b/spaghetti-monster/fsm-ramping.c index ee816dd..27e3876 100644 --- a/spaghetti-monster/fsm-ramping.c +++ b/spaghetti-monster/fsm-ramping.c @@ -65,7 +65,19 @@ void set_level(uint8_t level) { // 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; + + // auto-tint modes + uint8_t mytint; + // linear with power level + //if (tint == 0) { mytint = brightness; } + //else if (tint == 255) { mytint = 255 - brightness; } + // perceptual by ramp level + if (tint == 0) { mytint = 255 * (uint16_t)level / RAMP_SIZE; } + else if (tint == 255) { mytint = 255 - (255 * (uint16_t)level / RAMP_SIZE); } + // stretch 1-254 to fit 0-255 range + else { mytint = (tint * 100 / 99) - 1; } + + cool_PWM = (((uint16_t)mytint * (uint16_t)brightness) + 127) / 255; warm_PWM = brightness - cool_PWM; PWM1_LVL = warm_PWM; |
