diff options
| -rw-r--r-- | spaghetti-monster/anduril/config-default.h | 3 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/load-save-config-fsm.h | 3 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/load-save-config.c | 6 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/off-mode.c | 5 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/ramp-mode.c | 30 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/ramp-mode.h | 13 |
6 files changed, 49 insertions, 11 deletions
diff --git a/spaghetti-monster/anduril/config-default.h b/spaghetti-monster/anduril/config-default.h index 1043253..4beb753 100644 --- a/spaghetti-monster/anduril/config-default.h +++ b/spaghetti-monster/anduril/config-default.h @@ -71,6 +71,9 @@ // smooth ramp speed: 1, 2, 3, 4, ... for 1X speed, 1/2, 1/3rd, 1/4th, ... #define USE_RAMP_SPEED_CONFIG +// add runtime option for whether hold-from-off should ramp or stay at moon +#define USE_RAMP_AFTER_MOON_OPTION + // short blip when crossing from "click" to "hold" from off // (helps the user hit moon mode exactly, instead of holding too long // or too short) diff --git a/spaghetti-monster/anduril/load-save-config-fsm.h b/spaghetti-monster/anduril/load-save-config-fsm.h index edd4ed5..a6d1281 100644 --- a/spaghetti-monster/anduril/load-save-config-fsm.h +++ b/spaghetti-monster/anduril/load-save-config-fsm.h @@ -40,6 +40,9 @@ typedef enum { simple_ui_steps_e, simple_ui_active_e, #endif + #ifdef USE_RAMP_AFTER_MOON_OPTION + dont_ramp_after_moon_e, + #endif #ifdef USE_MANUAL_MEMORY manual_memory_e, #ifdef USE_MANUAL_MEMORY_TIMER diff --git a/spaghetti-monster/anduril/load-save-config.c b/spaghetti-monster/anduril/load-save-config.c index 57638d6..f564187 100644 --- a/spaghetti-monster/anduril/load-save-config.c +++ b/spaghetti-monster/anduril/load-save-config.c @@ -42,6 +42,9 @@ void load_config() { ramp_stepss[2] = eeprom[simple_ui_steps_e]; simple_ui_active = eeprom[simple_ui_active_e]; #endif + #ifdef USE_RAMP_AFTER_MOON_OPTION + dont_ramp_after_moon = eeprom[dont_ramp_after_moon_e]; + #endif #ifdef USE_MANUAL_MEMORY manual_memory = eeprom[manual_memory_e]; #ifdef USE_MANUAL_MEMORY_TIMER @@ -111,6 +114,9 @@ void save_config() { eeprom[simple_ui_steps_e] = ramp_stepss[2]; eeprom[simple_ui_active_e] = simple_ui_active; #endif + #ifdef USE_RAMP_AFTER_MOON_OPTION + eeprom[dont_ramp_after_moon_e] = dont_ramp_after_moon; + #endif #ifdef USE_MANUAL_MEMORY eeprom[manual_memory_e] = manual_memory; #ifdef USE_MANUAL_MEMORY_TIMER diff --git a/spaghetti-monster/anduril/off-mode.c b/spaghetti-monster/anduril/off-mode.c index 6faad1c..bf4642c 100644 --- a/spaghetti-monster/anduril/off-mode.c +++ b/spaghetti-monster/anduril/off-mode.c @@ -106,6 +106,11 @@ uint8_t off_state(Event event, uint16_t arg) { #else // B_RELEASE_T or B_TIMEOUT_T set_level(nearest_level(1)); #endif + #ifdef USE_RAMP_AFTER_MOON_OPTION + if (dont_ramp_after_moon) { + return MISCHIEF_MANAGED; + } + #endif // don't start ramping immediately; // give the user time to release at moon level //if (arg >= HOLD_TIMEOUT) { // smaller diff --git a/spaghetti-monster/anduril/ramp-mode.c b/spaghetti-monster/anduril/ramp-mode.c index 2508d52..634d8f2 100644 --- a/spaghetti-monster/anduril/ramp-mode.c +++ b/spaghetti-monster/anduril/ramp-mode.c @@ -419,9 +419,9 @@ uint8_t steady_state(Event event, uint16_t arg) { return MISCHIEF_MANAGED; } else if (event == EV_click10_hold) { - #ifdef USE_MANUAL_MEMORY_TIMER - // let user configure timer for manual / hybrid memory - push_state(manual_memory_timer_config_state, 0); + #ifdef USE_RAMP_EXTRAS_CONFIG + // let user configure a bunch of extra ramp options + push_state(ramp_extras_config_state, 0); #else // manual mem, but no timer // turn off manual memory; go back to automatic if (0 == arg) { @@ -479,19 +479,31 @@ uint8_t simple_ui_config_state(Event event, uint16_t arg) { #endif #endif // #ifdef USE_RAMP_CONFIG -#ifdef USE_MANUAL_MEMORY_TIMER -void manual_memory_timer_config_save(uint8_t step, uint8_t value) { +#ifdef USE_RAMP_EXTRAS_CONFIG +void ramp_extras_config_save(uint8_t step, uint8_t value) { // item 1: disable manual memory, go back to automatic - if (step == 1) { manual_memory = 0; } + if (1 == step) { manual_memory = 0; } + + #ifdef USE_MANUAL_MEMORY_TIMER // item 2: set manual memory timer duration // FIXME: should be limited to (65535 / SLEEP_TICKS_PER_MINUTE) // to avoid overflows or impossibly long timeouts // (by default, the effective limit is 145, but it allows up to 255) - else { manual_memory_timer = value; } + else if (2 == step) { manual_memory_timer = value; } + #endif + + #ifdef USE_RAMP_AFTER_MOON_OPTION + // item 3: ramp up after hold-from-off for moon? + // 0 = yes, ramp after moon + // 1+ = no, stay at moon + else if (3 == step) { + dont_ramp_after_moon = value; + } + #endif } -uint8_t manual_memory_timer_config_state(Event event, uint16_t arg) { - return config_state_base(event, arg, 2, manual_memory_timer_config_save); +uint8_t ramp_extras_config_state(Event event, uint16_t arg) { + return config_state_base(event, arg, 3, ramp_extras_config_save); } #endif diff --git a/spaghetti-monster/anduril/ramp-mode.h b/spaghetti-monster/anduril/ramp-mode.h index 7c8b014..7ad244a 100644 --- a/spaghetti-monster/anduril/ramp-mode.h +++ b/spaghetti-monster/anduril/ramp-mode.h @@ -127,8 +127,11 @@ uint8_t simple_ui_config_state(Event event, uint16_t arg); #endif #endif -#if defined(USE_MANUAL_MEMORY) && defined(USE_MANUAL_MEMORY_TIMER) -uint8_t manual_memory_timer_config_state(Event event, uint16_t arg); +#if defined(USE_MANUAL_MEMORY_TIMER) || defined(USE_RAMP_AFTER_MOON_OPTION) || defined(USE_2C_STYLE_OPTION) || defined(USE_AUTO_SUNSET) +#define USE_RAMP_EXTRAS_CONFIG +#endif +#ifdef USE_RAMP_EXTRAS_CONFIG +uint8_t ramp_extras_config_state(Event event, uint16_t arg); #endif // calculate the nearest ramp level which would be valid at the moment @@ -171,6 +174,12 @@ uint8_t ramp_style = RAMP_STYLE; // 0 = smooth, 1 = discrete #ifdef USE_RAMP_SPEED_CONFIG #define ramp_speed (ramp_stepss[0]) #endif +#ifdef USE_RAMP_AFTER_MOON_OPTION +#ifndef DEFAULT_DONT_RAMP_AFTER_MOON +#define DEFAULT_DONT_RAMP_AFTER_MOON 0 +#endif +uint8_t dont_ramp_after_moon = DEFAULT_DONT_RAMP_AFTER_MOON; +#endif // current values, regardless of style uint8_t ramp_floor = RAMP_SMOOTH_FLOOR; uint8_t ramp_ceil = RAMP_SMOOTH_CEIL; |
