From bb7e754473aea2083c406b94060b9982c66f7473 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 5 Apr 2015 11:50:44 +0300 Subject: [PATCH] Improve accessory turn-off logic in arducontrol driver In some cases the limit switch won't trigger properly, so we can't rely on the current dropping to determine success. --- source/libr2c2/arducontrol.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/libr2c2/arducontrol.cpp b/source/libr2c2/arducontrol.cpp index 8aced3b..3fc9f57 100644 --- a/source/libr2c2/arducontrol.cpp +++ b/source/libr2c2/arducontrol.cpp @@ -503,9 +503,11 @@ void ArduControl::tick() if(active_accessory && off_timeout) { - bool success = (monitor.get_peak()>0.35f && monitor.get_current()0.0f; + bool success = monitor.get_peak()>0.42f; + bool complete = (success && monitor.get_current()off_timeout || success) + if((t>off_timeout && got_peak) || complete) { Accessory &acc = *active_accessory; -- 2.43.0