aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorSelene ToyKeeper2023-07-21 15:44:38 -0600
committerSelene ToyKeeper2023-07-21 15:44:38 -0600
commit188eb9e0f2a31e07d5faee27c3f42dacb818e46e (patch)
treeb8b4d3fd888dd89327702c68cea408b1cffc98d9 /hw
parentkludgy attempt to factor PWM rise/fall time into level_calc.py (diff)
downloadanduril-188eb9e0f2a31e07d5faee27c3f42dacb818e46e.tar.gz
anduril-188eb9e0f2a31e07d5faee27c3f42dacb818e46e.tar.bz2
anduril-188eb9e0f2a31e07d5faee27c3f42dacb818e46e.zip
converted emisar-d4v2-nofet to multi-channel, and
gave it a new ramp with dynamic PWM
Diffstat (limited to '')
-rw-r--r--hwdef-emisar-d4v2-nofet.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/hwdef-emisar-d4v2-nofet.c b/hwdef-emisar-d4v2-nofet.c
new file mode 100644
index 0000000..60d80ea
--- /dev/null
+++ b/hwdef-emisar-d4v2-nofet.c
@@ -0,0 +1,55 @@
+// Emisar D4v2 (no DD FET, 1x7135 only) PWM helper functions
+// Copyright (C) 2017-2023 Selene ToyKeeper
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+#pragma once
+
+#include "chan-rgbaux.c"
+
+void set_level_main(uint8_t level);
+bool gradual_tick_main(uint8_t gt);
+
+
+Channel channels[] = {
+ { // main LEDs
+ .set_level = set_level_main,
+ .gradual_tick = gradual_tick_main
+ },
+ RGB_AUX_CHANNELS
+};
+
+
+// single set of LEDs with just a 1x7135 chip, max 350 mA or ~130 lm
+void set_level_main(uint8_t level) {
+ if (level == 0) {
+ CH1_PWM = 0;
+ PWM_CNT = 0; // reset phase
+ return;
+ }
+
+ level --; // PWM array index = level - 1
+ PWM_DATATYPE ch1_pwm = PWM_GET(pwm1_levels, level);
+ // pulse frequency modulation, a.k.a. dynamic PWM
+ uint16_t top = PWM_GET16(pwm_tops, level);
+
+ CH1_PWM = ch1_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_main(uint8_t gt) {
+ PWM_DATATYPE pwm1 = PWM_GET(pwm1_levels, gt);
+
+ GRADUAL_ADJUST_SIMPLE (pwm1, CH1_PWM);
+
+ if ( (pwm1 == CH1_PWM)
+ ) {
+ return true; // done
+ }
+ 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.