From cd5efd61d30da3f14733c43caf2595863618fc1a Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Sun, 31 Aug 2014 15:51:19 +0200 Subject: [PATCH] OP-1458 Increase the update for the accessory channels --- .../src/plugins/config/configinputwidget.cpp | 33 +++++++++++++------ .../src/plugins/config/configinputwidget.h | 7 +++- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp index 9bdf7b6dc..3d6df59fc 100644 --- a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp @@ -395,6 +395,10 @@ void ConfigInputWidget::goToWizard() flightModeSettingsData.Arming = FlightModeSettings::ARMING_ALWAYSDISARMED; flightModeSettingsObj->setData(flightModeSettingsData); + accessoryDesiredObj0 = AccessoryDesired::GetInstance(getObjectManager(), 0); + accessoryDesiredObj1 = AccessoryDesired::GetInstance(getObjectManager(), 1); + accessoryDesiredObj2 = AccessoryDesired::GetInstance(getObjectManager(), 2); + // Use faster input update rate. fastMdata(); @@ -633,12 +637,9 @@ void ConfigInputWidget::wizardSetUpStep(enum wizardSteps step) break; case wizardIdentifyLimits: { - accessoryDesiredObj0 = AccessoryDesired::GetInstance(getObjectManager(), 0); - accessoryDesiredObj1 = AccessoryDesired::GetInstance(getObjectManager(), 1); - accessoryDesiredObj2 = AccessoryDesired::GetInstance(getObjectManager(), 2); setTxMovement(nothing); ui->wzText->setText(QString(tr("Please move all controls to their maximum extents on both directions.\n\nPress Next when ready."))); - manualSettingsData = manualSettingsObj->getData(); + manualSettingsData = manualSettingsObj->getData(); for (uint i = 0; i < ManualControlSettings::CHANNELMAX_NUMELEM; ++i) { // Preserve the inverted status if (manualSettingsData.ChannelMin[i] <= manualSettingsData.ChannelMax[i]) { @@ -766,16 +767,27 @@ void ConfigInputWidget::wizardTearDownStep(enum wizardSteps step) } } +static void fastMdataSingle(UAVDataObject *object, UAVObject::Metadata *savedMdata) +{ + *savedMdata = object->getMetadata(); + UAVObject::Metadata mdata = *savedMdata; + UAVObject::SetFlightTelemetryUpdateMode(mdata, UAVObject::UPDATEMODE_PERIODIC); + mdata.flightTelemetryUpdatePeriod = 150; + object->setMetadata(mdata); +} + +static void restoreMdataSingle(UAVDataObject *object, UAVObject::Metadata *savedMdata) +{ + object->setMetadata(*savedMdata); +} + /** * Set manual control command to fast updates */ void ConfigInputWidget::fastMdata() { - manualControlMdata = manualCommandObj->getMetadata(); - UAVObject::Metadata mdata = manualControlMdata; - UAVObject::SetFlightTelemetryUpdateMode(mdata, UAVObject::UPDATEMODE_PERIODIC); - mdata.flightTelemetryUpdatePeriod = 150; - manualCommandObj->setMetadata(mdata); + fastMdataSingle(manualCommandObj, &manualControlMdata); + fastMdataSingle(accessoryDesiredObj0, &accessoryDesiredMdata0); } /** @@ -783,7 +795,8 @@ void ConfigInputWidget::fastMdata() */ void ConfigInputWidget::restoreMdata() { - manualCommandObj->setMetadata(manualControlMdata); + restoreMdataSingle(manualCommandObj, &manualControlMdata); + restoreMdataSingle(accessoryDesiredObj0, &accessoryDesiredMdata0); } /** diff --git a/ground/openpilotgcs/src/plugins/config/configinputwidget.h b/ground/openpilotgcs/src/plugins/config/configinputwidget.h index 4d046ca85..7261b1956 100644 --- a/ground/openpilotgcs/src/plugins/config/configinputwidget.h +++ b/ground/openpilotgcs/src/plugins/config/configinputwidget.h @@ -96,20 +96,25 @@ private: QList heliChannelOrder; QList acroChannelOrder; + UAVObject::Metadata manualControlMdata; ManualControlCommand *manualCommandObj; ManualControlCommand::DataFields manualCommandData; + FlightStatus *flightStatusObj; FlightStatus::DataFields flightStatusData; + + UAVObject::Metadata accessoryDesiredMdata0; AccessoryDesired *accessoryDesiredObj0; AccessoryDesired *accessoryDesiredObj1; AccessoryDesired *accessoryDesiredObj2; AccessoryDesired::DataFields accessoryDesiredData0; AccessoryDesired::DataFields accessoryDesiredData1; AccessoryDesired::DataFields accessoryDesiredData2; - UAVObject::Metadata manualControlMdata; + ManualControlSettings *manualSettingsObj; ManualControlSettings::DataFields manualSettingsData; ManualControlSettings::DataFields previousManualSettingsData; + FlightModeSettings *flightModeSettingsObj; FlightModeSettings::DataFields flightModeSettingsData; FlightModeSettings::DataFields previousFlightModeSettingsData;