aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSelene ToyKeeper2019-06-02 00:51:53 -0600
committerSelene ToyKeeper2019-06-02 00:51:53 -0600
commitfd75cddc425f13a96071e723392b60d894100088 (patch)
tree9f712f0feacca299b32e14fe1e55357242641b62
parentenabled manual memory option by default (diff)
downloadanduril-fd75cddc425f13a96071e723392b60d894100088.tar.gz
anduril-fd75cddc425f13a96071e723392b60d894100088.tar.bz2
anduril-fd75cddc425f13a96071e723392b60d894100088.zip
added compile option to configure response timing on 1-click on/off (at press, at release, or at event timeout), changed default from press-on to release-on
(but release-off is funky and annoying so it's still not default)
-rw-r--r--spaghetti-monster/anduril/anduril.c89
1 files changed, 71 insertions, 18 deletions
diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c
index 0fa5340..dffa981 100644
--- a/spaghetti-monster/anduril/anduril.c
+++ b/spaghetti-monster/anduril/anduril.c
@@ -31,7 +31,7 @@
// 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)
-#define MOON_TIMING_HINT
+#define MOON_TIMING_HINT // only applies if B_TIMING_ON == B_PRESS_T
// short blips while ramping
#define BLINK_AT_RAMP_MIDDLE
//#define BLINK_AT_RAMP_FLOOR
@@ -204,6 +204,24 @@ typedef enum {
#include "spaghetti-monster.h"
+// configure the timing of turning on/off in regular ramp mode
+// press: react as soon as the button is pressed
+#define B_PRESS_T 0
+// release: react as soon as the button is released
+#define B_RELEASE_T 1
+// timeout: react as soon as we're sure the user isn't doing a double-click
+#define B_TIMEOUT_T 2
+// defaults are release on, timeout off
+#ifndef B_TIMING_ON
+//#define B_TIMING_ON B_PRESS_T
+#define B_TIMING_ON B_RELEASE_T
+#endif
+#ifndef B_TIMING_OFF
+//#define B_TIMING_OFF B_RELEASE_T
+#define B_TIMING_OFF B_TIMEOUT_T
+#endif
+
+
// FSM states
uint8_t off_state(Event event, uint16_t arg);
// simple numeric entry config menu
@@ -449,19 +467,25 @@ uint8_t off_state(Event event, uint16_t arg) {
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
@@ -475,6 +499,7 @@ uint8_t off_state(Event event, uint16_t arg) {
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
@@ -485,6 +510,7 @@ uint8_t off_state(Event event, uint16_t arg) {
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
@@ -585,6 +611,11 @@ uint8_t steady_state(Event event, uint16_t arg) {
#ifdef USE_REVERSING
static int8_t ramp_direction = 1;
#endif
+ #if (B_TIMING_OFF == B_RELEASE_T)
+ // if the user double clicks, we need to abort turning off,
+ // and this stores the level to return to
+ static uint8_t level_before_off = 0;
+ #endif
if (ramp_style) {
mode_min = ramp_discrete_floor;
mode_max = ramp_discrete_ceil;
@@ -612,6 +643,25 @@ uint8_t steady_state(Event event, uint16_t arg) {
#endif
return MISCHIEF_MANAGED;
}
+ #if (B_TIMING_OFF == B_RELEASE_T)
+ // 1 click (early): off, if configured for early response
+ else if (event == EV_click1_release) {
+ level_before_off = actual_level;
+ #ifdef USE_THERMAL_REGULATION
+ target_level = 0;
+ #endif
+ set_level(0);
+ return MISCHIEF_MANAGED;
+ }
+ // 2 clicks (early): abort turning off, if configured for early response
+ else if (event == EV_click2_press) {
+ #ifdef USE_THERMAL_REGULATION
+ target_level = level_before_off;
+ #endif
+ set_level(level_before_off);
+ return MISCHIEF_MANAGED;
+ }
+ #endif // if (B_TIMING_OFF == B_RELEASE_T)
// 1 click: off
else if (event == EV_1click) {
set_state(off_state, 0);
@@ -831,26 +881,29 @@ uint8_t steady_state(Event event, uint16_t arg) {
else {
diff = actual_level - gradual_target;
}
- uint8_t magnitude = 0;
- #ifndef THERM_HARD_TURBO_DROP
- // if we're on a really high mode, drop faster
- if (actual_level >= THERM_FASTER_LEVEL) { magnitude ++; }
- #endif
- while (diff) {
- magnitude ++;
- diff >>= 1;
- }
- uint8_t ticks_per_adjust = intervals[magnitude];
- if (ticks_since_adjust > ticks_per_adjust)
- {
- gradual_tick();
- ticks_since_adjust = 0;
+ // if there's any adjustment to be made, make it
+ if (diff) {
+ uint8_t magnitude = 0;
+ #ifndef THERM_HARD_TURBO_DROP
+ // if we're on a really high mode, drop faster
+ if (actual_level >= THERM_FASTER_LEVEL) { magnitude ++; }
+ #endif
+ while (diff) {
+ magnitude ++;
+ diff >>= 1;
+ }
+ uint8_t ticks_per_adjust = intervals[magnitude];
+ if (ticks_since_adjust > ticks_per_adjust)
+ {
+ gradual_tick();
+ ticks_since_adjust = 0;
+ }
+ //if (!(arg % ticks_per_adjust)) gradual_tick();
}
- //if (!(arg % ticks_per_adjust)) gradual_tick();
#ifdef THERM_HARD_TURBO_DROP
}
#endif
- #endif
+ #endif // ifdef USE_SET_LEVEL_GRADUALLY
return MISCHIEF_MANAGED;
}
#endif
@@ -901,7 +954,7 @@ uint8_t steady_state(Event event, uint16_t arg) {
}
return MISCHIEF_MANAGED;
}
- #endif
+ #endif // ifdef USE_THERMAL_REGULATION
return EVENT_NOT_HANDLED;
}
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.