aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hwdef-BLF_LT1.h58
-rw-r--r--hwdef-blf-lt1.c197
-rw-r--r--hwdef-blf-lt1.h106
-rw-r--r--spaghetti-monster/anduril/cfg-blf-lantern.h97
-rw-r--r--spaghetti-monster/anduril/config-default.h4
-rw-r--r--spaghetti-monster/anduril/load-save-config-fsm.h2
-rw-r--r--spaghetti-monster/anduril/load-save-config.h2
-rw-r--r--spaghetti-monster/anduril/ramp-mode.h2
-rw-r--r--spaghetti-monster/anduril/strobe-modes.c4
9 files changed, 368 insertions, 104 deletions
diff --git a/hwdef-BLF_LT1.h b/hwdef-BLF_LT1.h
deleted file mode 100644
index e7c4791..0000000
--- a/hwdef-BLF_LT1.h
+++ /dev/null
@@ -1,58 +0,0 @@
-// BLF LT1 driver layout
-// Copyright (C) 2018-2023 Selene ToyKeeper
-// SPDX-License-Identifier: GPL-3.0-or-later
-#pragma once
-
-/*
- * ----
- * Reset -|1 8|- VCC
- * eswitch -|2 7|- (unused)
- * aux LED -|3 6|- PWM (5000K)
- * GND -|4 5|- PWM (3000K)
- * ----
- */
-
-#define ATTINY 85
-#include <avr/io.h>
-
-#define PWM_CHANNELS 1 // 1 virtual channel (1 for main LEDs + 1 for 2nd LEDs)
-#define PWM_BITS 9 // 0 to 255 at 15.6 kHz, but goes to 510 for "200%" turbo
-#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
-//#define PWM1_PHASE_RESET_OFF // force reset while shutting off
-//#define PWM1_PHASE_RESET_ON // force reset while turning on
-//#define PWM1_PHASE_SYNC // manual sync while changing level
-
-// 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 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
-
-#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
-
-#define FAST 0xA3 // fast PWM both channels
-#define PHASE 0xA1 // phase-correct PWM both channels
-
-#define LAYOUT_DEFINED
-
diff --git a/hwdef-blf-lt1.c b/hwdef-blf-lt1.c
new file mode 100644
index 0000000..df17612
--- /dev/null
+++ b/hwdef-blf-lt1.c
@@ -0,0 +1,197 @@
+// BLF LT1 PWM functions
+// Copyright (C) 2023 Selene ToyKeeper
+// SPDX-License-Identifier: GPL-3.0-or-later
+#pragma once
+
+
+void set_level_zero();
+
+void set_level_ch1(uint8_t level);
+void set_level_ch2(uint8_t level);
+void set_level_both(uint8_t level);
+void set_level_blend(uint8_t level);
+//void set_level_auto(uint8_t level); // redundant
+
+#if 0 // gradual adjustments are disabled to save space
+bool gradual_tick_ch1(uint8_t gt);
+bool gradual_tick_ch2(uint8_t gt);
+bool gradual_tick_both(uint8_t gt);
+bool gradual_tick_blend(uint8_t gt);
+//bool gradual_tick_auto(uint8_t gt); // redundant
+#endif
+
+
+Channel channels[] = {
+ { // channel 1 only
+ .set_level = set_level_ch1,
+ //.gradual_tick = gradual_tick_ch1,
+ .has_args = 0
+ },
+ { // channel 2 only
+ .set_level = set_level_ch2,
+ //.gradual_tick = gradual_tick_ch2,
+ .has_args = 0
+ },
+ { // both channels, tied together (max "200%" power)
+ .set_level = set_level_both,
+ //.gradual_tick = gradual_tick_both,
+ .has_args = 0
+ },
+ { // both channels, manual blend (max "100%" power)
+ .set_level = set_level_blend,
+ //.gradual_tick = gradual_tick_blend,
+ .has_args = 1
+ },
+ { // both channels, auto blend
+ .set_level = set_level_blend,
+ //.gradual_tick = gradual_tick_blend,
+ .has_args = 1
+ },
+};
+
+void set_level_zero() {
+ // turn off all LEDs
+ ch1_dsm_lvl = 0;
+ ch2_dsm_lvl = 0;
+ CH1_PWM = 0;
+ CH2_PWM = 0;
+}
+
+// wrap setting the dsm vars, to get a faster response
+// (just setting *_dsm_lvl doesn't work well for strobes)
+void set_hw_levels(PWM_DATATYPE ch1, PWM_DATATYPE ch2) {
+ // set delta-sigma soft levels
+ ch1_dsm_lvl = ch1;
+ ch2_dsm_lvl = ch2;
+
+ // set hardware PWM levels and init dsm loop
+ CH1_PWM = ch1_pwm = ch1 >> 7;
+ CH2_PWM = ch2_pwm = ch2 >> 7;
+}
+
+// delta-sigma modulation of PWM outputs
+// happens on each Timer0 overflow (every 512 cpu clock cycles)
+// uses 8-bit pwm w/ 7-bit dsm (0b 0PPP PPPP PDDD DDDD)
+ISR(TIMER0_OVF_vect) {
+ // set new hardware values first,
+ // for best timing (reduce effect of interrupt jitter)
+ CH1_PWM = ch1_pwm;
+ CH2_PWM = ch2_pwm;
+
+ // calculate next values, now that timing matters less
+
+ // accumulate error
+ ch1_dsm += (ch1_dsm_lvl & 0x007f);
+ // next PWM = base PWM value + carry bit
+ ch1_pwm = (ch1_dsm_lvl >> 7) + (ch1_dsm > 0x7f);
+ // clear carry bit
+ ch1_dsm &= 0x7f;
+
+ // repeat for other channels
+
+ ch2_dsm += (ch2_dsm_lvl & 0x007f);
+ ch2_pwm = (ch2_dsm_lvl >> 7) + (ch2_dsm > 0x7f);
+ ch2_dsm &= 0x7f;
+}
+
+
+void set_level_ch1(uint8_t level) {
+ set_hw_levels(PWM_GET(pwm1_levels, level), 0);
+}
+
+void set_level_ch2(uint8_t level) {
+ set_hw_levels(0, PWM_GET(pwm1_levels, level));
+}
+
+void set_level_both(uint8_t level) {
+ PWM_DATATYPE pwm = PWM_GET(pwm1_levels, level);
+ set_hw_levels(pwm, pwm);
+}
+
+void blend_helper(PWM_DATATYPE *warm, PWM_DATATYPE *cool, uint8_t level) {
+ PWM_DATATYPE brightness = PWM_GET(pwm1_levels, level);
+ uint8_t blend;
+ if (channel_mode == CM_AUTO) {
+ blend = 255 * (uint16_t)level / RAMP_SIZE;
+ if (cfg.channel_mode_args[channel_mode] & 0b01000000)
+ blend = 255 - blend;
+ } else {
+ blend = cfg.channel_mode_args[channel_mode];
+ }
+
+ calc_2ch_blend(warm, cool, brightness, DSM_TOP, blend);
+}
+
+void set_level_blend(uint8_t level) {
+ PWM_DATATYPE warm, cool;
+ blend_helper(&warm, &cool, level);
+ set_hw_levels(warm, cool);
+}
+
+/*
+void set_level_auto(uint8_t level) {
+ PWM_DATATYPE warm, cool;
+ blend_helper(&warm, &cool, level);
+ set_hw_levels(warm, cool);
+}
+*/
+
+///// "gradual tick" functions for smooth thermal regulation /////
+// (and other smooth adjustments)
+
+#if 0 // disabled to save space
+///// bump each channel toward a target value /////
+bool gradual_adjust(PWM_DATATYPE ch1, PWM_DATATYPE ch2) {
+ // adjust multiple times based on current brightness
+ // (so it adjusts faster/coarser when bright, slower/finer when dim)
+
+ // higher shift = slower/finer adjustments
+ const uint8_t shift = 9; // ((255 << 7) >> 9) = 63 max
+ uint8_t steps;
+
+ steps = ch1_dsm_lvl >> shift;
+ for (uint8_t i=0; i<=steps; i++)
+ GRADUAL_ADJUST_SIMPLE(ch1, ch1_dsm_lvl);
+
+ steps = ch2_dsm_lvl >> shift;
+ for (uint8_t i=0; i<=steps; i++)
+ GRADUAL_ADJUST_SIMPLE(ch2, ch2_dsm_lvl);
+
+ if ((ch1 == ch1_dsm_lvl)
+ && (ch2 == ch2_dsm_lvl )) {
+ return true; // done
+ }
+ return false; // not done yet
+}
+
+bool gradual_tick_ch1(uint8_t gt) {
+ PWM_DATATYPE pwm = PWM_GET(pwm1_levels, gt);
+ return gradual_adjust(pwm, 0);
+}
+
+bool gradual_tick_ch2(uint8_t gt) {
+ PWM_DATATYPE pwm = PWM_GET(pwm1_levels, gt);
+ return gradual_adjust(0, pwm);
+}
+
+bool gradual_tick_both(uint8_t gt) {
+ PWM_DATATYPE pwm = PWM_GET(pwm1_levels, gt);
+ return gradual_adjust(pwm, pwm);
+}
+
+bool gradual_tick_blend(uint8_t gt) {
+ PWM_DATATYPE warm, cool;
+ blend_helper(&warm, &cool, gt);
+ return gradual_adjust(warm, cool);
+}
+
+/*
+bool gradual_tick_auto(uint8_t gt) {
+ PWM_DATATYPE warm, cool;
+ blend_helper(&warm, &cool, gt);
+ return gradual_adjust(warm, cool);
+}
+*/
+
+#endif // if 0
+
diff --git a/hwdef-blf-lt1.h b/hwdef-blf-lt1.h
new file mode 100644
index 0000000..571fa44
--- /dev/null
+++ b/hwdef-blf-lt1.h
@@ -0,0 +1,106 @@
+// BLF LT1 driver layout
+// Copyright (C) 2018-2023 Selene ToyKeeper
+// SPDX-License-Identifier: GPL-3.0-or-later
+#pragma once
+
+/*
+ * ----
+ * Reset -|1 8|- VCC
+ * eswitch -|2 7|- (unused)
+ * aux LED -|3 6|- PWM (5000K)
+ * GND -|4 5|- PWM (3000K)
+ * ----
+ */
+
+#define ATTINY 85
+#include <avr/io.h>
+
+#define HWDEF_C_FILE hwdef-blf-lt1.c
+
+// channel modes:
+// * 0. channel 1 only
+// * 1. channel 2 only
+// * 2. both channels, tied together, max "200%" power
+// * 3. both channels, manual blend, max "100%" power
+// * 4. both channels, auto blend, reversible
+#define NUM_CHANNEL_MODES 5
+enum channel_modes_e {
+ CM_CH1 = 0,
+ CM_CH2,
+ CM_BOTH,
+ CM_BLEND,
+ CM_AUTO,
+};
+
+
+// right-most bit first, modes are in fedcba9876543210 order
+#define CHANNEL_MODES_ENABLED 0b00011000
+#define USE_CHANNEL_MODE_ARGS
+// _, _, _, 128=middle CCT, 0=warm-to-cool
+#define CHANNEL_MODE_ARGS 0,0,0,128,0
+
+// can use some of the common handlers
+#define USE_CALC_2CH_BLEND
+
+
+#define PWM_CHANNELS 1 // old, remove this
+
+#define PWM_BITS 16 // 8-bit hardware PWM + 16-bit DSM
+
+#define PWM_GET PWM_GET16
+#define PWM_DATATYPE uint16_t
+#define PWM_DATATYPE2 uint32_t // only needs 32-bit if ramp values go over 255
+#define PWM1_DATATYPE uint16_t // 15-bit PWM+DSM ramp
+
+// PWM parameters of both channels are tied together because they share a counter
+#define PWM_TOP_INIT 255
+#define DSM_TOP (255<<7) // 15-bit resolution leaves 1 bit for carry
+
+// warm LEDs
+uint16_t ch1_dsm_lvl;
+uint8_t ch1_pwm, ch1_dsm;
+#define CH1_PIN PB1 // pin 6, warm tint PWM
+#define CH1_PWM OCR0B // OCR0B is the output compare register for PB1
+
+// cold LEDs
+uint16_t ch2_dsm_lvl;
+uint8_t ch2_pwm, ch2_dsm;
+#define CH2_PIN PB0 // pin 5, cold tint PWM
+#define CH2_PWM OCR0A // OCR0A is the output compare register for PB0
+
+#define AUXLED_PIN PB4 // pin 3
+
+// e-switch
+#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
+
+#define FAST 0xA3 // fast PWM both channels
+#define PHASE 0xA1 // phase-correct PWM both channels
+
+
+inline void hwdef_setup() {
+ // configure PWM channels
+ DDRB = (1 << CH1_PIN)
+ | (1 << CH2_PIN);
+
+ TCCR0B = 0x01; // pre-scaler for timer (1 => 1, 2 => 8, 3 => 64...)
+ TCCR0A = PHASE;
+
+ // enable timer 0 overflow interrupt for DSM purposes
+ TIMSK |= (1 << TOIE0);
+
+ // configure e-switch
+ PORTB = (1 << SWITCH_PIN); // e-switch is the only input
+ PCMSK = (1 << SWITCH_PIN); // pin change interrupt uses this pin
+}
+
+
+#define LAYOUT_DEFINED
+
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