diff options
| author | Selene ToyKeeper | 2018-01-04 00:10:42 -0700 |
|---|---|---|
| committer | Selene ToyKeeper | 2018-01-04 00:10:42 -0700 |
| commit | 148b2f04e528a13051fd81c5054a7268e0dc4dac (patch) | |
| tree | 5dd463ebf06d9767afcef6cfe82cce4f9258dcbf | |
| parent | Debouncing finally works (at least, it does on my two test hosts). (diff) | |
| download | anduril-148b2f04e528a13051fd81c5054a7268e0dc4dac.tar.gz anduril-148b2f04e528a13051fd81c5054a7268e0dc4dac.tar.bz2 anduril-148b2f04e528a13051fd81c5054a7268e0dc4dac.zip | |
Made thermal adjustment speed change depending on how far it needs to go.
(faster for large changes, much slower for smaller changes)
(actual thermal behavior not tested yet)
Made lockout mode moon match the current ramp instead of using the lowest of both.
Made ramp-type toggle stop doing gradual adjustments back to the previous ramp's level (I hope).
Added LVP to muggle mode.
| -rw-r--r-- | spaghetti-monster/anduril/anduril.c | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c index 4915b39..40809af 100644 --- a/spaghetti-monster/anduril/anduril.c +++ b/spaghetti-monster/anduril/anduril.c @@ -359,6 +359,12 @@ uint8_t steady_state(EventPtr event, uint16_t arg) { else if (event == EV_3clicks) { ramp_style ^= 1; memorized_level = nearest_level(memorized_level); + #ifdef USE_THERMAL_REGULATION + target_level = memorized_level; + #ifdef USE_SET_LEVEL_GRADUALLY + //set_level_gradually(lvl); + #endif + #endif save_config(); #ifdef START_AT_MEMORIZED_LEVEL save_config_wl(); @@ -482,7 +488,15 @@ uint8_t steady_state(EventPtr event, uint16_t arg) { + 8 - log2(actual_level); } */ - if (!(arg & 7)) gradual_tick(); + uint8_t diff; + if (target_level > actual_level) diff = target_level - actual_level; + else diff = actual_level - target_level; + if (! diff) diff = 1; + uint8_t ticks_per_adjust = (TICKS_PER_SECOND*2) / diff; + if (!(arg % ticks_per_adjust)) gradual_tick(); + + // adjust every N frames + //if (!(arg & 7)) gradual_tick(); //if (!(arg & 3)) gradual_tick(); //gradual_tick(); #endif @@ -766,7 +780,13 @@ uint8_t lockout_state(EventPtr event, uint16_t arg) { if ((last == A_PRESS) || (last == A_HOLD)) { // detect moon level and activate it uint8_t lvl = ramp_smooth_floor; + #ifdef LOCKOUT_MOON_LOWEST + // Use lowest moon configured if (ramp_discrete_floor < lvl) lvl = ramp_discrete_floor; + #else + // Use moon from current ramp + if (ramp_style) lvl = ramp_discrete_floor; + #endif set_level(lvl); } else if ((last == A_RELEASE) || (last == A_RELEASE_TIMEOUT)) { @@ -1226,14 +1246,24 @@ void save_config_wl() { #endif void low_voltage() { + StatePtr state = current_state; + // "step down" from strobe to something low - if (current_state == strobe_state) { + if (state == strobe_state) { set_state(steady_state, RAMP_SIZE/6); } - // in normal mode, step down by half or turn off - else if (current_state == steady_state) { + // in normal or muggle mode, step down by half or turn off + else if ((state == steady_state) || (state == muggle_state)) { if (actual_level > 1) { - set_level((actual_level >> 1) + (actual_level >> 2)); + uint8_t lvl = (actual_level >> 1) + (actual_level >> 2); + set_level(lvl); + #ifdef USE_THERMAL_REGULATION + target_level = lvl; + #ifdef USE_SET_LEVEL_GRADUALLY + // not needed? + //set_level_gradually(lvl); + #endif + #endif } else { set_state(off_state, 0); |
