From 5f6bb2bda2dd4eccbdfba94e5d35cedc8c0c42dc Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Tue, 25 Apr 2023 01:07:15 -0600 Subject: updated D4Sv2-tintramp -> Emisar 2-channel build target ... ... and reworked how gradual_tick() works ... and updated LT1S Pro to use new method --- spaghetti-monster/fsm-ramping.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'spaghetti-monster/fsm-ramping.c') 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; + } } -- cgit v1.2.3