aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSelene ToyKeeper2023-04-29 02:50:03 -0600
committerSelene ToyKeeper2023-04-29 02:50:03 -0600
commit882567cd08e15d73aee0802fd1b1c31076801a02 (patch)
tree30acf038e041d406da504d7ab713a68561bb062a
parentD4v2 can use 8-bit ramp tables too (diff)
downloadanduril-882567cd08e15d73aee0802fd1b1c31076801a02.tar.gz
anduril-882567cd08e15d73aee0802fd1b1c31076801a02.tar.bz2
anduril-882567cd08e15d73aee0802fd1b1c31076801a02.zip
converted KR4-nofet build
-rw-r--r--hwdef-noctigon-kr4-nofet.c47
-rw-r--r--hwdef-noctigon-kr4.h6
-rw-r--r--spaghetti-monster/anduril/cfg-noctigon-kr4-nofet.h8
3 files changed, 52 insertions, 9 deletions
diff --git a/hwdef-noctigon-kr4-nofet.c b/hwdef-noctigon-kr4-nofet.c
new file mode 100644
index 0000000..ec984df
--- /dev/null
+++ b/hwdef-noctigon-kr4-nofet.c
@@ -0,0 +1,47 @@
+// Noctigon KR4 (no DD FET) PWM helper functions
+// Copyright (C) 2020-2023 Selene ToyKeeper
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+#pragma once
+
+#include "chan-rgbaux.c"
+
+// single set of LEDs with linear power channel
+void set_level_main(uint8_t level) {
+ if (level == 0) {
+ CH1_PWM = 0;
+ CH2_PWM = 0;
+ PWM_CNT = 0; // reset phase
+ CH1_ENABLE_PORT &= ~(1 << CH1_ENABLE_PIN); // disable opamp
+ return;
+ }
+
+ CH1_ENABLE_PORT |= (1 << CH1_ENABLE_PIN); // enable opamp
+
+ 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;
+ CH2_PWM = 0;
+ // 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/hwdef-noctigon-kr4.h b/hwdef-noctigon-kr4.h
index b20effc..d6c33ff 100644
--- a/hwdef-noctigon-kr4.h
+++ b/hwdef-noctigon-kr4.h
@@ -37,7 +37,9 @@
#define ATTINY 1634
#include <avr/io.h>
+#ifndef HWDEF_C_FILE
#define HWDEF_C_FILE hwdef-noctigon-kr4.c
+#endif
// allow using aux LEDs as extra channel modes
#include "chan-rgbaux.h"
@@ -92,10 +94,6 @@
#define CH1_PWM OCR1A // OCR1A is the output compare register for PB3
#define CH1_ENABLE_PIN PB0 // pin 19, Opamp power
#define CH1_ENABLE_PORT PORTB // control port for PB0
-// TODO: remove these
-#define PWM1_PHASE_RESET_OFF // force reset while shutting off
-#define PWM1_PHASE_RESET_ON // force reset while turning on
-#define PWM1_PHASE_SYNC // manual sync while changing level
// DD FET channel
#define CH2_PIN PA6 // pin 1, DD FET PWM
diff --git a/spaghetti-monster/anduril/cfg-noctigon-kr4-nofet.h b/spaghetti-monster/anduril/cfg-noctigon-kr4-nofet.h
index 701d93f..6d49a8b 100644
--- a/spaghetti-monster/anduril/cfg-noctigon-kr4-nofet.h
+++ b/spaghetti-monster/anduril/cfg-noctigon-kr4-nofet.h
@@ -1,10 +1,11 @@
-// Noctigon KR4 (fetless) config options for Anduril
+// Noctigon KR4 (no DD FET) config options for Anduril
// Copyright (C) 2020-2023 Selene ToyKeeper
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
// (and Noctigon KR1)
// (and Emisar D4v2 E21A, a.k.a. "D4v2.5")
+#define HWDEF_C_FILE hwdef-noctigon-kr4-nofet.c
#include "cfg-noctigon-kr4.h"
#undef MODEL_NUMBER
#define MODEL_NUMBER "0212"
@@ -16,7 +17,7 @@
// max regulated: 1740 lm
#undef PWM_CHANNELS
#define PWM_CHANNELS 1
-#define RAMP_LENGTH 150
+#define RAMP_SIZE 150
// prioritize low lows, at risk of visible ripple
// level_calc.py 5.01 1 149 7135 1 0.3 1740 --pwm dyn:78:16384:255
#undef PWM1_LEVELS
@@ -49,9 +50,6 @@
#define SIMPLE_UI_CEIL RAMP_DISCRETE_CEIL
-// make candle mode wobble more
-#define CANDLE_AMPLITUDE 32
-
// slow down party strobe; this driver can't pulse for 1ms or less
// (only needed on no-FET build)
#define PARTY_STROBE_ONTIME 2
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.