aboutsummaryrefslogtreecommitdiff
path: root/RoundTable/momentary.c
diff options
context:
space:
mode:
authorSelene ToyKeeper2017-08-18 23:31:11 -0600
committerSelene ToyKeeper2017-08-18 23:31:11 -0600
commit086aaabd39d3c6736ace56f2badac06b75567651 (patch)
treeb756e3cfa612127c409ee59203ed5177ceee1db6 /RoundTable/momentary.c
parentSome early ideas for Round Table. Nothing close to compile-able yet. (diff)
downloadanduril-086aaabd39d3c6736ace56f2badac06b75567651.tar.gz
anduril-086aaabd39d3c6736ace56f2badac06b75567651.tar.bz2
anduril-086aaabd39d3c6736ace56f2badac06b75567651.zip
First RoundTable example actually works (simple momentary 1-mode UI).
Changed how tk-attiny.h detects whether a layout was defined. Changed how tk-attiny.h detects number of PWM channels for new-style layouts. Added no-underscore versions of delay functions. Lots of RoundTable refactoring and blank-filling.
Diffstat (limited to 'RoundTable/momentary.c')
-rw-r--r--RoundTable/momentary.c72
1 files changed, 50 insertions, 22 deletions
diff --git a/RoundTable/momentary.c b/RoundTable/momentary.c
index 120406e..4394f46 100644
--- a/RoundTable/momentary.c
+++ b/RoundTable/momentary.c
@@ -20,7 +20,12 @@
*/
#define RT_EMISAR_D4_LAYOUT
+#define USE_LVP
+#define USE_DEBUG_BLINK
+#define OWN_DELAY
+#define USE_DELAY_MS
#include "round-table.c"
+#include "tk-delay.h"
volatile uint8_t brightness;
@@ -34,35 +39,58 @@ void light_off() {
PWM2_LVL = 0;
}
+//State momentary_state {
uint8_t momentary_state(EventPtr event, uint16_t arg) {
- switch(event) {
- case EV_press:
- brightness = 255;
- light_on();
- // reset current event queue
- empty_event_sequence();
- return 0;
+ if (event == EV_click1_press) {
+ brightness = 255;
+ light_on();
+ // reset current event queue
+ empty_event_sequence();
+ return 0;
+ }
+
+ else if (event == EV_release) {
+ light_off();
+ // reset current event queue
+ empty_event_sequence();
+ return 0;
+ }
- case EV_release:
+ /*
+ // LVP / low-voltage protection
+ //else if ((event == EV_voltage_low) || (event == EV_voltage_critical)) {
+ else if (event == EV_voltage_low) {
+ if (brightness > 0) brightness >>= 1;
+ else {
light_off();
- // reset current event queue
- empty_event_sequence();
- return 0;
+ standby_mode();
+ }
+ return 0;
+ }
+ */
- // LVP / low-voltage protection
- case EV_voltage_low:
- case EV_voltage_critical:
- if (brightness > 0) brightness >>= 1;
- else {
- light_off();
- standby_mode();
- }
- return 0;
+ // event not handled
+ return 1;
+}
+
+// LVP / low-voltage protection
+void low_voltage() {
+ if (brightness > 0) brightness >>= 1;
+ else {
+ light_off();
+ standby_mode();
}
- return 1; // event not handled
}
void setup() {
- set_state(momentary_state);
+ //debug_blink(1);
+ /*
+ brightness = 255;
+ light_on();
+ delay_ms(10);
+ light_off();
+ */
+
+ push_state(momentary_state);
}