Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions src/AutoPilotPlugins/PX4/AM32Component.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/****************************************************************************
*
* (c) 2009-2024 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.
*
****************************************************************************/

#include "AM32Component.h"
#include "Vehicle.h"

AM32Component::AM32Component(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent)
: VehicleComponent(vehicle, autopilot, AutoPilotPlugin::UnknownVehicleComponent, parent)
, _name(tr("AM32 ESC"))
{
}

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

QString AM32Component::description(void) const
{
return tr("AM32 ESC Setup is used to configure AM32 ESC settings.");
}

QString AM32Component::iconResource(void) const
{
return "/qmlimages/EscIndicator.svg";
}

bool AM32Component::requiresSetup(void) const
{
return false;
}

bool AM32Component::setupComplete(void) const
{
return true;
}

QStringList AM32Component::setupCompleteChangedTriggerList(void) const
{
return QStringList();
}

QUrl AM32Component::setupSource(void) const
{
return QUrl::fromUserInput("qrc:/qml/QGroundControl/AutoPilotPlugins/PX4/AM32Component.qml");
}

QUrl AM32Component::summaryQmlSource(void) const
{
return QUrl::fromUserInput("qrc:/qml/QGroundControl/AutoPilotPlugins/PX4/AM32ComponentSummary.qml");
}
36 changes: 36 additions & 0 deletions src/AutoPilotPlugins/PX4/AM32Component.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/****************************************************************************
*
* (c) 2009-2024 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.
*
****************************************************************************/

#pragma once

#include "VehicleComponent.h"

class AM32Component : public VehicleComponent
{
Q_OBJECT

public:
AM32Component(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = nullptr);

// Overrides from VehicleComponent
QStringList setupCompleteChangedTriggerList(void) const override;

// Overrides from VehicleComponent
QString name (void) const override;
QString description (void) const override;
QString iconResource (void) const override;
bool requiresSetup (void) const override;
bool setupComplete (void) const override;
QUrl setupSource (void) const override;
QUrl summaryQmlSource (void) const override;
bool allowSetupWhileArmed (void) const override { return true; }

private:
const QString _name;
};
35 changes: 35 additions & 0 deletions src/AutoPilotPlugins/PX4/AM32Component.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/****************************************************************************
*
* (c) 2009-2024 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.
*
****************************************************************************/

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts

import QGroundControl
import QGroundControl.FactControls
import QGroundControl.Controls
import QGroundControl.AutoPilotPlugins.PX4

SetupPage {
id: am32Page
pageComponent: pageComponent

Component {
id: pageComponent

Item {
width: availableWidth
height: availableHeight

AM32SettingsComponent {
anchors.fill: parent
}
}
}
}
45 changes: 45 additions & 0 deletions src/AutoPilotPlugins/PX4/AM32ComponentSummary.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/****************************************************************************
*
* (c) 2009-2024 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.
*
****************************************************************************/

import QtQuick
import QtQuick.Controls

import QGroundControl
import QGroundControl.FactControls
import QGroundControl.Controls

Item {
anchors.fill: parent

property var vehicle: globals.activeVehicle

Column {
anchors.fill: parent

VehicleSummaryRow {
labelText: qsTr("ESCs Detected")
valueText: vehicle && vehicle.am32eeproms ? vehicle.am32eeproms.count : qsTr("None")
}

VehicleSummaryRow {
labelText: qsTr("AM32 Support")
valueText: {
if (vehicle && vehicle.am32eeproms && vehicle.am32eeproms.count > 0) {
return qsTr("Available")
}
return qsTr("Unavailable")
}
}

VehicleSummaryRow {
labelText: qsTr("Status")
valueText: vehicle && vehicle.am32eeproms && vehicle.am32eeproms.count > 0 ? qsTr("Ready") : qsTr("Not Connected")
}
}
}
33 changes: 33 additions & 0 deletions src/AutoPilotPlugins/PX4/AM32EscMatchDots.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import QtQuick
import QGroundControl

