aboutsummaryrefslogtreecommitdiff
path: root/hwdef-wurkkos-ts25.c
diff options
context:
space:
mode:
authorSelene ToyKeeper2023-05-02 09:13:39 -0600
committerSelene ToyKeeper2023-05-02 09:13:39 -0600
commit8e9106f6fb26eadbfffd56fa14390b9f41e74ed2 (patch)
tree3e53d3d86a0e3ae74399cf61704570e24ffe688f /hwdef-wurkkos-ts25.c
parentD4v2: added the rest of the aux RGB colors as channel modes, (diff)
downloadanduril-8e9106f6fb26eadbfffd56fa14390b9f41e74ed2.tar.gz
anduril-8e9106f6fb26eadbfffd56fa14390b9f41e74ed2.tar.bz2
anduril-8e9106f6fb26eadbfffd56fa14390b9f41e74ed2.zip
converted Wurkkos TS25 build...
... and gave it a smoother ramp ... and the other new functions added recently
Diffstat (limited to 'hwdef-wurkkos-ts25.c')
-rw-r--r--hwdef-wurkkos-ts25.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/hwdef-wurkkos-ts25.c b/hwdef-wurkkos-ts25.c
new file mode 100644
index 0000000..1d5b656
--- /dev/null
+++ b/hwdef-wurkkos-ts25.c
@@ -0,0 +1,49 @@
+// Wurkkos TS25 PWM helper functions
+// Copyright (C) 2023 Selene ToyKeeper
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+#pragma once
+
+#include "chan-rgbaux.c"
+
+// single set of LEDs with 2 stacked power channels, DDFET+1 or DDFET+linear
+void set_level_main(uint8_t level) {
+ if (level == 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_GET16(pwm_tops, level);
+
+ CH1_PWM = ch1_pwm;
+ CH2_PWM = ch2_pwm;
+ // wait to sync the counter and avoid flashes
+ // (unnecessary w/ buffered registers)
+ //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_main(uint8_t gt) {
+ PWM_DATATYPE pwm1 = PWM_GET(pwm1_levels, gt);
+ PWM_DATATYPE pwm2 = PWM_GET(pwm2_levels, gt);
+
+ GRADUAL_ADJUST_STACKED(pwm1, CH1_PWM, PWM_TOP_INIT);
+ GRADUAL_ADJUST_SIMPLE (pwm2, CH2_PWM);
+
+ if ( (pwm1 == CH1_PWM)
+ && (pwm2 == CH2_PWM)
+ ) {
+ return true; // done
+ }
+ return false; // not done yet
+}
+