aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hwdef-BLF_LT1.h54
-rw-r--r--spaghetti-monster/anduril/cfg-blf-lantern.h23
-rw-r--r--spaghetti-monster/fsm-main.c4
3 files changed, 50 insertions, 31 deletions
diff --git a/hwdef-BLF_LT1.h b/hwdef-BLF_LT1.h
index 5dac5d2..d0c2821 100644
--- a/hwdef-BLF_LT1.h
+++ b/hwdef-BLF_LT1.h
@@ -1,21 +1,55 @@
-#ifndef HWDEF_BLF_Q8_H
-#define HWDEF_BLF_Q8_H
+#ifndef HWDEF_BLF_LT1_H
+#define HWDEF_BLF_LT1_H
-/* BLF Q8 driver layout
- * Q8 driver is the same as a D4, basically
+/* BLF LT1 driver layout
+ * ----
+ * Reset -|1 8|- VCC
+ * eswitch -|2 7|- (unused)
+ * aux LED -|3 6|- PWM (5000K)
+ * GND -|4 5|- PWM (3000K)
+ * ----
*/
-// ... except the Q8 has a lighted button
-#ifndef AUXLED_PIN
+#define ATTINY 85
+#include <avr/io.h>
+
+#define PWM_CHANNELS 1 // 1 virtual channel (1 for main LEDs + 1 for 2nd LEDs)
+#define PWM_BITS 8 // 0 to 255 at 15.6 kHz
+#define PWM_TOP 255
+
+// dynamic PWM with tint ramping (not supported on attiny85)
+//#define USE_DYN_PWM // dynamic frequency and speed
+//#define PWM1_CNT TCNT0 // for dynamic PWM, reset phase
+
+// usually PWM1_LVL would be a hardware register, but we need to abstract
+// it out to a soft brightness value, in order to handle tint ramping
+// (this allows smooth thermal regulation to work, and makes things
+// otherwise simpler and easier)
+uint8_t PWM1_LVL;
+
+#define PWM1_PIN PB0 // pin 5, warm tint PWM
+#define TINT1_LVL OCR0A // OCR0A is the output compare register for PB0
+
+#define PWM2_PIN PB1 // pin 6, cold tint PWM
+#define TINT2_LVL OCR0B // OCR0B is the output compare register for PB1
+
+
#define AUXLED_PIN PB4 // pin 3
-#endif
-// ... and slightly different calibration
+#define SWITCH_PIN PB3 // pin 2
+#define SWITCH_PCINT PCINT3 // pin 2 pin change interrupt
+
+#define ADC_PRSCL 0x07 // clk/128
+
+// average drop across diode on this hardware
#ifndef VOLTAGE_FUDGE_FACTOR
#define VOLTAGE_FUDGE_FACTOR 7 // add 0.35V
#endif
-// Q8 driver is the same as a D4, basically
-#include "hwdef-Emisar_D4.h"
+#define FAST 0xA3 // fast PWM both channels
+#define PHASE 0xA1 // phase-correct PWM both channels
+
+#define LAYOUT_DEFINED
+
#endif
diff --git a/spaghetti-monster/anduril/cfg-blf-lantern.h b/spaghetti-monster/anduril/cfg-blf-lantern.h
index 28c7dbb..48ed1f7 100644
--- a/spaghetti-monster/anduril/cfg-blf-lantern.h
+++ b/spaghetti-monster/anduril/cfg-blf-lantern.h
@@ -1,16 +1,7 @@
// BLF Lantern config options for Anduril
#define MODEL_NUMBER "0621"
-/* BLF Lantern pinout
- * ----
- * Reset -|1 8|- VCC
- * eswitch -|2 7|- powerbank enable?
- * aux LED -|3 6|- PWM (5000K)
- * GND -|4 5|- PWM (3000K)
- * ----
- */
-
-// basically the same as a Q8... sort of
-#include "hwdef-BLF_Q8.h"
+#include "hwdef-BLF_LT1.h"
+// ATTINY: 85
// the button lights up
#define USE_INDICATOR_LED
@@ -56,7 +47,7 @@
// LT1 can handle heat well, so don't limit simple mode
#define SIMPLE_UI_FLOOR RAMP_DISCRETE_FLOOR
-#define SIMPLE_UI_CEIL RAMP_DISCRETE_CEIL
+#define SIMPLE_UI_CEIL RAMP_DISCRETE_CEIL
#define SIMPLE_UI_STEPS RAMP_DISCRETE_STEPS
#define USE_SOS_MODE
@@ -68,14 +59,6 @@
#undef USE_THERMAL_REGULATION
#endif
-// also, the set_level_gradually() thing isn't compatible with tint ramping
-// (but unsetting it here doesn't actually do anything, because the thermal
-// regulation define enables it later... so this is mostly just a note to
-// make this compatibility issue explicit)
-#ifdef USE_SET_LEVEL_GRADUALLY
-#undef USE_SET_LEVEL_GRADUALLY
-#endif
-
// don't blink while ramping
#ifdef BLINK_AT_RAMP_MIDDLE
#undef BLINK_AT_RAMP_MIDDLE
diff --git a/spaghetti-monster/fsm-main.c b/spaghetti-monster/fsm-main.c
index f3c319c..7031009 100644
--- a/spaghetti-monster/fsm-main.c
+++ b/spaghetti-monster/fsm-main.c
@@ -47,7 +47,9 @@ static inline void hw_setup() {
TCCR0B = 0x01; // pre-scaler for timer (1 => 1, 2 => 8, 3 => 64...)
TCCR0A = PHASE;
#endif
- #if PWM_CHANNELS >= 2
+ // tint ramping needs second channel enabled,
+ // despite PWM_CHANNELS being only 1
+ #if (PWM_CHANNELS >= 2) || defined(USE_TINT_RAMPING)
DDRB |= (1 << PWM2_PIN);
#endif
#if PWM_CHANNELS >= 3
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.