diff options
| author | Selene ToyKeeper | 2023-10-25 10:26:56 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2023-10-25 10:26:56 -0600 |
| commit | 3a654aa5150a8943a787ecbfc65c2f9ff2bff75f (patch) | |
| tree | b77230ef73189b9f68a6630dfccff1c94d66d8d1 /spaghetti-monster | |
| parent | fixed emisar-d1 + emisar-d1s (diff) | |
| download | anduril-3a654aa5150a8943a787ecbfc65c2f9ff2bff75f.tar.gz anduril-3a654aa5150a8943a787ecbfc65c2f9ff2bff75f.tar.bz2 anduril-3a654aa5150a8943a787ecbfc65c2f9ff2bff75f.zip | |
rewrote blf-lantern (blf-lt1) code to use multi-channel and PWM+DSM,
which required ... a few pretty significant changes:
- no dynamic underclocking (it isn't compatible with DSM yet)
- no tint ramping brightness correction (removed to save space)
- removed ramp blinks (to save space, and because they're annoying)
- removed momentary mode (to save space)
- removed SOS mode (to save space)
- removed (to save space) some other relatively recent features which
weren't present in the original production firmware
... but some other things improved:
+ added smooth steps
+ extended Simple UI
+ added stepped tint ramping
+ added 13H factory reset, to save wear on threads
+ lower lows
+ smoother ramp
+ much higher tint ramp resolution in low modes
I'm not entirely happy with this yet, so it probably needs additional work
later in order to adjust the weird ramp shape (these 7135 chips have a weird
response curve), add dynamic underclocking, cut down the ROM size if possible,
re-add tint ramping brightness correction, etc. Multi-channel stuff in
particular added a lot to the size.
This is a pretty big change from the previous working build, so some users
may want to stick with the last pre-multi-channel version. Non-trivial
sacrifices were made to bring in more recent features.
Diffstat (limited to '')
| -rw-r--r-- | spaghetti-monster/anduril/cfg-blf-lantern.h | 97 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/config-default.h | 4 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/load-save-config-fsm.h | 2 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/load-save-config.h | 2 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/ramp-mode.h | 2 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/strobe-modes.c | 4 |
6 files changed, 65 insertions, 46 deletions
diff --git a/spaghetti-monster/anduril/cfg-blf-lantern.h b/spaghetti-monster/anduril/cfg-blf-lantern.h index c6b7bc8..b4e9ce7 100644 --- a/spaghetti-monster/anduril/cfg-blf-lantern.h +++ b/spaghetti-monster/anduril/cfg-blf-lantern.h @@ -4,69 +4,70 @@ #pragma once #define MODEL_NUMBER "0621" -#include "hwdef-BLF_LT1.h" +#include "hwdef-blf-lt1.h" // ATTINY: 85 // the button lights up #define USE_INDICATOR_LED // the button is visible while main LEDs are on #define USE_INDICATOR_LED_WHILE_RAMPING -// off mode: high (2) +// off mode: low (1) // lockout: blinking (3) -#define INDICATOR_LED_DEFAULT_MODE ((3<<2) + 2) +#define INDICATOR_LED_DEFAULT_MODE ((3<<2) + 1) + +// channel modes... +// CM_CH1, CM_CH2, CM_BOTH, CM_BLEND, CM_AUTO +#define DEFAULT_CHANNEL_MODE CM_AUTO -// the lantern has two PWM channels, but they drive different sets of emitters -// (one channel for warm emitters, one channel for cold) -// so enable a special ramping mode which changes tint instead of brightness -#define USE_TINT_RAMPING // how much to increase total brightness at middle tint // (0 = 100% brightness, 64 = 200% brightness) //#define TINT_RAMPING_CORRECTION 26 // prototype, 140% -#define TINT_RAMPING_CORRECTION 10 // production model, 115% -//#define TINT_RAMPING_CORRECTION 0 // none +//#define TINT_RAMPING_CORRECTION 10 // production model, 115% +#define TINT_RAMPING_CORRECTION 0 // none -#ifdef RAMP_LENGTH -#undef RAMP_LENGTH -#endif +#define RAMP_SIZE 150 +// delta-sigma modulated PWM (0b0HHHHHHHHLLLLLLL = 0, 8xHigh, 7xLow bits) +// (max is (255 << 7), because it's 8-bit PWM plus 7 bits of DSM) +// level_calc.py 5.01 1 150 7135 2 0.2 600 --pwm 32640 +//#define PWM1_LEVELS 2,4,5,7,9,12,14,17,20,23,27,31,35,39,44,50,56,62,68,76,83,91,100,110,120,130,142,154,167,181,195,211,227,244,263,282,303,324,347,371,397,424,452,482,513,545,580,616,653,693,734,778,823,871,920,972,1026,1083,1142,1203,1267,1334,1403,1475,1551,1629,1710,1795,1883,1974,2069,2167,2269,2375,2485,2599,2717,2839,2965,3096,3232,3372,3517,3667,3822,3982,4148,4319,4495,4677,4865,5060,5260,5466,5679,5899,6125,6358,6599,6846,7101,7363,7633,7911,8197,8491,8793,9104,9424,9753,10090,10437,10794,11160,11536,11922,12319,12726,13143,13572,14011,14462,14925,15399,15885,16383,16894,17417,17954,18503,19066,19642,20232,20837,21456,22089,22737,23400,24079,24774,25484,26211,26954,27713,28490,29284,30096,30926,31774,32640 +// level_calc.py 5.01 1 150 7135 128 0.2 600 --pwm 32640 +#define PWM1_LEVELS 128,130,131,133,135,138,140,143,146,149,153,157,161,165,170,176,181,188,194,201,209,217,226,235,245,256,267,279,292,306,320,336,352,369,388,407,428,449,472,496,521,548,576,606,637,669,703,739,777,816,858,901,946,993,1043,1094,1148,1204,1263,1324,1388,1455,1524,1596,1671,1749,1830,1914,2002,2093,2187,2285,2387,2492,2601,2715,2832,2954,3080,3210,3345,3485,3629,3779,3933,4093,4258,4428,4604,4785,4973,5166,5366,5571,5783,6002,6228,6460,6699,6946,7199,7461,7730,8006,8291,8584,8885,9195,9514,9841,10178,10523,10878,11243,11618,12002,12397,12803,13219,13645,14083,14532,14993,15465,15949,16446,16955,17476,18010,18558,19118,19692,20280,20882,21499,22130,22775,23436,24112,24804,25512,26235,26976,27732,28506,29297,30106,30932,31777,32640 + +#define DEFAULT_LEVEL 75 +#define MAX_1x7135 75 +#define HALFSPEED_LEVEL 44 +#define QUARTERSPEED_LEVEL 34 +#undef USE_DYNAMIC_UNDERCLOCKING // makes huge bumps in the ramp -// 1-130: 0 to 100% power -// level_calc.py 3.0 1 130 7135 1 30 800 --pwm 255 -// 131-150: 101% to 200% power -// level_calc.py 8.69 1 150 7135 1 1 1600 --pwm 510 -#define RAMP_LENGTH 150 -#define PWM1_LEVELS 1,1,2,2,3,3,4,5,5,6,6,7,8,8,9,10,10,11,12,12,13,14,15,16,17,17,18,19,20,21,22,23,24,25,26,27,28,29,31,32,33,34,35,37,38,39,40,42,43,45,46,47,49,50,52,54,55,57,58,60,62,63,65,67,69,70,72,74,76,78,80,82,84,86,88,90,92,95,97,99,101,104,106,108,111,113,115,118,121,123,126,128,131,134,136,139,142,145,148,150,153,156,159,162,166,169,172,175,178,181,185,188,191,195,198,202,205,209,213,216,220,224,227,231,235,239,243,247,251,255,264,274,284,294,305,316,327,339,351,363,376,389,403,417,431,446,461,477,493,510 -#define MAX_1x7135 130 -#define DEFAULT_LEVEL 70 -#define HALFSPEED_LEVEL 14 -#define QUARTERSPEED_LEVEL 5 +#define USE_SMOOTH_STEPS +//#define USE_SET_LEVEL_GRADUALLY // the default of 26 looks a bit flat, so increase it #define CANDLE_AMPLITUDE 40 // override default ramp style #undef RAMP_STYLE -#define RAMP_STYLE 1 // 0 = smooth, 1 = stepped +#define RAMP_STYLE 1 // 0 = smooth, 1 = stepped // set floor and ceiling as far apart as possible // because this lantern isn't overpowered -#define RAMP_SMOOTH_FLOOR 1 -#define RAMP_SMOOTH_CEIL 130 -#define RAMP_DISCRETE_FLOOR 10 -#define RAMP_DISCRETE_CEIL RAMP_SMOOTH_CEIL -#define RAMP_DISCRETE_STEPS 5 +#define RAMP_SMOOTH_FLOOR 1 +#define RAMP_SMOOTH_CEIL 150 +#define RAMP_DISCRETE_FLOOR 1 +#define RAMP_DISCRETE_CEIL 150 +#define RAMP_DISCRETE_STEPS 7 // Allow 3C in Simple UI for switching between smooth and stepped ramping #define USE_SIMPLE_UI_RAMPING_TOGGLE +#define USE_EXTENDED_SIMPLE_UI // 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_STEPS RAMP_DISCRETE_STEPS +#define SIMPLE_UI_FLOOR 10 +#define SIMPLE_UI_CEIL 150 +#define SIMPLE_UI_STEPS 5 // also at Sofirn's request, enable 2 click turbo (Anduril 1 style) -#define DEFAULT_2C_STYLE 1 +#define DEFAULT_2C_STYLE 1 -#define USE_SOS_MODE -#define USE_SOS_MODE_IN_BLINKY_GROUP // the sensor (attiny85) is nowhere near the emitters // so thermal regulation can't work @@ -74,18 +75,32 @@ #undef USE_THERMAL_REGULATION #endif -// don't blink at floor +// don't blink while ramping #ifdef BLINK_AT_RAMP_FLOOR #undef BLINK_AT_RAMP_FLOOR #endif -// blink at 100% power -#ifndef BLINK_AT_RAMP_MIDDLE -#define BLINK_AT_RAMP_MIDDLE +#ifdef BLINK_AT_RAMP_MIDDLE +#undef BLINK_AT_RAMP_MIDDLE #endif -// blink again at the 200% power / ceil / turbo -#ifndef BLINK_AT_RAMP_CEIL -#define BLINK_AT_RAMP_CEIL +#ifdef BLINK_AT_RAMP_CEIL +#undef BLINK_AT_RAMP_CEIL #endif // too big, turn off extra features +//#undef USE_STEPPED_TINT_RAMPING +#undef USE_MOMENTARY_MODE #undef USE_TACTICAL_MODE +#undef USE_SOS_MODE +//#undef USE_SIMPLE_UI +//#undef USE_BEACON_MODE +//#undef USE_RAMP_SPEED_CONFIG +#undef USE_RAMP_AFTER_MOON_CONFIG +#undef USE_2C_STYLE_CONFIG +#undef USE_VOLTAGE_CORRECTION +//#undef USE_CHANNEL_PER_STROBE +// party strobe, tac strobe, lightning, candle, bike +#define DEFAULT_STROBE_CHANNELS CM_BOTH,CM_BOTH,CM_AUTO,CM_AUTO,CM_AUTO + +// for consistency with other models +#define USE_SOFT_FACTORY_RESET + diff --git a/spaghetti-monster/anduril/config-default.h b/spaghetti-monster/anduril/config-default.h index bc301e0..899bc4a 100644 --- a/spaghetti-monster/anduril/config-default.h +++ b/spaghetti-monster/anduril/config-default.h @@ -201,3 +201,7 @@ // 0 = none, 1 = smooth, 2+ = undefined #define DEFAULT_SMOOTH_STEPS_STYLE 1 +// by default, allow user to set the channel for each strobe-group mode +// (but allow disabling this feature per build) +#define USE_CHANNEL_PER_STROBE + diff --git a/spaghetti-monster/anduril/load-save-config-fsm.h b/spaghetti-monster/anduril/load-save-config-fsm.h index 0a9cabd..d189d3a 100644 --- a/spaghetti-monster/anduril/load-save-config-fsm.h +++ b/spaghetti-monster/anduril/load-save-config-fsm.h @@ -75,7 +75,7 @@ typedef struct Config { ///// strobe / blinky mode settings #ifdef USE_STROBE_STATE uint8_t strobe_type; - #if NUM_CHANNEL_MODES > 1 + #if (NUM_CHANNEL_MODES > 1) && defined(USE_CHANNEL_PER_STROBE) uint8_t strobe_channels[NUM_STROBES]; #endif #endif diff --git a/spaghetti-monster/anduril/load-save-config.h b/spaghetti-monster/anduril/load-save-config.h index 6ae2ba2..514fcbb 100644 --- a/spaghetti-monster/anduril/load-save-config.h +++ b/spaghetti-monster/anduril/load-save-config.h @@ -105,7 +105,7 @@ Config cfg = { #ifdef USE_STROBE_STATE .strobe_type = DEFAULT_STROBE, - #if NUM_CHANNEL_MODES > 1 + #if (NUM_CHANNEL_MODES > 1) && defined(USE_CHANNEL_PER_STROBE) // channel mode saved per strobe-group mode #ifdef DEFAULT_STROBE_CHANNELS .strobe_channels = { DEFAULT_STROBE_CHANNELS }, diff --git a/spaghetti-monster/anduril/ramp-mode.h b/spaghetti-monster/anduril/ramp-mode.h index 615da87..59c8db0 100644 --- a/spaghetti-monster/anduril/ramp-mode.h +++ b/spaghetti-monster/anduril/ramp-mode.h @@ -129,7 +129,7 @@ uint8_t nearest_level(int16_t target); // ensure ramp globals are correct void ramp_update_config(); -#ifdef USE_THERMAL_REGULATION +#if defined(USE_THERMAL_REGULATION) || defined(USE_SMOOTH_STEPS) // brightness before thermal step-down uint8_t target_level = 0; void set_level_and_therm_target(uint8_t level); diff --git a/spaghetti-monster/anduril/strobe-modes.c b/spaghetti-monster/anduril/strobe-modes.c index 31d2aad..ad17964 100644 --- a/spaghetti-monster/anduril/strobe-modes.c +++ b/spaghetti-monster/anduril/strobe-modes.c @@ -43,7 +43,7 @@ uint8_t strobe_state(Event event, uint16_t arg) { save_config(); return EVENT_HANDLED; } - #if NUM_CHANNEL_MODES > 1 + #if (NUM_CHANNEL_MODES > 1) && defined(USE_CHANNEL_PER_STROBE) // 3 clicks: rotate through channel modes for the current strobe else if (event == EV_3clicks) { // TODO: maybe skip aux modes? @@ -167,7 +167,7 @@ uint8_t strobe_state(Event event, uint16_t arg) { inline void strobe_state_iter() { uint8_t st = current_strobe_type; // can't use switch() on an enum - #if NUM_CHANNEL_MODES > 1 + #if (NUM_CHANNEL_MODES > 1) && defined(USE_CHANNEL_PER_STROBE) // remember channel mode for each strobe channel_mode = cfg.strobe_channels[st]; #endif |
