aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSelene ToyKeeper2019-03-29 10:34:27 -0600
committerSelene ToyKeeper2019-03-29 10:34:27 -0600
commit8991713b7209dd030ada252b19af5d536c5f07f7 (patch)
tree58be3722414c28560630c414f78651a4ace60ef2
parentmerged from trunk (diff)
downloadanduril-8991713b7209dd030ada252b19af5d536c5f07f7.tar.gz
anduril-8991713b7209dd030ada252b19af5d536c5f07f7.tar.bz2
anduril-8991713b7209dd030ada252b19af5d536c5f07f7.zip
fixed bug: hold-from-off then release and hold failed in stepped ramp
(was necessary to wait 1 second before it'd ramp the right way) (reported by maukka)
-rw-r--r--spaghetti-monster/anduril/anduril.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c
index 93f8c16..88aafbb 100644
--- a/spaghetti-monster/anduril/anduril.c
+++ b/spaghetti-monster/anduril/anduril.c
@@ -624,9 +624,13 @@ uint8_t steady_state(Event event, uint16_t arg) {
return MISCHIEF_MANAGED;
}
#ifdef USE_REVERSING
- // make it ramp down instead, if already at max
- if ((arg <= 1) && (actual_level >= mode_max)) {
- ramp_direction = -1;
+ // fix ramp direction on first frame if necessary
+ if (!arg) {
+ // make it ramp down instead, if already at max
+ if (actual_level >= mode_max) { ramp_direction = -1; }
+ // make it ramp up if already at min
+ // (off->hold->stepped_min->release causes this state)
+ else if (actual_level <= mode_min) { ramp_direction = 1; }
}
memorized_level = nearest_level((int16_t)actual_level \
+ (ramp_step_size * ramp_direction));