aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorSelene ToyKeeper2023-08-25 16:21:04 -0600
committerSelene ToyKeeper2023-08-25 16:21:04 -0600
commitd53ba0d8cb2f491f95adabf7b37cf195ae1fe5e6 (patch)
tree818702217e01029d67f759a2b43ee912e370ef77 /hw
parentadded emisar-d4k-3ch build (diff)
downloadanduril-d53ba0d8cb2f491f95adabf7b37cf195ae1fe5e6.tar.gz
anduril-d53ba0d8cb2f491f95adabf7b37cf195ae1fe5e6.tar.bz2
anduril-d53ba0d8cb2f491f95adabf7b37cf195ae1fe5e6.zip
made custom 3H handler system work, added circular HSV ramping,
fixed some minor issues with LEDs not getting turned off in corner cases (strobe on channel 1 -> strobe on channel 2, 1 might not get turned off)
Diffstat (limited to '')
-rw-r--r--hwdef-emisar-d4k-3ch.c33
-rw-r--r--hwdef-emisar-d4k-3ch.h2
2 files changed, 24 insertions, 11 deletions
diff --git a/hwdef-emisar-d4k-3ch.c b/hwdef-emisar-d4k-3ch.c
index 1042d9e..1955b59 100644
--- a/hwdef-emisar-d4k-3ch.c
+++ b/hwdef-emisar-d4k-3ch.c
@@ -3,6 +3,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
+#include "spaghetti-monster/anduril/channel-modes.h" //for circular_tint_3h()
#include "chan-rgbaux.c"
@@ -69,15 +70,21 @@ Channel channels[] = {
RGB_AUX_CHANNELS
};
+// HSV mode needs a different 3H handler
+StatePtr channel_3H_modes[NUM_CHANNEL_MODES] = {
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, circular_tint_3h, NULL,
+};
// LEDs 1+2 are 8-bit
// this 8-bit channel may be LEDs 1+2 or LED 4, depending on wiring
void set_level_main2(uint8_t level) {
+ LED3_ENABLE_PORT &= ~(1 << LED3_ENABLE_PIN ); // turn off unused LEDs
+ LED4_ENABLE_PORT &= ~(1 << LED4_ENABLE_PIN ); // turn off unused LEDs
+
if (level == 0) {
MAIN2_PWM_LVL = 0;
MAIN2_ENABLE_PORT &= ~(1 << MAIN2_ENABLE_PIN); // turn off opamp
- LED3_ENABLE_PORT &= ~(1 << LED3_ENABLE_PIN ); // turn off opamp
- LED4_ENABLE_PORT &= ~(1 << LED4_ENABLE_PIN ); // turn off opamp
} else {
level --;
MAIN2_ENABLE_PORT |= (1 << MAIN2_ENABLE_PIN);
@@ -87,12 +94,13 @@ void set_level_main2(uint8_t level) {
// LED 3 is 16-bit
void set_level_led3(uint8_t level) {
+ MAIN2_ENABLE_PORT &= ~(1 << MAIN2_ENABLE_PIN); // turn off unused LEDs
+ LED4_ENABLE_PORT &= ~(1 << LED4_ENABLE_PIN ); // turn off unused LEDs
+
if (level == 0) {
LED3_PWM_LVL = 0;
PWM_CNT = 0;
- MAIN2_ENABLE_PORT &= ~(1 << MAIN2_ENABLE_PIN); // turn off opamp
LED3_ENABLE_PORT &= ~(1 << LED3_ENABLE_PIN ); // turn off opamp
- LED4_ENABLE_PORT &= ~(1 << LED4_ENABLE_PIN ); // turn off opamp
} else {
level --;
LED3_ENABLE_PORT |= (1 << LED3_ENABLE_PIN);
@@ -106,11 +114,12 @@ void set_level_led3(uint8_t level) {
// this 16-bit channel may be LED 4 or LEDs 1+2, depending on wiring
void set_level_led4(uint8_t level) {
+ MAIN2_ENABLE_PORT &= ~(1 << MAIN2_ENABLE_PIN); // turn off unused LEDs
+ LED3_ENABLE_PORT &= ~(1 << LED3_ENABLE_PIN ); // turn off unused LEDs
+
if (level == 0) {
LED4_PWM_LVL = 0;
PWM_CNT = 0; // reset phase
- MAIN2_ENABLE_PORT &= ~(1 << MAIN2_ENABLE_PIN); // turn off opamp
- LED3_ENABLE_PORT &= ~(1 << LED3_ENABLE_PIN ); // turn off opamp
LED4_ENABLE_PORT &= ~(1 << LED4_ENABLE_PIN ); // turn off opamp
} else {
level --; // PWM array index = level - 1
@@ -159,11 +168,12 @@ void set_level_all(uint8_t level) {
// 8/16/16 wiring, mix 16+16
void set_level_led34a_blend(uint8_t level) {
+ MAIN2_ENABLE_PORT &= ~(1 << MAIN2_ENABLE_PIN); // turn off unused LEDs
+
if (level == 0) {
LED3_PWM_LVL = 0;
LED4_PWM_LVL = 0;
PWM_CNT = 0; // reset phase
- MAIN2_ENABLE_PORT &= ~(1 << MAIN2_ENABLE_PIN); // turn off opamp
LED3_ENABLE_PORT &= ~(1 << LED3_ENABLE_PIN ); // turn off opamp
LED4_ENABLE_PORT &= ~(1 << LED4_ENABLE_PIN ); // turn off opamp
return;
@@ -189,13 +199,14 @@ void set_level_led34a_blend(uint8_t level) {
// 16/16/8 wiring, mix 16+8
void set_level_led34b_blend(uint8_t level) {
+ LED4_ENABLE_PORT &= ~(1 << LED4_ENABLE_PIN ); // turn off unused LEDs
+
if (level == 0) {
- LED3_PWM_LVL = 0;
- LED4_PWM_LVL = 0;
- PWM_CNT = 0; // reset phase
+ MAIN2_PWM_LVL = 0;
+ LED3_PWM_LVL = 0;
+ PWM_CNT = 0; // reset phase
MAIN2_ENABLE_PORT &= ~(1 << MAIN2_ENABLE_PIN); // turn off opamp
LED3_ENABLE_PORT &= ~(1 << LED3_ENABLE_PIN ); // turn off opamp
- LED4_ENABLE_PORT &= ~(1 << LED4_ENABLE_PIN ); // turn off opamp
return;
}
diff --git a/hwdef-emisar-d4k-3ch.h b/hwdef-emisar-d4k-3ch.h
index 4a3134e..538e3f6 100644
--- a/hwdef-emisar-d4k-3ch.h
+++ b/hwdef-emisar-d4k-3ch.h
@@ -72,6 +72,8 @@ enum channel_modes_e {
#define USE_CHANNEL_MODE_ARGS
// _, _, _, _, 128=middle CCT, 128=middle CCT, 213=purple, _
#define CHANNEL_MODE_ARGS 0,0,0,0,128,128,213,0,RGB_AUX_CM_ARGS
+#define USE_CUSTOM_CHANNEL_3H_MODES
+#define USE_CIRCULAR_TINT_3H
// can use some of the common handlers
#define USE_CALC_2CH_BLEND
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.