From a0b0a0af03d0c80d15d27ea02c8d3d7209dfdd01 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Tue, 31 Aug 2021 13:43:43 -0600 Subject: added runtime config option for smooth ramp speed --- spaghetti-monster/anduril/config-default.h | 3 +++ spaghetti-monster/anduril/load-save-config-fsm.h | 15 +++++++----- spaghetti-monster/anduril/load-save-config.c | 30 ++++++++++++++---------- spaghetti-monster/anduril/ramp-mode.c | 26 ++++++++++++++++++-- spaghetti-monster/anduril/ramp-mode.h | 8 ++++++- 5 files changed, 61 insertions(+), 21 deletions(-) diff --git a/spaghetti-monster/anduril/config-default.h b/spaghetti-monster/anduril/config-default.h index a50be5d..1043253 100644 --- a/spaghetti-monster/anduril/config-default.h +++ b/spaghetti-monster/anduril/config-default.h @@ -68,6 +68,9 @@ // 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 + // 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) diff --git a/spaghetti-monster/anduril/load-save-config-fsm.h b/spaghetti-monster/anduril/load-save-config-fsm.h index 343c6ff..edd4ed5 100644 --- a/spaghetti-monster/anduril/load-save-config-fsm.h +++ b/spaghetti-monster/anduril/load-save-config-fsm.h @@ -27,10 +27,19 @@ 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, + #endif #ifdef USE_MANUAL_MEMORY manual_memory_e, #ifdef USE_MANUAL_MEMORY_TIMER @@ -59,12 +68,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..57638d6 100644 --- a/spaghetti-monster/anduril/load-save-config.c +++ b/spaghetti-monster/anduril/load-save-config.c @@ -29,10 +29,19 @@ 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]; + #endif #ifdef USE_MANUAL_MEMORY manual_memory = eeprom[manual_memory_e]; #ifdef USE_MANUAL_MEMORY_TIMER @@ -59,12 +68,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 +98,19 @@ 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; + #endif #ifdef USE_MANUAL_MEMORY eeprom[manual_memory_e] = manual_memory; #ifdef USE_MANUAL_MEMORY_TIMER @@ -125,12 +137,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/ramp-mode.c b/spaghetti-monster/anduril/ramp-mode.c index e16a7b9..2508d52 100644 --- a/spaghetti-monster/anduril/ramp-mode.c +++ b/spaghetti-monster/anduril/ramp-mode.c @@ -149,6 +149,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 +166,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); } @@ -445,7 +463,11 @@ 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); } diff --git a/spaghetti-monster/anduril/ramp-mode.h b/spaghetti-monster/anduril/ramp-mode.h index 7fb704a..7c8b014 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 @@ -165,6 +168,9 @@ uint8_t simple_ui_active = SIMPLE_UI_ACTIVE; #endif // smooth vs discrete ramping uint8_t ramp_style = RAMP_STYLE; // 0 = smooth, 1 = discrete +#ifdef USE_RAMP_SPEED_CONFIG +#define ramp_speed (ramp_stepss[0]) +#endif // current values, regardless of style uint8_t ramp_floor = RAMP_SMOOTH_FLOOR; uint8_t ramp_ceil = RAMP_SMOOTH_CEIL; @@ -184,7 +190,7 @@ uint8_t ramp_ceils[] = { #endif }; uint8_t ramp_stepss[] = { - 0, + DEFAULT_RAMP_SPEED, RAMP_DISCRETE_STEPS, #ifdef USE_SIMPLE_UI SIMPLE_UI_STEPS, -- cgit v1.2.3 From bbdce623e3076f6b0f28526fe38771c894d7adfa Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Tue, 31 Aug 2021 14:16:38 -0600 Subject: added runtime option to select whether to ramp up after hold-from-off (default) or stay at floor --- spaghetti-monster/anduril/config-default.h | 3 +++ spaghetti-monster/anduril/load-save-config-fsm.h | 3 +++ spaghetti-monster/anduril/load-save-config.c | 6 +++++ spaghetti-monster/anduril/off-mode.c | 5 ++++ spaghetti-monster/anduril/ramp-mode.c | 30 +++++++++++++++++------- spaghetti-monster/anduril/ramp-mode.h | 13 ++++++++-- 6 files changed, 49 insertions(+), 11 deletions(-) diff --git a/spaghetti-monster/anduril/config-default.h b/spaghetti-monster/anduril/config-default.h index 1043253..4beb753 100644 --- a/spaghetti-monster/anduril/config-default.h +++ b/spaghetti-monster/anduril/config-default.h @@ -71,6 +71,9 @@ // smooth ramp speed: 1, 2, 3, 4, ... for 1X speed, 1/2, 1/3rd, 1/4th, ... #define USE_RAMP_SPEED_CONFIG +// add runtime option for whether hold-from-off should ramp or stay at moon +#define USE_RAMP_AFTER_MOON_OPTION + // 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) diff --git a/spaghetti-monster/anduril/load-save-config-fsm.h b/spaghetti-monster/anduril/load-save-config-fsm.h index edd4ed5..a6d1281 100644 --- a/spaghetti-monster/anduril/load-save-config-fsm.h +++ b/spaghetti-monster/anduril/load-save-config-fsm.h @@ -40,6 +40,9 @@ typedef enum { simple_ui_steps_e, simple_ui_active_e, #endif + #ifdef USE_RAMP_AFTER_MOON_OPTION + dont_ramp_after_moon_e, + #endif #ifdef USE_MANUAL_MEMORY manual_memory_e, #ifdef USE_MANUAL_MEMORY_TIMER diff --git a/spaghetti-monster/anduril/load-save-config.c b/spaghetti-monster/anduril/load-save-config.c index 57638d6..f564187 100644 --- a/spaghetti-monster/anduril/load-save-config.c +++ b/spaghetti-monster/anduril/load-save-config.c @@ -42,6 +42,9 @@ void load_config() { ramp_stepss[2] = eeprom[simple_ui_steps_e]; simple_ui_active = eeprom[simple_ui_active_e]; #endif + #ifdef USE_RAMP_AFTER_MOON_OPTION + dont_ramp_after_moon = eeprom[dont_ramp_after_moon_e]; + #endif #ifdef USE_MANUAL_MEMORY manual_memory = eeprom[manual_memory_e]; #ifdef USE_MANUAL_MEMORY_TIMER @@ -111,6 +114,9 @@ void save_config() { eeprom[simple_ui_steps_e] = ramp_stepss[2]; eeprom[simple_ui_active_e] = simple_ui_active; #endif + #ifdef USE_RAMP_AFTER_MOON_OPTION + eeprom[dont_ramp_after_moon_e] = dont_ramp_after_moon; + #endif #ifdef USE_MANUAL_MEMORY eeprom[manual_memory_e] = manual_memory; #ifdef USE_MANUAL_MEMORY_TIMER diff --git a/spaghetti-monster/anduril/off-mode.c b/spaghetti-monster/anduril/off-mode.c index 6faad1c..bf4642c 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_OPTION + 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 diff --git a/spaghetti-monster/anduril/ramp-mode.c b/spaghetti-monster/anduril/ramp-mode.c index 2508d52..634d8f2 100644 --- a/spaghetti-monster/anduril/ramp-mode.c +++ b/spaghetti-monster/anduril/ramp-mode.c @@ -419,9 +419,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) { @@ -479,19 +479,31 @@ uint8_t simple_ui_config_state(Event event, uint16_t arg) { #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_OPTION + // 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 } -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, 3, ramp_extras_config_save); } #endif diff --git a/spaghetti-monster/anduril/ramp-mode.h b/spaghetti-monster/anduril/ramp-mode.h index 7c8b014..7ad244a 100644 --- a/spaghetti-monster/anduril/ramp-mode.h +++ b/spaghetti-monster/anduril/ramp-mode.h @@ -127,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_OPTION) || defined(USE_2C_STYLE_OPTION) || 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 @@ -171,6 +174,12 @@ uint8_t ramp_style = RAMP_STYLE; // 0 = smooth, 1 = discrete #ifdef USE_RAMP_SPEED_CONFIG #define ramp_speed (ramp_stepss[0]) #endif +#ifdef USE_RAMP_AFTER_MOON_OPTION +#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; -- cgit v1.2.3 From f056ad231a259414c121cd3ab64df335acf10c5c Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Tue, 31 Aug 2021 14:50:48 -0600 Subject: added runtime option to choose Anduril 1 or Anduril 2 double-click turbo style (2C while on goes to full-power turbo (A1) or ceiling (A2)) also renamed _OPTION defs to _CONFIG for consistency --- spaghetti-monster/anduril/config-default.h | 5 +++- spaghetti-monster/anduril/hank-cfg.h | 2 +- spaghetti-monster/anduril/load-save-config-fsm.h | 5 +++- spaghetti-monster/anduril/load-save-config.c | 10 ++++++-- spaghetti-monster/anduril/off-mode.c | 2 +- spaghetti-monster/anduril/ramp-mode-fsm.h | 2 +- spaghetti-monster/anduril/ramp-mode.c | 32 ++++++++++++++++++------ spaghetti-monster/anduril/ramp-mode.h | 14 +++++++++-- 8 files changed, 55 insertions(+), 17 deletions(-) diff --git a/spaghetti-monster/anduril/config-default.h b/spaghetti-monster/anduril/config-default.h index 4beb753..16c7b49 100644 --- a/spaghetti-monster/anduril/config-default.h +++ b/spaghetti-monster/anduril/config-default.h @@ -72,7 +72,7 @@ #define USE_RAMP_SPEED_CONFIG // add runtime option for whether hold-from-off should ramp or stay at moon -#define USE_RAMP_AFTER_MOON_OPTION +#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 @@ -90,6 +90,9 @@ // - 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 +//#define DEFAULT_2C_STYLE 2 // default to Anduril 2 style // 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 a6d1281..5058f0c 100644 --- a/spaghetti-monster/anduril/load-save-config-fsm.h +++ b/spaghetti-monster/anduril/load-save-config-fsm.h @@ -40,9 +40,12 @@ typedef enum { simple_ui_steps_e, simple_ui_active_e, #endif - #ifdef USE_RAMP_AFTER_MOON_OPTION + #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 diff --git a/spaghetti-monster/anduril/load-save-config.c b/spaghetti-monster/anduril/load-save-config.c index f564187..439576f 100644 --- a/spaghetti-monster/anduril/load-save-config.c +++ b/spaghetti-monster/anduril/load-save-config.c @@ -42,9 +42,12 @@ void load_config() { ramp_stepss[2] = eeprom[simple_ui_steps_e]; simple_ui_active = eeprom[simple_ui_active_e]; #endif - #ifdef USE_RAMP_AFTER_MOON_OPTION + #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 @@ -114,9 +117,12 @@ void save_config() { eeprom[simple_ui_steps_e] = ramp_stepss[2]; eeprom[simple_ui_active_e] = simple_ui_active; #endif - #ifdef USE_RAMP_AFTER_MOON_OPTION + #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 diff --git a/spaghetti-monster/anduril/off-mode.c b/spaghetti-monster/anduril/off-mode.c index bf4642c..5004e61 100644 --- a/spaghetti-monster/anduril/off-mode.c +++ b/spaghetti-monster/anduril/off-mode.c @@ -106,7 +106,7 @@ 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_OPTION + #ifdef USE_RAMP_AFTER_MOON_CONFIG if (dont_ramp_after_moon) { return MISCHIEF_MANAGED; } 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 634d8f2..5317b27 100644 --- a/spaghetti-monster/anduril/ramp-mode.c +++ b/spaghetti-monster/anduril/ramp-mode.c @@ -101,7 +101,7 @@ 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 + #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 @@ -109,7 +109,18 @@ uint8_t steady_state(Event event, uint16_t arg) { else #endif turbo_level = MAX_LEVEL; - #else + #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 + if (ramp_2c_style <= 1) 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 @@ -492,7 +503,7 @@ void ramp_extras_config_save(uint8_t step, uint8_t value) { else if (2 == step) { manual_memory_timer = value; } #endif - #ifdef USE_RAMP_AFTER_MOON_OPTION + #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 @@ -500,20 +511,25 @@ void ramp_extras_config_save(uint8_t step, uint8_t value) { 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) { + if (value) ramp_2c_style = value; + } + #endif } uint8_t ramp_extras_config_state(Event event, uint16_t arg) { - return config_state_base(event, arg, 3, ramp_extras_config_save); + 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 7ad244a..242d7aa 100644 --- a/spaghetti-monster/anduril/ramp-mode.h +++ b/spaghetti-monster/anduril/ramp-mode.h @@ -127,7 +127,7 @@ uint8_t simple_ui_config_state(Event event, uint16_t arg); #endif #endif -#if defined(USE_MANUAL_MEMORY_TIMER) || defined(USE_RAMP_AFTER_MOON_OPTION) || defined(USE_2C_STYLE_OPTION) || defined(USE_AUTO_SUNSET) +#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 @@ -171,10 +171,20 @@ uint8_t simple_ui_active = SIMPLE_UI_ACTIVE; #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_OPTION +#ifdef USE_RAMP_AFTER_MOON_CONFIG #ifndef DEFAULT_DONT_RAMP_AFTER_MOON #define DEFAULT_DONT_RAMP_AFTER_MOON 0 #endif -- cgit v1.2.3 From 8869bcd869da0451e4a3c12f1e026dad0da2c365 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Tue, 31 Aug 2021 15:03:48 -0600 Subject: added third 2C style: 0 = no turbo (but it's still available as momentary) (also, adding this reduced the ROM size somehow) --- spaghetti-monster/anduril/config-default.h | 4 ++++ spaghetti-monster/anduril/ramp-mode.c | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/spaghetti-monster/anduril/config-default.h b/spaghetti-monster/anduril/config-default.h index 16c7b49..7670df4 100644 --- a/spaghetti-monster/anduril/config-default.h +++ b/spaghetti-monster/anduril/config-default.h @@ -92,6 +92,10 @@ //#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 // make the ramps configurable by the user diff --git a/spaghetti-monster/anduril/ramp-mode.c b/spaghetti-monster/anduril/ramp-mode.c index 5317b27..4922e2c 100644 --- a/spaghetti-monster/anduril/ramp-mode.c +++ b/spaghetti-monster/anduril/ramp-mode.c @@ -115,7 +115,11 @@ uint8_t steady_state(Event event, uint16_t arg) { if (simple_ui_active) turbo_level = mode_max; else #endif - if (ramp_2c_style <= 1) turbo_level = MAX_LEVEL; + // 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; } @@ -517,7 +521,7 @@ void ramp_extras_config_save(uint8_t step, uint8_t value) { // 1 = Anduril 1, 2C turbo // 2+ = Anduril 2, 2C ceiling else if (4 == step) { - if (value) ramp_2c_style = value; + ramp_2c_style = value; } #endif } -- cgit v1.2.3 From fe13ae8f3cbe49ecb8edc8eeff203496138ef40a Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Tue, 31 Aug 2021 22:07:45 -0600 Subject: made 2C ceiling/turbo behavior configurable in Simple UI also made it possible to block turbo in Advanced UI (each one has a 2C style: 0 = no turbo, only ceiling 1 = Anduril 1 style, direct to turbo 2 = Anduril 2 style, ceiling unless already there, then turbo ) --- spaghetti-monster/anduril/config-default.h | 1 + spaghetti-monster/anduril/load-save-config-fsm.h | 3 + spaghetti-monster/anduril/load-save-config.c | 6 ++ spaghetti-monster/anduril/off-mode.c | 29 ++++++-- spaghetti-monster/anduril/ramp-mode.c | 93 ++++++++++++++---------- 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 -- cgit v1.2.3 From ecb8f7456687b24a30deacdabbed94bb0922ba75 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Tue, 31 Aug 2021 22:37:47 -0600 Subject: documented recent changes in the user manual --- spaghetti-monster/anduril/anduril-manual.txt | 84 +++++++++++++++++++++------- 1 file changed, 64 insertions(+), 20 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) -- cgit v1.2.3 From dcc39c757b65fbbf3c85d927b699825807846bf7 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Tue, 31 Aug 2021 22:48:13 -0600 Subject: reduced length of auto-reverse timing window from ~1000 ms to ~660ms, because it was too fast --- spaghetti-monster/anduril/candle-mode.c | 2 +- spaghetti-monster/anduril/config-default.h | 3 +++ spaghetti-monster/anduril/ramp-mode.c | 2 +- spaghetti-monster/anduril/strobe-modes.c | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) 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/config-default.h b/spaghetti-monster/anduril/config-default.h index 9c194f9..5b9897c 100644 --- a/spaghetti-monster/anduril/config-default.h +++ b/spaghetti-monster/anduril/config-default.h @@ -71,6 +71,9 @@ // 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 diff --git a/spaghetti-monster/anduril/ramp-mode.c b/spaghetti-monster/anduril/ramp-mode.c index 31f959b..6d85480 100644 --- a/spaghetti-monster/anduril/ramp-mode.c +++ b/spaghetti-monster/anduril/ramp-mode.c @@ -258,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 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; -- cgit v1.2.3 From d3e37a3825c3a8f0971b197aa3ac543a25337f4d Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Tue, 31 Aug 2021 22:58:46 -0600 Subject: fixed builds which failed to compile after recent changes --- spaghetti-monster/anduril/cfg-ff-rot66.h | 2 ++ spaghetti-monster/anduril/cfg-gchart-fet1-t1616.h | 2 +- spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h | 4 ++++ spaghetti-monster/anduril/cfg-sofirn-sp10s.h | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) 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 -- cgit v1.2.3 From ccf3833849aafe9ea54f89f283e7c9adb8ef5dfe Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Tue, 7 Sep 2021 16:28:14 -0600 Subject: copied hwdef from K9.3 for new tint-ramping D4Sv2 --- hwdef-Emisar_D4Sv2-tintramp.h | 164 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 hwdef-Emisar_D4Sv2-tintramp.h diff --git a/hwdef-Emisar_D4Sv2-tintramp.h b/hwdef-Emisar_D4Sv2-tintramp.h new file mode 100644 index 0000000..6032b4c --- /dev/null +++ b/hwdef-Emisar_D4Sv2-tintramp.h @@ -0,0 +1,164 @@ +#ifndef HWDEF_NOCTIGON_K93_H +#define HWDEF_NOCTIGON_K93_H + +/* Noctigon K9.3 driver layout (attiny1634) + * + * Pin / Name / Function + * 1 PA6 2nd LED PWM (linear) (PWM1B) + * 2 PA5 R: red aux LED (PWM0B) + * 3 PA4 G: green aux LED + * 4 PA3 B: blue aux LED + * 5 PA2 button LED + * 6 PA1 Opamp 2 enable (2nd LEDs) + * 7 PA0 Opamp 1 enable (main LEDs) + * 8 GND GND + * 9 VCC VCC + * 10 PC5 (none) + * 11 PC4 (none) + * 12 PC3 RESET + * 13 PC2 (none) + * 14 PC1 SCK + * 15 PC0 main LED PWM (FET) (PWM0A) + * 16 PB3 main LED PWM (linear) (PWM1A) + * 17 PB2 MISO + * 18 PB1 MOSI / battery voltage (ADC6) + * 19 PB0 (none) + * 20 PA7 e-switch (PCINT7) + * ADC12 thermal sensor + * + * Main LED power uses one pin to turn the Opamp on/off, + * and one pin to control Opamp power level. + * Main brightness control uses the power level pin, with 4 kHz 10-bit PWM. + * The on/off pin is only used to turn the main LED on and off, + * not to change brightness. + * Some models also have a direct-drive FET for turbo. + */ + +#ifdef ATTINY +#undef ATTINY +#endif +#define ATTINY 1634 +#include + +#define PWM_CHANNELS 3 // 2 for main LEDs, 1 for 2nd LEDs +#define PWM_BITS 10 // 0 to 1023 at 4 kHz, not 0 to 255 at 16 kHz +#define PWM_TOP 1023 + +#define SWITCH_PIN PA7 // pin 20 +#define SWITCH_PCINT PCINT7 // pin 20 pin change interrupt +#define SWITCH_PCIE PCIE0 // PCIE1 is for PCINT[7:0] +#define SWITCH_PCMSK PCMSK0 // PCMSK1 is for PCINT[7:0] +#define SWITCH_PORT PINA // PINA or PINB or PINC +#define PCINT_vect PCINT0_vect // ISR for PCINT[7:0] + +#define PWM1_PIN PB3 // pin 16, Opamp reference +#define PWM1_LVL OCR1A // OCR1A is the output compare register for PB3 + +#define PWM2_PIN PC0 // pin 15, DD FET PWM +#define PWM2_LVL OCR0A // OCR0A is the output compare register for PC0 + +#define PWM3_PIN PA6 // pin 1, 2nd LED Opamp reference +#define PWM3_LVL OCR1B // OCR1B is the output compare register for PA6 + +#define LED_ENABLE_PIN PA0 // pin 7, Opamp power +#define LED_ENABLE_PORT PORTA // control port for PA0 + +#define LED2_ENABLE_PIN PA1 // pin 6, Opamp power +#define LED2_ENABLE_PORT PORTA // control port for PA1 + + +#define USE_VOLTAGE_DIVIDER // use a dedicated pin, not VCC, because VCC input is flattened +#define VOLTAGE_PIN PB1 // Pin 18 / PB1 / ADC6 +// pin to ADC mappings are in DS table 19-4 +#define VOLTAGE_ADC ADC6D // digital input disable pin for PB1 +// DIDR0/DIDR1 mappings are in DS section 19.13.5, 19.13.6 +#define VOLTAGE_ADC_DIDR DIDR1 // DIDR channel for ADC6D +// DS tables 19-3, 19-4 +// Bit 7 6 5 4 3 2 1 0 +// REFS1 REFS0 REFEN ADC0EN MUX3 MUX2 MUX1 MUX0 +// MUX[3:0] = 0, 1, 1, 0 for ADC6 / PB1 +// divided by ... +// REFS[1:0] = 1, 0 for internal 1.1V reference +// other bits reserved +#define ADMUX_VOLTAGE_DIVIDER 0b10000110 +#define ADC_PRSCL 0x07 // clk/128 + +// Raw ADC readings at 4.4V and 2.2V +// calibrate the voltage readout here +// estimated / calculated values are: +// (voltage - D1) * (R2/(R2+R1) * 1024 / 1.1) +// D1, R1, R2 = 0, 330, 100 +#ifndef ADC_44 +//#define ADC_44 981 // raw value at 4.40V +#define ADC_44 967 // manually tweaked so 4.16V will blink out 4.2 +#endif +#ifndef ADC_22 +//#define ADC_22 489 // raw value at 2.20V +#define ADC_22 482 // manually tweaked so 4.16V will blink out 4.2 +#endif + +// this light has aux LEDs under the optic +#define AUXLED_R_PIN PA5 // pin 2 +#define AUXLED_G_PIN PA4 // pin 3 +#define AUXLED_B_PIN PA3 // pin 4 +#define AUXLED_RGB_PORT PORTA // PORTA or PORTB or PORTC +#define AUXLED_RGB_DDR DDRA // DDRA or DDRB or DDRC +#define AUXLED_RGB_PUE PUEA // PUEA or PUEB or PUEC + +#define BUTTON_LED_PIN PA2 // pin 5 +#define BUTTON_LED_PORT PORTA // for all "PA" pins +#define BUTTON_LED_DDR DDRA // for all "PA" pins +#define BUTTON_LED_PUE PUEA // for all "PA" pins + +// with so many pins, doing this all with #ifdefs gets awkward... +// ... so just hardcode it in each hwdef file instead +inline void hwdef_setup() { + // enable output ports + DDRC = (1 << PWM2_PIN); + DDRB = (1 << PWM1_PIN); + DDRA = (1 << PWM3_PIN) + | (1 << AUXLED_R_PIN) + | (1 << AUXLED_G_PIN) + | (1 << AUXLED_B_PIN) + | (1 << BUTTON_LED_PIN) + | (1 << LED_ENABLE_PIN) + | (1 << LED2_ENABLE_PIN) + ; + + // configure PWM + // Setup PWM. F_pwm = F_clkio / 2 / N / TOP, where N = prescale factor, TOP = top of counter + // pre-scale for timer: N = 1 + // Linear opamp PWM for both main and 2nd LEDs (10-bit) + // WGM1[3:0]: 0,0,1,1: PWM, Phase Correct, 10-bit (DS table 12-5) + // CS1[2:0]: 0,0,1: clk/1 (No prescaling) (DS table 12-6) + // COM1A[1:0]: 1,0: PWM OC1A in the normal direction (DS table 12-4) + // COM1B[1:0]: 1,0: PWM OC1B in the normal direction (DS table 12-4) + TCCR1A = (1< -#define PWM_CHANNELS 3 // 2 for main LEDs, 1 for 2nd LEDs -#define PWM_BITS 10 // 0 to 1023 at 4 kHz, not 0 to 255 at 16 kHz -#define PWM_TOP 1023 +#define PWM_CHANNELS 2 // 1 for main LEDs, 1 for 2nd LEDs +#define PWM_BITS 12 // 0 to 4095 at 1 kHz, not 0 to 255 at 16 kHz +#define PWM_TOP 4095 +// TODO: dynamic PWM with tint ramping +//#define USE_DYN_PWM // dynamic frequency and speed #define SWITCH_PIN PA7 // pin 20 #define SWITCH_PCINT PCINT7 // pin 20 pin change interrupt @@ -53,12 +55,16 @@ #define PWM1_PIN PB3 // pin 16, Opamp reference #define PWM1_LVL OCR1A // OCR1A is the output compare register for PB3 +#define PWM1_CNT TCNT1 // for dynamic PWM, reset phase -#define PWM2_PIN PC0 // pin 15, DD FET PWM -#define PWM2_LVL OCR0A // OCR0A is the output compare register for PC0 +#define PWM2_PIN PA6 // pin 1, 2nd LED Opamp reference +#define PWM2_LVL OCR1B // OCR1B is the output compare register for PA6 -#define PWM3_PIN PA6 // pin 1, 2nd LED Opamp reference -#define PWM3_LVL OCR1B // OCR1B is the output compare register for PA6 +#define PWM3_PIN PC0 // pin 15, DD FET PWM +#define PWM3_LVL OCR0A // OCR0A is the output compare register for PC0 + +// PWM parameters of both channels are tied together because they share a counter +#define PWM1_TOP ICR1 // holds the TOP value for for variable-resolution PWM #define LED_ENABLE_PIN PA0 // pin 7, Opamp power #define LED_ENABLE_PORT PORTA // control port for PA0 @@ -114,9 +120,9 @@ // ... so just hardcode it in each hwdef file instead inline void hwdef_setup() { // enable output ports - DDRC = (1 << PWM2_PIN); + DDRC = (1 << PWM3_PIN); DDRB = (1 << PWM1_PIN); - DDRA = (1 << PWM3_PIN) + DDRA = (1 << PWM2_PIN) | (1 << AUXLED_R_PIN) | (1 << AUXLED_G_PIN) | (1 << AUXLED_B_PIN) @@ -129,16 +135,16 @@ inline void hwdef_setup() { // Setup PWM. F_pwm = F_clkio / 2 / N / TOP, where N = prescale factor, TOP = top of counter // pre-scale for timer: N = 1 // Linear opamp PWM for both main and 2nd LEDs (10-bit) - // WGM1[3:0]: 0,0,1,1: PWM, Phase Correct, 10-bit (DS table 12-5) + // WGM1[3:0]: 1,0,1,0: PWM, Phase Correct, adjustable (DS table 12-5) // CS1[2:0]: 0,0,1: clk/1 (No prescaling) (DS table 12-6) // COM1A[1:0]: 1,0: PWM OC1A in the normal direction (DS table 12-4) // COM1B[1:0]: 1,0: PWM OC1B in the normal direction (DS table 12-4) - TCCR1A = (1< -#define PWM_CHANNELS 2 // 1 for main LEDs, 1 for 2nd LEDs +#define PWM_CHANNELS 1 // 1 virtual channel (1 for main LEDs + 1 for 2nd LEDs) #define PWM_BITS 12 // 0 to 4095 at 1 kHz, not 0 to 255 at 16 kHz #define PWM_TOP 4095 -// TODO: dynamic PWM with tint ramping -//#define USE_DYN_PWM // dynamic frequency and speed +// dynamic PWM with tint ramping +#define USE_DYN_PWM // dynamic frequency and speed +#define PWM_DATATYPE2 uint16_t // doesn't need 32-bit math #define SWITCH_PIN PA7 // pin 20 #define SWITCH_PCINT PCINT7 // pin 20 pin change interrupt @@ -53,15 +54,20 @@ #define SWITCH_PORT PINA // PINA or PINB or PINC #define PCINT_vect PCINT0_vect // ISR for PCINT[7:0] +// usually PWM1_LVL would be a hardware register, but we need to abstract +// it out to a soft brightness value, in order to handle tint ramping +// (this allows smooth thermal regulation to work, and makes things +// otherwise simpler and easier) +uint16_t PWM1_LVL; #define PWM1_PIN PB3 // pin 16, Opamp reference -#define PWM1_LVL OCR1A // OCR1A is the output compare register for PB3 +#define TINT1_LVL OCR1A // OCR1A is the output compare register for PB3 #define PWM1_CNT TCNT1 // for dynamic PWM, reset phase #define PWM2_PIN PA6 // pin 1, 2nd LED Opamp reference -#define PWM2_LVL OCR1B // OCR1B is the output compare register for PA6 +#define TINT2_LVL OCR1B // OCR1B is the output compare register for PA6 -#define PWM3_PIN PC0 // pin 15, DD FET PWM -#define PWM3_LVL OCR0A // OCR0A is the output compare register for PC0 +//#define PWM3_PIN PC0 // pin 15, DD FET PWM +//#define PWM3_LVL OCR0A // OCR0A is the output compare register for PC0 // PWM parameters of both channels are tied together because they share a counter #define PWM1_TOP ICR1 // holds the TOP value for for variable-resolution PWM @@ -120,7 +126,7 @@ // ... so just hardcode it in each hwdef file instead inline void hwdef_setup() { // enable output ports - DDRC = (1 << PWM3_PIN); + //DDRC = (1 << PWM3_PIN); DDRB = (1 << PWM1_PIN); DDRA = (1 << PWM2_PIN) | (1 << AUXLED_R_PIN) diff --git a/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h b/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h index f3a6cdd..c808cd5 100644 --- a/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h +++ b/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h @@ -1,19 +1,12 @@ -// Noctigon K9.3 config options for Anduril -#define MODEL_NUMBER "0261" -#include "hwdef-Noctigon_K9.3.h" +// Emisar D4S V2 tint-ramping config options for Anduril (based on Noctigon K9.3) +#define MODEL_NUMBER "0135" +#include "hwdef-Emisar_D4Sv2-tintramp.h" #include "hank-cfg.h" // ATTINY: 1634 -// this model requires some special code -#define OVERRIDES_FILE cfg-noctigon-k9.3.c -#define OVERRIDE_SET_LEVEL -#define OVERRIDE_GRADUAL_TICK -inline void set_level_override(uint8_t level); - // this light has three aux LED channels: R, G, B #define USE_AUX_RGB_LEDS // the aux LEDs are front-facing, so turn them off while main LEDs are on -//#define USE_AUX_RGB_LEDS_WHILE_ON // it also has an independent LED in the button #define USE_BUTTON_LED // TODO: the whole "indicator LED" thing needs to be refactored into @@ -25,24 +18,22 @@ inline void set_level_override(uint8_t level); // has two channels of independent LEDs #define USE_TINT_RAMPING -// ... but it doesn't make sense to ramp between; only toggle -#define TINT_RAMP_TOGGLE_ONLY +// how much to increase total brightness at middle tint +// (0 = 100% brightness, 64 = 200% brightness) +#define TINT_RAMPING_CORRECTION 0 // none, linear regulator doesn't need it // main LEDs -// max regulated: ~1750 lm -// FET: ~8000 lm +// output: unknown, 2000 lm? +// FET: absent / unused? // 2nd LEDs -// max regulated: ~1500 lm -// maxreg at 120: level_calc.py cube 2 150 7135 0 2.5 1740 FET 1 10 3190 +// output: unknown, 2000 lm? #define RAMP_LENGTH 150 -// main LEDs -#define PWM1_LEVELS 0,0,1,1,2,2,3,3,4,4,5,6,7,8,9,10,11,13,14,15,17,19,20,22,24,26,28,30,33,35,38,40,43,46,49,52,55,59,62,66,70,74,78,82,86,91,96,100,105,111,116,121,127,133,139,145,151,158,165,172,179,186,193,201,209,217,225,234,243,251,261,270,280,289,299,310,320,331,342,353,364,376,388,400,412,425,438,451,464,478,492,506,521,536,551,566,582,597,614,630,647,664,681,699,717,735,754,772,792,811,831,851,871,892,913,935,956,978,1001,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,0 -#define PWM2_LEVELS 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,22,51,79,109,138,168,198,229,260,292,324,357,390,423,457,492,527,562,598,634,671,708,746,784,822,861,901,941,982,1023 -// 2nd LEDs -#define PWM3_LEVELS 0,0,1,1,2,2,3,3,4,4,5,5,6,7,8,9,10,11,12,13,15,16,17,18,20,21,23,24,26,27,29,31,33,35,37,39,41,43,45,48,50,53,55,58,61,63,66,69,72,75,79,82,85,89,92,96,100,104,108,112,116,120,125,129,134,138,143,148,153,158,163,169,174,180,185,191,197,203,209,215,222,228,235,242,248,255,263,270,277,285,292,300,308,316,324,333,341,350,359,368,377,386,395,405,414,424,434,444,454,465,475,486,497,508,519,531,542,554,566,578,590,603,615,628,641,654,667,680,694,708,722,736,750,765,779,794,809,825,840,856,872,888,904,920,937,954,971,988,1005,1023 -#define DEFAULT_LEVEL 46 -#define MAX_1x7135 120 -#define MAX_Nx7135 MAX_1x7135 +// level_calc.py 5.01 1 150 7135 1 0.2 2000 --pwm dyn:80:16383:255 +// abstract ramp (power is split between both sets of LEDs) +#define PWM1_LEVELS 1,1,1,2,2,2,3,4,4,5,6,6,7,8,9,10,12,13,14,16,17,19,21,23,25,27,29,31,33,36,38,41,44,47,50,53,56,59,62,66,69,73,76,80,83,87,90,94,98,101,104,108,111,114,117,120,122,125,127,129,130,131,132,132,132,131,130,128,125,122,118,113,108,101,93,84,75,63,51,37,22,23,24,26,27,28,29,30,32,33,34,36,37,39,40,42,44,46,47,49,51,53,55,57,60,62,64,66,69,71,74,77,80,82,85,88,91,95,98,101,105,108,112,116,120,123,128,132,136,140,145,149,154,159,164,169,174,180,185,191,197,203,209,215,221,228,234,241,248,255 +#define PWM_TOPS 16383,13682,10747,15453,11909,8095,12781,14776,12231,13453,14029,11886,12249,12339,12249,12032,12939,12468,11964,12288,11697,11793,11770,11661,11489,11268,11012,10729,10425,10411,10063,9968,9833,9668,9479,9273,9054,8825,8590,8482,8233,8097,7843,7691,7439,7278,7033,6869,6702,6470,6245,6085,5872,5668,5470,5280,5056,4882,4678,4485,4268,4064,3872,3664,3468,3260,3066,2863,2652,2457,2257,2054,1866,1659,1453,1248,1060,847,651,448,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255 +#define DEFAULT_LEVEL 70 +#define MAX_1x7135 150 #define HALFSPEED_LEVEL 10 #define QUARTERSPEED_LEVEL 2 @@ -50,9 +41,9 @@ inline void set_level_override(uint8_t level); //#define DEFAULT_MANUAL_MEMORY DEFAULT_LEVEL //#define DEFAULT_MANUAL_MEMORY_TIMER 10 -#define RAMP_SMOOTH_FLOOR 3 // level 1 is unreliable (?) -#define RAMP_SMOOTH_CEIL 120 -// 10, 28, [46], 65, 83, 101, [120] +#define RAMP_SMOOTH_FLOOR 10 // level 1 is unreliable (?) +#define RAMP_SMOOTH_CEIL 130 +// 10, 30, 50, [70], 90, 110, [130] #define RAMP_DISCRETE_FLOOR 10 #define RAMP_DISCRETE_CEIL RAMP_SMOOTH_CEIL #define RAMP_DISCRETE_STEPS 7 @@ -62,21 +53,29 @@ inline void set_level_override(uint8_t level); #define SIMPLE_UI_CEIL RAMP_DISCRETE_CEIL #define SIMPLE_UI_STEPS 5 -// stop panicking at ~25% power or ~1000 lm -#define THERM_FASTER_LEVEL 100 -#define MIN_THERM_STEPDOWN DEFAULT_LEVEL -//#define THERM_NEXT_WARNING_THRESHOLD 16 // accumulate less error before adjusting -//#define THERM_RESPONSE_MAGNITUDE 128 // bigger adjustments +// stop panicking at ~1500 lm +#define THERM_FASTER_LEVEL 140 +#define MIN_THERM_STEPDOWN 80 // use the brightest setting for strobe #define STROBE_BRIGHTNESS MAX_LEVEL // slow down party strobe; this driver can't pulse for 1ms or less #define PARTY_STROBE_ONTIME 2 +// the default of 26 looks a bit flat, so increase it +#define CANDLE_AMPLITUDE 40 + +// the power regulator is a bit slow, so push it harder for a quick response from off +#define DEFAULT_JUMP_START_LEVEL 21 +#define BLINK_BRIGHTNESS DEFAULT_LEVEL #define BLINK_ONCE_TIME 12 // longer blink, since main LEDs are slow #define THERM_CAL_OFFSET 5 +#ifdef BLINK_AT_RAMP_MIDDLE +#undef BLINK_AT_RAMP_MIDDLE +#endif + // for consistency with KR4 (not otherwise necessary though) #define USE_SOFT_FACTORY_RESET diff --git a/spaghetti-monster/fsm-ramping.c b/spaghetti-monster/fsm-ramping.c index 54ca45c..c3a5147 100644 --- a/spaghetti-monster/fsm-ramping.c +++ b/spaghetti-monster/fsm-ramping.c @@ -89,6 +89,10 @@ void set_level(uint8_t level) { #if PWM_CHANNELS >= 4 PWM4_LVL = 0; #endif + #ifdef USE_TINT_RAMPING + TINT1_LVL = 0; + TINT2_LVL = 0; + #endif // disable the power channel, if relevant #ifdef LED_ENABLE_PIN LED_ENABLE_PORT &= ~(1 << LED_ENABLE_PIN); @@ -117,44 +121,6 @@ void set_level(uint8_t level) { // PWM array index = level - 1 level --; - #ifdef USE_TINT_RAMPING - #ifndef TINT_RAMPING_CORRECTION - #define TINT_RAMPING_CORRECTION 26 // 140% brightness at middle tint - #endif - // calculate actual PWM levels based on a single-channel ramp - // and a global tint value - uint8_t brightness = PWM_GET(pwm1_levels, level); - uint8_t warm_PWM, cool_PWM; - - // auto-tint modes - uint8_t mytint; - #if 1 - // perceptual by ramp level - if (tint == 0) { mytint = 255 * (uint16_t)level / RAMP_SIZE; } - else if (tint == 255) { mytint = 255 - (255 * (uint16_t)level / RAMP_SIZE); } - #else - // linear with power level - //if (tint == 0) { mytint = brightness; } - //else if (tint == 255) { mytint = 255 - brightness; } - #endif - // stretch 1-254 to fit 0-255 range (hits every value except 98 and 198) - else { mytint = (tint * 100 / 99) - 1; } - - // middle tints sag, so correct for that effect - uint16_t base_PWM = brightness; - // correction is only necessary when PWM is fast - if (level > HALFSPEED_LEVEL) { - base_PWM = brightness - + ((((uint16_t)brightness) * TINT_RAMPING_CORRECTION / 64) * triangle_wave(mytint) / 255); - } - - cool_PWM = (((uint16_t)mytint * (uint16_t)base_PWM) + 127) / 255; - warm_PWM = base_PWM - cool_PWM; - - PWM1_LVL = warm_PWM; - PWM2_LVL = cool_PWM; - #else // ifdef USE_TINT_RAMPING - #if PWM_CHANNELS >= 1 PWM1_LVL = PWM_GET(pwm1_levels, level); #endif @@ -168,8 +134,6 @@ void set_level(uint8_t level) { PWM4_LVL = PWM_GET(pwm4_levels, level); #endif - #endif // ifdef USE_TINT_RAMPING - #ifdef USE_DYN_PWM uint16_t top = PWM_GET(pwm_tops, level); #ifdef PWM1_CNT @@ -214,6 +178,10 @@ void set_level(uint8_t level) { } #endif } + #ifdef USE_TINT_RAMPING + update_tint(); + #endif + #ifdef PWM1_CNT prev_level = api_level; #endif @@ -289,6 +257,9 @@ void gradual_tick() { { actual_level = gt + 1; } + #ifdef USE_TINT_RAMPING + update_tint(); + #endif #ifdef USE_DYNAMIC_UNDERCLOCKING auto_clock_speed(); #endif @@ -296,5 +267,62 @@ void gradual_tick() { #endif // ifdef OVERRIDE_GRADUAL_TICK #endif // ifdef USE_SET_LEVEL_GRADUALLY + +#ifdef USE_TINT_RAMPING +void update_tint() { + #ifndef TINT_RAMPING_CORRECTION + #define TINT_RAMPING_CORRECTION 26 // 140% brightness at middle tint + #endif + + // calculate actual PWM levels based on a single-channel ramp + // and a global tint value + //PWM_DATATYPE brightness = PWM_GET(pwm1_levels, level); + PWM_DATATYPE brightness = PWM1_LVL; + PWM_DATATYPE warm_PWM, cool_PWM; + + // auto-tint modes + uint8_t mytint; + uint8_t level = actual_level - 1; + #if 1 + // perceptual by ramp level + if (tint == 0) { mytint = 255 * (uint16_t)level / RAMP_SIZE; } + else if (tint == 255) { mytint = 255 - (255 * (uint16_t)level / RAMP_SIZE); } + #else + // linear with power level + //if (tint == 0) { mytint = brightness; } + //else if (tint == 255) { mytint = 255 - brightness; } + #endif + // stretch 1-254 to fit 0-255 range (hits every value except 98 and 198) + else { mytint = (tint * 100 / 99) - 1; } + + // middle tints sag, so correct for that effect + PWM_DATATYPE2 base_PWM = brightness; + // correction is only necessary when PWM is fast + #if defined(TINT_RAMPING_CORRECTION) && (TINT_RAMPING_CORRECTION > 0) + if (level > HALFSPEED_LEVEL) { + base_PWM = brightness + + ((((PWM_DATATYPE2)brightness) * TINT_RAMPING_CORRECTION / 64) * triangle_wave(mytint) / 255); + } + #endif + + cool_PWM = (((PWM_DATATYPE2)mytint * (PWM_DATATYPE2)base_PWM) + 127) / 255; + warm_PWM = base_PWM - cool_PWM; + + TINT1_LVL = warm_PWM; + TINT2_LVL = cool_PWM; + + // disable the power channel, if relevant + #ifdef LED_ENABLE_PIN + if (! warm_PWM) + LED_ENABLE_PORT &= ~(1 << LED_ENABLE_PIN); + #endif + #ifdef LED2_ENABLE_PIN + if (! cool_PWM) + LED2_ENABLE_PORT &= ~(1 << LED2_ENABLE_PIN); + #endif +} +#endif // ifdef USE_TINT_RAMPING + + #endif // ifdef USE_RAMPING #endif diff --git a/spaghetti-monster/fsm-ramping.h b/spaghetti-monster/fsm-ramping.h index 7a4fa3b..d8aad18 100644 --- a/spaghetti-monster/fsm-ramping.h +++ b/spaghetti-monster/fsm-ramping.h @@ -42,6 +42,10 @@ inline void set_level_gradually(uint8_t lvl); void gradual_tick(); #endif +#ifdef USE_TINT_RAMPING +void update_tint(); +#endif + // auto-detect the data type for PWM tables #ifndef PWM_BITS #define PWM_BITS 8 @@ -49,10 +53,14 @@ void gradual_tick(); #endif #if PWM_BITS <= 8 #define PWM_DATATYPE uint8_t +#define PWM_DATATYPE2 uint16_t #define PWM_TOP 255 #define PWM_GET(x,y) pgm_read_byte(x+y) #else #define PWM_DATATYPE uint16_t +#ifndef PWM_DATATYPE2 +#define PWM_DATATYPE2 uint32_t +#endif #ifndef PWM_TOP #define PWM_TOP 1023 // 10 bits by default #endif -- cgit v1.2.3 From 7393af3c7e2539d78243a593d061a2523ea9e39f Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Wed, 8 Sep 2021 17:15:14 -0600 Subject: fixed outdated comment in KR4 hwdef --- hwdef-Noctigon_KR4.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hwdef-Noctigon_KR4.h b/hwdef-Noctigon_KR4.h index eee4e08..75dd4c6 100644 --- a/hwdef-Noctigon_KR4.h +++ b/hwdef-Noctigon_KR4.h @@ -132,7 +132,7 @@ inline void hwdef_setup() { // configure PWM // Setup PWM. F_pwm = F_clkio / 2 / N / TOP, where N = prescale factor, TOP = top of counter // pre-scale for timer: N = 1 - // WGM1[3:0]: 0,0,1,1: PWM, Phase Correct, 10-bit (DS table 12-5) + // WGM1[3:0]: 1,0,1,0: PWM, Phase Correct, adjustable (DS table 12-5) // CS1[2:0]: 0,0,1: clk/1 (No prescaling) (DS table 12-6) // COM1A[1:0]: 1,0: PWM OC1A in the normal direction (DS table 12-4) // COM1B[1:0]: 1,0: PWM OC1B in the normal direction (DS table 12-4) -- cgit v1.2.3 From c89d9f41b2dabca6bce12bc2facec60182354ddb Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Wed, 8 Sep 2021 20:45:20 -0600 Subject: copied Q8 hwdef to LT1 so I can improve it --- hwdef-BLF_LT1.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 hwdef-BLF_LT1.h diff --git a/hwdef-BLF_LT1.h b/hwdef-BLF_LT1.h new file mode 100644 index 0000000..5dac5d2 --- /dev/null +++ b/hwdef-BLF_LT1.h @@ -0,0 +1,21 @@ +#ifndef HWDEF_BLF_Q8_H +#define HWDEF_BLF_Q8_H + +/* BLF Q8 driver layout + * Q8 driver is the same as a D4, basically + */ + +// ... except the Q8 has a lighted button +#ifndef AUXLED_PIN +#define AUXLED_PIN PB4 // pin 3 +#endif + +// ... and slightly different calibration +#ifndef VOLTAGE_FUDGE_FACTOR +#define VOLTAGE_FUDGE_FACTOR 7 // add 0.35V +#endif + +// Q8 driver is the same as a D4, basically +#include "hwdef-Emisar_D4.h" + +#endif -- cgit v1.2.3 From baee74468b044a664e80eaf4540af6d001186bce Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Wed, 8 Sep 2021 21:38:20 -0600 Subject: fixed D4Sv2-tintramp PWM_TOP (should be set to the value it needs during thermal regulation) --- hwdef-Emisar_D4Sv2-tintramp.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hwdef-Emisar_D4Sv2-tintramp.h b/hwdef-Emisar_D4Sv2-tintramp.h index 2b36ed4..a0300ad 100644 --- a/hwdef-Emisar_D4Sv2-tintramp.h +++ b/hwdef-Emisar_D4Sv2-tintramp.h @@ -41,8 +41,8 @@ #include #define PWM_CHANNELS 1 // 1 virtual channel (1 for main LEDs + 1 for 2nd LEDs) -#define PWM_BITS 12 // 0 to 4095 at 1 kHz, not 0 to 255 at 16 kHz -#define PWM_TOP 4095 +#define PWM_BITS 14 // 0 to 16383 at variable Hz, not 0 to 255 at 16 kHz +#define PWM_TOP 255 // dynamic PWM with tint ramping #define USE_DYN_PWM // dynamic frequency and speed #define PWM_DATATYPE2 uint16_t // doesn't need 32-bit math -- cgit v1.2.3 From 7489f72a8eedf89be0052ebf72e9a1e41aa5ed78 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Wed, 8 Sep 2021 21:40:27 -0600 Subject: got BLF LT1 working again, using new tint-ramping code --- hwdef-BLF_LT1.h | 54 +++++++++++++++++++++++------ spaghetti-monster/anduril/cfg-blf-lantern.h | 23 ++---------- spaghetti-monster/fsm-main.c | 4 ++- 3 files changed, 50 insertions(+), 31 deletions(-) diff --git a/hwdef-BLF_LT1.h b/hwdef-BLF_LT1.h index 5dac5d2..d0c2821 100644 --- a/hwdef-BLF_LT1.h +++ b/hwdef-BLF_LT1.h @@ -1,21 +1,55 @@ -#ifndef HWDEF_BLF_Q8_H -#define HWDEF_BLF_Q8_H +#ifndef HWDEF_BLF_LT1_H +#define HWDEF_BLF_LT1_H -/* BLF Q8 driver layout - * Q8 driver is the same as a D4, basically +/* BLF LT1 driver layout + * ---- + * Reset -|1 8|- VCC + * eswitch -|2 7|- (unused) + * aux LED -|3 6|- PWM (5000K) + * GND -|4 5|- PWM (3000K) + * ---- */ -// ... except the Q8 has a lighted button -#ifndef AUXLED_PIN +#define ATTINY 85 +#include + +#define PWM_CHANNELS 1 // 1 virtual channel (1 for main LEDs + 1 for 2nd LEDs) +#define PWM_BITS 8 // 0 to 255 at 15.6 kHz +#define PWM_TOP 255 + +// dynamic PWM with tint ramping (not supported on attiny85) +//#define USE_DYN_PWM // dynamic frequency and speed +//#define PWM1_CNT TCNT0 // for dynamic PWM, reset phase + +// usually PWM1_LVL would be a hardware register, but we need to abstract +// it out to a soft brightness value, in order to handle tint ramping +// (this allows smooth thermal regulation to work, and makes things +// otherwise simpler and easier) +uint8_t PWM1_LVL; + +#define PWM1_PIN PB0 // pin 5, warm tint PWM +#define TINT1_LVL OCR0A // OCR0A is the output compare register for PB0 + +#define PWM2_PIN PB1 // pin 6, cold tint PWM +#define TINT2_LVL OCR0B // OCR0B is the output compare register for PB1 + + #define AUXLED_PIN PB4 // pin 3 -#endif -// ... and slightly different calibration +#define SWITCH_PIN PB3 // pin 2 +#define SWITCH_PCINT PCINT3 // pin 2 pin change interrupt + +#define ADC_PRSCL 0x07 // clk/128 + +// average drop across diode on this hardware #ifndef VOLTAGE_FUDGE_FACTOR #define VOLTAGE_FUDGE_FACTOR 7 // add 0.35V #endif -// Q8 driver is the same as a D4, basically -#include "hwdef-Emisar_D4.h" +#define FAST 0xA3 // fast PWM both channels +#define PHASE 0xA1 // phase-correct PWM both channels + +#define LAYOUT_DEFINED + #endif diff --git a/spaghetti-monster/anduril/cfg-blf-lantern.h b/spaghetti-monster/anduril/cfg-blf-lantern.h index 28c7dbb..48ed1f7 100644 --- a/spaghetti-monster/anduril/cfg-blf-lantern.h +++ b/spaghetti-monster/anduril/cfg-blf-lantern.h @@ -1,16 +1,7 @@ // BLF Lantern config options for Anduril #define MODEL_NUMBER "0621" -/* BLF Lantern pinout - * ---- - * Reset -|1 8|- VCC - * eswitch -|2 7|- powerbank enable? - * aux LED -|3 6|- PWM (5000K) - * GND -|4 5|- PWM (3000K) - * ---- - */ - -// basically the same as a Q8... sort of -#include "hwdef-BLF_Q8.h" +#include "hwdef-BLF_LT1.h" +// ATTINY: 85 // the button lights up #define USE_INDICATOR_LED @@ -56,7 +47,7 @@ // LT1 can handle heat well, so don't limit simple mode #define SIMPLE_UI_FLOOR RAMP_DISCRETE_FLOOR -#define SIMPLE_UI_CEIL RAMP_DISCRETE_CEIL +#define SIMPLE_UI_CEIL RAMP_DISCRETE_CEIL #define SIMPLE_UI_STEPS RAMP_DISCRETE_STEPS #define USE_SOS_MODE @@ -68,14 +59,6 @@ #undef USE_THERMAL_REGULATION #endif -// also, the set_level_gradually() thing isn't compatible with tint ramping -// (but unsetting it here doesn't actually do anything, because the thermal -// regulation define enables it later... so this is mostly just a note to -// make this compatibility issue explicit) -#ifdef USE_SET_LEVEL_GRADUALLY -#undef USE_SET_LEVEL_GRADUALLY -#endif - // don't blink while ramping #ifdef BLINK_AT_RAMP_MIDDLE #undef BLINK_AT_RAMP_MIDDLE diff --git a/spaghetti-monster/fsm-main.c b/spaghetti-monster/fsm-main.c index f3c319c..7031009 100644 --- a/spaghetti-monster/fsm-main.c +++ b/spaghetti-monster/fsm-main.c @@ -47,7 +47,9 @@ static inline void hw_setup() { TCCR0B = 0x01; // pre-scaler for timer (1 => 1, 2 => 8, 3 => 64...) TCCR0A = PHASE; #endif - #if PWM_CHANNELS >= 2 + // tint ramping needs second channel enabled, + // despite PWM_CHANNELS being only 1 + #if (PWM_CHANNELS >= 2) || defined(USE_TINT_RAMPING) DDRB |= (1 << PWM2_PIN); #endif #if PWM_CHANNELS >= 3 -- cgit v1.2.3 From 68c4818b68af698ee475611954c5cd52d030900b Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Wed, 8 Sep 2021 22:21:50 -0600 Subject: changed D4Sv2-tintramp from 255 to 511 for lowest PWM TOP value, to make its thermal regulation smoother and generally increase tint ramp resolution in middle modes (also, tried thermal regulation, and it works) --- hwdef-Emisar_D4Sv2-tintramp.h | 4 ++-- spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hwdef-Emisar_D4Sv2-tintramp.h b/hwdef-Emisar_D4Sv2-tintramp.h index a0300ad..64550c3 100644 --- a/hwdef-Emisar_D4Sv2-tintramp.h +++ b/hwdef-Emisar_D4Sv2-tintramp.h @@ -42,10 +42,10 @@ #define PWM_CHANNELS 1 // 1 virtual channel (1 for main LEDs + 1 for 2nd LEDs) #define PWM_BITS 14 // 0 to 16383 at variable Hz, not 0 to 255 at 16 kHz -#define PWM_TOP 255 +#define PWM_TOP 511 // dynamic PWM with tint ramping #define USE_DYN_PWM // dynamic frequency and speed -#define PWM_DATATYPE2 uint16_t // doesn't need 32-bit math +#define PWM_DATATYPE2 uint32_t // only needs 32-bit if ramp values go over 255 #define SWITCH_PIN PA7 // pin 20 #define SWITCH_PCINT PCINT7 // pin 20 pin change interrupt diff --git a/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h b/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h index c808cd5..abec6bb 100644 --- a/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h +++ b/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h @@ -28,10 +28,10 @@ // 2nd LEDs // output: unknown, 2000 lm? #define RAMP_LENGTH 150 -// level_calc.py 5.01 1 150 7135 1 0.2 2000 --pwm dyn:80:16383:255 +// level_calc.py 5.01 1 150 7135 1 0.2 2000 --pwm dyn:80:16383:511 // abstract ramp (power is split between both sets of LEDs) -#define PWM1_LEVELS 1,1,1,2,2,2,3,4,4,5,6,6,7,8,9,10,12,13,14,16,17,19,21,23,25,27,29,31,33,36,38,41,44,47,50,53,56,59,62,66,69,73,76,80,83,87,90,94,98,101,104,108,111,114,117,120,122,125,127,129,130,131,132,132,132,131,130,128,125,122,118,113,108,101,93,84,75,63,51,37,22,23,24,26,27,28,29,30,32,33,34,36,37,39,40,42,44,46,47,49,51,53,55,57,60,62,64,66,69,71,74,77,80,82,85,88,91,95,98,101,105,108,112,116,120,123,128,132,136,140,145,149,154,159,164,169,174,180,185,191,197,203,209,215,221,228,234,241,248,255 -#define PWM_TOPS 16383,13682,10747,15453,11909,8095,12781,14776,12231,13453,14029,11886,12249,12339,12249,12032,12939,12468,11964,12288,11697,11793,11770,11661,11489,11268,11012,10729,10425,10411,10063,9968,9833,9668,9479,9273,9054,8825,8590,8482,8233,8097,7843,7691,7439,7278,7033,6869,6702,6470,6245,6085,5872,5668,5470,5280,5056,4882,4678,4485,4268,4064,3872,3664,3468,3260,3066,2863,2652,2457,2257,2054,1866,1659,1453,1248,1060,847,651,448,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255 +#define PWM1_LEVELS 1,1,1,2,2,2,3,4,4,5,6,6,7,8,9,10,12,13,14,16,17,19,20,22,24,26,28,30,33,35,37,40,43,45,48,51,54,57,60,63,66,69,72,75,78,82,85,88,91,93,96,99,101,103,106,107,109,110,111,112,112,112,111,110,108,105,102,98,94,88,82,74,66,57,46,35,37,38,40,42,44,46,48,50,53,55,57,60,63,65,68,71,74,77,80,83,87,90,94,98,102,106,110,114,118,123,128,132,137,142,148,153,159,164,170,176,183,189,196,202,209,216,224,231,239,247,255,263,272,281,290,299,309,318,328,339,349,360,371,382,394,406,418,430,443,456,469,483,497,511 +#define PWM_TOPS 16383,13675,10740,15439,11908,8117,12779,14760,12239,13449,14017,11902,12260,12349,12259,12045,12929,12466,11970,12281,11704,11791,11178,11133,11013,10837,10619,10370,10425,10113,9792,9719,9603,9248,9093,8917,8725,8521,8309,8091,7870,7648,7425,7204,6985,6855,6638,6425,6218,5952,5760,5573,5339,5116,4952,4704,4513,4292,4084,3889,3673,3470,3252,3048,2833,2608,2401,2187,1989,1767,1563,1339,1134,929,711,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511 #define DEFAULT_LEVEL 70 #define MAX_1x7135 150 #define HALFSPEED_LEVEL 10 -- cgit v1.2.3 From aebf13971bb2cd9b0e3976a8cab3bac23391dbb6 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Fri, 10 Sep 2021 00:35:44 -0600 Subject: added -mrelax to build.sh; saves ~330 bytes on t1634 builds (suggested by solrize) (doesn't seem to reduce size of t85 builds though) --- bin/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/build.sh b/bin/build.sh index aa983c8..58896a5 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -30,7 +30,7 @@ export CC=avr-gcc export OBJCOPY=avr-objcopy export DFPFLAGS="-B $ATTINY_DFP/gcc/dev/$MCU/ -I $ATTINY_DFP/include/" export CFLAGS="-Wall -g -Os -mmcu=$MCU -c -std=gnu99 -fgnu89-inline -fwhole-program -DATTINY=$ATTINY -I.. -I../.. -I../../.. -fshort-enums $DFPFLAGS" -export OFLAGS="-Wall -g -Os -mmcu=$MCU $DFPFLAGS" +export OFLAGS="-Wall -g -Os -mmcu=$MCU -mrelax $DFPFLAGS" export LDFLAGS="-fgnu89-inline" export OBJCOPYFLAGS='--set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O ihex' export OBJS=$PROGRAM.o -- cgit v1.2.3 From 5405c977d887e4077e76c4ba035b4676509fec12 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Fri, 10 Sep 2021 00:40:47 -0600 Subject: added D4Sv2-tintramp-FET build, which uses a FET on one set of LEDs for turbo modes (it's weird, but Hank wants it) also reworked gradual tint adjustment a bit, so some complex parts go in set_level() instead (probably needs more testing) --- hwdef-Emisar_D4Sv2-tintramp.h | 16 +++--- .../anduril/cfg-emisar-d4sv2-tintramp-fet.h | 62 ++++++++++++++++++++++ .../anduril/cfg-emisar-d4sv2-tintramp.h | 4 +- spaghetti-monster/fsm-ramping.c | 19 ++++--- 4 files changed, 86 insertions(+), 15 deletions(-) create mode 100644 spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp-fet.h diff --git a/hwdef-Emisar_D4Sv2-tintramp.h b/hwdef-Emisar_D4Sv2-tintramp.h index 64550c3..76f6097 100644 --- a/hwdef-Emisar_D4Sv2-tintramp.h +++ b/hwdef-Emisar_D4Sv2-tintramp.h @@ -19,7 +19,7 @@ * 12 PC3 RESET * 13 PC2 (none) * 14 PC1 SCK - * 15 PC0 main LED PWM (FET) (PWM0A) (unused because tint ramping) + * 15 PC0 main LED PWM (FET) (PWM0A) (unused on some models because tint ramping) * 16 PB3 main LED PWM (linear) (PWM1A) * 17 PB2 MISO * 18 PB1 MOSI / battery voltage (ADC6) @@ -63,11 +63,15 @@ uint16_t PWM1_LVL; #define TINT1_LVL OCR1A // OCR1A is the output compare register for PB3 #define PWM1_CNT TCNT1 // for dynamic PWM, reset phase -#define PWM2_PIN PA6 // pin 1, 2nd LED Opamp reference +// gah, this driver is weird... +// two linear channels are treated as one, +// while there's also a FET on one channel for turbo on half the LEDs +// so the FET needs to be "PWM2" but the second linear is "TINT2" +#define PWM3_PIN PA6 // pin 1, 2nd LED Opamp reference #define TINT2_LVL OCR1B // OCR1B is the output compare register for PA6 -//#define PWM3_PIN PC0 // pin 15, DD FET PWM -//#define PWM3_LVL OCR0A // OCR0A is the output compare register for PC0 +#define PWM2_PIN PC0 // pin 15, DD FET PWM +#define PWM2_LVL OCR0A // OCR0A is the output compare register for PC0 // PWM parameters of both channels are tied together because they share a counter #define PWM1_TOP ICR1 // holds the TOP value for for variable-resolution PWM @@ -126,9 +130,9 @@ uint16_t PWM1_LVL; // ... so just hardcode it in each hwdef file instead inline void hwdef_setup() { // enable output ports - //DDRC = (1 << PWM3_PIN); + DDRC = (1 << PWM2_PIN); DDRB = (1 << PWM1_PIN); - DDRA = (1 << PWM2_PIN) + DDRA = (1 << PWM3_PIN) | (1 << AUXLED_R_PIN) | (1 << AUXLED_G_PIN) | (1 << AUXLED_B_PIN) diff --git a/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp-fet.h b/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp-fet.h new file mode 100644 index 0000000..3c638a7 --- /dev/null +++ b/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp-fet.h @@ -0,0 +1,62 @@ +// Emisar D4S V2 tint-ramping (plus FET) config options for Anduril (based on Noctigon K9.3) +#include "cfg-emisar-d4sv2-tintramp.h" +#undef MODEL_NUMBER +#define MODEL_NUMBER "0136" +// ATTINY: 1634 + +// enable the FET channel, even though it's ... kinda funky +#undef PWM_CHANNELS +#define PWM_CHANNELS 2 + +// main LEDs +// output: unknown, 2000 lm? +// FET: unknown, 3000 lm? +// 2nd LEDs +// output: unknown, 2000 lm? +#define RAMP_LENGTH 150 +// level_calc.py 5.01 1 140 7135 1 0.2 2000 --pwm dyn:69:16383:511 +// plus a FET segment +// level_calc.py 2 1 10 7135 5 50.0 3000 --pwm 255 +// abstract ramp (power is split between both sets of LEDs) +// append: ,500,482,456,420,374,318,252,178,94,0 +#undef PWM1_LEVELS +#define PWM1_LEVELS 1,1,1,2,2,3,3,4,5,5,6,7,8,9,10,12,13,14,16,18,19,21,23,25,27,30,32,35,37,40,43,45,48,51,54,58,61,64,67,70,74,77,80,83,86,89,92,95,97,99,101,103,105,106,106,107,106,106,104,102,100,96,92,87,81,73,65,56,45,33,35,37,39,41,43,45,47,49,52,54,57,59,62,65,68,71,74,78,81,85,89,92,96,100,105,109,114,118,123,128,133,139,144,150,156,162,168,175,181,188,195,202,210,217,225,233,242,250,259,268,278,287,297,307,318,328,339,351,362,374,386,399,412,425,438,452,466,481,496,511,500,482,456,420,374,318,252,178,94,0 +// append: ,511,511,511,511,511,511,511,511,511,511 +#undef PWM_TOPS +#define PWM_TOPS 16383,13469,10296,14694,10845,14620,11496,13507,14400,11954,12507,12676,12605,12376,12036,12805,12240,11650,11882,11933,11243,11155,10988,10763,10497,10569,10223,10164,9781,9646,9475,9071,8870,8652,8422,8330,8077,7823,7569,7318,7169,6919,6676,6439,6209,5986,5770,5561,5305,5063,4834,4618,4413,4180,3925,3723,3468,3264,3016,2787,2576,2333,2111,1885,1658,1412,1189,968,734,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511 +// prepend: 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +#define PWM2_LEVELS 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,14,27,45,68,96,129,166,208,255 +#undef DEFAULT_LEVEL +#define DEFAULT_LEVEL 70 +#undef MAX_1x7135 +#define MAX_1x7135 140 + +#undef RAMP_SMOOTH_FLOOR +#define RAMP_SMOOTH_FLOOR 10 // level 1 is unreliable (?) +#undef RAMP_SMOOTH_CEIL +#define RAMP_SMOOTH_CEIL 130 +// 10, 30, 50, [70], 90, 110, [130] +#undef RAMP_DISCRETE_FLOOR +#define RAMP_DISCRETE_FLOOR 10 +#undef RAMP_DISCRETE_CEIL +#define RAMP_DISCRETE_CEIL RAMP_SMOOTH_CEIL +#undef RAMP_DISCRETE_STEPS +#define RAMP_DISCRETE_STEPS 7 + +// safe limit highest regulated power (no FET or turbo) +#undef SIMPLE_UI_FLOOR +#define SIMPLE_UI_FLOOR RAMP_DISCRETE_FLOOR +#undef SIMPLE_UI_CEIL +#define SIMPLE_UI_CEIL RAMP_DISCRETE_CEIL +#undef SIMPLE_UI_STEPS +#define SIMPLE_UI_STEPS 5 + +// stop panicking at ~2000 lm +#undef THERM_FASTER_LEVEL +#define THERM_FASTER_LEVEL 140 +#undef MIN_THERM_STEPDOWN +#define MIN_THERM_STEPDOWN 70 // should be above highest dyn_pwm level + +// speed up party strobe; the FET is really fast +#undef PARTY_STROBE_ONTIME + diff --git a/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h b/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h index abec6bb..67de5aa 100644 --- a/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h +++ b/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h @@ -28,7 +28,7 @@ // 2nd LEDs // output: unknown, 2000 lm? #define RAMP_LENGTH 150 -// level_calc.py 5.01 1 150 7135 1 0.2 2000 --pwm dyn:80:16383:511 +// level_calc.py 5.01 1 150 7135 1 0.2 2000 --pwm dyn:75:16383:511 // abstract ramp (power is split between both sets of LEDs) #define PWM1_LEVELS 1,1,1,2,2,2,3,4,4,5,6,6,7,8,9,10,12,13,14,16,17,19,20,22,24,26,28,30,33,35,37,40,43,45,48,51,54,57,60,63,66,69,72,75,78,82,85,88,91,93,96,99,101,103,106,107,109,110,111,112,112,112,111,110,108,105,102,98,94,88,82,74,66,57,46,35,37,38,40,42,44,46,48,50,53,55,57,60,63,65,68,71,74,77,80,83,87,90,94,98,102,106,110,114,118,123,128,132,137,142,148,153,159,164,170,176,183,189,196,202,209,216,224,231,239,247,255,263,272,281,290,299,309,318,328,339,349,360,371,382,394,406,418,430,443,456,469,483,497,511 #define PWM_TOPS 16383,13675,10740,15439,11908,8117,12779,14760,12239,13449,14017,11902,12260,12349,12259,12045,12929,12466,11970,12281,11704,11791,11178,11133,11013,10837,10619,10370,10425,10113,9792,9719,9603,9248,9093,8917,8725,8521,8309,8091,7870,7648,7425,7204,6985,6855,6638,6425,6218,5952,5760,5573,5339,5116,4952,4704,4513,4292,4084,3889,3673,3470,3252,3048,2833,2608,2401,2187,1989,1767,1563,1339,1134,929,711,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511 @@ -55,7 +55,7 @@ // stop panicking at ~1500 lm #define THERM_FASTER_LEVEL 140 -#define MIN_THERM_STEPDOWN 80 +#define MIN_THERM_STEPDOWN 75 // should be above highest dyn_pwm level // use the brightest setting for strobe #define STROBE_BRIGHTNESS MAX_LEVEL diff --git a/spaghetti-monster/fsm-ramping.c b/spaghetti-monster/fsm-ramping.c index c3a5147..50907ec 100644 --- a/spaghetti-monster/fsm-ramping.c +++ b/spaghetti-monster/fsm-ramping.c @@ -204,6 +204,7 @@ void gradual_tick() { if (gt < actual_level) gt = actual_level - 1; else if (gt > actual_level) gt = actual_level + 1; + /* #ifdef LED_ENABLE_PIN_LEVEL_MIN // only enable during part of the ramp if ((gt >= LED_ENABLE_PIN_LEVEL_MIN) @@ -212,6 +213,7 @@ void gradual_tick() { else // disable during other parts of the ramp LED_ENABLE_PORT &= ~(1 << LED_ENABLE_PIN); #endif + */ gt --; // convert 1-based number to 0-based @@ -255,14 +257,17 @@ void gradual_tick() { #endif ) { - actual_level = gt + 1; + //actual_level = gt + 1; + set_level(gt + 1); } - #ifdef USE_TINT_RAMPING - update_tint(); - #endif - #ifdef USE_DYNAMIC_UNDERCLOCKING - auto_clock_speed(); - #endif + // is handled in set_level() + //#ifdef USE_TINT_RAMPING + //update_tint(); + //#endif + // is handled in set_level() + //#ifdef USE_DYNAMIC_UNDERCLOCKING + //auto_clock_speed(); + //#endif } #endif // ifdef OVERRIDE_GRADUAL_TICK #endif // ifdef USE_SET_LEVEL_GRADUALLY -- cgit v1.2.3 From b8b6214b7e9c3f2bb86f7379995fb64c73736d11 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Fri, 10 Sep 2021 00:48:01 -0600 Subject: fixed ancient bug which caused a weird up-spike in thermal regulation during initial turbo drop, on 3-channel drivers like FW3A and ROT66 (as shown here: http://toykeeper.net/torches/fw3a/therm-2019-05-22.1.png ) What happened was... the FET would start to drop, but gradual adjustments noticed that the Nx7135 channel needed to go from 0 to 255, so it would then slowly ramp that up, and then afterward, the FET drop could finally continue... because the code didn't jump straight from 0 to 255 like it was supposed to. Simple, easy fix: Make channel 2 go up immediately just like channel 1 does. This makes the thermal response several seconds faster than it was before, so it doesn't get as hot, and is less likely to overshoot and bounce later. --- spaghetti-monster/fsm-ramping.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/spaghetti-monster/fsm-ramping.c b/spaghetti-monster/fsm-ramping.c index 50907ec..88fb490 100644 --- a/spaghetti-monster/fsm-ramping.c +++ b/spaghetti-monster/fsm-ramping.c @@ -221,14 +221,23 @@ void gradual_tick() { #if PWM_CHANNELS >= 1 target = PWM_GET(pwm1_levels, gt); - if ((gt < actual_level) // special case for FET-only turbo - && (PWM1_LVL == 0) // (bypass adjustment period for first step) - && (target == PWM_TOP)) PWM1_LVL = PWM_TOP; - else if (PWM1_LVL < target) PWM1_LVL ++; + #if PWM_CHANNELS > 1 + if ((gt < actual_level) // special case for FET-only turbo + && (PWM1_LVL == 0) // (bypass adjustment period for first step) + && (target == PWM_TOP)) PWM1_LVL = PWM_TOP; + else + #endif + if (PWM1_LVL < target) PWM1_LVL ++; else if (PWM1_LVL > target) PWM1_LVL --; #endif #if PWM_CHANNELS >= 2 target = PWM_GET(pwm2_levels, gt); + #if PWM_CHANNELS > 2 + if ((gt < actual_level) // special case for FET-only turbo + && (PWM2_LVL == 0) // (bypass adjustment period for first step) + && (target == PWM_TOP)) PWM2_LVL = PWM_TOP; + else + #endif if (PWM2_LVL < target) PWM2_LVL ++; else if (PWM2_LVL > target) PWM2_LVL --; #endif -- cgit v1.2.3 From 6ef2962edefcb3ddd1c21a42b0c6b3bfebcd8d59 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Fri, 10 Sep 2021 01:15:37 -0600 Subject: fixed blf-lantern-t1616 build... I think (can't test because I have no hardware, but it at least compiles) --- hwdef-BLF_LT1-t1616.h | 107 ++++++++++++++++++++++ spaghetti-monster/anduril/cfg-blf-lantern-t1616.h | 18 +--- 2 files changed, 109 insertions(+), 16 deletions(-) create mode 100644 hwdef-BLF_LT1-t1616.h diff --git a/hwdef-BLF_LT1-t1616.h b/hwdef-BLF_LT1-t1616.h new file mode 100644 index 0000000..8e5c58b --- /dev/null +++ b/hwdef-BLF_LT1-t1616.h @@ -0,0 +1,107 @@ +#ifndef HWDEF_BLF_LANTERN_T1616_H +#define HWDEF_BLF_LANTERN_T1616_H + +/* BLF LT1 driver layout using the Attiny1616 + +Driver pinout: + * eSwitch: PA5 + * Aux LED: PB5 + * PWM FET: PB0 (TCA0 WO0) + * PWM 1x7135: PB1 (TCA0 WO1) + * Voltage: VCC + +*/ + + +#define LAYOUT_DEFINED + +#ifdef ATTINY +#undef ATTINY +#endif +#define ATTINY 1616 +#include + +#define PWM_CHANNELS 1 + +#ifndef SWITCH_PIN +#define SWITCH_PIN PIN5_bp +#define SWITCH_PORT VPORTA.IN +#define SWITCH_ISC_REG PORTA.PIN2CTRL +#define SWITCH_VECT PORTA_PORT_vect +#define SWITCH_INTFLG VPORTA.INTFLAGS +#endif + + +// usually PWM1_LVL would be a hardware register, but we need to abstract +// it out to a soft brightness value, in order to handle tint ramping +// (this allows smooth thermal regulation to work, and makes things +// otherwise simpler and easier) +uint8_t PWM1_LVL; + +// warm tint channel +#ifndef PWM1_PIN +#define PWM1_PIN PB1 // +#define TINT1_LVL TCA0.SINGLE.CMP1 // CMP1 is the output compare register for PB1 +#endif + +// cold tint channel +#ifndef PWM2_PIN +#define PWM2_PIN PB0 // +#define TINT2_LVL TCA0.SINGLE.CMP0 // CMP0 is the output compare register for PB0 +#endif + +// average drop across diode on this hardware +#ifndef VOLTAGE_FUDGE_FACTOR +#define VOLTAGE_FUDGE_FACTOR 7 // add 0.35V +#endif + + +// lighted button +#ifndef AUXLED_PIN +#define AUXLED_PIN PIN5_bp +#define AUXLED_PORT PORTB +#endif + + +// with so many pins, doing this all with #ifdefs gets awkward... +// ... so just hardcode it in each hwdef file instead +inline void hwdef_setup() { + + // set up the system clock to run at 5 MHz instead of the default 3.33 MHz + _PROTECTED_WRITE( CLKCTRL.MCLKCTRLB, CLKCTRL_PDIV_4X_gc | CLKCTRL_PEN_bm ); + + //VPORTA.DIR = ...; + VPORTB.DIR = PIN0_bm | PIN1_bm | PIN5_bm; // Outputs: Aux LED and PWMs + //VPORTC.DIR = ...; + + // enable pullups on the unused pins to reduce power + PORTA.PIN0CTRL = PORT_PULLUPEN_bm; + PORTA.PIN1CTRL = PORT_PULLUPEN_bm; + PORTA.PIN2CTRL = PORT_PULLUPEN_bm; + PORTA.PIN3CTRL = PORT_PULLUPEN_bm; + PORTA.PIN4CTRL = PORT_PULLUPEN_bm; + PORTA.PIN5CTRL = PORT_PULLUPEN_bm | PORT_ISC_BOTHEDGES_gc; // eSwitch + PORTA.PIN6CTRL = PORT_PULLUPEN_bm; + PORTA.PIN7CTRL = PORT_PULLUPEN_bm; + + //PORTB.PIN0CTRL = PORT_PULLUPEN_bm; // cold tint channel + //PORTB.PIN1CTRL = PORT_PULLUPEN_bm; // warm tint channel + PORTB.PIN2CTRL = PORT_PULLUPEN_bm; + PORTB.PIN3CTRL = PORT_PULLUPEN_bm; + PORTB.PIN4CTRL = PORT_PULLUPEN_bm; + //PORTB.PIN5CTRL = PORT_PULLUPEN_bm; // Aux LED + + PORTC.PIN0CTRL = PORT_PULLUPEN_bm; + PORTC.PIN1CTRL = PORT_PULLUPEN_bm; + PORTC.PIN2CTRL = PORT_PULLUPEN_bm; + PORTC.PIN3CTRL = PORT_PULLUPEN_bm; + + // set up the PWM + // TODO: add references to MCU documentation + TCA0.SINGLE.CTRLB = TCA_SINGLE_CMP0EN_bm | TCA_SINGLE_CMP1EN_bm | TCA_SINGLE_WGMODE_SINGLESLOPE_gc; + TCA0.SINGLE.PER = 255; + TCA0.SINGLE.CTRLA = TCA_SINGLE_CLKSEL_DIV1_gc | TCA_SINGLE_ENABLE_bm; +} + + +#endif diff --git a/spaghetti-monster/anduril/cfg-blf-lantern-t1616.h b/spaghetti-monster/anduril/cfg-blf-lantern-t1616.h index 51c3d6a..56c7275 100644 --- a/spaghetti-monster/anduril/cfg-blf-lantern-t1616.h +++ b/spaghetti-monster/anduril/cfg-blf-lantern-t1616.h @@ -1,12 +1,6 @@ // BLF Lantern config options for Anduril using the Attiny1616 #define MODEL_NUMBER "0622" -/* BLF Lantern pinout - * PB0 is 5000K channel - * PB1 is 3000K channel - */ - -// basically the same as a Q8... sort of -#include "hwdef-BLF_Q8-T1616.h" +#include "hwdef-BLF_LT1-t1616.h" // ATTINY: 1616 // the button lights up @@ -53,7 +47,7 @@ // LT1 can handle heat well, so don't limit simple mode #define SIMPLE_UI_FLOOR RAMP_DISCRETE_FLOOR -#define SIMPLE_UI_CEIL RAMP_DISCRETE_CEIL +#define SIMPLE_UI_CEIL RAMP_DISCRETE_CEIL #define SIMPLE_UI_STEPS RAMP_DISCRETE_STEPS #define USE_SOS_MODE @@ -65,14 +59,6 @@ #undef USE_THERMAL_REGULATION #endif -// also, the set_level_gradually() thing isn't compatible with tint ramping -// (but unsetting it here doesn't actually do anything, because the thermal -// regulation define enables it later... so this is mostly just a note to -// make this compatibility issue explicit) -#ifdef USE_SET_LEVEL_GRADUALLY -#undef USE_SET_LEVEL_GRADUALLY -#endif - // don't blink while ramping #ifdef BLINK_AT_RAMP_MIDDLE #undef BLINK_AT_RAMP_MIDDLE -- cgit v1.2.3 From 75cecc4525522b3a4c6339b5aa303bb568769974 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Fri, 10 Sep 2021 01:22:35 -0600 Subject: fixed K9.3 builds (oops, new update_tint() needed to be compiled out for K9.3) --- spaghetti-monster/fsm-ramping.c | 2 +- spaghetti-monster/fsm-ramping.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spaghetti-monster/fsm-ramping.c b/spaghetti-monster/fsm-ramping.c index 88fb490..e8fcde7 100644 --- a/spaghetti-monster/fsm-ramping.c +++ b/spaghetti-monster/fsm-ramping.c @@ -282,7 +282,7 @@ void gradual_tick() { #endif // ifdef USE_SET_LEVEL_GRADUALLY -#ifdef USE_TINT_RAMPING +#if defined(USE_TINT_RAMPING) && (!defined(TINT_RAMP_TOGGLE_ONLY)) void update_tint() { #ifndef TINT_RAMPING_CORRECTION #define TINT_RAMPING_CORRECTION 26 // 140% brightness at middle tint diff --git a/spaghetti-monster/fsm-ramping.h b/spaghetti-monster/fsm-ramping.h index d8aad18..c1f6064 100644 --- a/spaghetti-monster/fsm-ramping.h +++ b/spaghetti-monster/fsm-ramping.h @@ -42,7 +42,7 @@ inline void set_level_gradually(uint8_t lvl); void gradual_tick(); #endif -#ifdef USE_TINT_RAMPING +#if defined(USE_TINT_RAMPING) && (!defined(TINT_RAMP_TOGGLE_ONLY)) void update_tint(); #endif -- cgit v1.2.3 From bd934678b03f0448aa7fd128fe0a745651b545ce Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Fri, 10 Sep 2021 01:28:29 -0600 Subject: fixed builds which failed due to being too big (rot66, mf01-mini) by turning off one more of the recent extra features (can turn it back on later if the build size goes down) --- spaghetti-monster/anduril/cfg-ff-rot66.h | 2 ++ spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/spaghetti-monster/anduril/cfg-ff-rot66.h b/spaghetti-monster/anduril/cfg-ff-rot66.h index 7e21fe7..48541a7 100644 --- a/spaghetti-monster/anduril/cfg-ff-rot66.h +++ b/spaghetti-monster/anduril/cfg-ff-rot66.h @@ -43,3 +43,5 @@ // too big, remove stuff to make room #undef USE_RAMP_AFTER_MOON_CONFIG +#undef USE_RAMP_SPEED_CONFIG +//#undef USE_2C_STYLE_CONFIG diff --git a/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h b/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h index 962317e..86e8c26 100644 --- a/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h +++ b/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h @@ -53,4 +53,6 @@ // too big, remove stuff to make room +#undef USE_RAMP_AFTER_MOON_CONFIG #undef USE_RAMP_SPEED_CONFIG +//#undef USE_2C_STYLE_CONFIG -- cgit v1.2.3 From 21a6e84bfdff469cfb9cfffa5ad4e8c6eb24c598 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Tue, 14 Sep 2021 20:23:53 -0600 Subject: added a hold shortcut in number entry menu: click for +1, hold for +10 --- spaghetti-monster/anduril/config-default.h | 4 ++++ spaghetti-monster/anduril/config-mode.c | 12 ++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/spaghetti-monster/anduril/config-default.h b/spaghetti-monster/anduril/config-default.h index 5b9897c..406e98b 100644 --- a/spaghetti-monster/anduril/config-default.h +++ b/spaghetti-monster/anduril/config-default.h @@ -181,6 +181,10 @@ #define USE_MOMENTARY_MODE +// enable a shortcut for +10 in number entry mode +// (click for +1, hold for +10) +#define USE_NUMBER_ENTRY_PLUS10 + // cut clock speed at very low modes for better efficiency // (defined here so config files can override it) #define USE_DYNAMIC_UNDERCLOCKING diff --git a/spaghetti-monster/anduril/config-mode.c b/spaghetti-monster/anduril/config-mode.c index f89a922..3af2a1c 100644 --- a/spaghetti-monster/anduril/config-mode.c +++ b/spaghetti-monster/anduril/config-mode.c @@ -146,9 +146,17 @@ uint8_t number_entry_state(Event event, uint16_t arg) { return MISCHIEF_MANAGED; } - // count clicks - else if (event == EV_click1_release) { + // count clicks: click = +1, hold = +10 + else if ((event == EV_click1_release) + #ifdef USE_NUMBER_ENTRY_PLUS10 + || (event == EV_click1_hold_release) + #endif + ) { entry_step = 1; // in case user clicked during initial delay + #ifdef USE_NUMBER_ENTRY_PLUS10 + if (event == EV_click1_hold_release) number_entry_value += 10; + else + #endif number_entry_value ++; // update the result empty_event_sequence(); // reset FSM's click count set_level(RAMP_SIZE/2); // flash briefly -- cgit v1.2.3 From bc6d512e990fe1266a8dc5ef08d246da46b7a1a4 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Tue, 14 Sep 2021 20:27:07 -0600 Subject: documented "hold" action in number entry state --- spaghetti-monster/anduril/anduril-manual.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spaghetti-monster/anduril/anduril-manual.txt b/spaghetti-monster/anduril/anduril-manual.txt index ef0ad5f..2b5f589 100644 --- a/spaghetti-monster/anduril/anduril-manual.txt +++ b/spaghetti-monster/anduril/anduril-manual.txt @@ -533,6 +533,11 @@ menu item, the light follows the same pattern: to enter a number. It will keep buzzing until the user stops clicking, so there is no need to hurry. + The actions here are: + - click: add 1 + - hold: add 10 (only in versions 2021-09 or later) + - wait: exit + After entering a number, or after skipping every menu item, it waits until the button is released then exits the menu. It should return to whatever mode the light was in before entering the config menu. -- cgit v1.2.3 From 62636961e82722a8175c720768edef1aff53eb0e Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Wed, 15 Sep 2021 01:25:10 -0600 Subject: fixed wrong value on D4Sv2-tintramp ramp calculator (was off by one) --- spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h b/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h index 67de5aa..c170645 100644 --- a/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h +++ b/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h @@ -28,10 +28,10 @@ // 2nd LEDs // output: unknown, 2000 lm? #define RAMP_LENGTH 150 -// level_calc.py 5.01 1 150 7135 1 0.2 2000 --pwm dyn:75:16383:511 +// level_calc.py 5.01 1 150 7135 1 0.2 2000 --pwm dyn:74:16383:511 // abstract ramp (power is split between both sets of LEDs) -#define PWM1_LEVELS 1,1,1,2,2,2,3,4,4,5,6,6,7,8,9,10,12,13,14,16,17,19,20,22,24,26,28,30,33,35,37,40,43,45,48,51,54,57,60,63,66,69,72,75,78,82,85,88,91,93,96,99,101,103,106,107,109,110,111,112,112,112,111,110,108,105,102,98,94,88,82,74,66,57,46,35,37,38,40,42,44,46,48,50,53,55,57,60,63,65,68,71,74,77,80,83,87,90,94,98,102,106,110,114,118,123,128,132,137,142,148,153,159,164,170,176,183,189,196,202,209,216,224,231,239,247,255,263,272,281,290,299,309,318,328,339,349,360,371,382,394,406,418,430,443,456,469,483,497,511 -#define PWM_TOPS 16383,13675,10740,15439,11908,8117,12779,14760,12239,13449,14017,11902,12260,12349,12259,12045,12929,12466,11970,12281,11704,11791,11178,11133,11013,10837,10619,10370,10425,10113,9792,9719,9603,9248,9093,8917,8725,8521,8309,8091,7870,7648,7425,7204,6985,6855,6638,6425,6218,5952,5760,5573,5339,5116,4952,4704,4513,4292,4084,3889,3673,3470,3252,3048,2833,2608,2401,2187,1989,1767,1563,1339,1134,929,711,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511 +#define PWM1_LEVELS 1,1,1,2,2,2,3,4,4,5,6,6,7,8,9,10,12,13,14,16,17,19,20,22,24,26,28,30,32,35,37,40,42,45,47,50,53,56,59,62,65,68,71,74,77,80,83,86,89,91,94,96,98,100,102,104,105,106,107,107,107,106,105,103,101,98,94,90,84,78,71,63,54,44,33,35,37,38,40,42,44,46,48,50,53,55,57,60,63,65,68,71,74,77,80,83,87,90,94,98,102,106,110,114,118,123,128,132,137,142,148,153,159,164,170,176,183,189,196,202,209,216,224,231,239,247,255,263,272,281,290,299,309,318,328,339,349,360,371,382,394,406,418,430,443,456,469,483,497,511 +#define PWM_TOPS 16383,13673,10738,15435,11908,8123,12779,14756,12240,13447,14013,11907,12263,12351,12261,12048,12926,12464,11972,12278,11704,11789,11180,11134,11013,10837,10620,10371,10100,10113,9793,9718,9376,9248,8898,8738,8560,8369,8168,7961,7749,7535,7321,7107,6895,6686,6480,6278,6080,5823,5639,5403,5178,4965,4763,4570,4346,4134,3936,3714,3507,3283,3074,2853,2648,2433,2211,2006,1776,1564,1351,1137,924,714,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511 #define DEFAULT_LEVEL 70 #define MAX_1x7135 150 #define HALFSPEED_LEVEL 10 -- cgit v1.2.3 From 7bb4ee663dca7da96e4c6ce2519f4cd3f5faf494 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Wed, 15 Sep 2021 01:27:18 -0600 Subject: added Noctigon K9.3-tintramp build targets for FET, reduced FET, and noFET (apparently Hank liked the D4Sv2-tintramp demo/experiment so much that he decided to use it in production for the K9.3... so it need its own builds since it's a pretty different light even if the driver is almost identical) --- .../anduril/cfg-noctigon-k9.3-tintramp-219.h | 10 +++ .../anduril/cfg-noctigon-k9.3-tintramp-fet.h | 63 ++++++++++++++++ .../anduril/cfg-noctigon-k9.3-tintramp-nofet.h | 84 ++++++++++++++++++++++ 3 files changed, 157 insertions(+) create mode 100644 spaghetti-monster/anduril/cfg-noctigon-k9.3-tintramp-219.h create mode 100644 spaghetti-monster/anduril/cfg-noctigon-k9.3-tintramp-fet.h create mode 100644 spaghetti-monster/anduril/cfg-noctigon-k9.3-tintramp-nofet.h diff --git a/spaghetti-monster/anduril/cfg-noctigon-k9.3-tintramp-219.h b/spaghetti-monster/anduril/cfg-noctigon-k9.3-tintramp-219.h new file mode 100644 index 0000000..04efa83 --- /dev/null +++ b/spaghetti-monster/anduril/cfg-noctigon-k9.3-tintramp-219.h @@ -0,0 +1,10 @@ +// Noctigon K9.3 tint-ramping (reduced FET) config options for Anduril +#include "cfg-noctigon-k9.3-tintramp-fet.h" +#undef MODEL_NUMBER +#define MODEL_NUMBER "0267" +// ATTINY: 1634 + +// 85% FET power +#undef PWM2_LEVELS +#define PWM2_LEVELS 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,11,17,24,33,41,51,60,70,80,91,103,116,129,141,156,170,185,200,216 + diff --git a/spaghetti-monster/anduril/cfg-noctigon-k9.3-tintramp-fet.h b/spaghetti-monster/anduril/cfg-noctigon-k9.3-tintramp-fet.h new file mode 100644 index 0000000..8535c57 --- /dev/null +++ b/spaghetti-monster/anduril/cfg-noctigon-k9.3-tintramp-fet.h @@ -0,0 +1,63 @@ +// Noctigon K9.3 tint-ramping (plus FET) config options for Anduril +#include "cfg-noctigon-k9.3-tintramp-nofet.h" +#undef MODEL_NUMBER +#define MODEL_NUMBER "0266" +// ATTINY: 1634 + +// enable the FET channel, even though it's ... kinda funky +#undef PWM_CHANNELS +#define PWM_CHANNELS 2 + +// main LEDs +// output: 3000 lm? +// FET: 5000 to 7500 lm +// 2nd LEDs +// output: 1500 lm? +#define RAMP_LENGTH 150 +// level_calc.py 5.01 1 130 7135 1 0.2 2000 --pwm dyn:64:16383:511 +// plus a FET segment +// level_calc.py 2 1 20 7135 5 1000.0 7000 --pwm 255 +// abstract ramp (power is split between both sets of LEDs) +// ','.join([str(511 - int(x*2.005)) for x in fet]) +#undef PWM1_LEVELS +// append: ,501,485,469,453,433,413,391,369,345,321,295,267,237,207,177,143,108,74,38,0 +#define PWM1_LEVELS 1,1,1,2,2,3,3,4,5,6,7,8,9,10,12,13,15,16,18,20,22,24,27,29,32,34,37,40,43,46,49,53,56,59,63,66,70,73,77,80,83,87,90,93,96,98,100,103,104,105,106,107,106,105,104,101,98,94,89,83,76,67,57,46,33,35,37,39,41,43,46,48,51,53,56,59,62,65,68,72,75,79,83,86,91,95,99,104,108,113,118,123,129,135,140,146,153,159,166,172,179,187,194,202,210,218,227,236,245,254,264,274,284,295,306,317,328,340,352,365,378,391,405,419,433,448,463,479,495,511,501,485,469,453,433,413,391,369,345,321,295,267,237,207,177,143,108,74,38,0 +#undef PWM_TOPS +// append: ,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511 +#define PWM_TOPS 16383,13233,9780,13825,9592,13434,9971,12020,12899,13192,13149,12898,12507,12022,12665,11981,12180,11421,11392,11246,11017,10730,10825,10433,10364,9926,9766,9564,9331,9075,8805,8692,8394,8095,7927,7625,7438,7142,6947,6664,6392,6202,5945,5699,5464,5186,4925,4726,4450,4194,3956,3734,3462,3212,2982,2717,2475,2230,1985,1741,1500,1244,996,755,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511 +// prepend: 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +#define PWM2_LEVELS 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,13,21,29,39,49,60,71,83,95,108,122,137,152,167,184,201,218,236,255 +#undef DEFAULT_LEVEL +#define DEFAULT_LEVEL 70 +#undef MAX_1x7135 +#define MAX_1x7135 130 + +#undef RAMP_SMOOTH_FLOOR +#define RAMP_SMOOTH_FLOOR 10 // level 1 is unreliable (?) +#undef RAMP_SMOOTH_CEIL +#define RAMP_SMOOTH_CEIL 130 +// 10, 30, 50, [70], 90, 110, [130] +#undef RAMP_DISCRETE_FLOOR +#define RAMP_DISCRETE_FLOOR 10 +#undef RAMP_DISCRETE_CEIL +#define RAMP_DISCRETE_CEIL RAMP_SMOOTH_CEIL +#undef RAMP_DISCRETE_STEPS +#define RAMP_DISCRETE_STEPS 7 + +// safe limit highest regulated power (no FET or turbo) +#undef SIMPLE_UI_FLOOR +#define SIMPLE_UI_FLOOR RAMP_DISCRETE_FLOOR +#undef SIMPLE_UI_CEIL +#define SIMPLE_UI_CEIL RAMP_DISCRETE_CEIL +#undef SIMPLE_UI_STEPS +#define SIMPLE_UI_STEPS 5 + +// stop panicking at ~3000 lm +#undef THERM_FASTER_LEVEL +#define THERM_FASTER_LEVEL 130 +#undef MIN_THERM_STEPDOWN +#define MIN_THERM_STEPDOWN 65 // should be above highest dyn_pwm level + +// speed up party strobe; the FET is really fast +#undef PARTY_STROBE_ONTIME + diff --git a/spaghetti-monster/anduril/cfg-noctigon-k9.3-tintramp-nofet.h b/spaghetti-monster/anduril/cfg-noctigon-k9.3-tintramp-nofet.h new file mode 100644 index 0000000..21ab415 --- /dev/null +++ b/spaghetti-monster/anduril/cfg-noctigon-k9.3-tintramp-nofet.h @@ -0,0 +1,84 @@ +// Noctigon K9.3 noFET tint-ramping config options for Anduril +#define MODEL_NUMBER "0265" +#include "hwdef-Emisar_D4Sv2-tintramp.h" +#include "hank-cfg.h" +// ATTINY: 1634 + +// this light has three aux LED channels: R, G, B +#define USE_AUX_RGB_LEDS +// the aux LEDs are front-facing, so turn them off while main LEDs are on +// it also has an independent LED in the button +#define USE_BUTTON_LED +// TODO: the whole "indicator LED" thing needs to be refactored into +// "aux LED(s)" and "button LED(s)" since they work a bit differently +// enabling this option breaks the button LED on D4v2.5 +#ifdef USE_INDICATOR_LED_WHILE_RAMPING +#undef USE_INDICATOR_LED_WHILE_RAMPING +#endif + +// has two channels of independent LEDs +#define USE_TINT_RAMPING +// how much to increase total brightness at middle tint +// (0 = 100% brightness, 64 = 200% brightness) +#define TINT_RAMPING_CORRECTION 0 // none, linear regulator doesn't need it + +// main LEDs +// output: 3000 lm? +// FET: disabled +// 2nd LEDs +// output: 1500 lm? +#define RAMP_LENGTH 150 +// level_calc.py 5.01 1 150 7135 1 0.2 2000 --pwm dyn:74:16383:511 +// abstract ramp (power is split between both sets of LEDs) +#define PWM1_LEVELS 1,1,1,2,2,2,3,4,4,5,6,6,7,8,9,10,12,13,14,16,17,19,20,22,24,26,28,30,32,35,37,40,42,45,47,50,53,56,59,62,65,68,71,74,77,80,83,86,89,91,94,96,98,100,102,104,105,106,107,107,107,106,105,103,101,98,94,90,84,78,71,63,54,44,33,35,37,38,40,42,44,46,48,50,53,55,57,60,63,65,68,71,74,77,80,83,87,90,94,98,102,106,110,114,118,123,128,132,137,142,148,153,159,164,170,176,183,189,196,202,209,216,224,231,239,247,255,263,272,281,290,299,309,318,328,339,349,360,371,382,394,406,418,430,443,456,469,483,497,511 +#define PWM_TOPS 16383,13673,10738,15435,11908,8123,12779,14756,12240,13447,14013,11907,12263,12351,12261,12048,12926,12464,11972,12278,11704,11789,11180,11134,11013,10837,10620,10371,10100,10113,9793,9718,9376,9248,8898,8738,8560,8369,8168,7961,7749,7535,7321,7107,6895,6686,6480,6278,6080,5823,5639,5403,5178,4965,4763,4570,4346,4134,3936,3714,3507,3283,3074,2853,2648,2433,2211,2006,1776,1564,1351,1137,924,714,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511 +#define DEFAULT_LEVEL 70 +#define MAX_1x7135 150 +#define HALFSPEED_LEVEL 10 +#define QUARTERSPEED_LEVEL 2 + +#define USE_MANUAL_MEMORY_TIMER_FOR_TINT +//#define DEFAULT_MANUAL_MEMORY DEFAULT_LEVEL +//#define DEFAULT_MANUAL_MEMORY_TIMER 10 + +#define RAMP_SMOOTH_FLOOR 10 // level 1 is unreliable (?) +#define RAMP_SMOOTH_CEIL 130 +// 10, 30, 50, [70], 90, 110, [130] +#define RAMP_DISCRETE_FLOOR 10 +#define RAMP_DISCRETE_CEIL RAMP_SMOOTH_CEIL +#define RAMP_DISCRETE_STEPS 7 + +// safe limit highest regulated power (no FET or turbo) +#define SIMPLE_UI_FLOOR RAMP_DISCRETE_FLOOR +#define SIMPLE_UI_CEIL RAMP_DISCRETE_CEIL +#define SIMPLE_UI_STEPS 5 + +// stop panicking at ~2000 lm +#define THERM_FASTER_LEVEL 140 +#define MIN_THERM_STEPDOWN 75 // should be above highest dyn_pwm level + +// use the brightest setting for strobe +#define STROBE_BRIGHTNESS MAX_LEVEL +// slow down party strobe; this driver can't pulse for 1ms or less +#define PARTY_STROBE_ONTIME 2 + +// the default of 26 looks a bit flat, so increase it +#define CANDLE_AMPLITUDE 40 + +// the power regulator is a bit slow, so push it harder for a quick response from off +#define DEFAULT_JUMP_START_LEVEL 21 +#define BLINK_BRIGHTNESS DEFAULT_LEVEL +#define BLINK_ONCE_TIME 12 // longer blink, since main LEDs are slow + +#define THERM_CAL_OFFSET 9 + +#ifdef BLINK_AT_RAMP_MIDDLE +#undef BLINK_AT_RAMP_MIDDLE +#endif + +// for consistency with KR4 (not otherwise necessary though) +#define USE_SOFT_FACTORY_RESET + + +// work around bizarre bug: lockout mode fails when set to solid color blinking +#define USE_K93_LOCKOUT_KLUDGE -- cgit v1.2.3 From 933fc55d7289d081cd124ee47a3d5af2b27ba0cc Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Fri, 17 Sep 2021 02:22:21 -0600 Subject: clarified where brightness level comes from in beacon/sos/momentary modes --- spaghetti-monster/anduril/anduril-manual.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spaghetti-monster/anduril/anduril-manual.txt b/spaghetti-monster/anduril/anduril-manual.txt index 2b5f589..a8f3730 100644 --- a/spaghetti-monster/anduril/anduril-manual.txt +++ b/spaghetti-monster/anduril/anduril-manual.txt @@ -406,8 +406,9 @@ In more detail, this is what each blinky / utility mode does: stays off until the next blink. The brightness and the number of seconds between pulses are configurable: - - Brightness is the user's last-ramped level, so set this in - ramping mode before starting beacon mode. + - Brightness is the user's memorized ramp level, so set this in + ramping mode before activating beacon mode. Follows the same + memory rules as ramping -- automatic, manual, or hybrid. - Speed is configured by holding the button. The light should blink once per second while holding the button. Release it @@ -421,8 +422,7 @@ In more detail, this is what each blinky / utility mode does: Blinks out a distress signal. Three short, three long, three short. Repeats until light is turned off or until battery is low. - The last-ramped brightness in Ramping Mode determines the brightness - of SOS Mode. + The memorized ramp level determines the brightness of SOS Mode. Strobe / Mood Modes @@ -505,8 +505,8 @@ depending on which was active before going to momentary mode. To select which one, go to the mode you want to use, adjust the brightness and speed and other settings, then click 5 times to enter momentary mode. -In steady mode, brightness is the last-ramped level, so adjust that -before entering momentary mode. +In steady mode, brightness is the memorized ramp level, so adjust that +in Ramp Mode before entering momentary mode. In momentary strobe mode, the settings are copied from the last-used strobe mode, such as party strobe, tactical strobe, or lightning. -- cgit v1.2.3