aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSelene ToyKeeper2023-05-02 23:44:22 -0600
committerSelene ToyKeeper2023-05-02 23:44:22 -0600
commit00dbf2b76cdbad2dbf2fd3b960bcb09d77f932d1 (patch)
tree0988a942a7dbec3eaad6724f2f4a2ca6c4ada5c8
parentadded Wurkkos FC13 and TS11 (diff)
downloadanduril-00dbf2b76cdbad2dbf2fd3b960bcb09d77f932d1.tar.gz
anduril-00dbf2b76cdbad2dbf2fd3b960bcb09d77f932d1.tar.bz2
anduril-00dbf2b76cdbad2dbf2fd3b960bcb09d77f932d1.zip
post-off voltage display: use low brightness when torch was at moon level before,
and skip the voltage display after UI actions which didn't change the mode (like "Off -> 7C" to change aux LED settings)
-rw-r--r--spaghetti-monster/anduril/aux-leds.c9
-rw-r--r--spaghetti-monster/anduril/battcheck-mode-fsm.h4
-rw-r--r--spaghetti-monster/anduril/lockout-mode.c20
-rw-r--r--spaghetti-monster/anduril/off-mode.c3
-rw-r--r--spaghetti-monster/anduril/off-mode.h3
-rw-r--r--spaghetti-monster/fsm-ramping.c1
-rw-r--r--spaghetti-monster/fsm-ramping.h2
7 files changed, 30 insertions, 12 deletions
diff --git a/spaghetti-monster/anduril/aux-leds.c b/spaghetti-monster/anduril/aux-leds.c
index d833d82..3ecbefd 100644
--- a/spaghetti-monster/anduril/aux-leds.c
+++ b/spaghetti-monster/anduril/aux-leds.c
@@ -106,8 +106,13 @@ void rgb_led_update(uint8_t mode, uint16_t arg) {
#ifdef USE_POST_OFF_VOLTAGE
// use voltage high mode for a few seconds after initial poweroff
- else if (arg < (cfg.post_off_voltage * SLEEP_TICKS_PER_SECOND)) {
- pattern = 2;
+ // (but not after changing aux LED settings and other similar actions)
+ else if ((arg < (cfg.post_off_voltage * SLEEP_TICKS_PER_SECOND))
+ && (ticks_since_on < (cfg.post_off_voltage * SLEEP_TICKS_PER_SECOND))
+ ) {
+ // use high mode unless prev_level was really low
+ pattern = 1 + (prev_level >= POST_OFF_VOLTAGE_BRIGHTNESS);
+ // voltage mode
color = RGB_LED_NUM_COLORS - 1;
}
#endif
diff --git a/spaghetti-monster/anduril/battcheck-mode-fsm.h b/spaghetti-monster/anduril/battcheck-mode-fsm.h
index 35c657a..5f8e8ec 100644
--- a/spaghetti-monster/anduril/battcheck-mode-fsm.h
+++ b/spaghetti-monster/anduril/battcheck-mode-fsm.h
@@ -11,4 +11,8 @@
#ifndef DEFAULT_POST_OFF_VOLTAGE_SECONDS
#define DEFAULT_POST_OFF_VOLTAGE_SECONDS 4
#endif
+ #ifndef POST_OFF_VOLTAGE_BRIGHTNESS
+ // level at which to switch from low to high aux brightness
+ #define POST_OFF_VOLTAGE_BRIGHTNESS (RAMP_SIZE/10)
+ #endif
#endif
diff --git a/spaghetti-monster/anduril/lockout-mode.c b/spaghetti-monster/anduril/lockout-mode.c
index c755a61..ee78a19 100644
--- a/spaghetti-monster/anduril/lockout-mode.c
+++ b/spaghetti-monster/anduril/lockout-mode.c
@@ -39,18 +39,17 @@ uint8_t lockout_state(Event event, uint16_t arg) {
// (allow staying awake long enough to exit, but otherwise
// be persistent about going back to sleep every few seconds
// even if the user keeps pressing the button)
- #ifdef USE_INDICATOR_LED
- // redundant, sleep tick does the same thing
- //if (event == EV_enter_state) {
- // indicator_led_update(cfg.indicator_led_mode >> 2, 0);
- //} else
- #elif defined(USE_AUX_RGB_LEDS)
if (event == EV_enter_state) {
- rgb_led_update(cfg.rgb_led_lockout_mode, 0);
- } else
- #endif
+ ticks_since_on = 0;
+ #ifdef USE_INDICATOR_LED
+ // redundant, sleep tick does the same thing
+ // indicator_led_update(cfg.indicator_led_mode >> 2, 0);
+ #elif defined(USE_AUX_RGB_LEDS)
+ rgb_led_update(cfg.rgb_led_lockout_mode, 0);
+ #endif
+ }
- if (event == EV_tick) {
+ else if (event == EV_tick) {
if (arg > HOLD_TIMEOUT) {
go_to_standby = 1;
#ifdef USE_INDICATOR_LED
@@ -65,6 +64,7 @@ uint8_t lockout_state(Event event, uint16_t arg) {
#if defined(TICK_DURING_STANDBY) && (defined(USE_INDICATOR_LED) || defined(USE_AUX_RGB_LEDS))
else if (event == EV_sleep_tick) {
+ if (ticks_since_on < 255) ticks_since_on ++;
#ifdef USE_MANUAL_MEMORY_TIMER
// reset to manual memory level when timer expires
if (cfg.manual_memory &&
diff --git a/spaghetti-monster/anduril/off-mode.c b/spaghetti-monster/anduril/off-mode.c
index 103e29d..c1ae2e4 100644
--- a/spaghetti-monster/anduril/off-mode.c
+++ b/spaghetti-monster/anduril/off-mode.c
@@ -15,6 +15,7 @@ uint8_t off_state(Event event, uint16_t arg) {
// turn emitter off when entering state
if (event == EV_enter_state) {
set_level(0);
+ ticks_since_on = 0;
#ifdef USE_INDICATOR_LED
// redundant, sleep tick does the same thing
//indicator_led_update(cfg.indicator_led_mode & 0x03, 0);
@@ -47,6 +48,7 @@ uint8_t off_state(Event event, uint16_t arg) {
#if defined(TICK_DURING_STANDBY)
// blink the indicator LED, maybe
else if (event == EV_sleep_tick) {
+ if (ticks_since_on < 255) ticks_since_on ++;
#ifdef USE_MANUAL_MEMORY_TIMER
// reset to manual memory level when timer expires
if (cfg.manual_memory &&
@@ -141,6 +143,7 @@ uint8_t off_state(Event event, uint16_t arg) {
// click, hold: momentary at ceiling or turbo
else if (event == EV_click2_hold) {
+ ticks_since_on = 0; // momentary turbo is definitely "on"
uint8_t turbo_level; // how bright is "turbo"?
#if defined(USE_2C_STYLE_CONFIG) // user can choose 2C behavior
diff --git a/spaghetti-monster/anduril/off-mode.h b/spaghetti-monster/anduril/off-mode.h
index 71d45eb..d07fff1 100644
--- a/spaghetti-monster/anduril/off-mode.h
+++ b/spaghetti-monster/anduril/off-mode.h
@@ -4,6 +4,9 @@
#pragma once
+// was the light in an "on" mode within the past second or so?
+uint8_t ticks_since_on = 0;
+
// when the light is "off" or in standby
uint8_t off_state(Event event, uint16_t arg);
diff --git a/spaghetti-monster/fsm-ramping.c b/spaghetti-monster/fsm-ramping.c
index 393c425..d4e2068 100644
--- a/spaghetti-monster/fsm-ramping.c
+++ b/spaghetti-monster/fsm-ramping.c
@@ -71,6 +71,7 @@ void set_level(uint8_t level) {
SetLevelFuncPtr set_level_func = channel_modes[CH_MODE];
set_level_func(level);
+ if (actual_level != level) prev_level = actual_level;
actual_level = level;
#ifdef USE_SET_LEVEL_GRADUALLY
diff --git a/spaghetti-monster/fsm-ramping.h b/spaghetti-monster/fsm-ramping.h
index 3003ecb..8d5ed27 100644
--- a/spaghetti-monster/fsm-ramping.h
+++ b/spaghetti-monster/fsm-ramping.h
@@ -8,6 +8,8 @@
// actual_level: last ramp level set by set_level()
uint8_t actual_level = 0;
+// the level used before actual
+uint8_t prev_level = 0;
// TODO: size-optimize the case with only 1 channel mode
// (the arrays and stuff shouldn't be needed)
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.