aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSelene ToyKeeper2018-06-16 23:59:02 -0600
committerSelene ToyKeeper2018-06-16 23:59:02 -0600
commitb178a530fa654f6af52912d75b0f1e8eafe59035 (patch)
treedec9cefd6a6d621bc02301e606ed70cc45b0eca2
parentDocumented how to configure indicator LED level while off. (diff)
downloadanduril-b178a530fa654f6af52912d75b0f1e8eafe59035.tar.gz
anduril-b178a530fa654f6af52912d75b0f1e8eafe59035.tar.bz2
anduril-b178a530fa654f6af52912d75b0f1e8eafe59035.zip
Added dual-switch support (tail clicky + e-switch) to muggle mode.
-rw-r--r--spaghetti-monster/anduril/anduril.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c
index 26db6d8..4eba836 100644
--- a/spaghetti-monster/anduril/anduril.c
+++ b/spaghetti-monster/anduril/anduril.c
@@ -1040,13 +1040,25 @@ uint8_t muggle_state(EventPtr event, uint16_t arg) {
// turn LED off when we first enter the mode
if (event == EV_enter_state) {
- muggle_mode_active = 1;
- save_config();
-
- muggle_off_mode = 1;
ramp_direction = 1;
- //memorized_level = MAX_1x7135;
- memorized_level = (MUGGLE_FLOOR + MUGGLE_CEILING) / 2;
+
+ #ifdef START_AT_MEMORIZED_LEVEL
+ memorized_level = arg;
+ muggle_off_mode = 0;
+ set_level(memorized_level);
+
+ if (! muggle_mode_active) { // don't write eeprom at every boot
+ muggle_mode_active = 1;
+ save_config();
+ }
+ #else
+ muggle_mode_active = 1;
+ save_config();
+
+ muggle_off_mode = 1;
+ //memorized_level = MAX_1x7135;
+ memorized_level = (MUGGLE_FLOOR + MUGGLE_CEILING) / 2;
+ #endif
return MISCHIEF_MANAGED;
}
// initial press: moon hint
@@ -1107,6 +1119,9 @@ uint8_t muggle_state(EventPtr event, uint16_t arg) {
// reverse ramp direction on hold release
else if (event == EV_click1_hold_release) {
ramp_direction = -ramp_direction;
+ #ifdef START_AT_MEMORIZED_LEVEL
+ save_config_wl(); // momentary use should retain brightness level
+ #endif
return MISCHIEF_MANAGED;
}
/*
@@ -1513,6 +1528,12 @@ void setup() {
// dual switch: e-switch + power clicky
// power clicky acts as a momentary mode
load_config();
+
+ #ifdef USE_MUGGLE_MODE
+ if (muggle_mode_active)
+ push_state(muggle_state, memorized_level);
+ else
+ #endif
if (button_is_pressed())
// hold button to go to moon
push_state(steady_state, 1);
@@ -1520,7 +1541,7 @@ void setup() {
// otherwise use memory
push_state(steady_state, memorized_level);
- #else
+ #else // if not START_AT_MEMORIZED_LEVEL
// blink at power-on to let user know power is connected
set_level(RAMP_SIZE/8);
@@ -1531,7 +1552,7 @@ void setup() {
#ifdef USE_MUGGLE_MODE
if (muggle_mode_active)
- push_state(muggle_state, 0);
+ push_state(muggle_state, (MUGGLE_FLOOR+MUGGLE_CEILING)/2);
else
#endif
push_state(off_state, 0);
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.