aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster
diff options
context:
space:
mode:
authorSelene ToyKeeper2020-03-05 17:51:27 -0700
committerSelene ToyKeeper2020-03-05 17:51:27 -0700
commit4d1c7a34fd00a4dd19e591ea0602f0f47f10d9f0 (patch)
tree8a22c1983165f5edf9fe72733690680712a792c2 /spaghetti-monster
parentmerged from fsm, mostly to get thermal regulation updates (diff)
downloadanduril-4d1c7a34fd00a4dd19e591ea0602f0f47f10d9f0.tar.gz
anduril-4d1c7a34fd00a4dd19e591ea0602f0f47f10d9f0.tar.bz2
anduril-4d1c7a34fd00a4dd19e591ea0602f0f47f10d9f0.zip
initial support for Noctigon KR4
(not complete, but far enough that it installs and runs) New hardware support features: - allow using PCINT other than 0 (PCINT1, PCINT2, etc) - option to ignore voltage ADC while the button is pressed (because my prototype shorts the voltage divider to 0 while the button is down)
Diffstat (limited to 'spaghetti-monster')
-rw-r--r--spaghetti-monster/anduril/cfg-noctigon-kr4.h66
-rw-r--r--spaghetti-monster/fsm-adc.c6
-rw-r--r--spaghetti-monster/fsm-pcint.c4
3 files changed, 76 insertions, 0 deletions
diff --git a/spaghetti-monster/anduril/cfg-noctigon-kr4.h b/spaghetti-monster/anduril/cfg-noctigon-kr4.h
new file mode 100644
index 0000000..87be78e
--- /dev/null
+++ b/spaghetti-monster/anduril/cfg-noctigon-kr4.h
@@ -0,0 +1,66 @@
+// Noctigon KR4 config options for Anduril
+#include "hwdef-Noctigon_KR4.h"
+// ATTINY: 1634
+
+// this light has three aux LED channels: R, G, B
+#define USE_AUX_RGB_LEDS
+//#define USE_AUX_RGB_LEDS_WHILE_ON
+//#define USE_INDICATOR_LED_WHILE_RAMPING
+#define RGB_LED_OFF_DEFAULT 0x18 // low, voltage
+#define RGB_LED_LOCKOUT_DEFAULT 0x37 // blinking, rainbow
+
+// enable blinking aux LEDs
+#define TICK_DURING_STANDBY
+#define STANDBY_TICK_SPEED 3 // every 0.128 s
+
+
+// ../../bin/level_calc.py cube 1 150 7135 1 4 1300
+// (with max_pwm set to 1023)
+#define RAMP_LENGTH 150
+#define PWM1_LEVELS 1,1,2,2,3,3,4,4,5,6,6,7,8,9,10,11,12,13,14,15,16,17,18,20,21,23,24,26,27,29,31,32,34,36,38,40,43,45,47,49,52,54,57,60,62,65,68,71,74,77,81,84,87,91,95,98,102,106,110,114,118,122,127,131,136,141,145,150,155,160,166,171,176,182,188,193,199,205,211,218,224,231,237,244,251,258,265,272,280,287,295,303,310,319,327,335,344,352,361,370,379,388,397,407,416,426,436,446,457,467,477,488,499,510,521,533,544,556,568,580,592,604,617,629,642,655,668,682,695,709,723,737,751,766,781,795,810,826,841,857,872,888,904,921,937,954,971,988,1005,1023
+#define MAX_1x7135 50
+
+// the entire ramp is regulated; don't blink halfway up
+#ifdef BLINK_AT_RAMP_MIDDLE
+#undef BLINK_AT_RAMP_MIDDLE
+#endif
+
+// don't slow down at low levels; this isn't that sort of light
+// (it needs to stay at full speed for the 10-bit PWM to work)
+#ifdef USE_DYNAMIC_UNDERCLOCKING
+#undef USE_DYNAMIC_UNDERCLOCKING
+#endif
+
+#define RAMP_SMOOTH_FLOOR 1
+#define RAMP_SMOOTH_CEIL 130
+// 10, 30, [50], 70, 90, 110, 130
+#define RAMP_DISCRETE_FLOOR 10
+#define RAMP_DISCRETE_CEIL RAMP_SMOOTH_CEIL
+#define RAMP_DISCRETE_STEPS 7
+
+#define MUGGLE_FLOOR RAMP_DISCRETE_FLOOR
+#define MUGGLE_CEILING 70
+
+// optional, makes initial turbo step-down faster so first peak isn't as hot
+// the KR4 runs very very hot on turbo, so be extra careful
+//#define THERM_HARD_TURBO_DROP
+
+// stop panicking at ~70% power or ~600 lm
+#define THERM_FASTER_LEVEL 130
+// respond to thermal changes faster
+#define THERMAL_WARNING_SECONDS 3
+#define THERMAL_UPDATE_SPEED 1
+#define THERM_PREDICTION_STRENGTH 4
+
+// easier access to thermal config mode, for Noctigon
+#define USE_TENCLICK_THERMAL_CONFIG
+
+// slow down party strobe; this driver can't pulse for 1ms or less
+#define PARTY_STROBE_ONTIME 2
+
+#define THERM_CAL_OFFSET 5
+
+// attiny1634 has enough space to smooth out voltage readings
+// (prevent the button from blinking during use)
+//#define USE_VOLTAGE_LOWPASS
+
diff --git a/spaghetti-monster/fsm-adc.c b/spaghetti-monster/fsm-adc.c
index 2a3c5c6..2d8d01f 100644
--- a/spaghetti-monster/fsm-adc.c
+++ b/spaghetti-monster/fsm-adc.c
@@ -206,6 +206,12 @@ static inline void ADC_voltage_handler() {
#define LVP_TIMER_START (VOLTAGE_WARNING_SECONDS*ADC_CYCLES_PER_SECOND) // N seconds between LVP warnings
#define LVP_LOWPASS_STRENGTH ADC_CYCLES_PER_SECOND // lowpass for one second
+ #ifdef NO_LVP_WHILE_BUTTON_PRESSED
+ // don't run if button is currently being held
+ // (because the button causes a reading of zero volts)
+ if (button_last_state) return;
+ #endif
+
uint16_t measurement = adc_values[0]; // latest 10-bit ADC reading
#ifdef USE_VOLTAGE_LOWPASS
diff --git a/spaghetti-monster/fsm-pcint.c b/spaghetti-monster/fsm-pcint.c
index 1ba1c15..d362633 100644
--- a/spaghetti-monster/fsm-pcint.c
+++ b/spaghetti-monster/fsm-pcint.c
@@ -66,7 +66,11 @@ inline void PCINT_off() {
//void button_change_interrupt() {
#if (ATTINY == 25) || (ATTINY == 45) || (ATTINY == 85) || (ATTINY == 1634)
//EMPTY_INTERRUPT(PCINT0_vect);
+#ifdef PCINT_vect
+ISR(PCINT_vect) {
+#else
ISR(PCINT0_vect) {
+#endif
irq_pcint = 1;
}
#else
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.