diff options
| author | Selene ToyKeeper | 2021-08-31 23:04:00 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2021-08-31 23:04:00 -0600 |
| commit | d1854a36d7cc53e757a1b4d2f214295c720b01b4 (patch) | |
| tree | 10c85b219c1ba5cab150907a08b230223ade6c75 | |
| parent | made it possible to use autolock in simple UI (diff) | |
| parent | fixed builds which failed to compile after recent changes (diff) | |
| download | anduril-d1854a36d7cc53e757a1b4d2f214295c720b01b4.tar.gz anduril-d1854a36d7cc53e757a1b4d2f214295c720b01b4.tar.bz2 anduril-d1854a36d7cc53e757a1b4d2f214295c720b01b4.zip | |
merged in a bunch of new features...
+ runtime option for smooth ramp speed
+ runtime option for whether hold-from-off should ramp up or stay at the floor
+ runtime option to select turbo style / 2C style in Advanced UI
+ same thing, but for Simple UI
* sped up the auto-reverse timing window; it was too slow
| -rw-r--r-- | spaghetti-monster/anduril/anduril-manual.txt | 84 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/candle-mode.c | 2 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-ff-rot66.h | 2 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-gchart-fet1-t1616.h | 2 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h | 4 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-sofirn-sp10s.h | 2 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/config-default.h | 17 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/hank-cfg.h | 2 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/load-save-config-fsm.h | 24 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/load-save-config.c | 48 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/off-mode.c | 34 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/ramp-mode-fsm.h | 2 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/ramp-mode.c | 149 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/ramp-mode.h | 41 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/strobe-modes.c | 2 |
15 files changed, 320 insertions, 95 deletions
diff --git a/spaghetti-monster/anduril/anduril-manual.txt b/spaghetti-monster/anduril/anduril-manual.txt index 74ca0c7..ef0ad5f 100644 --- a/spaghetti-monster/anduril/anduril-manual.txt +++ b/spaghetti-monster/anduril/anduril-manual.txt @@ -51,8 +51,8 @@ light to someone else, or if you just don't want to bother with any crazy disco modes. Simple UI has all the basic functions needed to work as a flashlight, -but the minimum and maximum brightness are limited to make it safer, and -any complex or advanced functions are blocked. +but the minimum and maximum brightness are limited by default to make it +safer, and any complex or advanced functions are blocked. Functions available in Simple UI include: @@ -112,6 +112,29 @@ counting it like music to make it easier: Simple UI is enabled after each factory reset. +Simple UI can be configured in several ways, but not while Simple UI is +active. So go to the Advanced UI, configure things, then go back to +Simple UI. + +Configurable options include: + + - floor level + - ceiling level + - number of steps (in stepped ramp) + - turbo style + +Other options are inherited from Advanced UI: + + - ramp style (smooth / stepped) + - smooth ramp speed + - ramp-after-moon style + - memory settings + - auto-lock settings + - aux LED settings + - voltage calibration + - thermal regulation settings + - hardware-specific "misc menu" settings + Advanced UI ----------- @@ -168,15 +191,30 @@ While the light is on, a few actions are available: - 7H: Ramp config menu. - Item 1: Floor level. - Item 2: Ceiling level. - - Item 3: Number of steps (except for smooth ramp). + - Item 3: + Stepped ramp: Number of steps. Can be 1 to 150. + Smooth ramp: Ramp speed. + 1 = Full speed, ~2.5s from end to end. + 2 = Half speed, ~5s from end to end. + 3 = Third speed, ~7.5s. + 4 = Quarter speed, ~10s. - 10C: Activate manual memory and save the current brightness. - - 10H: Manual memory config menu. + - 10H: Ramp extras config menu. - Item 1: Disable manual memory and go back to automatic memory. (doesn't matter what value the user enters at the prompt) - Item 2: Configure the manual memory timer. Sets the timer to N minutes, where N is the number of clicks. A value of 0 (no clicks) turns the timer off. + - Item 3: Configure whether to ramp up after "Off -> 1H". + 0: Ramp up after moon. + 1: Don't ramp up, just stay at the floor level. + - Item 4: Configure Advanced UI's turbo style: + 0: No turbo, only ceiling. + 1: Anduril 1 style. Ramp -> 2C goes to full power. + 2: Anduril 2 style. Ramp -> 2C goes to ceiling, + or goes to full power if user ramped up to ceiling first. + This value also affects momentary turbo in Ramp and Off modes. Memory determines which brightness level the light goes to with 1 click from off. There are three types of brightness memory to choose from: @@ -240,6 +278,7 @@ more than 2 times when the light is off: - 4C: Lockout mode. - 5C: Momentary mode. - 7C / 7H: Aux LED configuration. + - 9H: Misc configuration menu. (only on some lights) - 10H: Simple UI configuration menu. - 13H: Factory reset (on some lights). - 15C or more: Version check. @@ -508,10 +547,11 @@ final click) to access the config menu for the current ramp. Or, to access the ramp config for Simple UI, make sure the Simple UI is not active, then do a 10H action from Off. -For smooth ramping mode, there are two menu options: +For smooth ramping mode, there are three menu options: 1. Floor. (default = 1/150) 2. Ceiling. (default = 120/150) + 3. Ramp speed. (default = 1, fastest speed) For the stepped ramping mode, there are three menu options: @@ -519,12 +559,13 @@ For the stepped ramping mode, there are three menu options: 2. Ceiling. (default = 120/150) 3. Number of steps. (default = 7) -For the Simple UI mode, there are three menu options. They are the same -as stepped ramping mode. +For the Simple UI mode, there are four menu options. The first three +are the same as stepped ramping mode. 1. Floor. (default = 20/150) 2. Ceiling. (default = 120/150) 3. Number of steps. (default = 5) + 4. Turbo style. (default = 0, no turbo) Default values are different for each model of flashlight. The numbers above are only examples. @@ -639,17 +680,12 @@ when the main emitters are on, and when the light is otherwise awake. The aux LEDs on most lights only turn on when the light is asleep. -Global Config Menu ------------------- +Misc Config Menu +---------------- Some models may have an extra config menu for settings which don't fit anywhere else. These settings are, in order: - - 2C style: (not yet implemented) - - 1: 2C goes to turbo (Anduril V1 style) - 2: 2C goes to ramp ceiling (Anduril V2 style) - - Jump Start level: Some lights are prone to starting up slowly at low levels, so they @@ -657,9 +693,9 @@ anywhere else. These settings are, in order: level for a few milliseconds when changing from off to a low level. This setting specifies how bright that pulse should be. - The value can be from 1 to 150, but is usually between 10 and 30. + The value can be from 1 to 150, but is usually between 20 and 50. -Some settings are hardware-specific and may not be present on all +These settings are hardware-specific and may not be present on all lights. The number of settings in the global menu depends on the hardware model and the firmware version. @@ -705,10 +741,14 @@ Off Any 4C Lockout mode Off Full 5C Momentary mode Off Full 7C Aux LEDs: Next pattern Off Full 7H Aux LEDs: Next color -Off Full 9H Global config menu +Off Full 9H Misc config menu (varies per light) Off Full 10C Enable Simple UI Off Simple 10H Disable Simple UI -Off Full 10H Simple UI ramp config menu (1: floor, 2: ceiling, [3: steps]) +Off Full 10H Simple UI ramp config menu: + 1: floor + 2: ceiling + 3: steps + 4: turbo style Off Any 13H Factory reset (on some lights) Off Any 15+C Version check @@ -723,9 +763,13 @@ Ramp Full 3H Momentary turbo (on lights without tint ramping) Ramp Any 4C Lockout mode Ramp Full 5C Momentary mode Ramp Full 5H Sunset timer on, and add 5 minutes -Ramp Full 7H Ramp config menu (1: floor, 2: ceiling, [3: steps]) +Ramp Full 7H Ramp config menu (1: floor, 2: ceiling, 3: speed/steps) Ramp Full 10C Turn on manual memory and save current brightness -Ramp Full 10H Manual memory config menu (1: off, 2: set timeout) +Ramp Full 10H Ramp Extras config menu: + 1: enable automatic mem + 2: set manual mem timeout + 3: ramp after moon or not + 4: advanced UI turbo style Lockout Any 1C/1H Momentary moon (lowest floor) Lockout Any 2C/2H Momentary moon (highest floor, or manual mem level) diff --git a/spaghetti-monster/anduril/candle-mode.c b/spaghetti-monster/anduril/candle-mode.c index 3704ee6..d15195e 100644 --- a/spaghetti-monster/anduril/candle-mode.c +++ b/spaghetti-monster/anduril/candle-mode.c @@ -98,7 +98,7 @@ uint8_t candle_mode_state(Event event, uint16_t arg) { // clock tick: animate candle brightness else if (event == EV_tick) { // un-reverse after 1 second - if (arg == TICKS_PER_SECOND) ramp_direction = 1; + if (arg == AUTO_REVERSE_TIME) ramp_direction = 1; // 3-oscillator synth for a relatively organic pattern uint8_t add; diff --git a/spaghetti-monster/anduril/cfg-ff-rot66.h b/spaghetti-monster/anduril/cfg-ff-rot66.h index 652c98b..7e21fe7 100644 --- a/spaghetti-monster/anduril/cfg-ff-rot66.h +++ b/spaghetti-monster/anduril/cfg-ff-rot66.h @@ -41,3 +41,5 @@ #undef BLINK_AT_RAMP_MIDDLE #undef BLINK_AT_RAMP_CEIL +// too big, remove stuff to make room +#undef USE_RAMP_AFTER_MOON_CONFIG diff --git a/spaghetti-monster/anduril/cfg-gchart-fet1-t1616.h b/spaghetti-monster/anduril/cfg-gchart-fet1-t1616.h index 192307e..9036d26 100644 --- a/spaghetti-monster/anduril/cfg-gchart-fet1-t1616.h +++ b/spaghetti-monster/anduril/cfg-gchart-fet1-t1616.h @@ -32,4 +32,4 @@ #define THERM_FASTER_LEVEL 105 // enable 2 click turbo -#define USE_2C_MAX_TURBO +#define DEFAULT_2C_STYLE 1 diff --git a/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h b/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h index de5da88..962317e 100644 --- a/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h +++ b/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h @@ -50,3 +50,7 @@ #define THERM_FASTER_LEVEL 130 // throttle back faster when high + + +// too big, remove stuff to make room +#undef USE_RAMP_SPEED_CONFIG diff --git a/spaghetti-monster/anduril/cfg-sofirn-sp10s.h b/spaghetti-monster/anduril/cfg-sofirn-sp10s.h index 99ed17d..06720b6 100644 --- a/spaghetti-monster/anduril/cfg-sofirn-sp10s.h +++ b/spaghetti-monster/anduril/cfg-sofirn-sp10s.h @@ -25,4 +25,4 @@ #define THERM_FASTER_LEVEL 105 // enable 2 click turbo -#define USE_2C_MAX_TURBO +#define DEFAULT_2C_STYLE 1 diff --git a/spaghetti-monster/anduril/config-default.h b/spaghetti-monster/anduril/config-default.h index a50be5d..5b9897c 100644 --- a/spaghetti-monster/anduril/config-default.h +++ b/spaghetti-monster/anduril/config-default.h @@ -68,6 +68,15 @@ // default ramp style: 0 = smooth, 1 = stepped #define RAMP_STYLE 0 +// smooth ramp speed: 1, 2, 3, 4, ... for 1X speed, 1/2, 1/3rd, 1/4th, ... +#define USE_RAMP_SPEED_CONFIG + +// after ramping, how long until the direction resets to "up"? +#define AUTO_REVERSE_TIME (TICKS_PER_SECOND * 2 / 3) + +// add runtime option for whether hold-from-off should ramp or stay at moon +#define USE_RAMP_AFTER_MOON_CONFIG + // 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) @@ -84,6 +93,14 @@ // - Ramp 2C goes to ceiling, unless already at ceiling or in simple UI. // (Advanced UI ceiling 2C goes to turbo) //#define USE_2C_MAX_TURBO +// Or uncomment to let the user decide which style they want: +#define USE_2C_STYLE_CONFIG +// 0 = no turbo +// 1 = A1 style: Off 2C = ceil, On 2C = turbo +// 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/hank-cfg.h b/spaghetti-monster/anduril/hank-cfg.h index b55404f..11eb0a1 100644 --- a/spaghetti-monster/anduril/hank-cfg.h +++ b/spaghetti-monster/anduril/hank-cfg.h @@ -16,6 +16,6 @@ // double click while on goes to full-power turbo, not ramp ceiling -#define USE_2C_MAX_TURBO +#define DEFAULT_2C_STYLE 1 #endif // ifndef HANK_CFG diff --git a/spaghetti-monster/anduril/load-save-config-fsm.h b/spaghetti-monster/anduril/load-save-config-fsm.h index 343c6ff..894c344 100644 --- a/spaghetti-monster/anduril/load-save-config-fsm.h +++ b/spaghetti-monster/anduril/load-save-config-fsm.h @@ -27,10 +27,28 @@ typedef enum { #ifdef USE_RAMP_CONFIG ramp_smooth_floor_e, ramp_smooth_ceil_e, + #ifdef USE_RAMP_SPEED_CONFIG + ramp_speed_e, + #endif ramp_discrete_floor_e, ramp_discrete_ceil_e, ramp_discrete_steps_e, #endif + #ifdef USE_SIMPLE_UI + simple_ui_floor_e, + 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, + #endif + #ifdef USE_2C_STYLE_CONFIG + ramp_2c_style_e, + #endif #ifdef USE_MANUAL_MEMORY manual_memory_e, #ifdef USE_MANUAL_MEMORY_TIMER @@ -59,12 +77,6 @@ typedef enum { #ifdef USE_BEACON_MODE beacon_seconds_e, #endif - #ifdef USE_SIMPLE_UI - simple_ui_active_e, - simple_ui_floor_e, - simple_ui_ceil_e, - simple_ui_steps_e, - #endif #ifdef USE_THERMAL_REGULATION therm_ceil_e, therm_cal_offset_e, diff --git a/spaghetti-monster/anduril/load-save-config.c b/spaghetti-monster/anduril/load-save-config.c index cd29ca5..ee451ac 100644 --- a/spaghetti-monster/anduril/load-save-config.c +++ b/spaghetti-monster/anduril/load-save-config.c @@ -29,10 +29,28 @@ void load_config() { #ifdef USE_RAMP_CONFIG ramp_floors[0] = eeprom[ramp_smooth_floor_e]; ramp_ceils[0] = eeprom[ramp_smooth_ceil_e]; + #ifdef USE_RAMP_SPEED_CONFIG + ramp_speed = eeprom[ramp_speed_e]; + #endif ramp_floors[1] = eeprom[ramp_discrete_floor_e]; ramp_ceils[1] = eeprom[ramp_discrete_ceil_e]; ramp_stepss[1] = eeprom[ramp_discrete_steps_e]; #endif + #ifdef USE_SIMPLE_UI + ramp_floors[2] = eeprom[simple_ui_floor_e]; + 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]; + #endif + #ifdef USE_2C_STYLE_CONFIG + ramp_2c_style = eeprom[ramp_2c_style_e]; + #endif #ifdef USE_MANUAL_MEMORY manual_memory = eeprom[manual_memory_e]; #ifdef USE_MANUAL_MEMORY_TIMER @@ -59,12 +77,6 @@ void load_config() { #ifdef USE_BEACON_MODE beacon_seconds = eeprom[beacon_seconds_e]; #endif - #ifdef USE_SIMPLE_UI - simple_ui_active = eeprom[simple_ui_active_e]; - ramp_floors[2] = eeprom[simple_ui_floor_e]; - ramp_ceils[2] = eeprom[simple_ui_ceil_e]; - ramp_stepss[2] = eeprom[simple_ui_steps_e]; - #endif #ifdef USE_THERMAL_REGULATION therm_ceil = eeprom[therm_ceil_e]; therm_cal_offset = eeprom[therm_cal_offset_e]; @@ -95,10 +107,28 @@ void save_config() { #ifdef USE_RAMP_CONFIG eeprom[ramp_smooth_floor_e] = ramp_floors[0]; eeprom[ramp_smooth_ceil_e] = ramp_ceils[0]; + #ifdef USE_RAMP_SPEED_CONFIG + eeprom[ramp_speed_e] = ramp_speed; + #endif eeprom[ramp_discrete_floor_e] = ramp_floors[1]; eeprom[ramp_discrete_ceil_e] = ramp_ceils[1]; eeprom[ramp_discrete_steps_e] = ramp_stepss[1]; #endif + #ifdef USE_SIMPLE_UI + eeprom[simple_ui_floor_e] = ramp_floors[2]; + 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; + #endif + #ifdef USE_2C_STYLE_CONFIG + eeprom[ramp_2c_style_e] = ramp_2c_style; + #endif #ifdef USE_MANUAL_MEMORY eeprom[manual_memory_e] = manual_memory; #ifdef USE_MANUAL_MEMORY_TIMER @@ -125,12 +155,6 @@ void save_config() { #ifdef USE_BEACON_MODE eeprom[beacon_seconds_e] = beacon_seconds; #endif - #ifdef USE_SIMPLE_UI - eeprom[simple_ui_active_e] = simple_ui_active; - eeprom[simple_ui_floor_e] = ramp_floors[2]; - eeprom[simple_ui_ceil_e] = ramp_ceils[2]; - eeprom[simple_ui_steps_e] = ramp_stepss[2]; - #endif #ifdef USE_THERMAL_REGULATION eeprom[therm_ceil_e] = therm_ceil; eeprom[therm_cal_offset_e] = therm_cal_offset; diff --git a/spaghetti-monster/anduril/off-mode.c b/spaghetti-monster/anduril/off-mode.c index 6faad1c..236ad7e 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_CONFIG + 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 @@ -150,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-fsm.h b/spaghetti-monster/anduril/ramp-mode-fsm.h index 425ac69..7f67d1e 100644 --- a/spaghetti-monster/anduril/ramp-mode-fsm.h +++ b/spaghetti-monster/anduril/ramp-mode-fsm.h @@ -47,7 +47,7 @@ #endif // include an extra config mode for random stuff which doesn't fit elsewhere -#if defined(USE_JUMP_START) || defined(USE_2C_STYLE_CONFIG) +#if defined(USE_JUMP_START) #define USE_GLOBALS_CONFIG #endif diff --git a/spaghetti-monster/anduril/ramp-mode.c b/spaghetti-monster/anduril/ramp-mode.c index e16a7b9..6d85480 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,27 +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 - // 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 - // 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); } @@ -149,6 +165,12 @@ uint8_t steady_state(Event event, uint16_t arg) { if (ramp_style && (arg % HOLD_TIMEOUT != 0)) { return MISCHIEF_MANAGED; } + #ifdef USE_RAMP_SPEED_CONFIG + // ramp slower if user configured things that way + if ((! ramp_style) && (arg % ramp_speed)) { + return MISCHIEF_MANAGED; + } + #endif // fix ramp direction on first frame if necessary if (!arg) { // click, hold should always go down if possible @@ -160,12 +182,24 @@ uint8_t steady_state(Event event, uint16_t arg) { else if (actual_level <= mode_min) { ramp_direction = 1; } } // if the button is stuck, err on the side of safety and ramp down - else if ((arg > TICKS_PER_SECOND * 5) && (actual_level >= mode_max)) { + else if ((arg > TICKS_PER_SECOND * 5 + #ifdef USE_RAMP_SPEED_CONFIG + // FIXME: count from time actual_level hits mode_max, + // not from beginning of button hold + * ramp_speed + #endif + ) && (actual_level >= mode_max)) { ramp_direction = -1; } #ifdef USE_LOCKOUT_MODE // if the button is still stuck, lock the light - else if ((arg > TICKS_PER_SECOND * 10) && (actual_level <= mode_min)) { + else if ((arg > TICKS_PER_SECOND * 10 + #ifdef USE_RAMP_SPEED_CONFIG + // FIXME: count from time actual_level hits mode_min, + // not from beginning of button hold + * ramp_speed + #endif + ) && (actual_level <= mode_min)) { blink_once(); set_state(lockout_state, 0); } @@ -224,7 +258,7 @@ 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; + if (arg == AUTO_REVERSE_TIME) ramp_direction = 1; #ifdef USE_SUNSET_TIMER // reduce output if shutoff timer is active @@ -362,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; } @@ -401,9 +435,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) { @@ -429,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 @@ -445,41 +488,69 @@ void ramp_config_save(uint8_t step, uint8_t value) { } uint8_t ramp_config_state(Event event, uint16_t arg) { + #ifdef USE_RAMP_SPEED_CONFIG + const uint8_t num_config_steps = 3; + #else uint8_t num_config_steps = ramp_style + 2; + #endif return config_state_base(event, arg, num_config_steps, ramp_config_save); } #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 -#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_CONFIG + // 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 + + #ifdef USE_2C_STYLE_CONFIG + // item 4: Anduril 1 2C turbo, or Anduril 2 2C ceiling? + // 1 = Anduril 1, 2C turbo + // 2+ = Anduril 2, 2C ceiling + else if (4 == step) { + ramp_2c_style = 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, 4, ramp_extras_config_save); } #endif #ifdef USE_GLOBALS_CONFIG void globals_config_save(uint8_t step, uint8_t value) { if (0) {} - #ifdef USE_2C_STYLE_CONFIG - // TODO: make double-click style configurable (turbo or ceil) - else if (1 == step) {} - #endif #ifdef USE_JUMP_START else { jump_start_level = value; } #endif diff --git a/spaghetti-monster/anduril/ramp-mode.h b/spaghetti-monster/anduril/ramp-mode.h index 7fb704a..bba6d96 100644 --- a/spaghetti-monster/anduril/ramp-mode.h +++ b/spaghetti-monster/anduril/ramp-mode.h @@ -75,6 +75,9 @@ #ifndef RAMP_STYLE #define RAMP_STYLE 0 // smooth default #endif +#ifndef DEFAULT_RAMP_SPEED +#define DEFAULT_RAMP_SPEED 1 // WDT ticks per "frame", must be 1 or more +#endif #ifndef RAMP_SMOOTH_FLOOR #define RAMP_SMOOTH_FLOOR 1 #endif @@ -124,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_CONFIG) || defined(USE_2C_STYLE_CONFIG) || 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 @@ -160,11 +166,36 @@ 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 +#ifdef USE_2C_STYLE_CONFIG +#ifndef DEFAULT_2C_STYLE +#define DEFAULT_2C_STYLE 2 +#endif +uint8_t ramp_2c_style = DEFAULT_2C_STYLE; // 1 = A1 style, 2 = A2 style +#ifdef USE_2C_MAX_TURBO +#error Cannot use USE_2C_MAX_TURBO and USE_2C_STYLE_CONFIG at the same time. +#endif +#endif + +#ifdef USE_RAMP_SPEED_CONFIG +#define ramp_speed (ramp_stepss[0]) +#endif +#ifdef USE_RAMP_AFTER_MOON_CONFIG +#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; @@ -184,7 +215,7 @@ uint8_t ramp_ceils[] = { #endif }; uint8_t ramp_stepss[] = { - 0, + DEFAULT_RAMP_SPEED, RAMP_DISCRETE_STEPS, #ifdef USE_SIMPLE_UI SIMPLE_UI_STEPS, diff --git a/spaghetti-monster/anduril/strobe-modes.c b/spaghetti-monster/anduril/strobe-modes.c index b27f298..d5f12c0 100644 --- a/spaghetti-monster/anduril/strobe-modes.c +++ b/spaghetti-monster/anduril/strobe-modes.c @@ -153,7 +153,7 @@ uint8_t strobe_state(Event event, uint16_t arg) { // clock tick: bump the random seed else if (event == EV_tick) { // un-reverse after 1 second - if (arg == TICKS_PER_SECOND) ramp_direction = 1; + if (arg == AUTO_REVERSE_TIME) ramp_direction = 1; pseudo_rand_seed += arg; return MISCHIEF_MANAGED; |
