aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSelene ToyKeeper2023-07-21 15:44:38 -0600
committerSelene ToyKeeper2023-07-21 15:44:38 -0600
commit188eb9e0f2a31e07d5faee27c3f42dacb818e46e (patch)
treeb8b4d3fd888dd89327702c68cea408b1cffc98d9
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
-rw-r--r--hwdef-emisar-d4v2-nofet.c55
-rw-r--r--spaghetti-monster/anduril/cfg-emisar-d4v2-nofet.h31
2 files changed, 71 insertions, 15 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
+}
+
diff --git a/spaghetti-monster/anduril/cfg-emisar-d4v2-nofet.h b/spaghetti-monster/anduril/cfg-emisar-d4v2-nofet.h
index 9c6f0b0..6eddb40 100644
--- a/spaghetti-monster/anduril/cfg-emisar-d4v2-nofet.h
+++ b/spaghetti-monster/anduril/cfg-emisar-d4v2-nofet.h
@@ -3,35 +3,35 @@
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
+// switch to 1-channel support functions
+#define HWDEF_C_FILE hwdef-emisar-d4v2-nofet.c
+
#include "cfg-emisar-d4v2.h"
#undef MODEL_NUMBER
#define MODEL_NUMBER "0115"
// ATTINY: 1634
-// switch to 1-channel support functions
-#undef USE_SET_LEVEL_2CH_STACKED
-#undef USE_GRADUAL_TICK_2CH_STACKED
-#define USE_SET_LEVEL_1CH
-#define USE_GRADUAL_TICK_1CH
-#undef SET_LEVEL_MODES
-#undef GRADUAL_TICK_MODES
-#define SET_LEVEL_MODES set_level_1ch
-#define GRADUAL_TICK_MODES gradual_tick_1ch
-
+// the ramp uses only 1x7135 chip, max ~130 lm
#undef PWM_CHANNELS
#define PWM_CHANNELS 1
-#undef LOW_PWM_LEVELS
-#undef HIGH_PWM_LEVELS
-#define LOW_PWM_LEVELS 1,1,1,2,2,2,2,3,3,3,3,4,4,5,5,6,6,6,7,8,8,9,9,10,10,11,12,13,13,14,15,16,16,17,18,19,20,21,22,23,23,24,26,27,28,29,30,31,32,33,34,36,37,38,39,41,42,43,45,46,47,49,50,52,53,55,56,58,59,61,62,64,66,67,69,71,72,74,76,78,80,81,83,85,87,89,91,93,95,97,99,101,103,105,107,109,111,113,116,118,120,122,125,127,129,132,134,136,139,141,144,146,148,151,154,156,159,161,164,166,169,172,174,177,180,183,185,188,191,194,197,200,203,205,208,211,214,217,220,223,226,230,233,236,239,242,245,249,252,255
+#undef PWM1_LEVELS
+#undef PWM2_LEVELS
+#undef PWM_TOPS
+//#define PWM1_LEVELS 1,1,1,2,2,2,2,3,3,3,3,4,4,5,5,6,6,6,7,8,8,9,9,10,10,11,12,13,13,14,15,16,16,17,18,19,20,21,22,23,23,24,26,27,28,29,30,31,32,33,34,36,37,38,39,41,42,43,45,46,47,49,50,52,53,55,56,58,59,61,62,64,66,67,69,71,72,74,76,78,80,81,83,85,87,89,91,93,95,97,99,101,103,105,107,109,111,113,116,118,120,122,125,127,129,132,134,136,139,141,144,146,148,151,154,156,159,161,164,166,169,172,174,177,180,183,185,188,191,194,197,200,203,205,208,211,214,217,220,223,226,230,233,236,239,242,245,249,252,255
+// level_calc.py 3.01 1 150 7135 -1 0.1 140 --pwm dyn:64:4096:255:3 --clock 11:21:8.0
+// (and some manual tweaks to make half/quarter speed levels less bumpy)
+#define PWM1_LEVELS 1,1,2,2,3,4,4,5,6,7,9,10,11,11,12,13,13,14,15,15,18,18,17,18,18,19,19,19,19,19,20,20,20,20,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,21,21,22,23,24,24,26,27,28,29,30,31,32,33,34,35,36,38,39,40,42,43,44,46,47,49,50,52,53,55,56,58,60,62,63,65,67,69,71,73,75,77,79,81,83,85,88,90,92,95,97,100,102,105,107,110,112,115,118,121,124,127,129,132,135,139,142,145,148,151,155,158,162,165,169,172,176,179,183,187,191,195,199,203,207,211,215,219,223,228,232,237,241,246,250,255
+#define PWM_TOPS 4094,2719,3280,1954,2599,3032,2342,2548,2626,2635,2246,2261,2244,1964,1956,1929,1743,1733,1763,1697,1492,1362,1245,1231,1132,1118,1034,958,889,826,821,767,717,671,629,591,556,523,493,465,440,416,394,373,354,336,319,304,299,293,279,282,269,257,260,249,251,252,253,243,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
#undef MAX_1x7135
#define MAX_1x7135 150
#undef QUARTERSPEED_LEVEL
#undef HALFSPEED_LEVEL
-#define QUARTERSPEED_LEVEL 8
-#define HALFSPEED_LEVEL 16
+#define QUARTERSPEED_LEVEL 11
+#define HALFSPEED_LEVEL 21
+#undef DEFAULT_LEVEL
#define DEFAULT_LEVEL 80
#undef RAMP_SMOOTH_CEIL
@@ -50,6 +50,7 @@
#define SIMPLE_UI_FLOOR RAMP_DISCRETE_FLOOR
#define SIMPLE_UI_CEIL RAMP_DISCRETE_CEIL
+#undef CANDLE_AMPLITUDE
#define CANDLE_AMPLITUDE 60
#undef THERM_FASTER_LEVEL
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.