aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster
diff options
context:
space:
mode:
authorSelene ToyKeeper2018-09-13 04:30:02 -0600
committerSelene ToyKeeper2018-09-13 04:30:02 -0600
commit4b93b02d6d966f4bda4ea90499601b52430c62f8 (patch)
tree261467268a0a12c28c4b95dcadffb410c041704c /spaghetti-monster
parentmade tint ramping actually work (diff)
downloadanduril-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
Diffstat (limited to 'spaghetti-monster')
-rw-r--r--spaghetti-monster/fsm-ramping.c16
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
If you find this content useful please consider a small donation via bitcoin: bitcoin:1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2?amount=0.001&message=Donation Scraping git contents via cgit is very resource intensive. The continued hosting of these git repositories is entirely financed by your bitcoin contributions. For donations of a least 1 mBTC you include your IP address in the message of your bitcoin donation. This will remove this message in the future for requests from your IP, which will significantly reduce token usage. In any case, any contributions to bitcoin address 1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2 are very welcome. Thanks in advance for you contribution to a self-sustaining ecosystem.