Refactor setup hardware, trainer and calibration
This commit is contained in:
@@ -3,16 +3,18 @@ include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
||||
set(generaledit_NAMES
|
||||
generaledit
|
||||
generalsetup
|
||||
trainer
|
||||
hardware
|
||||
)
|
||||
|
||||
set(generaledit_SRCS
|
||||
calibration.cpp
|
||||
hardware.cpp
|
||||
trainer.cpp
|
||||
)
|
||||
|
||||
set(generaledit_HDRS
|
||||
calibration.h
|
||||
hardware.h
|
||||
trainer.h
|
||||
)
|
||||
|
||||
set(generaledit_UIS
|
||||
|
||||
@@ -18,93 +18,45 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QHeaderView>
|
||||
#include <QSpinBox>
|
||||
#include "calibration.h"
|
||||
|
||||
#include "autospinbox.h"
|
||||
#include "helpers.h"
|
||||
|
||||
CalibrationPanel::CalibrationPanel(QWidget * parent, GeneralSettings & generalSettings, Firmware * firmware):
|
||||
GeneralPanel(parent, generalSettings, firmware)
|
||||
{
|
||||
int rows = Boards::getCapability(getCurrentBoard(), Board::MaxAnalogs);
|
||||
|
||||
tableWidget = new QTableWidget();
|
||||
QVBoxLayout * layout = new QVBoxLayout();
|
||||
layout->addWidget(tableWidget);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
this->setLayout(layout);
|
||||
|
||||
tableWidget->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
tableWidget->setColumnCount(3);
|
||||
tableWidget->setShowGrid(false);
|
||||
tableWidget->setSelectionMode(QAbstractItemView::NoSelection);
|
||||
tableWidget->setFrameStyle(QFrame::NoFrame | QFrame::Plain);
|
||||
tableWidget->setStyleSheet("QTableWidget {background-color: transparent;}");
|
||||
QStringList headerLabels;
|
||||
headerLabels << tr("Negative span") << tr("Mid value") << tr("Positive span");
|
||||
tableWidget->setHorizontalHeaderLabels(headerLabels);
|
||||
headerLabels << "" << tr("Negative span") << tr("Mid value") << tr("Positive span");
|
||||
|
||||
int rows = getBoardCapability(getCurrentBoard(), Board::MaxAnalogs);
|
||||
tableWidget->setRowCount(rows);
|
||||
TableLayout * tableLayout = new TableLayout(this, rows, headerLabels);
|
||||
|
||||
for(int i = 0; i < rows; ++i) {
|
||||
for (int i = 0; i < rows; i++) {
|
||||
int col = 0;
|
||||
QLabel * label = new QLabel(this);
|
||||
label->setText(firmware->getAnalogInputName(i));
|
||||
tableLayout->addWidget(i, col++, label);
|
||||
|
||||
QTableWidgetItem *newItem = new QTableWidgetItem(firmware->getAnalogInputName(i));
|
||||
newItem->setTextAlignment(Qt::AlignLeft);
|
||||
tableWidget->setVerticalHeaderItem(i, newItem);
|
||||
QLineEdit * leNeg = new QLineEdit(this);
|
||||
leNeg->setText(QString("%1").arg(generalSettings.calibSpanNeg[i]));
|
||||
leNeg->setReadOnly(true);
|
||||
tableLayout->addWidget(i, col++, leNeg);
|
||||
|
||||
for(int j = 0; j < 3; ++j) {
|
||||
QSpinBox * newItem = new QSpinBox();
|
||||
newItem->setMinimum(-9999);
|
||||
newItem->setMaximum(9999);
|
||||
newItem->setSingleStep(1);
|
||||
newItem->setValue(getCalibrationValue(i, j));
|
||||
newItem->setProperty("row", i);
|
||||
newItem->setProperty("column", j);
|
||||
tableWidget->setCellWidget(i, j, newItem);
|
||||
connect(newItem, SIGNAL(valueChanged(int)), this, SLOT(onCellChanged(int)));
|
||||
}
|
||||
QLineEdit * leMid = new QLineEdit(this);
|
||||
leMid->setText(QString("%1").arg(generalSettings.calibMid[i]));
|
||||
leMid->setReadOnly(true);
|
||||
tableLayout->addWidget(i, col++, leMid);
|
||||
|
||||
QLineEdit * lePos = new QLineEdit(this);
|
||||
lePos->setText(QString("%1").arg(generalSettings.calibSpanPos[i]));
|
||||
lePos->setReadOnly(true);
|
||||
tableLayout->addWidget(i, col++, lePos);
|
||||
}
|
||||
|
||||
disableMouseScrolling();
|
||||
}
|
||||
|
||||
void CalibrationPanel::onCellChanged(int value)
|
||||
{
|
||||
QSpinBox * sb = qobject_cast<QSpinBox*>(sender());
|
||||
int row = sb->property("row").toInt();
|
||||
int column = sb->property("column").toInt();
|
||||
|
||||
if (value != getCalibrationValue(row, column)) {
|
||||
setCalibrationValue(row,column, value);
|
||||
qDebug() << "CalibrationPanel::onCellChanged" << row << column << "to" << value;
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
int CalibrationPanel::getCalibrationValue(int row, int column)
|
||||
{
|
||||
switch(column) {
|
||||
case 0:
|
||||
return generalSettings.calibSpanNeg[row];
|
||||
case 1:
|
||||
return generalSettings.calibMid[row];
|
||||
case 2:
|
||||
return generalSettings.calibSpanPos[row];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CalibrationPanel::setCalibrationValue(int row, int column, int value)
|
||||
{
|
||||
switch(column) {
|
||||
case 0:
|
||||
generalSettings.calibSpanNeg[row] = value;
|
||||
break;
|
||||
case 1:
|
||||
generalSettings.calibMid[row] = value;
|
||||
break;
|
||||
case 2:
|
||||
generalSettings.calibSpanPos[row] = value;
|
||||
break;
|
||||
}
|
||||
tableLayout->resizeColumnsToContents();
|
||||
tableLayout->setColumnWidth(0, QString(15, ' '));
|
||||
tableLayout->pushColumnsLeft(headerLabels.count());
|
||||
tableLayout->pushRowsUp(rows + 1);
|
||||
}
|
||||
|
||||
@@ -18,20 +18,10 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef _CALIBRATION_H_
|
||||
#define _CALIBRATION_H_
|
||||
#pragma once
|
||||
|
||||
#include <QTableWidget>
|
||||
#include "generaledit.h"
|
||||
|
||||
namespace Ui {
|
||||
class Calibration;
|
||||
}
|
||||
|
||||
class QLabel;
|
||||
class AutoLineEdit;
|
||||
class AutoComboBox;
|
||||
|
||||
class CalibrationPanel : public GeneralPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -40,14 +30,5 @@ class CalibrationPanel : public GeneralPanel
|
||||
CalibrationPanel(QWidget *parent, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
virtual ~CalibrationPanel() {};
|
||||
|
||||
private slots:
|
||||
void onCellChanged(int value);
|
||||
|
||||
private:
|
||||
QTableWidget * tableWidget;
|
||||
|
||||
int getCalibrationValue(int row, int column);
|
||||
void setCalibrationValue(int row, int column, int value);
|
||||
};
|
||||
|
||||
#endif // _CALIBRATION_H_
|
||||
|
||||
@@ -46,26 +46,27 @@ GeneralEdit::GeneralEdit(QWidget * parent, RadioData & radioData, Firmware * fir
|
||||
}
|
||||
|
||||
ui->profile_CB->clear();
|
||||
for (int i=0; i<MAX_PROFILES; ++i) {
|
||||
for (int i = 0; i < MAX_PROFILES; ++i) {
|
||||
QString name=g.profile[i].name();
|
||||
if (!name.isEmpty()) {
|
||||
ui->profile_CB->addItem(name, i);
|
||||
if (i==g.id()) {
|
||||
ui->profile_CB->setCurrentIndex(ui->profile_CB->count()-1);
|
||||
if (i == g.id()) {
|
||||
ui->profile_CB->setCurrentIndex(ui->profile_CB->count() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sharedItemModels = new CompoundItemModelFactory(&generalSettings, nullptr);
|
||||
sharedItemModels->addItemModel(AbstractItemModel::IMID_RawSource);
|
||||
sharedItemModels->addItemModel(AbstractItemModel::IMID_RawSwitch);
|
||||
sharedItemModels->addItemModel(AbstractItemModel::IMID_CustomFuncAction);
|
||||
sharedItemModels->addItemModel(AbstractItemModel::IMID_CustomFuncResetParam);
|
||||
editorItemModels = new CompoundItemModelFactory(&generalSettings, nullptr);
|
||||
// tabs created below expect these item models to be pre-registered
|
||||
editorItemModels->addItemModel(AbstractItemModel::IMID_RawSource);
|
||||
editorItemModels->addItemModel(AbstractItemModel::IMID_RawSwitch);
|
||||
editorItemModels->addItemModel(AbstractItemModel::IMID_CustomFuncAction);
|
||||
editorItemModels->addItemModel(AbstractItemModel::IMID_CustomFuncResetParam);
|
||||
|
||||
addTab(new GeneralSetupPanel(this, generalSettings, firmware), tr("Setup"));
|
||||
addTab(new CustomFunctionsPanel(this, nullptr, generalSettings, firmware, sharedItemModels), tr("Global Functions"));
|
||||
addTab(new TrainerPanel(this, generalSettings, firmware), tr("Trainer"));
|
||||
addTab(new HardwarePanel(this, generalSettings, firmware), tr("Hardware"));
|
||||
addTab(new CustomFunctionsPanel(this, nullptr, generalSettings, firmware, editorItemModels), tr("Global Functions"));
|
||||
addTab(new TrainerPanel(this, generalSettings, firmware, editorItemModels), tr("Trainer"));
|
||||
addTab(new HardwarePanel(this, generalSettings, firmware, editorItemModels), tr("Hardware"));
|
||||
addTab(new CalibrationPanel(this, generalSettings, firmware), tr("Calibration"));
|
||||
|
||||
ui->tabWidget->setCurrentIndex( g.generalEditTab() );
|
||||
@@ -74,7 +75,7 @@ GeneralEdit::GeneralEdit(QWidget * parent, RadioData & radioData, Firmware * fir
|
||||
GeneralEdit::~GeneralEdit()
|
||||
{
|
||||
delete ui;
|
||||
delete sharedItemModels;
|
||||
delete editorItemModels; // cleans up item models registered by the tabs
|
||||
}
|
||||
|
||||
void GeneralEdit::closeEvent(QCloseEvent *event)
|
||||
@@ -90,7 +91,7 @@ void GeneralEdit::addTab(GenericPanel *panel, QString text)
|
||||
VerticalScrollArea * area = new VerticalScrollArea(widget, panel);
|
||||
baseLayout->addWidget(area);
|
||||
ui->tabWidget->addTab(widget, text);
|
||||
connect(panel, SIGNAL(modified()), this, SLOT(onTabModified()));
|
||||
connect(panel, &GenericPanel::modified, this, &GeneralEdit::onTabModified);
|
||||
}
|
||||
|
||||
void GeneralEdit::onTabModified()
|
||||
|
||||
@@ -18,8 +18,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef _GENERALEDIT_H_
|
||||
#define _GENERALEDIT_H_
|
||||
#pragma once
|
||||
|
||||
#include <QtWidgets>
|
||||
#include "eeprominterface.h"
|
||||
@@ -35,7 +34,7 @@ class GeneralPanel : public GenericPanel
|
||||
{
|
||||
public:
|
||||
GeneralPanel(QWidget *parent, GeneralSettings & generalSettings, Firmware * firmware):
|
||||
GenericPanel(parent, NULL, generalSettings, firmware)
|
||||
GenericPanel(parent, nullptr, generalSettings, firmware)
|
||||
{
|
||||
}
|
||||
};
|
||||
@@ -73,7 +72,5 @@ class GeneralEdit : public QDialog
|
||||
QVector<GenericPanel *> panels;
|
||||
void addTab(GenericPanel *panel, QString text);
|
||||
void closeEvent(QCloseEvent *event);
|
||||
CompoundItemModelFactory *sharedItemModels;
|
||||
CompoundItemModelFactory *editorItemModels;
|
||||
};
|
||||
|
||||
#endif // _GENERALEDIT_H_
|
||||
|
||||
@@ -19,326 +19,268 @@
|
||||
*/
|
||||
|
||||
#include "hardware.h"
|
||||
#include "ui_hardware.h"
|
||||
#include "compounditemmodels.h"
|
||||
#include "filtereditemmodels.h"
|
||||
#include "autolineedit.h"
|
||||
#include "autocombobox.h"
|
||||
#include "autocheckbox.h"
|
||||
#include "autospinbox.h"
|
||||
#include "autodoublespinbox.h"
|
||||
|
||||
void HardwarePanel::setupSwitchType(int index, QLabel * label, AutoLineEdit * name, AutoComboBox * type, bool threePos)
|
||||
{
|
||||
Board::Type board = getCurrentBoard();
|
||||
if (IS_STM32(board) && index < getBoardCapability(board, Board::Switches)) {
|
||||
type->addItem(tr("None"), Board::SWITCH_NOT_AVAILABLE);
|
||||
type->addItem(tr("2 Positions Toggle"), Board::SWITCH_TOGGLE);
|
||||
type->addItem(tr("2 Positions"), Board::SWITCH_2POS);
|
||||
if (threePos) {
|
||||
type->addItem(tr("3 Positions"), Board::SWITCH_3POS);
|
||||
}
|
||||
name->setField(generalSettings.switchName[index], 3, this);
|
||||
type->setField(generalSettings.switchConfig[index], this);
|
||||
if (IS_TARANIS_X7(board)) {
|
||||
if (index == 4) {
|
||||
label->setText("SF");
|
||||
}
|
||||
else if (index == 5) {
|
||||
label->setText("SH");
|
||||
}
|
||||
if (index == 6) {
|
||||
label->setText("SI");
|
||||
}
|
||||
else if (index == 7) {
|
||||
label->setText("SJ");
|
||||
}
|
||||
}
|
||||
else if (IS_RADIOMASTER_TX12(board)) {
|
||||
if (index == 6) {
|
||||
label->setText("SI");
|
||||
}
|
||||
else if (index == 7) {
|
||||
label->setText("SJ");
|
||||
}
|
||||
}
|
||||
else if (IS_FAMILY_T12(board)) {
|
||||
if (index == 4) {
|
||||
label->setText("SG");
|
||||
}
|
||||
else if (index == 5) {
|
||||
label->setText("SH");
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
label->hide();
|
||||
name->hide();
|
||||
type->hide();
|
||||
}
|
||||
}
|
||||
#include <QLabel>
|
||||
#include <QGridLayout>
|
||||
#include <QFrame>
|
||||
|
||||
void HardwarePanel::setupPotType(int index, QLabel * label, AutoLineEdit * name, AutoComboBox * type)
|
||||
{
|
||||
Board::Type board = firmware->getBoard();
|
||||
constexpr char FIM_SWITCHTYPE2POS[] {"Switch Type 2 Pos"};
|
||||
constexpr char FIM_SWITCHTYPE3POS[] {"Switch Type 3 Pos"};
|
||||
|
||||
if (IS_STM32(board) && index < getBoardCapability(board, Board::Pots)) {
|
||||
label->setText(RawSource(SOURCE_TYPE_STICK, CPN_MAX_STICKS+index).toString());
|
||||
type->addItem(tr("None"), Board::POT_NONE);
|
||||
type->addItem(tr("Pot with detent"), Board::POT_WITH_DETENT);
|
||||
type->addItem(tr("Multipos switch"), Board::POT_MULTIPOS_SWITCH);
|
||||
type->addItem(tr("Pot without detent"), Board::POT_WITHOUT_DETENT);
|
||||
name->setField(generalSettings.potName[index], 3, this);
|
||||
type->setField(generalSettings.potConfig[index], this);
|
||||
}
|
||||
else {
|
||||
label->hide();
|
||||
name->hide();
|
||||
type->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void HardwarePanel::setupSliderType(int index, QLabel *label, AutoLineEdit *name, AutoComboBox *type)
|
||||
{
|
||||
Board::Type board = firmware->getBoard();
|
||||
|
||||
if (IS_STM32(board) && index < getBoardCapability(board, Board::Sliders)) {
|
||||
label->setText(RawSource(SOURCE_TYPE_STICK, CPN_MAX_STICKS+getBoardCapability(board, Board::Pots)+index).toString());
|
||||
type->addItem(tr("None"), Board::SLIDER_NONE);
|
||||
type->addItem(tr("Slider with detent"), Board::SLIDER_WITH_DETENT);
|
||||
name->setField(generalSettings.sliderName[index], 3, this);
|
||||
type->setField(generalSettings.sliderConfig[index], this);
|
||||
}
|
||||
else {
|
||||
label->hide();
|
||||
name->hide();
|
||||
type->hide();
|
||||
}
|
||||
}
|
||||
|
||||
bool HardwarePanel::isSwitch3Pos(int idx)
|
||||
{
|
||||
Board::Type board = firmware->getBoard();
|
||||
Board::SwitchInfo switchInfo = Boards::getSwitchInfo(board, idx);
|
||||
|
||||
switchInfo.config = Board::SwitchType(generalSettings.switchConfig[idx]);
|
||||
return switchInfo.config == Board::SWITCH_3POS;
|
||||
};
|
||||
|
||||
HardwarePanel::HardwarePanel(QWidget * parent, GeneralSettings & generalSettings, Firmware * firmware):
|
||||
HardwarePanel::HardwarePanel(QWidget * parent, GeneralSettings & generalSettings, Firmware * firmware, CompoundItemModelFactory * sharedItemModels):
|
||||
GeneralPanel(parent, generalSettings, firmware),
|
||||
ui(new Ui::Hardware)
|
||||
board(firmware->getBoard()),
|
||||
editorItemModels(sharedItemModels)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
editorItemModels->registerItemModel(Boards::potTypeItemModel());
|
||||
editorItemModels->registerItemModel(Boards::sliderTypeItemModel());
|
||||
int id = editorItemModels->registerItemModel(Boards::switchTypeItemModel());
|
||||
|
||||
Board::Type board = firmware->getBoard();
|
||||
tabFilteredModels = new FilteredItemModelFactory();
|
||||
tabFilteredModels->registerItemModel(new FilteredItemModel(editorItemModels->getItemModel(id), Board::SwitchTypeContext2Pos), FIM_SWITCHTYPE2POS);
|
||||
tabFilteredModels->registerItemModel(new FilteredItemModel(editorItemModels->getItemModel(id), Board::SwitchTypeContext3Pos), FIM_SWITCHTYPE3POS);
|
||||
|
||||
if (IS_STM32(board)) {
|
||||
ui->rudName->setField(generalSettings.stickName[0], 3, this);
|
||||
ui->eleName->setField(generalSettings.stickName[1], 3, this);
|
||||
ui->thrName->setField(generalSettings.stickName[2], 3, this);
|
||||
ui->ailName->setField(generalSettings.stickName[3], 3, this);
|
||||
int antmodelid = editorItemModels->registerItemModel(GeneralSettings::antennaModeItemModel());
|
||||
int btmodelid = editorItemModels->registerItemModel(GeneralSettings::bluetoothModeItemModel());
|
||||
int auxmodelid = editorItemModels->registerItemModel(GeneralSettings::auxSerialModeItemModel());
|
||||
int baudmodelid = editorItemModels->registerItemModel(GeneralSettings::telemetryBaudrateItemModel());
|
||||
|
||||
grid = new QGridLayout(this);
|
||||
int count;
|
||||
int row = 0;
|
||||
|
||||
count = Boards::getCapability(board, Board::Sticks);
|
||||
if (count) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
addStick(i, row);
|
||||
}
|
||||
}
|
||||
else {
|
||||
ui->rudLabel->hide();
|
||||
ui->rudName->hide();
|
||||
ui->eleLabel->hide();
|
||||
ui->eleName->hide();
|
||||
ui->thrLabel->hide();
|
||||
ui->thrName->hide();
|
||||
ui->ailLabel->hide();
|
||||
ui->ailName->hide();
|
||||
ui->potsTypeSeparator_1->hide();
|
||||
ui->potsTypeSeparator_2->hide();
|
||||
|
||||
count = Boards::getCapability(board, Board::Pots);
|
||||
if (count) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
addPot(i, row);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
count = Boards::getCapability(board, Board::Sliders);
|
||||
if (count) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
addSlider(i, row);
|
||||
}
|
||||
addLine(row);
|
||||
}
|
||||
|
||||
count = Boards::getCapability(board, Board::Switches);
|
||||
if (count) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
addSwitch(i, row);
|
||||
}
|
||||
addLine(row);
|
||||
}
|
||||
|
||||
addLabel(tr("Battery Offset"), row, 0);
|
||||
AutoDoubleSpinBox *txVoltageCalibration = new AutoDoubleSpinBox(this);
|
||||
FieldRange txVCRng = GeneralSettings::getTxVoltageCalibrationRange();
|
||||
txVoltageCalibration->setDecimals(txVCRng.decimals);
|
||||
txVoltageCalibration->setSingleStep(txVCRng.step);
|
||||
txVoltageCalibration->setSuffix(txVCRng.unit);
|
||||
txVoltageCalibration->setField(generalSettings.txVoltageCalibration);
|
||||
addParams(row, txVoltageCalibration);
|
||||
|
||||
if (Boards::getCapability(board, Board::HasRTC)) {
|
||||
addLabel(tr("RTC Battery Check"), row, 0);
|
||||
AutoCheckBox *rtcCheckDisable = new AutoCheckBox(this);
|
||||
rtcCheckDisable->setField(generalSettings.rtcCheckDisable, this, true);
|
||||
addParams(row, rtcCheckDisable);
|
||||
}
|
||||
|
||||
if (firmware->getCapability(HasBluetooth)) {
|
||||
addLabel(tr("Bluetooth"), row, 0);
|
||||
|
||||
QGridLayout *btlayout = new QGridLayout();
|
||||
|
||||
AutoComboBox *bluetoothMode = new AutoComboBox(this);
|
||||
bluetoothMode->setModel(editorItemModels->getItemModel(btmodelid));
|
||||
bluetoothMode->setField(generalSettings.bluetoothMode, this);
|
||||
btlayout->addWidget(bluetoothMode, 0, 0);
|
||||
|
||||
QSpacerItem * spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
|
||||
btlayout->addItem(spacer, 0, 1);
|
||||
|
||||
QLabel *btnamelabel = new QLabel(this);
|
||||
btnamelabel->setText(tr("Device Name:"));
|
||||
btlayout->addWidget(btnamelabel, 0, 2);
|
||||
|
||||
AutoLineEdit *bluetoothName = new AutoLineEdit(this);
|
||||
bluetoothName->setField(generalSettings.bluetoothName, BLUETOOTH_NAME_LEN, this);
|
||||
btlayout->addWidget(bluetoothName, 0, 3);
|
||||
|
||||
grid->addLayout(btlayout, row, 1);
|
||||
row++;
|
||||
}
|
||||
|
||||
if (firmware->getCapability(HasAntennaChoice)) {
|
||||
addLabel(tr("Antenna"), row, 0);
|
||||
AutoComboBox *antennaMode = new AutoComboBox(this);
|
||||
antennaMode->setModel(editorItemModels->getItemModel(antmodelid));
|
||||
antennaMode->setField(generalSettings.antennaMode, this);
|
||||
addParams(row, antennaMode);
|
||||
}
|
||||
|
||||
if (firmware->getCapability(HasAuxSerialMode)) {
|
||||
QString lbl = "Serial Port";
|
||||
if (IS_RADIOMASTER_TX16S(board))
|
||||
lbl.append(" (TTL)");
|
||||
addLabel(tr("%1").arg(lbl), row, 0);
|
||||
AutoComboBox *serialPortMode = new AutoComboBox(this);
|
||||
serialPortMode->setModel(editorItemModels->getItemModel(auxmodelid));
|
||||
serialPortMode->setField(generalSettings.auxSerialMode);
|
||||
addParams(row, serialPortMode);
|
||||
}
|
||||
|
||||
if (firmware->getCapability(HasAux2SerialMode)) {
|
||||
QString lbl = "Serial Port 2";
|
||||
if (IS_RADIOMASTER_TX16S(board))
|
||||
lbl.append(" (TTL)");
|
||||
addLabel(tr("%1").arg(lbl), row, 0);
|
||||
AutoComboBox *serialPort2Mode = new AutoComboBox(this);
|
||||
serialPort2Mode->setModel(editorItemModels->getItemModel(auxmodelid));
|
||||
serialPort2Mode->setField(generalSettings.aux2SerialMode);
|
||||
addParams(row, serialPort2Mode);
|
||||
}
|
||||
|
||||
if (firmware->getCapability(HasADCJitterFilter)) {
|
||||
addLabel(tr("ADC Filter"), row, 0);
|
||||
AutoCheckBox *filterEnable = new AutoCheckBox(this);
|
||||
filterEnable->setField(generalSettings.jitterFilter, this, true);
|
||||
addParams(row, filterEnable);
|
||||
}
|
||||
|
||||
if (firmware->getCapability(HasSportConnector)) {
|
||||
ui->sportPower->setChecked(generalSettings.sportPower);
|
||||
}
|
||||
else {
|
||||
ui->sportPower->hide();
|
||||
ui->sportPowerLabel->hide();
|
||||
addLabel(tr("S.Port Power"), row, 0);
|
||||
AutoCheckBox *sportPower = new AutoCheckBox(this);
|
||||
sportPower->setField(generalSettings.sportPower, this);
|
||||
addParams(row, sportPower);
|
||||
}
|
||||
|
||||
setupPotType(0, ui->pot1Label, ui->pot1Name, ui->pot1Type);
|
||||
setupPotType(1, ui->pot2Label, ui->pot2Name, ui->pot2Type);
|
||||
setupPotType(2, ui->pot3Label, ui->pot3Name, ui->pot3Type);
|
||||
setupPotType(3, ui->pot4Label, ui->pot4Name, ui->pot4Type);
|
||||
setupPotType(4, ui->pot5Label, ui->pot5Name, ui->pot5Type);
|
||||
|
||||
setupSliderType(0, ui->lsLabel, ui->lsName, ui->lsType);
|
||||
setupSliderType(1, ui->rsLabel, ui->rsName, ui->rsType);
|
||||
setupSliderType(2, ui->ls2Label, ui->ls2Name, ui->ls2Type);
|
||||
setupSliderType(3, ui->rs2Label, ui->rs2Name, ui->rs2Type);
|
||||
|
||||
setupSwitchType(0, ui->saLabel, ui->saName, ui->saType, isSwitch3Pos(0));
|
||||
setupSwitchType(1, ui->sbLabel, ui->sbName, ui->sbType, isSwitch3Pos(1));
|
||||
setupSwitchType(2, ui->scLabel, ui->scName, ui->scType, isSwitch3Pos(2));
|
||||
setupSwitchType(3, ui->sdLabel, ui->sdName, ui->sdType, isSwitch3Pos(3));
|
||||
setupSwitchType(4, ui->seLabel, ui->seName, ui->seType, isSwitch3Pos(4));
|
||||
setupSwitchType(5, ui->sfLabel, ui->sfName, ui->sfType, isSwitch3Pos(5));
|
||||
setupSwitchType(6, ui->sgLabel, ui->sgName, ui->sgType, isSwitch3Pos(6));
|
||||
setupSwitchType(7, ui->shLabel, ui->shName, ui->shType, isSwitch3Pos(7));
|
||||
setupSwitchType(8, ui->siLabel, ui->siName, ui->siType, isSwitch3Pos(8));
|
||||
setupSwitchType(9, ui->sjLabel, ui->sjName, ui->sjType, isSwitch3Pos(9));
|
||||
setupSwitchType(10, ui->skLabel, ui->skName, ui->skType); // Here starts X9E, only 3 switches
|
||||
setupSwitchType(11, ui->slLabel, ui->slName, ui->slType);
|
||||
setupSwitchType(12, ui->smLabel, ui->smName, ui->smType);
|
||||
setupSwitchType(13, ui->snLabel, ui->snName, ui->snType);
|
||||
setupSwitchType(14, ui->soLabel, ui->soName, ui->soType);
|
||||
setupSwitchType(15, ui->spLabel, ui->spName, ui->spType);
|
||||
setupSwitchType(16, ui->sqLabel, ui->sqName, ui->sqType);
|
||||
setupSwitchType(17, ui->srLabel, ui->srName, ui->srType);
|
||||
|
||||
if (IS_TARANIS(board) && !IS_TARANIS_SMALL(board)) {
|
||||
ui->serialPortMode->setCurrentIndex(generalSettings.auxSerialMode);
|
||||
}
|
||||
else {
|
||||
ui->serialPortMode->setCurrentIndex(0);
|
||||
ui->serialPortMode->hide();
|
||||
ui->serialPortLabel->hide();
|
||||
if (firmware->getCapability(HasTelemetryBaudrate)) {
|
||||
addLabel(tr("Maximum Baud"), row, 0);
|
||||
AutoComboBox *maxBaudRate = new AutoComboBox(this);
|
||||
maxBaudRate->setModel(editorItemModels->getItemModel(baudmodelid));
|
||||
maxBaudRate->setField(generalSettings.telemetryBaudrate, this);
|
||||
addParams(row, maxBaudRate);
|
||||
}
|
||||
|
||||
if (!IS_SKY9X(board)) {
|
||||
ui->txCurrentCalibration->hide();
|
||||
ui->txCurrentCalibrationLabel->hide();
|
||||
}
|
||||
|
||||
if (IS_TARANIS_X7(board) || IS_TARANIS_XLITE(board)|| IS_TARANIS_X9E(board) || IS_TARANIS_X9DP_2019(board) || IS_FAMILY_HORUS_OR_T16(board)) {
|
||||
ui->bluetoothMode->addItem(tr("OFF"), 0);
|
||||
if (IS_TARANIS_X9E(board)) {
|
||||
ui->bluetoothMode->addItem(tr("Enabled"), 1);
|
||||
}
|
||||
else {
|
||||
ui->bluetoothMode->addItem(tr("Telemetry"), 1);
|
||||
ui->bluetoothMode->addItem(tr("Trainer"), 2);
|
||||
}
|
||||
ui->bluetoothMode->setField(generalSettings.bluetoothMode, this);
|
||||
ui->bluetoothName->setField(generalSettings.bluetoothName, 10, this);
|
||||
}
|
||||
else {
|
||||
ui->bluetoothLabel->hide();
|
||||
ui->bluetoothWidget->hide();
|
||||
}
|
||||
|
||||
if ((IS_FAMILY_HORUS_OR_T16(board) && board != Board::BOARD_X10_EXPRESS) || (IS_TARANIS_XLITE(board) && !IS_TARANIS_XLITES(board))) {
|
||||
ui->antennaMode->addItem(tr("Internal"), -2);
|
||||
ui->antennaMode->addItem(tr("Ask"), -1);
|
||||
ui->antennaMode->addItem(tr("Per model"), 0);
|
||||
ui->antennaMode->addItem(IS_HORUS_X12S(board) ? tr("Internal + External") : tr("External"), 1);
|
||||
ui->antennaMode->setField(generalSettings.antennaMode, this);
|
||||
}
|
||||
else {
|
||||
ui->antennaLabel->hide();
|
||||
ui->antennaMode->hide();
|
||||
}
|
||||
|
||||
if (IS_HORUS_OR_TARANIS(board)) {
|
||||
ui->filterEnable->setChecked(!generalSettings.jitterFilter);
|
||||
}
|
||||
else {
|
||||
ui->filterEnable->hide();
|
||||
ui->filterLabel->hide();
|
||||
}
|
||||
|
||||
if (IS_STM32(board)) {
|
||||
ui->rtcCheckDisable->setChecked(!generalSettings.rtcCheckDisable);
|
||||
}
|
||||
else {
|
||||
ui->rtcCheckDisable->hide();
|
||||
ui->rtcCheckLabel->hide();
|
||||
if (firmware->getCapability(HastxCurrentCalibration)) {
|
||||
addLabel(tr("Current Offset"), row, 0);
|
||||
AutoSpinBox *txCurrentCalibration = new AutoSpinBox(this);
|
||||
FieldRange txCCRng = GeneralSettings::getTxCurrentCalibration();
|
||||
txCurrentCalibration->setSuffix(txVCRng.unit);
|
||||
txCurrentCalibration->setField(generalSettings.txCurrentCalibration);
|
||||
addParams(row, txCurrentCalibration);
|
||||
}
|
||||
|
||||
addVSpring(grid, 0, grid->rowCount());
|
||||
addHSpring(grid, grid->columnCount(), 0);
|
||||
disableMouseScrolling();
|
||||
|
||||
setValues();
|
||||
}
|
||||
|
||||
HardwarePanel::~HardwarePanel()
|
||||
{
|
||||
delete ui;
|
||||
delete tabFilteredModels;
|
||||
}
|
||||
|
||||
void HardwarePanel::on_filterEnable_stateChanged()
|
||||
void HardwarePanel::addStick(int index, int & row)
|
||||
{
|
||||
generalSettings.jitterFilter = !ui->filterEnable->isChecked();
|
||||
int col = 0;
|
||||
addLabel(Boards::getAnalogInputName(board, index), row, col++);
|
||||
|
||||
AutoLineEdit *name = new AutoLineEdit(this);
|
||||
name->setField(generalSettings.stickName[index], HARDWARE_NAME_LEN, this);
|
||||
|
||||
addParams(row, name);
|
||||
}
|
||||
|
||||
void HardwarePanel::on_sportPower_stateChanged()
|
||||
void HardwarePanel::addPot(int index, int & row)
|
||||
{
|
||||
generalSettings.sportPower = ui->sportPower->isChecked();
|
||||
addLabel(Boards::getAnalogInputName(board, Boards::getCapability(board, Board::Sticks) + index), row, 0);
|
||||
|
||||
AutoLineEdit *name = new AutoLineEdit(this);
|
||||
name->setField(generalSettings.potName[index], HARDWARE_NAME_LEN, this);
|
||||
|
||||
AutoComboBox *type = new AutoComboBox(this);
|
||||
type->setModel(editorItemModels->getItemModel(AIM_BOARDS_POT_TYPE));
|
||||
type->setField(generalSettings.potConfig[index], this);
|
||||
|
||||
addParams(row, name, type);
|
||||
}
|
||||
|
||||
void HardwarePanel::on_rtcCheckDisable_stateChanged()
|
||||
void HardwarePanel::addSlider(int index, int & row)
|
||||
{
|
||||
generalSettings.rtcCheckDisable = !ui->rtcCheckDisable->isChecked();
|
||||
addLabel(Boards::getAnalogInputName(board, Boards::getCapability(board, Board::Sticks) +
|
||||
Boards::getCapability(board, Board::Pots) + index), row, 0);
|
||||
|
||||
AutoLineEdit *name = new AutoLineEdit(this);
|
||||
name->setField(generalSettings.sliderName[index], HARDWARE_NAME_LEN, this);
|
||||
|
||||
AutoComboBox *type = new AutoComboBox(this);
|
||||
type->setModel(editorItemModels->getItemModel(AIM_BOARDS_SLIDER_TYPE));
|
||||
type->setField(generalSettings.sliderConfig[index], this);
|
||||
|
||||
addParams(row, name, type);
|
||||
}
|
||||
|
||||
void HardwarePanel::on_PPM_MultiplierDSB_editingFinished()
|
||||
void HardwarePanel::addSwitch(int index, int & row)
|
||||
{
|
||||
int val = (int)(ui->PPM_MultiplierDSB->value()*10)-10;
|
||||
if (generalSettings.PPM_Multiplier != val) {
|
||||
generalSettings.PPM_Multiplier = val;
|
||||
emit modified();
|
||||
}
|
||||
addLabel(Boards::getSwitchInfo(board, index).name, row, 0);
|
||||
|
||||
AutoLineEdit *name = new AutoLineEdit(this);
|
||||
name->setField(generalSettings.switchName[index], HARDWARE_NAME_LEN, this);
|
||||
|
||||
AutoComboBox *type = new AutoComboBox(this);
|
||||
Board::SwitchInfo switchInfo = Boards::getSwitchInfo(board, index);
|
||||
type->setModel(switchInfo.config < Board::SWITCH_3POS ? tabFilteredModels->getItemModel(FIM_SWITCHTYPE2POS) :
|
||||
tabFilteredModels->getItemModel(FIM_SWITCHTYPE3POS));
|
||||
type->setField(generalSettings.switchConfig[index], this);
|
||||
|
||||
addParams(row, name, type);
|
||||
}
|
||||
|
||||
void HardwarePanel::on_PPM1_editingFinished()
|
||||
void HardwarePanel::addLabel(QString text, int row, int col)
|
||||
{
|
||||
if (generalSettings.trainer.calib[0] != ui->PPM1->value()) {
|
||||
generalSettings.trainer.calib[0] = ui->PPM1->value();
|
||||
emit modified();
|
||||
}
|
||||
QLabel *label = new QLabel(this);
|
||||
label->setText(text);
|
||||
grid->addWidget(label, row, col);
|
||||
}
|
||||
|
||||
void HardwarePanel::on_PPM2_editingFinished()
|
||||
void HardwarePanel::addLine(int & row)
|
||||
{
|
||||
if (generalSettings.trainer.calib[1] != ui->PPM2->value()) {
|
||||
generalSettings.trainer.calib[1] = ui->PPM2->value();
|
||||
emit modified();
|
||||
}
|
||||
QFrame *line = new QFrame(this);
|
||||
line->setFrameShape(QFrame::HLine);
|
||||
line->setFrameShadow(QFrame::Sunken);
|
||||
line->setLineWidth(1);
|
||||
line->setMidLineWidth(0);
|
||||
grid->addWidget(line, row, 0, 1, grid->columnCount());
|
||||
row++;
|
||||
}
|
||||
|
||||
void HardwarePanel::on_PPM3_editingFinished()
|
||||
void HardwarePanel::addParams(int & row, QWidget * widget1, QWidget * widget2)
|
||||
{
|
||||
if (generalSettings.trainer.calib[2] != ui->PPM3->value()) {
|
||||
generalSettings.trainer.calib[2] = ui->PPM3->value();
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void HardwarePanel::on_PPM4_editingFinished()
|
||||
{
|
||||
if (generalSettings.trainer.calib[3] != ui->PPM4->value()) {
|
||||
generalSettings.trainer.calib[3] = ui->PPM4->value();
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void HardwarePanel::on_txCurrentCalibration_editingFinished()
|
||||
{
|
||||
if (generalSettings.txCurrentCalibration != ui->txCurrentCalibration->value()) {
|
||||
generalSettings.txCurrentCalibration = ui->txCurrentCalibration->value();
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void HardwarePanel::setValues()
|
||||
{
|
||||
ui->txVoltageCalibration->setValue((double)generalSettings.txVoltageCalibration/10);
|
||||
ui->txCurrentCalibration->setValue((double)generalSettings.txCurrentCalibration);
|
||||
|
||||
ui->PPM1->setValue(generalSettings.trainer.calib[0]);
|
||||
ui->PPM2->setValue(generalSettings.trainer.calib[1]);
|
||||
ui->PPM3->setValue(generalSettings.trainer.calib[2]);
|
||||
ui->PPM4->setValue(generalSettings.trainer.calib[3]);
|
||||
ui->PPM_MultiplierDSB->setValue((qreal)(generalSettings.PPM_Multiplier+10)/10);
|
||||
}
|
||||
|
||||
void HardwarePanel::on_txVoltageCalibration_editingFinished()
|
||||
{
|
||||
if (generalSettings.txVoltageCalibration != ui->txVoltageCalibration->value()*10) {
|
||||
generalSettings.txVoltageCalibration = ui->txVoltageCalibration->value()*10;
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void HardwarePanel::on_serialPortMode_currentIndexChanged(int index)
|
||||
{
|
||||
generalSettings.auxSerialMode = index;
|
||||
emit modified();
|
||||
QGridLayout *subgrid = new QGridLayout();
|
||||
subgrid->addWidget(widget1, 0, 0);
|
||||
if (widget2)
|
||||
subgrid->addWidget(widget2, 0, 1);
|
||||
else
|
||||
addHSpring(subgrid, 1, 0);
|
||||
addHSpring(subgrid, 2, 0);
|
||||
grid->addLayout(subgrid, row, 1);
|
||||
row++;
|
||||
}
|
||||
|
||||
@@ -18,52 +18,33 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef _HARDWARE_H_
|
||||
#define _HARDWARE_H_
|
||||
#pragma once
|
||||
|
||||
#include "generaledit.h"
|
||||
|
||||
namespace Ui {
|
||||
class Hardware;
|
||||
}
|
||||
|
||||
class QLabel;
|
||||
class AutoLineEdit;
|
||||
class AutoComboBox;
|
||||
class CompoundItemModelFactory;
|
||||
class FilteredItemModelFactory;
|
||||
class QGridLayout;
|
||||
|
||||
class HardwarePanel : public GeneralPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
HardwarePanel(QWidget * parent, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
HardwarePanel(QWidget * parent, GeneralSettings & generalSettings, Firmware * firmware, CompoundItemModelFactory * editorItemModels);
|
||||
virtual ~HardwarePanel();
|
||||
|
||||
private slots:
|
||||
void on_PPM1_editingFinished();
|
||||
void on_PPM2_editingFinished();
|
||||
void on_PPM3_editingFinished();
|
||||
void on_PPM4_editingFinished();
|
||||
void on_PPM_MultiplierDSB_editingFinished();
|
||||
|
||||
void on_txCurrentCalibration_editingFinished();
|
||||
void on_txVoltageCalibration_editingFinished();
|
||||
void on_filterEnable_stateChanged();
|
||||
void on_rtcCheckDisable_stateChanged();
|
||||
void on_sportPower_stateChanged();
|
||||
|
||||
void on_serialPortMode_currentIndexChanged(int index);
|
||||
|
||||
protected:
|
||||
void setupPotType(int index, QLabel * label, AutoLineEdit * name, AutoComboBox * type);
|
||||
void setupSliderType(int index, QLabel * label, AutoLineEdit * name, AutoComboBox * type);
|
||||
void setupSwitchType(int index, QLabel * label, AutoLineEdit * name, AutoComboBox * type, bool threePos = true);
|
||||
|
||||
private:
|
||||
Ui::Hardware *ui;
|
||||
Board::Type board;
|
||||
CompoundItemModelFactory *editorItemModels;
|
||||
FilteredItemModelFactory *tabFilteredModels;
|
||||
QGridLayout *grid;
|
||||
|
||||
void setValues();
|
||||
bool isSwitch3Pos(int idx);
|
||||
void addStick(int index, int & row);
|
||||
void addPot(int index, int & row);
|
||||
void addSlider(int index, int & row);
|
||||
void addSwitch(int index, int & row);
|
||||
void addLabel(QString text, int row, int col);
|
||||
void addLine(int & row);
|
||||
void addParams(int & row, QWidget * widget1, QWidget * widget2 = nullptr);
|
||||
};
|
||||
|
||||
#endif // _HARDWARE_H_
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -19,103 +19,106 @@
|
||||
*/
|
||||
|
||||
#include "trainer.h"
|
||||
#include "ui_trainer.h"
|
||||
#include "compounditemmodels.h"
|
||||
#include "autocombobox.h"
|
||||
#include "autolineedit.h"
|
||||
#include "autospinbox.h"
|
||||
#include "autodoublespinbox.h"
|
||||
|
||||
TrainerPanel::TrainerPanel(QWidget * parent, GeneralSettings & generalSettings, Firmware * firmware):
|
||||
GeneralPanel(parent, generalSettings, firmware),
|
||||
ui(new Ui::Trainer)
|
||||
#include <QFrame>
|
||||
#include <QLabel>
|
||||
#include <QStringList>
|
||||
|
||||
TrainerPanel::TrainerPanel(QWidget * parent, GeneralSettings & generalSettings, Firmware * firmware, CompoundItemModelFactory * editorItemModels):
|
||||
GeneralPanel(parent, generalSettings, firmware)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
int modeid = editorItemModels->registerItemModel(TrainerMix::modeItemModel());
|
||||
int srcid = editorItemModels->registerItemModel(TrainerMix::srcItemModel());
|
||||
|
||||
Board::Type board = getCurrentBoard();
|
||||
const int stickcnt = Boards::getCapability(board, Board::Sticks);
|
||||
|
||||
ui->trnMode_1->setCurrentIndex(generalSettings.trainer.mix[0].mode);
|
||||
ui->trnChn_1->setCurrentIndex(generalSettings.trainer.mix[0].src);
|
||||
ui->trnWeight_1->setValue(generalSettings.trainer.mix[0].weight);
|
||||
ui->trnMode_2->setCurrentIndex(generalSettings.trainer.mix[1].mode);
|
||||
ui->trnChn_2->setCurrentIndex(generalSettings.trainer.mix[1].src);
|
||||
ui->trnWeight_2->setValue(generalSettings.trainer.mix[1].weight);
|
||||
ui->trnMode_3->setCurrentIndex(generalSettings.trainer.mix[2].mode);
|
||||
ui->trnChn_3->setCurrentIndex(generalSettings.trainer.mix[2].src);
|
||||
ui->trnWeight_3->setValue(generalSettings.trainer.mix[2].weight);
|
||||
ui->trnMode_4->setCurrentIndex(generalSettings.trainer.mix[3].mode);
|
||||
ui->trnChn_4->setCurrentIndex(generalSettings.trainer.mix[3].src);
|
||||
ui->trnWeight_4->setValue(generalSettings.trainer.mix[3].weight);
|
||||
const FieldRange weightrng = TrainerMix::getWeightRange();
|
||||
|
||||
grid = new QGridLayout(this);
|
||||
|
||||
int col = 0;
|
||||
int row = 0;
|
||||
|
||||
if (stickcnt) {
|
||||
addLabel(tr("Mode"), row, 1);
|
||||
addLabel(tr("Weight"), row, 2);
|
||||
addLabel(tr("Source"), row++, 3);
|
||||
|
||||
for (int i = 0; i < 4; i++, row++) { // TODO constant
|
||||
col = 0;
|
||||
addLabel(Boards::getAnalogInputName(board, i), row, col++);
|
||||
|
||||
AutoComboBox *mode = new AutoComboBox(this);
|
||||
mode->setModel(editorItemModels->getItemModel(modeid));
|
||||
mode->setField(generalSettings.trainer.mix[i].mode, this);
|
||||
grid->addWidget(mode, row, col++);
|
||||
|
||||
AutoSpinBox *weight = new AutoSpinBox(this);
|
||||
weight->setRange(weightrng.min, weightrng.max);
|
||||
weight->setField(generalSettings.trainer.mix[i].weight, this);
|
||||
grid->addWidget(weight, row, col++);
|
||||
|
||||
AutoComboBox *src = new AutoComboBox(this);
|
||||
src->setModel(editorItemModels->getItemModel(srcid));
|
||||
src->setField(generalSettings.trainer.mix[i].src, this);
|
||||
grid->addWidget(src, row, col++);
|
||||
}
|
||||
|
||||
addLine(row++, 0, grid->columnCount());
|
||||
}
|
||||
|
||||
col = 0;
|
||||
addLabel(tr("Multiplier"), row, col++);
|
||||
|
||||
const FieldRange ppmmrng = GeneralSettings::getPPM_MultiplierRange();
|
||||
|
||||
AutoDoubleSpinBox *multi = new AutoDoubleSpinBox(this);
|
||||
multi->setDecimals(ppmmrng.decimals);
|
||||
multi->setOffset(ppmmrng.offset);
|
||||
multi->setSingleStep(ppmmrng.step);
|
||||
multi->setRange(ppmmrng.min, ppmmrng.max);
|
||||
multi->setField(generalSettings.PPM_Multiplier, this);
|
||||
grid->addWidget(multi, row++, col);
|
||||
|
||||
col = 0;
|
||||
|
||||
addLabel(tr("Calibration"), row, col++);
|
||||
|
||||
for (int i = 0; i < stickcnt; i++, col++) {
|
||||
AutoLineEdit *calib = new AutoLineEdit(this);
|
||||
calib->setText(QString("%1").arg(generalSettings.trainer.calib[i]));
|
||||
calib->setReadOnly(true);
|
||||
grid->addWidget(calib, row, col);
|
||||
}
|
||||
|
||||
addHSpring(grid, grid->columnCount(), 0);
|
||||
addVSpring(grid, 0, grid->rowCount());
|
||||
disableMouseScrolling();
|
||||
}
|
||||
|
||||
TrainerPanel::~TrainerPanel()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void TrainerPanel::on_trnMode_1_currentIndexChanged(int index)
|
||||
void TrainerPanel::addLabel(QString text, int row, int col)
|
||||
{
|
||||
generalSettings.trainer.mix[0].mode = index;
|
||||
emit modified();
|
||||
QLabel *label = new QLabel(this);
|
||||
label->setText(text);
|
||||
grid->addWidget(label, row, col);
|
||||
}
|
||||
|
||||
void TrainerPanel::on_trnChn_1_currentIndexChanged(int index)
|
||||
void TrainerPanel::addLine(int row, int col, int colspan)
|
||||
{
|
||||
generalSettings.trainer.mix[0].src = index;
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void TrainerPanel::on_trnWeight_1_editingFinished()
|
||||
{
|
||||
generalSettings.trainer.mix[0].weight = ui->trnWeight_1->value();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void TrainerPanel::on_trnMode_2_currentIndexChanged(int index)
|
||||
{
|
||||
generalSettings.trainer.mix[1].mode = index;
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void TrainerPanel::on_trnChn_2_currentIndexChanged(int index)
|
||||
{
|
||||
generalSettings.trainer.mix[1].src = index;
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void TrainerPanel::on_trnWeight_2_editingFinished()
|
||||
{
|
||||
generalSettings.trainer.mix[1].weight = ui->trnWeight_2->value();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void TrainerPanel::on_trnMode_3_currentIndexChanged(int index)
|
||||
{
|
||||
generalSettings.trainer.mix[2].mode = index;
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void TrainerPanel::on_trnChn_3_currentIndexChanged(int index)
|
||||
{
|
||||
generalSettings.trainer.mix[2].src = index;
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void TrainerPanel::on_trnWeight_3_editingFinished()
|
||||
{
|
||||
generalSettings.trainer.mix[2].weight = ui->trnWeight_3->value();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void TrainerPanel::on_trnMode_4_currentIndexChanged(int index)
|
||||
{
|
||||
generalSettings.trainer.mix[3].mode = index;
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void TrainerPanel::on_trnChn_4_currentIndexChanged(int index)
|
||||
{
|
||||
generalSettings.trainer.mix[3].src = index;
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void TrainerPanel::on_trnWeight_4_editingFinished()
|
||||
{
|
||||
generalSettings.trainer.mix[3].weight = ui->trnWeight_4->value();
|
||||
emit modified();
|
||||
QFrame *line = new QFrame(this);
|
||||
line->setFrameShape(QFrame::HLine);
|
||||
line->setFrameShadow(QFrame::Sunken);
|
||||
line->setLineWidth(1);
|
||||
line->setMidLineWidth(0);
|
||||
grid->addWidget(line, row, col, 1, colspan);
|
||||
}
|
||||
|
||||
@@ -18,42 +18,23 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef _TRAINER_H_
|
||||
#define _TRAINER_H_
|
||||
#pragma once
|
||||
|
||||
#include "generaledit.h"
|
||||
#include "eeprominterface.h"
|
||||
|
||||
namespace Ui {
|
||||
class Trainer;
|
||||
}
|
||||
class CompoundItemModelFactory;
|
||||
|
||||
class TrainerPanel : public GeneralPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TrainerPanel(QWidget *parent, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
TrainerPanel(QWidget *parent, GeneralSettings & generalSettings, Firmware * firmware, CompoundItemModelFactory * editorItemModels);
|
||||
virtual ~TrainerPanel();
|
||||
|
||||
private slots:
|
||||
void on_trnMode_1_currentIndexChanged(int index);
|
||||
void on_trnChn_1_currentIndexChanged(int index);
|
||||
void on_trnWeight_1_editingFinished();
|
||||
void on_trnMode_2_currentIndexChanged(int index);
|
||||
void on_trnChn_2_currentIndexChanged(int index);
|
||||
void on_trnWeight_2_editingFinished();
|
||||
void on_trnMode_3_currentIndexChanged(int index);
|
||||
void on_trnChn_3_currentIndexChanged(int index);
|
||||
void on_trnWeight_3_editingFinished();
|
||||
void on_trnMode_4_currentIndexChanged(int index);
|
||||
void on_trnChn_4_currentIndexChanged(int index);
|
||||
void on_trnWeight_4_editingFinished();
|
||||
|
||||
private:
|
||||
Ui::Trainer *ui;
|
||||
|
||||
void setValues();
|
||||
QGridLayout * grid;
|
||||
void addLabel(QString text, int row, int col);
|
||||
void addLine(int row, int col, int colspan);
|
||||
};
|
||||
|
||||
#endif // _TRAINER_H_
|
||||
|
||||
@@ -1,475 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Trainer</class>
|
||||
<widget class="QWidget" name="Trainer">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="3" column="3">
|
||||
<widget class="QSpinBox" name="trnWeight_3">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>-125</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>125</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_36">
|
||||
<property name="text">
|
||||
<string>Mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="label_37">
|
||||
<property name="text">
|
||||
<string>Input</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLabel" name="label_38">
|
||||
<property name="text">
|
||||
<string>Weight</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="trnLabel_1">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Rud</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="trnMode_1">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>Beeper volume
|
||||
|
||||
0 - Quiet. No beeps at all.
|
||||
1 - No Keys. Normal beeps but menu keys do not beep.
|
||||
2 - Normal.
|
||||
3 - Loud.
|
||||
4 - Extra loud.</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Off</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>+= (Sum)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>:= (Replace)</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QComboBox" name="trnChn_1">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>Beeper volume
|
||||
|
||||
0 - Quiet. No beeps at all.
|
||||
1 - No Keys. Normal beeps but menu keys do not beep.
|
||||
2 - Normal.
|
||||
3 - Loud.
|
||||
4 - Extra loud.</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>chn1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>chn2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>chn3</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>chn4</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QSpinBox" name="trnWeight_1">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>-125</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>125</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="trnLabel_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Ele</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="trnMode_2">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>Beeper volume
|
||||
|
||||
0 - Quiet. No beeps at all.
|
||||
1 - No Keys. Normal beeps but menu keys do not beep.
|
||||
2 - Normal.
|
||||
3 - Loud.
|
||||
4 - Extra loud.</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Off</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>+= (Sum)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>:= (Replace)</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QComboBox" name="trnChn_2">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>Beeper volume
|
||||
|
||||
0 - Quiet. No beeps at all.
|
||||
1 - No Keys. Normal beeps but menu keys do not beep.
|
||||
2 - Normal.
|
||||
3 - Loud.
|
||||
4 - Extra loud.</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>chn1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>chn2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>chn3</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>chn4</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QComboBox" name="trnChn_3">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>Beeper volume
|
||||
|
||||
0 - Quiet. No beeps at all.
|
||||
1 - No Keys. Normal beeps but menu keys do not beep.
|
||||
2 - Normal.
|
||||
3 - Loud.
|
||||
4 - Extra loud.</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>chn1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>chn2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>chn3</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>chn4</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QSpinBox" name="trnWeight_2">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>-125</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>125</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="trnLabel_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Thr</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="trnMode_3">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>Beeper volume
|
||||
|
||||
0 - Quiet. No beeps at all.
|
||||
1 - No Keys. Normal beeps but menu keys do not beep.
|
||||
2 - Normal.
|
||||
3 - Loud.
|
||||
4 - Extra loud.</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Off</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>+= (Sum)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>:= (Replace)</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="trnLabel_4">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Ail</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="trnMode_4">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>Beeper volume
|
||||
|
||||
0 - Quiet. No beeps at all.
|
||||
1 - No Keys. Normal beeps but menu keys do not beep.
|
||||
2 - Normal.
|
||||
3 - Loud.
|
||||
4 - Extra loud.</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Off</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>+= (Sum)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>:= (Replace)</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QComboBox" name="trnChn_4">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>Beeper volume
|
||||
|
||||
0 - Quiet. No beeps at all.
|
||||
1 - No Keys. Normal beeps but menu keys do not beep.
|
||||
2 - Normal.
|
||||
3 - Loud.
|
||||
4 - Extra loud.</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>chn1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>chn2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>chn3</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>chn4</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="3">
|
||||
<widget class="QSpinBox" name="trnWeight_4">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>-125</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>125</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user