aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster/meteor
diff options
context:
space:
mode:
authorSelene ToyKeeper2017-09-01 00:16:03 -0600
committerSelene ToyKeeper2017-09-01 00:16:03 -0600
commitbb6314450b170220a884df49baf0b76cf549b3bc (patch)
tree5399291d5b46d73c9ddd0455f553cd20e5803724 /spaghetti-monster/meteor
parentStarted a Meteor M43 clone UI. (diff)
downloadanduril-bb6314450b170220a884df49baf0b76cf549b3bc.tar.gz
anduril-bb6314450b170220a884df49baf0b76cf549b3bc.tar.bz2
anduril-bb6314450b170220a884df49baf0b76cf549b3bc.zip
Added UI2. UI2 is weird.
Not sure I got everything the same; will have to try UI2 on my actual Meteor to see how it works.
Diffstat (limited to 'spaghetti-monster/meteor')
-rw-r--r--spaghetti-monster/meteor/meteor.c91
1 files changed, 86 insertions, 5 deletions
diff --git a/spaghetti-monster/meteor/meteor.c b/spaghetti-monster/meteor/meteor.c
index 9a630cd..c2ea6ec 100644
--- a/spaghetti-monster/meteor/meteor.c
+++ b/spaghetti-monster/meteor/meteor.c
@@ -70,9 +70,11 @@ uint8_t UI2_mode = 0;
uint8_t UI2_mode1 = 1;
uint8_t UI2_mode2 = 0;
uint8_t UI2_mode3 = 0;
-uint8_t UI2_group1[] = {0, 2};
-uint8_t UI2_group2[] = {4, 6};
-uint8_t UI2_group3[] = {8, 10};
+uint8_t UI2_mode4 = 0; // doesn't matter, makes other code easier
+uint8_t UI2_group1[] = { 0, 2}; // moon, low
+uint8_t UI2_group2[] = { 4, 6}; // mid1, mid2
+uint8_t UI2_group3[] = { 8, 10}; // high1, high2
+uint8_t UI2_group4[] = {11, 11}; // turbo only
// UI3 can access all levels, with 3 different mode memory slots
uint8_t UI3_mode = 0;
uint8_t UI3_mode1 = 2;
@@ -94,6 +96,12 @@ void set_any_mode(uint8_t mode, uint8_t *group) {
#endif
}
+void blink_fast() {
+ set_level(MAX_LEVEL/2);
+ delay_4ms(8/4);
+ set_level(0);
+}
+
uint8_t base_off_state(EventPtr event, uint16_t arg) {
// turn emitter off when entering state
if (event == EV_enter_state) {
@@ -130,16 +138,19 @@ uint8_t base_off_state(EventPtr event, uint16_t arg) {
}
// 9 clicks: activate UI1
else if (event == EV_9clicks) {
+ blink_fast();
set_state(ui1_off_state, 0);
return EVENT_HANDLED;
}
// 10 clicks: activate UI2
else if (event == EV_10clicks) {
+ blink_fast();
set_state(ui2_off_state, 0);
return EVENT_HANDLED;
}
// 11 clicks: activate UI3
else if (event == EV_11clicks) {
+ blink_fast();
set_state(ui3_off_state, 0);
return EVENT_HANDLED;
}
@@ -184,6 +195,31 @@ uint8_t ui2_off_state(EventPtr event, uint16_t arg) {
if (event == EV_enter_state) {
return EVENT_HANDLED;
}
+ // 1 click: low modes
+ if (event == EV_1click) {
+ set_any_mode(UI2_mode1, UI2_group1);
+ set_state(ui2_on_state, 0);
+ return EVENT_HANDLED;
+ }
+ // 2 clicks: high modes
+ else if (event == EV_2clicks) {
+ set_any_mode(UI2_mode3, UI2_group3);
+ set_state(ui2_on_state, 2);
+ return EVENT_HANDLED;
+ }
+ // hold: turbo
+ else if (event == EV_hold) {
+ if (arg == 0) {
+ set_level(MAX_LEVEL);
+ }
+ //set_state(ui1_on_state, 3);
+ return EVENT_HANDLED;
+ }
+ // release hold: off
+ else if (event == EV_click1_hold_release) {
+ set_state(base_off_state, 0);
+ return EVENT_HANDLED;
+ }
return base_off_state(event, arg);
}
@@ -261,11 +297,56 @@ uint8_t ui1_on_state(EventPtr event, uint16_t arg) {
set_any_mode(*mode, group);
return MISCHIEF_MANAGED;
}
- return base_on_state(event, arg, &UI1_mode1, UI1_group1);
+ return base_on_state(event, arg, mode, group);
}
uint8_t ui2_on_state(EventPtr event, uint16_t arg) {
- return base_on_state(event, arg, &UI2_mode1, UI2_group1);
+ // turn on LED when entering the mode
+ static uint8_t *mode = &UI2_mode1;
+ static uint8_t *group = UI2_group1;
+ if (event == EV_enter_state) {
+ UI2_mode = arg;
+ }
+ switch (UI2_mode) {
+ case 0:
+ mode = &UI2_mode1;
+ group = UI2_group1;
+ break;
+ case 1:
+ mode = &UI2_mode2;
+ group = UI2_group2;
+ break;
+ case 2:
+ mode = &UI2_mode3;
+ group = UI2_group3;
+ break;
+ default: // turbo only
+ mode = &UI2_mode4;
+ group = UI2_group4;
+ break;
+ }
+
+ if (event == EV_enter_state) {
+ set_any_mode(*mode, group);
+ return EVENT_HANDLED;
+ }
+ // 2 clicks: toggle moon/low, mid1/mid2, or high1/high2
+ else if (event == EV_2clicks) {
+ *mode ^= 1;
+ set_any_mode(*mode, group);
+ return MISCHIEF_MANAGED;
+ }
+ // hold: rotate through low/mid/high/turbo
+ else if (event == EV_hold) {
+ if (arg % HOLD_TIMEOUT == 0) {
+ UI2_mode = (UI2_mode + 1) & 3;
+ }
+ else if (arg % HOLD_TIMEOUT == 1) {
+ set_any_mode(*mode, group);
+ }
+ return MISCHIEF_MANAGED;
+ }
+ return base_on_state(event, arg, mode, group);
}
uint8_t ui3_on_state(EventPtr event, uint16_t arg) {
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.