aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSelene ToyKeeper2017-09-09 14:38:55 -0600
committerSelene ToyKeeper2017-09-09 14:38:55 -0600
commit5aa64f52af0505ebe257eafba2e46d2e477f61af (patch)
tree227ca55f5e141e04befcb346f59c66c04d19d7b3
parentAdded momentary(ish) moon mode to lockout state. (diff)
downloadanduril-5aa64f52af0505ebe257eafba2e46d2e477f61af.tar.gz
anduril-5aa64f52af0505ebe257eafba2e46d2e477f61af.tar.bz2
anduril-5aa64f52af0505ebe257eafba2e46d2e477f61af.zip
Made "off" mode more vigilant about staying off.
-rw-r--r--spaghetti-monster/anduril/anduril.c17
-rw-r--r--spaghetti-monster/spaghetti-monster.h3
2 files changed, 16 insertions, 4 deletions
diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c
index dd06160..91c7b0b 100644
--- a/spaghetti-monster/anduril/anduril.c
+++ b/spaghetti-monster/anduril/anduril.c
@@ -63,6 +63,7 @@ uint8_t goodnight_state(EventPtr event, uint16_t arg);
uint8_t beacon_state(EventPtr event, uint16_t arg);
uint8_t beacon_config_state(EventPtr event, uint16_t arg);
// soft lockout
+#define MOON_DURING_LOCKOUT_MODE
uint8_t lockout_state(EventPtr event, uint16_t arg);
// momentary / signalling mode
uint8_t momentary_state(EventPtr event, uint16_t arg);
@@ -116,11 +117,22 @@ volatile uint8_t beacon_seconds = 2;
uint8_t off_state(EventPtr event, uint16_t arg) {
+ static uint8_t ticks_spent_awake = 0;
// turn emitter off when entering state
if (event == EV_enter_state) {
set_level(0);
// sleep while off (lower power use)
go_to_standby = 1;
+ ticks_spent_awake = 0;
+ return MISCHIEF_MANAGED;
+ }
+ // go back to sleep eventually if we got bumped but didn't leave "off" state
+ else if (event == EV_tick) {
+ ticks_spent_awake ++;
+ if (ticks_spent_awake > 240) {
+ ticks_spent_awake = 0;
+ go_to_standby = 1;
+ }
return MISCHIEF_MANAGED;
}
// hold (initially): go to lowest level, but allow abort for regular click
@@ -149,7 +161,7 @@ uint8_t off_state(EventPtr event, uint16_t arg) {
return MISCHIEF_MANAGED;
}
#ifdef USE_BATTCHECK
- // 3 clicks: battcheck mode
+ // 3 clicks: battcheck mode / blinky mode group 1
else if (event == EV_3clicks) {
set_state(battcheck_state, 0);
return MISCHIEF_MANAGED;
@@ -162,6 +174,7 @@ uint8_t off_state(EventPtr event, uint16_t arg) {
return MISCHIEF_MANAGED;
}
// 5 clicks: strobe mode
+ // TODO: remap this to click, click, long-click?
else if (event == EV_5clicks) {
set_state(strobe_state, 0);
return MISCHIEF_MANAGED;
@@ -487,6 +500,7 @@ uint8_t goodnight_state(EventPtr event, uint16_t arg) {
uint8_t lockout_state(EventPtr event, uint16_t arg) {
static uint8_t ticks_spent_awake = 0;
+ #ifdef MOON_DURING_LOCKOUT_MODE
// momentary(ish) moon mode during lockout
// not all presses will be counted;
// it depends on what is in the master event_sequences table
@@ -503,6 +517,7 @@ uint8_t lockout_state(EventPtr event, uint16_t arg) {
else if ((last == A_RELEASE) || (last == A_RELEASE_TIMEOUT)) {
set_level(0);
}
+ #endif
// regular event handling
// conserve power while locked out
diff --git a/spaghetti-monster/spaghetti-monster.h b/spaghetti-monster/spaghetti-monster.h
index 82800b4..5599bca 100644
--- a/spaghetti-monster/spaghetti-monster.h
+++ b/spaghetti-monster/spaghetti-monster.h
@@ -57,9 +57,6 @@ void debug_blink(uint8_t num) {
}
#endif
-// TODO? new delay() functions which handle queue consumption?
-// TODO? new interruptible delay() functions?
-
// Define these in your SpaghettiMonster recipe
// boot-time tasks
void setup();
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.