diff options
Diffstat (limited to '')
| -rw-r--r-- | spaghetti-monster/anduril/config-default.h | 1 | ||||
| -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 | 29 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/ramp-mode.c | 93 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/ramp-mode.h | 10 |
6 files changed, 95 insertions, 47 deletions
diff --git a/spaghetti-monster/anduril/config-default.h b/spaghetti-monster/anduril/config-default.h index 7670df4..9c194f9 100644 --- a/spaghetti-monster/anduril/config-default.h +++ b/spaghetti-monster/anduril/config-default.h @@ -97,6 +97,7 @@ // 2 = A2 style: Off 2C = ceil, On 2C = ceil, Ramped ceil 2C = turbo // All styles allow momentary turbo in advanced UI //#define DEFAULT_2C_STYLE 2 // default to Anduril 2 style +//#define DEFAULT_2C_STYLE_SIMPLE 0 // no turbo at all // make the ramps configurable by the user #define USE_RAMP_CONFIG diff --git a/spaghetti-monster/anduril/load-save-config-fsm.h b/spaghetti-monster/anduril/load-save-config-fsm.h index 5058f0c..894c344 100644 --- a/spaghetti-monster/anduril/load-save-config-fsm.h +++ b/spaghetti-monster/anduril/load-save-config-fsm.h @@ -39,6 +39,9 @@ typedef enum { simple_ui_ceil_e, simple_ui_steps_e, simple_ui_active_e, + #ifdef USE_2C_STYLE_CONFIG + ramp_2c_style_simple_e, + #endif #endif #ifdef USE_RAMP_AFTER_MOON_CONFIG dont_ramp_after_moon_e, diff --git a/spaghetti-monster/anduril/load-save-config.c b/spaghetti-monster/anduril/load-save-config.c index 439576f..ee451ac 100644 --- a/spaghetti-monster/anduril/load-save-config.c +++ b/spaghetti-monster/anduril/load-save-config.c @@ -41,6 +41,9 @@ void load_config() { ramp_ceils[2] = eeprom[simple_ui_ceil_e]; ramp_stepss[2] = eeprom[simple_ui_steps_e]; simple_ui_active = eeprom[simple_ui_active_e]; + #ifdef USE_2C_STYLE_CONFIG + ramp_2c_style_simple = eeprom[ramp_2c_style_simple_e]; + #endif #endif #ifdef USE_RAMP_AFTER_MOON_CONFIG dont_ramp_after_moon = eeprom[dont_ramp_after_moon_e]; @@ -116,6 +119,9 @@ void save_config() { eeprom[simple_ui_ceil_e] = ramp_ceils[2]; eeprom[simple_ui_steps_e] = ramp_stepss[2]; eeprom[simple_ui_active_e] = simple_ui_active; + #ifdef USE_2C_STYLE_CONFIG + eeprom[ramp_2c_style_simple_e] = ramp_2c_style_simple; + #endif #endif #ifdef USE_RAMP_AFTER_MOON_CONFIG eeprom[dont_ramp_after_moon_e] = dont_ramp_after_moon; diff --git a/spaghetti-monster/anduril/off-mode.c b/spaghetti-monster/anduril/off-mode.c index 5004e61..236ad7e 100644 --- a/spaghetti-monster/anduril/off-mode.c +++ b/spaghetti-monster/anduril/off-mode.c @@ -155,14 +155,29 @@ uint8_t off_state(Event event, uint16_t arg) { } // click, hold: momentary at ceiling or turbo else if (event == EV_click2_hold) { - #ifdef USE_SIMPLE_UI - if (simple_ui_active) { - set_level(nearest_level(MAX_LEVEL)); - } else + uint8_t turbo_level; // how bright is "turbo"? + + #if defined(USE_2C_STYLE_CONFIG) // user can choose 2C behavior + uint8_t style_2c = ramp_2c_style; + #ifdef USE_SIMPLE_UI + // simple UI has its own turbo config + if (simple_ui_active) style_2c = ramp_2c_style_simple; + #endif + // 0 = ceiling + // 1+ = full power + if (0 == style_2c) turbo_level = nearest_level(MAX_LEVEL); + else turbo_level = MAX_LEVEL; + #else + // simple UI: ceiling + // full UI: full power + #ifdef USE_SIMPLE_UI + if (simple_ui_active) turbo_level = nearest_level(MAX_LEVEL); + else + #endif + turbo_level = MAX_LEVEL; #endif - { - set_level(MAX_LEVEL); - } + + set_level(turbo_level); return MISCHIEF_MANAGED; } else if (event == EV_click2_hold_release) { diff --git a/spaghetti-monster/anduril/ramp-mode.c b/spaghetti-monster/anduril/ramp-mode.c index 4922e2c..31f959b 100644 --- a/spaghetti-monster/anduril/ramp-mode.c +++ b/spaghetti-monster/anduril/ramp-mode.c @@ -45,6 +45,43 @@ uint8_t steady_state(Event event, uint16_t arg) { if (ramp_style) { step_size = ramp_discrete_step_size; } else { step_size = 1; } + // how bright is "turbo"? + uint8_t turbo_level; + #if defined(USE_2C_STYLE_CONFIG) // user can choose 2C behavior + uint8_t style_2c = ramp_2c_style; + #ifdef USE_SIMPLE_UI + // simple UI has its own turbo config + if (simple_ui_active) style_2c = ramp_2c_style_simple; + #endif + // 0 = no turbo + // 1 = Anduril 1 direct to turbo + // 2 = Anduril 2 direct to ceiling, or turbo if already at ceiling + if (0 == style_2c) turbo_level = mode_max; + else if (1 == style_2c) turbo_level = MAX_LEVEL; + else { + if (memorized_level < mode_max) { turbo_level = mode_max; } + else { turbo_level = MAX_LEVEL; } + } + #elif defined(USE_2C_MAX_TURBO) // Anduril 1 style always + // simple UI: to/from ceiling + // full UI: to/from turbo (Anduril1 behavior) + #ifdef USE_SIMPLE_UI + if (simple_ui_active) turbo_level = mode_max; + else + #endif + turbo_level = MAX_LEVEL; + #else // Anduril 2 style always + // simple UI: to/from ceiling + // full UI: to/from ceiling if mem < ceiling, + // or to/from turbo if mem >= ceiling + if ((memorized_level < mode_max) + #ifdef USE_SIMPLE_UI + || simple_ui_active + #endif + ) { turbo_level = mode_max; } + else { turbo_level = MAX_LEVEL; } + #endif + #ifdef USE_SUNSET_TIMER // handle the shutoff timer first static uint8_t timer_orig_level = 0; @@ -100,42 +137,6 @@ uint8_t steady_state(Event event, uint16_t arg) { } // 2 clicks: go to/from highest level else if (event == EV_2clicks) { - uint8_t turbo_level; - #ifdef USE_2C_MAX_TURBO // Anduril 1 style always - // simple UI: to/from ceiling - // full UI: to/from turbo (Anduril1 behavior) - #ifdef USE_SIMPLE_UI - if (simple_ui_active) turbo_level = mode_max; - else - #endif - turbo_level = MAX_LEVEL; - #elif defined(USE_2C_STYLE_CONFIG) // user can choose A1 style or A2 style - #ifdef USE_SIMPLE_UI - // no turbo in simple UI yet (needs its own config) - if (simple_ui_active) turbo_level = mode_max; - else - #endif - // 0 = no turbo - // 1 = Anduril 1 direct to turbo - // 2 = Anduril 2 direct to ceiling, or turbo if already at ceiling - if (0 == ramp_2c_style) turbo_level = mode_max; - else if (1 == ramp_2c_style) turbo_level = MAX_LEVEL; - else { - if (memorized_level < mode_max) { turbo_level = mode_max; } - else { turbo_level = MAX_LEVEL; } - } - #else // Anduril 2 style always - // simple UI: to/from ceiling - // full UI: to/from ceiling if mem < ceiling, - // or to/from turbo if mem >= ceiling - if ((memorized_level < mode_max) - #ifdef USE_SIMPLE_UI - || simple_ui_active - #endif - ) { turbo_level = mode_max; } - else { turbo_level = MAX_LEVEL; } - #endif - if (actual_level < turbo_level) { set_level_and_therm_target(turbo_level); } @@ -395,7 +396,7 @@ uint8_t steady_state(Event event, uint16_t arg) { // 3H: momentary turbo (on lights with no tint ramping) else if (event == EV_click3_hold) { if (! arg) { // first frame only, to allow thermal regulation to work - set_level_and_therm_target(MAX_LEVEL); + set_level_and_therm_target(turbo_level); } return MISCHIEF_MANAGED; } @@ -462,6 +463,15 @@ void ramp_config_save(uint8_t step, uint8_t value) { if (current_state == simple_ui_config_state) style = 2; #endif + #if defined(USE_SIMPLE_UI) && defined(USE_2C_STYLE_CONFIG) + // simple UI config is weird... + // has some ramp extras after floor/ceil/steps + if (4 == step) { + ramp_2c_style_simple = value; + } + else + #endif + // save adjusted value to the correct slot if (value) { // ceiling value is inverted @@ -489,7 +499,14 @@ uint8_t ramp_config_state(Event event, uint16_t arg) { #ifdef USE_SIMPLE_UI uint8_t simple_ui_config_state(Event event, uint16_t arg) { - return config_state_base(event, arg, 3, ramp_config_save); + #if defined(USE_2C_STYLE_CONFIG) + #define SIMPLE_UI_NUM_MENU_ITEMS 4 + #else + #define SIMPLE_UI_NUM_MENU_ITEMS 3 + #endif + return config_state_base(event, arg, + SIMPLE_UI_NUM_MENU_ITEMS, + ramp_config_save); } #endif #endif // #ifdef USE_RAMP_CONFIG diff --git a/spaghetti-monster/anduril/ramp-mode.h b/spaghetti-monster/anduril/ramp-mode.h index 242d7aa..bba6d96 100644 --- a/spaghetti-monster/anduril/ramp-mode.h +++ b/spaghetti-monster/anduril/ramp-mode.h @@ -166,8 +166,14 @@ uint8_t manual_memory_timer = DEFAULT_MANUAL_MEMORY_TIMER; #endif #endif #ifdef USE_SIMPLE_UI -// whether to enable the simplified interface or not -uint8_t simple_ui_active = SIMPLE_UI_ACTIVE; + // whether to enable the simplified interface or not + uint8_t simple_ui_active = SIMPLE_UI_ACTIVE; + #ifdef USE_2C_STYLE_CONFIG + #ifndef DEFAULT_2C_STYLE_SIMPLE + #define DEFAULT_2C_STYLE_SIMPLE 0 + #endif + uint8_t ramp_2c_style_simple = DEFAULT_2C_STYLE_SIMPLE; // 0 = no turbo, 1 = A1 style, 2 = A2 style + #endif #endif // smooth vs discrete ramping uint8_t ramp_style = RAMP_STYLE; // 0 = smooth, 1 = discrete |
