aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorSelene ToyKeeper2023-07-10 11:56:04 -0600
committerSelene ToyKeeper2023-07-10 11:56:04 -0600
commit95a9eb6b3078915a2686c7ec55320273ef429838 (patch)
treeb185eca82ac208bf75e732a2ee300ab99eda0bbb /hw
parentPartially fixed oscillating aux LED voltage colors while asleep. (diff)
downloadanduril-95a9eb6b3078915a2686c7ec55320273ef429838.tar.gz
anduril-95a9eb6b3078915a2686c7ec55320273ef429838.tar.bz2
anduril-95a9eb6b3078915a2686c7ec55320273ef429838.zip
refactored how channel modes are defined, and converted emisar-2ch build
Diffstat (limited to '')
-rw-r--r--hwdef-emisar-2ch.c46
-rw-r--r--hwdef-emisar-2ch.h53
2 files changed, 63 insertions, 36 deletions
diff --git a/hwdef-emisar-2ch.c b/hwdef-emisar-2ch.c
index 53117e0..427509f 100644
--- a/hwdef-emisar-2ch.c
+++ b/hwdef-emisar-2ch.c
@@ -3,6 +3,52 @@
// 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-emisar-2ch.h b/hwdef-emisar-2ch.h
index 9d1b185..32cbc3b 100644
--- a/hwdef-emisar-2ch.h
+++ b/hwdef-emisar-2ch.h
@@ -33,37 +33,31 @@
#define HWDEF_C_FILE hwdef-emisar-2ch.c
-#define USE_CHANNEL_MODES
+// allow using aux LEDs as extra channel modes
+#include "chan-rgbaux.h"
+
// channel modes:
// * 0. channel 1 only
// * 1. channel 2 only
// * 2. both channels, tied together
// * 3. 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
-
-#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 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
+#define CHANNEL_MODE_ARGS 0,0,0,128,0,RGB_AUX_CM_ARGS
+
// can use some of the common handlers
#define USE_CALC_2CH_BLEND
@@ -151,19 +145,6 @@
#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);
-
-
inline void hwdef_setup() {
// enable output ports
//DDRC = (1 << CH3_PIN);
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.