diff options
| author | Selene ToyKeeper | 2021-11-03 04:16:05 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2021-11-03 04:16:05 -0600 |
| commit | efd3f3ebdb0898d79e44d984cedd4c0409902e25 (patch) | |
| tree | e3ccf22928de7c410b615d91acfa09fb00f18aa9 | |
| parent | added KR4-tintramp build (diff) | |
| download | anduril-efd3f3ebdb0898d79e44d984cedd4c0409902e25.tar.gz anduril-efd3f3ebdb0898d79e44d984cedd4c0409902e25.tar.bz2 anduril-efd3f3ebdb0898d79e44d984cedd4c0409902e25.zip | |
added runtime config to choose tint-ramping or tint-toggle
(Off->9H option 1, 0=smooth, 1=toggle)
| -rw-r--r-- | spaghetti-monster/anduril/anduril-manual.txt | 10 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/load-save-config-fsm.h | 1 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/load-save-config.c | 2 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/ramp-mode-fsm.h | 2 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/ramp-mode.c | 7 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/ramp-mode.h | 10 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/tint-ramping.c | 46 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/tint-ramping.h | 8 |
8 files changed, 54 insertions, 32 deletions
diff --git a/spaghetti-monster/anduril/anduril-manual.txt b/spaghetti-monster/anduril/anduril-manual.txt index 34ae1bb..8d6ad75 100644 --- a/spaghetti-monster/anduril/anduril-manual.txt +++ b/spaghetti-monster/anduril/anduril-manual.txt @@ -692,6 +692,11 @@ Misc Config Menu Some models may have an extra config menu for settings which don't fit anywhere else. These settings are, in order: + - Tint ramp style: + + 0 = smooth (blend channels in any proportion) + 1 = toggle (only one channel active at a time) + - Jump Start level: Some lights are prone to starting up slowly at low levels, so they @@ -728,6 +733,11 @@ be warm white while dim, or cool white while bright. Or vice-versa. To access this, ramp to the end of the tint range, then keep holding until the light blinks a second time. +The misc config menu also has a setting to choose a tint ramp style. +This can be smooth, allowing the user to smoothly blend both channels in +whatever ratio they desire... or it can be "tint toggle" style, where +only one channel is active at a time. + UI Reference Table ------------------ diff --git a/spaghetti-monster/anduril/load-save-config-fsm.h b/spaghetti-monster/anduril/load-save-config-fsm.h index 894c344..ba3c69b 100644 --- a/spaghetti-monster/anduril/load-save-config-fsm.h +++ b/spaghetti-monster/anduril/load-save-config-fsm.h @@ -60,6 +60,7 @@ typedef enum { #endif #ifdef USE_TINT_RAMPING tint_e, + tint_style_e, #endif #ifdef USE_JUMP_START jump_start_level_e, diff --git a/spaghetti-monster/anduril/load-save-config.c b/spaghetti-monster/anduril/load-save-config.c index ee451ac..4987def 100644 --- a/spaghetti-monster/anduril/load-save-config.c +++ b/spaghetti-monster/anduril/load-save-config.c @@ -62,6 +62,7 @@ void load_config() { #endif #ifdef USE_TINT_RAMPING tint = eeprom[tint_e]; + tint_style = eeprom[tint_style_e]; #endif #ifdef USE_JUMP_START jump_start_level = eeprom[jump_start_level_e], @@ -140,6 +141,7 @@ void save_config() { #endif #ifdef USE_TINT_RAMPING eeprom[tint_e] = tint; + eeprom[tint_style_e] = tint_style; #endif #ifdef USE_JUMP_START eeprom[jump_start_level_e] = jump_start_level, diff --git a/spaghetti-monster/anduril/ramp-mode-fsm.h b/spaghetti-monster/anduril/ramp-mode-fsm.h index 7f67d1e..1a062e9 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) +#if defined(USE_TINT_RAMPING) || 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 6d85480..851f5a4 100644 --- a/spaghetti-monster/anduril/ramp-mode.c +++ b/spaghetti-monster/anduril/ramp-mode.c @@ -551,14 +551,17 @@ uint8_t ramp_extras_config_state(Event event, uint16_t arg) { #ifdef USE_GLOBALS_CONFIG void globals_config_save(uint8_t step, uint8_t value) { if (0) {} + #ifdef USE_TINT_RAMPING + else if (step == 1+tint_style_config_step) { tint_style = value; } + #endif #ifdef USE_JUMP_START - else { jump_start_level = value; } + else if (step == 1+jump_start_config_step) { jump_start_level = value; } #endif } uint8_t globals_config_state(Event event, uint16_t arg) { // TODO: set number of steps based on how many configurable options - return config_state_base(event, arg, 1, globals_config_save); + return config_state_base(event, arg, globals_config_num_steps, globals_config_save); } #endif diff --git a/spaghetti-monster/anduril/ramp-mode.h b/spaghetti-monster/anduril/ramp-mode.h index bba6d96..93756ab 100644 --- a/spaghetti-monster/anduril/ramp-mode.h +++ b/spaghetti-monster/anduril/ramp-mode.h @@ -224,6 +224,16 @@ uint8_t ramp_stepss[] = { uint8_t ramp_discrete_step_size; // don't set this #ifdef USE_GLOBALS_CONFIG +typedef enum { + #ifdef USE_TINT_RAMPING + tint_style_config_step, + #endif + #ifdef USE_JUMP_START + jump_start_config_step, + #endif + globals_config_num_steps +} globals_config_steps_e; + void globals_config_save(uint8_t step, uint8_t value); uint8_t globals_config_state(Event event, uint16_t arg); #endif diff --git a/spaghetti-monster/anduril/tint-ramping.c b/spaghetti-monster/anduril/tint-ramping.c index aa9b1f6..6cc0616 100644 --- a/spaghetti-monster/anduril/tint-ramping.c +++ b/spaghetti-monster/anduril/tint-ramping.c @@ -22,31 +22,6 @@ #include "tint-ramping.h" -#ifdef TINT_RAMP_TOGGLE_ONLY - -uint8_t tint_ramping_state(Event event, uint16_t arg) { - // click, click, hold: change the tint - if (event == EV_click3_hold) { - // toggle once on first frame; ignore other frames - if (! arg) { - tint = !tint; - set_level(actual_level); - //blink_once(); // unnecessary, and kind of annoying on moon - } - return EVENT_HANDLED; - } - - // click, click, hold, release: save config - else if (event == EV_click3_hold_release) { - // remember tint after battery change - save_config(); - return EVENT_HANDLED; - } - - return EVENT_NOT_HANDLED; -} - -#else // no TINT_RAMP_TOGGLE_ONLY uint8_t tint_ramping_state(Event event, uint16_t arg) { static int8_t tint_ramp_direction = 1; @@ -61,6 +36,21 @@ uint8_t tint_ramping_state(Event event, uint16_t arg) { // click, click, hold: change the tint if (event == EV_click3_hold) { + ///// tint-toggle mode + // toggle once on first frame; ignore other frames + if (tint_style) { + // only respond on first frame + if (arg) return EVENT_NOT_HANDLED; + + // force tint to be 1 or 254 + if (tint != 254) { tint = 1; } + // invert between 1 and 254 + tint = tint ^ 0xFF; + set_level(actual_level); + return EVENT_HANDLED; + } + + ///// smooth tint-ramp mode // reset at beginning of movement if (! arg) { active = 1; // first frame means this is for us @@ -98,8 +88,8 @@ uint8_t tint_ramping_state(Event event, uint16_t arg) { active = 0; // ignore next hold if it wasn't meant for us // reverse tint_ramp_direction = -tint_ramp_direction; - if (tint == 0) tint_ramp_direction = 1; - else if (tint == 255) tint_ramp_direction = -1; + if (tint <= 1) tint_ramp_direction = 1; + else if (tint >= 254) tint_ramp_direction = -1; // remember tint after battery change save_config(); return EVENT_HANDLED; @@ -108,8 +98,6 @@ uint8_t tint_ramping_state(Event event, uint16_t arg) { return EVENT_NOT_HANDLED; } -#endif // ifdef TINT_RAMP_TOGGLE_ONLY - #endif diff --git a/spaghetti-monster/anduril/tint-ramping.h b/spaghetti-monster/anduril/tint-ramping.h index e482999..1c5e22a 100644 --- a/spaghetti-monster/anduril/tint-ramping.h +++ b/spaghetti-monster/anduril/tint-ramping.h @@ -20,6 +20,14 @@ #ifndef TINT_RAMPING_H #define TINT_RAMPING_H +// 0: smooth tint ramp +// 1: toggle tint only between two extremes +#ifdef TINT_RAMP_TOGGLE_ONLY +uint8_t tint_style = 1; +#else +uint8_t tint_style = 0; +#endif + #ifdef USE_MANUAL_MEMORY uint8_t manual_memory_tint; #endif |
