PX4RadioComponent.cc 2.34 KB
Newer Older
1 2 3 4 5 6 7 8 9
/****************************************************************************
 *
 *   (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.
 *
 ****************************************************************************/

10

Don Gagne's avatar
Don Gagne committed
11
#include "PX4RadioComponent.h"
Don Gagne's avatar
Don Gagne committed
12
#include "PX4AutoPilotPlugin.h"
13

Don Gagne's avatar
Don Gagne committed
14
PX4RadioComponent::PX4RadioComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) :
15
    VehicleComponent(vehicle, autopilot, parent),
16 17 18 19
    _name(tr("Radio"))
{
}

Don Gagne's avatar
Don Gagne committed
20
QString PX4RadioComponent::name(void) const
21 22 23 24
{
    return _name;
}

Don Gagne's avatar
Don Gagne committed
25
QString PX4RadioComponent::description(void) const
26
{
27 28
    return tr("Radio Setup is used to calibrate your transmitter. "
              "It also assign channels for Roll, Pitch, Yaw and Throttle vehicle control as well as determining whether they are reversed.");
29 30
}

Don Gagne's avatar
Don Gagne committed
31
QString PX4RadioComponent::iconResource(void) const
32
{
33
    return "/qmlimages/RadioComponentIcon.png";
34 35
}

Don Gagne's avatar
Don Gagne committed
36
bool PX4RadioComponent::requiresSetup(void) const
37
{
38
    return _vehicle->parameterManager()->getParameter(-1, "COM_RC_IN_MODE")->rawValue().toInt() == 1 ? false : true;
39 40
}

Don Gagne's avatar
Don Gagne committed
41
bool PX4RadioComponent::setupComplete(void) const
42
{
43
    if (_vehicle->parameterManager()->getParameter(-1, "COM_RC_IN_MODE")->rawValue().toInt() != 1) {
44 45 46 47
        // The best we can do to detect the need for a radio calibration is look for attitude
        // controls to be mapped.
        QStringList attitudeMappings;
        attitudeMappings << "RC_MAP_ROLL" << "RC_MAP_PITCH" << "RC_MAP_YAW" << "RC_MAP_THROTTLE";
48
        foreach(const QString &mapParam, attitudeMappings) {
49
            if (_vehicle->parameterManager()->getParameter(FactSystem::defaultComponentId, mapParam)->rawValue().toInt() == 0) {
50 51
                return false;
            }
52
        }
53
    }
54 55
    
    return true;
56 57
}

Don Gagne's avatar
Don Gagne committed
58
QStringList PX4RadioComponent::setupCompleteChangedTriggerList(void) const
59
{
Don Gagne's avatar
Don Gagne committed
60 61
    QStringList triggers;
    
Don Gagne's avatar
Don Gagne committed
62
    triggers << "COM_RC_IN_MODE" << "RC_MAP_ROLL" << "RC_MAP_PITCH" << "RC_MAP_YAW" << "RC_MAP_THROTTLE";
Don Gagne's avatar
Don Gagne committed
63 64
    
    return triggers;
65 66
}

Don Gagne's avatar
Don Gagne committed
67
QUrl PX4RadioComponent::setupSource(void) const
68
{
69
    return QUrl::fromUserInput("qrc:/qml/RadioComponent.qml");
70 71
}

Don Gagne's avatar
Don Gagne committed
72
QUrl PX4RadioComponent::summaryQmlSource(void) const
73
{
Don Gagne's avatar
Don Gagne committed
74
    return QUrl::fromUserInput("qrc:/qml/PX4RadioComponentSummary.qml");
75
}