aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster
diff options
context:
space:
mode:
Diffstat (limited to 'spaghetti-monster')
-rw-r--r--spaghetti-monster/anduril/cfg-sofirn-lt1s-pro.h3
-rw-r--r--spaghetti-monster/anduril/config-mode.c61
-rw-r--r--spaghetti-monster/anduril/config-mode.h31
3 files changed, 46 insertions, 49 deletions
diff --git a/spaghetti-monster/anduril/cfg-sofirn-lt1s-pro.h b/spaghetti-monster/anduril/cfg-sofirn-lt1s-pro.h
index b98eebd..282dca2 100644
--- a/spaghetti-monster/anduril/cfg-sofirn-lt1s-pro.h
+++ b/spaghetti-monster/anduril/cfg-sofirn-lt1s-pro.h
@@ -24,6 +24,9 @@
#define FACTORY_RESET_WARN_CHANNEL CM_RED
#define FACTORY_RESET_SUCCESS_CHANNEL CM_WHITE
+#define CONFIG_WAITING_CHANNEL CM_RED
+#define CONFIG_BLINK_CHANNEL CM_WHITE
+
#define POLICE_COLOR_STROBE_CH1 CM_RED
#define POLICE_COLOR_STROBE_CH2 CM_WHITE
diff --git a/spaghetti-monster/anduril/config-mode.c b/spaghetti-monster/anduril/config-mode.c
index 3af2a1c..a74bdbe 100644
--- a/spaghetti-monster/anduril/config-mode.c
+++ b/spaghetti-monster/anduril/config-mode.c
@@ -1,24 +1,8 @@
-/*
- * config-mode.c: Config mode base functions 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 <http://www.gnu.org/licenses/>.
- */
-
-#ifndef CONFIG_MODE_C
-#define CONFIG_MODE_C
+// config-mode.c: Config mode base functions for Anduril.
+// Copyright (C) 2017-2023 Selene ToyKeeper
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+#pragma once
#include "config-mode.h"
@@ -45,7 +29,13 @@ uint8_t config_state_base(
void (*savefunc)(uint8_t step, uint8_t value)) {
static uint8_t config_step;
+ #ifdef USE_CONFIG_COLORS
+ static uint8_t orig_channel;
+ #endif
if (event == EV_enter_state) {
+ #ifdef USE_CONFIG_COLORS
+ orig_channel = channel_mode;
+ #endif
config_step = 0;
set_level(0);
// if button isn't held, configure first menu item
@@ -62,14 +52,21 @@ uint8_t config_state_base(
#define B_ANY_HOLD_RELEASE (B_CLICK|B_HOLD|B_RELEASE|B_TIMEOUT)
else if ((event & B_CLICK_FLAGS) == B_ANY_HOLD) {
if (config_step <= num_config_steps) {
- if (2 == (arg % (TICKS_PER_SECOND*3/2))) {
+ if ((TICKS_PER_SECOND/10) == (arg % (TICKS_PER_SECOND*3/2))) {
config_step ++;
// blink when config step advances
- if (config_step <= num_config_steps)
+ if (config_step <= num_config_steps) {
+ #ifdef CONFIG_BLINK_CHANNEL
+ set_channel_mode(CONFIG_BLINK_CHANNEL);
+ #endif
set_level(RAMP_SIZE * 3 / 8);
+ }
}
else {
// stay on at a low level to indicate menu is active
+ #ifdef CONFIG_WAITING_CHANNEL
+ set_channel_mode(CONFIG_WAITING_CHANNEL);
+ #endif
set_level(RAMP_SIZE * 1 / 8);
}
} else {
@@ -99,6 +96,13 @@ uint8_t config_state_base(
pop_state();
}
+ #ifdef USE_CONFIG_COLORS
+ else if (event == EV_leave_state) {
+ // put the colors back how they were
+ set_channel_mode(orig_channel);
+ }
+ #endif
+
// eat all other events; don't pass any through to parent
return EVENT_HANDLED;
}
@@ -135,8 +139,11 @@ uint8_t number_entry_state(Event event, uint16_t arg) {
// (flicker every other frame,
// except first frame (so we can see flashes after each click))
else if (arg) {
+ #ifdef CONFIG_WAITING_CHANNEL
+ set_channel_mode(CONFIG_WAITING_CHANNEL);
+ #endif
set_level( (RAMP_SIZE/8)
- + ((arg&2)<<1) );
+ + ((arg&2)<<2) );
}
}
// all done, save result and return to parent state
@@ -159,6 +166,9 @@ uint8_t number_entry_state(Event event, uint16_t arg) {
#endif
number_entry_value ++; // update the result
empty_event_sequence(); // reset FSM's click count
+ #ifdef CONFIG_BLINK_CHANNEL
+ set_channel_mode(CONFIG_BLINK_CHANNEL);
+ #endif
set_level(RAMP_SIZE/2); // flash briefly
return MISCHIEF_MANAGED;
}
@@ -167,6 +177,3 @@ uint8_t number_entry_state(Event event, uint16_t arg) {
return EVENT_HANDLED;
}
-
-#endif
-
diff --git a/spaghetti-monster/anduril/config-mode.h b/spaghetti-monster/anduril/config-mode.h
index 7cbc534..388c0a2 100644
--- a/spaghetti-monster/anduril/config-mode.h
+++ b/spaghetti-monster/anduril/config-mode.h
@@ -1,24 +1,13 @@
-/*
- * config-mode.h: Config mode base functions 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 <http://www.gnu.org/licenses/>.
- */
+// config-mode.h: Config mode base functions for Anduril.
+// Copyright (C) 2017-2023 Selene ToyKeeper
+// SPDX-License-Identifier: GPL-3.0-or-later
-#ifndef CONFIG_MODE_H
-#define CONFIG_MODE_H
+#pragma once
+
+// menus can use 2 colors
+#if defined (CONFIG_WAITING_CHANNEL) || defined(CONFIG_BLINK_CHANNEL)
+#define USE_CONFIG_COLORS
+#endif
// config menu
uint8_t config_state_base(
@@ -28,5 +17,3 @@ uint8_t config_state_base(
void (*savefunc)(uint8_t step, uint8_t value)
);
-
-#endif