aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
If you find this content useful please consider a small donation via bitcoin: bitcoin:1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2?amount=0.001&message=Donation Scraping git contents via cgit is very resource intensive. The continued hosting of these git repositories is entirely financed by your bitcoin contributions. For donations of a least 1 mBTC you include your IP address in the message of your bitcoin donation. This will remove this message in the future for requests from your IP, which will significantly reduce token usage. In any case, any contributions to bitcoin address 1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2 are very welcome. Thanks in advance for you contribution to a self-sustaining ecosystem.