aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSelene ToyKeeper2020-07-31 21:37:48 -0600
committerSelene ToyKeeper2020-07-31 21:37:48 -0600
commit54e7b0208f2ee83a4db1a363c67d4c8302e91ee4 (patch)
treebf6fe6ec35e5d2efeb3a420f5fee838ae96c7187
parentadded a voltage calibration / correction function, 7C from battcheck to confi... (diff)
downloadanduril-54e7b0208f2ee83a4db1a363c67d4c8302e91ee4.tar.gz
anduril-54e7b0208f2ee83a4db1a363c67d4c8302e91ee4.tar.bz2
anduril-54e7b0208f2ee83a4db1a363c67d4c8302e91ee4.zip
made simple UI's ramp configurable, and fixed bug where it wouldn't remember if simple UI was enabled
-rw-r--r--spaghetti-monster/anduril/off-mode.c13
-rw-r--r--spaghetti-monster/anduril/ramp-mode.c15
-rw-r--r--spaghetti-monster/anduril/ramp-mode.h3
3 files changed, 23 insertions, 8 deletions
diff --git a/spaghetti-monster/anduril/off-mode.c b/spaghetti-monster/anduril/off-mode.c
index 9218752..4977d6b 100644
--- a/spaghetti-monster/anduril/off-mode.c
+++ b/spaghetti-monster/anduril/off-mode.c
@@ -176,10 +176,16 @@ uint8_t off_state(Event event, uint16_t arg) {
#endif
#ifdef USE_SIMPLE_UI
- // 8 clicks, but hold last click: turn simple UI off
+ // 8 clicks, but hold last click: turn simple UI off (or configure it)
else if ((event == EV_click8_hold) && (!arg)) {
- blink_confirm(1);
- simple_ui_active = 0;
+ if (simple_ui_active) { // turn off simple UI
+ blink_confirm(1);
+ simple_ui_active = 0;
+ save_config();
+ }
+ else { // configure simple UI ramp
+ push_state(simple_ui_config_state, 0);
+ }
return MISCHIEF_MANAGED;
}
@@ -191,6 +197,7 @@ uint8_t off_state(Event event, uint16_t arg) {
else if (event == EV_8clicks) {
blink_confirm(1);
simple_ui_active = 1;
+ save_config();
return MISCHIEF_MANAGED;
}
#endif
diff --git a/spaghetti-monster/anduril/ramp-mode.c b/spaghetti-monster/anduril/ramp-mode.c
index 5ca5dbb..23f2ad4 100644
--- a/spaghetti-monster/anduril/ramp-mode.c
+++ b/spaghetti-monster/anduril/ramp-mode.c
@@ -429,8 +429,9 @@ uint8_t steady_state(Event event, uint16_t arg) {
void ramp_config_save() {
// parse values
uint8_t val;
+ // 0 = smooth ramp, 1 = stepped ramp, 2 = simple UI's ramp
uint8_t style = ramp_style;
- // TODO: detect if we're configuring the simple UI
+ if (current_state == simple_ui_config_state) style = 2;
val = config_state_values[0];
if (val) { ramp_floors[style] = val; }
@@ -438,20 +439,24 @@ void ramp_config_save() {
val = config_state_values[1];
if (val) { ramp_ceils[style] = MAX_LEVEL + 1 - val; }
- if (ramp_style) { // discrete / stepped ramp
+ if (style) { // smooth ramp has no third value
val = config_state_values[2];
if (val) ramp_stepss[style] = val;
}
}
uint8_t ramp_config_state(Event event, uint16_t arg) {
- uint8_t num_config_steps;
- num_config_steps = 2 + ramp_style;
+ uint8_t num_config_steps = ramp_style + 2;
return config_state_base(event, arg,
num_config_steps, ramp_config_save);
}
-#endif // #ifdef USE_RAMP_CONFIG
+#ifdef USE_SIMPLE_UI
+uint8_t simple_ui_config_state(Event event, uint16_t arg) {
+ return config_state_base(event, arg, 3, ramp_config_save);
+}
+#endif
+#endif // #ifdef USE_RAMP_CONFIG
// find the ramp level closest to the target,
// using only the levels which are allowed in the current state
diff --git a/spaghetti-monster/anduril/ramp-mode.h b/spaghetti-monster/anduril/ramp-mode.h
index 03fd381..7d3d138 100644
--- a/spaghetti-monster/anduril/ramp-mode.h
+++ b/spaghetti-monster/anduril/ramp-mode.h
@@ -121,6 +121,9 @@ uint8_t steady_state(Event event, uint16_t arg);
#ifdef USE_RAMP_CONFIG
uint8_t ramp_config_state(Event event, uint16_t arg);
void ramp_config_save();
+#ifdef USE_SIMPLE_UI
+uint8_t simple_ui_config_state(Event event, uint16_t arg);
+#endif
#endif
// calculate the nearest ramp level which would be valid at the moment