FlightModesComponent.cc 2.29 KB
Newer Older
1 2 3 4 5 6 7 8
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
9

10 11 12 13 14

/// @file
///     @author Don Gagne <don@thegagnes.com>

#include "FlightModesComponent.h"
Don Gagne's avatar
Don Gagne committed
15
#include "PX4AutoPilotPlugin.h"
16 17 18 19 20 21

struct SwitchListItem {
    const char* param;
    const char* name;
};

22
FlightModesComponent::FlightModesComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) :
23
    VehicleComponent(vehicle, autopilot, parent),
24 25 26 27 28 29 30 31 32 33 34
    _name(tr("Flight Modes"))
{
}

QString FlightModesComponent::name(void) const
{
    return _name;
}

QString FlightModesComponent::description(void) const
{
35
    return tr("Flight Modes Setup is used to configure the transmitter switches associated with Flight Modes.");
36 37
}

38
QString FlightModesComponent::iconResource(void) const
39
{
40
    return "/qmlimages/FlightModesComponentIcon.png";
41 42 43 44
}

bool FlightModesComponent::requiresSetup(void) const
{
45
    return _vehicle->parameterManager()->getParameter(-1, "COM_RC_IN_MODE")->rawValue().toInt() == 1 ? false : true;
46 47 48 49
}

bool FlightModesComponent::setupComplete(void) const
{
50
    if (_vehicle->parameterManager()->getParameter(-1, "COM_RC_IN_MODE")->rawValue().toInt() == 1) {
Don Gagne's avatar
Don Gagne committed
51 52 53
        return true;
    }

54 55
    if (_vehicle->parameterManager()->getParameter(FactSystem::defaultComponentId, "RC_MAP_MODE_SW")->rawValue().toInt() != 0 ||
            (_vehicle->parameterManager()->parameterExists(FactSystem::defaultComponentId, "RC_MAP_FLTMODE") && _vehicle->parameterManager()->getParameter(FactSystem::defaultComponentId, "RC_MAP_FLTMODE")->rawValue().toInt() != 0)) {
Don Gagne's avatar
Don Gagne committed
56 57 58 59
        return true;
    }

    return false;
60 61
}

Don Gagne's avatar
Don Gagne committed
62
QStringList FlightModesComponent::setupCompleteChangedTriggerList(void) const
63
{
Don Gagne's avatar
Don Gagne committed
64 65 66 67 68
    QStringList list;

    list << QStringLiteral("RC_MAP_MODE_SW") << QStringLiteral("RC_MAP_FLTMODE");

    return list;
69 70
}

71
QUrl FlightModesComponent::setupSource(void) const
72
{
Don Gagne's avatar
Don Gagne committed
73
    return QUrl::fromUserInput("qrc:/qml/PX4FlightModes.qml");
74 75
}

76
QUrl FlightModesComponent::summaryQmlSource(void) const
77
{
78
    return QUrl::fromUserInput("qrc:/qml/FlightModesComponentSummary.qml");
79
}