aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster
diff options
context:
space:
mode:
authorSelene ToyKeeper2021-08-31 14:16:38 -0600
committerSelene ToyKeeper2021-08-31 14:16:38 -0600
commitbbdce623e3076f6b0f28526fe38771c894d7adfa (patch)
treef396b6f89b13edf37c5978f4828f7b93ba1824ac /spaghetti-monster
parentadded runtime config option for smooth ramp speed (diff)
downloadanduril-bbdce623e3076f6b0f28526fe38771c894d7adfa.tar.gz
anduril-bbdce623e3076f6b0f28526fe38771c894d7adfa.tar.bz2
anduril-bbdce623e3076f6b0f28526fe38771c894d7adfa.zip
added runtime option to select whether to ramp up after hold-from-off (default) or stay at floor
Diffstat (limited to 'spaghetti-monster')
-rw-r--r--spaghetti-monster/anduril/config-default.h3
-rw-r--r--spaghetti-monster/anduril/load-save-config-fsm.h3
-rw-r--r--spaghetti-monster/anduril/load-save-config.c6
-rw-r--r--spaghetti-monster/anduril/off-mode.c5
-rw-r--r--spaghetti-monster/anduril/ramp-mode.c30
-rw-r--r--spaghetti-monster/anduril/ramp-mode.h13
6 files changed, 49 insertions, 11 deletions
diff --git a/spaghetti-monster/anduril/config-default.h b/spaghetti-monster/anduril/config-default.h
index 1043253..4beb753 100644
--- a/spaghetti-monster/anduril/config-default.h
+++ b/spaghetti-monster/anduril/config-default.h
@@ -71,6 +71,9 @@
// smooth ramp speed: 1, 2, 3, 4, ... for 1X speed, 1/2, 1/3rd, 1/4th, ...
#define USE_RAMP_SPEED_CONFIG
+// add runtime option for whether hold-from-off should ramp or stay at moon
+#define USE_RAMP_AFTER_MOON_OPTION
+
// short blip when crossing from "click" to "hold" from off
// (helps the user hit moon mode exactly, instead of holding too long
// or too short)
diff --git a/spaghetti-monster/anduril/load-save-config-fsm.h b/spaghetti-monster/anduril/load-save-config-fsm.h
index edd4ed5..a6d1281 100644
--- a/spaghetti-monster/anduril/load-save-config-fsm.h
+++ b/spaghetti-monster/anduril/load-save-config-fsm.h
@@ -40,6 +40,9 @@ typedef enum {
simple_ui_steps_e,
simple_ui_active_e,
#endif
+ #ifdef USE_RAMP_AFTER_MOON_OPTION
+ dont_ramp_after_moon_e,
+ #endif
#ifdef USE_MANUAL_MEMORY
manual_memory_e,
#ifdef USE_MANUAL_MEMORY_TIMER
diff --git a/spaghetti-monster/anduril/load-save-config.c b/spaghetti-monster/anduril/load-save-config.c
index 57638d6..f564187 100644
--- a/spaghetti-monster/anduril/load-save-config.c
+++ b/spaghetti-monster/anduril/load-save-config.c
@@ -42,6 +42,9 @@ void load_config() {
ramp_stepss[2] = eeprom[simple_ui_steps_e];
simple_ui_active = eeprom[simple_ui_active_e];
#endif
+ #ifdef USE_RAMP_AFTER_MOON_OPTION
+ dont_ramp_after_moon = eeprom[dont_ramp_after_moon_e];
+ #endif
#ifdef USE_MANUAL_MEMORY
manual_memory = eeprom[manual_memory_e];
#ifdef USE_MANUAL_MEMORY_TIMER
@@ -111,6 +114,9 @@ void save_config() {
eeprom[simple_ui_steps_e] = ramp_stepss[2];
eeprom[simple_ui_active_e] = simple_ui_active;
#endif
+ #ifdef USE_RAMP_AFTER_MOON_OPTION
+ eeprom[dont_ramp_after_moon_e] = dont_ramp_after_moon;
+ #endif
#ifdef USE_MANUAL_MEMORY
eeprom[manual_memory_e] = manual_memory;
#ifdef USE_MANUAL_MEMORY_TIMER
diff --git a/spaghetti-monster/anduril/off-mode.c b/spaghetti-monster/anduril/off-mode.c
index 6faad1c..bf4642c 100644
--- a/spaghetti-monster/anduril/off-mode.c
+++ b/spaghetti-monster/anduril/off-mode.c
@@ -106,6 +106,11 @@ uint8_t off_state(Event event, uint16_t arg) {
#else // B_RELEASE_T or B_TIMEOUT_T
set_level(nearest_level(1));
#endif
+ #ifdef USE_RAMP_AFTER_MOON_OPTION
+ if (dont_ramp_after_moon) {
+ return MISCHIEF_MANAGED;
+ }
+ #endif
// don't start ramping immediately;
// give the user time to release at moon level
//if (arg >= HOLD_TIMEOUT) { // smaller
diff --git a/spaghetti-monster/anduril/ramp-mode.c b/spaghetti-monster/anduril/ramp-mode.c
index 2508d52..634d8f2 100644
--- a/spaghetti-monster/anduril/ramp-mode.c
+++ b/spaghetti-monster/anduril/ramp-mode.c
@@ -419,9 +419,9 @@ uint8_t steady_state(Event event, uint16_t arg) {
return MISCHIEF_MANAGED;
}
else if (event == EV_click10_hold) {
- #ifdef USE_MANUAL_MEMORY_TIMER
- // let user configure timer for manual / hybrid memory
- push_state(manual_memory_timer_config_state, 0);
+ #ifdef USE_RAMP_EXTRAS_CONFIG
+ // let user configure a bunch of extra ramp options
+ push_state(ramp_extras_config_state, 0);
#else // manual mem, but no timer
// turn off manual memory; go back to automatic
if (0 == arg) {
@@ -479,19 +479,31 @@ uint8_t simple_ui_config_state(Event event, uint16_t arg) {
#endif
#endif // #ifdef USE_RAMP_CONFIG
-#ifdef USE_MANUAL_MEMORY_TIMER
-void manual_memory_timer_config_save(uint8_t step, uint8_t value) {
+#ifdef USE_RAMP_EXTRAS_CONFIG
+void ramp_extras_config_save(uint8_t step, uint8_t value) {
// item 1: disable manual memory, go back to automatic
- if (step == 1) { manual_memory = 0; }
+ if (1 == step) { manual_memory = 0; }
+
+ #ifdef USE_MANUAL_MEMORY_TIMER
// item 2: set manual memory timer duration
// FIXME: should be limited to (65535 / SLEEP_TICKS_PER_MINUTE)
// to avoid overflows or impossibly long timeouts
// (by default, the effective limit is 145, but it allows up to 255)
- else { manual_memory_timer = value; }
+ else if (2 == step) { manual_memory_timer = value; }
+ #endif
+
+ #ifdef USE_RAMP_AFTER_MOON_OPTION
+ // item 3: ramp up after hold-from-off for moon?
+ // 0 = yes, ramp after moon
+ // 1+ = no, stay at moon
+ else if (3 == step) {
+ dont_ramp_after_moon = value;
+ }
+ #endif
}
-uint8_t manual_memory_timer_config_state(Event event, uint16_t arg) {
- return config_state_base(event, arg, 2, manual_memory_timer_config_save);
+uint8_t ramp_extras_config_state(Event event, uint16_t arg) {
+ return config_state_base(event, arg, 3, ramp_extras_config_save);
}
#endif
diff --git a/spaghetti-monster/anduril/ramp-mode.h b/spaghetti-monster/anduril/ramp-mode.h
index 7c8b014..7ad244a 100644
--- a/spaghetti-monster/anduril/ramp-mode.h
+++ b/spaghetti-monster/anduril/ramp-mode.h
@@ -127,8 +127,11 @@ uint8_t simple_ui_config_state(Event event, uint16_t arg);
#endif
#endif
-#if defined(USE_MANUAL_MEMORY) && defined(USE_MANUAL_MEMORY_TIMER)
-uint8_t manual_memory_timer_config_state(Event event, uint16_t arg);
+#if defined(USE_MANUAL_MEMORY_TIMER) || defined(USE_RAMP_AFTER_MOON_OPTION) || defined(USE_2C_STYLE_OPTION) || defined(USE_AUTO_SUNSET)
+#define USE_RAMP_EXTRAS_CONFIG
+#endif
+#ifdef USE_RAMP_EXTRAS_CONFIG
+uint8_t ramp_extras_config_state(Event event, uint16_t arg);
#endif
// calculate the nearest ramp level which would be valid at the moment
@@ -171,6 +174,12 @@ uint8_t ramp_style = RAMP_STYLE; // 0 = smooth, 1 = discrete
#ifdef USE_RAMP_SPEED_CONFIG
#define ramp_speed (ramp_stepss[0])
#endif
+#ifdef USE_RAMP_AFTER_MOON_OPTION
+#ifndef DEFAULT_DONT_RAMP_AFTER_MOON
+#define DEFAULT_DONT_RAMP_AFTER_MOON 0
+#endif
+uint8_t dont_ramp_after_moon = DEFAULT_DONT_RAMP_AFTER_MOON;
+#endif
// current values, regardless of style
uint8_t ramp_floor = RAMP_SMOOTH_FLOOR;
uint8_t ramp_ceil = RAMP_SMOOTH_CEIL;
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.