From e2b727acfce7bc19843cdcc7f327efc9c61230d8 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Tue, 24 Sep 2019 00:32:53 -0600 Subject: 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) --- spaghetti-monster/anduril/anduril.c | 38 ++++++++++++++++++++++ spaghetti-monster/anduril/build-all.sh | 2 ++ spaghetti-monster/anduril/cfg-emisar-d18.h | 6 ++++ .../anduril/cfg-mateminco-mf01-mini.h | 6 ++++ 4 files changed, 52 insertions(+) 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 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 -- cgit v1.2.3