aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSelene ToyKeeper2023-04-29 01:21:51 -0600
committerSelene ToyKeeper2023-04-29 01:21:51 -0600
commit71929d68d210a26ac12bd53299cc0a52fcfafdbf (patch)
tree026da08305f50c1d019d666468e8d6707108040f
parentNoctigon KR4: updated to use new channel system (diff)
downloadanduril-71929d68d210a26ac12bd53299cc0a52fcfafdbf.tar.gz
anduril-71929d68d210a26ac12bd53299cc0a52fcfafdbf.tar.bz2
anduril-71929d68d210a26ac12bd53299cc0a52fcfafdbf.zip
missed this file on previous commit
-rw-r--r--hwdef-emisar-d4v2.c55
1 files changed, 29 insertions, 26 deletions
diff --git a/hwdef-emisar-d4v2.c b/hwdef-emisar-d4v2.c
index dce6c92..9b647a3 100644
--- a/hwdef-emisar-d4v2.c
+++ b/hwdef-emisar-d4v2.c
@@ -7,39 +7,42 @@
#include "chan-rgbaux.c"
// single set of LEDs with 2 stacked power channels, DDFET+1 or DDFET+linear
-void set_level_stacked(uint8_t level) {
+void set_level_main(uint8_t level) {
if (level == 0) {
- LOW_PWM_LVL = 0;
- HIGH_PWM_LVL = 0;
- PWM_CNT = 0; // reset phase
- } else {
- level --; // PWM array index = level - 1
- LOW_PWM_LVL = PWM_GET(pwm1_levels, level);
- HIGH_PWM_LVL = PWM_GET(pwm2_levels, level);
- // pulse frequency modulation, a.k.a. dynamic PWM
- uint16_t top = PWM_GET(pwm_tops, level);
- // wait to sync the counter and avoid flashes
- while(actual_level && (PWM_CNT > (top - 32))) {}
- PWM_TOP = top;
- // force reset phase when turning on from zero
- // (because otherwise the initial response is inconsistent)
- if (! actual_level) PWM_CNT = 0;
+ CH1_PWM = 0;
+ CH2_PWM = 0;
+ PWM_CNT = 0; // reset phase
+ return;
}
+
+ level --; // PWM array index = level - 1
+ PWM_DATATYPE ch1_pwm = PWM_GET(pwm1_levels, level);
+ PWM_DATATYPE ch2_pwm = PWM_GET(pwm2_levels, level);
+ // pulse frequency modulation, a.k.a. dynamic PWM
+ uint16_t top = PWM_GET(pwm_tops, level);
+
+ CH1_PWM = ch1_pwm;
+ CH2_PWM = ch2_pwm;
+ // wait to sync the counter and avoid flashes
+ while(actual_level && (PWM_CNT > (top - 32))) {}
+ PWM_TOP = top;
+ // force reset phase when turning on from zero
+ // (because otherwise the initial response is inconsistent)
+ if (! actual_level) PWM_CNT = 0;
}
-bool gradual_tick_stacked(uint8_t gt) {
- GRADUAL_TICK_SETUP();
+bool gradual_tick_main(uint8_t gt) {
+ PWM_DATATYPE pwm1 = PWM_GET(pwm1_levels, gt);
+ PWM_DATATYPE pwm2 = PWM_GET(pwm2_levels, gt);
- GRADUAL_ADJUST(pwm1_levels, LOW_PWM_LVL, PWM_TOP_INIT);
- GRADUAL_ADJUST_1CH(pwm2_levels, HIGH_PWM_LVL);
+ GRADUAL_ADJUST_STACKED(pwm1, CH1_PWM, PWM_TOP_INIT);
+ GRADUAL_ADJUST_SIMPLE (pwm2, CH2_PWM);
- // did we go far enough to hit the next defined ramp level?
- // if so, update the main ramp level tracking var
- if ( (LOW_PWM_LVL == PWM_GET(pwm1_levels, gt))
- && (HIGH_PWM_LVL == PWM_GET(pwm2_levels, gt))
+ if ( (pwm1 == CH1_PWM)
+ && (pwm2 == CH2_PWM)
) {
- return true;
+ return true; // done
}
- return false;
+ return false; // not done yet
}
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.