Row {
id: root

required property string settingName
required property var eeproms

anchors.right: parent.right
anchors.top: parent.top
anchors.margins: 4
spacing: 2
visible: eeproms && eeproms.count > 1

Repeater {
model: root.eeproms ? root.eeproms : null

Rectangle {
property var esc: object
property var setting: esc ? esc.settings[root.settingName] : null

width: 8
height: 8
radius: 4
color: {
if (!esc || !esc.dataLoaded) return qgcPal.colorGrey
if (!setting) return qgcPal.colorGrey
return setting.matchesMajority ? qgcPal.colorGreen : qgcPal.colorRed
}
}
}
}
17 changes: 17 additions & 0 deletions src/AutoPilotPlugins/PX4/AM32SettingCheckbox.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import QtQuick
import QGroundControl.Controls

QGCCheckBox {
required property var firstEeprom
required property var updateSetting

property string label: ""
property string settingName: ""
property var setting: firstEeprom ? firstEeprom.settings[settingName] : null

visible: setting && firstEeprom && firstEeprom.isSettingAvailable(settingName)
text: label + (setting && setting.hasPendingChanges ? " *" : "")
checked: setting ? setting.fact.rawValue != 0 : false
textColor: setting && setting.hasPendingChanges ? qgcPal.colorOrange : (setting && !setting.allMatch ? qgcPal.colorRed : qgcPal.text)
onClicked: updateSetting(settingName, checked)
}
92 changes: 92 additions & 0 deletions src/AutoPilotPlugins/PX4/AM32SettingSlider.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import QtQuick
import QtQuick.Controls
import QGroundControl
import QGroundControl.Controls

Column {
id: control

property string label: ""
property var setting: null

property var fact: setting ? setting.fact : null
property real value: fact ? fact.rawValue : 0

property real from: fact ? fact.min : 0
property real to: fact ? fact.max : 100
// fact.increment may be NaN if not set - default to 1
property real stepSize: (fact && !isNaN(fact.increment)) ? fact.increment : 1
property int decimalPlaces: fact ? fact.decimalPlaces : 0
property bool enabled: true

signal userValueChanged(real newValue)

spacing: ScreenTools.defaultFontPixelHeight / 4

QGCLabel {
text: label + (setting && setting.hasPendingChanges ? " *" : "")
color: setting && setting.hasPendingChanges ? qgcPal.colorOrange : qgcPal.text
anchors.horizontalCenter: parent.horizontalCenter
}

Slider {
id: slider
width: ScreenTools.defaultFontPixelWidth * 28
from: parent.from
to: parent.to
value: parent.value
stepSize: parent.stepSize
snapMode: Slider.SnapAlways
enabled: parent.enabled

onMoved: control.userValueChanged(value)
onPressedChanged: if (!pressed) value = Qt.binding(function() { return control.value })

// Visual handle
handle: Rectangle {
x: slider.leftPadding + slider.visualPosition * (slider.availableWidth - width)
y: slider.topPadding + slider.availableHeight / 2 - height / 2
implicitWidth: ScreenTools.defaultFontPixelHeight
implicitHeight: implicitWidth
radius: width / 2
color: slider.pressed ? qgcPal.buttonHighlight : qgcPal.button
border.color: qgcPal.text
}

// Value display
ToolTip {
parent: slider.handle
visible: slider.pressed
text: slider.value.toFixed(decimalPlaces)
}

// Slider fill direction (left to right)
background: Rectangle {
x: slider.leftPadding
y: slider.topPadding + slider.availableHeight / 2 - height / 2
implicitWidth: 200
implicitHeight: 4
width: slider.availableWidth
height: implicitHeight
radius: 2
color: qgcPal.window
border.color: qgcPal.text
border.width: 1

// Progress fill from left to right
Rectangle {
width: slider.visualPosition * parent.width
height: parent.height
color: qgcPal.text
radius: parent.radius
}
}
}

// Value label
QGCLabel {
text: value.toFixed(decimalPlaces)
anchors.horizontalCenter: parent.horizontalCenter
font.pointSize: ScreenTools.smallFontPointSize
}
}
Loading
Loading