From a1683d309f4f9370c1b2b2a05802c8580c1e2543 Mon Sep 17 00:00:00 2001
From: Selene ToyKeeper
Date: Wed, 22 Jul 2020 16:50:22 -0600
Subject: renamed off-state.* -> off-mode.*
---
spaghetti-monster/anduril/anduril.c | 4 +-
spaghetti-monster/anduril/off-mode.c | 261 ++++++++++++++++++++++++++++++++++
spaghetti-monster/anduril/off-mode.h | 27 ++++
spaghetti-monster/anduril/off-state.c | 261 ----------------------------------
spaghetti-monster/anduril/off-state.h | 27 ----
5 files changed, 290 insertions(+), 290 deletions(-)
create mode 100644 spaghetti-monster/anduril/off-mode.c
create mode 100644 spaghetti-monster/anduril/off-mode.h
delete mode 100644 spaghetti-monster/anduril/off-state.c
delete mode 100644 spaghetti-monster/anduril/off-state.h
(limited to 'spaghetti-monster')
diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c
index 67b4b3f..6ef7954 100644
--- a/spaghetti-monster/anduril/anduril.c
+++ b/spaghetti-monster/anduril/anduril.c
@@ -88,7 +88,7 @@
/********* Include all the regular app headers *********/
-#include "off-state.h"
+#include "off-mode.h"
#include "ramp-mode.h"
#include "load-save-config.h"
#include "config-mode.h"
@@ -204,7 +204,7 @@ uint8_t rgb_led_lockout_mode = RGB_LED_LOCKOUT_DEFAULT;
// (is a bit weird to do things this way,
// but it saves a lot of space by letting us use the -fwhole-program flag)
-#include "off-state.c"
+#include "off-mode.c"
#include "ramp-mode.c"
#include "load-save-config.c"
#include "config-mode.c"
diff --git a/spaghetti-monster/anduril/off-mode.c b/spaghetti-monster/anduril/off-mode.c
new file mode 100644
index 0000000..a640b5c
--- /dev/null
+++ b/spaghetti-monster/anduril/off-mode.c
@@ -0,0 +1,261 @@
+/*
+ * off-mode.c: "Off" mode for Anduril.
+ *
+ * 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 OFF_MODE_C
+#define OFF_MODE_C
+
+#include "off-mode.h"
+
+uint8_t off_state(Event event, uint16_t arg) {
+ // turn emitter off when entering state
+ if (event == EV_enter_state) {
+ set_level(0);
+ #ifdef USE_INDICATOR_LED
+ indicator_led(indicator_led_mode & 0x03);
+ #elif defined(USE_AUX_RGB_LEDS)
+ rgb_led_update(rgb_led_off_mode, 0);
+ #endif
+ // sleep while off (lower power use)
+ // (unless delay requested; give the ADC some time to catch up)
+ if (! arg) { go_to_standby = 1; }
+ return MISCHIEF_MANAGED;
+ }
+ // go back to sleep eventually if we got bumped but didn't leave "off" state
+ else if (event == EV_tick) {
+ if (arg > HOLD_TIMEOUT) {
+ go_to_standby = 1;
+ #ifdef USE_INDICATOR_LED
+ indicator_led(indicator_led_mode & 0x03);
+ #elif defined(USE_AUX_RGB_LEDS)
+ rgb_led_update(rgb_led_off_mode, arg);
+ #endif
+ }
+ return MISCHIEF_MANAGED;
+ }
+ #if defined(TICK_DURING_STANDBY) && (defined(USE_INDICATOR_LED) || defined(USE_AUX_RGB_LEDS))
+ // blink the indicator LED, maybe
+ else if (event == EV_sleep_tick) {
+ #ifdef USE_INDICATOR_LED
+ if ((indicator_led_mode & 0b00000011) == 0b00000011) {
+ indicator_blink(arg);
+ }
+ #elif defined(USE_AUX_RGB_LEDS)
+ rgb_led_update(rgb_led_off_mode, arg);
+ #endif
+ return MISCHIEF_MANAGED;
+ }
+ #endif
+ #if (B_TIMING_ON == B_PRESS_T)
+ // hold (initially): go to lowest level (floor), but allow abort for regular click
+ else if (event == EV_click1_press) {
+ set_level(nearest_level(1));
+ return MISCHIEF_MANAGED;
+ }
+ #endif // B_TIMING_ON == B_PRESS_T
+ // hold: go to lowest level
+ else if (event == EV_click1_hold) {
+ #if (B_TIMING_ON == B_PRESS_T)
+ #ifdef MOON_TIMING_HINT
+ if (arg == 0) {
+ // let the user know they can let go now to stay at moon
+ blip();
+ } else
+ #endif
+ #else // B_RELEASE_T or B_TIMEOUT_T
+ set_level(nearest_level(1));
+ #endif
+ // don't start ramping immediately;
+ // give the user time to release at moon level
+ //if (arg >= HOLD_TIMEOUT) { // smaller
+ if (arg >= (!ramp_style) * HOLD_TIMEOUT) { // more consistent
+ set_state(steady_state, 1);
+ }
+ return MISCHIEF_MANAGED;
+ }
+ // hold, release quickly: go to lowest level (floor)
+ else if (event == EV_click1_hold_release) {
+ set_state(steady_state, 1);
+ return MISCHIEF_MANAGED;
+ }
+ #if (B_TIMING_ON != B_TIMEOUT_T)
+ // 1 click (before timeout): go to memorized level, but allow abort for double click
+ else if (event == EV_click1_release) {
+ #ifdef USE_MANUAL_MEMORY
+ if (manual_memory)
+ set_level(nearest_level(manual_memory));
+ else
+ #endif
+ set_level(nearest_level(memorized_level));
+ return MISCHIEF_MANAGED;
+ }
+ #endif // if (B_TIMING_ON != B_TIMEOUT_T)
+ // 1 click: regular mode
+ else if (event == EV_1click) {
+ #ifdef USE_MANUAL_MEMORY
+ if (manual_memory)
+ set_state(steady_state, manual_memory);
+ else
+ #endif
+ set_state(steady_state, memorized_level);
+ return MISCHIEF_MANAGED;
+ }
+ // click, hold: go to highest level (ceiling) (for ramping down)
+ else if (event == EV_click2_hold) {
+ set_state(steady_state, MAX_LEVEL);
+ return MISCHIEF_MANAGED;
+ }
+ // 2 clicks: highest mode (ceiling)
+ else if (event == EV_2clicks) {
+ set_state(steady_state, MAX_LEVEL);
+ return MISCHIEF_MANAGED;
+ }
+ // 3 clicks (initial press): off, to prep for later events
+ else if (event == EV_click3_press) {
+ set_level(0);
+ return MISCHIEF_MANAGED;
+ }
+ #ifdef USE_BATTCHECK
+ // 3 clicks: battcheck mode / blinky mode group 1
+ else if (event == EV_3clicks) {
+ set_state(battcheck_state, 0);
+ return MISCHIEF_MANAGED;
+ }
+ #endif
+ #ifdef USE_LOCKOUT_MODE
+ // 4 clicks: soft lockout
+ else if (event == EV_4clicks) {
+ blink_confirm(2);
+ set_state(lockout_state, 0);
+ return MISCHIEF_MANAGED;
+ }
+ #endif
+ #if defined(USE_FACTORY_RESET) && defined(USE_SOFT_FACTORY_RESET)
+ // 13 clicks and hold the last click: invoke factory reset (reboot)
+ else if (event == EV_click13_hold) {
+ reboot();
+ return MISCHIEF_MANAGED;
+ }
+ #endif
+ #ifdef USE_VERSION_CHECK
+ // 15+ clicks: show the version number
+ else if (event == EV_15clicks) {
+ set_state(version_check_state, 0);
+ return MISCHIEF_MANAGED;
+ }
+ #endif
+
+ #ifdef USE_SIMPLE_UI
+ // 8 clicks, but hold last click: turn simple UI off
+ else if ((event == EV_click8_hold) && (!arg)) {
+ blink_confirm(1);
+ simple_ui_active = 0;
+ return MISCHIEF_MANAGED;
+ }
+
+ ////////// Every action below here is blocked in the simple UI //////////
+ if (simple_ui_active) {
+ return EVENT_NOT_HANDLED;
+ }
+ // 8 clicks: enable simple UI
+ else if (event == EV_8clicks) {
+ blink_confirm(1);
+ simple_ui_active = 1;
+ return MISCHIEF_MANAGED;
+ }
+ #endif
+
+ // click, click, long-click: strobe mode
+ #ifdef USE_STROBE_STATE
+ else if (event == EV_click3_hold) {
+ set_state(strobe_state, 0);
+ return MISCHIEF_MANAGED;
+ }
+ #elif defined(USE_BORING_STROBE_STATE)
+ else if (event == EV_click3_hold) {
+ set_state(boring_strobe_state, 0);
+ return MISCHIEF_MANAGED;
+ }
+ #endif
+ #ifdef USE_MOMENTARY_MODE
+ // 5 clicks: momentary mode
+ else if (event == EV_5clicks) {
+ blink_confirm(1);
+ set_state(momentary_state, 0);
+ return MISCHIEF_MANAGED;
+ }
+ #endif
+ #ifdef USE_INDICATOR_LED
+ // 7 clicks: change indicator LED mode
+ else if (event == EV_7clicks) {
+ uint8_t mode = (indicator_led_mode & 3) + 1;
+ #ifdef TICK_DURING_STANDBY
+ mode = mode & 3;
+ #else
+ mode = mode % 3;
+ #endif
+ #ifdef INDICATOR_LED_SKIP_LOW
+ if (mode == 1) { mode ++; }
+ #endif
+ indicator_led_mode = (indicator_led_mode & 0b11111100) | mode;
+ indicator_led(mode);
+ save_config();
+ return MISCHIEF_MANAGED;
+ }
+ #elif defined(USE_AUX_RGB_LEDS)
+ // 7 clicks: change RGB aux LED pattern
+ else if (event == EV_7clicks) {
+ uint8_t mode = (rgb_led_off_mode >> 4) + 1;
+ mode = mode % RGB_LED_NUM_PATTERNS;
+ rgb_led_off_mode = (mode << 4) | (rgb_led_off_mode & 0x0f);
+ rgb_led_update(rgb_led_off_mode, 0);
+ save_config();
+ blink_confirm(1);
+ return MISCHIEF_MANAGED;
+ }
+ // 7 clicks (hold last): change RGB aux LED color
+ else if (event == EV_click7_hold) {
+ setting_rgb_mode_now = 1;
+ if (0 == (arg & 0x3f)) {
+ uint8_t mode = (rgb_led_off_mode & 0x0f) + 1;
+ mode = mode % RGB_LED_NUM_COLORS;
+ rgb_led_off_mode = mode | (rgb_led_off_mode & 0xf0);
+ //save_config();
+ }
+ rgb_led_update(rgb_led_off_mode, arg);
+ return MISCHIEF_MANAGED;
+ }
+ else if (event == EV_click7_hold_release) {
+ setting_rgb_mode_now = 0;
+ save_config();
+ return MISCHIEF_MANAGED;
+ }
+ #endif // end 7 clicks
+ #if defined(USE_TENCLICK_THERMAL_CONFIG) && defined(USE_THERMAL_REGULATION)
+ // 10 clicks: thermal config mode
+ else if (event == EV_10clicks) {
+ push_state(thermal_config_state, 0);
+ return MISCHIEF_MANAGED;
+ }
+ #endif
+ return EVENT_NOT_HANDLED;
+}
+
+
+#endif
+
diff --git a/spaghetti-monster/anduril/off-mode.h b/spaghetti-monster/anduril/off-mode.h
new file mode 100644
index 0000000..776173c
--- /dev/null
+++ b/spaghetti-monster/anduril/off-mode.h
@@ -0,0 +1,27 @@
+/*
+ * off-mode.h: "Off" mode for Anduril.
+ *
+ * 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 OFF_MODE_H
+#define OFF_MODE_H
+
+// when the light is "off" or in standby
+uint8_t off_state(Event event, uint16_t arg);
+
+
+#endif
diff --git a/spaghetti-monster/anduril/off-state.c b/spaghetti-monster/anduril/off-state.c
deleted file mode 100644
index 9bbdc81..0000000
--- a/spaghetti-monster/anduril/off-state.c
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- * off-state.c: "Off" state for Anduril.
- *
- * 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 OFF_STATE_C
-#define OFF_STATE_C
-
-#include "off-state.h"
-
-uint8_t off_state(Event event, uint16_t arg) {
- // turn emitter off when entering state
- if (event == EV_enter_state) {
- set_level(0);
- #ifdef USE_INDICATOR_LED
- indicator_led(indicator_led_mode & 0x03);
- #elif defined(USE_AUX_RGB_LEDS)
- rgb_led_update(rgb_led_off_mode, 0);
- #endif
- // sleep while off (lower power use)
- // (unless delay requested; give the ADC some time to catch up)
- if (! arg) { go_to_standby = 1; }
- return MISCHIEF_MANAGED;
- }
- // go back to sleep eventually if we got bumped but didn't leave "off" state
- else if (event == EV_tick) {
- if (arg > HOLD_TIMEOUT) {
- go_to_standby = 1;
- #ifdef USE_INDICATOR_LED
- indicator_led(indicator_led_mode & 0x03);
- #elif defined(USE_AUX_RGB_LEDS)
- rgb_led_update(rgb_led_off_mode, arg);
- #endif
- }
- return MISCHIEF_MANAGED;
- }
- #if defined(TICK_DURING_STANDBY) && (defined(USE_INDICATOR_LED) || defined(USE_AUX_RGB_LEDS))
- // blink the indicator LED, maybe
- else if (event == EV_sleep_tick) {
- #ifdef USE_INDICATOR_LED
- if ((indicator_led_mode & 0b00000011) == 0b00000011) {
- indicator_blink(arg);
- }
- #elif defined(USE_AUX_RGB_LEDS)
- rgb_led_update(rgb_led_off_mode, arg);
- #endif
- return MISCHIEF_MANAGED;
- }
- #endif
- #if (B_TIMING_ON == B_PRESS_T)
- // hold (initially): go to lowest level (floor), but allow abort for regular click
- else if (event == EV_click1_press) {
- set_level(nearest_level(1));
- return MISCHIEF_MANAGED;
- }
- #endif // B_TIMING_ON == B_PRESS_T
- // hold: go to lowest level
- else if (event == EV_click1_hold) {
- #if (B_TIMING_ON == B_PRESS_T)
- #ifdef MOON_TIMING_HINT
- if (arg == 0) {
- // let the user know they can let go now to stay at moon
- blip();
- } else
- #endif
- #else // B_RELEASE_T or B_TIMEOUT_T
- set_level(nearest_level(1));
- #endif
- // don't start ramping immediately;
- // give the user time to release at moon level
- //if (arg >= HOLD_TIMEOUT) { // smaller
- if (arg >= (!ramp_style) * HOLD_TIMEOUT) { // more consistent
- set_state(steady_state, 1);
- }
- return MISCHIEF_MANAGED;
- }
- // hold, release quickly: go to lowest level (floor)
- else if (event == EV_click1_hold_release) {
- set_state(steady_state, 1);
- return MISCHIEF_MANAGED;
- }
- #if (B_TIMING_ON != B_TIMEOUT_T)
- // 1 click (before timeout): go to memorized level, but allow abort for double click
- else if (event == EV_click1_release) {
- #ifdef USE_MANUAL_MEMORY
- if (manual_memory)
- set_level(nearest_level(manual_memory));
- else
- #endif
- set_level(nearest_level(memorized_level));
- return MISCHIEF_MANAGED;
- }
- #endif // if (B_TIMING_ON != B_TIMEOUT_T)
- // 1 click: regular mode
- else if (event == EV_1click) {
- #ifdef USE_MANUAL_MEMORY
- if (manual_memory)
- set_state(steady_state, manual_memory);
- else
- #endif
- set_state(steady_state, memorized_level);
- return MISCHIEF_MANAGED;
- }
- // click, hold: go to highest level (ceiling) (for ramping down)
- else if (event == EV_click2_hold) {
- set_state(steady_state, MAX_LEVEL);
- return MISCHIEF_MANAGED;
- }
- // 2 clicks: highest mode (ceiling)
- else if (event == EV_2clicks) {
- set_state(steady_state, MAX_LEVEL);
- return MISCHIEF_MANAGED;
- }
- // 3 clicks (initial press): off, to prep for later events
- else if (event == EV_click3_press) {
- set_level(0);
- return MISCHIEF_MANAGED;
- }
- #ifdef USE_BATTCHECK
- // 3 clicks: battcheck mode / blinky mode group 1
- else if (event == EV_3clicks) {
- set_state(battcheck_state, 0);
- return MISCHIEF_MANAGED;
- }
- #endif
- #ifdef USE_LOCKOUT_MODE
- // 4 clicks: soft lockout
- else if (event == EV_4clicks) {
- blink_confirm(2);
- set_state(lockout_state, 0);
- return MISCHIEF_MANAGED;
- }
- #endif
- #if defined(USE_FACTORY_RESET) && defined(USE_SOFT_FACTORY_RESET)
- // 13 clicks and hold the last click: invoke factory reset (reboot)
- else if (event == EV_click13_hold) {
- reboot();
- return MISCHIEF_MANAGED;
- }
- #endif
- #ifdef USE_VERSION_CHECK
- // 15+ clicks: show the version number
- else if (event == EV_15clicks) {
- set_state(version_check_state, 0);
- return MISCHIEF_MANAGED;
- }
- #endif
-
- #ifdef USE_SIMPLE_UI
- // 8 clicks, but hold last click: turn simple UI off
- else if ((event == EV_click8_hold) && (!arg)) {
- blink_confirm(1);
- simple_ui_active = 0;
- return MISCHIEF_MANAGED;
- }
-
- ////////// Every action below here is blocked in the simple UI //////////
- if (simple_ui_active) {
- return EVENT_NOT_HANDLED;
- }
- // 8 clicks: enable simple UI
- else if (event == EV_8clicks) {
- blink_confirm(1);
- simple_ui_active = 1;
- return MISCHIEF_MANAGED;
- }
- #endif
-
- // click, click, long-click: strobe mode
- #ifdef USE_STROBE_STATE
- else if (event == EV_click3_hold) {
- set_state(strobe_state, 0);
- return MISCHIEF_MANAGED;
- }
- #elif defined(USE_BORING_STROBE_STATE)
- else if (event == EV_click3_hold) {
- set_state(boring_strobe_state, 0);
- return MISCHIEF_MANAGED;
- }
- #endif
- #ifdef USE_MOMENTARY_MODE
- // 5 clicks: momentary mode
- else if (event == EV_5clicks) {
- blink_confirm(1);
- set_state(momentary_state, 0);
- return MISCHIEF_MANAGED;
- }
- #endif
- #ifdef USE_INDICATOR_LED
- // 7 clicks: change indicator LED mode
- else if (event == EV_7clicks) {
- uint8_t mode = (indicator_led_mode & 3) + 1;
- #ifdef TICK_DURING_STANDBY
- mode = mode & 3;
- #else
- mode = mode % 3;
- #endif
- #ifdef INDICATOR_LED_SKIP_LOW
- if (mode == 1) { mode ++; }
- #endif
- indicator_led_mode = (indicator_led_mode & 0b11111100) | mode;
- indicator_led(mode);
- save_config();
- return MISCHIEF_MANAGED;
- }
- #elif defined(USE_AUX_RGB_LEDS)
- // 7 clicks: change RGB aux LED pattern
- else if (event == EV_7clicks) {
- uint8_t mode = (rgb_led_off_mode >> 4) + 1;
- mode = mode % RGB_LED_NUM_PATTERNS;
- rgb_led_off_mode = (mode << 4) | (rgb_led_off_mode & 0x0f);
- rgb_led_update(rgb_led_off_mode, 0);
- save_config();
- blink_confirm(1);
- return MISCHIEF_MANAGED;
- }
- // 7 clicks (hold last): change RGB aux LED color
- else if (event == EV_click7_hold) {
- setting_rgb_mode_now = 1;
- if (0 == (arg & 0x3f)) {
- uint8_t mode = (rgb_led_off_mode & 0x0f) + 1;
- mode = mode % RGB_LED_NUM_COLORS;
- rgb_led_off_mode = mode | (rgb_led_off_mode & 0xf0);
- //save_config();
- }
- rgb_led_update(rgb_led_off_mode, arg);
- return MISCHIEF_MANAGED;
- }
- else if (event == EV_click7_hold_release) {
- setting_rgb_mode_now = 0;
- save_config();
- return MISCHIEF_MANAGED;
- }
- #endif // end 7 clicks
- #if defined(USE_TENCLICK_THERMAL_CONFIG) && defined(USE_THERMAL_REGULATION)
- // 10 clicks: thermal config mode
- else if (event == EV_10clicks) {
- push_state(thermal_config_state, 0);
- return MISCHIEF_MANAGED;
- }
- #endif
- return EVENT_NOT_HANDLED;
-}
-
-
-#endif
-
diff --git a/spaghetti-monster/anduril/off-state.h b/spaghetti-monster/anduril/off-state.h
deleted file mode 100644
index 2bd7508..0000000
--- a/spaghetti-monster/anduril/off-state.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * off-state.h: "Off" state for Anduril.
- *
- * 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 OFF_STATE_H
-#define OFF_STATE_H
-
-// handles when the light is "off" or in standby
-uint8_t off_state(Event event, uint16_t arg);
-
-
-#endif
--
cgit v1.2.3