aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSelene ToyKeeper2019-05-25 16:02:00 -0600
committerSelene ToyKeeper2019-05-25 16:02:00 -0600
commit8a10d804fe32e1215789dd3d55275979689fbee5 (patch)
treedf5df6ed9c2c582947408bb9fd1b98f232470d8d
parentD4S actually steps down a bit too fast, so... minimize that (diff)
downloadanduril-8a10d804fe32e1215789dd3d55275979689fbee5.tar.gz
anduril-8a10d804fe32e1215789dd3d55275979689fbee5.tar.bz2
anduril-8a10d804fe32e1215789dd3d55275979689fbee5.zip
Added a compile-time option for manual memory.
(as opposed to the automatic memory it uses by default) 5 clicks while on: enable manual memory and save the current level 5 clicks and hold the last press: turn manual memory off, go back to automatic
Diffstat (limited to '')
-rw-r--r--spaghetti-monster/anduril/anduril.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c
index f9509e7..8e801bc 100644
--- a/spaghetti-monster/anduril/anduril.c
+++ b/spaghetti-monster/anduril/anduril.c
@@ -77,6 +77,9 @@
// dual-switch support (second switch is a tail clicky)
//#define START_AT_MEMORIZED_LEVEL
+// add a "manual memory" function (as opposed to the default automatic memory)
+//#define USE_MANUAL_MEMORY
+
/***** specific settings for known driver types *****/
#include "tk.h"
#include incfile(CONFIGFILE)
@@ -145,6 +148,9 @@ typedef enum {
ramp_discrete_ceil_e,
ramp_discrete_steps_e,
#endif
+ #ifdef USE_MANUAL_MEMORY
+ manual_memory_e,
+ #endif
#ifdef USE_TINT_RAMPING
tint_e,
#endif
@@ -316,6 +322,9 @@ void save_config_wl();
#define DEFAULT_LEVEL MAX_1x7135
#endif
uint8_t memorized_level = DEFAULT_LEVEL;
+#ifdef USE_MANUAL_MEMORY
+uint8_t manual_memory = 0;
+#endif
// smooth vs discrete ramping
volatile uint8_t ramp_style = RAMP_STYLE; // 0 = smooth, 1 = discrete
volatile uint8_t ramp_smooth_floor = RAMP_SMOOTH_FLOOR;
@@ -464,11 +473,21 @@ uint8_t off_state(Event event, uint16_t arg) {
}
// 1 click (before timeout): go to memorized level, but allow abort for double click
else if (event == EV_click1_release) {
+ #ifdef USE_MANUAL_MEMORY
+ if (manual_memory)
+ set_level(nearest_level(manual_memory));
+ else
+ #endif
set_level(nearest_level(memorized_level));
return MISCHIEF_MANAGED;
}
// 1 click: regular mode
else if (event == EV_1click) {
+ #ifdef USE_MANUAL_MEMORY
+ if (manual_memory)
+ set_state(steady_state, manual_memory);
+ else
+ #endif
set_state(steady_state, memorized_level);
return MISCHIEF_MANAGED;
}
@@ -763,6 +782,20 @@ uint8_t steady_state(Event event, uint16_t arg) {
return MISCHIEF_MANAGED;
}
#endif
+ #ifdef USE_MANUAL_MEMORY
+ else if (event == EV_5clicks) {
+ manual_memory = actual_level;
+ save_config();
+ blip();
+ }
+ else if (event == EV_click5_hold) {
+ if (0 == arg) {
+ manual_memory = 0;
+ save_config();
+ blip();
+ }
+ }
+ #endif
#if defined(USE_SET_LEVEL_GRADUALLY) || defined(USE_REVERSING)
else if (event == EV_tick) {
#ifdef USE_REVERSING
@@ -2074,6 +2107,9 @@ void load_config() {
ramp_discrete_ceil = eeprom[ramp_discrete_ceil_e];
ramp_discrete_steps = eeprom[ramp_discrete_steps_e];
#endif
+ #ifdef USE_MANUAL_MEMORY
+ manual_memory = eeprom[manual_memory_e];
+ #endif
#ifdef USE_TINT_RAMPING
tint = eeprom[tint_e];
#endif
@@ -2115,6 +2151,9 @@ void save_config() {
eeprom[ramp_discrete_ceil_e] = ramp_discrete_ceil;
eeprom[ramp_discrete_steps_e] = ramp_discrete_steps;
#endif
+ #ifdef USE_MANUAL_MEMORY
+ eeprom[manual_memory_e] = manual_memory;
+ #endif
#ifdef USE_TINT_RAMPING
eeprom[tint_e] = tint;
#endif
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.