aboutsummaryrefslogtreecommitdiff
path: root/hwdef-Sofirn_LT1S-Pro.h
diff options
context:
space:
mode:
Diffstat (limited to 'hwdef-Sofirn_LT1S-Pro.h')
-rw-r--r--hwdef-Sofirn_LT1S-Pro.h109
1 files changed, 80 insertions, 29 deletions
diff --git a/hwdef-Sofirn_LT1S-Pro.h b/hwdef-Sofirn_LT1S-Pro.h
index ce6ee3a..c52364f 100644
--- a/hwdef-Sofirn_LT1S-Pro.h
+++ b/hwdef-Sofirn_LT1S-Pro.h
@@ -1,6 +1,3 @@
-#ifndef HWDEF_SOFIRN_LT1S_PRO_H
-#define HWDEF_SOFIRN_LT1S_PRO_H
-
/* BLF LT1S Pro driver layout using the Attiny1616
Driver pinout:
@@ -13,8 +10,10 @@ Driver pinout:
*/
+#pragma once
-#define LAYOUT_DEFINED
+
+#define HWDEF_C_FILE hwdef-Sofirn_LT1S-Pro.c
#ifdef ATTINY
#undef ATTINY
@@ -22,40 +21,85 @@ Driver pinout:
#define ATTINY 1616
#include <avr/io.h>
+// channel modes:
+// * 0. warm/cool white blend
+// * 1. auto 3ch blend (red -> warm -> cool by ramp level)
+// * 2. red only
+// * 3. red + white blend
+#define NUM_CHANNEL_MODES 4
+//#define CHANNEL_MODES_ENABLED 1,1,1,1
+#define CHANNEL_MODES_ENABLED 0b00001111
+#define CM_WHITE 0
+#define CM_AUTO 1
+#define CM_RED 2
+#define CM_WHITE_RED 3
+
+// TODO: blend mode should enable this automatically?
+#define USE_CHANNEL_MODES
+// TODO: blend mode should enable this automatically?
+#define USE_CHANNEL_MODE_ARGS
+// TODO: or maybe if args are defined, the USE_ should be auto-set?
+#define CHANNEL_MODE_ARGS 128,0,0,255
+#define SET_LEVEL_MODES set_level_2ch_blend, \
+ set_level_auto_3ch_blend, \
+ set_level_1ch, \
+ set_level_red_white_blend
+// TODO: gradual ticking for thermal regulation
+#define GRADUAL_TICK_MODES gradual_tick_2ch_blend, \
+ gradual_tick_auto_3ch_blend, \
+ gradual_tick_1ch, \
+ gradual_tick_red_white_blend
+// can use some of the common handlers
+#define USE_SET_LEVEL_2CH_BLEND
+//#define USE_SET_LEVEL_AUTO_3CH_BLEND
+#define USE_SET_LEVEL_1CH
+//#define USE_SET_LEVEL_RED_WHITE_BLEND
+// TODO:
+//#define USE_GRADUAL_TICK_2CH_BLEND
+//#define USE_GRADUAL_TICK_AUTO_3CH_BLEND
+//#define USE_GRADUAL_TICK_1CH
+//#define USE_GRADUAL_TICK_RED_WHITE_BLEND
+
+#define DEFAULT_CHANNEL_MODE CM_AUTO
+
+#define FACTORY_RESET_WARN_CHANNEL CM_RED
+#define FACTORY_RESET_SUCCESS_CHANNEL CM_WHITE
+
+#define POLICE_COLOR_STROBE_CH1 CM_RED
+#define POLICE_COLOR_STROBE_CH2 CM_WHITE
+
+// TODO: remove this as soon as it's not needed
#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 PB0 //
-#define TINT1_LVL TCA0.SINGLE.CMP0 // CMP1 is the output compare register for PB0
-#endif
+#define WARM_PWM_PIN PB0
+#define WARM_PWM_LVL TCA0.SINGLE.CMP0 // CMP1 is the output compare register for PB0
// cold tint channel
-#ifndef PWM2_PIN
-#define PWM2_PIN PB1 //
-#define TINT2_LVL TCA0.SINGLE.CMP1 // CMP0 is the output compare register for PB1
-#endif
+#define COOL_PWM_PIN PB1
+#define COOL_PWM_LVL TCA0.SINGLE.CMP1 // CMP0 is the output compare register for PB1
// red channel
-#ifndef PWM3_PIN
-#define PWM3_PIN PB0 //
-#define PWM3_LVL TCA0.SINGLE.CMP2 // CMP2 is the output compare register for PB2
-#endif
+#define RED_PWM_PIN PB0 //
+#define RED_PWM_LVL TCA0.SINGLE.CMP2 // CMP2 is the output compare register for PB2
+
+// translate cfg names to FSM names
+#define LOW_PWM_LEVELS RED_PWM_LEVELS
+#define LOW_PWM_LVL RED_PWM_LVL
+#define LOW_PWM_PIN RED_PWM_PIN
+
+// only using 8-bit on this light
+#define PWM_GET PWM_GET8
+#define PWM_DATATYPE uint8_t
+#define BLEND_PWM_DATATYPE uint8_t
+
// average drop across diode on this hardware
#ifndef VOLTAGE_FUDGE_FACTOR
@@ -64,14 +108,20 @@ uint8_t PWM1_LVL;
// lighted button
-#ifndef AUXLED_PIN
#define AUXLED_PIN PIN5_bp
#define AUXLED_PORT PORTB
-#endif
+
+// the button lights up
+#define USE_INDICATOR_LED
+// the button is visible while main LEDs are on
+#define USE_INDICATOR_LED_WHILE_RAMPING
+
+
+// custom channel modes
+void set_level_auto_3ch_blend(uint8_t level);
+void set_level_red_white_blend(uint8_t level);
-// 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 10 MHz instead of the default 3.33 MHz
@@ -111,4 +161,5 @@ inline void hwdef_setup() {
}
-#endif
+#define LAYOUT_DEFINED
+