diff options
Diffstat (limited to 'spaghetti-monster/fsm-ramping.c')
| -rw-r--r-- | spaghetti-monster/fsm-ramping.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/spaghetti-monster/fsm-ramping.c b/spaghetti-monster/fsm-ramping.c index 092c242..cc5f486 100644 --- a/spaghetti-monster/fsm-ramping.c +++ b/spaghetti-monster/fsm-ramping.c @@ -67,10 +67,12 @@ inline void set_level_gradually(uint8_t lvl) { // call this every frame or every few frames to change brightness very smoothly void gradual_tick() { // go by only one ramp level at a time instead of directly to the target - uint8_t gt = gradual_target - 1; + uint8_t gt = gradual_target; if (gt < actual_level) gt = actual_level - 1; else if (gt > actual_level) gt = actual_level + 1; + gt --; // convert 1-based number to 0-based + uint8_t target; #if PWM_CHANNELS >= 1 @@ -111,7 +113,7 @@ void gradual_tick() { #endif ) { - actual_level = gt; + actual_level = gt + 1; } } #endif |
