aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSelene ToyKeeper2020-08-05 21:19:01 -0600
committerSelene ToyKeeper2020-08-05 21:19:01 -0600
commit649034122c619e4ad3dfa5582c37c8dd2522eecb (patch)
treeb2bcbd3ec6b66c0ee6cd8792888b9fde09bedcbe
parentmade a couple actions use blink_once() instead of blip(), for better consistency (diff)
downloadanduril-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)
-rw-r--r--spaghetti-monster/anduril/ramp-mode.c15
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;
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.