Skip to content

Commit 213893e

Browse files
mindneverf5soh
authored andcommitted
Merged in mindnever/librepilot/LP-525-GCS_Hardware_pages_for_F3_boards (pull request #455)
Add GCS Hardware pages for F3 boards Approved-by: Mateusz Kaduk <mateusz.kaduk@gmail.com> Approved-by: Vladimir Zidar <mr_w@mindnever.org> Approved-by: Lalanne Laurent <f5soh@free.fr> Approved-by: Philippe Renon <philippe_renon@yahoo.fr>
2 parents 8935906 + 8b61e7b commit 213893e

17 files changed

Lines changed: 2683 additions & 928 deletions

flight/targets/boards/pikoblx/firmware/pios_board.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,9 @@ void PIOS_Board_Init(void)
221221
}
222222

223223
#ifdef PIOS_INCLUDE_PPM
224-
PIOS_BOARD_IO_Configure_PPM_RCVR(&pios_ppm_cfg);
224+
if (boardHwSettings.PPMPort == HWPIKOBLXSETTINGS_PPMPORT_ENABLED) {
225+
PIOS_BOARD_IO_Configure_PPM_RCVR(&pios_ppm_cfg);
226+
}
225227
#endif
226228

227229
#ifdef PIOS_INCLUDE_GCSRCVR
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
/**
2+
******************************************************************************
3+
*
4+
* @file commonhwsettingswidget.cpp
5+
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017.
6+
* @addtogroup GCSPlugins GCS Plugins
7+
* @{
8+
* @addtogroup ConfigPlugin Config Plugin
9+
* @{
10+
* @brief Common hardware configuration panel
11+
*****************************************************************************/
12+
/*
13+
* This program is free software; you can redistribute it and/or modify
14+
* it under the terms of the GNU General Public License as published by
15+
* the Free Software Foundation; either version 3 of the License, or
16+
* (at your option) any later version.
17+
*
18+
* This program is distributed in the hope that it will be useful, but
19+
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20+
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21+
* for more details.
22+
*
23+
* You should have received a copy of the GNU General Public License along
24+
* with this program; if not, write to the Free Software Foundation, Inc.,
25+
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26+
*/
27+
#include "commonhwsettingswidget.h"
28+
#include "ui_commonhwsettingswidget.h"
29+
#include "hwsettings.h"
30+
31+
#include <QDebug>
32+
#include <extensionsystem/pluginmanager.h>
33+
#include "uavobjectmanager.h"
34+
35+
36+
CommonHWSettingsWidget::CommonHWSettingsWidget(QWidget *parent) : ConfigTaskWidget(parent, Child)
37+
{
38+
m_ui = new Ui_CommonHWSettingsWidget();
39+
m_ui->setupUi(this);
40+
41+
m_ui->cbDSMxBind->addItem(tr("Disabled"), 0);
42+
43+
setFeatures(0);
44+
45+
// Relay signals from private members
46+
connect(m_ui->cbUSBHID, SIGNAL(currentIndexChanged(int)), this, SIGNAL(USBHIDFunctionChanged(int)));
47+
connect(m_ui->cbUSBVCP, SIGNAL(currentIndexChanged(int)), this, SIGNAL(USBVCPFunctionChanged(int)));
48+
49+
// And these are here to handle conflicting VCP & HID options (such as USBTelemetry).
50+
connect(m_ui->cbUSBHID, SIGNAL(currentIndexChanged(int)), this, SLOT(USBHIDComboChanged(int)));
51+
connect(m_ui->cbUSBVCP, SIGNAL(currentIndexChanged(int)), this, SLOT(USBVCPComboChanged(int)));
52+
}
53+
54+
CommonHWSettingsWidget::~CommonHWSettingsWidget()
55+
{
56+
delete m_ui;
57+
}
58+
59+
void CommonHWSettingsWidget::registerWidgets(ConfigTaskWidget &ct)
60+
{
61+
ct.addWidgetBinding("HwSettings", "USB_HIDPort", m_ui->cbUSBHID);
62+
ct.addWidgetBinding("HwSettings", "USB_VCPPort", m_ui->cbUSBVCP);
63+
64+
ct.addWidgetBinding("HwSettings", "TelemetrySpeed", m_ui->cbTelemetrySpeed);
65+
ct.addWidgetBinding("HwSettings", "GPSSpeed", m_ui->cbGPSSpeed);
66+
ct.addWidgetBinding("HwSettings", "DebugConsoleSpeed", m_ui->cbDebugConsoleSpeed);
67+
ct.addWidgetBinding("HwSettings", "SBusMode", m_ui->cbSBUSMode);
68+
69+
ct.addWidgetBinding("HwSettings", "DSMxBind", m_ui->cbDSMxBind, 0, 1, true);
70+
71+
ct.addWidgetBinding("GPSSettings", "DataProtocol", m_ui->cbGPSProtocol);
72+
}
73+
74+
void CommonHWSettingsWidget::refreshWidgetsValues(UAVObject *obj)
75+
{
76+
Q_UNUSED(obj);
77+
78+
int option = HwSettings::GetInstance(getObjectManager())->getDSMxBind();
79+
80+
if (m_ui->cbDSMxBind->count() == 0) {
81+
m_ui->cbDSMxBind->addItem(tr("None"), 0);
82+
m_ui->cbDSMxBind->addItem(tr("DSM2 1024bit/22ms"), 3);
83+
m_ui->cbDSMxBind->addItem(tr("DSM2 2048bit/11ms"), 5);
84+
m_ui->cbDSMxBind->addItem(tr("DSMX 1024bit/22ms"), 7);
85+
m_ui->cbDSMxBind->addItem(tr("DSMX 2048bit/22ms"), 8);
86+
m_ui->cbDSMxBind->addItem(tr("DSMX 2048bit/11ms"), 9);
87+
}
88+
89+
int index = m_ui->cbDSMxBind->findData(option);
90+
91+
if (index == -1) {
92+
m_ui->cbDSMxBind->addItem(tr("%1 Pulses").arg(option), option);
93+
m_ui->cbDSMxBind->setCurrentIndex(m_ui->cbDSMxBind->count() - 1);
94+
} else {
95+
m_ui->cbDSMxBind->setCurrentIndex(index);
96+
}
97+
}
98+
99+
void CommonHWSettingsWidget::setFeatures(quint32 features)
100+
{
101+
bool flag = features != 0;
102+
103+
setVisible(flag);
104+
105+
flag = (features & F_USB) != 0;
106+
107+
m_ui->lbUSBHID->setVisible(flag);
108+
m_ui->cbUSBHID->setVisible(flag);
109+
m_ui->lbUSBVCP->setVisible(flag);
110+
m_ui->cbUSBVCP->setVisible(flag);
111+
112+
flag = (features & F_SBUS) != 0;
113+
114+
m_ui->lbSBUSMode->setVisible(flag);
115+
m_ui->cbSBUSMode->setVisible(flag);
116+
117+
flag = (features & F_DSM) != 0;
118+
119+
m_ui->lbDSMxBind->setVisible(flag);
120+
m_ui->cbDSMxBind->setVisible(flag);
121+
122+
flag = (features & F_TELEMETRY) != 0;
123+
124+
m_ui->lbTelemetrySpeed->setVisible(flag);
125+
m_ui->cbTelemetrySpeed->setVisible(flag);
126+
127+
flag = (features & F_DEBUGCONSOLE) != 0;
128+
129+
m_ui->lbDebugConsoleSpeed->setVisible(flag);
130+
m_ui->cbDebugConsoleSpeed->setVisible(flag);
131+
132+
flag = (features & F_GPS) != 0;
133+
134+
m_ui->lbGPSSpeed->setVisible(flag);
135+
m_ui->cbGPSSpeed->setVisible(flag);
136+
m_ui->lbGPSProtocol->setVisible(flag);
137+
m_ui->cbGPSProtocol->setVisible(flag);
138+
}
139+
140+
QComboBox *CommonHWSettingsWidget::USBVCPComboBox()
141+
{
142+
return m_ui->cbUSBVCP;
143+
}
144+
145+
bool CommonHWSettingsWidget::USBFunctionConflict()
146+
{
147+
return (getComboboxSelectedOption(m_ui->cbUSBHID) == HwSettings::USB_HIDPORT_USBTELEMETRY)
148+
&& (getComboboxSelectedOption(m_ui->cbUSBVCP) == HwSettings::USB_VCPPORT_USBTELEMETRY);
149+
}
150+
151+
void CommonHWSettingsWidget::USBHIDComboChanged(int index)
152+
{
153+
Q_UNUSED(index);
154+
155+
if (USBFunctionConflict()) {
156+
setComboboxSelectedOption(m_ui->cbUSBVCP, HwSettings::USB_VCPPORT_DISABLED);
157+
} else if (getComboboxSelectedOption(m_ui->cbUSBHID) != HwSettings::USB_HIDPORT_USBTELEMETRY) {
158+
setComboboxSelectedOption(m_ui->cbUSBVCP, HwSettings::USB_VCPPORT_USBTELEMETRY);
159+
}
160+
}
161+
162+
void CommonHWSettingsWidget::USBVCPComboChanged(int index)
163+
{
164+
Q_UNUSED(index);
165+
166+
if (USBFunctionConflict()) {
167+
setComboboxSelectedOption(m_ui->cbUSBHID, HwSettings::USB_HIDPORT_DISABLED);
168+
} else if (getComboboxSelectedOption(m_ui->cbUSBVCP) != HwSettings::USB_VCPPORT_USBTELEMETRY) {
169+
setComboboxSelectedOption(m_ui->cbUSBHID, HwSettings::USB_HIDPORT_USBTELEMETRY);
170+
}
171+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/**
2+
******************************************************************************
3+
*
4+
* @file commonhwsettingswidget.h
5+
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017.
6+
* @addtogroup GCSPlugins GCS Plugins
7+
* @{
8+
* @addtogroup ConfigPlugin Config Plugin
9+
* @{
10+
* @brief Common hardware configuration panel
11+
*****************************************************************************/
12+
/*
13+
* This program is free software; you can redistribute it and/or modify
14+
* it under the terms of the GNU General Public License as published by
15+
* the Free Software Foundation; either version 3 of the License, or
16+
* (at your option) any later version.
17+
*
18+
* This program is distributed in the hope that it will be useful, but
19+
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20+
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21+
* for more details.
22+
*
23+
* You should have received a copy of the GNU General Public License along
24+
* with this program; if not, write to the Free Software Foundation, Inc.,
25+
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26+
*/
27+
#ifndef COMMONHWSETTINGSWIDGET_H
28+
#define COMMONHWSETTINGSWIDGET_H
29+
30+
#include "../uavobjectwidgetutils/configtaskwidget.h"
31+
32+
class Ui_CommonHWSettingsWidget;
33+
34+
class CommonHWSettingsWidget : public ConfigTaskWidget {
35+
Q_OBJECT
36+
37+
public:
38+
static const quint32 F_USB = (1 << 0);
39+
static const quint32 F_SBUS = (1 << 1);
40+
static const quint32 F_DSM = (1 << 2);
41+
static const quint32 F_TELEMETRY = (1 << 3);
42+
static const quint32 F_DEBUGCONSOLE = (1 << 4);
43+
static const quint32 F_GPS = (1 << 5);
44+
45+
CommonHWSettingsWidget(QWidget *parent = 0);
46+
virtual ~CommonHWSettingsWidget();
47+
48+
void registerWidgets(ConfigTaskWidget &ct);
49+
void refreshWidgetsValues(UAVObject *obj);
50+
51+
void setFeatures(quint32 features);
52+
53+
QComboBox *USBVCPComboBox();
54+
55+
signals:
56+
void USBHIDFunctionChanged(int index);
57+
void USBVCPFunctionChanged(int index);
58+
59+
private slots:
60+
void USBHIDComboChanged(int index);
61+
void USBVCPComboChanged(int index);
62+
63+
private:
64+
Ui_CommonHWSettingsWidget *m_ui;
65+
66+
bool USBFunctionConflict();
67+
};
68+
69+
#endif // COMMONHWSETTINGSWIDGET_H

0 commit comments

Comments
 (0)