diff options
| author | Selene ToyKeeper | 2020-08-05 21:19:01 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2020-08-05 21:19:01 -0600 |
| commit | 649034122c619e4ad3dfa5582c37c8dd2522eecb (patch) | |
| tree | b2bcbd3ec6b66c0ee6cd8792888b9fde09bedcbe /spaghetti-monster | |
| parent | made a couple actions use blink_once() instead of blip(), for better consistency (diff) | |
| download | anduril-649034122c619e4ad3dfa5582c37c8dd2522eecb.tar.gz anduril-649034122c619e4ad3dfa5582c37c8dd2522eecb.tar.bz2 anduril-649034122c619e4ad3dfa5582c37c8dd2522eecb.zip | |
added support for 1-step ramps in stepped ramp mode
(uses the midpoint between floor and ceiling)
Diffstat (limited to 'spaghetti-monster')
| -rw-r--r-- | spaghetti-monster/anduril/ramp-mode.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/spaghetti-monster/anduril/ramp-mode.c b/spaghetti-monster/anduril/ramp-mode.c index 6c4b14e..6f6e5dc 100644 --- a/spaghetti-monster/anduril/ramp-mode.c +++ b/spaghetti-monster/anduril/ramp-mode.c @@ -201,6 +201,9 @@ uint8_t steady_state(Event event, uint16_t arg) { } else if (event == EV_tick) { + // un-reverse after 1 second + if (arg == TICKS_PER_SECOND) ramp_direction = 1; + #ifdef USE_SUNSET_TIMER // reduce output if shutoff timer is active if (sunset_timer) { @@ -213,9 +216,8 @@ uint8_t steady_state(Event event, uint16_t arg) { set_level_and_therm_target(dimmed_level); #endif } - #endif - // un-reverse after 1 second - if (arg == TICKS_PER_SECOND) ramp_direction = 1; + #endif // ifdef USE_SUNSET_TIMER + #ifdef USE_SET_LEVEL_GRADUALLY int16_t diff = gradual_target - actual_level; static uint16_t ticks_since_adjust = 0; @@ -404,13 +406,18 @@ uint8_t nearest_level(int16_t target) { // by allowing us to correct for numbers < 0 or > 255 in one central place uint8_t mode_min = ramp_floor; uint8_t mode_max = ramp_ceil; + uint8_t num_steps = ramp_stepss[1 + simple_ui_active]; + // special case for 1-step ramp... use halfway point between floor and ceiling + if (ramp_style && (1 == num_steps)) { + uint8_t mid = (mode_max + mode_min) >> 1; + return mid; + } if (target < mode_min) return mode_min; if (target > mode_max) return mode_max; // the rest isn't relevant for smooth ramping if (! ramp_style) return target; uint8_t ramp_range = mode_max - mode_min; - uint8_t num_steps = ramp_stepss[1 + simple_ui_active]; ramp_discrete_step_size = ramp_range / (num_steps-1); uint8_t this_level = mode_min; |
