aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSelene ToyKeeper2023-10-29 04:27:28 -0600
committerSelene ToyKeeper2023-10-29 04:27:28 -0600
commit842cfe6ab5ff989cf876688196b4e11898e2db88 (patch)
tree591e9521d57fc657b42ce8c2d940734e712f5b86
parentconverted noctigon-k1-sbt90 to new API and switched to dynamic PWM (diff)
downloadanduril-842cfe6ab5ff989cf876688196b4e11898e2db88.tar.gz
anduril-842cfe6ab5ff989cf876688196b4e11898e2db88.tar.bz2
anduril-842cfe6ab5ff989cf876688196b4e11898e2db88.zip
fixed blf-lt1-t1616, after testing on actual hardware
(its DSM interrupt wasn't working at all, and it needed a few other tweaks)
-rw-r--r--hwdef-blf-lt1-t1616.c8
-rw-r--r--hwdef-blf-lt1-t1616.h8
-rw-r--r--hwdef-sofirn-lt1s-pro.h5
-rw-r--r--spaghetti-monster/anduril/cfg-blf-lantern-t1616.h21
-rw-r--r--spaghetti-monster/anduril/cfg-sofirn-lt1s-pro.h22
5 files changed, 39 insertions, 25 deletions
diff --git a/hwdef-blf-lt1-t1616.c b/hwdef-blf-lt1-t1616.c
index 48a401d..9d268a4 100644
--- a/hwdef-blf-lt1-t1616.c
+++ b/hwdef-blf-lt1-t1616.c
@@ -54,7 +54,7 @@ Channel channels[] = {
void set_level_zero() {
// disable timer overflow interrupt
// (helps improve button press handling from Off state)
- DSM_INTCTRL &= ~DSM_OVF_bm;
+ DSM_INTCTRL = 0;
// turn off all LEDs
ch1_dsm_lvl = 0;
@@ -77,7 +77,7 @@ void set_hw_levels(PWM_DATATYPE ch1, PWM_DATATYPE ch2) {
CH2_PWM = ch2_pwm = ch2 >> 7;
// enable timer overflow interrupt so DSM can work
- DSM_INTCTRL |= DSM_OVF_bm;
+ DSM_INTCTRL = DSM_OVF_bm;
// reset phase when turning on
if (! was_on) PWM_CNT = 0;
@@ -107,6 +107,10 @@ ISR(DSM_vect) {
ch2_dsm += (ch2_dsm_lvl & 0x007f);
ch2_pwm = (ch2_dsm_lvl >> 7) + (ch2_dsm > 0x7f);
ch2_dsm &= 0x7f;
+
+ // clear the interrupt flag to indicate it was handled
+ // as per: https://onlinedocs.microchip.com/pr/GUID-C37FFBA8-82C6-4339-A2B1-ABD9A0F6C162-en-US-8/index.html?GUID-C2A2BEFD-158F-413D-B9D4-0F0556AA79BD
+ DSM_INTFLAGS = DSM_OVF_bm;
}
diff --git a/hwdef-blf-lt1-t1616.h b/hwdef-blf-lt1-t1616.h
index cc6d065..a28ee0f 100644
--- a/hwdef-blf-lt1-t1616.h
+++ b/hwdef-blf-lt1-t1616.h
@@ -65,19 +65,20 @@ enum channel_modes_e {
// timer interrupt for DSM
#define DSM_vect TCA0_OVF_vect
#define DSM_INTCTRL TCA0.SINGLE.INTCTRL
+#define DSM_INTFLAGS TCA0.SINGLE.INTFLAGS
#define DSM_OVF_bm TCA_SINGLE_OVF_bm
// warm LEDs
uint16_t ch1_dsm_lvl;
uint8_t ch1_pwm, ch1_dsm;
#define CH1_PIN PB1
-#define CH1_PWM TCA0.SINGLE.CMP1 // CMP1 is the output compare register for PB1
+#define CH1_PWM TCA0.SINGLE.CMP1BUF // CMP1 is the output compare register for PB1
// cold LEDs
uint16_t ch2_dsm_lvl;
uint8_t ch2_pwm, ch2_dsm;
#define CH2_PIN PB0
-#define CH2_PWM TCA0.SINGLE.CMP0 // CMP0 is the output compare register for PB0
+#define CH2_PWM TCA0.SINGLE.CMP0BUF // CMP0 is the output compare register for PB0
// lighted button
#define AUXLED_PIN PIN5_bp
@@ -106,6 +107,7 @@ inline void hwdef_setup() {
// Outputs
VPORTB.DIR = PIN0_bm // cool white
| PIN1_bm // warm white
+ // | PIN2_bm // for testing on LT1S Pro, disable red channel
| PIN5_bm; // aux LED
//VPORTC.DIR = ...;
@@ -121,7 +123,7 @@ inline void hwdef_setup() {
//PORTB.PIN0CTRL = PORT_PULLUPEN_bm; // cold tint channel
//PORTB.PIN1CTRL = PORT_PULLUPEN_bm; // warm tint channel
- PORTB.PIN2CTRL = PORT_PULLUPEN_bm;
+ PORTB.PIN2CTRL = PORT_PULLUPEN_bm; // comment out for testing on LT1S Pro
PORTB.PIN3CTRL = PORT_PULLUPEN_bm;
PORTB.PIN4CTRL = PORT_PULLUPEN_bm;
//PORTB.PIN5CTRL = PORT_PULLUPEN_bm; // Aux LED
diff --git a/hwdef-sofirn-lt1s-pro.h b/hwdef-sofirn-lt1s-pro.h
index 97de7d7..ae6b3bf 100644
--- a/hwdef-sofirn-lt1s-pro.h
+++ b/hwdef-sofirn-lt1s-pro.h
@@ -96,10 +96,11 @@ enum channel_modes_e {
inline void hwdef_setup() {
// set up the system clock to run at 10 MHz instead of the default 3.33 MHz
- _PROTECTED_WRITE( CLKCTRL.MCLKCTRLB, CLKCTRL_PDIV_2X_gc | CLKCTRL_PEN_bm );
+ _PROTECTED_WRITE( CLKCTRL.MCLKCTRLB,
+ CLKCTRL_PDIV_2X_gc | CLKCTRL_PEN_bm );
//VPORTA.DIR = ...;
- // Outputs:
+ // Outputs
VPORTB.DIR = PIN0_bm // warm white
| PIN1_bm // cool white
| PIN2_bm // red
diff --git a/spaghetti-monster/anduril/cfg-blf-lantern-t1616.h b/spaghetti-monster/anduril/cfg-blf-lantern-t1616.h
index 24a7c7c..fc02619 100644
--- a/spaghetti-monster/anduril/cfg-blf-lantern-t1616.h
+++ b/spaghetti-monster/anduril/cfg-blf-lantern-t1616.h
@@ -17,9 +17,14 @@
// channel modes...
// CM_CH1, CM_CH2, CM_BOTH, CM_BLEND, CM_AUTO
-#define DEFAULT_CHANNEL_MODE CM_AUTO
+#define DEFAULT_CHANNEL_MODE CM_AUTO
+#define DEFAULT_BLINK_CHANNEL CM_BOTH
+
+#define CONFIG_WAITING_CHANNEL CM_BOTH
+#define CONFIG_BLINK_CHANNEL CM_BOTH
+
+// blink numbers on the main LEDs by default (but allow user to change it)
#define DEFAULT_BLINK_CHANNEL CM_BOTH
-#define USE_CHANNEL_MODE_ARGS
// how much to increase total brightness at middle tint
// (0 = 100% brightness, 64 = 200% brightness)
@@ -30,13 +35,13 @@
// 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 3.333 1 150 7135 32 0.2 600 --pwm 32640
-#define PWM1_LEVELS 32,35,38,41,45,50,55,61,67,74,82,91,100,110,121,133,146,160,175,192,209,227,247,268,291,314,340,366,395,424,456,489,524,560,599,639,681,726,772,820,871,924,979,1036,1096,1158,1222,1289,1359,1431,1506,1584,1664,1747,1834,1923,2015,2111,2209,2311,2416,2524,2636,2751,2870,2992,3118,3247,3380,3518,3659,3803,3952,4105,4262,4423,4589,4759,4933,5111,5294,5482,5674,5871,6073,6279,6491,6707,6928,7155,7386,7623,7865,8113,8365,8624,8888,9157,9432,9713,10000,10292,10591,10895,11206,11523,11846,12175,12511,12853,13202,13557,13919,14287,14663,15045,15434,15830,16233,16644,17061,17486,17919,18358,18805,19260,19723,20193,20671,21156,21650,22152,22662,23180,23706,24241,24784,25335,25895,26464,27041,27627,28222,28826,29439,30060,30691,31332,31981,32640
+#define PWM1_LEVELS 4,35,38,41,45,50,55,61,67,74,82,91,100,110,121,133,146,160,175,192,209,227,247,268,291,314,340,366,395,424,456,489,524,560,599,639,681,726,772,820,871,924,979,1036,1096,1158,1222,1289,1359,1431,1506,1584,1664,1747,1834,1923,2015,2111,2209,2311,2416,2524,2636,2751,2870,2992,3118,3247,3380,3518,3659,3803,3952,4105,4262,4423,4589,4759,4933,5111,5294,5482,5674,5871,6073,6279,6491,6707,6928,7155,7386,7623,7865,8113,8365,8624,8888,9157,9432,9713,10000,10292,10591,10895,11206,11523,11846,12175,12511,12853,13202,13557,13919,14287,14663,15045,15434,15830,16233,16644,17061,17486,17919,18358,18805,19260,19723,20193,20671,21156,21650,22152,22662,23180,23706,24241,24784,25335,25895,26464,27041,27627,28222,28826,29439,30060,30691,31332,31981,32640
#define DEFAULT_LEVEL 75
#define MAX_1x7135 75
-#define HALFSPEED_LEVEL 1 // lowest level for tint ramping correction
-#define QUARTERSPEED_LEVEL 1
-#undef USE_DYNAMIC_UNDERCLOCKING // makes huge bumps in the ramp
+#define HALFSPEED_LEVEL 0 // always use tint ramping correction
+#define QUARTERSPEED_LEVEL 2 // quarter speed at level 1, full speed at 2+
+//#undef USE_DYNAMIC_UNDERCLOCKING // makes huge bumps in the ramp
#define USE_SET_LEVEL_GRADUALLY
@@ -57,8 +62,10 @@
#define SIMPLE_UI_CEIL 150
#define SIMPLE_UI_STEPS 5
-// Allow 3C in Simple UI for switching between smooth and stepped ramping
+// Allow 3C (or 6C) in Simple UI (toggle smooth or stepped ramping)
#define USE_SIMPLE_UI_RAMPING_TOGGLE
+
+// allow Aux Config and Strobe Modes in Simple UI
#define USE_EXTENDED_SIMPLE_UI
#define USE_SOS_MODE
diff --git a/spaghetti-monster/anduril/cfg-sofirn-lt1s-pro.h b/spaghetti-monster/anduril/cfg-sofirn-lt1s-pro.h
index aee9ba0..440a03d 100644
--- a/spaghetti-monster/anduril/cfg-sofirn-lt1s-pro.h
+++ b/spaghetti-monster/anduril/cfg-sofirn-lt1s-pro.h
@@ -32,9 +32,6 @@
// blink numbers on the main LEDs by default (but allow user to change it)
#define DEFAULT_BLINK_CHANNEL CM_RED
-#define POLICE_COLOR_STROBE_CH1 CM_RED
-#define POLICE_COLOR_STROBE_CH2 CM_WHITE
-
// how much to increase total brightness at middle tint
// (0 = 100% brightness, 64 = 200% brightness)
// seems unnecessary on this light
@@ -74,18 +71,18 @@
#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 150
+#define RAMP_SMOOTH_FLOOR 1
+#define RAMP_SMOOTH_CEIL 150
//#define RAMP_DISCRETE_FLOOR 17 // 17 50 83 116 150
-#define RAMP_DISCRETE_FLOOR 1 // 1 25 50 75 100 125 150
-#define RAMP_DISCRETE_CEIL RAMP_SMOOTH_CEIL
-#define RAMP_DISCRETE_STEPS 7
+#define RAMP_DISCRETE_FLOOR 1 // 1 25 50 75 100 125 150
+#define RAMP_DISCRETE_CEIL 150
+#define RAMP_DISCRETE_STEPS 7
// LT1S can handle heat well, so don't limit simple mode
//#define SIMPLE_UI_FLOOR 10 // 10 45 80 115 150
-#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 1
+#define SIMPLE_UI_CEIL 150
+#define SIMPLE_UI_STEPS 7
// Allow 3C (or 6C) in Simple UI (toggle smooth or stepped ramping)
#define USE_SIMPLE_UI_RAMPING_TOGGLE
@@ -106,6 +103,9 @@
#define USE_SOS_MODE_IN_BLINKY_GROUP
#define USE_POLICE_COLOR_STROBE_MODE
+#define POLICE_COLOR_STROBE_CH1 CM_RED
+#define POLICE_COLOR_STROBE_CH2 CM_WHITE
+
#undef TACTICAL_LEVELS
#define TACTICAL_LEVELS 120,30,(RAMP_SIZE+3) // high, low, police strobe
If you find this content useful please consider a small donation via bitcoin: bitcoin:1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2?amount=0.001&message=Donation Scraping git contents via cgit is very resource intensive. The continued hosting of these git repositories is entirely financed by your bitcoin contributions. For donations of a least 1 mBTC you include your IP address in the message of your bitcoin donation. This will remove this message in the future for requests from your IP, which will significantly reduce token usage. In any case, any contributions to bitcoin address 1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2 are very welcome. Thanks in advance for you contribution to a self-sustaining ecosystem.