aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSelene ToyKeeper2023-07-16 16:27:44 -0600
committerSelene ToyKeeper2023-07-16 16:27:44 -0600
commit723b5b1ffa8f12b29110a2133a8f09beaf528aad (patch)
tree229a77ce7bc61ec065cef4ecee8be330ac7fd624
parentrefactored how channel modes are defined, and converted emisar-2ch build (diff)
downloadanduril-723b5b1ffa8f12b29110a2133a8f09beaf528aad.tar.gz
anduril-723b5b1ffa8f12b29110a2133a8f09beaf528aad.tar.bz2
anduril-723b5b1ffa8f12b29110a2133a8f09beaf528aad.zip
fixed d4v2, kr4, m44, emisar-2ch (using new refactor),
added RGB aux channel modes to models which didn't have it
-rw-r--r--hwdef-emisar-2ch.c1
-rw-r--r--hwdef-emisar-d4v2.c13
-rw-r--r--hwdef-emisar-d4v2.h45
-rw-r--r--hwdef-noctigon-kr4-nofet.c13
-rw-r--r--hwdef-noctigon-kr4.c13
-rw-r--r--hwdef-noctigon-kr4.h45
-rw-r--r--hwdef-noctigon-m44.c47
-rw-r--r--hwdef-noctigon-m44.h131
-rw-r--r--spaghetti-monster/anduril/cfg-emisar-2ch.h4
-rw-r--r--spaghetti-monster/anduril/cfg-noctigon-m44.h6
-rw-r--r--spaghetti-monster/chan-rgbaux.h35
11 files changed, 181 insertions, 172 deletions
diff --git a/hwdef-emisar-2ch.c b/hwdef-emisar-2ch.c
index 427509f..793e9bc 100644
--- a/hwdef-emisar-2ch.c
+++ b/hwdef-emisar-2ch.c
@@ -1,6 +1,7 @@
// Emisar 2-channel generic w/ tint ramping
// Copyright (C) 2021-2023 Selene ToyKeeper
// SPDX-License-Identifier: GPL-3.0-or-later
+
#pragma once
#include "chan-rgbaux.c"
diff --git a/hwdef-emisar-d4v2.c b/hwdef-emisar-d4v2.c
index db32f19..c4ae5dd 100644
--- a/hwdef-emisar-d4v2.c
+++ b/hwdef-emisar-d4v2.c
@@ -6,6 +6,19 @@
#include "chan-rgbaux.c"
+void set_level_main(uint8_t level);
+bool gradual_tick_main(uint8_t gt);
+
+
+Channel channels[] = {
+ { // channel 1 only
+ .set_level = set_level_main,
+ .gradual_tick = gradual_tick_main
+ },
+ RGB_AUX_CHANNELS
+};
+
+
// single set of LEDs with 2 stacked power channels, DDFET+1 or DDFET+linear
void set_level_main(uint8_t level) {
if (level == 0) {
diff --git a/hwdef-emisar-d4v2.h b/hwdef-emisar-d4v2.h
index 728d9e4..6837bcd 100644
--- a/hwdef-emisar-d4v2.h
+++ b/hwdef-emisar-d4v2.h
@@ -36,54 +36,23 @@
// allow using aux LEDs as extra channel modes
#include "chan-rgbaux.h"
-#define USE_CHANNEL_MODES
// channel modes:
// * 0. FET+7135 stacked
-// * 1. aux red
-// * 2. aux yellow
-// * 3. aux green
-// * 4. aux cyan
-// * 5. aux blue
-// * 6. aux purple
-// * 7. aux white
-#define NUM_CHANNEL_MODES 8
+// * 1+. aux RGB
+#define NUM_CHANNEL_MODES (1 + NUM_RGB_AUX_CHANNEL_MODES)
enum CHANNEL_MODES {
CM_MAIN = 0,
- CM_AUXRED,
- CM_AUXYEL,
- CM_AUXGRN,
- CM_AUXCYN,
- CM_AUXBLU,
- CM_AUXPRP,
- CM_AUXWHT,
+ RGB_AUX_ENUMS
};
#define DEFAULT_CHANNEL_MODE CM_MAIN
-#define CHANNEL_MODES_ENABLED 0b00000001
-#define CHANNEL_HAS_ARGS 0b00000000
+// right-most bit first, modes are in fedcba9876543210 order
+#define CHANNEL_MODES_ENABLED 0b0000000000000001
// no args
//#define USE_CHANNEL_MODE_ARGS
//#define CHANNEL_MODE_ARGS 0,0,0,0,0,0,0,0
-#define SET_LEVEL_MODES set_level_main, \
- set_level_auxred, \
- set_level_auxyel, \
- set_level_auxgrn, \
- set_level_auxcyn, \
- set_level_auxblu, \
- set_level_auxprp, \
- set_level_auxwht
-// gradual ticking for thermal regulation
-#define GRADUAL_TICK_MODES gradual_tick_main, \
- gradual_tick_null, \
- gradual_tick_null, \
- gradual_tick_null, \
- gradual_tick_null, \
- gradual_tick_null, \
- gradual_tick_null, \
- gradual_tick_null
-
#define PWM_CHANNELS 2 // old, remove this
@@ -146,10 +115,6 @@ enum CHANNEL_MODES {
#undef USE_INDICATOR_LED_WHILE_RAMPING
#endif
-void set_level_main(uint8_t level);
-
-bool gradual_tick_main(uint8_t gt);
-
inline void hwdef_setup() {
// enable output ports
diff --git a/hwdef-noctigon-kr4-nofet.c b/hwdef-noctigon-kr4-nofet.c
index ec984df..8ce9525 100644
--- a/hwdef-noctigon-kr4-nofet.c
+++ b/hwdef-noctigon-kr4-nofet.c
@@ -6,6 +6,19 @@
#include "chan-rgbaux.c"
+void set_level_main(uint8_t level);
+bool gradual_tick_main(uint8_t gt);
+
+
+Channel channels[] = {
+ { // channel 1 only
+ .set_level = set_level_main,
+ .gradual_tick = gradual_tick_main
+ },
+ RGB_AUX_CHANNELS
+};
+
+
// single set of LEDs with linear power channel
void set_level_main(uint8_t level) {
if (level == 0) {
diff --git a/hwdef-noctigon-kr4.c b/hwdef-noctigon-kr4.c
index 5813a9b..e49ff69 100644
--- a/hwdef-noctigon-kr4.c
+++ b/hwdef-noctigon-kr4.c
@@ -6,6 +6,19 @@
#include "chan-rgbaux.c"
+void set_level_main(uint8_t level);
+bool gradual_tick_main(uint8_t gt);
+
+
+Channel channels[] = {
+ { // channel 1 only
+ .set_level = set_level_main,
+ .gradual_tick = gradual_tick_main
+ },
+ RGB_AUX_CHANNELS
+};
+
+
// single set of LEDs with 2 stacked power channels, linear + DD FET
void set_level_main(uint8_t level) {
if (level == 0) {
diff --git a/hwdef-noctigon-kr4.h b/hwdef-noctigon-kr4.h
index 806aeab..202a302 100644
--- a/hwdef-noctigon-kr4.h
+++ b/hwdef-noctigon-kr4.h
@@ -44,54 +44,23 @@
// allow using aux LEDs as extra channel modes
#include "chan-rgbaux.h"
-#define USE_CHANNEL_MODES
// channel modes:
// * 0. linear + DD FET stacked
-// * 1. aux red
-// * 2. aux yellow
-// * 3. aux green
-// * 4. aux cyan
-// * 5. aux blue
-// * 6. aux purple
-// * 7. aux white
-#define NUM_CHANNEL_MODES 8
+// * 1+. aux RGB
+#define NUM_CHANNEL_MODES (1 + NUM_RGB_AUX_CHANNEL_MODES)
enum CHANNEL_MODES {
CM_MAIN = 0,
- CM_AUXRED,
- CM_AUXYEL,
- CM_AUXGRN,
- CM_AUXCYN,
- CM_AUXBLU,
- CM_AUXPRP,
- CM_AUXWHT,
+ RGB_AUX_ENUMS
};
#define DEFAULT_CHANNEL_MODE CM_MAIN
-#define CHANNEL_MODES_ENABLED 0b00000001
-#define CHANNEL_HAS_ARGS 0b00000000
+// right-most bit first, modes are in fedcba9876543210 order
+#define CHANNEL_MODES_ENABLED 0b0000000000000001
// no args
//#define USE_CHANNEL_MODE_ARGS
//#define CHANNEL_MODE_ARGS 0,0,0,0,0,0,0,0
-#define SET_LEVEL_MODES set_level_main, \
- set_level_auxred, \
- set_level_auxyel, \
- set_level_auxgrn, \
- set_level_auxcyn, \
- set_level_auxblu, \
- set_level_auxprp, \
- set_level_auxwht
-// gradual ticking for thermal regulation
-#define GRADUAL_TICK_MODES gradual_tick_main, \
- gradual_tick_null, \
- gradual_tick_null, \
- gradual_tick_null, \
- gradual_tick_null, \
- gradual_tick_null, \
- gradual_tick_null, \
- gradual_tick_null
-
#define PWM_CHANNELS 2 // old, remove this
@@ -182,10 +151,6 @@ enum CHANNEL_MODES {
#undef USE_INDICATOR_LED_WHILE_RAMPING
#endif
-void set_level_main(uint8_t level);
-
-bool gradual_tick_main(uint8_t gt);
-
inline void hwdef_setup() {
// enable output ports
diff --git a/hwdef-noctigon-m44.c b/hwdef-noctigon-m44.c
index 482ef05..3fc6abe 100644
--- a/hwdef-noctigon-m44.c
+++ b/hwdef-noctigon-m44.c
@@ -1,8 +1,55 @@
// hwdef for Noctigon M44 2-channel light
// Copyright (C) 2023 Selene ToyKeeper
// SPDX-License-Identifier: GPL-3.0-or-later
+
#pragma once
+#include "chan-rgbaux.c"
+
+
+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);
+
+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);
+
+
+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_auto,
+ .gradual_tick = gradual_tick_auto,
+ .has_args = 1
+ },
+ RGB_AUX_CHANNELS
+};
+
+
// set new values for both channels,
// handling any possible combination
// and any before/after state
diff --git a/hwdef-noctigon-m44.h b/hwdef-noctigon-m44.h
index 02b5904..f69fdd5 100644
--- a/hwdef-noctigon-m44.h
+++ b/hwdef-noctigon-m44.h
@@ -28,11 +28,14 @@
* ADC12 thermal sensor
*/
-#define HWDEF_C_FILE hwdef-noctigon-m44.c
-
#define ATTINY 1634
#include <avr/io.h>
+#define HWDEF_C_FILE hwdef-noctigon-m44.c
+
+// allow using aux LEDs as extra channel modes
+#include "chan-rgbaux.h"
+
// channel modes:
// * 0. channel 1 only
// * 1. channel 2 only
@@ -40,32 +43,22 @@
// * 3. both channels, manual blend
// * 4? both channels, manual blend, max 200% power
// * 4. both channels, auto blend, reversible
-#define NUM_CHANNEL_MODES 5
-#define CM_CH1 0
-#define CM_CH2 1
-#define CM_BOTH 2
-#define CM_BLEND 3
-#define CM_AUTO 4
-// TODO: Add RGB aux channel modes
-
-#define CHANNEL_MODES_ENABLED 0b00011111
-#define CHANNEL_HAS_ARGS 0b00011000
+#define NUM_CHANNEL_MODES (5 + NUM_RGB_AUX_CHANNEL_MODES)
+enum channel_modes_e {
+ CM_CH1 = 0,
+ CM_CH2,
+ CM_BOTH,
+ CM_BLEND,
+ CM_AUTO,
+ RGB_AUX_ENUMS
+};
+
+// right-most bit first, modes are in fedcba9876543210 order
+#define CHANNEL_MODES_ENABLED 0b0000000000011111
+#define USE_CHANNEL_MODE_ARGS
// _, _, _, 128=middle CCT, 0=warm-to-cool
-#define CHANNEL_MODE_ARGS 0,0,0,128,0
+#define CHANNEL_MODE_ARGS 0,0,0,128,0,RGB_AUX_CM_ARGS
-#define USE_CHANNEL_MODES
-#define USE_CHANNEL_MODE_ARGS
-#define SET_LEVEL_MODES set_level_ch1, \
- set_level_ch2, \
- set_level_both, \
- set_level_blend, \
- set_level_auto
-// gradual ticking for thermal regulation
-#define GRADUAL_TICK_MODES gradual_tick_ch1, \
- gradual_tick_ch2, \
- gradual_tick_both, \
- gradual_tick_blend, \
- gradual_tick_auto
// can use some of the common handlers
#define USE_CALC_2CH_BLEND
@@ -96,6 +89,7 @@
#define CH2_ENABLE_PORT PORTA // control port for PA0
+// e-switch
#ifndef SWITCH_PIN
#define SWITCH_PIN PA7 // pin 20
#define SWITCH_PCINT PCINT7 // pin 20 pin change interrupt
@@ -150,57 +144,42 @@
#define BUTTON_LED_PUE PUEA // for all "PA" pins
-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);
-
-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);
-
-
-// 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 << CH3_PIN);
- DDRB = (1 << CH1_PIN)
- | (1 << CH1_ENABLE_PIN)
- ;
- DDRA = (1 << CH2_PIN)
- | (1 << CH2_ENABLE_PIN)
- | (1 << AUXLED_R_PIN)
- | (1 << AUXLED_G_PIN)
- | (1 << AUXLED_B_PIN)
- | (1 << BUTTON_LED_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]: 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<<WGM11) | (0<<WGM10) // adjustable PWM (TOP=ICR1) (DS table 12-5)
- | (1<<COM1A1) | (0<<COM1A0) // PWM 1A in normal direction (DS table 12-4)
- | (1<<COM1B1) | (0<<COM1B0) // PWM 1B in normal direction (DS table 12-4)
- ;
- TCCR1B = (0<<CS12) | (0<<CS11) | (1<<CS10) // clk/1 (no prescaling) (DS table 12-6)
- | (1<<WGM13) | (0<<WGM12) // phase-correct adjustable PWM (DS table 12-5)
- ;
-
- // set PWM resolution
- PWM_TOP = PWM_TOP_INIT;
-
- // set up e-switch
- SWITCH_PUE = (1 << SWITCH_PIN); // pull-up for e-switch
- SWITCH_PCMSK = (1 << SWITCH_PCINT); // enable pin change interrupt
+ // enable output ports
+ //DDRC = (1 << CH3_PIN);
+ DDRB = (1 << CH1_PIN)
+ | (1 << CH1_ENABLE_PIN)
+ ;
+ DDRA = (1 << CH2_PIN)
+ | (1 << CH2_ENABLE_PIN)
+ | (1 << AUXLED_R_PIN)
+ | (1 << AUXLED_G_PIN)
+ | (1 << AUXLED_B_PIN)
+ | (1 << BUTTON_LED_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]: 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<<WGM11) | (0<<WGM10) // adjustable PWM (TOP=ICR1) (DS table 12-5)
+ | (1<<COM1A1) | (0<<COM1A0) // PWM 1A in normal direction (DS table 12-4)
+ | (1<<COM1B1) | (0<<COM1B0) // PWM 1B in normal direction (DS table 12-4)
+ ;
+ TCCR1B = (0<<CS12) | (0<<CS11) | (1<<CS10) // clk/1 (no prescaling) (DS table 12-6)
+ | (1<<WGM13) | (0<<WGM12) // phase-correct adjustable PWM (DS table 12-5)
+ ;
+
+ // set PWM resolution
+ PWM_TOP = PWM_TOP_INIT;
+
+ // set up e-switch
+ SWITCH_PUE = (1 << SWITCH_PIN); // pull-up for e-switch
+ SWITCH_PCMSK = (1 << SWITCH_PCINT); // enable pin change interrupt
}
#define LAYOUT_DEFINED
diff --git a/spaghetti-monster/anduril/cfg-emisar-2ch.h b/spaghetti-monster/anduril/cfg-emisar-2ch.h
index d158b88..5f3384a 100644
--- a/spaghetti-monster/anduril/cfg-emisar-2ch.h
+++ b/spaghetti-monster/anduril/cfg-emisar-2ch.h
@@ -22,7 +22,8 @@
// channel modes...
// CM_CH1, CM_CH2, CM_BOTH, CM_BLEND, CM_AUTO
-#define DEFAULT_CHANNEL_MODE CM_BLEND
+// enable max brightness out of the box
+#define DEFAULT_CHANNEL_MODE CM_BOTH
//#define FACTORY_RESET_WARN_CHANNEL CM_CH2
//#define FACTORY_RESET_SUCCESS_CHANNEL CM_BOTH
@@ -97,6 +98,7 @@
#define THERM_CAL_OFFSET 5
+// don't blink while ramping
#ifdef BLINK_AT_RAMP_MIDDLE
#undef BLINK_AT_RAMP_MIDDLE
#endif
diff --git a/spaghetti-monster/anduril/cfg-noctigon-m44.h b/spaghetti-monster/anduril/cfg-noctigon-m44.h
index aeded00..92cf38f 100644
--- a/spaghetti-monster/anduril/cfg-noctigon-m44.h
+++ b/spaghetti-monster/anduril/cfg-noctigon-m44.h
@@ -22,7 +22,8 @@
// channel modes...
// CM_CH1, CM_CH2, CM_BOTH, CM_BLEND, CM_AUTO
-#define DEFAULT_CHANNEL_MODE CM_AUTO
+// enable max brightness out of the box
+#define DEFAULT_CHANNEL_MODE CM_BOTH
//#define FACTORY_RESET_WARN_CHANNEL CM_CH2
//#define FACTORY_RESET_SUCCESS_CHANNEL CM_BOTH
@@ -31,6 +32,9 @@
//#define CONFIG_WAITING_CHANNEL CM_CH2
//#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_BLEND
+
#define POLICE_COLOR_STROBE_CH1 CM_CH1
#define POLICE_COLOR_STROBE_CH2 CM_CH2
diff --git a/spaghetti-monster/chan-rgbaux.h b/spaghetti-monster/chan-rgbaux.h
index ebb1bb9..6ef5d89 100644
--- a/spaghetti-monster/chan-rgbaux.h
+++ b/spaghetti-monster/chan-rgbaux.h
@@ -16,41 +16,48 @@
#define NUM_RGB_AUX_CHANNEL_MODES 7
+// include / exclude field based on compile options
+#ifdef USE_CHANNEL_MODE_ARGS
+ #define AUX_RGB_HAS_ARGS , .has_args = 0
+#else
+ #define AUX_RGB_HAS_ARGS
+#endif
+
#define RGB_AUX_CHANNELS \
{ \
.set_level = set_level_auxred, \
- .gradual_tick = gradual_tick_null, \
- .has_args = 0 \
+ .gradual_tick = gradual_tick_null \
+ AUX_RGB_HAS_ARGS \
}, \
{ \
.set_level = set_level_auxyel, \
- .gradual_tick = gradual_tick_null, \
- .has_args = 0 \
+ .gradual_tick = gradual_tick_null \
+ AUX_RGB_HAS_ARGS \
}, \
{ \
.set_level = set_level_auxgrn, \
- .gradual_tick = gradual_tick_null, \
- .has_args = 0 \
+ .gradual_tick = gradual_tick_null \
+ AUX_RGB_HAS_ARGS \
}, \
{ \
.set_level = set_level_auxcyn, \
- .gradual_tick = gradual_tick_null, \
- .has_args = 0 \
+ .gradual_tick = gradual_tick_null \
+ AUX_RGB_HAS_ARGS \
}, \
{ \
.set_level = set_level_auxblu, \
- .gradual_tick = gradual_tick_null, \
- .has_args = 0 \
+ .gradual_tick = gradual_tick_null \
+ AUX_RGB_HAS_ARGS \
}, \
{ \
.set_level = set_level_auxprp, \
- .gradual_tick = gradual_tick_null, \
- .has_args = 0 \
+ .gradual_tick = gradual_tick_null \
+ AUX_RGB_HAS_ARGS \
}, \
{ \
.set_level = set_level_auxwht, \
- .gradual_tick = gradual_tick_null, \
- .has_args = 0 \
+ .gradual_tick = gradual_tick_null \
+ AUX_RGB_HAS_ARGS \
}
void set_level_auxred(uint8_t level);
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.