diff options
| author | Selene ToyKeeper | 2021-08-23 04:24:08 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2021-08-23 04:24:08 -0600 |
| commit | dac03ab316ed47aff8e1e28d357935c7e4cbda29 (patch) | |
| tree | c43a2bcef0fedae36e935a73cc84c4155d17e688 /spaghetti-monster | |
| parent | made jump start level configurable at runtime, and made it activate in more p... (diff) | |
| download | anduril-dac03ab316ed47aff8e1e28d357935c7e4cbda29.tar.gz anduril-dac03ab316ed47aff8e1e28d357935c7e4cbda29.tar.bz2 anduril-dac03ab316ed47aff8e1e28d357935c7e4cbda29.zip | |
moved jump start into FSM so it'll be more universal and the app won't need special clauses
(also adjusted KR4 jump start levels a bit)
Diffstat (limited to 'spaghetti-monster')
| -rw-r--r-- | spaghetti-monster/anduril/cfg-noctigon-kr4-nofet.h | 4 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-noctigon-kr4.h | 2 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/load-save-config-fsm.h | 4 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/load-save-config.c | 8 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/lockout-mode.c | 3 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/off-mode.c | 14 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/ramp-mode-fsm.h | 7 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/ramp-mode.c | 10 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/ramp-mode.h | 5 | ||||
| -rw-r--r-- | spaghetti-monster/fsm-ramping.c | 12 | ||||
| -rw-r--r-- | spaghetti-monster/fsm-ramping.h | 10 |
11 files changed, 39 insertions, 40 deletions
diff --git a/spaghetti-monster/anduril/cfg-noctigon-kr4-nofet.h b/spaghetti-monster/anduril/cfg-noctigon-kr4-nofet.h index 383a0c8..e4879ef 100644 --- a/spaghetti-monster/anduril/cfg-noctigon-kr4-nofet.h +++ b/spaghetti-monster/anduril/cfg-noctigon-kr4-nofet.h @@ -53,8 +53,8 @@ #define PARTY_STROBE_ONTIME 2 // jump start a bit higher than base driver -#undef JUMP_START_MOON -#define JUMP_START_MOON 31 +#undef DEFAULT_JUMP_START_LEVEL +#define DEFAULT_JUMP_START_LEVEL 25 // stop panicking at ~1300 lm #undef THERM_FASTER_LEVEL diff --git a/spaghetti-monster/anduril/cfg-noctigon-kr4.h b/spaghetti-monster/anduril/cfg-noctigon-kr4.h index d584445..8071457 100644 --- a/spaghetti-monster/anduril/cfg-noctigon-kr4.h +++ b/spaghetti-monster/anduril/cfg-noctigon-kr4.h @@ -69,7 +69,7 @@ #define THERM_CAL_OFFSET 5 // the power regulator is a bit slow, so push it harder for a quick response from off -#define JUMP_START_MOON 26 +#define DEFAULT_JUMP_START_LEVEL 21 #define BLINK_BRIGHTNESS DEFAULT_LEVEL #define BLINK_ONCE_TIME 12 diff --git a/spaghetti-monster/anduril/load-save-config-fsm.h b/spaghetti-monster/anduril/load-save-config-fsm.h index 0a62380..343c6ff 100644 --- a/spaghetti-monster/anduril/load-save-config-fsm.h +++ b/spaghetti-monster/anduril/load-save-config-fsm.h @@ -43,8 +43,8 @@ typedef enum { #ifdef USE_TINT_RAMPING tint_e, #endif - #ifdef JUMP_START_MOON - jump_start_moon_e, + #ifdef USE_JUMP_START + jump_start_level_e, #endif #ifdef USE_STROBE_STATE strobe_type_e, diff --git a/spaghetti-monster/anduril/load-save-config.c b/spaghetti-monster/anduril/load-save-config.c index cdeaeea..cd29ca5 100644 --- a/spaghetti-monster/anduril/load-save-config.c +++ b/spaghetti-monster/anduril/load-save-config.c @@ -45,8 +45,8 @@ void load_config() { #ifdef USE_TINT_RAMPING tint = eeprom[tint_e]; #endif - #ifdef JUMP_START_MOON - jump_start_moon = eeprom[jump_start_moon_e], + #ifdef USE_JUMP_START + jump_start_level = eeprom[jump_start_level_e], #endif #if defined(USE_PARTY_STROBE_MODE) || defined(USE_TACTICAL_STROBE_MODE) strobe_type = eeprom[strobe_type_e]; // TODO: move this to eeprom_wl? @@ -111,8 +111,8 @@ void save_config() { #ifdef USE_TINT_RAMPING eeprom[tint_e] = tint; #endif - #ifdef JUMP_START_MOON - eeprom[jump_start_moon_e] = jump_start_moon, + #ifdef USE_JUMP_START + eeprom[jump_start_level_e] = jump_start_level, #endif #if defined(USE_PARTY_STROBE_MODE) || defined(USE_TACTICAL_STROBE_MODE) eeprom[strobe_type_e] = strobe_type; // TODO: move this to eeprom_wl? diff --git a/spaghetti-monster/anduril/lockout-mode.c b/spaghetti-monster/anduril/lockout-mode.c index 4e2196f..8c83cff 100644 --- a/spaghetti-monster/anduril/lockout-mode.c +++ b/spaghetti-monster/anduril/lockout-mode.c @@ -42,9 +42,6 @@ uint8_t lockout_state(Event event, uint16_t arg) { } else { // anything except second click if (ramp_floors[1] < lvl) lvl = ramp_floors[1]; } - #ifdef JUMP_START_MOON - if (! actual_level) jump_start_func(); - #endif set_level(lvl); } // button was released diff --git a/spaghetti-monster/anduril/off-mode.c b/spaghetti-monster/anduril/off-mode.c index 4472f74..e37bec3 100644 --- a/spaghetti-monster/anduril/off-mode.c +++ b/spaghetti-monster/anduril/off-mode.c @@ -96,11 +96,6 @@ uint8_t off_state(Event event, uint16_t arg) { #if (B_TIMING_ON == B_PRESS_T) // hold (initially): go to lowest level (floor), but allow abort for regular click else if (event == EV_click1_press) { - #ifdef JUMP_START_MOON - if (!arg) { - jump_start_func(); - } - #endif set_level(nearest_level(1)); return MISCHIEF_MANAGED; } @@ -115,12 +110,6 @@ uint8_t off_state(Event event, uint16_t arg) { } else #endif #else // B_RELEASE_T or B_TIMEOUT_T - #ifdef JUMP_START_MOON - // pulse the output for a moment to wake up the power regulator - if (!arg) { - jump_start_func(); - } - #endif set_level(nearest_level(1)); #endif // don't start ramping immediately; @@ -149,9 +138,6 @@ uint8_t off_state(Event event, uint16_t arg) { #endif } #endif - #ifdef JUMP_START_MOON - jump_start_func(); - #endif set_level(nearest_level(memorized_level)); return MISCHIEF_MANAGED; } diff --git a/spaghetti-monster/anduril/ramp-mode-fsm.h b/spaghetti-monster/anduril/ramp-mode-fsm.h index c6ef4c8..425ac69 100644 --- a/spaghetti-monster/anduril/ramp-mode-fsm.h +++ b/spaghetti-monster/anduril/ramp-mode-fsm.h @@ -41,8 +41,13 @@ #define TICK_DURING_STANDBY #endif +// ensure the jump start feature gets compiled in if needed +#ifdef DEFAULT_JUMP_START_LEVEL +#define USE_JUMP_START +#endif + // include an extra config mode for random stuff which doesn't fit elsewhere -#if defined(JUMP_START_MOON) || defined(USE_2C_STYLE_CONFIG) +#if defined(USE_JUMP_START) || defined(USE_2C_STYLE_CONFIG) #define USE_GLOBALS_CONFIG #endif diff --git a/spaghetti-monster/anduril/ramp-mode.c b/spaghetti-monster/anduril/ramp-mode.c index f4eba59..e16a7b9 100644 --- a/spaghetti-monster/anduril/ramp-mode.c +++ b/spaghetti-monster/anduril/ramp-mode.c @@ -480,8 +480,8 @@ void globals_config_save(uint8_t step, uint8_t value) { // TODO: make double-click style configurable (turbo or ceil) else if (1 == step) {} #endif - #ifdef JUMP_START_MOON - else { jump_start_moon = value; } + #ifdef USE_JUMP_START + else { jump_start_level = value; } #endif } @@ -552,12 +552,6 @@ void set_level_and_therm_target(uint8_t level) { #define set_level_and_therm_target(level) set_level(level) #endif -#ifdef JUMP_START_MOON -void jump_start_func() { - set_level(jump_start_moon); - delay_4ms(3); -} -#endif #endif diff --git a/spaghetti-monster/anduril/ramp-mode.h b/spaghetti-monster/anduril/ramp-mode.h index efc77d3..7fb704a 100644 --- a/spaghetti-monster/anduril/ramp-mode.h +++ b/spaghetti-monster/anduril/ramp-mode.h @@ -192,11 +192,6 @@ uint8_t ramp_stepss[] = { }; uint8_t ramp_discrete_step_size; // don't set this -#ifdef JUMP_START_MOON -uint8_t jump_start_moon = JUMP_START_MOON; -void jump_start_func(); -#endif - #ifdef USE_GLOBALS_CONFIG void globals_config_save(uint8_t step, uint8_t value); uint8_t globals_config_state(Event event, uint16_t arg); diff --git a/spaghetti-monster/fsm-ramping.c b/spaghetti-monster/fsm-ramping.c index 017a5b8..54ca45c 100644 --- a/spaghetti-monster/fsm-ramping.c +++ b/spaghetti-monster/fsm-ramping.c @@ -24,6 +24,18 @@ #ifdef USE_RAMPING void set_level(uint8_t level) { + #ifdef USE_JUMP_START + // maybe "jump start" the engine, if it's prone to slow starts + // (pulse the output high for a moment to wake up the power regulator) + // (only do this when starting from off and going to a low level) + if ((! actual_level) + && level + && (level < jump_start_level)) { + set_level(jump_start_level); + delay_4ms(JUMP_START_TIME/4); + } + #endif // ifdef USE_JUMP_START + actual_level = level; #ifdef USE_SET_LEVEL_GRADUALLY diff --git a/spaghetti-monster/fsm-ramping.h b/spaghetti-monster/fsm-ramping.h index d1ef6bc..7a4fa3b 100644 --- a/spaghetti-monster/fsm-ramping.h +++ b/spaghetti-monster/fsm-ramping.h @@ -82,6 +82,16 @@ PROGMEM const PWM_DATATYPE pwm4_levels[] = { PWM4_LEVELS }; PROGMEM const PWM_DATATYPE pwm_tops[] = { PWM_TOPS }; #endif +#ifdef USE_JUMP_START +#ifndef JUMP_START_TIME +#define JUMP_START_TIME 8 // in ms, should be 4, 8, or 12 +#endif +#ifndef DEFAULT_JUMP_START_LEVEL +#define DEFAULT_JUMP_START_LEVEL 10 +#endif +uint8_t jump_start_level = DEFAULT_JUMP_START_LEVEL; +#endif + // default / example ramps #ifndef PWM1_LEVELS #if PWM_CHANNELS == 1 |
