FlightModesComponent.cc 2.32 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"
Don Gagne's avatar
Don Gagne committed
16
#include "QGCQmlWidgetHolder.h"
17 18 19 20 21 22

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

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

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

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

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

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

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

55 56
    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
57 58 59 60
        return true;
    }

    return false;
61 62
}

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

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

    return list;
70 71
}

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

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