From a8d90974e239c780ec65e4b376169773ae337afc Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Wed, 13 May 2015 17:50:18 -0700 Subject: [PATCH] Improve usability --- src/AutoPilotPlugins/PX4/SensorsComponent.qml | 62 ++++++------------- .../PX4/SensorsComponentController.cc | 9 +++ src/QmlControls/QGCView.qml | 4 +- 3 files changed, 31 insertions(+), 44 deletions(-) diff --git a/src/AutoPilotPlugins/PX4/SensorsComponent.qml b/src/AutoPilotPlugins/PX4/SensorsComponent.qml index 781542203..eb6abfdf0 100644 --- a/src/AutoPilotPlugins/PX4/SensorsComponent.qml +++ b/src/AutoPilotPlugins/PX4/SensorsComponent.qml @@ -46,6 +46,8 @@ QGCView { readonly property string accelHelp: "For Accelerometer calibration you will need to place your vehicle on all six sides and hold it still in each orientation for a few seconds." readonly property string airspeedHelp: "For Airspeed calibration you will need to keep your airspeed sensor out of any wind and then blow across the sensor." + readonly property string statusTextAreaDefaultText: compassHelp + "\n\n" + gyroHelp + "\n\n" + accelHelp + "\n\n" + airspeedHelp + "\n\n" + // Used to pass what type of calibration is being performed to the preCalibrationDialog property string preCalibrationDialogType @@ -83,12 +85,28 @@ QGCView { "ROTATION_ROLL_270_YAW_270" ] + Fact { id: cal_mag0_id; name: "CAL_MAG0_ID"; onFactMissing: showMissingFactOverlay(name) } + Fact { id: cal_mag1_id; name: "CAL_MAG1_ID"; onFactMissing: showMissingFactOverlay(name) } + Fact { id: cal_mag2_id; name: "CAL_MAG2_ID"; onFactMissing: showMissingFactOverlay(name) } + Fact { id: cal_mag0_rot; name: "CAL_MAG0_ROT"; onFactMissing: showMissingFactOverlay(name) } + Fact { id: cal_mag1_rot; name: "CAL_MAG1_ROT"; onFactMissing: showMissingFactOverlay(name) } + Fact { id: cal_mag2_rot; name: "CAL_MAG2_ROT"; onFactMissing: showMissingFactOverlay(name) } + + // Id > = signals compass available, rot < 0 signals internal compass + property bool showCompass0Rot: cal_mag0_id.value > 0 && cal_mag0_rot.value >= 0 + property bool showCompass1Rot: cal_mag1_id.value > 0 && cal_mag1_rot.value >= 0 + property bool showCompass2Rot: cal_mag2_id.value > 0 && cal_mag2_rot.value >= 0 + SensorsComponentController { - id: controller + id: controller onResetStatusTextArea: statusLog.text = statusTextAreaDefaultText - onSetCompassRotations: showDialog(compassRotationDialogComponent, "Set Compass Rotation(s)", 50, StandardButton.Ok) + onSetCompassRotations: { + if (showCompass0Rot || showCompass1Rot || showCompass2Rot) { + showDialog(compassRotationDialogComponent, "Set Compass Rotation(s)", 50, StandardButton.Ok) + } + } onWaitingForCancelChanged: { if (controller.waitingForCancel) { @@ -243,53 +261,13 @@ QGCView { } } - SensorsComponentController { - id: controller - - onResetStatusTextArea: statusTextArea.text = statusTextAreaDefaultText - - onSetCompassRotations: showCompassRotationOverlay() - - onWaitingForCancelChanged: { - if (controller.waitingForCancel) { - showMessage("Calibration Cancel", "Waiting for Vehicle to response to Cancel. This may take a few seconds.", 0) - } else { - hideDialog() - } - } - } - QGCPalette { id: qgcPal; colorGroupEnabled: enabled } - readonly property string statusTextAreaDefaultText: "For Compass calibration you will need to rotate your vehicle through a number of positions. For this calibration is is best " + - "to be connected to your vehicle via radio instead of USB since the USB cable will likely get in the way.\n\n" + - "For Gyroscope calibration you will need to place your vehicle right side up on solid surface and leave it still.\n\n" + - "For Accelerometer calibration you will need to place your vehicle on all six sides and hold it still there for a few seconds.\n\n" + - "For Airspeed calibration you will need to keep your airspeed sensor out of any wind and then blow across the sensor.\n\n" - - Fact { id: cal_mag0_id; name: "CAL_MAG0_ID" } - Fact { id: cal_mag1_id; name: "CAL_MAG1_ID" } - Fact { id: cal_mag2_id; name: "CAL_MAG2_ID" } - Fact { id: cal_mag0_rot; name: "CAL_MAG0_ROT" } - Fact { id: cal_mag1_rot; name: "CAL_MAG1_ROT" } - Fact { id: cal_mag2_rot; name: "CAL_MAG2_ROT" } - - // Id > = signals compass available, rot < 0 signals internal compass - property bool showCompass0Rot: cal_mag0_id.value > 0 && cal_mag0_rot.value >= 0 - property bool showCompass1Rot: cal_mag1_id.value > 0 && cal_mag1_rot.value >= 0 - property bool showCompass2Rot: cal_mag2_id.value > 0 && cal_mag2_rot.value >= 0 color: qgcPal.window - function showCompassRotationOverlay() { - if (showCompass0Rot || showCompass1Rot || showCompass2Rot) { - compassRotationOverlay.visible = true - overlay.visible = true - } - } - Column { anchors.fill: parent diff --git a/src/AutoPilotPlugins/PX4/SensorsComponentController.cc b/src/AutoPilotPlugins/PX4/SensorsComponentController.cc index e170e904e..c22b2f570 100644 --- a/src/AutoPilotPlugins/PX4/SensorsComponentController.cc +++ b/src/AutoPilotPlugins/PX4/SensorsComponentController.cc @@ -392,6 +392,15 @@ void SensorsComponentController::_handleUASTextMessage(int uasId, int compId, in void SensorsComponentController::_refreshParams(void) { + QStringList fastRefreshList; + + // We ask for a refresh on these first so that the rotation combo show up as fast as possible + fastRefreshList << "CAL_MAG0_ID" << "CAL_MAG1_ID" << "CAL_MAG2_ID" << "CAL_MAG0_ROT" << "CAL_MAG1_ROT" << "CAL_MAG2_ROT"; + foreach (QString paramName, fastRefreshList) { + _autopilot->refreshParameter(FactSystem::defaultComponentId, paramName); + } + + // Now ask for all to refresh _autopilot->refreshParametersPrefix(FactSystem::defaultComponentId, "CAL_"); _autopilot->refreshParametersPrefix(FactSystem::defaultComponentId, "SENS_"); } diff --git a/src/QmlControls/QGCView.qml b/src/QmlControls/QGCView.qml index d225fc4d7..2fd8e97a3 100644 --- a/src/QmlControls/QGCView.qml +++ b/src/QmlControls/QGCView.qml @@ -34,7 +34,7 @@ import QGroundControl.ScreenTools 1.0 import QGroundControl.FactSystem 1.0 import QGroundControl.FactControls 1.0 -Item { +FactPanel { id: __rootItem property Component viewComponent @@ -164,7 +164,7 @@ Item { Connections { target: __dialogComponentLoader.item - onHideDialog: __hideDialog() + onHideDialog: __rootItem.hideDialog() } Loader { -- 2.22.0