aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSelene ToyKeeper2019-09-24 00:32:53 -0600
committerSelene ToyKeeper2019-09-24 00:32:53 -0600
commite2b727acfce7bc19843cdcc7f327efc9c61230d8 (patch)
tree6f91c9cfd71b4efd6c9792b4565da09bf72bfe42
parentsped up blink_digit() a little bit, because it was annoyingly slow (diff)
downloadanduril-e2b727acfce7bc19843cdcc7f327efc9c61230d8.tar.gz
anduril-e2b727acfce7bc19843cdcc7f327efc9c61230d8.tar.bz2
anduril-e2b727acfce7bc19843cdcc7f327efc9c61230d8.zip
added a version check function on 15+ clicks from off, added a safety ramp-down if button is held too long at ceiling
(also removed muggle mode from a couple build targets because it doesn't fit, not enough ROM)
-rw-r--r--spaghetti-monster/anduril/anduril.c38
-rwxr-xr-xspaghetti-monster/anduril/build-all.sh2
-rw-r--r--spaghetti-monster/anduril/cfg-emisar-d18.h6
-rw-r--r--spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h6
4 files changed, 52 insertions, 0 deletions
diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c
index 8ab66f5..1505f59 100644
--- a/spaghetti-monster/anduril/anduril.c
+++ b/spaghetti-monster/anduril/anduril.c
@@ -35,6 +35,8 @@
// (currently incompatible with factory reset)
//#define START_AT_MEMORIZED_LEVEL
+// include a function to blink out the firmware version
+#define USE_VERSION_CHECK
// short blip when crossing from "click" to "hold" from off
// (helps the user hit moon mode exactly, instead of holding too long
@@ -483,6 +485,11 @@ uint8_t triangle_wave(uint8_t phase);
volatile uint8_t beacon_seconds = 2;
#endif
+#ifdef USE_VERSION_CHECK
+#include "version.h"
+const PROGMEM uint8_t version_number[] = VERSION_NUMBER;
+uint8_t version_check_state(Event event, uint16_t arg);
+#endif
uint8_t off_state(Event event, uint16_t arg) {
// turn emitter off when entering state
@@ -682,6 +689,13 @@ uint8_t off_state(Event event, uint16_t arg) {
return MISCHIEF_MANAGED;
}
#endif
+ #ifdef USE_VERSION_CHECK
+ // 15+ clicks: show the version number
+ else if (event == EV_15clicks) {
+ set_state(version_check_state, 0);
+ return MISCHIEF_MANAGED;
+ }
+ #endif
#if defined(USE_FACTORY_RESET) && defined(USE_SOFT_FACTORY_RESET)
// 13 clicks and hold the last click: invoke factory reset (reboot)
else if (event == EV_click13_hold) {
@@ -792,6 +806,10 @@ uint8_t steady_state(Event event, uint16_t arg) {
// (off->hold->stepped_min->release causes this state)
else if (actual_level <= mode_min) { ramp_direction = 1; }
}
+ // if the button is stuck, err on the side of safety and ramp down
+ else if ((arg > TICKS_PER_SECOND * 5) && (actual_level >= mode_max)) {
+ ramp_direction = -1;
+ }
memorized_level = nearest_level((int16_t)actual_level \
+ (ramp_step_size * ramp_direction));
#else
@@ -1956,6 +1974,13 @@ uint8_t muggle_state(Event event, uint16_t arg) {
#endif
+#ifdef USE_VERSION_CHECK
+uint8_t version_check_state(Event event, uint16_t arg) {
+ return EVENT_NOT_HANDLED;
+}
+#endif
+
+
// ask the user for a sequence of numbers, then save them and return to caller
uint8_t config_state_base(Event event, uint16_t arg,
uint8_t num_config_steps,
@@ -2558,6 +2583,19 @@ void loop() {
if (0) {}
+ #ifdef USE_VERSION_CHECK
+ else if (state == version_check_state) {
+ for (uint8_t i=0; i<sizeof(version_number)-1; i++) {
+ blink_digit(pgm_read_byte(version_number + i) - '0');
+ nice_delay_ms(300);
+ }
+ set_state(off_state, 0);
+ // FIXME: when user interrupts with button, "off" takes an extra click
+ // before it'll turn back on, because the click to cancel gets sent
+ // to the "off" state instead of version_check_state
+ }
+ #endif // #ifdef USE_VERSION_CHECK
+
#ifdef USE_STROBE_STATE
else if ((state == strobe_state)
|| ((state == momentary_state) && (momentary_mode == 1) && (momentary_active)) ) { // also handle momentary strobes
diff --git a/spaghetti-monster/anduril/build-all.sh b/spaghetti-monster/anduril/build-all.sh
index 56a88bf..42a36fd 100755
--- a/spaghetti-monster/anduril/build-all.sh
+++ b/spaghetti-monster/anduril/build-all.sh
@@ -2,6 +2,8 @@
UI=anduril
+date '+#define VERSION_NUMBER "%Y%m%d"' > version.h
+
for TARGET in cfg-*.h ; do
NAME=$(echo "$TARGET" | perl -ne '/cfg-(.*).h/ && print "$1\n";')
echo "===== $NAME ====="
diff --git a/spaghetti-monster/anduril/cfg-emisar-d18.h b/spaghetti-monster/anduril/cfg-emisar-d18.h
index 16fbacd..02e8f01 100644
--- a/spaghetti-monster/anduril/cfg-emisar-d18.h
+++ b/spaghetti-monster/anduril/cfg-emisar-d18.h
@@ -16,6 +16,12 @@
#define USE_TENCLICK_THERMAL_CONFIG
+// save space, and remove a mode which doesn't make much sense on this light
+#ifdef USE_MUGGLE_MODE
+#undef USE_MUGGLE_MODE
+#endif
+
+
// level_calc.py seventh 3 150 7135 1 1.4 117.99 7135 6 1 1706.86 FET 3 10 13000
// (designed to make 1x hit at level 50, and Nx hit at level 100)
#define RAMP_LENGTH 150
diff --git a/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h b/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h
index bbf751b..a1d366d 100644
--- a/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h
+++ b/spaghetti-monster/anduril/cfg-mateminco-mf01-mini.h
@@ -15,6 +15,12 @@
#define INDICATOR_LED_DEFAULT_MODE ((3<<2) + 1)
+// doesn't quite fit
+#ifdef USE_MUGGLE_MODE
+#undef USE_MUGGLE_MODE
+#endif
+
+
// don't blink during ramp, it's irrelevant and annoying on this light
#define BLINK_AT_RAMP_CEILING
#undef BLINK_AT_RAMP_MIDDLE