diff options
| author | Gabriel Hart | 2021-08-29 14:39:15 -0500 |
|---|---|---|
| committer | Gabriel Hart | 2021-08-29 14:39:15 -0500 |
| commit | 59f22692f73a250123f085b792c29e9a32d664a8 (patch) | |
| tree | c2154260d6b11ea4831d0fba14d08b11d3f21f02 | |
| parent | Add 2C Turbo for BLF Lantern (LT1) (diff) | |
| parent | made it possible to use autolock in simple UI (diff) | |
| download | anduril-59f22692f73a250123f085b792c29e9a32d664a8.tar.gz anduril-59f22692f73a250123f085b792c29e9a32d664a8.tar.bz2 anduril-59f22692f73a250123f085b792c29e9a32d664a8.zip | |
Merge TK's changes thru her rev 618 including autolock in Simple UI and jump start updates
Diffstat (limited to '')
| -rw-r--r-- | spaghetti-monster/anduril/anduril-manual.txt | 26 | ||||
| -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 | 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-fsm.h | 10 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/ramp-mode.c | 18 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/ramp-mode.h | 5 | ||||
| -rw-r--r-- | spaghetti-monster/fsm-ramping.c | 42 | ||||
| -rw-r--r-- | spaghetti-monster/fsm-ramping.h | 10 |
11 files changed, 129 insertions, 26 deletions
diff --git a/spaghetti-monster/anduril/anduril-manual.txt b/spaghetti-monster/anduril/anduril-manual.txt index 57f1986..74ca0c7 100644 --- a/spaghetti-monster/anduril/anduril-manual.txt +++ b/spaghetti-monster/anduril/anduril-manual.txt @@ -639,6 +639,31 @@ 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 +------------------ + +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 + have an option to "jump start" the engine by pulsing a higher power + 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. + +Some 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. + + Tint Ramping ------------ @@ -680,6 +705,7 @@ 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 10C Enable Simple UI Off Simple 10H Disable Simple UI Off Full 10H Simple UI ramp config menu (1: floor, 2: ceiling, [3: steps]) 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 9d3dd86..343c6ff 100644 --- a/spaghetti-monster/anduril/load-save-config-fsm.h +++ b/spaghetti-monster/anduril/load-save-config-fsm.h @@ -43,6 +43,9 @@ typedef enum { #ifdef USE_TINT_RAMPING tint_e, #endif + #ifdef USE_JUMP_START + jump_start_level_e, + #endif #ifdef USE_STROBE_STATE strobe_type_e, #endif diff --git a/spaghetti-monster/anduril/load-save-config.c b/spaghetti-monster/anduril/load-save-config.c index 3823521..cd29ca5 100644 --- a/spaghetti-monster/anduril/load-save-config.c +++ b/spaghetti-monster/anduril/load-save-config.c @@ -45,6 +45,9 @@ void load_config() { #ifdef USE_TINT_RAMPING tint = eeprom[tint_e]; #endif + #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? strobe_delays[0] = eeprom[strobe_delays_0_e]; @@ -108,6 +111,9 @@ void save_config() { #ifdef USE_TINT_RAMPING eeprom[tint_e] = tint; #endif + #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? eeprom[strobe_delays_0_e] = strobe_delays[0]; diff --git a/spaghetti-monster/anduril/off-mode.c b/spaghetti-monster/anduril/off-mode.c index b1faf47..6faad1c 100644 --- a/spaghetti-monster/anduril/off-mode.c +++ b/spaghetti-monster/anduril/off-mode.c @@ -78,17 +78,11 @@ uint8_t off_state(Event event, uint16_t arg) { #endif #ifdef USE_AUTOLOCK - // lock the light after being off for N minutes - #ifdef USE_SIMPLE_UI - if (! simple_ui_active) { // no auto-lock in Simple UI - #endif + // lock the light after being off for N minutes uint16_t ticks = autolock_time * SLEEP_TICKS_PER_MINUTE; if ((autolock_time > 0) && (arg > ticks)) { set_state(lockout_state, 0); } - #ifdef USE_SIMPLE_UI - } - #endif #endif // ifdef USE_AUTOLOCK return MISCHIEF_MANAGED; } @@ -96,12 +90,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) { - set_level(JUMP_START_MOON); - delay_4ms(3); - } - #endif set_level(nearest_level(1)); return MISCHIEF_MANAGED; } @@ -116,13 +104,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) { - set_level(JUMP_START_MOON); - delay_4ms(3); - } - #endif set_level(nearest_level(1)); #endif // don't start ramping immediately; @@ -316,6 +297,14 @@ uint8_t off_state(Event event, uint16_t arg) { return MISCHIEF_MANAGED; } #endif // end 7 clicks + + #ifdef USE_GLOBALS_CONFIG + // 9 clicks, but hold last click: configure misc global settings + else if ((event == EV_click9_hold) && (!arg)) { + push_state(globals_config_state, 0); + return MISCHIEF_MANAGED; + } + #endif return EVENT_NOT_HANDLED; } diff --git a/spaghetti-monster/anduril/ramp-mode-fsm.h b/spaghetti-monster/anduril/ramp-mode-fsm.h index 997e80d..425ac69 100644 --- a/spaghetti-monster/anduril/ramp-mode-fsm.h +++ b/spaghetti-monster/anduril/ramp-mode-fsm.h @@ -41,5 +41,15 @@ #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(USE_JUMP_START) || defined(USE_2C_STYLE_CONFIG) +#define USE_GLOBALS_CONFIG +#endif + #endif diff --git a/spaghetti-monster/anduril/ramp-mode.c b/spaghetti-monster/anduril/ramp-mode.c index 263a7aa..22c421a 100644 --- a/spaghetti-monster/anduril/ramp-mode.c +++ b/spaghetti-monster/anduril/ramp-mode.c @@ -481,6 +481,24 @@ uint8_t manual_memory_timer_config_state(Event event, uint16_t arg) { } #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 +} + +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); +} +#endif + // find the ramp level closest to the target, // using only the levels which are allowed in the current state uint8_t nearest_level(int16_t target) { diff --git a/spaghetti-monster/anduril/ramp-mode.h b/spaghetti-monster/anduril/ramp-mode.h index ed806bd..7fb704a 100644 --- a/spaghetti-monster/anduril/ramp-mode.h +++ b/spaghetti-monster/anduril/ramp-mode.h @@ -192,5 +192,10 @@ uint8_t ramp_stepss[] = { }; uint8_t ramp_discrete_step_size; // don't set this +#ifdef USE_GLOBALS_CONFIG +void globals_config_save(uint8_t step, uint8_t value); +uint8_t globals_config_state(Event event, uint16_t arg); +#endif + #endif diff --git a/spaghetti-monster/fsm-ramping.c b/spaghetti-monster/fsm-ramping.c index 1a08149..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 @@ -58,6 +70,11 @@ void set_level(uint8_t level) { set_level_override(level); #else + #ifdef PWM1_CNT + static uint8_t prev_level = 0; + uint8_t api_level = level; + #endif + //TCCR0A = PHASE; if (level == 0) { #if PWM_CHANNELS >= 1 @@ -97,6 +114,7 @@ void set_level(uint8_t level) { LED2_ENABLE_PORT |= (1 << LED2_ENABLE_PIN); #endif + // PWM array index = level - 1 level --; #ifdef USE_TINT_RAMPING @@ -160,8 +178,10 @@ void set_level(uint8_t level) { // goes all the way to 65535 before returning) // (see attiny1634 reference manual page 103 for a warning about // the timing of changing the TOP value (section 12.8.4)) + // (but don't wait when turning on from zero, because + // it'll reset the phase below anyway) // to be safe, allow at least 64 cycles to update TOP - while(PWM1_CNT > (top - 64)) {} + while(prev_level && (PWM1_CNT > (top - 64))) {} #endif // pulse frequency modulation, a.k.a. dynamic PWM PWM1_TOP = top; @@ -169,18 +189,34 @@ void set_level(uint8_t level) { // repeat for other channels if necessary #ifdef PMW2_TOP #ifdef PWM2_CNT - while(PWM2_CNT > (top - 64)) {} + while(prev_level && (PWM2_CNT > (top - 64))) {} #endif PWM2_TOP = top; #endif #ifdef PMW3_TOP #ifdef PWM3_CNT - while(PWM3_CNT > (top - 64)) {} + while(prev_level && (PWM3_CNT > (top - 64))) {} #endif PWM3_TOP = top; #endif #endif // ifdef USE_DYN_PWM + #ifdef PWM1_CNT + // force reset phase when turning on from zero + // (because otherwise the initial response is inconsistent) + if (! prev_level) { + PWM1_CNT = 0; + #ifdef PWM2_CNT + PWM2_CNT = 0; + #endif + #ifdef PWM3_CNT + PWM3_CNT = 0; + #endif + } + #endif } + #ifdef PWM1_CNT + prev_level = api_level; + #endif #endif // ifdef OVERRIDE_SET_LEVEL #ifdef USE_DYNAMIC_UNDERCLOCKING auto_clock_speed(); 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 |
