From eeed7a62ee7dea0fa0f1ccabc5e58b380d1adcb7 Mon Sep 17 00:00:00 2001
From: Willian Galvani <williangalvani@gmail.com>
Date: Wed, 11 Sep 2019 13:08:34 -0300
Subject: [PATCH 1/2] Add timeout field  to motorTest() call in
 APMSubMotorComponent.qml

This is a bugfix due to changed signature in 3089da58b4d6ddab9daf74f6a0a095fde36357ef
---
 src/AutoPilotPlugins/APM/APMSubMotorComponent.qml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/AutoPilotPlugins/APM/APMSubMotorComponent.qml b/src/AutoPilotPlugins/APM/APMSubMotorComponent.qml
index 609e0c3..f824487 100644
--- a/src/AutoPilotPlugins/APM/APMSubMotorComponent.qml
+++ b/src/AutoPilotPlugins/APM/APMSubMotorComponent.qml
@@ -212,9 +212,9 @@ SetupPage {
                             var reversed = controller.getParameterFact(-1, "MOT_" + (_lastIndex + 1) + "_DIRECTION").value == -1
 
                             if (reversed) {
-                                controller.vehicle.motorTest(_lastIndex, 100 - slider.motorSlider.value)
+                                controller.vehicle.motorTest(_lastIndex, 100 - slider.motorSlider.value, 0)
                             } else {
-                                controller.vehicle.motorTest(_lastIndex, slider.motorSlider.value)
+                                controller.vehicle.motorTest(_lastIndex, slider.motorSlider.value, 0)
                             }
                     }
                 }

From 20ed1f6996108be5624a88e7222a45528638438e Mon Sep 17 00:00:00 2001
From: Willian Galvani <williangalvani@gmail.com>
Date: Wed, 11 Sep 2019 13:10:19 -0300
Subject: [PATCH 2/2] Add cooldown to Sub motor test page

---
 src/AutoPilotPlugins/APM/APMSubMotorComponent.qml | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/src/AutoPilotPlugins/APM/APMSubMotorComponent.qml b/src/AutoPilotPlugins/APM/APMSubMotorComponent.qml
index f824487..5be9015 100644
--- a/src/AutoPilotPlugins/APM/APMSubMotorComponent.qml
+++ b/src/AutoPilotPlugins/APM/APMSubMotorComponent.qml
@@ -168,6 +168,8 @@ SetupPage {
                     onToggled: {
                         if (controller.vehicle.armed) {
                             timer.stop()
+                            enabled = false
+                            coolDownTimer.start()
                         }
 
                         controller.vehicle.armed = checked
@@ -183,6 +185,8 @@ SetupPage {
                         safetySwitch.checked = armed
                             if (!armed) {
                                 timer.stop()
+                                safetySwitch.enabled = false
+                                coolDownTimer.start()
                             } else {
                                 timer.start()
                             }
@@ -198,7 +202,14 @@ SetupPage {
                     text:   qsTr("Slide this switch to arm the vehicle and enable the motor test (CAUTION!)")
                 }
             } // Row
-
+            Row {
+                QGCLabel {
+                    id: cooldownLabel
+                    visible: coolDownTimer.running
+                    color:  qgcPal.warningText
+                    text:   qsTr("A 10 second coooldown is required before testing again, please stand by...")
+                }
+            }
             // Repeats the command signal and updates the checkbox every 50 ms
             Timer {
                 id: timer
@@ -219,6 +230,15 @@ SetupPage {
                     }
                 }
             }
+            Timer {
+                id: coolDownTimer
+                interval:       11000
+                repeat:         false
+
+                onTriggered: {
+                    safetySwitch.enabled = true
+                }
+            }
         } // Column
     } // Component
 } // SetupPahe