From d1259b707920506f0c73d2ed4991915c54963944 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Thu, 30 Jul 2020 18:31:50 -0600 Subject: made ramping "bump" the sunset timer up a little if it's near the deadline --- spaghetti-monster/anduril/sunset-timer.c | 8 ++++++++ spaghetti-monster/anduril/sunset-timer.h | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'spaghetti-monster') diff --git a/spaghetti-monster/anduril/sunset-timer.c b/spaghetti-monster/anduril/sunset-timer.c index 4c91723..7340ff1 100644 --- a/spaghetti-monster/anduril/sunset-timer.c +++ b/spaghetti-monster/anduril/sunset-timer.c @@ -30,6 +30,14 @@ uint8_t sunset_timer_state(Event event, uint16_t arg) { sunset_ticks = 0; return MISCHIEF_MANAGED; } + // hold: maybe "bump" the timer if it's active and almost expired + else if (event == EV_hold) { + // ramping up should "bump" the timer to extend the deadline a bit + if ((sunset_timer > 0) && (sunset_timer < 4)) { + sunset_timer = 3; + sunset_timer_peak = 3; + } + } // 4H: add 10m to timer, per second, until released else if (event == EV_click4_hold) { if (0 == (arg % TICKS_PER_SECOND)) { diff --git a/spaghetti-monster/anduril/sunset-timer.h b/spaghetti-monster/anduril/sunset-timer.h index 2e39e5d..d197f0e 100644 --- a/spaghetti-monster/anduril/sunset-timer.h +++ b/spaghetti-monster/anduril/sunset-timer.h @@ -26,9 +26,9 @@ #define TICKS_PER_MINUTE (TICKS_PER_SECOND*60) // automatic shutoff timer -uint8_t sunset_timer = 0; -uint8_t sunset_timer_peak = 0; -uint16_t sunset_ticks = 0; +uint8_t sunset_timer = 0; // minutes remaining in countdown +uint8_t sunset_timer_peak = 0; // total minutes in countdown +uint16_t sunset_ticks = 0; // counts from 0 to TICKS_PER_MINUTE, then repeats uint8_t sunset_timer_state(Event event, uint16_t arg); -- cgit v1.2.3