From 73a5a6974a98aa73ab392272b4d69d285c85dee5 Mon Sep 17 00:00:00 2001
From: Selene ToyKeeper
Date: Sat, 19 Aug 2017 17:20:46 -0600
Subject: Completely reorganized SpaghettiMonster code into smaller logical
pieces: fsm-*.c and fsm-*.h.
---
spaghetti-monster/fsm-events.h | 197 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 197 insertions(+)
create mode 100644 spaghetti-monster/fsm-events.h
(limited to 'spaghetti-monster/fsm-events.h')
diff --git a/spaghetti-monster/fsm-events.h b/spaghetti-monster/fsm-events.h
new file mode 100644
index 0000000..434fa10
--- /dev/null
+++ b/spaghetti-monster/fsm-events.h
@@ -0,0 +1,197 @@
+/*
+ * fsm-events.h: Event-handling functions for SpaghettiMonster.
+ *
+ * Copyright (C) 2017 Selene ToyKeeper
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#ifndef FSM_EVENTS_H
+#define FSM_EVENTS_H
+
+#include
+
+// typedefs
+typedef PROGMEM const uint8_t Event;
+typedef Event * EventPtr;
+typedef struct Emission {
+ EventPtr event;
+ uint16_t arg;
+} Emission;
+
+#define EV_MAX_LEN 16
+uint8_t current_event[EV_MAX_LEN];
+// at 0.016 ms per tick, 255 ticks = 4.08 s
+// TODO: 16 bits?
+static volatile uint16_t ticks_since_last_event = 0;
+
+// timeout durations in ticks (each tick 1/60th s)
+#define HOLD_TIMEOUT 24
+#define RELEASE_TIMEOUT 24
+
+#define A_ENTER_STATE 1
+#define A_LEAVE_STATE 2
+#define A_TICK 3
+#define A_PRESS 4
+#define A_HOLD 5
+#define A_RELEASE 6
+#define A_RELEASE_TIMEOUT 7
+// TODO: add events for over/under-heat conditions (with parameter for severity)
+#define A_OVERHEATING 8
+#define A_UNDERHEATING 9
+// TODO: add events for low voltage conditions
+#define A_VOLTAGE_LOW 10
+//#define A_VOLTAGE_CRITICAL 11
+#define A_DEBUG 255 // test event for debugging
+
+// Event types
+Event EV_debug[] = {
+ A_DEBUG,
+ 0 } ;
+Event EV_enter_state[] = {
+ A_ENTER_STATE,
+ 0 } ;
+Event EV_leave_state[] = {
+ A_LEAVE_STATE,
+ 0 } ;
+Event EV_tick[] = {
+ A_TICK,
+ 0 } ;
+#ifdef USE_LVP
+Event EV_voltage_low[] = {
+ A_VOLTAGE_LOW,
+ 0 } ;
+#endif
+#ifdef USE_THERMAL_REGULATION
+Event EV_temperature_high[] = {
+ A_OVERHEATING,
+ 0 } ;
+Event EV_temperature_low[] = {
+ A_UNDERHEATING,
+ 0 } ;
+#endif
+Event EV_click1_press[] = {
+ A_PRESS,
+ 0 };
+// shouldn't normally happen, but UI might reset event while button is down
+// so a release with no recorded prior hold could be possible
+Event EV_release[] = {
+ A_RELEASE,
+ 0 };
+Event EV_click1_release[] = {
+ A_PRESS,
+ A_RELEASE,
+ 0 };
+#define EV_1click EV_click1_complete
+Event EV_click1_complete[] = {
+ A_PRESS,
+ A_RELEASE,
+ A_RELEASE_TIMEOUT,
+ 0 };
+#define EV_hold EV_click1_hold
+// FIXME: Should holds use "start+tick" or just "tick" with a tick number?
+// Or "start+tick" with a tick number?
+Event EV_click1_hold[] = {
+ A_PRESS,
+ A_HOLD,
+ 0 };
+Event EV_click1_hold_release[] = {
+ A_PRESS,
+ A_HOLD,
+ A_RELEASE,
+ 0 };
+Event EV_click2_press[] = {
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ 0 };
+Event EV_click2_release[] = {
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ 0 };
+#define EV_2clicks EV_click2_complete
+Event EV_click2_complete[] = {
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_RELEASE_TIMEOUT,
+ 0 };
+Event EV_click3_press[] = {
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ 0 };
+Event EV_click3_release[] = {
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ 0 };
+#define EV_3clicks EV_click3_complete
+Event EV_click3_complete[] = {
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_RELEASE_TIMEOUT,
+ 0 };
+// ... and so on
+
+// A list of button event types for easy iteration
+EventPtr event_sequences[] = {
+ EV_click1_press,
+ EV_release,
+ EV_click1_release,
+ EV_click1_complete,
+ EV_click1_hold,
+ EV_click1_hold_release,
+ EV_click2_press,
+ EV_click2_release,
+ EV_click2_complete,
+ EV_click3_press,
+ EV_click3_release,
+ EV_click3_complete,
+ // ...
+};
+
+#define events_match(a,b) compare_event_sequences(a,b)
+// return 1 if (a == b), 0 otherwise
+uint8_t compare_event_sequences(uint8_t *a, const uint8_t *b);
+void empty_event_sequence();
+uint8_t push_event(uint8_t ev_type);
+// uint8_t last_event(uint8_t offset);
+inline uint8_t last_event_num();
+
+
+#define EMISSION_QUEUE_LEN 16
+// no comment about "volatile emissions"
+volatile Emission emissions[EMISSION_QUEUE_LEN];
+
+void append_emission(EventPtr event, uint16_t arg);
+void delete_first_emission();
+//#define emit_now emit
+uint8_t emit_now(EventPtr event, uint16_t arg);
+void emit(EventPtr event, uint16_t arg);
+void emit_current_event(uint16_t arg);
+
+#endif
--
cgit v1.2.3
From badf37072988156a4cee753b922306195ee45916 Mon Sep 17 00:00:00 2001
From: Selene ToyKeeper
Date: Thu, 24 Aug 2017 02:09:33 -0600
Subject: Added a ramping UI example. Added ramping support in general.
---
spaghetti-monster/fsm-events.h | 7 +++++++
1 file changed, 7 insertions(+)
(limited to 'spaghetti-monster/fsm-events.h')
diff --git a/spaghetti-monster/fsm-events.h b/spaghetti-monster/fsm-events.h
index 434fa10..420baf1 100644
--- a/spaghetti-monster/fsm-events.h
+++ b/spaghetti-monster/fsm-events.h
@@ -116,6 +116,12 @@ Event EV_click2_press[] = {
A_RELEASE,
A_PRESS,
0 };
+Event EV_click2_hold[] = {
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_HOLD,
+ 0 };
Event EV_click2_release[] = {
A_PRESS,
A_RELEASE,
@@ -166,6 +172,7 @@ EventPtr event_sequences[] = {
EV_click1_hold,
EV_click1_hold_release,
EV_click2_press,
+ EV_click2_hold,
EV_click2_release,
EV_click2_complete,
EV_click3_press,
--
cgit v1.2.3
From 939a13fe9949c576e21914939e1d847641f215c9 Mon Sep 17 00:00:00 2001
From: Selene ToyKeeper
Date: Thu, 24 Aug 2017 02:25:58 -0600
Subject: Made ramping UI able to toggle between smooth and discrete ramping
with 4 clicks.
---
spaghetti-monster/fsm-events.h | 13 +++++++++++++
1 file changed, 13 insertions(+)
(limited to 'spaghetti-monster/fsm-events.h')
diff --git a/spaghetti-monster/fsm-events.h b/spaghetti-monster/fsm-events.h
index 420baf1..246a4ee 100644
--- a/spaghetti-monster/fsm-events.h
+++ b/spaghetti-monster/fsm-events.h
@@ -161,6 +161,18 @@ Event EV_click3_complete[] = {
A_RELEASE,
A_RELEASE_TIMEOUT,
0 };
+#define EV_4clicks EV_click4_complete
+Event EV_click4_complete[] = {
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_RELEASE_TIMEOUT,
+ 0 };
// ... and so on
// A list of button event types for easy iteration
@@ -178,6 +190,7 @@ EventPtr event_sequences[] = {
EV_click3_press,
EV_click3_release,
EV_click3_complete,
+ EV_click4_complete,
// ...
};
--
cgit v1.2.3
From 32eaeddee34c76dda5456ed960be6278ed68e48d Mon Sep 17 00:00:00 2001
From: Selene ToyKeeper
Date: Thu, 24 Aug 2017 16:21:45 -0600
Subject: Added loop() to API, executes constantly. Added nice_delay_ms() to
process events while waiting, and abort on state change. Converted ramping-ui
strobe to smoothly variable with party and tactical modes.
---
spaghetti-monster/fsm-events.h | 3 +++
1 file changed, 3 insertions(+)
(limited to 'spaghetti-monster/fsm-events.h')
diff --git a/spaghetti-monster/fsm-events.h b/spaghetti-monster/fsm-events.h
index 246a4ee..a14d7aa 100644
--- a/spaghetti-monster/fsm-events.h
+++ b/spaghetti-monster/fsm-events.h
@@ -209,9 +209,12 @@ volatile Emission emissions[EMISSION_QUEUE_LEN];
void append_emission(EventPtr event, uint16_t arg);
void delete_first_emission();
+void process_emissions();
//#define emit_now emit
uint8_t emit_now(EventPtr event, uint16_t arg);
void emit(EventPtr event, uint16_t arg);
void emit_current_event(uint16_t arg);
+uint8_t nice_delay_ms(uint16_t ms);
+
#endif
--
cgit v1.2.3
From 5184aad41fdb501f05ff7b0d7131011657ed8275 Mon Sep 17 00:00:00 2001
From: Selene ToyKeeper
Date: Thu, 24 Aug 2017 19:22:10 -0600
Subject: Started on some documentation, spaghetti-monster.txt. Added #defines
for State return values: EVENT_HANDLED, EVENT_NOT_HANDLED Improved handling
of delay includes. Managed mischief.
---
spaghetti-monster/fsm-events.h | 5 +++++
1 file changed, 5 insertions(+)
(limited to 'spaghetti-monster/fsm-events.h')
diff --git a/spaghetti-monster/fsm-events.h b/spaghetti-monster/fsm-events.h
index a14d7aa..a3ef130 100644
--- a/spaghetti-monster/fsm-events.h
+++ b/spaghetti-monster/fsm-events.h
@@ -30,6 +30,11 @@ typedef struct Emission {
uint16_t arg;
} Emission;
+#define EVENT_HANDLED 0
+#define EVENT_NOT_HANDLED 1
+#define MISCHIEF_MANAGED EVENT_HANDLED
+#define MISCHIEF_NOT_MANAGED EVENT_NOT_HANDLED
+
#define EV_MAX_LEN 16
uint8_t current_event[EV_MAX_LEN];
// at 0.016 ms per tick, 255 ticks = 4.08 s
--
cgit v1.2.3
From 39b30b41f92978a3e05a8de0a416279fb35b35b1 Mon Sep 17 00:00:00 2001
From: Selene ToyKeeper
Date: Fri, 25 Aug 2017 02:14:31 -0600
Subject: Added battcheck mode to ramping-ui. It's bigger than I had hoped.
:( Added fsm-misc.*, which currently only has interruptible blink functions
in it. (for blinking out numbers and such)
---
spaghetti-monster/fsm-events.h | 2 ++
1 file changed, 2 insertions(+)
(limited to 'spaghetti-monster/fsm-events.h')
diff --git a/spaghetti-monster/fsm-events.h b/spaghetti-monster/fsm-events.h
index a3ef130..141a0dc 100644
--- a/spaghetti-monster/fsm-events.h
+++ b/spaghetti-monster/fsm-events.h
@@ -221,5 +221,7 @@ void emit(EventPtr event, uint16_t arg);
void emit_current_event(uint16_t arg);
uint8_t nice_delay_ms(uint16_t ms);
+//uint8_t nice_delay_4ms(uint8_t ms);
+//uint8_t nice_delay_s();
#endif
--
cgit v1.2.3
From 674259407ace91bef354059c842b4114e95eb23c Mon Sep 17 00:00:00 2001
From: Selene ToyKeeper
Date: Sat, 26 Aug 2017 03:06:12 -0600
Subject: Added beacons/strobes to DarkHorse. Added a way to explicitly cancel
the current "nice" delay without changing state.
---
spaghetti-monster/fsm-events.h | 1 +
1 file changed, 1 insertion(+)
(limited to 'spaghetti-monster/fsm-events.h')
diff --git a/spaghetti-monster/fsm-events.h b/spaghetti-monster/fsm-events.h
index 141a0dc..f2a0181 100644
--- a/spaghetti-monster/fsm-events.h
+++ b/spaghetti-monster/fsm-events.h
@@ -223,5 +223,6 @@ void emit_current_event(uint16_t arg);
uint8_t nice_delay_ms(uint16_t ms);
//uint8_t nice_delay_4ms(uint8_t ms);
//uint8_t nice_delay_s();
+inline void interrupt_nice_delays();
#endif
--
cgit v1.2.3
From 6d9ceae8eab62ba33011a82c8fad8e55d37fe7ba Mon Sep 17 00:00:00 2001
From: Selene ToyKeeper
Date: Sat, 26 Aug 2017 16:48:25 -0600
Subject: Added eeprom load/save API (no wear levelling yet), verified it works
in DarkHorse.
---
spaghetti-monster/fsm-events.h | 8 ++++++++
1 file changed, 8 insertions(+)
(limited to 'spaghetti-monster/fsm-events.h')
diff --git a/spaghetti-monster/fsm-events.h b/spaghetti-monster/fsm-events.h
index f2a0181..90dcbd6 100644
--- a/spaghetti-monster/fsm-events.h
+++ b/spaghetti-monster/fsm-events.h
@@ -127,6 +127,13 @@ Event EV_click2_hold[] = {
A_PRESS,
A_HOLD,
0 };
+Event EV_click2_hold_release[] = {
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_HOLD,
+ A_RELEASE,
+ 0 };
Event EV_click2_release[] = {
A_PRESS,
A_RELEASE,
@@ -190,6 +197,7 @@ EventPtr event_sequences[] = {
EV_click1_hold_release,
EV_click2_press,
EV_click2_hold,
+ EV_click2_hold_release,
EV_click2_release,
EV_click2_complete,
EV_click3_press,
--
cgit v1.2.3
From c2b995167d2f523f13187d5ca39c9343cf62a702 Mon Sep 17 00:00:00 2001
From: Selene ToyKeeper
Date: Sun, 27 Aug 2017 01:58:07 -0600
Subject: Made it easier to configure the maximum number of clicks it'll try to
count in one sequence. (use #define MAX_CLICKS 5, for example) Keeps data
sizes from being excessively large without having to edit FSM sources per UI.
---
spaghetti-monster/fsm-events.h | 58 +++++++++++++++++++++++++++++++++++++++++-
1 file changed, 57 insertions(+), 1 deletion(-)
(limited to 'spaghetti-monster/fsm-events.h')
diff --git a/spaghetti-monster/fsm-events.h b/spaghetti-monster/fsm-events.h
index 90dcbd6..114ccc4 100644
--- a/spaghetti-monster/fsm-events.h
+++ b/spaghetti-monster/fsm-events.h
@@ -35,7 +35,11 @@ typedef struct Emission {
#define MISCHIEF_MANAGED EVENT_HANDLED
#define MISCHIEF_NOT_MANAGED EVENT_NOT_HANDLED
-#define EV_MAX_LEN 16
+#ifndef MAX_CLICKS
+#define MAX_CLICKS 4
+#endif
+
+#define EV_MAX_LEN ((MAX_CLICKS*2)+3)
uint8_t current_event[EV_MAX_LEN];
// at 0.016 ms per tick, 255 ticks = 4.08 s
// TODO: 16 bits?
@@ -116,6 +120,7 @@ Event EV_click1_hold_release[] = {
A_HOLD,
A_RELEASE,
0 };
+#if MAX_CLICKS >= 2
Event EV_click2_press[] = {
A_PRESS,
A_RELEASE,
@@ -148,6 +153,8 @@ Event EV_click2_complete[] = {
A_RELEASE,
A_RELEASE_TIMEOUT,
0 };
+#endif // MAX_CLICKS >= 2
+#if MAX_CLICKS >= 3
Event EV_click3_press[] = {
A_PRESS,
A_RELEASE,
@@ -173,6 +180,8 @@ Event EV_click3_complete[] = {
A_RELEASE,
A_RELEASE_TIMEOUT,
0 };
+#endif // MAX_CLICKS >= 3
+#if MAX_CLICKS >= 4
#define EV_4clicks EV_click4_complete
Event EV_click4_complete[] = {
A_PRESS,
@@ -185,6 +194,41 @@ Event EV_click4_complete[] = {
A_RELEASE,
A_RELEASE_TIMEOUT,
0 };
+#endif
+#if MAX_CLICKS >= 5
+#define EV_5clicks EV_click5_complete
+Event EV_click5_complete[] = {
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_RELEASE_TIMEOUT,
+ 0 };
+#endif
+#if MAX_CLICKS >= 6
+#define EV_6clicks EV_click6_complete
+Event EV_click6_complete[] = {
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_RELEASE_TIMEOUT,
+ 0 };
+#endif
// ... and so on
// A list of button event types for easy iteration
@@ -195,15 +239,27 @@ EventPtr event_sequences[] = {
EV_click1_complete,
EV_click1_hold,
EV_click1_hold_release,
+ #if MAX_CLICKS >= 2
EV_click2_press,
EV_click2_hold,
EV_click2_hold_release,
EV_click2_release,
EV_click2_complete,
+ #endif
+ #if MAX_CLICKS >= 3
EV_click3_press,
EV_click3_release,
EV_click3_complete,
+ #endif
+ #if MAX_CLICKS >= 4
EV_click4_complete,
+ #endif
+ #if MAX_CLICKS >= 5
+ EV_click5_complete,
+ #endif
+ #if MAX_CLICKS >= 6
+ EV_click6_complete,
+ #endif
// ...
};
--
cgit v1.2.3
From dce497bf15799133bf336ab46c3e39d7b0d92839 Mon Sep 17 00:00:00 2001
From: Selene ToyKeeper
Date: Sun, 27 Aug 2017 19:40:40 -0600
Subject: Ramp config mode actually works now... Added EV_reenter_state event
to indicate an obscuring state was popped off the stack and the underlying
one is now on top again.
---
spaghetti-monster/fsm-events.h | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
(limited to 'spaghetti-monster/fsm-events.h')
diff --git a/spaghetti-monster/fsm-events.h b/spaghetti-monster/fsm-events.h
index 114ccc4..e3edc77 100644
--- a/spaghetti-monster/fsm-events.h
+++ b/spaghetti-monster/fsm-events.h
@@ -51,17 +51,18 @@ static volatile uint16_t ticks_since_last_event = 0;
#define A_ENTER_STATE 1
#define A_LEAVE_STATE 2
-#define A_TICK 3
-#define A_PRESS 4
-#define A_HOLD 5
-#define A_RELEASE 6
-#define A_RELEASE_TIMEOUT 7
+#define A_REENTER_STATE 3
+#define A_TICK 4
+#define A_PRESS 5
+#define A_HOLD 6
+#define A_RELEASE 7
+#define A_RELEASE_TIMEOUT 8
// TODO: add events for over/under-heat conditions (with parameter for severity)
-#define A_OVERHEATING 8
-#define A_UNDERHEATING 9
+#define A_OVERHEATING 9
+#define A_UNDERHEATING 10
// TODO: add events for low voltage conditions
-#define A_VOLTAGE_LOW 10
-//#define A_VOLTAGE_CRITICAL 11
+#define A_VOLTAGE_LOW 11
+//#define A_VOLTAGE_CRITICAL 12
#define A_DEBUG 255 // test event for debugging
// Event types
@@ -74,6 +75,9 @@ Event EV_enter_state[] = {
Event EV_leave_state[] = {
A_LEAVE_STATE,
0 } ;
+Event EV_reenter_state[] = {
+ A_REENTER_STATE,
+ 0 } ;
Event EV_tick[] = {
A_TICK,
0 } ;
--
cgit v1.2.3
From 0a801bff0f22be650aed6c3724c41cae03814d8f Mon Sep 17 00:00:00 2001
From: Selene ToyKeeper
Date: Thu, 31 Aug 2017 23:45:36 -0600
Subject: Started a Meteor M43 clone UI. So far, UI1 and battcheck both work.
UI2 and UI3 and other blinkies aren't implement yet. Added 6-bar battcheck
style to match Meteor (ish). Increased maximum number of clicks to 12,
because WTF. If your UI needs 12 clicks, what are you even doing in life?
---
spaghetti-monster/fsm-events.h | 168 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 168 insertions(+)
(limited to 'spaghetti-monster/fsm-events.h')
diff --git a/spaghetti-monster/fsm-events.h b/spaghetti-monster/fsm-events.h
index e3edc77..c77facd 100644
--- a/spaghetti-monster/fsm-events.h
+++ b/spaghetti-monster/fsm-events.h
@@ -233,6 +233,156 @@ Event EV_click6_complete[] = {
A_RELEASE_TIMEOUT,
0 };
#endif
+#if MAX_CLICKS >= 7
+#define EV_7clicks EV_click7_complete
+Event EV_click7_complete[] = {
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_RELEASE_TIMEOUT,
+ 0 };
+#endif
+#if MAX_CLICKS >= 8
+#define EV_8clicks EV_click8_complete
+Event EV_click8_complete[] = {
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_RELEASE_TIMEOUT,
+ 0 };
+#endif
+#if MAX_CLICKS >= 9
+#define EV_9clicks EV_click9_complete
+Event EV_click9_complete[] = {
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_RELEASE_TIMEOUT,
+ 0 };
+#endif
+#if MAX_CLICKS >= 10
+#define EV_10clicks EV_click10_complete
+Event EV_click10_complete[] = {
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_RELEASE_TIMEOUT,
+ 0 };
+#endif
+#if MAX_CLICKS >= 11
+#define EV_11clicks EV_click11_complete
+Event EV_click11_complete[] = {
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_RELEASE_TIMEOUT,
+ 0 };
+#endif
+#if MAX_CLICKS >= 12
+#define EV_12clicks EV_click12_complete
+Event EV_click12_complete[] = {
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_RELEASE_TIMEOUT,
+ 0 };
+#endif
// ... and so on
// A list of button event types for easy iteration
@@ -264,6 +414,24 @@ EventPtr event_sequences[] = {
#if MAX_CLICKS >= 6
EV_click6_complete,
#endif
+ #if MAX_CLICKS >= 7
+ EV_click7_complete,
+ #endif
+ #if MAX_CLICKS >= 8
+ EV_click8_complete,
+ #endif
+ #if MAX_CLICKS >= 9
+ EV_click9_complete,
+ #endif
+ #if MAX_CLICKS >= 10
+ EV_click10_complete,
+ #endif
+ #if MAX_CLICKS >= 11
+ EV_click11_complete,
+ #endif
+ #if MAX_CLICKS >= 12
+ EV_click12_complete,
+ #endif
// ...
};
--
cgit v1.2.3
From d4a3e889ec53155a913763a52fd4a82bee14d95c Mon Sep 17 00:00:00 2001
From: Selene ToyKeeper
Date: Sun, 10 Sep 2017 02:37:39 -0600
Subject: Moved strobes from 5 clicks to "click, click, long-click". Moved
momentary mode from 6 clicks to 5 clicks.
---
spaghetti-monster/fsm-events.h | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
(limited to 'spaghetti-monster/fsm-events.h')
diff --git a/spaghetti-monster/fsm-events.h b/spaghetti-monster/fsm-events.h
index c77facd..074b459 100644
--- a/spaghetti-monster/fsm-events.h
+++ b/spaghetti-monster/fsm-events.h
@@ -166,6 +166,25 @@ Event EV_click3_press[] = {
A_RELEASE,
A_PRESS,
0 };
+Event EV_click3_hold[] = {
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_HOLD,
+ 0 };
+/*
+Event EV_click3_hold_release[] = {
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_RELEASE,
+ A_PRESS,
+ A_HOLD,
+ A_RELEASE,
+ 0 };
+ */
Event EV_click3_release[] = {
A_PRESS,
A_RELEASE,
@@ -402,6 +421,8 @@ EventPtr event_sequences[] = {
#endif
#if MAX_CLICKS >= 3
EV_click3_press,
+ EV_click3_hold,
+ //EV_click3_hold_release,
EV_click3_release,
EV_click3_complete,
#endif
--
cgit v1.2.3
From c3ade0cf9b7f344be2fcf14c1ba05cf49eded954 Mon Sep 17 00:00:00 2001
From: Selene ToyKeeper
Date: Fri, 6 Oct 2017 00:34:34 -0600
Subject: Made HOLD_TIMEOUT and RELEASE_TIMEOUT define-able in the UI code.
---
spaghetti-monster/fsm-events.h | 4 ++++
1 file changed, 4 insertions(+)
(limited to 'spaghetti-monster/fsm-events.h')
diff --git a/spaghetti-monster/fsm-events.h b/spaghetti-monster/fsm-events.h
index 074b459..453ad0b 100644
--- a/spaghetti-monster/fsm-events.h
+++ b/spaghetti-monster/fsm-events.h
@@ -46,8 +46,12 @@ uint8_t current_event[EV_MAX_LEN];
static volatile uint16_t ticks_since_last_event = 0;
// timeout durations in ticks (each tick 1/60th s)
+#ifndef HOLD_TIMEOUT
#define HOLD_TIMEOUT 24
+#endif
+#ifndef RELEASE_TIMEOUT
#define RELEASE_TIMEOUT 24
+#endif
#define A_ENTER_STATE 1
#define A_LEAVE_STATE 2
--
cgit v1.2.3
From 5764a79e80ca35b7c5268b3580891b3b17768253 Mon Sep 17 00:00:00 2001
From: Selene ToyKeeper
Date: Fri, 20 Oct 2017 08:06:46 -0600
Subject: Er, don't save_config() every frame... wait until the user lets go
of the button.
---
spaghetti-monster/fsm-events.h | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
(limited to 'spaghetti-monster/fsm-events.h')
diff --git a/spaghetti-monster/fsm-events.h b/spaghetti-monster/fsm-events.h
index 453ad0b..28f1b10 100644
--- a/spaghetti-monster/fsm-events.h
+++ b/spaghetti-monster/fsm-events.h
@@ -178,7 +178,6 @@ Event EV_click3_hold[] = {
A_PRESS,
A_HOLD,
0 };
-/*
Event EV_click3_hold_release[] = {
A_PRESS,
A_RELEASE,
@@ -188,7 +187,6 @@ Event EV_click3_hold_release[] = {
A_HOLD,
A_RELEASE,
0 };
- */
Event EV_click3_release[] = {
A_PRESS,
A_RELEASE,
@@ -426,7 +424,7 @@ EventPtr event_sequences[] = {
#if MAX_CLICKS >= 3
EV_click3_press,
EV_click3_hold,
- //EV_click3_hold_release,
+ EV_click3_hold_release,
EV_click3_release,
EV_click3_complete,
#endif
--
cgit v1.2.3
From 8267c1f121d9766e37d2056004bd7bb47b512288 Mon Sep 17 00:00:00 2001
From: Selene ToyKeeper
Date: Wed, 24 Jan 2018 18:28:29 -0700
Subject: Save a few bytes by changing how PCINT is defined. Minor comment
cleaning.
---
spaghetti-monster/fsm-events.h | 2 --
1 file changed, 2 deletions(-)
(limited to 'spaghetti-monster/fsm-events.h')
diff --git a/spaghetti-monster/fsm-events.h b/spaghetti-monster/fsm-events.h
index 28f1b10..2721303 100644
--- a/spaghetti-monster/fsm-events.h
+++ b/spaghetti-monster/fsm-events.h
@@ -61,10 +61,8 @@ static volatile uint16_t ticks_since_last_event = 0;
#define A_HOLD 6
#define A_RELEASE 7
#define A_RELEASE_TIMEOUT 8
-// TODO: add events for over/under-heat conditions (with parameter for severity)
#define A_OVERHEATING 9
#define A_UNDERHEATING 10
-// TODO: add events for low voltage conditions
#define A_VOLTAGE_LOW 11
//#define A_VOLTAGE_CRITICAL 12
#define A_DEBUG 255 // test event for debugging
--
cgit v1.2.3