aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster/fsm-ramping.c
diff options
context:
space:
mode:
Diffstat (limited to 'spaghetti-monster/fsm-ramping.c')
-rw-r--r--spaghetti-monster/fsm-ramping.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/spaghetti-monster/fsm-ramping.c b/spaghetti-monster/fsm-ramping.c
index 280e4b3..393c425 100644
--- a/spaghetti-monster/fsm-ramping.c
+++ b/spaghetti-monster/fsm-ramping.c
@@ -398,9 +398,20 @@ inline void set_level_gradually(uint8_t lvl) {
// call this every frame or every few frames to change brightness very smoothly
void gradual_tick() {
+ uint8_t gt = gradual_target;
+ if (gt < actual_level) gt = actual_level - 1;
+ else if (gt > actual_level) gt = actual_level + 1;
+ gt --;
+
// call the relevant hardware-specific function
GradualTickFuncPtr gradual_tick_func = gradual_tick_modes[CH_MODE];
- gradual_tick_func();
+ bool done = gradual_tick_func(gt);
+
+ if (done) {
+ uint8_t orig = gradual_target;
+ set_level(gt + 1);
+ gradual_target = orig;
+ }
}