From 23624919ab9410de47adc56fb38c894cd5032490 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Fri, 22 May 2015 11:42:49 -0700 Subject: [PATCH] Better handling of battery already connected warning --- src/AutoPilotPlugins/PX4/PowerComponent.qml | 1 + src/AutoPilotPlugins/PX4/PowerComponentController.cc | 7 +++++++ src/AutoPilotPlugins/PX4/PowerComponentController.h | 1 + 3 files changed, 9 insertions(+) diff --git a/src/AutoPilotPlugins/PX4/PowerComponent.qml b/src/AutoPilotPlugins/PX4/PowerComponent.qml index f0c1b68..a02c801 100644 --- a/src/AutoPilotPlugins/PX4/PowerComponent.qml +++ b/src/AutoPilotPlugins/PX4/PowerComponent.qml @@ -110,6 +110,7 @@ QGCView { onCalibrationFailed: showMessage("ESC Calibration failed", errorMessage, StandardButton.Ok) onCalibrationSuccess: showMessage("ESC Calibration", "Calibration complete. You can disconnect your battery now if you like.", StandardButton.Ok) onConnectBattery: showMessage("ESC Calibration", "WARNING: Props must be removed from vehicle prior to performing ESC calibration.\n\nConnect the battery now and calibration will begin.", 0) + onDisconnectBattery: showMessage("ESC Calibration failed", "You must disconnect the battery prior to performing ESC Calibration. Disconnect your battery and try again.", , StandardButton.Ok) } Column { diff --git a/src/AutoPilotPlugins/PX4/PowerComponentController.cc b/src/AutoPilotPlugins/PX4/PowerComponentController.cc index 4b2c076..ce17b81 100644 --- a/src/AutoPilotPlugins/PX4/PowerComponentController.cc +++ b/src/AutoPilotPlugins/PX4/PowerComponentController.cc @@ -105,8 +105,15 @@ void PowerComponentController::_handleUASTextMessage(int uasId, int compId, int return; } + QString failedPrefix("calibration failed: "); if (text.startsWith(failedPrefix)) { + QString failureText = text.right(text.length() - failedPrefix.length()); + if (failureText.startsWith("Disconnect battery")) { + emit disconnectBattery(); + return; + } + _stopCalibration(); emit calibrationFailed(text.right(text.length() - failedPrefix.length())); return; diff --git a/src/AutoPilotPlugins/PX4/PowerComponentController.h b/src/AutoPilotPlugins/PX4/PowerComponentController.h index 3c77045..0b99874 100644 --- a/src/AutoPilotPlugins/PX4/PowerComponentController.h +++ b/src/AutoPilotPlugins/PX4/PowerComponentController.h @@ -49,6 +49,7 @@ signals: void newerFirmware(void); void incorrectFirmwareRevReporting(void); void connectBattery(void); + void disconnectBattery(void); void batteryConnected(void); void calibrationFailed(const QString& errorMessage); void calibrationSuccess(const QStringList& warningMessages);