PX4RadioComponent.cc 2.18 KB
Newer Older
1 2
/****************************************************************************
 *
Gus Grubba's avatar
Gus Grubba committed
3
 * (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
4 5 6 7 8 9
 *
 * 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
        // The best we can do to detect the need for a radio calibration is look for attitude
        // controls to be mapped.
46
        for(const QString &mapParam : {"RC_MAP_ROLL", "RC_MAP_PITCH", "RC_MAP_YAW", "RC_MAP_THROTTLE"}) {
47
            if (_vehicle->parameterManager()->getParameter(FactSystem::defaultComponentId, mapParam)->rawValue().toInt() == 0) {
48 49
                return false;
            }
50
        }
51
    }
52

53
    return true;
54 55
}

Don Gagne's avatar
Don Gagne committed
56
QStringList PX4RadioComponent::setupCompleteChangedTriggerList(void) const
57
{
58
    return {"COM_RC_IN_MODE", "RC_MAP_ROLL", "RC_MAP_PITCH", "RC_MAP_YAW", "RC_MAP_THROTTLE"};
59 60
}

Don Gagne's avatar
Don Gagne committed
61
QUrl PX4RadioComponent::setupSource(void) const
62
{
63
    return QUrl::fromUserInput("qrc:/qml/RadioComponent.qml");
64 65
}

Don Gagne's avatar
Don Gagne committed
66
QUrl PX4RadioComponent::summaryQmlSource(void) const
67
{
Don Gagne's avatar
Don Gagne committed
68
    return QUrl::fromUserInput("qrc:/qml/PX4RadioComponentSummary.qml");
69
}