aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster
diff options
context:
space:
mode:
authorSelene ToyKeeper2020-06-01 21:02:33 -0600
committerSelene ToyKeeper2020-06-01 21:02:33 -0600
commit784d8927b85d2dcedcbbb6738dc2a1bb3fec0210 (patch)
tree432756e4b5bf26bac78c7809128d52e0d531262c /spaghetti-monster
parentK1-SBT90.2 doesn't need party strobe slowed down (diff)
parent"SOS" is treated as one "letter" in Morse code... it's not three letters (diff)
downloadanduril-784d8927b85d2dcedcbbb6738dc2a1bb3fec0210.tar.gz
anduril-784d8927b85d2dcedcbbb6738dc2a1bb3fec0210.tar.bz2
anduril-784d8927b85d2dcedcbbb6738dc2a1bb3fec0210.zip
merged from fsm to get latest updates
Diffstat (limited to 'spaghetti-monster')
-rw-r--r--spaghetti-monster/anduril/anduril.c25
-rw-r--r--spaghetti-monster/anduril/cfg-emisar-d1.h5
-rw-r--r--spaghetti-monster/anduril/cfg-emisar-d1s.h5
-rw-r--r--spaghetti-monster/anduril/cfg-emisar-d1v2.h17
-rw-r--r--spaghetti-monster/anduril/cfg-emisar-d4.h4
-rw-r--r--spaghetti-monster/anduril/cfg-emisar-d4s.h5
-rw-r--r--spaghetti-monster/anduril/cfg-emisar-d4v2-nofet.h34
-rw-r--r--spaghetti-monster/fsm-eeprom.c20
-rw-r--r--spaghetti-monster/fsm-events.c8
-rw-r--r--spaghetti-monster/fsm-events.h2
-rw-r--r--spaghetti-monster/momentary/momentary.c1
-rw-r--r--spaghetti-monster/werner/Makefile7
-rwxr-xr-xspaghetti-monster/werner/build-all.sh6
-rw-r--r--spaghetti-monster/werner/werner.c7
14 files changed, 106 insertions, 40 deletions
diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c
index e87a30c..01904dc 100644
--- a/spaghetti-monster/anduril/anduril.c
+++ b/spaghetti-monster/anduril/anduril.c
@@ -493,7 +493,7 @@ volatile strobe_mode_te strobe_type = 0;
#if defined(USE_PARTY_STROBE_MODE) || defined(USE_TACTICAL_STROBE_MODE)
// party / tactical strobe timing
-volatile uint8_t strobe_delays[] = { 40, 67 }; // party strobe, tactical strobe
+volatile uint8_t strobe_delays[] = { 41, 67 }; // party strobe 24 Hz, tactical strobe 10 Hz
#endif
// bike mode config options
@@ -1572,7 +1572,8 @@ void sos_blink(uint8_t num, uint8_t dah) {
nice_delay_ms(DIT_LENGTH);
}
// three "off" dits (or one "dah") between letters
- nice_delay_ms(DIT_LENGTH*2);
+ // (except for SOS, which is collectively treated as a single "letter")
+ //nice_delay_ms(DIT_LENGTH*2);
}
inline void sos_mode_iter() {
@@ -1593,11 +1594,25 @@ uint8_t battcheck_state(Event event, uint16_t arg) {
set_state(off_state, 0);
return MISCHIEF_MANAGED;
}
+ #ifdef USE_GOODNIGHT_MODE
// 2 clicks: goodnight mode
else if (event == EV_2clicks) {
set_state(goodnight_state, 0);
return MISCHIEF_MANAGED;
}
+ #elif defined(USE_BEACON_MODE)
+ // 2 clicks: beacon mode
+ else if (event == EV_2clicks) {
+ set_state(beacon_state, 0);
+ return MISCHIEF_MANAGED;
+ }
+ #elif defined(USE_THERMAL_REGULATION)
+ // 2 clicks: tempcheck mode
+ else if (event == EV_2clicks) {
+ set_state(tempcheck_state, 0);
+ return MISCHIEF_MANAGED;
+ }
+ #endif
return EVENT_NOT_HANDLED;
}
#endif
@@ -1840,9 +1855,11 @@ uint8_t momentary_state(Event event, uint16_t arg) {
// TODO: momentary strobe here? (for light painting)
// init strobe mode, if relevant
+ #ifdef USE_STROBE_STATE
if ((event == EV_enter_state) && (momentary_mode == 1)) {
strobe_state(event, arg);
}
+ #endif
// light up when the button is pressed; go dark otherwise
// button is being held
@@ -1868,6 +1885,7 @@ uint8_t momentary_state(Event event, uint16_t arg) {
// disconnected for several seconds, so we want to be awake when that
// happens to speed up the process)
else if (event == EV_tick) {
+ #ifdef USE_STROBE_STATE
if (momentary_active) {
// 0 = ramping, 1 = strobes
if (momentary_mode == 1) {
@@ -1875,6 +1893,7 @@ uint8_t momentary_state(Event event, uint16_t arg) {
}
}
else {
+ #endif
if (arg > TICKS_PER_SECOND*5) { // sleep after 5 seconds
go_to_standby = 1; // sleep while light is off
// turn off lighted button
@@ -1884,7 +1903,9 @@ uint8_t momentary_state(Event event, uint16_t arg) {
rgb_led_update(0, 0);
#endif
}
+ #ifdef USE_STROBE_STATE
}
+ #endif
return MISCHIEF_MANAGED;
}
diff --git a/spaghetti-monster/anduril/cfg-emisar-d1.h b/spaghetti-monster/anduril/cfg-emisar-d1.h
index 35e91db..9276ba3 100644
--- a/spaghetti-monster/anduril/cfg-emisar-d1.h
+++ b/spaghetti-monster/anduril/cfg-emisar-d1.h
@@ -8,8 +8,3 @@
#undef THERM_FASTER_LEVEL
#endif
#define THERM_FASTER_LEVEL (RAMP_SIZE*9/10) // throttle back faster when high
-
-// no need to be extra-careful on this light
-#ifdef THERM_HARD_TURBO_DROP
-#undef THERM_HARD_TURBO_DROP
-#endif
diff --git a/spaghetti-monster/anduril/cfg-emisar-d1s.h b/spaghetti-monster/anduril/cfg-emisar-d1s.h
index 56200a2..c01c37d 100644
--- a/spaghetti-monster/anduril/cfg-emisar-d1s.h
+++ b/spaghetti-monster/anduril/cfg-emisar-d1s.h
@@ -8,8 +8,3 @@
#undef THERM_FASTER_LEVEL
#endif
#define THERM_FASTER_LEVEL 144 // throttle back faster when high
-
-// no need to be extra-careful on this light
-#ifdef THERM_HARD_TURBO_DROP
-#undef THERM_HARD_TURBO_DROP
-#endif
diff --git a/spaghetti-monster/anduril/cfg-emisar-d1v2.h b/spaghetti-monster/anduril/cfg-emisar-d1v2.h
new file mode 100644
index 0000000..91be3f3
--- /dev/null
+++ b/spaghetti-monster/anduril/cfg-emisar-d1v2.h
@@ -0,0 +1,17 @@
+// Emisar D1v2 config options for Anduril (D1 w/ D4v2 driver)
+// ATTINY: 1634
+// same as Emisar D4v2, mostly
+#include "cfg-emisar-d4v2.h"
+
+// there are no aux LEDs on a D1
+#undef USE_AUX_RGB_LEDS
+// ... and no button LED
+#undef USE_BUTTON_LED
+// no aux LEDs means no need for sleep ticks
+#undef TICK_DURING_STANDBY
+
+// stop panicking at ~75% power or ~1000 lm (D1 has a decent power-to-thermal-mass ratio)
+#ifdef THERM_FASTER_LEVEL
+#undef THERM_FASTER_LEVEL
+#endif
+#define THERM_FASTER_LEVEL (RAMP_SIZE*9/10) // throttle back faster when high
diff --git a/spaghetti-monster/anduril/cfg-emisar-d4.h b/spaghetti-monster/anduril/cfg-emisar-d4.h
index 501b9c7..7700d88 100644
--- a/spaghetti-monster/anduril/cfg-emisar-d4.h
+++ b/spaghetti-monster/anduril/cfg-emisar-d4.h
@@ -18,10 +18,6 @@
#define RAMP_DISCRETE_CEIL RAMP_SMOOTH_CEIL
#define RAMP_DISCRETE_STEPS 7
-// optional, makes initial turbo step-down faster so first peak isn't as hot
-// the D4 runs very very hot, so be extra careful
-//#define THERM_HARD_TURBO_DROP
-
// stop panicking at ~30% power or ~1200 lm
#define THERM_FASTER_LEVEL 105
diff --git a/spaghetti-monster/anduril/cfg-emisar-d4s.h b/spaghetti-monster/anduril/cfg-emisar-d4s.h
index 88465da..f5addb2 100644
--- a/spaghetti-monster/anduril/cfg-emisar-d4s.h
+++ b/spaghetti-monster/anduril/cfg-emisar-d4s.h
@@ -37,8 +37,3 @@
#endif
#define MIN_THERM_STEPDOWN 60 // lowest value it'll step down to
#define THERM_FASTER_LEVEL (RAMP_SIZE-20) // don't throttle back faster when high
-
-// no need to be extra-careful on this light
-#ifdef THERM_HARD_TURBO_DROP
-#undef THERM_HARD_TURBO_DROP
-#endif
diff --git a/spaghetti-monster/anduril/cfg-emisar-d4v2-nofet.h b/spaghetti-monster/anduril/cfg-emisar-d4v2-nofet.h
new file mode 100644
index 0000000..cbb5891
--- /dev/null
+++ b/spaghetti-monster/anduril/cfg-emisar-d4v2-nofet.h
@@ -0,0 +1,34 @@
+// Emisar D4v2-noFET config options for Anduril
+#include "cfg-emisar-d4v2.h"
+// ATTINY: 1634
+
+#undef PWM_CHANNELS
+#define PWM_CHANNELS 1
+#undef PWM1_LEVELS
+#undef PWM2_LEVELS
+#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
+#undef MAX_1x7135
+#define MAX_1x7135 150
+#undef QUARTERSPEED_LEVEL
+#undef HALFSPEED_LEVEL
+#define QUARTERSPEED_LEVEL 8
+#define HALFSPEED_LEVEL 16
+
+#define DEFAULT_LEVEL 80
+
+#undef RAMP_SMOOTH_CEIL
+#define RAMP_SMOOTH_CEIL 150
+// 10, 45, 80, 115, 150
+#undef RAMP_DISCRETE_FLOOR
+#undef RAMP_DISCRETE_CEIL
+#undef RAMP_DISCRETE_STEPS
+#define RAMP_DISCRETE_FLOOR 10
+#define RAMP_DISCRETE_CEIL 150
+#define RAMP_DISCRETE_STEPS 5
+
+#define CANDLE_AMPLITUDE 60
+
+#undef THERM_FASTER_LEVEL
+#define THERM_FASTER_LEVEL 150
+
+#undef USE_THERMAL_REGULATION
diff --git a/spaghetti-monster/fsm-eeprom.c b/spaghetti-monster/fsm-eeprom.c
index 77352cf..0de7e05 100644
--- a/spaghetti-monster/fsm-eeprom.c
+++ b/spaghetti-monster/fsm-eeprom.c
@@ -67,7 +67,7 @@ void save_eeprom() {
#ifdef USE_EEPROM_WL
uint8_t eeprom_wl[EEPROM_WL_BYTES];
-EEP_OFFSET_T eep_wl_prev_offset;
+uint8_t * eep_wl_prev_offset;
uint8_t load_eeprom_wl() {
#ifdef LED_ENABLE_PIN
@@ -77,11 +77,11 @@ uint8_t load_eeprom_wl() {
cli();
// check if eeprom has been initialized; abort if it hasn't
uint8_t found = 0;
- EEP_OFFSET_T offset;
+ uint8_t * offset;
for(offset = 0;
- offset < EEP_WL_SIZE - EEPROM_WL_BYTES - 1;
+ offset < (uint8_t *)(EEP_WL_SIZE - EEPROM_WL_BYTES - 1);
offset += (EEPROM_WL_BYTES + 1)) {
- if (eeprom_read_byte((uint8_t *)offset) == EEP_MARKER) {
+ if (eeprom_read_byte(offset) == EEP_MARKER) {
found = 1;
eep_wl_prev_offset = offset;
break;
@@ -91,7 +91,7 @@ uint8_t load_eeprom_wl() {
if (found) {
// load the actual data
for(uint8_t i=0; i<EEPROM_WL_BYTES; i++) {
- eeprom_wl[i] = eeprom_read_byte((uint8_t *)(offset+1+i));
+ eeprom_wl[i] = eeprom_read_byte(offset+1+i);
}
}
sei();
@@ -105,22 +105,22 @@ void save_eeprom_wl() {
cli();
// erase old state
- EEP_OFFSET_T offset = eep_wl_prev_offset;
+ uint8_t * offset = eep_wl_prev_offset;
for (uint8_t i = 0; i < EEPROM_WL_BYTES+1; i ++) {
- eeprom_update_byte((uint8_t *)offset+i, 0xFF);
+ eeprom_update_byte(offset+i, 0xFF);
}
// save new state
offset += EEPROM_WL_BYTES+1;
- if (offset > EEP_WL_SIZE-EEPROM_WL_BYTES-1) offset = 0;
+ if (offset > (uint8_t *)(EEP_WL_SIZE-EEPROM_WL_BYTES-1)) offset = 0;
eep_wl_prev_offset = offset;
// marker byte
// FIXME: write the marker last, to signal completed transaction
- eeprom_update_byte((uint8_t *)offset, EEP_MARKER);
+ eeprom_update_byte(offset, EEP_MARKER);
offset ++;
// user data
for(uint8_t i=0; i<EEPROM_WL_BYTES; i++, offset++) {
- eeprom_update_byte((uint8_t *)(offset), eeprom_wl[i]);
+ eeprom_update_byte(offset, eeprom_wl[i]);
}
sei();
}
diff --git a/spaghetti-monster/fsm-events.c b/spaghetti-monster/fsm-events.c
index a1b013a..ad869a6 100644
--- a/spaghetti-monster/fsm-events.c
+++ b/spaghetti-monster/fsm-events.c
@@ -120,7 +120,7 @@ uint8_t nice_delay_ms(uint16_t ms) {
uint8_t level = actual_level; // volatile, avoid repeat access
if (level < QUARTERSPEED_LEVEL) {
clock_prescale_set(clock_div_4);
- _delay_loop_2(BOGOMIPS*95/100/4);
+ _delay_loop_2(BOGOMIPS*90/100/4);
}
//else if (level < HALFSPEED_LEVEL) {
// clock_prescale_set(clock_div_2);
@@ -128,7 +128,7 @@ uint8_t nice_delay_ms(uint16_t ms) {
//}
else {
clock_prescale_set(clock_div_1);
- _delay_loop_2(BOGOMIPS*95/100);
+ _delay_loop_2(BOGOMIPS*90/100);
}
// restore regular clock speed
clock_prescale_set(clock_div_1);
@@ -136,13 +136,13 @@ uint8_t nice_delay_ms(uint16_t ms) {
// underclock MCU to save power
clock_prescale_set(clock_div_4);
// wait
- _delay_loop_2(BOGOMIPS*95/100/4);
+ _delay_loop_2(BOGOMIPS*90/100/4);
// restore regular clock speed
clock_prescale_set(clock_div_1);
#endif // ifdef USE_RAMPING
#else
// wait
- _delay_loop_2(BOGOMIPS*95/100);
+ _delay_loop_2(BOGOMIPS*90/100);
#endif // ifdef USE_DYNAMIC_UNDERCLOCKING
// run pending system processes while we wait
diff --git a/spaghetti-monster/fsm-events.h b/spaghetti-monster/fsm-events.h
index 6760fdd..a132d5a 100644
--- a/spaghetti-monster/fsm-events.h
+++ b/spaghetti-monster/fsm-events.h
@@ -218,8 +218,8 @@ void emit(Event event, uint16_t arg);
void emit_current_event(uint16_t arg);
uint8_t nice_delay_ms(uint16_t ms);
-//uint8_t nice_delay_4ms(uint8_t ms);
//uint8_t nice_delay_s();
inline void interrupt_nice_delays();
+void delay_4ms(uint8_t ms);
#endif
diff --git a/spaghetti-monster/momentary/momentary.c b/spaghetti-monster/momentary/momentary.c
index 26acd44..c7a8cf1 100644
--- a/spaghetti-monster/momentary/momentary.c
+++ b/spaghetti-monster/momentary/momentary.c
@@ -22,7 +22,6 @@
#include "hwdef-Emisar_D4.h"
#define USE_LVP
#define USE_DEBUG_BLINK
-#define USE_DELAY_4MS
#include "spaghetti-monster.h"
volatile uint8_t brightness;
diff --git a/spaghetti-monster/werner/Makefile b/spaghetti-monster/werner/Makefile
new file mode 100644
index 0000000..21d85f7
--- /dev/null
+++ b/spaghetti-monster/werner/Makefile
@@ -0,0 +1,7 @@
+all:
+ ./build-all.sh
+
+clean:
+ rm -f cfg-*.h *.hex *~ *.elf *.o
+
+.phony: clean
diff --git a/spaghetti-monster/werner/build-all.sh b/spaghetti-monster/werner/build-all.sh
index 87d4f0d..b114101 100755
--- a/spaghetti-monster/werner/build-all.sh
+++ b/spaghetti-monster/werner/build-all.sh
@@ -7,7 +7,9 @@ UI=werner
for TARGET in cfg-*.h ; do
NAME=$(echo "$TARGET" | perl -ne '/cfg-(.*).h/ && print "$1\n";')
echo "===== $NAME ====="
- echo ../../../bin/build.sh 85 "$UI" "-DCONFIGFILE=${TARGET}"
- ../../../bin/build.sh 85 "$UI" "-DCONFIGFILE=${TARGET}"
+ ATTINY=$(grep 'ATTINY:' $TARGET | awk '{ print $3 }')
+ if [ -z "$ATTINY" ]; then ATTINY=85 ; fi
+ echo ../../../bin/build.sh $ATTINY "$UI" "-DCONFIGFILE=${TARGET}"
+ ../../../bin/build.sh $ATTINY "$UI" "-DCONFIGFILE=${TARGET}"
mv -f "$UI".hex "$UI".$NAME.hex
done
diff --git a/spaghetti-monster/werner/werner.c b/spaghetti-monster/werner/werner.c
index 4159fc6..1c3d4ad 100644
--- a/spaghetti-monster/werner/werner.c
+++ b/spaghetti-monster/werner/werner.c
@@ -33,6 +33,10 @@
//#define BATTCHECK_8bars // FIXME: breaks build
//#define BATTCHECK_4bars // FIXME: breaks build
+// cut clock speed at very low modes for better efficiency
+// (defined here so config files can override it)
+#define USE_DYNAMIC_UNDERCLOCKING
+
/***** specific settings for known driver types *****/
#ifdef CONFIGFILE
#include "tk.h"
@@ -63,7 +67,6 @@
#define RAMP_LENGTH 150 // default, if not overridden in a driver cfg file
#define USE_BATTCHECK
#define USE_IDLE_MODE // reduce power use while awake and no tasks are pending
-#define USE_DYNAMIC_UNDERCLOCKING // cut clock speed at very low modes for better efficiency
// auto-detect how many eeprom bytes
#define USE_EEPROM
@@ -369,12 +372,14 @@ uint8_t battcheck_state(Event event, uint16_t arg) {
set_state(off_state, 0);
return MISCHIEF_MANAGED;
}
+ #ifdef USE_THERMAL_REGULATION
// 2 clicks: tempcheck mode
else if (event == EV_2clicks) {
blink_confirm(2);
set_state(tempcheck_state, 0);
return MISCHIEF_MANAGED;
}
+ #endif
return EVENT_NOT_HANDLED;
}
#endif