aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster
diff options
context:
space:
mode:
authorSelene ToyKeeper2017-08-26 03:47:44 -0600
committerSelene ToyKeeper2017-08-26 03:47:44 -0600
commit4b8fef64d036336e329b8b7871a42440cdc38766 (patch)
tree731da82dabf06a4835e0ffe8184494f27cee2d7d /spaghetti-monster
parentForgot to handle beacon/strobe in LVP earlier. (diff)
downloadanduril-4b8fef64d036336e329b8b7871a42440cdc38766.tar.gz
anduril-4b8fef64d036336e329b8b7871a42440cdc38766.tar.bz2
anduril-4b8fef64d036336e329b8b7871a42440cdc38766.zip
Made DarkHorse always start at low when holding the button, like a real ZebraLight does.
(previously ramped up one mode instead of resetting to low each time)
Diffstat (limited to 'spaghetti-monster')
-rw-r--r--spaghetti-monster/darkhorse.c43
1 files changed, 19 insertions, 24 deletions
diff --git a/spaghetti-monster/darkhorse.c b/spaghetti-monster/darkhorse.c
index 03cd5e7..1244864 100644
--- a/spaghetti-monster/darkhorse.c
+++ b/spaghetti-monster/darkhorse.c
@@ -168,6 +168,22 @@ uint8_t any_mode_state(EventPtr event, uint16_t arg, uint8_t *primary, uint8_t *
set_state(off_state, 0);
return MISCHIEF_MANAGED;
}
+ // hold: change brightness (low, med, hi, always starting at low)
+ else if (event == EV_click1_hold) {
+ uint8_t which = arg % (HOLD_TIMEOUT * 3) / HOLD_TIMEOUT;
+ switch(which) {
+ case 0:
+ set_state(low_mode_state, 0);
+ break;
+ case 1:
+ set_state(med_mode_state, 0);
+ break;
+ case 2:
+ set_state(hi_mode_state, 0);
+ break;
+ }
+ return MISCHIEF_MANAGED;
+ }
// 2 clicks: toggle primary/secondary level
else if (event == EV_2clicks) {
*primary ^= 1;
@@ -210,36 +226,15 @@ uint8_t any_mode_state(EventPtr event, uint16_t arg, uint8_t *primary, uint8_t *
}
uint8_t low_mode_state(EventPtr event, uint16_t arg) {
- // hold: change brightness (brighter)
- if (event == EV_click1_hold) {
- if (arg % HOLD_TIMEOUT == 0) {
- set_state(med_mode_state, 0);
- }
- return MISCHIEF_MANAGED;
- }
- else return any_mode_state(event, arg, &L1, &L2, low_modes);
+ return any_mode_state(event, arg, &L1, &L2, low_modes);
}
uint8_t med_mode_state(EventPtr event, uint16_t arg) {
- // hold: change brightness (brighter)
- if (event == EV_click1_hold) {
- if (arg % HOLD_TIMEOUT == 0) {
- set_state(hi_mode_state, 0);
- }
- return MISCHIEF_MANAGED;
- }
- else return any_mode_state(event, arg, &M1, &M2, med_modes);
+ return any_mode_state(event, arg, &M1, &M2, med_modes);
}
uint8_t hi_mode_state(EventPtr event, uint16_t arg) {
- // hold: change brightness (brighter)
- if (event == EV_click1_hold) {
- if (arg % HOLD_TIMEOUT == 0) {
- set_state(low_mode_state, 0);
- }
- return MISCHIEF_MANAGED;
- }
- else return any_mode_state(event, arg, &H1, &H2, hi_modes);
+ return any_mode_state(event, arg, &H1, &H2, hi_modes);
}
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.