]> git.tdb.fi Git - r2c2.git/commitdiff
Improve accessory turn-off logic in arducontrol driver
authorMikko Rasa <tdb@tdb.fi>
Sun, 5 Apr 2015 08:50:44 +0000 (11:50 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 5 Apr 2015 08:50:44 +0000 (11:50 +0300)
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

index 8aced3be4ad9d15f137da9a93f38c1e4abf96284..3fc9f577e9cc5106d170f8a4ad586ea24fd8d2fe 100644 (file)
@@ -503,9 +503,11 @@ void ArduControl::tick()
 
        if(active_accessory && off_timeout)
        {
-               bool success = (monitor.get_peak()>0.35f && monitor.get_current()<monitor.get_peak()-0.2f);
+               bool got_peak = monitor.get_peak()>0.0f;
+               bool success = monitor.get_peak()>0.42f;
+               bool complete = (success && monitor.get_current()<monitor.get_peak()-0.2f);
                Time::TimeStamp t = Time::now();
-               if(t>off_timeout || success)
+               if((t>off_timeout && got_peak) || complete)
                {
                        Accessory &acc = *active_accessory;