feat(cpn): add support for surface radios inc Radiomaster MT12 (#5381)

This commit is contained in:
Neil Horne
2024-09-26 20:39:51 +10:00
committed by GitHub
parent 2bd62c95c8
commit 149e1a2df0
90 changed files with 3746 additions and 2387 deletions
+36 -8
View File
@@ -29,23 +29,27 @@
#include "joystickdialog.h"
#endif
#include "moduledata.h"
#include "compounditemmodels.h"
#include "filtereditemmodels.h"
#include "updates/updatefactories.h"
#include "updates/updateoptionsdialog.h"
#include <QAbstractItemModel>
constexpr char FIM_TEMPLATESETUP[] {"Template Setup"};
AppPreferencesDialog::AppPreferencesDialog(QWidget * parent, UpdateFactories * factories) :
QDialog(parent),
ui(new Ui::AppPreferencesDialog),
updateLock(false),
mainWinHasDirtyChild(false),
factories(factories)
factories(factories),
panelItemModels(nullptr)
{
ui->setupUi(this);
setWindowIcon(CompanionIcon("apppreferences.png"));
ui->tabWidget->setCurrentIndex(0);
panelItemModels = new FilteredItemModelFactory();
panelItemModels->registerItemModel(new FilteredItemModel(GeneralSettings::templateSetupItemModel()), FIM_TEMPLATESETUP);
initSettings();
connect(ui->boardCB, SIGNAL(currentIndexChanged(int)), this, SLOT(onBaseFirmwareChanged()));
connect(ui->opt_appDebugLog, &QCheckBox::toggled, this, &AppPreferencesDialog::toggleAppLogSettings);
@@ -65,6 +69,7 @@ AppPreferencesDialog::AppPreferencesDialog(QWidget * parent, UpdateFactories * f
AppPreferencesDialog::~AppPreferencesDialog()
{
delete ui;
delete panelItemModels;
}
void AppPreferencesDialog::setMainWinHasDirtyChild(bool value)
@@ -156,8 +161,8 @@ void AppPreferencesDialog::accept()
profile.defaultInternalModule(ui->defaultInternalModuleCB->currentData().toInt());
profile.externalModuleSize(ui->externalModuleSizeCB->currentData().toInt());
profile.channelOrder(ui->channelorderCB->currentIndex());
profile.defaultMode(ui->stickmodeCB->currentIndex());
profile.channelOrder(ui->channelorderCB->currentData().toInt());
profile.defaultMode(ui->stickmodeCB->currentData().toInt());
profile.burnFirmware(ui->burnFirmware->isChecked());
profile.sdPath(ui->sdPath->text());
profile.pBackupDir(ui->profilebackupPath->text());
@@ -305,8 +310,12 @@ void AppPreferencesDialog::initSettings()
ui->defaultInternalModuleCB->setCurrentIndex(ui->defaultInternalModuleCB->findData(profile.defaultInternalModule()));
ui->externalModuleSizeCB->setModel(Boards::externalModuleSizeItemModel());
ui->externalModuleSizeCB->setCurrentIndex(ui->externalModuleSizeCB->findData(profile.externalModuleSize()));
ui->channelorderCB->setCurrentIndex(profile.channelOrder());
ui->stickmodeCB->setCurrentIndex(profile.defaultMode());
panelItemModels->getItemModel(FIM_TEMPLATESETUP)->setFilterFlags(Boards::isAir() ? GeneralSettings::RadioTypeContextAir :
GeneralSettings::RadioTypeContextSurface);
ui->channelorderCB->setModel(panelItemModels->getItemModel(FIM_TEMPLATESETUP));
ui->channelorderCB->setCurrentIndex(ui->channelorderCB->findData(profile.channelOrder()));
ui->stickmodeCB->setModel(GeneralSettings::stickModeItemModel());
ui->stickmodeCB->setCurrentIndex(ui->stickmodeCB->findData(profile.defaultMode()));
ui->sdPath->setText(profile.sdPath());
if (!profile.pBackupDir().isEmpty()) {
if (QDir(profile.pBackupDir()).exists()) {
@@ -321,6 +330,11 @@ void AppPreferencesDialog::initSettings()
ui->pbackupEnable->setDisabled(true);
}
if (Boards::isSurface()) {
ui->stickmodeLabel->hide();
ui->stickmodeCB->hide();
}
ui->profileNameLE->setText(profile.name());
QString hwSettings;
@@ -649,7 +663,8 @@ bool AppPreferencesDialog::displayImage(const QString & fileName)
return false;
ui->imageLabel->setPixmap(makePixMap(image));
ui->imageLabel->setFixedSize(getCurrentFirmware()->getCapability(LcdWidth), getCurrentFirmware()->getCapability(LcdHeight));
ui->imageLabel->setFixedSize(Boards::getCapability(getCurrentBoard(), Board::LcdWidth),
Boards::getCapability(getCurrentBoard(), Board::LcdHeight));
return true;
}
@@ -690,6 +705,19 @@ void AppPreferencesDialog::onBaseFirmwareChanged()
profile.externalModuleSize(Boards::getDefaultExternalModuleSize(newfw->getBoard()));
ui->externalModuleSizeCB->setModel(Boards::externalModuleSizeItemModel());
ui->externalModuleSizeCB->setCurrentIndex(ui->externalModuleSizeCB->findData(profile.externalModuleSize()));
if (Boards::isSurface()) {
profile.defaultMode(1);
ui->stickmodeLabel->hide();
ui->stickmodeCB->hide();
profile.channelOrder(0);
}
ui->stickmodeCB->setCurrentIndex(ui->stickmodeCB->findData(profile.defaultMode()));
panelItemModels->getItemModel(FIM_TEMPLATESETUP)->setFilterFlags(Boards::isAir() ? GeneralSettings::RadioTypeContextAir :
GeneralSettings::RadioTypeContextSurface);
ui->channelorderCB->setCurrentIndex(ui->channelorderCB->findData(profile.channelOrder()));
}
Firmware *AppPreferencesDialog::getBaseFirmware() const
+4
View File
@@ -28,6 +28,8 @@
#include <QCheckBox>
#include <QComboBox>
class FilteredItemModelFactory;
namespace Ui {
class AppPreferencesDialog;
}
@@ -95,6 +97,8 @@ class AppPreferencesDialog : public QDialog
QComboBox *cboReleaseChannel[MAX_COMPONENTS];
QPushButton *btnComponentOptions[MAX_COMPONENTS];
FilteredItemModelFactory *panelItemModels;
void loadUpdatesTab();
};
+2 -2
View File
@@ -624,7 +624,7 @@ Mode 4:
</widget>
</item>
<item row="15" column="0">
<widget class="QLabel" name="label_14">
<widget class="QLabel" name="stickmodeLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -676,7 +676,7 @@ Mode 4:
</widget>
</item>
<item row="16" column="0">
<widget class="QLabel" name="label_13">
<widget class="QLabel" name="channelorderLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -395,7 +395,7 @@ ThrottleSourceItemModel::ThrottleSourceItemModel(const GeneralSettings * const g
if (!modelData)
return;
setUpdateMask(IMUE_Timers | IMUE_Inputs | IMUE_TeleSensors);
setUpdateMask(IMUE_Channels);
for (int i = 0; i < modelData->thrTraceSrcCount(); i++) {
QStandardItem * modelItem = new QStandardItem();
@@ -407,7 +407,7 @@ ThrottleSourceItemModel::ThrottleSourceItemModel(const GeneralSettings * const g
void ThrottleSourceItemModel::setDynamicItemData(QStandardItem * item, const int value) const
{
item->setText(modelData->thrTraceSrcToString(value));
item->setText(modelData->thrTraceSrcToString(generalSettings, value));
item->setData(modelData->isThrTraceSrcAvailable(generalSettings, value), IMDR_Available);
}
+81 -6
View File
@@ -68,6 +68,7 @@ BoardJson::BoardJson(Board::Type board, QString hwdefn) :
m_inputs(new InputsTable),
m_switches(new SwitchesTable),
m_trims(new TrimsTable),
m_keys(new KeysTable),
m_inputCnt({0, 0, 0, 0, 0, 0, 0, 0, 0}),
m_switchCnt({0, 0, 0})
{
@@ -79,10 +80,12 @@ BoardJson::~BoardJson()
delete m_inputs;
delete m_switches;
delete m_trims;
delete m_keys;
}
// static
void BoardJson::afterLoadFixups(Board::Type board, InputsTable * inputs, SwitchesTable * switches)
void BoardJson::afterLoadFixups(Board::Type board, InputsTable * inputs, SwitchesTable * switches,
KeysTable * keys, TrimsTable * trims)
{
// TODO json files do not contain gyro defs
// Radio cmake directive IMU is currently used
@@ -114,8 +117,8 @@ void BoardJson::afterLoadFixups(Board::Type board, InputsTable * inputs, Switche
}
}
// Flex switches are not listed in json file
int count = IS_RADIOMASTER_TX16S(board) ? 2 : 0;
// Flex switches are not listed in json file for these radios
int count = IS_RADIOMASTER_TX16S(board) || IS_RADIOMASTER_MT12(board) ? 2 : 0;
for (int i = 1; i <= count; i++) {
QString tag = QString("FL%1").arg(i);
@@ -164,6 +167,9 @@ const int BoardJson::getCapability(const Board::Capability capability) const
case Board::InputSwitches:
return m_inputCnt.switches;
case Board::Keys:
return m_keys->size();
case Board::MultiposPots:
// assumes every input has potential to be one
// index used for mapping 6 pos switches back to input
@@ -332,6 +338,14 @@ const int BoardJson::getInputSliderIndex(int index)
return -1;
}
const int BoardJson::getInputThrottleIndex()
{
if (getCapability(Board::Sticks) > 0)
return getInputTagOffset(m_inputs, Boards::getCapability(m_board, Board::Air) ? "RV" : "TH");
return -1;
}
const int BoardJson::getInputTypeOffset(Board::AnalogInputType type)
{
return getInputTypeOffset(m_inputs, type);
@@ -371,6 +385,42 @@ Board::InputInfo BoardJson::getInputInfo(const InputsTable * inputs, int index)
return info;
}
const int BoardJson::getKeyIndex(const QString key) const
{
return getKeyIndex(m_keys, key);
}
// static
int BoardJson::getKeyIndex(const KeysTable * keys, QString key)
{
for (int i = 0; i < (int)keys->size(); i++) {
if (keys->at(i).key.c_str() == key)
return i;
}
return -1;
}
const Board::KeyInfo BoardJson::getKeyInfo(int index) const
{
return getKeyInfo(m_keys, index);
}
// static
Board::KeyInfo BoardJson::getKeyInfo(const KeysTable * keys, int index)
{
Board::KeyInfo info;
if (index >= 0 && index < (int)keys->size()) {
KeyDefn defn = keys->at(index);
info.name = defn.name;
info.key = defn.key;
info.label = defn.label;
}
return info;
}
// static
int BoardJson::getNumericSuffix(const std::string str)
{
@@ -771,10 +821,10 @@ bool BoardJson::loadDefinition()
if (m_board == Board::BOARD_UNKNOWN)
return true;
if (!loadFile(m_board, m_hwdefn, m_inputs, m_switches, m_trims))
if (!loadFile(m_board, m_hwdefn, m_inputs, m_switches, m_keys, m_trims))
return false;
afterLoadFixups(m_board, m_inputs, m_switches);
afterLoadFixups(m_board, m_inputs, m_switches, m_keys, m_trims);
setInputCounts(m_inputs, m_inputCnt);
setSwitchCounts(m_switches, m_switchCnt);
@@ -795,6 +845,7 @@ bool BoardJson::loadDefinition()
"flex inputs:" << getCapability(Board::FlexInputs) <<
"input switches:" << getCapability(Board::InputSwitches) <<
"trims:" << getCapability(Board::NumTrims) <<
"keys:" << getCapability(Board::Keys) <<
"std switches:" << getCapability(Board::StandardSwitches) <<
"flex switches:" << getCapability(Board::FlexSwitches) <<
"func switches:" << getCapability(Board::FunctionSwitches) <<
@@ -805,7 +856,8 @@ bool BoardJson::loadDefinition()
}
// static
bool BoardJson::loadFile(Board::Type board, QString hwdefn, InputsTable * inputs, SwitchesTable * switches, TrimsTable * trims)
bool BoardJson::loadFile(Board::Type board, QString hwdefn, InputsTable * inputs, SwitchesTable * switches,
KeysTable * keys, TrimsTable * trims)
{
if (board == Board::BOARD_UNKNOWN) {
return false;
@@ -952,6 +1004,29 @@ bool BoardJson::loadFile(Board::Type board, QString hwdefn, InputsTable * inputs
}
}
if (obj.value("keys").isArray()) {
const QJsonArray &kys = obj.value("keys").toArray();
for (const QJsonValue &key : kys)
{
if (key.isObject()) {
const QJsonObject &o = key.toObject();
KeyDefn k;
if (!o.value("name").isUndefined()) {
k.name = o.value("name").toString().toStdString();
k.key = o.value("key").toString().toStdString();
k.label = o.value("label").toString().toStdString();
k.tag = k.name;
}
keys->insert(keys->end(), k);
// qDebug() << "name:" << k.name.c_str() << "key:" << k.key.c_str() << "label:" << k.label.c_str();
}
}
}
if (obj.value("trims").isArray()) {
const QJsonArray &trms = obj.value("trims").toArray();
+25 -2
View File
@@ -76,6 +76,19 @@ class BoardJson
typedef std::vector<SwitchDefn> SwitchesTable;
struct KeyDefn {
std::string tag = "";
std::string name = "";
std::string key = "";
std::string label = "";
Board::LookupValueType cfgYaml = Board::LVT_TAG;
Board::LookupValueType refYaml = Board::LVT_NAME;
KeyDefn() = default;
};
typedef std::vector<KeyDefn> KeysTable;
struct TrimDefn {
std::string tag = "";
std::string name = "";
@@ -106,6 +119,7 @@ class BoardJson
const int getInputSliderIndex(int index);
const QString getInputTag(int index) const;
const int getInputTagOffset(QString tag);
const int getInputThrottleIndex();
const int getInputTypeOffset(Board::AnalogInputType type);
const int getInputYamlIndex(const QString val, YamlLookupType ylt) const;
const QString getInputYamlName(int index, YamlLookupType ylt) const;
@@ -119,6 +133,9 @@ class BoardJson
const bool isInputStick(int index) const;
const bool isInputSwitch(int index) const;
const Board::KeyInfo getKeyInfo(int index) const;
const int getKeyIndex(const QString key) const;
const int getSwitchIndex(const QString val, Board::LookupValueType lvt) const;
const Board::SwitchInfo getSwitchInfo(int index) const;
const QString getSwitchName(int index) const;
@@ -144,6 +161,7 @@ private:
InputsTable *m_inputs;
SwitchesTable *m_switches;
TrimsTable *m_trims;
KeysTable *m_keys;
struct InputCounts {
unsigned int flexGyroAxes;
@@ -167,8 +185,10 @@ private:
SwitchCounts m_switchCnt;
static bool loadFile(Board::Type board, QString hwdefn, InputsTable * inputs, SwitchesTable * switches, TrimsTable * trims);
static void afterLoadFixups(Board::Type board, InputsTable * inputs, SwitchesTable * switches);
static bool loadFile(Board::Type board, QString hwdefn, InputsTable * inputs, SwitchesTable * switches,
KeysTable * keys, TrimsTable * trims);
static void afterLoadFixups(Board::Type board, InputsTable * inputs, SwitchesTable * switches,
KeysTable * keys, TrimsTable * trims);
static int getInputsCalibrated(const InputsTable * inputs);
@@ -179,6 +199,9 @@ private:
static int getInputTagOffset(const InputsTable * inputs, QString tag);
static int getInputTypeOffset(const InputsTable * inputs, Board::AnalogInputType type);
static int getKeyIndex(const KeysTable * keys, QString key);
static Board::KeyInfo getKeyInfo(const KeysTable * keys, int index);
static int getSwitchIndex(const SwitchesTable * switches, QString val, Board::LookupValueType lvt);
static Board::SwitchInfo getSwitchInfo(const SwitchesTable * switches, int index);
static QString getSwitchName(const SwitchesTable * switches, int index);
+90 -9
View File
@@ -199,6 +199,7 @@ int Boards::getEEpromSize(Board::Type board)
case BOARD_RADIOMASTER_ZORRO:
case BOARD_RADIOMASTER_BOXER:
case BOARD_RADIOMASTER_POCKET:
case BOARD_RADIOMASTER_MT12:
return EESIZE_TARANIS;
case BOARD_UNKNOWN:
return EESIZE_MAX;
@@ -256,6 +257,7 @@ int Boards::getFlashSize(Type board)
case BOARD_RADIOMASTER_BOXER:
case BOARD_RADIOMASTER_T8:
case BOARD_RADIOMASTER_POCKET:
case BOARD_RADIOMASTER_MT12:
return FSIZE_TARANIS;
case BOARD_HORUS_X12S:
case BOARD_X10:
@@ -283,6 +285,9 @@ int Boards::getCapability(Board::Type board, Board::Capability capability)
// TODO investigate usage of any that should be covered in BoardJson::getCapability or are no longer required
// some could be used when importing pre v2.10 configurations
switch (capability) {
case Air:
return !getCapability(board, Surface);
case FactoryInstalledPots:
if (IS_TARANIS_X9(board))
return 2;
@@ -340,6 +345,40 @@ int Boards::getCapability(Board::Type board, Board::Capability capability)
IS_RADIOMASTER_TX12_MK2(board) || IS_RADIOMASTER_BOXER(board) || IS_RADIOMASTER_POCKET(board)) ||
(getCapability(board, HasExternalModuleSupport) && (IS_TARANIS(board) && !IS_FAMILY_T12(board))));
case LcdDepth:
if (IS_FAMILY_HORUS_OR_T16(board))
return 16;
else if (IS_TARANIS_SMALL(board))
return 1;
else if (IS_TARANIS(board))
return 4;
else
return 1;
case LcdHeight:
if (IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board))
return 480;
else if (IS_FLYSKY_PL18(board) || IS_JUMPER_T15(board))
return 320;
else if (IS_FAMILY_HORUS_OR_T16(board))
return 272;
else
return 64;
case LcdWidth:
if (IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board))
return 320;
else if (IS_FLYSKY_PL18(board))
return 480;
else if (IS_FAMILY_HORUS_OR_T16(board))
return 480;
else if (IS_TARANIS_SMALL(board))
return 128;
else if (IS_TARANIS(board))
return 212;
else
return 128;
case MaxAnalogs:
return getCapability(board, Board::Sticks) + getCapability(board, Board::Pots) + getCapability(board, Board::Sliders) +
getCapability(board, Board::JoystickAxes) + getCapability(board, Board::GyroAxes);
@@ -351,6 +390,9 @@ int Boards::getCapability(Board::Type board, Board::Capability capability)
else
return 250000; // less than 400K
case Surface:
return IS_RADIOMASTER_MT12(board);
default:
return getBoardJson(board)->getCapability(capability);
}
@@ -557,20 +599,22 @@ QString Boards::getBoardName(Board::Type board)
return "Jumper T20";
case BOARD_JUMPER_T20V2:
return "Jumper T20 V2";
case BOARD_RADIOMASTER_TX16S:
return "Radiomaster TX16S";
case BOARD_RADIOMASTER_TX12:
return "Radiomaster TX12";
case BOARD_RADIOMASTER_TX12_MK2:
return "Radiomaster TX12 Mark II";
case BOARD_RADIOMASTER_ZORRO:
return "Radiomaster Zorro";
case BOARD_RADIOMASTER_BOXER:
return "Radiomaster Boxer";
case BOARD_RADIOMASTER_POCKET:
return "Radiomaster Pocket";
case BOARD_RADIOMASTER_MT12:
return "Radiomaster MT12";
case BOARD_RADIOMASTER_T8:
return "Radiomaster T8";
case BOARD_RADIOMASTER_TX12:
return "Radiomaster TX12";
case BOARD_RADIOMASTER_TX12_MK2:
return "Radiomaster TX12 Mark II";
case BOARD_RADIOMASTER_TX16S:
return "Radiomaster TX16S";
case BOARD_RADIOMASTER_ZORRO:
return "Radiomaster Zorro";
case BOARD_FLYSKY_NV14:
return "FlySky NV14";
case BOARD_FLYSKY_EL18:
@@ -637,6 +681,11 @@ QList<int> Boards::getSupportedInternalModules(Board::Type board)
(int)MODULE_TYPE_FLYSKY_AFHDS3,
(int)MODULE_TYPE_CROSSFIRE,
});
} else if (IS_RADIOMASTER_MT12(board)) {
modules.append({
(int)MODULE_TYPE_CROSSFIRE,
(int)MODULE_TYPE_MULTIMODULE,
});
} else if (IS_FAMILY_HORUS_OR_T16(board) || IS_FAMILY_T12(board) ||
(IS_TARANIS_SMALL(board) && IS_ACCESS_RADIO(board))) {
modules.append({
@@ -688,6 +737,7 @@ int Boards::getDefaultInternalModules(Board::Type board)
case BOARD_BETAFPV_LR3PRO:
case BOARD_RADIOMASTER_ZORRO:
case BOARD_RADIOMASTER_BOXER:
case BOARD_RADIOMASTER_MT12:
case BOARD_RADIOMASTER_POCKET:
case BOARD_RADIOMASTER_TX12_MK2:
case BOARD_IFLIGHT_COMMANDO8:
@@ -729,7 +779,7 @@ void Boards::getBattRange(Board::Type board, int& vmin, int& vmax, unsigned int&
case BOARD_RADIOMASTER_BOXER:
case BOARD_RADIOMASTER_POCKET:
case BOARD_RADIOMASTER_ZORRO:
// case BOARD_RADIOMASTER_MT12: // TODO
case BOARD_RADIOMASTER_MT12:
case BOARD_JUMPER_T12:
case BOARD_JUMPER_T14:
case BOARD_JUMPER_TPRO:
@@ -786,6 +836,7 @@ int Boards::getDefaultExternalModuleSize(Board::Type board)
if (IS_TARANIS_X9LITE(board) ||
IS_RADIOMASTER_ZORRO(board) ||
IS_RADIOMASTER_MT12(board) ||
IS_RADIOMASTER_POCKET(board) ||
IS_JUMPER_TLITE(board) ||
IS_JUMPER_TPRO(board) ||
@@ -909,6 +960,11 @@ int Boards::getInputTagOffset(QString tag, Board::Type board)
return getBoardJson(board)->getInputTagOffset(tag);
}
int Boards::getInputThrottleIndex(Board::Type board)
{
return getBoardJson(board)->getInputThrottleIndex();
}
int Boards::getInputTypeOffset(Board::AnalogInputType type, Board::Type board)
{
return getBoardJson(board)->getInputTypeOffset(type);
@@ -929,6 +985,16 @@ int Boards::getInputsCalibrated(Board::Type board)
return getBoardJson(board)->getInputsCalibrated();
}
Board::KeyInfo Boards::getKeyInfo(int index, Board::Type board)
{
return getBoardJson(board)->getKeyInfo(index);
}
int Boards::getKeyIndex(QString key, Board::Type board)
{
return getBoardJson(board)->getKeyIndex(key);
}
Board::SwitchInfo Boards::getSwitchInfo(int index, Board::Type board)
{
return getBoardJson(board)->getSwitchInfo(index);
@@ -1023,3 +1089,18 @@ bool Boards::isSwitchFunc(int index, Board::Type board)
{
return getBoardJson(board)->isSwitchFunc(index);
}
QString Boards::getRadioTypeString(Board::Type board)
{
return getCapability(board == Board::BOARD_UNKNOWN ? getCurrentBoard() : board, Board::Air) ? tr("Flight") : tr("Drive");
}
bool Boards::isAir(Board::Type board)
{
return getCapability(board == Board::BOARD_UNKNOWN ? getCurrentBoard() : board, Board::Air);
}
bool Boards::isSurface(Board::Type board)
{
return getCapability(board == Board::BOARD_UNKNOWN ? getCurrentBoard() : board, Board::Surface);
}
+79
View File
@@ -88,6 +88,7 @@ namespace Board {
BOARD_JUMPER_T20V2,
BOARD_FATFISH_F16,
BOARD_HELLORADIOSKY_V16,
BOARD_RADIOMASTER_MT12,
BOARD_TYPE_COUNT,
BOARD_TYPE_MAX = BOARD_TYPE_COUNT - 1
};
@@ -160,7 +161,47 @@ namespace Board {
TRIM_SW_COUNT
};
enum StickAxesSurface {
STICK_AXIS_SURFACE_RH = 0, // Steering
STICK_AXIS_SURFACE_LV, // Throttle
STICK_AXIS_SURFACE_COUNT
};
enum TrimAxesSurface {
TRIM_AXIS_SURFACE_RH = 0,
TRIM_AXIS_SURFACE_LH, // Throttle axis vertical but its trim horizontal in lcd
TRIM_AXIS_SURFACE_T3,
TRIM_AXIS_SURFACE_T4,
TRIM_AXIS_SURFACE_T5,
TRIM_AXIS_SURFACE_T6,
TRIM_AXIS_SURFACE_T7,
TRIM_AXIS_SURFACE_T8,
TRIM_AXIS_SURFACE_COUNT
};
enum TrimSwitchesSurface
{
TRIM_SW_SURFACE_RH_DEC,
TRIM_SW_SURFACE_RH_INC,
TRIM_SW_SURFACE_LH_DEC, // Throttle axis vertical but its trim horizontal in lcd
TRIM_SW_SURFACE_LH_INC, // Throttle axis vertical but its trim horizontal in lcd
TRIM_SW_SURFACE_T3_DEC,
TRIM_SW_SURFACE_T3_INC,
TRIM_SW_SURFACE_T4_DEC,
TRIM_SW_SURFACE_T4_INC,
TRIM_SW_SURFACE_T5_DEC,
TRIM_SW_SURFACE_T5_INC,
TRIM_SW_SURFACE_T6_DEC,
TRIM_SW_SURFACE_T6_INC,
TRIM_SW_SURFACE_T7_DEC,
TRIM_SW_SURFACE_T7_INC,
TRIM_SW_SURFACE_T8_DEC,
TRIM_SW_SURFACE_T8_INC,
TRIM_SW_SURFACE_COUNT
};
enum Capability {
Air,
FactoryInstalledPots,
FactoryInstalledSwitches,
FlexInputs,
@@ -180,11 +221,15 @@ namespace Board {
HasTrainerModuleCPPM,
HasTrainerModuleSBUS,
HasVBat,
LcdDepth,
LcdHeight,
LcdWidth,
MaxAnalogs,
Inputs,
InputSwitches,
Joysticks,
JoystickAxes,
Keys,
MultiposPots,
MultiposPotsPositions,
NumFunctionSwitchesPositions,
@@ -195,6 +240,7 @@ namespace Board {
SportMaxBaudRate,
StandardSwitches,
Sticks,
Surface,
Switches,
SwitchesPositions,
};
@@ -294,6 +340,26 @@ namespace Board {
SwitchType dflt;
bool inverted;
};
struct KeyInfo {
KeyInfo() :
key(""),
name(""),
label("")
{}
std::string key;
std::string name;
std::string label;
};
struct TrimInfo {
TrimInfo() :
name("")
{}
std::string name;
};
}
class Boards
@@ -343,10 +409,14 @@ class Boards
static int getInputSliderIndex(int index, Board::Type board = Board::BOARD_UNKNOWN);
static QString getInputTag(int index, Board::Type board = Board::BOARD_UNKNOWN);
static int getInputTagOffset(QString tag, Board::Type board = Board::BOARD_UNKNOWN);
static int getInputThrottleIndex(Board::Type board = Board::BOARD_UNKNOWN);
static int getInputTypeOffset(Board::AnalogInputType type, Board::Type board = Board::BOARD_UNKNOWN);
static int getInputYamlIndex(QString val, int ylt, Board::Type board = Board::BOARD_UNKNOWN);
static QString getInputYamlName(int index, int ylt, Board::Type board = Board::BOARD_UNKNOWN);
static Board::KeyInfo getKeyInfo(int index, Board::Type board = Board::BOARD_UNKNOWN);
static int getKeyIndex(QString key, Board::Type board = Board::BOARD_UNKNOWN);
static Board::SwitchInfo getSwitchInfo(int index, Board::Type board = Board::BOARD_UNKNOWN);
static int getSwitchIndex(QString val, Board::LookupValueType lvt, Board::Type board = Board::BOARD_UNKNOWN);
static QString getSwitchName(int index, Board::Type board = Board::BOARD_UNKNOWN);
@@ -379,6 +449,9 @@ class Boards
static AbstractStaticItemModel * flexTypeItemModel();
static std::string getLegacyAnalogMappedInputTag(const char * legacytag, Board::Type board = Board::BOARD_UNKNOWN);
static QString getRadioTypeString(Board::Type board = Board::BOARD_UNKNOWN);
static bool isAir(Board::Type board = Board::BOARD_UNKNOWN);
static bool isSurface(Board::Type board = Board::BOARD_UNKNOWN);
private:
@@ -501,6 +574,11 @@ inline bool IS_RADIOMASTER_BOXER(Board::Type board)
return board == Board::BOARD_RADIOMASTER_BOXER;
}
inline bool IS_RADIOMASTER_MT12(Board::Type board)
{
return board == Board::BOARD_RADIOMASTER_MT12;
}
inline bool IS_RADIOMASTER_POCKET(Board::Type board)
{
return board == Board::BOARD_RADIOMASTER_POCKET;
@@ -542,6 +620,7 @@ inline bool IS_FAMILY_T12(Board::Type board)
board == Board::BOARD_RADIOMASTER_TX12_MK2 ||
board == Board::BOARD_RADIOMASTER_ZORRO ||
board == Board::BOARD_RADIOMASTER_BOXER ||
board == Board::BOARD_RADIOMASTER_MT12 ||
board == Board::BOARD_RADIOMASTER_POCKET ||
board == Board::BOARD_RADIOMASTER_T8 ||
board == Board::BOARD_BETAFPV_LR3PRO ||
@@ -262,7 +262,7 @@ Node convert<GeneralSettings>::encode(const GeneralSettings& rhs)
node["labelSingleSelect"] = rhs.labelSingleSelect;
node["labelMultiMode"] = rhs.labelMultiMode;
node["favMultiMode"] = rhs.favMultiMode;
} else if (fw->getCapability(LcdWidth) == 128) {
} else if (Boards::getCapability(board, Board::LcdWidth) == 128) {
node["invertLCD"] = (int)rhs.invertLCD;
}
@@ -167,38 +167,42 @@ struct YamlThrTrace {
YamlThrTrace(unsigned int cpn_value)
{
Board::Type board = getCurrentBoard();
if (cpn_value == 0) {
src = RawSource(SOURCE_TYPE_INPUT, 2/* throttle */);
if (Boards::getInputThrottleIndex(board) >= 0)
src = RawSource(SOURCE_TYPE_INPUT, Boards::getInputThrottleIndex(board) + 1);
else
src = RawSource(SOURCE_TYPE_NONE);
return;
}
cpn_value--;
Boards board(getCurrentBoard());
int pots = board.getCapability(Board::Pots);
int sliders = board.getCapability(Board::Sliders);
if (cpn_value < (unsigned int)(pots + sliders)) {
src = RawSource(SOURCE_TYPE_INPUT, 4/* sticks */ + cpn_value);
}
else {
cpn_value -= pots + sliders;
src = RawSource(SOURCE_TYPE_CH, cpn_value);
}
int sticks = Boards::getCapability(board, Board::Sticks);
int pots = Boards::getCapability(board, Board::Pots);
int sliders = Boards::getCapability(board, Board::Sliders);
if (cpn_value <= (unsigned int)(pots + sliders))
src = RawSource(SOURCE_TYPE_INPUT, sticks + cpn_value);
else
src = RawSource(SOURCE_TYPE_CH, cpn_value - pots - sliders);
}
unsigned int toCpn()
{
Board::Type board = getCurrentBoard();
int sticks = Boards::getCapability(board, Board::Sticks);
switch (src.type) {
case SOURCE_TYPE_INPUT:
if (src.index == 2 /* throttle */) {
if (src.index == Boards::getInputThrottleIndex(board) + 1)
return 0;
} else {
return src.index - 4/* sticks */ + 1;
}
else
return src.index - sticks;
break;
case SOURCE_TYPE_CH: {
Boards board(getCurrentBoard());
int pots = board.getCapability(Board::Pots);
int sliders = board.getCapability(Board::Sliders);
return 1 + pots + sliders + src.index;
int pots = Boards::getCapability(board, Board::Pots);
int sliders = Boards::getCapability(board, Board::Sliders);
return pots + sliders + src.index;
} break;
default:
break;
@@ -162,7 +162,7 @@ RawSource YamlRawSourceDecode(const std::string& src_str)
} else if ((val_len == 2 &&
val[0] == 'S' &&
val[1] >= 'A' && val[1] <= 'Z') ||
val[1] >= 'A' && val[1] <= 'S') || // ST used for surface steering
(val_len == 3 && (
(val[0] == 'F' && val[1] == 'L') ||
(val[0] == 'S' && val[1] == 'W')) &&
+10 -8
View File
@@ -37,11 +37,16 @@
#include <iostream>
#include <string>
const uint8_t modn12x3[4][4]= {
{1, 2, 3, 4},
{1, 3, 2, 4},
{4, 2, 3, 1},
{4, 3, 2, 1} };
const uint8_t modn12x3[8][4]= {
{1, 2, 3, 4}, // air mode 1
{1, 3, 2, 4}, // air mode 2
{4, 2, 3, 1}, // air mode 3
{4, 3, 2, 1}, // air mode 4
{2, 3, 4, 1}, // surface mode 1
{2, 3, 4, 1}, // surface mode 2
{2, 3, 4, 1}, // surface mode 3
{2, 3, 4, 1} // surface mode 4
};
enum Capability {
Models,
@@ -129,9 +134,6 @@ enum Capability {
PermTimers,
HasSDLogs,
CSFunc,
LcdWidth,
LcdHeight,
LcdDepth,
GetThrSwitch,
HasDisplayText,
HasTopLcd,
+1 -1
View File
@@ -43,7 +43,7 @@ void FlightModeData::clear(const int phaseIdx)
QString FlightModeData::nameToString(int phaseIdx) const
{
return RadioData::getElementName(tr("FM"), phaseIdx, name); // names are zero-based, FM0, FM1, etc
return RadioData::getElementName(Boards::isAir() ? tr("FM") : tr("DM"), phaseIdx, name); // names are zero-based, FM0, FM1, etc
}
bool FlightModeData::isEmpty(int phaseIdx) const
+114 -4
View File
@@ -27,13 +27,41 @@
#include "compounditemmodels.h"
#include "yaml_ops.h"
const uint8_t chout_ar[] = { // First number is 0..23 -> template setup, Second is relevant channel out
const QList<int> channelsAir = { // First number is 0..23 -> template setup, Second is relevant channel out
1,2,3,4 , 1,2,4,3 , 1,3,2,4 , 1,3,4,2 , 1,4,2,3 , 1,4,3,2,
2,1,3,4 , 2,1,4,3 , 2,3,1,4 , 2,3,4,1 , 2,4,1,3 , 2,4,3,1,
3,1,2,4 , 3,1,4,2 , 3,2,1,4 , 3,2,4,1 , 3,4,1,2 , 3,4,2,1,
4,1,2,3 , 4,1,3,2 , 4,2,1,3 , 4,2,3,1 , 4,3,1,2 , 4,3,2,1
};
const QList<QChar> controlsAir = { 'R', 'E', 'T', 'A' }; // channelsAir[x] - 1] entry mapping
const QList<int> channelsSurface = { // First number is 0..1 -> template setup, Second is relevant channel out
1,2 , 2,1
};
const QList<QChar> controlsSurface = { 'S', 'T' }; // channelsSurface[x] - 1] entry mapping
const QList<int> useChannels(bool isBoardAir)
{
return isBoardAir ? channelsAir : channelsSurface;
}
const QList<QChar> useControls(bool isBoardAir)
{
return isBoardAir ? controlsAir : controlsSurface;
}
const int channelsCount(bool isBoardAir)
{
return isBoardAir ? channelsAir.size() : channelsSurface.size();
}
const int controlsCount(bool isBoardAir)
{
return isBoardAir ? controlsAir.size() : controlsSurface.size();
}
bool GeneralSettings::switchPositionAllowed(int index) const
{
if (index == 0)
@@ -351,13 +379,15 @@ int GeneralSettings::getDefaultStick(unsigned int channel) const
{
if (channel >= CPN_MAX_STICKS)
return -1;
else
return chout_ar[4 * templateSetup + channel] - 1;
else {
return useChannels(Boards::isAir())[controlsCount(Boards::isAir()) * templateSetup + channel] - 1;
}
}
RawSource GeneralSettings::getDefaultSource(unsigned int channel) const
{
int stick = getDefaultStick(channel);
if (stick >= 0)
return RawSource(SOURCE_TYPE_INPUT, stick + 1);
else
@@ -366,7 +396,7 @@ RawSource GeneralSettings::getDefaultSource(unsigned int channel) const
int GeneralSettings::getDefaultChannel(unsigned int stick) const
{
for (int i = 0; i < 4; i++){
for (int i = 0; i < controlsCount(Boards::isAir()); i++) {
if (getDefaultStick(i) == (int)stick)
return i;
}
@@ -959,3 +989,83 @@ AbstractStaticItemModel * TrainerMix::srcItemModel()
mdl->loadItemList();
return mdl;
}
QString GeneralSettings::stickModeToString() const
{
return stickModeToString(stickMode);
}
// static
QString GeneralSettings::stickModeToString(int value)
{
switch(value) {
case STICK_MODE_1:
return tr("Mode 1 (RUD ELE THR AIL)");
case STICK_MODE_2:
return tr("Mode 2 (RUD THR ELE AIL)");
case STICK_MODE_3:
return tr("Mode 3 (AIL ELE THR RUD)");
case STICK_MODE_4:
return tr("Mode 4 (AIL THR ELE RUD)");
default:
return CPN_STR_UNKNOWN_ITEM;
}
}
// static
AbstractStaticItemModel * GeneralSettings::stickModeItemModel()
{
AbstractStaticItemModel * mdl = new AbstractStaticItemModel();
mdl->setName(AIM_GS_STICKMODE);
for (int i = 0; i < STICK_MODE_COUNT; i++) {
mdl->appendToItemList(stickModeToString(i), i);
}
mdl->loadItemList();
return mdl;
}
QString GeneralSettings::templateSetupToString() const
{
return templateSetupToString(templateSetup, Boards::isAir());
}
// static
QString GeneralSettings::templateSetupToString(int value, bool isBoardAir)
{
QString ret;
const QList<int> channels = useChannels(isBoardAir);
const QList<QChar> controls = useControls(isBoardAir);
if (value < (channels.size() / controls.size())) {
for (int i = 0; i < controls.size(); i++) {
if (i > 0)
ret.append(" ");
int idx = channels[controls.size() * value + i] - 1;
if (idx >= 0 && idx < controls.size())
ret.append(controls[channels[controls.size() * value + i] - 1]);
}
}
return ret;
}
// static
AbstractStaticItemModel * GeneralSettings::templateSetupItemModel()
{
AbstractStaticItemModel * mdl = new AbstractStaticItemModel();
mdl->setName(AIM_GS_TEMPLATESETUP);
for (int i = 0; i < (channelsCount(true) / controlsCount(true)); i++) {
mdl->appendToItemList(templateSetupToString(i, true), i, true, 0, RadioTypeContextAir);
}
for (int i = 0; i < (channelsCount(false) / controlsCount(false)); i++) {
mdl->appendToItemList(templateSetupToString(i, false), i, true, 0, RadioTypeContextSurface);
}
mdl->loadItemList();
return mdl;
}
+22
View File
@@ -44,6 +44,9 @@ constexpr char AIM_GS_INTMODULEBAUDRATE[] {"gs.intmodulebaudrate"};
constexpr char AIM_GS_STICKDEADZONE[] {"gs.stickdeadzone"};
constexpr char AIM_GS_UARTSAMPLEMODE[] {"gs.uartsamplemode"};
constexpr char AIM_GS_HATSMODE[] {"gs.hatsmode"};
constexpr char AIM_GS_STICKMODE[] {"gs.stickmode"};
constexpr char AIM_GS_TEMPLATESETUP[] {"gs.templatesetup"};
constexpr char AIM_TRAINERMIX_MODE[] {"trainermix.mode"};
constexpr char AIM_TRAINERMIX_SRC[] {"trainermix.src"};
@@ -188,6 +191,19 @@ class GeneralSettings {
PPM_US
};
enum StickMode {
STICK_MODE_1,
STICK_MODE_2,
STICK_MODE_3,
STICK_MODE_4,
STICK_MODE_COUNT,
};
enum RadioTypeContext {
RadioTypeContextAir = 1 << 1,
RadioTypeContextSurface = 1 << 2,
};
GeneralSettings() { clear(); }
void clear();
void init();
@@ -394,6 +410,8 @@ class GeneralSettings {
QString internalModuleBaudrateToString() const;
QString uartSampleModeToString() const;
QString hatsModeToString() const;
QString stickModeToString() const;
QString templateSetupToString() const;
static QString antennaModeToString(int value);
static QString bluetoothModeToString(int value);
@@ -403,6 +421,8 @@ class GeneralSettings {
static FieldRange getTxCurrentCalibration();
static QString uartSampleModeToString(int value);
static QString hatsModeToString(int value);
static QString stickModeToString(int value);
static QString templateSetupToString(int value, bool isBoardAir);
static AbstractStaticItemModel * antennaModeItemModel(bool model_setup = false);
static AbstractStaticItemModel * bluetoothModeItemModel();
@@ -411,6 +431,8 @@ class GeneralSettings {
static AbstractStaticItemModel * stickDeadZoneItemModel();
static AbstractStaticItemModel * uartSampleModeItemModel();
static AbstractStaticItemModel * hatsModeItemModel(bool radio_setup = true);
static AbstractStaticItemModel * stickModeItemModel();
static AbstractStaticItemModel * templateSetupItemModel();
void validateFlexSwitches();
};
+13 -10
View File
@@ -193,7 +193,7 @@ bool ModelData::isEmpty() const
void ModelData::setDefaultInputs(const GeneralSettings & settings)
{
for (int i = 0; i < CPN_MAX_STICKS; i++) {
for (int i = 0; i < Boards::getCapability(getCurrentBoard(), Board::Sticks); i++) {
ExpoData * expo = &expoData[i];
expo->chn = i;
expo->mode = INPUT_MODE_BOTH;
@@ -207,7 +207,7 @@ void ModelData::setDefaultMixes(const GeneralSettings & settings)
{
setDefaultInputs(settings);
for (int i = 0; i < CPN_MAX_STICKS; i++) {
for (int i = 0; i < Boards::getCapability(getCurrentBoard(), Board::Sticks); i++) {
MixData * mix = &mixData[i];
mix->destCh = i + 1;
mix->weight = 100;
@@ -1492,20 +1492,21 @@ void ModelData::updateResetParam(CustomFunctionData * cfd)
QString ModelData::thrTraceSrcToString() const
{
return thrTraceSrcToString((int)thrTraceSrc);
return thrTraceSrcToString(nullptr, (int)thrTraceSrc);
}
QString ModelData::thrTraceSrcToString(const int index) const
QString ModelData::thrTraceSrcToString(const GeneralSettings * generalSettings, const int index) const
{
const Board::Type board = getCurrentBoard();
const int pscnt = Boards::getCapability(board, Board::Pots) + Boards::getCapability(board, Board::Sliders);
if (index == 0)
return tr("THR");
return Boards::getCapability(board, Board::Air) ? tr("THR") : tr("TH");
else if (index <= pscnt)
return Boards::getInputName(index + Boards::getCapability(board, Board::Sticks) - 1, board);
//return Boards::getInputName(index + Boards::getCapability(board, Board::Sticks) - 1, board);
return RawSource(SOURCE_TYPE_INPUT, index + Boards::getCapability(board, Board::Sticks)).toString(this, generalSettings, board);
else if (index <= pscnt + getCurrentFirmware()->getCapability(Outputs))
return RawSource(SOURCE_TYPE_CH, index - pscnt - 1).toString(this);
return RawSource(SOURCE_TYPE_CH, index - pscnt).toString(this);
return QString(CPN_STR_UNKNOWN_ITEM);
}
@@ -1522,10 +1523,12 @@ bool ModelData::isThrTraceSrcAvailable(const GeneralSettings * generalSettings,
{
const Board::Type board = getCurrentBoard();
if (index > 0 && index <= Boards::getCapability(board, Board::Pots) + Boards::getCapability(board, Board::Sliders))
return RawSource(SOURCE_TYPE_INPUT, index + Boards::getCapability(board, Board::Sticks) - 1).isAvailable(this, generalSettings, board);
else
if (index == 0)
return true;
else if (index > 0 && index <= Boards::getCapability(board, Board::Pots) + Boards::getCapability(board, Board::Sliders))
return RawSource(SOURCE_TYPE_INPUT, index + Boards::getCapability(board, Board::Sticks)).isAvailable(this, generalSettings, board);
else
return hasMixes(index - Boards::getCapability(board, Board::Pots) - Boards::getCapability(board, Board::Sliders) - 1);
}
void ModelData::limitsClear(const int index)
+2 -2
View File
@@ -314,7 +314,7 @@ class ModelData {
bool hasExpoSiblings(const int index);
void removeMix(const int idx);
QString thrTraceSrcToString() const;
QString thrTraceSrcToString(const int index) const;
QString thrTraceSrcToString(const GeneralSettings * generalSettings, const int index) const;
int thrTraceSrcCount() const;
bool isThrTraceSrcAvailable(const GeneralSettings * generalSettings, const int index) const;
@@ -336,7 +336,7 @@ class ModelData {
static AbstractStaticItemModel * funcSwitchConfigItemModel();
static AbstractStaticItemModel * funcSwitchGroupStartSwitchModel(int switchcnt);
static AbstractStaticItemModel * funcSwitchGroupsModel();
unsigned int getFuncSwitchGroup(unsigned int index) const;
void setFuncSwitchGroup(unsigned int index, unsigned int value);
@@ -545,7 +545,9 @@ int OpenTxFirmware::getCapability(::Capability capability)
case FlightModesHaveFades:
return 1;
case Heli:
if (IS_HORUS_OR_TARANIS(board))
if (Boards::getCapability(board, Board::Surface))
return false;
else if (IS_HORUS_OR_TARANIS(board))
return id.contains("noheli") ? 0 : 1;
else
return id.contains("heli") ? 1 : 0;
@@ -674,9 +676,9 @@ int OpenTxFirmware::getCapability(::Capability capability)
case OptrexDisplay:
return (board == BOARD_SKY9X ? true : false);
case HasVario:
return 1;
return Boards::isAir(board);
case HasVarioSink:
return true;
return Boards::isAir(board);
case HasFailsafe:
return 32;
case NumModules:
@@ -705,37 +707,6 @@ int OpenTxFirmware::getCapability(::Capability capability)
return 18;
case HasSDLogs:
return true;
case LcdWidth:
if (IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board))
return 320;
else if (IS_FLYSKY_PL18(board))
return 480;
else if (IS_FAMILY_HORUS_OR_T16(board))
return 480;
else if (IS_TARANIS_SMALL(board))
return 128;
else if (IS_TARANIS(board))
return 212;
else
return 128;
case LcdHeight:
if (IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board))
return 480;
else if (IS_FLYSKY_PL18(board) || IS_JUMPER_T15(board))
return 320;
else if (IS_FAMILY_HORUS_OR_T16(board))
return 272;
else
return 64;
case LcdDepth:
if (IS_FAMILY_HORUS_OR_T16(board))
return 16;
else if (IS_TARANIS_SMALL(board))
return 1;
else if (IS_TARANIS(board))
return 4;
else
return 1;
case GetThrSwitch:
return (IS_HORUS_OR_TARANIS(board) ? SWITCH_SF1 : SWITCH_THR);
case HasDisplayText:
@@ -817,12 +788,14 @@ int OpenTxFirmware::getCapability(::Capability capability)
case HasAuxSerialMode:
return (IS_FAMILY_HORUS_OR_T16(board) && !(IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board))) ||
(IS_TARANIS_X9(board) && !IS_TARANIS_X9DP_2019(board)) ||
IS_RADIOMASTER_ZORRO(board) || IS_RADIOMASTER_TX12_MK2(board);
IS_RADIOMASTER_ZORRO(board) || IS_RADIOMASTER_TX12_MK2(board) || IS_RADIOMASTER_MT12(board);
case HasAux2SerialMode:
return IS_FAMILY_T16(board);
case HasVCPSerialMode:
return IS_FAMILY_HORUS_OR_T16(board) || IS_RADIOMASTER_ZORRO(board) ||
IS_JUMPER_TPRO(board) || IS_RADIOMASTER_TX12_MK2(board) || IS_RADIOMASTER_BOXER(board) || IS_RADIOMASTER_POCKET(board);
IS_JUMPER_TPRO(board) || IS_RADIOMASTER_TX12_MK2(board) ||
IS_RADIOMASTER_BOXER(board) || IS_RADIOMASTER_POCKET(board) ||
IS_RADIOMASTER_MT12(board);
case HasBluetooth:
return (IS_FAMILY_HORUS_OR_T16(board) || IS_TARANIS_X7(board) || IS_TARANIS_XLITE(board)|| IS_TARANIS_X9E(board) ||
IS_TARANIS_X9DP_2019(board) || IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board) || IS_FLYSKY_PL18(board)) ? true : false;
@@ -831,7 +804,7 @@ int OpenTxFirmware::getCapability(::Capability capability)
case HasTelemetryBaudrate:
return IS_HORUS_OR_TARANIS(board);
case TopBarZones:
return getCapability(LcdWidth) > getCapability(LcdHeight) ? 4 : 2;
return Boards::getCapability(board, Board::LcdWidth) > Boards::getCapability(board, Board::LcdHeight) ? 4 : 2;
case HasModelsList:
return IS_FAMILY_HORUS_OR_T16(board);
case HasFlySkyGimbals:
@@ -843,7 +816,7 @@ int OpenTxFirmware::getCapability(::Capability capability)
IS_RADIOMASTER_TX12_MK2(board) || IS_RADIOMASTER_ZORRO(board) ||
IS_RADIOMASTER_BOXER(board) || IS_RADIOMASTER_TX16S(board) ||
IS_JUMPER_T18(board) || IS_JUMPER_T20(board) ||
IS_RADIOMASTER_POCKET(board));
IS_RADIOMASTER_POCKET(board) || IS_RADIOMASTER_MT12(board));
case HasSoftwareSerialPower:
return IS_RADIOMASTER_TX16S(board);
case HasIntModuleMulti:
@@ -851,13 +824,15 @@ int OpenTxFirmware::getCapability(::Capability capability)
IS_RADIOMASTER_TX12(board) || IS_JUMPER_TLITE(board) || IS_BETAFPV_LR3PRO(board) ||
(IS_RADIOMASTER_ZORRO(board) && !id.contains("internalelrs")) ||
(IS_RADIOMASTER_BOXER(board) && !id.contains("internalelrs")) ||
(IS_RADIOMASTER_POCKET(board) && !id.contains("internalelrs"));
(IS_RADIOMASTER_POCKET(board) && !id.contains("internalelrs")) ||
(IS_RADIOMASTER_MT12(board) && !id.contains("internalelrs"));
case HasIntModuleCRSF:
return id.contains("internalcrsf");
case HasIntModuleELRS:
return id.contains("internalelrs") || IS_RADIOMASTER_TX12_MK2(board) ||
IS_IFLIGHT_COMMANDO8(board) || IS_RADIOMASTER_BOXER(board) ||
IS_RADIOMASTER_POCKET(board) || IS_JUMPER_T20(board);
IS_RADIOMASTER_POCKET(board) || IS_JUMPER_T20(board) ||
IS_RADIOMASTER_MT12(board);
case HasIntModuleFlySky:
return id.contains("afhds2a") || id.contains("afhds3") ||
IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board);
@@ -1529,6 +1504,15 @@ void registerOpenTxFirmwares()
registerOpenTxFirmware(firmware);
addOpenTxRfOptions(firmware, FLEX + AFHDS2A + AFHDS3);
/* Radiomaster MT12 board */
firmware = new OpenTxFirmware(FIRMWAREID("mt12"), QCoreApplication::translate("Firmware", "Radiomaster MT12"), Board::BOARD_RADIOMASTER_MT12);
addOpenTxCommonOptions(firmware);
firmware->addOption("nogvars", Firmware::tr("Disable Global variables"));
firmware->addOption("lua", Firmware::tr("Enable Lua custom scripts screen"));
addOpenTxFontOptions(firmware);
registerOpenTxFirmware(firmware);
addOpenTxRfOptions(firmware, NONE);
/* Radiomaster T8 board */
firmware = new OpenTxFirmware(FIRMWAREID("t8"), QCoreApplication::translate("Firmware", "Radiomaster T8"), BOARD_RADIOMASTER_T8);
addOpenTxCommonOptions(firmware);
+24 -6
View File
@@ -137,8 +137,12 @@ QString RawSource::toString(const ModelData * model, const GeneralSettings * con
if (board == Board::BOARD_UNKNOWN)
board = getCurrentBoard();
static const QString trims[] = {
"", tr("TrmR"), tr("TrmE"), tr("TrmT"), tr("TrmA"), tr("Trm5"), tr("Trm6"), tr("Trm7"), tr("Trm8")
static const QString trimsAir[] = {
"", tr("Trim Rud"), tr("Trim Ele"), tr("Trim Thr"), tr("Trim Ail"), tr("Trim 5"), tr("Trim 6"), tr("Trim 7"), tr("Trim 8")
};
static const QString trimsSurface[] = {
"", tr("Trim ST"), tr("Trim TH"), tr("Trim 3"), tr("Trim 4"), tr("Trim 5"), tr("Trim 6"), tr("Trim 7"), tr("Trim 8")
};
static const QString trims2[] = {
@@ -180,7 +184,9 @@ QString RawSource::toString(const ModelData * model, const GeneralSettings * con
return DataHelpers::getCompositeName(dfltName, custName, prefixCustomName);
case SOURCE_TYPE_TRIM:
return (Boards::getCapability(board, Board::NumTrims) == 2 ? CHECK_IN_ARRAY(trims2, index) : CHECK_IN_ARRAY(trims, index));
return (Boards::getCapability(board, Board::NumTrims) == 2 ? CHECK_IN_ARRAY(trims2, index) :
(Boards::isAir(board) ? CHECK_IN_ARRAY(trimsAir, index) :
CHECK_IN_ARRAY(trimsSurface, index)));
case SOURCE_TYPE_ROTARY_ENCODER:
return CHECK_IN_ARRAY(rotary, index);
@@ -286,6 +292,7 @@ bool RawSource::isAvailable(const ModelData * const model, const GeneralSettings
board = getCurrentBoard();
Boards b(board);
Firmware *firmware = getCurrentFirmware();
if (type == SOURCE_TYPE_CH && abs(index) > CPN_MAX_CHNOUT)
return false;
@@ -296,9 +303,6 @@ bool RawSource::isAvailable(const ModelData * const model, const GeneralSettings
if (type == SOURCE_TYPE_CUSTOM_SWITCH && abs(index) > CPN_MAX_LOGICAL_SWITCHES)
return false;
if (type == SOURCE_TYPE_FUNCTIONSWITCH_GROUP && b.getCapability(Board::FunctionSwitches) && model->getFuncGroupSwitchCount(abs(index), CPN_MAX_SWITCHES_FUNCTION) == 0)
return false;
if (type == SOURCE_TYPE_LUA_OUTPUT && div(abs(index - 1), 16).quot >= CPN_MAX_SCRIPTS)
return false;
@@ -317,6 +321,9 @@ bool RawSource::isAvailable(const ModelData * const model, const GeneralSettings
if (type == SOURCE_TYPE_TELEMETRY && div(abs(index), 3).quot > CPN_MAX_SENSORS)
return false;
if (type == SOURCE_TYPE_CYC && !firmware->getCapability(Heli))
return false;
if (model) {
if (type == SOURCE_TYPE_TIMER && model->timers[abs(index) - 1].isModeOff())
return false;
@@ -342,6 +349,17 @@ bool RawSource::isAvailable(const ModelData * const model, const GeneralSettings
if (type == SOURCE_TYPE_CH && !model->hasMixes(abs(index) - 1))
return false;
if (type == SOURCE_TYPE_FUNCTIONSWITCH_GROUP) {
if (!b.getCapability(Board::FunctionSwitches))
return false;
else if (model->getFuncGroupSwitchCount(abs(index), CPN_MAX_SWITCHES_FUNCTION) == 0)
return false;
}
}
else {
if (type == SOURCE_TYPE_FUNCTIONSWITCH_GROUP && b.getCapability(Board::FunctionSwitches))
return false;
}
if (gs) {
+23 -10
View File
@@ -37,15 +37,26 @@ QString RawSwitch::toString(Board::Type board, const GeneralSettings * const gen
QString("AIL"), QString("GEA"), QString("TRN")
};
static const QString trimsSwitches[] = {
tr("Rud-"), tr("Rud+"),
tr("Ele-"), tr("Ele+"),
tr("Thr-"), tr("Thr+"),
tr("Ail-"), tr("Ail+"),
tr("T5-"), tr("T5+"),
tr("T6-"), tr("T6+"),
tr("T7-"), tr("T7+"),
tr("T8-"), tr("T8+")
static const QString trimsSwitchesAir[] = {
tr("Trim Rud-"), tr("Trim Rud+"),
tr("Trim Ele-"), tr("Trim Ele+"),
tr("Trim Thr-"), tr("Trim Thr+"),
tr("Trim Ail-"), tr("Trim Ail+"),
tr("Trim T5-"), tr("Trim T5+"),
tr("Trim T6-"), tr("Trim T6+"),
tr("Trim T7-"), tr("Trim T7+"),
tr("Trim T8-"), tr("Trim T8+")
};
static const QString trimsSwitchesSurface[] = {
tr("Trim ST-"), tr("Trim ST+"),
tr("Trim TH-"), tr("Trim TH+"),
tr("Trim T3-"), tr("Trim T3+"),
tr("Trim T4-"), tr("Trim T4+"),
tr("Trim T5-"), tr("Trim T5+"),
tr("Trim T6-"), tr("Trim T6+"),
tr("Trim T7-"), tr("Trim T7+"),
tr("Trim T8-"), tr("Trim T8+")
};
static const QString trimsSwitches2[] = {
@@ -115,7 +126,9 @@ QString RawSwitch::toString(Board::Type board, const GeneralSettings * const gen
case SWITCH_TYPE_TRIM:
return (Boards::getCapability(board, Board::NumTrims) == 2 ?
CHECK_IN_ARRAY(trimsSwitches2, index - 1) : CHECK_IN_ARRAY(trimsSwitches, index - 1));
CHECK_IN_ARRAY(trimsSwitches2, index - 1) :
(Boards::isAir(board) ? CHECK_IN_ARRAY(trimsSwitchesAir, index - 1) :
CHECK_IN_ARRAY(trimsSwitchesSurface, index - 1)));
case SWITCH_TYPE_ROTARY_ENCODER:
return CHECK_IN_ARRAY(rotaryEncoders, index - 1);
+1 -1
View File
@@ -68,7 +68,7 @@ GeneralOptionsPanel::GeneralOptionsPanel(QWidget * parent, GeneralSettings & gen
addParams();
}
addLabel(tr("Flight Modes"));
addLabel(tr("%1 Modes").arg(Boards::getRadioTypeString(board)));
AutoCheckBox *fmDisable = new AutoCheckBox(this);
fmDisable->setField(generalSettings.modelFMDisabled, this, true);
params->append(fmDisable);
+314 -184
View File
@@ -26,6 +26,10 @@
#include "autocombobox.h"
#include "namevalidator.h"
constexpr char FIM_HATSMODE[] {"Hats Mode"};
constexpr char FIM_STICKMODE[] {"Stick Mode"};
constexpr char FIM_TEMPLATESETUP[] {"Template Setup"};
GeneralSetupPanel::GeneralSetupPanel(QWidget * parent, GeneralSettings & generalSettings, Firmware * firmware):
GeneralPanel(parent, generalSettings, firmware),
ui(new Ui::GeneralSetup)
@@ -34,6 +38,15 @@ ui(new Ui::GeneralSetup)
Board::Type board = firmware->getBoard();
panelFilteredModels = new FilteredItemModelFactory();
panelFilteredModels->registerItemModel(new FilteredItemModel(GeneralSettings::hatsModeItemModel()), FIM_HATSMODE);
panelFilteredModels->registerItemModel(new FilteredItemModel(GeneralSettings::stickModeItemModel()), FIM_STICKMODE);
panelFilteredModels->registerItemModel(new FilteredItemModel(GeneralSettings::templateSetupItemModel(),
Boards::isAir(board) ? GeneralSettings::RadioTypeContextAir :
GeneralSettings::RadioTypeContextSurface),
FIM_TEMPLATESETUP);
QLabel *pmsl[] = {ui->ro_label, ui->ro1_label, ui->ro2_label, ui->ro3_label, ui->ro4_label, ui->ro5_label, ui->ro6_label, ui->ro7_label, ui->ro8_label, NULL};
QSlider *tpmsld[] = {ui->chkSA, ui->chkSB, ui->chkSC, ui->chkSD, ui->chkSE, ui->chkSF, ui->chkSG, ui->chkSH, NULL};
@@ -178,7 +191,7 @@ ui(new Ui::GeneralSetup)
}
if (IS_FLYSKY_EL18(board) || IS_FLYSKY_NV14(board) || IS_FLYSKY_PL18(board)) {
ui->hatsModeCB->setModel(new FilteredItemModel(GeneralSettings::hatsModeItemModel()));
ui->hatsModeCB->setModel(panelFilteredModels->getItemModel(FIM_HATSMODE));
ui->hatsModeCB->setField(generalSettings.hatsMode, this);
}
else {
@@ -204,12 +217,12 @@ ui(new Ui::GeneralSetup)
}
if (!firmware->getCapability(HasVolume)) {
ui->volume_SB->hide();
ui->volume_SB->setDisabled(true);
ui->volume_SL->hide();
ui->volume_SL->setDisabled(true);
ui->label_volume->hide();
}
else {
ui->volume_SB->setMaximum(firmware->getCapability(MaxVolume));
ui->volume_SL->setMaximum(firmware->getCapability(MaxVolume));
}
if (!firmware->getCapability(HasBrightness)) {
@@ -264,8 +277,8 @@ ui(new Ui::GeneralSetup)
ui->contrastSB->setMaximum(firmware->getCapability(MaxContrast));
ui->contrastSB->setValue(generalSettings.contrast);
ui->battwarningDSB->setValue((double)generalSettings.vBatWarn/10);
ui->backlightautoSB->setValue(generalSettings.backlightDelay*5);
ui->battwarningDSB->setValue((double)generalSettings.vBatWarn / 10);
ui->backlightautoSB->setValue(generalSettings.backlightDelay * 5);
ui->inactimerSB->setValue(generalSettings.inactivityTimer);
ui->memwarnChkB->setChecked(!generalSettings.disableMemoryWarning); // Default is zero=checked
@@ -274,7 +287,7 @@ ui(new Ui::GeneralSetup)
ui->rssiPowerOffWarnChkB->setChecked(!generalSettings.disableRssiPoweroffAlarm); // Default is zero=checked
ui->trainerPowerOffWarnChkB->setChecked(!generalSettings.disableTrainerPoweroffAlarm); // Default is zero=checked
ui->splashScreenDuration->setCurrentIndex(3-generalSettings.splashMode);
ui->splashScreenDuration->setCurrentIndex(3 - generalSettings.splashMode);
if (IS_FAMILY_HORUS_OR_T16(firmware->getBoard())) {
ui->splashScreenDuration->setItemText(0, QCoreApplication::translate("GeneralSetup", "1s", nullptr));
}
@@ -297,11 +310,14 @@ ui(new Ui::GeneralSetup)
ui->registrationId->setValidator(new NameValidator(board, this));
ui->registrationId->setMaxLength(REGISTRATION_ID_LEN);
ui->stickmodeCB->setModel(panelFilteredModels->getItemModel(FIM_STICKMODE));
ui->channelorderCB->setModel(panelFilteredModels->getItemModel(FIM_TEMPLATESETUP));
setValues();
lock = false;
for (int i=0; tpmsld[i]; i++) {
for (int i = 0; tpmsld[i]; i++) {
connect(tpmsld[i], SIGNAL(valueChanged(int)),this,SLOT(unlockSwitchEdited()));
}
@@ -333,7 +349,7 @@ ui(new Ui::GeneralSetup)
ui->backlightColor2_label->hide();
}
ui->switchesDelay->setValue(10*(generalSettings.switchesDelay+15));
ui->switchesDelay->setValue(10 * (generalSettings.switchesDelay + 15));
ui->blAlarm_ChkB->setChecked(generalSettings.alarmsFlash);
if (!firmware->getCapability(HasBatMeterRange)) {
@@ -344,12 +360,30 @@ ui(new Ui::GeneralSetup)
ui->vBatMaxDSB->hide();
}
if (Boards::getCapability(board, Board::Surface)) {
ui->stickModeLabel->hide();
ui->stickmodeCB->hide();
}
if (!firmware->getCapability(HasVario)) {
ui->varioVolume_label->hide();
ui->varioVolume_SL->hide();
ui->varioP0_label->hide();
ui->varioP0_SB->hide();
ui->varioPMax_label->hide();
ui->varioPMax_SB->hide();
ui->varioR0_label->hide();
ui->varioR0_SB->hide();
}
disableMouseScrolling();
}
GeneralSetupPanel::~GeneralSetupPanel()
{
delete ui;
delete panelFilteredModels;
}
void GeneralSetupPanel::on_timezoneLE_textEdited(const QString &text)
@@ -365,14 +399,15 @@ void GeneralSetupPanel::on_timezoneLE_textEdited(const QString &text)
void GeneralSetupPanel::populateBacklightCB()
{
QComboBox * b = ui->backlightswCB;
QString strings[] = { tr("OFF"), tr("Keys"), tr("Sticks"), tr("Keys + Sticks"), tr("ON"), NULL };
const QStringList strings = { tr("OFF"), tr("Keys"), tr("Controls"), tr("Keys + Controls"), tr("ON") };
b->clear();
int startValue = (firmware->getCapability(LcdDepth)>=8)?1:0;
for (int i=startValue; !strings[i].isNull(); i++) {
int startValue = (Boards::getCapability(firmware->getBoard(), Board::LcdDepth) >= 8) ? 1 : 0;
for (int i = startValue; i < strings.size(); i++) {
b->addItem(strings[i], 0);
if (generalSettings.backlightMode == i) {
b->setCurrentIndex(b->count()-1);
b->setCurrentIndex(b->count() - 1);
}
}
}
@@ -403,10 +438,10 @@ void GeneralSetupPanel::populateVoiceLangCB()
{ NULL, NULL }};
b->clear();
for (int i=0; strings[i][0]!=NULL; i++) {
for (int i = 0; strings[i][0] != NULL; i++) {
b->addItem(strings[i][0],strings[i][1]);
if (generalSettings.ttsLanguage == strings[i][1]) {
b->setCurrentIndex(b->count()-1);
b->setCurrentIndex(b->count() - 1);
}
}
}
@@ -455,7 +490,7 @@ void GeneralSetupPanel::on_voiceLang_CB_currentIndexChanged(int index)
{
if (!lock) {
QString code = ui->voiceLang_CB->itemData(index).toString();
for (int i=0; i<2; i++) {
for (int i = 0; i < 2; i++) {
generalSettings.ttsLanguage[i] = code.at(i).toLatin1();
}
generalSettings.ttsLanguage[2] = '\0';
@@ -465,8 +500,8 @@ void GeneralSetupPanel::on_voiceLang_CB_currentIndexChanged(int index)
void GeneralSetupPanel::updateVarioPitchRange()
{
ui->varioPMax_SB->setMaximum(700+(generalSettings.varioPitch*10)+1000+800);
ui->varioPMax_SB->setMinimum(700+(generalSettings.varioPitch*10)+1000-800);
ui->varioPMax_SB->setMaximum(700 + (generalSettings.varioPitch * 10) + 1000 + 800);
ui->varioPMax_SB->setMinimum(700 + (generalSettings.varioPitch * 10) + 1000 - 800);
}
void GeneralSetupPanel::populateRotEncCB(int reCount)
@@ -475,7 +510,7 @@ void GeneralSetupPanel::populateRotEncCB(int reCount)
QComboBox * b = ui->re_CB;
b->clear();
for (int i=0; i<=reCount; i++) {
for (int i = 0; i <= reCount; i++) {
b->addItem(strings[i]);
}
b->setCurrentIndex(generalSettings.reNavigation);
@@ -495,29 +530,30 @@ int pwrDelayToYaml(int delay)
void GeneralSetupPanel::setValues()
{
Board::Type board = firmware->getBoard();
ui->beeperCB->setCurrentIndex(generalSettings.beeperMode+2);
ui->channelorderCB->setCurrentIndex(generalSettings.templateSetup);
ui->stickmodeCB->setCurrentIndex(generalSettings.stickMode);
ui->channelorderCB->setCurrentIndex(ui->channelorderCB->findData(generalSettings.templateSetup));
ui->stickmodeCB->setCurrentIndex(ui->stickmodeCB->findData(generalSettings.stickMode));
if (firmware->getCapability(Haptic)) {
ui->hapticLengthCB->setCurrentIndex(generalSettings.hapticLength+2);
ui->hapticLengthCB->setCurrentIndex(generalSettings.hapticLength + 2);
}
else {
ui->label_HL->hide();
ui->hapticLengthCB->hide();
}
ui->OFFBright_SB->setMinimum(firmware->getCapability(BacklightLevelMin));
if (generalSettings.backlightOffBright > 100-generalSettings.backlightBright)
generalSettings.backlightOffBright = 100-generalSettings.backlightBright;
ui->BLBright_SB->setValue(100-generalSettings.backlightBright);
if (generalSettings.backlightOffBright > 100 - generalSettings.backlightBright)
generalSettings.backlightOffBright = 100 - generalSettings.backlightBright;
ui->BLBright_SB->setValue(100 - generalSettings.backlightBright);
ui->OFFBright_SB->setValue(generalSettings.backlightOffBright);
ui->BLBright_SB->setMinimum(ui->OFFBright_SB->value());
ui->OFFBright_SB->setMaximum(ui->BLBright_SB->value());
ui->soundModeCB->setCurrentIndex(generalSettings.speakerMode);
ui->volume_SB->setValue(generalSettings.speakerVolume + 12);
ui->beeperlenCB->setCurrentIndex(generalSettings.beeperLength+2);
ui->volume_SL->setValue(generalSettings.speakerVolume + 12);
ui->beeperlenCB->setCurrentIndex(generalSettings.beeperLength + 2);
ui->speakerPitchSB->setValue(generalSettings.speakerPitch);
ui->hapticStrength->setValue(generalSettings.hapticStrength);
ui->hapticmodeCB->setCurrentIndex(generalSettings.hapticMode+2);
ui->hapticmodeCB->setCurrentIndex(generalSettings.hapticMode + 2);
if (firmware->getCapability(HasBatMeterRange)) {
ui->vBatMinDSB->setValue((double)(generalSettings.vBatMin + 90) / 10);
@@ -532,7 +568,7 @@ void GeneralSetupPanel::setValues()
ui->startSoundCB->setChecked(!generalSettings.dontPlayHello);
if (Boards::getCapability(firmware->getBoard(), Board::HasColorLcd)) {
if (Boards::getCapability(board, Board::HasColorLcd)) {
ui->modelQuickSelect_CB->setChecked(generalSettings.modelQuickSelect);
ui->modelSelectLayout_CB->setCurrentIndex(generalSettings.modelSelectLayout);
ui->labelSingleSelect_CB->setCurrentIndex(generalSettings.labelSingleSelect);
@@ -551,13 +587,6 @@ void GeneralSetupPanel::setValues()
ui->label_favMultiMode->hide();
ui->favMultiMode_CB->hide();
}
if (firmware->getCapability(LcdWidth) == 128) {
ui->invertLCD_CB->setChecked(generalSettings.invertLCD);
} else {
ui->invertLCD_label->hide();
ui->invertLCD_CB->hide();
}
}
void GeneralSetupPanel::showLabelSelectOptions()
@@ -582,21 +611,23 @@ void GeneralSetupPanel::showLabelSelectOptions()
void GeneralSetupPanel::on_faimode_CB_stateChanged(int)
{
if (ui->faimode_CB->isChecked()) {
int ret = QMessageBox::question(this, CPN_STR_APP_NAME,
tr("If you enable FAI, only RSSI and RxBt sensors will keep working.\nThis function cannot be disabled by the radio.\nAre you sure ?") ,
QMessageBox::Yes | QMessageBox::No);
if (ret==QMessageBox::Yes) {
generalSettings.fai = true;
if (!lock) {
if (ui->faimode_CB->isChecked()) {
int ret = QMessageBox::question(this, CPN_STR_APP_NAME,
tr("If you enable FAI, only RSSI and RxBt sensors will keep working.\nThis function cannot be disabled by the radio.\nAre you sure ?") ,
QMessageBox::Yes | QMessageBox::No);
if (ret == QMessageBox::Yes) {
generalSettings.fai = true;
}
else {
ui->faimode_CB->setChecked(false);
}
}
else {
ui->faimode_CB->setChecked(false);
generalSettings.fai = false;
}
emit modified();
}
else {
generalSettings.fai = false;
}
emit modified();
}
void GeneralSetupPanel::populateRotEncModeCB()
@@ -610,7 +641,7 @@ void GeneralSetupPanel::populateRotEncModeCB()
}
b->clear();
for (uint8_t i=0; i < itemCount; i++) {
for (int i = 0; i < itemCount; i++) {
b->addItem(strings[i], 0);
}
b->setCurrentIndex(generalSettings.rotEncMode);
@@ -626,212 +657,276 @@ void GeneralSetupPanel::on_rotEncMode_CB_currentIndexChanged(int index)
void GeneralSetupPanel::on_speakerPitchSB_editingFinished()
{
generalSettings.speakerPitch = ui->speakerPitchSB->value();
emit modified();
if (!lock) {
generalSettings.speakerPitch = ui->speakerPitchSB->value();
emit modified();
}
}
void GeneralSetupPanel::on_hapticStrength_valueChanged()
{
generalSettings.hapticStrength = ui->hapticStrength->value();
emit modified();
if (!lock) {
generalSettings.hapticStrength = ui->hapticStrength->value();
emit modified();
}
}
void GeneralSetupPanel::on_soundModeCB_currentIndexChanged(int index)
{
generalSettings.speakerMode = index;
emit modified();
if (!lock) {
generalSettings.speakerMode = index;
emit modified();
}
}
void GeneralSetupPanel::on_splashScreenDuration_currentIndexChanged(int index)
{
generalSettings.splashMode = 3-index;
emit modified();
if (!lock) {
generalSettings.splashMode = 3 - index;
emit modified();
}
}
void GeneralSetupPanel::on_pwrOnDelay_currentIndexChanged(int index)
{
generalSettings.pwrOnSpeed = pwrDelayToYaml(index);
emit modified();
if (!lock) {
generalSettings.pwrOnSpeed = pwrDelayToYaml(index);
emit modified();
}
}
void GeneralSetupPanel::on_pwrOffDelay_currentIndexChanged(int index)
{
generalSettings.pwrOffSpeed = pwrDelayToYaml(index);
emit modified();
if (!lock) {
generalSettings.pwrOffSpeed = pwrDelayToYaml(index);
emit modified();
}
}
void GeneralSetupPanel::on_pwrOnOffHaptic_CB_stateChanged(int)
{
generalSettings.disablePwrOnOffHaptic = ui->pwrOnOffHaptic_CB->isChecked() ? 0 : 1;
emit modified();
if (!lock) {
generalSettings.disablePwrOnOffHaptic = ui->pwrOnOffHaptic_CB->isChecked() ? 0 : 1;
emit modified();
}
}
void GeneralSetupPanel::on_beepVolume_SL_valueChanged()
{
generalSettings.beepVolume=ui->beepVolume_SL->value();
emit modified();
if (!lock) {
generalSettings.beepVolume = ui->beepVolume_SL->value();
emit modified();
}
}
void GeneralSetupPanel::on_wavVolume_SL_valueChanged()
{
generalSettings.wavVolume=ui->wavVolume_SL->value();
emit modified();
if (!lock) {
generalSettings.wavVolume = ui->wavVolume_SL->value();
emit modified();
}
}
void GeneralSetupPanel::on_varioVolume_SL_valueChanged()
{
generalSettings.varioVolume=ui->varioVolume_SL->value();
emit modified();
if (!lock) {
generalSettings.varioVolume = ui->varioVolume_SL->value();
emit modified();
}
}
void GeneralSetupPanel::on_bgVolume_SL_valueChanged()
{
generalSettings.backgroundVolume=ui->bgVolume_SL->value();
emit modified();
if (!lock) {
generalSettings.backgroundVolume = ui->bgVolume_SL->value();
emit modified();
}
}
void GeneralSetupPanel::on_varioP0_SB_editingFinished()
{
generalSettings.varioPitch = (ui->varioP0_SB->value()-700)/10;
updateVarioPitchRange();
emit modified();
if (!lock) {
generalSettings.varioPitch = (ui->varioP0_SB->value() - 700) / 10;
updateVarioPitchRange();
emit modified();
}
}
void GeneralSetupPanel::on_varioPMax_SB_editingFinished()
{
generalSettings.varioRange = (ui->varioPMax_SB->value()-(700+(generalSettings.varioPitch*10))-1000)/10;
emit modified();
if (!lock) {
generalSettings.varioRange = (ui->varioPMax_SB->value() - (700 + (generalSettings.varioPitch * 10)) - 1000) / 10;
emit modified();
}
}
void GeneralSetupPanel::on_varioR0_SB_editingFinished()
{
generalSettings.varioRepeat = (ui->varioR0_SB->value()-500)/10;
emit modified();
if (!lock) {
generalSettings.varioRepeat = (ui->varioR0_SB->value() - 500) / 10;
emit modified();
}
}
void GeneralSetupPanel::on_BLBright_SB_editingFinished()
{
if (ui->BLBright_SB->value() < ui->OFFBright_SB->value()) {
ui->BLBright_SB->setValue(ui->OFFBright_SB->value());
} else {
ui->OFFBright_SB->setMaximum(ui->BLBright_SB->value());
generalSettings.backlightBright = 100 - ui->BLBright_SB->value();
emit modified();
if (!lock) {
if (ui->BLBright_SB->value() < ui->OFFBright_SB->value()) {
ui->BLBright_SB->setValue(ui->OFFBright_SB->value());
} else {
ui->OFFBright_SB->setMaximum(ui->BLBright_SB->value());
generalSettings.backlightBright = 100 - ui->BLBright_SB->value();
emit modified();
}
}
}
void GeneralSetupPanel::on_OFFBright_SB_editingFinished()
{
if (ui->OFFBright_SB->value() > ui->BLBright_SB->value()) {
ui->OFFBright_SB->setValue(ui->BLBright_SB->value());
} else {
ui->BLBright_SB->setMinimum(ui->OFFBright_SB->value());
generalSettings.backlightOffBright = ui->OFFBright_SB->value();
if (!lock) {
if (ui->OFFBright_SB->value() > ui->BLBright_SB->value()) {
ui->OFFBright_SB->setValue(ui->BLBright_SB->value());
} else {
ui->BLBright_SB->setMinimum(ui->OFFBright_SB->value());
generalSettings.backlightOffBright = ui->OFFBright_SB->value();
emit modified();
}
}
}
void GeneralSetupPanel::on_volume_SL_valueChanged()
{
if (!lock) {
generalSettings.speakerVolume = ui->volume_SL->value() - 12;
emit modified();
}
}
void GeneralSetupPanel::on_volume_SB_editingFinished()
{
generalSettings.speakerVolume = ui->volume_SB->value() - 12;
emit modified();
}
void GeneralSetupPanel::on_contrastSB_editingFinished()
{
generalSettings.contrast = ui->contrastSB->value();
emit modified();
if (!lock) {
generalSettings.contrast = ui->contrastSB->value();
emit modified();
}
}
void GeneralSetupPanel::on_battwarningDSB_editingFinished()
{
generalSettings.vBatWarn = (int)(ui->battwarningDSB->value()*10);
emit modified();
if (!lock) {
generalSettings.vBatWarn = (int)(ui->battwarningDSB->value() * 10);
emit modified();
}
}
void GeneralSetupPanel::on_vBatMinDSB_editingFinished()
{
generalSettings.vBatMin = ui->vBatMinDSB->value() * 10 - 90;
emit modified();
if (!lock) {
generalSettings.vBatMin = ui->vBatMinDSB->value() * 10 - 90;
emit modified();
}
}
void GeneralSetupPanel::on_vBatMaxDSB_editingFinished()
{
generalSettings.vBatMax = ui->vBatMaxDSB->value() * 10 - 120;
emit modified();
if (!lock) {
generalSettings.vBatMax = ui->vBatMaxDSB->value() * 10 - 120;
emit modified();
}
}
void GeneralSetupPanel::on_re_CB_currentIndexChanged(int index)
{
generalSettings.reNavigation = ui->re_CB->currentIndex();
emit modified();
if (!lock) {
generalSettings.reNavigation = ui->re_CB->currentIndex();
emit modified();
}
}
void GeneralSetupPanel::on_countrycode_CB_currentIndexChanged(int index)
{
generalSettings.countryCode = ui->countrycode_CB->currentIndex();
emit modified();
if (!lock) {
generalSettings.countryCode = ui->countrycode_CB->currentIndex();
emit modified();
}
}
void GeneralSetupPanel::on_units_CB_currentIndexChanged(int index)
{
generalSettings.imperial = ui->units_CB->currentIndex();
emit modified();
if (!lock) {
generalSettings.imperial = ui->units_CB->currentIndex();
emit modified();
}
}
void GeneralSetupPanel::on_ppm_units_CB_currentIndexChanged(int index)
{
generalSettings.ppmunit = ui->ppm_units_CB->currentIndex();
emit modified();
if (!lock) {
generalSettings.ppmunit = ui->ppm_units_CB->currentIndex();
emit modified();
}
}
void GeneralSetupPanel::on_beeperlenCB_currentIndexChanged(int index)
{
generalSettings.beeperLength = index-2;
emit modified();
if (!lock) {
generalSettings.beeperLength = index - 2;
emit modified();
}
}
void GeneralSetupPanel::on_hapticLengthCB_currentIndexChanged(int index)
{
generalSettings.hapticLength = index-2;
emit modified();
if (!lock) {
generalSettings.hapticLength = index - 2;
emit modified();
}
}
void GeneralSetupPanel::on_gpsFormatCB_currentIndexChanged(int index)
{
generalSettings.gpsFormat = index;
emit modified();
if (!lock) {
generalSettings.gpsFormat = index;
emit modified();
}
}
void GeneralSetupPanel::on_backlightautoSB_editingFinished()
{
int i = ui->backlightautoSB->value()/5;
if((i*5)!=ui->backlightautoSB->value())
ui->backlightautoSB->setValue(i*5);
else
{
generalSettings.backlightDelay = i;
emit modified();
if (!lock) {
int i = ui->backlightautoSB->value() / 5;
if((i * 5) != ui->backlightautoSB->value())
ui->backlightautoSB->setValue(i * 5);
else
{
generalSettings.backlightDelay = i;
emit modified();
}
}
}
void GeneralSetupPanel::on_switchesDelay_valueChanged(int)
{
generalSettings.switchesDelay = (ui->switchesDelay->value() / 10) - 15;
emit modified();
if (!lock) {
generalSettings.switchesDelay = (ui->switchesDelay->value() / 10) - 15;
emit modified();
}
}
void GeneralSetupPanel::on_adjustRTC_stateChanged(int)
{
generalSettings.adjustRTC = ui->adjustRTC->isChecked();
emit modified();
if (!lock) {
generalSettings.adjustRTC = ui->adjustRTC->isChecked();
emit modified();
}
}
void GeneralSetupPanel::on_inactimerSB_editingFinished()
{
generalSettings.inactivityTimer = ui->inactimerSB->value();
emit modified();
if (!lock) {
generalSettings.inactivityTimer = ui->inactimerSB->value();
emit modified();
}
}
void GeneralSetupPanel::on_pwrOffIfInactiveSB_editingFinished()
@@ -842,132 +937,167 @@ void GeneralSetupPanel::on_pwrOffIfInactiveSB_editingFinished()
void GeneralSetupPanel::on_memwarnChkB_stateChanged(int)
{
generalSettings.disableMemoryWarning = ui->memwarnChkB->isChecked() ? 0 : 1;
emit modified();
if (!lock) {
generalSettings.disableMemoryWarning = !ui->memwarnChkB->isChecked();
emit modified();
}
}
void GeneralSetupPanel::on_alarmwarnChkB_stateChanged(int)
{
generalSettings.disableAlarmWarning = ui->alarmwarnChkB->isChecked() ? 0 : 1;
emit modified();
if (!lock) {
generalSettings.disableAlarmWarning = !ui->alarmwarnChkB->isChecked();
emit modified();
}
}
void GeneralSetupPanel::on_rssiPowerOffWarnChkB_stateChanged(int)
{
generalSettings.disableRssiPoweroffAlarm = ui->rssiPowerOffWarnChkB->isChecked() ? 0 : 1;
emit modified();
if (!lock) {
generalSettings.disableRssiPoweroffAlarm = !ui->rssiPowerOffWarnChkB->isChecked();
emit modified();
}
}
void GeneralSetupPanel::on_trainerPowerOffWarnChkB_stateChanged(int)
{
generalSettings.disableTrainerPoweroffAlarm = ui->trainerPowerOffWarnChkB->isChecked() ? 0 : 1;
emit modified();
if (!lock) {
generalSettings.disableTrainerPoweroffAlarm = !ui->trainerPowerOffWarnChkB->isChecked();
emit modified();
}
}
void GeneralSetupPanel::on_beeperCB_currentIndexChanged(int index)
{
generalSettings.beeperMode = (GeneralSettings::BeeperMode)(index-2);
emit modified();
if (!lock) {
generalSettings.beeperMode = (GeneralSettings::BeeperMode)(index - 2);
emit modified();
}
}
void GeneralSetupPanel::on_displayTypeCB_currentIndexChanged(int index)
{
generalSettings.optrexDisplay = index;
emit modified();
if (!lock) {
generalSettings.optrexDisplay = index;
emit modified();
}
}
void GeneralSetupPanel::on_hapticmodeCB_currentIndexChanged(int index)
{
generalSettings.hapticMode = (GeneralSettings::BeeperMode)(index-2);
emit modified();
if (!lock) {
generalSettings.hapticMode = (GeneralSettings::BeeperMode)(index - 2);
emit modified();
}
}
void GeneralSetupPanel::on_channelorderCB_currentIndexChanged(int index)
{
generalSettings.templateSetup = index;
emit modified();
if (!lock) {
generalSettings.templateSetup = ui->channelorderCB->currentData().toInt();
emit modified();
}
}
void GeneralSetupPanel::on_stickmodeCB_currentIndexChanged(int index)
{
generalSettings.stickMode = index;
emit modified();
if (!lock) {
generalSettings.stickMode = ui->stickmodeCB->currentData().toInt();
emit modified();
}
}
void GeneralSetupPanel::unlockSwitchEdited()
{
int i=0;
i|=(((uint16_t)ui->chkSA->value()));
i|=(((uint16_t)ui->chkSB->value())<<2);
i|=(((uint16_t)ui->chkSC->value())<<4);
i|=(((uint16_t)ui->chkSD->value())<<6);
i|=(((uint16_t)ui->chkSE->value())<<8);
i|=(((uint16_t)ui->chkSF->value())<<10);
i|=(((uint16_t)ui->chkSG->value())<<12);
i|=(((uint16_t)ui->chkSH->value())<<14);
generalSettings.switchUnlockStates=i;
emit modified();
if (!lock) {
int i = 0;
i |= (((uint16_t)ui->chkSA->value()));
i |= (((uint16_t)ui->chkSB->value()) << 2);
i |= (((uint16_t)ui->chkSC->value()) << 4);
i |= (((uint16_t)ui->chkSD->value()) << 6);
i |= (((uint16_t)ui->chkSE->value()) << 8);
i |= (((uint16_t)ui->chkSF->value()) << 10);
i |= (((uint16_t)ui->chkSG->value()) << 12);
i |= (((uint16_t)ui->chkSH->value()) << 14);
generalSettings.switchUnlockStates=i;
emit modified();
}
}
void GeneralSetupPanel::on_blAlarm_ChkB_stateChanged()
{
generalSettings.alarmsFlash = ui->blAlarm_ChkB->isChecked();
emit modified();
if (!lock) {
generalSettings.alarmsFlash = ui->blAlarm_ChkB->isChecked();
emit modified();
}
}
void GeneralSetupPanel::on_registrationId_editingFinished()
{
strncpy(generalSettings.registrationId, ui->registrationId->text().toLatin1(), REGISTRATION_ID_LEN);
emit modified();
if (!lock) {
strncpy(generalSettings.registrationId, ui->registrationId->text().toLatin1(), REGISTRATION_ID_LEN);
emit modified();
}
}
void GeneralSetupPanel::stickReverseEdited()
{
generalSettings.stickReverse = ((int)ui->stickReverse1->isChecked()) | ((int)ui->stickReverse2->isChecked()<<1) | ((int)ui->stickReverse3->isChecked()<<2) | ((int)ui->stickReverse4->isChecked()<<3);
emit modified();
if (!lock) {
generalSettings.stickReverse = ((int)ui->stickReverse1->isChecked()) |
((int)ui->stickReverse2->isChecked() << 1) |
((int)ui->stickReverse3->isChecked() << 2) |
((int)ui->stickReverse4->isChecked() << 3);
emit modified();
}
}
void GeneralSetupPanel::on_modelQuickSelect_CB_stateChanged(int)
{
generalSettings.modelQuickSelect = ui->modelQuickSelect_CB->isChecked();
emit modified();
if (!lock) {
generalSettings.modelQuickSelect = ui->modelQuickSelect_CB->isChecked();
emit modified();
}
}
void GeneralSetupPanel::on_modelSelectLayout_CB_currentIndexChanged(int index)
{
generalSettings.modelSelectLayout = index;
emit modified();
if (!lock) {
generalSettings.modelSelectLayout = index;
emit modified();
}
}
void GeneralSetupPanel::on_labelSingleSelect_CB_currentIndexChanged(int index)
{
generalSettings.labelSingleSelect = index;
showLabelSelectOptions();
emit modified();
if (!lock) {
generalSettings.labelSingleSelect = index;
showLabelSelectOptions();
emit modified();
}
}
void GeneralSetupPanel::on_labelMultiMode_CB_currentIndexChanged(int index)
{
generalSettings.labelMultiMode = index;
showLabelSelectOptions();
emit modified();
if (!lock) {
generalSettings.labelMultiMode = index;
showLabelSelectOptions();
emit modified();
}
}
void GeneralSetupPanel::on_favMultiMode_CB_currentIndexChanged(int index)
{
generalSettings.favMultiMode = index;
emit modified();
if (!lock) {
generalSettings.favMultiMode = index;
emit modified();
}
}
void GeneralSetupPanel::on_startSoundCB_stateChanged(int)
{
generalSettings.dontPlayHello = !ui->startSoundCB->isChecked();
emit modified();
}
void GeneralSetupPanel::on_invertLCD_CB_stateChanged(int)
{
generalSettings.invertLCD = ui->invertLCD_CB->isChecked();
emit modified();
if (!lock) {
generalSettings.dontPlayHello = !ui->startSoundCB->isChecked();
emit modified();
}
}
+4 -2
View File
@@ -25,6 +25,8 @@
#include "generaledit.h"
#include "eeprominterface.h"
class FilteredItemModelFactory;
namespace Ui {
class GeneralSetup;
}
@@ -58,7 +60,7 @@ class GeneralSetupPanel : public GeneralPanel
void on_hapticStrength_valueChanged();
void on_soundModeCB_currentIndexChanged(int index);
void on_beeperlenCB_currentIndexChanged(int index);
void on_volume_SB_editingFinished();
void on_volume_SL_valueChanged();
void on_hapticmodeCB_currentIndexChanged(int index);
void on_hapticLengthCB_currentIndexChanged(int index);
void on_backlightswCB_currentIndexChanged(int index);
@@ -102,12 +104,12 @@ class GeneralSetupPanel : public GeneralPanel
void on_labelSingleSelect_CB_currentIndexChanged(int);
void on_labelMultiMode_CB_currentIndexChanged(int);
void on_favMultiMode_CB_currentIndexChanged(int);
void on_invertLCD_CB_stateChanged(int);
void on_pwrOffIfInactiveSB_editingFinished();
private:
Ui::GeneralSetup *ui;
FilteredItemModelFactory *panelFilteredModels;
void showLabelSelectOptions();
File diff suppressed because it is too large Load Diff
+10
View File
@@ -357,6 +357,16 @@ HardwarePanel::HardwarePanel(QWidget * parent, GeneralSettings & generalSettings
addParams();
}
if (Boards::getCapability(board, Board::LcdWidth) == 128) {
addSection(tr("Screen"));
addLabel(tr("Invert"));
AutoCheckBox *screenInvert = new AutoCheckBox(this);
screenInvert->setField(generalSettings.invertLCD, this);
params->append(screenInvert);
addParams();
}
addVSpring(grid, 0, grid->rowCount());
addHSpring(grid, grid->columnCount(), 0);
disableMouseScrolling();
+1 -1
View File
@@ -50,7 +50,7 @@ TrainerPanel::TrainerPanel(QWidget * parent, GeneralSettings & generalSettings,
addLabel(tr("Weight"), row, 2);
addLabel(tr("Source"), row++, 3);
for (int i = 0; i < CPN_MAX_STICKS; i++, row++) {
for (int i = 0; i < stickcnt; i++, row++) {
col = 0;
addLabel(Boards::getInputName(i), row, col++);
+4 -14
View File
@@ -225,17 +225,6 @@ void GVarGroup::setWeight(int val)
* Helpers namespace functions
*/
// TODO: Move lookup to GVarData class (w/out combobox)
void Helpers::populateGvarUseCB(QComboBox * b, unsigned int phase)
{
b->addItem(QCoreApplication::translate("GVarData", "Own value"));
for (int i=0; i<getCurrentFirmware()->getCapability(FlightModes); i++) {
if (i != (int)phase) {
b->addItem(QCoreApplication::translate("GVarData", "Flight mode %1 value").arg(i));
}
}
}
static bool caseInsensitiveLessThan(const QString &s1, const QString &s2)
{
return s1.toLower() < s2.toLower();
@@ -413,9 +402,10 @@ void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx)
QPixmap makePixMap(const QImage & image)
{
Firmware * firmware = getCurrentFirmware();
QImage result = image.scaled(firmware->getCapability(LcdWidth), firmware->getCapability(LcdHeight));
if (firmware->getCapability(LcdDepth) == 4) {
Board::Type board = getCurrentBoard();
QImage result = image.scaled(Boards::getCapability(board, Board::LcdWidth), Boards::getCapability(board, Board::LcdHeight));
if (Boards::getCapability(board, Board::LcdDepth) == 4) {
result = result.convertToFormat(QImage::Format_RGB32);
for (int i = 0; i < result.width(); ++i) {
for (int j = 0; j < result.height(); ++j) {
+2 -3
View File
@@ -39,7 +39,8 @@ extern const QColor colors[CPN_MAX_CURVES];
//convert from mode 1 to mode generalSettings.stickMode
//NOTICE! => 1..4 -> 1..4
#define CONVERT_MODE(x) (((x)<=4) ? modn12x3[generalSettings.stickMode][((x)-1)] : (x))
#define CONVERT_AIRMODE(x) (((x)<=4) ? modn12x3[generalSettings.stickMode][((x)-1)] : (x))
#define CONVERT_SURFACEMODE(x) (((x)<=4) ? modn12x3[4 + generalSettings.stickMode][((x)-1)] : (x))
#define CURVE_BASE 7
#define CH(x) (SRC_CH1+(x)-1-(SRC_SWC-SRC_3POS))
@@ -106,8 +107,6 @@ class GVarGroup: public QObject {
namespace Helpers
{
void populateGvarUseCB(QComboBox *b, unsigned int phase);
void populateFileComboBox(QComboBox * b, const QSet<QString> & set, const QString & current);
void getFileComboBoxValue(QComboBox * b, char * dest, int length);
+13 -5
View File
@@ -40,6 +40,8 @@
UserInterfacePanel::UserInterfacePanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware):
ModelPanel(parent, model, generalSettings, firmware)
{
Board::Type board = firmware->getBoard();
QString sdPath = QString(g.profile[g.id()].sdPath()).trimmed();
grid = new QGridLayout(this);
@@ -126,8 +128,10 @@ UserInterfacePanel::UserInterfacePanel(QWidget * parent, ModelData & model, Gene
QImage image(path);
if (!image.isNull()) {
img->setText("");
img->setFixedSize(QSize(firmware->getCapability(LcdWidth) / 2, firmware->getCapability(LcdHeight) / 2));
img->setPixmap(QPixmap::fromImage(image.scaled(firmware->getCapability(LcdWidth) / 2, firmware->getCapability(LcdHeight) / 2)));
img->setFixedSize(QSize(Boards::getCapability(board, Board::LcdWidth) / 2,
Boards::getCapability(board, Board::LcdHeight) / 2));
img->setPixmap(QPixmap::fromImage(image.scaled(Boards::getCapability(board, Board::LcdWidth) / 2,
Boards::getCapability(board, Board::LcdHeight) / 2)));
}
grid->addWidget(img, row++, col++);
@@ -223,6 +227,7 @@ UserInterfacePanel::~UserInterfacePanel()
CustomScreenPanel::CustomScreenPanel(QWidget * parent, ModelData & model, int index, GeneralSettings & generalSettings, Firmware * firmware):
ModelPanel(parent, model, generalSettings, firmware)
{
Board::Type board = firmware->getBoard();
RadioLayout::CustomScreens & scrns = model.customScreens;
grid = new QGridLayout(this);
@@ -245,11 +250,14 @@ CustomScreenPanel::CustomScreenPanel(QWidget * parent, ModelData & model, int in
QString path(QString(":/layouts/mask_%1.png").arg(QString(scrns.customScreenData[index].layoutId).toLower()));
QFile f(path);
if (f.exists()) {
QImage image(path);
if (!image.isNull()) {
img->setFixedSize(QSize(firmware->getCapability(LcdWidth) / 5, firmware->getCapability(LcdHeight) / 5));
img->setPixmap(QPixmap::fromImage(image.scaled(firmware->getCapability(LcdWidth) / 5, firmware->getCapability(LcdHeight) / 5)));
img->setFixedSize(QSize(Boards::getCapability(board, Board::LcdWidth) / 5,
Boards::getCapability(board, Board::LcdHeight) / 5));
img->setPixmap(QPixmap::fromImage(image.scaled(Boards::getCapability(board, Board::LcdWidth) / 5,
Boards::getCapability(board, Board::LcdHeight) / 5)));
}
}
@@ -325,7 +333,7 @@ CustomScreenPanel::CustomScreenPanel(QWidget * parent, ModelData & model, int in
str = tr("Top bar");
break;
case LAYOUT_OPTION_FM:
str = tr("Flight mode");
str = tr("%1 mode").arg(Boards::getRadioTypeString(firmware->getBoard()));
break;
case LAYOUT_OPTION_SLIDERS:
str = tr("Sliders");
+1 -1
View File
@@ -83,7 +83,7 @@
<item row="8" column="0">
<widget class="QLabel" name="label_phases">
<property name="text">
<string>Flight modes</string>
<string>Modes</string>
</property>
</widget>
</item>
+68 -34
View File
@@ -27,11 +27,12 @@
#include "namevalidator.h"
FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseIdx, GeneralSettings & generalSettings, Firmware * firmware,
FilteredItemModel * rawSwitchFilteredModel):
FilteredItemModel * rawSwitchFilteredModel, QString radioType):
ModelPanel(parent, model, generalSettings, firmware),
ui(new Ui::FlightMode),
phaseIdx(phaseIdx),
phase(model.flightModeData[phaseIdx])
phase(model.flightModeData[phaseIdx]),
radioType(radioType)
{
ui->setupUi(this);
connectItemModelEvents(rawSwitchFilteredModel);
@@ -40,7 +41,7 @@ FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseI
ui->labelName->setToolTip(tr("Popup menu available"));
connect(ui->labelName, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onCustomContextMenuRequested(const QPoint &)));
board = getCurrentBoard();
board = firmware->getBoard();
fmCount = firmware->getCapability(FlightModes);
gvCount = firmware->getCapability(Gvars);
reCount = firmware->getCapability(RotaryEncoders);
@@ -85,13 +86,14 @@ FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseI
// The trims
QString labels[CPN_MAX_TRIMS];
for(int i = 0; i < CPN_MAX_STICKS; i++) {
for (int i = 0; i < Boards::getCapability(board, Board::Sticks); i++) {
labels[i] = Boards::getInputName(i);
}
labels[4] = "T5"; // TODO firmware function
labels[5] = "T6"; // TODO firmware function
labels[6] = "T7"; // TODO firmware function
labels[7] = "T8"; // TODO firmware function
for (int i = Boards::getCapability(board, Board::Sticks); i < CPN_MAX_TRIMS; i++) {
labels[i] = QString("T%1").arg(i + 1);
}
trimsLabel << ui->trim1Label << ui->trim2Label << ui->trim3Label << ui->trim4Label << ui->trim5Label << ui->trim6Label << ui->trim7Label << ui->trim8Label;
trimsUse << ui->trim1Use << ui->trim2Use << ui->trim3Use << ui->trim4Use << ui->trim5Use << ui->trim6Use << ui->trim7Use << ui->trim8Use;
@@ -106,7 +108,7 @@ FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseI
}
for (int i = 0; i < trimCount; i++) {
trimsLabel[i]->setText(labels[CONVERT_MODE(i + 1) - 1]);
trimsLabel[i]->setText(labels[Boards::isAir(board) ? CONVERT_AIRMODE(i + 1) - 1 : CONVERT_SURFACEMODE(i + 1) - 1]);
QComboBox * cb = trimsUse[i];
cb->setProperty("index", i);
if (IS_HORUS_OR_TARANIS(board)) {
@@ -118,9 +120,9 @@ FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseI
cb->addItem(tr("Own Trim"), m * 2);
}
else if (phaseIdx > 0) {
cb->addItem(tr("Use Trim from Flight mode %1").arg(m), m * 2);
cb->addItem(tr("Use Trim from %1 Mode %2").arg(radioType).arg(m), m * 2);
if (IS_HORUS_OR_TARANIS(board)) {
cb->addItem(tr("Use Trim from Flight mode %1 + Own Trim as an offset").arg(m), m * 2 + 1);
cb->addItem(tr("Use Trim from %1 Mode %2 + Own Trim as an offset").arg(radioType).arg(m), m * 2 + 1);
}
}
}
@@ -137,8 +139,9 @@ FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseI
trimsSlider[i]->setProperty("index", i);
trimsSlider[i]->setRange(-trimsMax, +trimsMax);
int chn = CONVERT_MODE(i + 1) - 1;
if (chn == 2/*TODO constant*/ && model.throttleReversed)
int chn = Boards::isAir(board) ? CONVERT_AIRMODE(i + 1) - 1 : CONVERT_SURFACEMODE(i + 1) - 1;
if (model.throttleReversed && ((Boards::isAir(board) && chn == 2/*TODO constant*/) ||
(Boards::isSurface(board) && chn == 1/*TODO constant*/)))
trimsSlider[i]->setInvertedAppearance(true);
connect(trimsSlider[i], SIGNAL(valueChanged(int)), this, SLOT(phaseTrimSlider_valueChanged()));
}
@@ -155,7 +158,7 @@ FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseI
// RE link to another RE
reUse[i] = new QComboBox(ui->reGB);
reUse[i]->setProperty("index", i);
Helpers::populateGvarUseCB(reUse[i], phaseIdx);
populateGvarUseCB(reUse[i], phaseIdx);
connect(reUse[i], SIGNAL(currentIndexChanged(int)), this, SLOT(phaseREUse_currentIndexChanged(int)));
reLayout->addWidget(reUse[i], i, 1, 1, 1);
}
@@ -221,7 +224,7 @@ FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseI
int col = 0;
// GVar label
QLabel *label = new QLabel(ui->gvGB);
label->setText(tr("GVAR%1").arg(i + 1));
label->setText(tr("GV%1").arg(i + 1));
label->setProperty("index", i);
label->setContextMenuPolicy(Qt::CustomContextMenu);
label->setToolTip(tr("Popup menu available"));
@@ -241,7 +244,7 @@ FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseI
// GVar link to another GVar
gvUse[i] = new QComboBox(ui->gvGB);
gvUse[i]->setProperty("index", i);
Helpers::populateGvarUseCB(gvUse[i], phaseIdx);
populateGvarUseCB(gvUse[i], phaseIdx);
connect(gvUse[i], SIGNAL(currentIndexChanged(int)), this, SLOT(phaseGVUse_currentIndexChanged(int)));
gvLayout->addWidget(gvUse[i], i + 1, col++, 1, 1);
}
@@ -348,6 +351,16 @@ void FlightModePanel::updateGVar(int index)
lock = false;
}
void FlightModePanel::populateGvarUseCB(QComboBox * b, unsigned int phase)
{
b->addItem(tr("Own value"));
for (int i = 0; i < getCurrentFirmware()->getCapability(FlightModes); i++) {
if (i != (int)phase) {
b->addItem(tr("%1 Mode %2 value").arg(radioType).arg(i));
}
}
}
void FlightModePanel::setGVSB(QDoubleSpinBox * sb, int min, int max, int val)
{
int idx = sb->property("index").toInt();
@@ -430,7 +443,7 @@ void FlightModePanel::phaseFadeOut_editingFinished()
void FlightModePanel::trimUpdate(unsigned int trim)
{
lock = true;
int chn = CONVERT_MODE(trim + 1) - 1;
int chn = Boards::isAir(board) ? CONVERT_AIRMODE(trim + 1) - 1 : CONVERT_SURFACEMODE(trim + 1) - 1;
int value = model->getTrimValue(phaseIdx, chn);
trimsSlider[trim]->setValue(value);
trimsValue[trim]->setValue(value);
@@ -496,7 +509,7 @@ void FlightModePanel::phaseGVUse_currentIndexChanged(int index)
phase.gvars[gvar] = GVAR_MAX_VALUE + index;
}
if (model->isGVarLinkedCircular(phaseIdx, gvar))
QMessageBox::warning(this, "Companion", tr("Warning: Global variable links back to itself. Flight Mode 0 value used."));
QMessageBox::warning(this, "Companion", tr("Warning: Global variable links back to itself. %1 Mode 0 value used.").arg(radioType));
updateGVar(gvar);
emit modified();
lock = false;
@@ -605,7 +618,7 @@ void FlightModePanel::phaseREUse_currentIndexChanged(int index)
}
update();
if (model->isREncLinkedCircular(phaseIdx, re))
QMessageBox::warning(this, "Companion", tr("Warning: Rotary encoder links back to itself. Flight Mode 0 value used."));
QMessageBox::warning(this, "Companion", tr("Warning: Rotary encoder links back to itself. %1 Mode 0 value used.").arg(radioType));
emit modified();
lock = false;
}
@@ -616,7 +629,7 @@ void FlightModePanel::phaseTrimUse_currentIndexChanged(int index)
if (!lock) {
QComboBox *comboBox = qobject_cast<QComboBox*>(sender());
int trim = comboBox->property("index").toInt();
int chn = CONVERT_MODE(trim + 1) - 1;
int chn = Boards::isAir(board) ? CONVERT_AIRMODE(trim + 1) - 1 : CONVERT_SURFACEMODE(trim + 1) - 1;
int data = comboBox->itemData(index).toInt();
if (data < 0) {
phase.trimMode[chn] = -1;
@@ -648,7 +661,7 @@ void FlightModePanel::phaseTrim_valueChanged()
if (!lock) {
QSpinBox *spinBox = qobject_cast<QSpinBox*>(sender());
int trim = spinBox->property("index").toInt();
int chn = CONVERT_MODE(trim + 1) - 1;
int chn = Boards::isAir(board) ? CONVERT_AIRMODE(trim + 1) - 1 : CONVERT_SURFACEMODE(trim + 1) - 1;
int value = spinBox->value();
model->setTrimValue(phaseIdx, chn, value);
lock = true;
@@ -663,7 +676,7 @@ void FlightModePanel::phaseTrimSlider_valueChanged()
if (!lock) {
QSlider *slider = qobject_cast<QSlider*>(sender());
int trim = slider->property("index").toInt();
int chn = CONVERT_MODE(trim + 1) - 1;
int chn = Boards::isAir(board) ? CONVERT_AIRMODE(trim + 1) - 1 : CONVERT_SURFACEMODE(trim + 1) - 1;
int value = slider->value();
model->setTrimValue(phaseIdx, chn, value);
lock = true;
@@ -724,7 +737,7 @@ bool FlightModePanel::moveUpAllowed() const
void FlightModePanel::cmClear(bool prompt)
{
if (prompt) {
if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Clear Flight Mode. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Clear %1 Mode. Are you sure?").arg(radioType), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
return;
}
@@ -761,7 +774,7 @@ void FlightModePanel::cmClear(bool prompt)
void FlightModePanel::cmClearAll()
{
if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Clear all Flight Modes. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Clear all %1 Modes. Are you sure?").arg(radioType), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
return;
for (int j = 0; j < fmCount; j++) {
@@ -796,7 +809,7 @@ void FlightModePanel::cmCopy()
void FlightModePanel::cmCut()
{
if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Cut Flight Mode. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Cut %1 Mode. Are you sure?").arg(radioType), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
return;
cmCopy();
cmClear(false);
@@ -804,7 +817,7 @@ void FlightModePanel::cmCut()
void FlightModePanel::cmDelete()
{
if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Delete Flight Mode. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Delete %1 Mode. Are you sure?").arg(radioType), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
return;
const int maxidx = fmCount - 1;
@@ -1160,7 +1173,7 @@ void FlightModePanel::gvCmClear(bool prompt)
{
if (phaseIdx == 0) {
if (prompt) {
if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Clear Global Variable across all Flight Modes. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Clear Global Variable across all %1 Modes. Are you sure?").arg(radioType), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
return;
}
model->gvarData[gvIdx].clear();
@@ -1184,7 +1197,7 @@ void FlightModePanel::gvCmClear(bool prompt)
void FlightModePanel::gvCmClearAll()
{
if (phaseIdx == 0) {
if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Clear all Global Variables for all Flight Modes. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Clear all Global Variables for all %1 Modes. Are you sure?").arg(radioType), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
return;
for (int i = 0; i < gvCount; i++) {
model->gvarData[i].clear();
@@ -1195,7 +1208,7 @@ void FlightModePanel::gvCmClearAll()
}
}
else {
if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Clear all Global Variables for this Flight Mode. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Clear all Global Variables for this %1 Mode. Are you sure?").arg(radioType), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
return;
for (int i = 0; i < gvCount; i++) {
phase.gvars[i] = phase.linkedGVarFlightModeZero(phaseIdx);
@@ -1247,7 +1260,7 @@ void FlightModePanel::gvCmCopy()
void FlightModePanel::gvCmCut()
{
if (phaseIdx == 0) {
if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Cut Global Variable across all Flight Modes. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Cut Global Variable across all %1 Modes. Are you sure?").arg(radioType), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
return;
}
else {
@@ -1325,7 +1338,7 @@ void FlightModePanel::gvCmPaste()
{
QByteArray data;
if (phaseIdx == 0) {
if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Paste to selected Global Variable across all Flight Modes. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Paste to selected Global Variable across all %1 Modes. Are you sure?").arg(radioType), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
return;
if (gvHasDefnClipboardData(&data)) {
memcpy(&model->gvarData[gvIdx], data.constData(), sizeof(GVarData));
@@ -1391,6 +1404,18 @@ void FlightModePanel::onItemModelUpdateComplete()
lock = false;
}
void FlightModePanel::onThrottleReverseChanged()
{
for (int i = 0; i < CPN_MAX_TRIMS; i++) {
int chn = Boards::isAir(board) ? CONVERT_AIRMODE(i + 1) - 1 : CONVERT_SURFACEMODE(i + 1) - 1;
if (model->throttleReversed && ((Boards::isAir(board) && chn == 2/*TODO constant*/) ||
(Boards::isSurface(board) && chn == 1/*TODO constant*/)))
trimsSlider[i]->setInvertedAppearance(true);
else
trimsSlider[i]->setInvertedAppearance(false);
}
}
/**********************************************************/
FlightModesPanel::FlightModesPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware,
@@ -1402,11 +1427,13 @@ FlightModesPanel::FlightModesPanel(QWidget * parent, ModelData & model, GeneralS
connectItemModelEvents(rawSwitchFilteredModel);
modesCount = firmware->getCapability(FlightModes);
radioType = Boards::getRadioTypeString(firmware->getBoard());
QGridLayout * gridLayout = new QGridLayout(this);
tabWidget = new QTabWidget(this);
for (int i = 0; i < modesCount; i++) {
FlightModePanel * tab = new FlightModePanel(tabWidget, model, i, generalSettings, firmware, rawSwitchFilteredModel);
FlightModePanel * tab = new FlightModePanel(tabWidget, model, i, generalSettings, firmware, rawSwitchFilteredModel, radioType);
tab->setProperty("index", i);
connect(tab, &FlightModePanel::modified, this, &FlightModesPanel::modified);
connect(tab, &FlightModePanel::phaseDataChanged, this, &FlightModesPanel::onPhaseNameChanged);
@@ -1414,10 +1441,12 @@ FlightModesPanel::FlightModesPanel(QWidget * parent, ModelData & model, GeneralS
connect(tab, &FlightModePanel::phaseSwitchChanged, this, &FlightModesPanel::updateItemModels);
connect(tab, &FlightModePanel::gvNameChanged, this, &FlightModesPanel::updateItemModels);
connect(this, &FlightModesPanel::updated, tab, &FlightModePanel::update);
connect(this, &FlightModesPanel::updated, tab, &FlightModePanel::update);
connect(this, &FlightModesPanel::refreshThrottleTrim, tab, &FlightModePanel::onThrottleReverseChanged);
tabWidget->addTab(tab, getTabName(i));
panels << tab;
}
connect(tabWidget, &QTabWidget::currentChanged, this, &FlightModesPanel::onTabIndexChanged);
gridLayout->addWidget(tabWidget, 0, 0, 1, 1);
onTabIndexChanged(0);
@@ -1430,7 +1459,7 @@ FlightModesPanel::~FlightModesPanel()
QString FlightModesPanel::getTabName(int index)
{
QString result = tr("Flight Mode %1").arg(index);
QString result = tr("%1 Mode %2").arg(radioType).arg(index);
const char *name = model->flightModeData[index].name;
if (firmware->getCapability(FlightModesName) && strlen(name) > 0) {
result += tr(" (%1)").arg(name);
@@ -1479,3 +1508,8 @@ void FlightModesPanel::onTabIndexChanged(int index)
if (index < panels.size())
panels.at(index)->update();
}
void FlightModesPanel::onThrottleReverseChanged()
{
emit refreshThrottleTrim();
}
+11 -6
View File
@@ -19,8 +19,7 @@
* GNU General Public License for more details.
*/
#ifndef _FLIGHTMODES_H_
#define _FLIGHTMODES_H_
#pragma once
#include "modeledit.h"
#include "eeprominterface.h"
@@ -43,7 +42,7 @@ class FlightModePanel : public ModelPanel
public:
FlightModePanel(QWidget *parent, ModelData &model, int modeIdx, GeneralSettings & generalSettings, Firmware * firmware,
FilteredItemModel * rawSwitchFilteredModel);
FilteredItemModel * rawSwitchFilteredModel, QString radioType);
virtual ~FlightModePanel();
virtual void update();
@@ -54,6 +53,9 @@ class FlightModePanel : public ModelPanel
void phaseNameChanged();
void phaseSwitchChanged();
public slots:
void onThrottleReverseChanged();
private slots:
void phaseName_editingFinished();
void phaseSwitch_currentIndexChanged(int index);
@@ -119,6 +121,7 @@ class FlightModePanel : public ModelPanel
QVector<QSpinBox *> trimsValue;
QVector<QSlider *> trimsSlider;
Board::Type board;
QString radioType;
void trimUpdate(unsigned int trim);
void updateGVar(int index);
@@ -141,6 +144,7 @@ class FlightModePanel : public ModelPanel
bool gvMoveUpAllowed() const;
void gvSwapData(int idx1, int idx2);
void connectItemModelEvents(const FilteredItemModel * itemModel);
void populateGvarUseCB(QComboBox *b, unsigned int phase);
};
class FlightModesPanel : public ModelPanel
@@ -153,9 +157,11 @@ class FlightModesPanel : public ModelPanel
public slots:
virtual void update() override;
void onThrottleReverseChanged();
signals:
void updated();
void refreshThrottleTrim();
private slots:
void onPhaseNameChanged();
@@ -171,9 +177,8 @@ class FlightModesPanel : public ModelPanel
CompoundItemModelFactory *sharedItemModels;
FilteredItemModel *rawSwitchFilteredModel;
QVector<GenericPanel *> panels;
QString radioType;
void updateItemModels();
void connectItemModelEvents(const FilteredItemModel * itemModel);
};
#endif // _FLIGHTMODES_H_
+1 -1
View File
@@ -275,7 +275,7 @@
<item row="7" column="0">
<widget class="QLabel" name="label_phases">
<property name="text">
<string>Flight modes</string>
<string>Modes</string>
</property>
</widget>
</item>
+7 -4
View File
@@ -72,7 +72,7 @@ ModelEdit::ModelEdit(QWidget * parent, RadioData & radioData, int modelId, Firmw
s1.report("Init");
SetupPanel * setupPanel = new SetupPanel(this, model, generalSettings, firmware, sharedItemModels);
SetupPanel *setupPanel = new SetupPanel(this, model, generalSettings, firmware, sharedItemModels);
addTab(setupPanel, tr("Setup"));
s1.report("Setup");
@@ -81,8 +81,10 @@ ModelEdit::ModelEdit(QWidget * parent, RadioData & radioData, int modelId, Firmw
s1.report("Heli");
}
addTab(new FlightModesPanel(this, model, generalSettings, firmware, sharedItemModels), tr("Flight Modes"));
s1.report("Flight Modes");
QString radioType = QString("%1 Modes").arg(Boards::getRadioTypeString(firmware->getBoard()));
FlightModesPanel *flightModesPanel = new FlightModesPanel(this, model, generalSettings, firmware, sharedItemModels);
addTab(flightModesPanel, radioType);
s1.report(radioType);
addTab(new InputsPanel(this, model, generalSettings, firmware, sharedItemModels), tr("Inputs"));
s1.report("Inputs");
@@ -90,7 +92,7 @@ ModelEdit::ModelEdit(QWidget * parent, RadioData & radioData, int modelId, Firmw
addTab(new MixesPanel(this, model, generalSettings, firmware, sharedItemModels), tr("Mixes"));
s1.report("Mixes");
ChannelsPanel * channelsPanel = new ChannelsPanel(this, model, generalSettings, firmware, sharedItemModels);
ChannelsPanel *channelsPanel = new ChannelsPanel(this, model, generalSettings, firmware, sharedItemModels);
addTab(channelsPanel, tr("Outputs"));
s1.report("Outputs");
@@ -121,6 +123,7 @@ ModelEdit::ModelEdit(QWidget * parent, RadioData & radioData, int modelId, Firmw
s1.report("Enabled Features");
connect(setupPanel, &SetupPanel::extendedLimitsToggled, channelsPanel, &ChannelsPanel::refreshExtendedLimits);
connect(setupPanel, &SetupPanel::throttleReverseChanged, flightModesPanel, &FlightModesPanel::onThrottleReverseChanged);
connect(ui->tabWidget, &QTabWidget::currentChanged, this, &ModelEdit::onTabIndexChanged);
connect(ui->pushButton, &QPushButton::clicked, this, &ModelEdit::launchSimulation);
+1 -1
View File
@@ -82,7 +82,7 @@ ModelOptionsPanel::ModelOptionsPanel(QWidget * parent, ModelData & model, Genera
addParams();
}
addLabel(tr("Flight Modes"));
addLabel(tr("%1 Modes").arg(Boards::getRadioTypeString(firmware->getBoard())));
AutoComboBox *fmDisable = new AutoComboBox(this);
fmDisable->setModel(mdl);
fmDisable->setField(model.modelFMDisabled, this);
+21 -9
View File
@@ -1872,6 +1872,7 @@ void SetupPanel::on_customThrottleWarningPosition_valueChanged(int value)
void SetupPanel::on_throttleReverse_toggled(bool checked)
{
model->throttleReversed = checked;
emit throttleReverseChanged();
emit modified();
}
@@ -1935,18 +1936,29 @@ void SetupPanel::on_image_currentIndexChanged(int index)
void SetupPanel::populateThrottleTrimSwitchCB()
{
Board::Type board = firmware->getBoard();
bool isBoardSurface = Boards::isSurface(board);
lock = true;
ui->throttleTrimSwitch->clear();
int idx=0;
int idx = 0;
QString trim;
for (int i=0; i<getBoardCapability(board, Board::NumTrims); i++, idx++) {
// here order is TERA instead of RETA
if (i == 0)
trim = RawSource(SOURCE_TYPE_TRIM, 2 + 1).toString(model, &generalSettings);
else if (i == 2)
trim = RawSource(SOURCE_TYPE_TRIM, 0 + 1).toString(model, &generalSettings);
else
trim = RawSource(SOURCE_TYPE_TRIM, i + 1).toString(model, &generalSettings);
for (int i = 0; i < getBoardCapability(board, Board::NumTrims); i++, idx++) {
if (isBoardSurface) {
if (i == 0)
trim = RawSource(SOURCE_TYPE_TRIM, 1 + 1).toString(model, &generalSettings);
else if (i == 1)
trim = RawSource(SOURCE_TYPE_TRIM, 0 + 1).toString(model, &generalSettings);
else
trim = RawSource(SOURCE_TYPE_TRIM, i + 1).toString(model, &generalSettings);
}
else {
// here order is TERA instead of RETA
if (i == 0)
trim = RawSource(SOURCE_TYPE_TRIM, 2 + 1).toString(model, &generalSettings);
else if (i == 2)
trim = RawSource(SOURCE_TYPE_TRIM, 0 + 1).toString(model, &generalSettings);
else
trim = RawSource(SOURCE_TYPE_TRIM, i + 1).toString(model, &generalSettings);
}
ui->throttleTrimSwitch->addItem(trim, idx);
}
+1
View File
@@ -292,6 +292,7 @@ class SetupPanel : public ModelPanel
signals:
void extendedLimitsToggled();
void updated();
void throttleReverseChanged();
private slots:
void on_name_editingFinished();
+1
View File
@@ -34,6 +34,7 @@ GenericPanel::GenericPanel(QWidget * parent, ModelData * model, GeneralSettings
model(model),
generalSettings(generalSettings),
firmware(firmware),
//board(firmware->getBoard()), TODO: as part of capabilities refactor
lock(false)
{
}
+2
View File
@@ -50,7 +50,9 @@ class GenericPanel : public QWidget
ModelData * model;
GeneralSettings & generalSettings;
Firmware * firmware;
//Board::Type board; TODO: as part of refactor to move physical capabilities from Firmware to Boards
bool lock;
void addLabel(QGridLayout * gridLayout, const QString &text, int col, bool mimimize=false);
void addEmptyLabel(QGridLayout * gridLayout, int col);
void addHSpring(QGridLayout *, int col, int row);
+7
View File
@@ -49,6 +49,7 @@ set(${PROJECT_NAME}_SRCS
simulateduiwidgetJumperTPRO.cpp
simulateduiwidgetJumperTPROS.cpp
simulateduiwidgetLR3PRO.cpp
simulateduiwidgetMT12.cpp
simulateduiwidgetNV14.cpp
simulateduiwidgetPL18.cpp
simulateduiwidgetPocket.cpp
@@ -70,6 +71,7 @@ set(${PROJECT_NAME}_SRCS
set(${PROJECT_NAME}_HDRS
${${PROJECT_NAME}_HDRS}
radiouiaction.h
simulateduiwidgetGeneric.h
widgets/buttonswidget.h
widgets/radiofaderwidget.h
widgets/radiokeywidget.h
@@ -84,6 +86,11 @@ qt5_wrap_cpp(${PROJECT_NAME}_SRCS
${${PROJECT_NAME}_HDRS}
)
# AUTOUIC does not detect as ui in .h so manually process
qt5_wrap_ui(${PROJECT_NAME}_SRCS
simulateduiwidgetGeneric.ui
)
add_library(${PROJECT_NAME}
${${PROJECT_NAME}_SRCS}
)
+1 -5
View File
@@ -19,8 +19,7 @@
* GNU General Public License for more details.
*/
#ifndef _DEBUGOUTPUT_H_
#define _DEBUGOUTPUT_H_
#pragma once
#include "simulator.h"
#include "simulatorinterface.h"
@@ -107,6 +106,3 @@ class DeleteComboBoxItemEventFilter : public QObject
protected:
bool eventFilter(QObject *obj, QEvent *event);
};
#endif // _DEBUGOUTPUT_H_
@@ -19,8 +19,7 @@
* GNU General Public License for more details.
*/
#ifndef FILTEREDTEXTBUFFER_H
#define FILTEREDTEXTBUFFER_H
#pragma once
#include <QBuffer>
#include <QRegularExpression>
@@ -117,6 +116,3 @@ class FilteredTextBuffer : public FIFOBufferDevice
bool m_lineFilterEnable;
bool m_lineFilterExclusive;
};
#endif // FILTEREDTEXTBUFFER_H
+1 -4
View File
@@ -19,8 +19,7 @@
* GNU General Public License for more details.
*/
#ifndef _JOYSTICK_H_
#define _JOYSTICK_H_
#pragma once
#include <QObject>
#include <QMap>
@@ -82,5 +81,3 @@ class Joystick : public QObject
public slots:
void processEvents();
};
#endif // _JOYSTICK_H_
+1 -4
View File
@@ -19,8 +19,7 @@
* GNU General Public License for more details.
*/
#ifndef _JOYSTICKDIALOG_H_
#define _JOYSTICKDIALOG_H_
#pragma once
#include <QtWidgets>
#include "appdata.h"
@@ -79,5 +78,3 @@ class joystickDialog : public QDialog
void on_okButton_clicked();
};
#endif // _JOYSTICKDIALOG_H_
@@ -222,9 +222,10 @@ void RadioOutputsWidget::setupGVarsDisplay()
ui->globalVarsScroll->setWidget(gvarsWidget);
QPalette::ColorRole bgrole = QPalette::AlternateBase;
const bool isAir = Boards::isAir();
for (int fm=0; fm < fmodes; fm++) {
QLabel * label = new QLabel(gvarsWidget);
label->setText(QString(tr("FM%1")).arg(fm));
label->setText(QString("%1%2").arg(isAir ? tr("FM") : tr("DM")).arg(fm));
label->setAlignment(Qt::AlignCenter);
label->setBackgroundRole(bgrole);
gvarsLayout->addWidget(label, 0, fm+1);
@@ -19,8 +19,7 @@
* GNU General Public License for more details.
*/
#ifndef RADIOOUTPUTSWIDGET_H
#define RADIOOUTPUTSWIDGET_H
#pragma once
#include "simulator.h"
#include "simulatorinterface.h"
@@ -86,5 +85,3 @@ class RadioOutputsWidget : public QWidget
private:
Ui::RadioOutputsWidget * ui;
};
#endif // RADIOOUTPUTSWIDGET_H
+3 -16
View File
@@ -19,8 +19,7 @@
* GNU General Public License for more details.
*/
#ifndef RADIOUIACTION_H
#define RADIOUIACTION_H
#pragma once
#include <QtCore>
#include <QWidget>
@@ -43,7 +42,7 @@ class RadioUiAction : public QObject
* @param text Optional title for this action. The text and description are currently used in generated help text.
* @param descript Optional longer description text for this action.
*/
RadioUiAction(int index = -1, int key = 0, const QString &text = "", const QString &descript = "", QWidget * parent = NULL):
RadioUiAction(int index = -1, int key = 0, const QString &text = "", const QString &descript = "", QWidget * parent = nullptr):
m_hwIndex(index),
m_active(false),
m_keys(QList<int>()),
@@ -57,7 +56,7 @@ class RadioUiAction : public QObject
* @param keys QList of Qt:Key codes to use as shortcuts.
* [See above for other params.]
*/
RadioUiAction(int index, QList<int> keys, const QString &text = "", const QString &descript = "", QWidget * parent = NULL):
RadioUiAction(int index, QList<int> keys, const QString &text = "", const QString &descript = "", QWidget * parent = nullptr):
RadioUiAction(index, 0, text, descript, parent)
{
addKeys(keys);
@@ -165,15 +164,3 @@ class RadioUiAction : public QObject
void pushed(int index); // only emitted on user interaction && when 'active' is true
void pushed();
};
#endif // RADIOUIACTION_H
+151 -9
View File
@@ -25,6 +25,10 @@
#include "radiouiaction.h"
#include "radiokeywidget.h"
#include "simulatorinterface.h"
#include "buttonswidget.h"
#include <QPushButton>
#include <QVBoxLayout>
//#define FLASH_DURATION 10
//#define CBEEP_ON "QLabel { background-color: #FF364E }"
@@ -34,11 +38,11 @@ SimulatedUIWidget::SimulatedUIWidget(SimulatorInterface * simulator, QWidget * p
QWidget(parent),
m_simulator(simulator),
m_parent(parent),
m_lcd(NULL),
m_scrollUpAction(NULL),
m_scrollDnAction(NULL),
m_mouseMidClickAction(NULL),
m_screenshotAction(NULL),
m_lcd(nullptr),
m_scrollUpAction(nullptr),
m_scrollDnAction(nullptr),
m_mouseMidClickAction(nullptr),
m_screenshotAction(nullptr),
m_board(getCurrentBoard()),
m_backLight(0),
m_beepShow(0),
@@ -191,11 +195,11 @@ void SimulatedUIWidget::mouseReleaseEvent(QMouseEvent * event)
void SimulatedUIWidget::setLcd(LcdWidget * lcd)
{
m_lcd = lcd;
Firmware * firmware = getCurrentFirmware();
Board::Type board = getCurrentBoard();
auto width = firmware->getCapability(LcdWidth);
auto height = firmware->getCapability(LcdHeight);
auto depth = firmware->getCapability(LcdDepth);
auto width = Boards::getCapability(board, Board::LcdWidth);
auto height = Boards::getCapability(board, Board::LcdHeight);
auto depth = Boards::getCapability(board, Board::LcdDepth);
m_lcd->setData(width, height, depth);
if (!m_backlightColors.size())
@@ -227,3 +231,141 @@ void SimulatedUIWidget::connectScrollActions()
});
}
}
// static
int SimulatedUIWidget::strKeyToInt(std::string key)
{
QStringList keys = {
"KEY_MENU",
"KEY_EXIT",
"KEY_ENTER",
"KEY_PAGEUP",
"KEY_PAGEDN",
"KEY_UP",
"KEY_DOWN",
"KEY_LEFT",
"KEY_RIGHT",
"KEY_PLUS",
"KEY_MINUS",
"KEY_MODEL",
"KEY_TELE",
"KEY_SYS",
"KEY_SHIFT",
"KEY_BIND"
};
return keys.indexOf(key.c_str());
}
void SimulatedUIWidget::addScrollActions()
{
// Note: the keys cannot duplicate those used for radio buttons
m_scrollUpAction = new RadioUiAction(-1, QList<int>() << Qt::Key_Minus,
SIMU_STR_HLP_KEY_MIN % "|" % SIMU_STR_HLP_MOUSE_UP, SIMU_STR_HLP_ACT_ROT_LFT);
m_scrollDnAction = new RadioUiAction(-1, QList<int>() << Qt::Key_Plus << Qt::Key_Equal,
SIMU_STR_HLP_KEY_PLS % "|" % SIMU_STR_HLP_MOUSE_DN, SIMU_STR_HLP_ACT_ROT_RGT);
connectScrollActions();
}
void SimulatedUIWidget::addMouseActions()
{
m_mouseMidClickAction = new RadioUiAction(KEY_ENTER, QList<int>() << Qt::Key_Enter << Qt::Key_Return,
SIMU_STR_HLP_KEYS_ACTIVATE, SIMU_STR_HLP_ACT_ROT_DN);
}
// Notes: unused rows will be hidden and squashed
// keys cannot duplicate those used for scrolling tefer m_mouseMidClickAction
static const QList<GenericKeyDefinition> genericKeyDefinitions = {
{ KEY_SYS, 'R', 0, 0, QList<int>() << Qt::Key_Left, SIMU_STR_HLP_KEY_LFT, SIMU_STR_HLP_ACT_SYS },
{ KEY_MODEL, 'R', 0, 1, QList<int>() << Qt::Key_Up, SIMU_STR_HLP_KEY_UP, SIMU_STR_HLP_ACT_MDL },
{ KEY_PAGEUP, 'R', 1, 0, QList<int>() << Qt::Key_PageUp, SIMU_STR_HLP_KEY_PGUP, SIMU_STR_HLP_ACT_PGUP },
{ KEY_PAGEDN, 'R', 1, 1, QList<int>() << Qt::Key_PageDown, SIMU_STR_HLP_KEY_PGDN, SIMU_STR_HLP_ACT_PGDN },
{ KEY_UP, 'R', 2, 0, QList<int>() << Qt::Key_Up
<< Qt::Key_PageUp, SIMU_STR_HLP_KEYS_GO_UP, SIMU_STR_HLP_ACT_UP },
{ KEY_DOWN, 'R', 2, 1, QList<int>() << Qt::Key_Down
<< Qt::Key_PageDown, SIMU_STR_HLP_KEYS_GO_DN, SIMU_STR_HLP_ACT_DN },
{ KEY_LEFT, 'R', 3, 0, QList<int>() << Qt::Key_Left
<< Qt::Key_Minus, SIMU_STR_HLP_KEY_LFT % "|" % SIMU_STR_HLP_KEY_MIN, SIMU_STR_HLP_ACT_MIN },
{ KEY_RIGHT, 'R', 3, 1, QList<int>() << Qt::Key_Right
<< Qt::Key_Plus, SIMU_STR_HLP_KEY_RGT % "|" % SIMU_STR_HLP_KEY_PLS, SIMU_STR_HLP_ACT_PLS },
{ KEY_MINUS, 'R', 4, 0, QList<int>() << Qt::Key_Minus
<< Qt::Key_Right, SIMU_STR_HLP_KEY_RGT % "|" % SIMU_STR_HLP_KEY_MIN % "|" % SIMU_STR_HLP_MOUSE_DN, SIMU_STR_HLP_ACT_MIN },
{ KEY_PLUS, 'R', 4, 1, QList<int>() << Qt::Key_Plus
<< Qt::Key_Equal
<< Qt::Key_Left, SIMU_STR_HLP_KEY_LFT % "|" % SIMU_STR_HLP_KEY_PLS % "|" % SIMU_STR_HLP_MOUSE_UP, SIMU_STR_HLP_ACT_PLS },
{ KEY_TELE, 'R', 5, 1, QList<int>() << Qt::Key_Right, SIMU_STR_HLP_KEY_RGT, SIMU_STR_HLP_ACT_TELE },
{ KEY_MENU, 'R', 6, 0, QList<int>() << Qt::Key_Up
<< Qt::Key_PageUp, SIMU_STR_HLP_KEYS_GO_UP, SIMU_STR_HLP_ACT_MENU },
{ KEY_SHIFT, 'R', 6, 1, QList<int>() << Qt::Key_S, SIMU_STR_HLP_KEY_SHIFT, SIMU_STR_HLP_ACT_SHIFT },
{ KEY_EXIT, 'R', 7, 0, QList<int>() << Qt::Key_Down
<< Qt::Key_Delete
<< Qt::Key_Escape
<< Qt::Key_Backspace, SIMU_STR_HLP_KEYS_EXIT, SIMU_STR_HLP_ACT_EXIT },
{ KEY_ENTER, 'R', 7, 1, QList<int>() << Qt::Key_Enter
<< Qt::Key_Return, SIMU_STR_HLP_KEYS_ACTIVATE, SIMU_STR_HLP_ACT_ROT_DN },
};
void SimulatedUIWidget::addGenericPushButtons(ButtonsWidget * leftButtons, ButtonsWidget * rightButtons)
{
QGridLayout * leftButtonsGrid = new QGridLayout();
QGridLayout * rightButtonsGrid = new QGridLayout();
for (int i = 0; i < Boards::getCapability(m_board, Board::Keys); i++) {
Board::KeyInfo info = Boards::getKeyInfo(i, m_board);
int idx = strKeyToInt(info.key);
//qDebug() << "key:" << info.key.c_str() << info.name.c_str() << info.label.c_str() << idx;
if (idx >= 0)
addGenericPushButton(idx, info.label.c_str(), leftButtons, leftButtonsGrid, rightButtons, rightButtonsGrid);
else
qDebug() << "Unknown key:" << info.key.c_str() << info.name.c_str() << info.label.c_str();
}
QGridLayout * gridLeft = new QGridLayout((QWidget *)leftButtons);
gridLeft->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 0);
gridLeft->addLayout(leftButtonsGrid, 0, 1);
//gridLeft->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 2);
QGridLayout * gridRight = new QGridLayout((QWidget *)rightButtons);
//gridRight->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 0);
gridRight->addLayout(rightButtonsGrid, 0, 1);
gridRight->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 2);
}
void SimulatedUIWidget::addGenericPushButton(int index, QString label, ButtonsWidget * leftButtons, QGridLayout * leftButtonsGrid,
ButtonsWidget * rightButtons, QGridLayout * rightButtonsGrid)
{
if (index >= genericKeyDefinitions.size())
return;
for (int i = 0; i < genericKeyDefinitions.size(); i++) {
const GenericKeyDefinition defn = genericKeyDefinitions.at(i);
if (defn.index == index) {
QPushButton * b = new QPushButton(label);
b->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
b->setMinimumSize(60, 30);
b->setMaximumSize(60, 30);
RadioUiAction * act = new RadioUiAction();
ButtonsWidget * btns = defn.side == 'L' ? leftButtons : rightButtons;
QGridLayout * grid = defn.side == 'L' ? leftButtonsGrid : rightButtonsGrid;
grid->addWidget(b, defn.gridRow, defn.gridCol);
act = new RadioUiAction(defn.index, defn.keys, defn.helpKeys, defn.helpActions);
addRadioWidget(btns->addPushButton(b, act));
break;
}
}
}
+52 -4
View File
@@ -19,8 +19,7 @@
* GNU General Public License for more details.
*/
#ifndef SIMULATEDUIWIDGET_H
#define SIMULATEDUIWIDGET_H
#pragma once
#include "boards.h"
#include "constants.h"
@@ -35,6 +34,8 @@ class SimulatorInterface;
class LcdWidget;
class RadioKeyWidget;
class RadioUiAction;
class ButtonsWidget;
class QPushButton;
// Match with /radio/src/hal/key_driver.h
enum EnumKeys {
@@ -64,6 +65,23 @@ enum EnumKeys {
MAX_KEYS
};
struct GenericKeyDefinition {
int index = 0;
QChar side = 'L';
int gridRow = 0;
int gridCol = 0;
QList<int> keys = QList<int>();
QString helpKeys = "";
QString helpActions = "";
GenericKeyDefinition(int index, QChar side, int gridRow, int gridCol,
QList<int> keys, QString helpKeys, QString helpActions) :
index(index), side(side), gridRow(gridRow), gridCol(gridCol),
keys(keys), helpKeys(helpKeys), helpActions(helpActions) {}
GenericKeyDefinition() = default;
};
/*
* This is a base class for the main hardware-specific radio user interface, including LCD screen and navigation buttons/widgets.
* It is responsible for hanlding all interactions with this part of the simulation (vs. common radio widgets like sticks/switches/knobs).
@@ -126,11 +144,20 @@ class SimulatedUIWidget : public QWidget
unsigned int m_backLight;
int m_beepShow;
int m_beepVal;
static int strKeyToInt(std::string key);
void addGenericPushButton(int index, QString label, ButtonsWidget * leftButtons, QGridLayout * leftButtonsGrid,
ButtonsWidget * rightButtons, QGridLayout * rightButtonsGrid);
void addGenericPushButtons(ButtonsWidget * leftButtons, ButtonsWidget * rightButtons);
void addScrollActions();
void addMouseActions();
};
// Each subclass is responsible for its own Ui
namespace Ui {
class SimulatedUIWidgetGeneric;
class SimulatedUIWidget9X;
class SimulatedUIWidgetX9LITE;
class SimulatedUIWidgetX7;
@@ -156,6 +183,7 @@ namespace Ui {
class SimulatedUIWidgetTX12;
class SimulatedUIWidgetZorro;
class SimulatedUIWidgetBoxer;
class SimulatedUIWidgetMT12;
class SimulatedUIWidgetPocket;
class SimulatedUIWidgetT8;
class SimulatedUIWidgetFatfishF16;
@@ -165,6 +193,19 @@ namespace Ui {
class SimulatedUIWidgetV16;
}
class SimulatedUIWidgetGeneric: public SimulatedUIWidget
{
Q_OBJECT
public:
explicit SimulatedUIWidgetGeneric(SimulatorInterface * simulator, QWidget * parent = nullptr);
virtual ~SimulatedUIWidgetGeneric();
private:
Ui::SimulatedUIWidgetGeneric * ui;
};
class SimulatedUIWidget9X: public SimulatedUIWidget
{
Q_OBJECT
@@ -469,6 +510,15 @@ class SimulatedUIWidgetBoxer: public SimulatedUIWidget
Ui::SimulatedUIWidgetBoxer * ui;
};
class SimulatedUIWidgetMT12: public SimulatedUIWidgetGeneric
{
Q_OBJECT
public:
explicit SimulatedUIWidgetMT12(SimulatorInterface * simulator, QWidget * parent = nullptr);
virtual ~SimulatedUIWidgetMT12();
};
class SimulatedUIWidgetPocket: public SimulatedUIWidget
{
Q_OBJECT
@@ -552,5 +602,3 @@ class SimulatedUIWidgetV16: public SimulatedUIWidget
private:
Ui::SimulatedUIWidgetV16 * ui;
};
#endif // SIMULATEDUIWIDGET_H
@@ -1,3 +1,24 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "simulateduiwidget.h"
#include "ui_simulateduiwidgetBoxer.h"
@@ -1,3 +1,24 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "simulateduiwidget.h"
#include "ui_simulateduiwidgetCommando8.h"
@@ -19,7 +19,6 @@
* GNU General Public License for more details.
*/
#include "simulateduiwidget.h"
#include "ui_simulateduiwidgetFatfishF16.h"
@@ -0,0 +1,48 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#pragma once
#include "simulateduiwidget.h"
#include "ui_simulateduiwidgetGeneric.h"
/*
Note: This class is not expected to be instantiated directly but as the base for each firmware that uses it
due to the methods and functions surrounding the building and loading of radio simulators
*/
SimulatedUIWidgetGeneric::SimulatedUIWidgetGeneric(SimulatorInterface *simulator, QWidget * parent):
SimulatedUIWidget(simulator, parent),
ui(new Ui::SimulatedUIWidgetGeneric)
{
ui->setupUi(this);
addGenericPushButtons(ui->leftbuttons, ui->rightbuttons);
addScrollActions();
setLcd(ui->lcd);
}
SimulatedUIWidgetGeneric::~SimulatedUIWidgetGeneric()
{
delete ui;
}
@@ -0,0 +1,210 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SimulatedUIWidgetGeneric</class>
<widget class="QWidget" name="SimulatedUIWidgetGeneric">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>737</width>
<height>246</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>737</width>
<height>246</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>737</width>
<height>246</height>
</size>
</property>
<property name="windowTitle">
<string notr="true">Generic Simulator</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<widget class="ButtonsWidget" name="leftbuttons" native="true">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>241</width>
<height>246</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>241</width>
<height>246</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>241</width>
<height>246</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="ButtonsWidget" name="rightbuttons" native="true">
<property name="geometry">
<rect>
<x>496</x>
<y>0</y>
<width>241</width>
<height>246</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>241</width>
<height>246</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>241</width>
<height>246</height>
</size>
</property>
</widget>
<widget class="QWidget" name="bottom" native="true">
<property name="geometry">
<rect>
<x>241</x>
<y>188</y>
<width>255</width>
<height>58</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>255</width>
<height>58</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>255</width>
<height>58</height>
</size>
</property>
</widget>
<widget class="LcdWidget" name="lcd" native="true">
<property name="geometry">
<rect>
<x>240</x>
<y>59</y>
<width>256</width>
<height>128</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>100</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>424</width>
<height>180</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(215, 243, 255);</string>
</property>
</widget>
<widget class="QWidget" name="top" native="true">
<property name="geometry">
<rect>
<x>241</x>
<y>0</y>
<width>255</width>
<height>59</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>255</width>
<height>59</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>255</width>
<height>59</height>
</size>
</property>
</widget>
<zorder>bottom</zorder>
<zorder>top</zorder>
<zorder>rightbuttons</zorder>
<zorder>leftbuttons</zorder>
<zorder>lcd</zorder>
</widget>
<customwidgets>
<customwidget>
<class>LcdWidget</class>
<extends>QWidget</extends>
<header>lcdwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ButtonsWidget</class>
<extends>QWidget</extends>
<header>buttonswidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../companion.qrc"/>
</resources>
<connections/>
</ui>
@@ -1,3 +1,24 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "simulateduiwidget.h"
#include "ui_simulateduiwidgetJumperT12.h"
@@ -1,3 +1,24 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "simulateduiwidget.h"
#include "ui_simulateduiwidgetJumperT14.h"
@@ -1,3 +1,24 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "simulateduiwidget.h"
#include "ui_simulateduiwidgetJumperT20.h"
@@ -1,3 +1,24 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "simulateduiwidget.h"
#include "ui_simulateduiwidgetJumperTLITE.h"
@@ -1,3 +1,24 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "simulateduiwidget.h"
#include "ui_simulateduiwidgetJumperTPRO.h"
#include "eeprominterface.h"
@@ -1,3 +1,24 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "simulateduiwidget.h"
#include "ui_simulateduiwidgetLR3PRO.h"
@@ -0,0 +1,33 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "simulateduiwidgetGeneric.h"
SimulatedUIWidgetMT12::SimulatedUIWidgetMT12(SimulatorInterface *simulator, QWidget * parent):
SimulatedUIWidgetGeneric(simulator, parent)
{
// Perform any customisation such as loading lcd area background color lists
}
SimulatedUIWidgetMT12::~SimulatedUIWidgetMT12()
{
}
@@ -1,3 +1,24 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "simulateduiwidget.h"
#include "ui_simulateduiwidgetPocket.h"
@@ -1,3 +1,24 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "simulateduiwidget.h"
#include "ui_simulateduiwidgetT8.h"
@@ -1,3 +1,24 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "simulateduiwidget.h"
#include "ui_simulateduiwidgetTX12.h"
@@ -1,3 +1,24 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "simulateduiwidget.h"
#include "ui_simulateduiwidgetX7.h"
@@ -1,3 +1,24 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "simulateduiwidget.h"
#include "ui_simulateduiwidgetX9LITE.h"
@@ -1,3 +1,24 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "simulateduiwidget.h"
#include "ui_simulateduiwidgetXLITE.h"
@@ -1,3 +1,24 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "simulateduiwidget.h"
#include "ui_simulateduiwidgetZorro.h"
+1 -5
View File
@@ -19,8 +19,7 @@
* GNU General Public License for more details.
*/
#ifndef SIMULATOR_H
#define SIMULATOR_H
#pragma once
#include <QColor>
#include <QDataStream>
@@ -195,6 +194,3 @@ struct SimulatorOptions
};
Q_DECLARE_METATYPE(SimulatorOptions)
#endif // SIMULATOR_H
+22 -4
View File
@@ -1,5 +1,25 @@
#ifndef SIMULATOR_STRINGS_H
#define SIMULATOR_STRINGS_H
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#pragma once
#include <QCoreApplication>
@@ -64,5 +84,3 @@
#define SIMU_STR_HLP_ACT_ROT_LFT SIMU_STR_HLP_ROTENC % " " % SIMU_STR_HLP_ROTENC_LFT
#define SIMU_STR_HLP_ACT_ROT_RGT SIMU_STR_HLP_ROTENC % " " % SIMU_STR_HLP_ROTENC_RGT
#define SIMU_STR_HLP_ACT_ROT_DN SIMU_STR_HLP_ROTENC % " " % SIMU_STR_HLP_ROTENC_DN
#endif // SIMULATOR_STRINGS_H
@@ -19,8 +19,7 @@
* GNU General Public License for more details.
*/
#ifndef _SIMULATORINTERFACE_H_
#define _SIMULATORINTERFACE_H_
#pragma once
#include "firmwares/boards.h"
#include "constants.h"
@@ -204,5 +203,3 @@ class SimulatorLoader
static int registerSimulators(const QDir & dir);
static QMap<QString, QLibrary *> registeredSimulators;
};
#endif // _SIMULATORINTERFACE_H_
@@ -19,8 +19,7 @@
* GNU General Public License for more details.
*/
#ifndef SIMULATORMAINWINDOW_H
#define SIMULATORMAINWINDOW_H
#pragma once
#include "simulator.h"
@@ -114,5 +113,3 @@ class SimulatorMainWindow : public QMainWindow
const static quint16 m_savedUiStateVersion;
};
#endif // SIMULATORMAINWINDOW_H
@@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>OpenTx Simulator</string>
<string>EdgeTX Simulator</string>
</property>
<property name="windowIcon">
<iconset resource="../companion.qrc">
@@ -37,7 +37,7 @@
<x>0</x>
<y>0</y>
<width>644</width>
<height>21</height>
<height>22</height>
</rect>
</property>
<property name="nativeMenuBar">
@@ -19,8 +19,7 @@
* GNU General Public License for more details.
*/
#ifndef SIMULATORSTARTUPDIALOG_H
#define SIMULATORSTARTUPDIALOG_H
#pragma once
#include "simulator.h"
#include <QDialog>
@@ -75,5 +74,3 @@ class SimulatorStartupDialog : public QDialog
void setGlobalFirmware(const QString & id);
};
#endif // SIMULATORSTARTUPDIALOG_H
+4 -1
View File
@@ -138,6 +138,9 @@ SimulatorWidget::SimulatorWidget(QWidget * parent, SimulatorInterface * simulato
case Board::BOARD_RADIOMASTER_BOXER:
radioUiWidget = new SimulatedUIWidgetBoxer(simulator, this);
break;
case Board::BOARD_RADIOMASTER_MT12:
radioUiWidget = new SimulatedUIWidgetMT12(simulator, this);
break;
case Board::BOARD_RADIOMASTER_T8:
radioUiWidget = new SimulatedUIWidgetT8(simulator, this);
break;
@@ -836,7 +839,7 @@ void SimulatorWidget::onSimulatorError(const QString & error)
void SimulatorWidget::onPhaseChanged(qint32 phase, const QString & name)
{
setWindowTitle(windowName + tr(" - Flight Mode %1 (#%2)").arg(name).arg(phase));
setWindowTitle(windowName + QString(" - %1 %2 (#%3)").arg(Boards::getCapability(m_board, Board::Air) ? tr("Flight Mode") : tr("Drive Mode")).arg(name).arg(phase));
}
void SimulatorWidget::onRadioWidgetValueChange(const RadioWidget::RadioWidgetType type, int index, int value)
+1 -4
View File
@@ -19,8 +19,7 @@
* GNU General Public License for more details.
*/
#ifndef _SIMULATORWIDGET_H_
#define _SIMULATORWIDGET_H_
#pragma once
#include "appdata.h"
#include "constants.h"
@@ -152,5 +151,3 @@ class SimulatorWidget : public QWidget
int switchDirection[MAX_JS_BUTTONS];
#endif
};
#endif // _SIMULATORWIDGET_H_
-1
View File
@@ -121,4 +121,3 @@ class TelemetrySimulator : public QWidget
LogPlaybackController *logPlayback;
}; // TelemetrySimulator
+1 -6
View File
@@ -19,9 +19,7 @@
* GNU General Public License for more details.
*/
#ifndef _TRAINERSIMU_H_
#define _TRAINERSIMU_H_
#pragma once
#include <QShowEvent>
#include <QCloseEvent>
@@ -67,6 +65,3 @@ class TrainerSimulator : public QWidget
bool m_simuStarted;
};
#endif // _TRAINERSIMU_H_
@@ -19,8 +19,7 @@
* GNU General Public License for more details.
*/
#ifndef _BUTTONSWIDGET_H_
#define _BUTTONSWIDGET_H_
#pragma once
#include "radiouiaction.h"
#include "radiokeywidget.h"
@@ -46,17 +45,46 @@ class ButtonsWidget : public QWidget
QWidget::setStyleSheet(sheet);
}
RadioKeyWidget * addArea(const QRect & rect, const char * image, RadioUiAction * action = NULL)
RadioKeyWidget * addArea(const QRect & rect, const char * image, RadioUiAction * action = nullptr)
{
return addArea(QPolygon(rect), image, action);
}
RadioKeyWidget * addArea(const QPolygon & polygon, const char * image, RadioUiAction * action = NULL)
RadioKeyWidget * addArea(const QPolygon & polygon, const char * image, RadioUiAction * action = nullptr)
{
RadioKeyWidget * btn = new RadioKeyWidget(polygon, image, action, this);
m_buttons.append(btn);
connect(btn, &RadioKeyWidget::imageChanged, this, &ButtonsWidget::setBitmap);
return btn;
RadioKeyWidget * rkw = new RadioKeyWidget(polygon, image, action, this);
m_buttons.append(rkw);
connect(rkw, &RadioKeyWidget::imageChanged, this, &ButtonsWidget::setBitmap);
return rkw;
}
RadioKeyWidget * addPushButton(QPushButton * pushbtn, RadioUiAction * action = nullptr)
{
RadioKeyWidget * rkw = new RadioKeyWidget(pushbtn, action, this);
m_buttons.append(rkw);
connect(pushbtn, &QPushButton::pressed, rkw, &RadioKeyWidget::press);
connect(pushbtn, &QPushButton::released, rkw, &RadioKeyWidget::release);
if (action) {
// blink push button on click or matching key(s) press
connect(action, static_cast<void (RadioUiAction::*)(void)>(&RadioUiAction::pushed), [this, pushbtn] (void) {
// TODO: use a palette colors
// set to default -> blink -> default
QString csssave = pushbtn->styleSheet();
QString blnkcol = "background-color: rgb(239, 41, 41)";
// pressing the same key in rapid seccession can affect the order of the events see TODO
if (csssave != blnkcol) {
pushbtn->setFocus();
pushbtn->setStyleSheet(blnkcol);
QTimer * tim = new QTimer(this);
tim->setSingleShot(true);
connect(tim, &QTimer::timeout, [pushbtn, csssave]() { pushbtn->setStyleSheet(csssave); });
tim->start(300);
}
});
}
pushbtn->setFocusPolicy(Qt::ClickFocus);
return rkw;
}
protected:
@@ -111,5 +139,3 @@ class ButtonsWidget : public QWidget
QList<RadioKeyWidget *> m_buttons;
QString defaultStyleSheet;
};
#endif // _BUTTONSWIDGET_H_
@@ -19,8 +19,7 @@
* GNU General Public License for more details.
*/
#ifndef _RADIOFADERWIDGET_H_
#define _RADIOFADERWIDGET_H_
#pragma once
#include "radiowidget.h"
#include "sliderwidget.h"
@@ -63,8 +62,3 @@ class RadioFaderWidget : public RadioWidget
setWidget(sl);
}
};
#endif // _RADIOFADERWIDGET_H_
@@ -19,22 +19,25 @@
* GNU General Public License for more details.
*/
#ifndef RADIOKEYWIDGET_H
#define RADIOKEYWIDGET_H
#pragma once
#include "radiouiaction.h"
#include "radiowidget.h"
#include <QPushButton>
class RadioKeyWidget : public RadioWidget
{
Q_OBJECT
public:
explicit RadioKeyWidget(const QPolygon & polygon, const QString &image, RadioUiAction * action = NULL, QWidget * parent = NULL, Qt::WindowFlags f = Qt::WindowFlags()):
explicit RadioKeyWidget(const QPolygon & polygon, const QString &image, RadioUiAction * action = nullptr,
QWidget * parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags(), QPushButton * pushbtn = nullptr):
RadioWidget(action, parent, f),
polygon(polygon),
imgFile(image)
imgFile(image),
pushbtn(pushbtn)
{
m_type = RADIO_WIDGET_KEY;
setValue(0);
@@ -42,6 +45,11 @@ class RadioKeyWidget : public RadioWidget
setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
}
explicit RadioKeyWidget(QPushButton * pushbtn = nullptr, RadioUiAction * action = nullptr,
QWidget * parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()) :
RadioKeyWidget(QPolygon(), QString(), action, parent, f, pushbtn) {}
virtual void setAction(RadioUiAction * action)
{
if (m_action)
@@ -82,6 +90,7 @@ class RadioKeyWidget : public RadioWidget
signals:
void imageChanged(const QString image);
void actionTriggered();
protected:
@@ -91,11 +100,13 @@ class RadioKeyWidget : public RadioWidget
emit imageChanged(active ? imgFile : "");
}
virtual void onActionTriggered(int index, bool active)
{
if (pushbtn)
emit actionTriggered();
}
QPolygon polygon;
QString imgFile;
QPushButton *pushbtn;
};
#endif // RADIOKEYWIDGET_H
@@ -19,8 +19,7 @@
* GNU General Public License for more details.
*/
#ifndef _RADIOSWITCHWIDGET_H_
#define _RADIOSWITCHWIDGET_H_
#pragma once
#include "radiowidget.h"
#include "boards.h"
@@ -146,5 +145,3 @@ class RadioSwitchWidget : public RadioWidget
quint16 m_stepSize;
};
#endif // _RADIOSWITCHWIDGET_H_
@@ -19,8 +19,7 @@
* GNU General Public License for more details.
*/
#ifndef _RADIOTRIMWIDGET_H_
#define _RADIOTRIMWIDGET_H_
#pragma once
#include "radiowidget.h"
#include "boards.h"
@@ -138,5 +137,3 @@ class RadioTrimWidget : public RadioWidget
int m_btnDecIndex;
int m_btnIncIndex;
};
#endif // _RADIOTRIMWIDGET_H_
@@ -137,10 +137,10 @@ void RadioWidget::setAction(RadioUiAction * action)
if (m_action->getIndex() > -1)
setIndex(m_action->getIndex());
connect(m_action, &RadioUiAction::toggled, this, &RadioWidget::onActionToggled);
connect(m_action, &RadioUiAction::triggered, this, &RadioWidget::onActionTriggered);
}
}
int RadioWidget::getValue() const
{
return m_value;
@@ -179,6 +179,10 @@ void RadioWidget::onActionToggled(int index, bool active)
emit valueChange(m_type, index, getValue());
}
void RadioWidget::onActionTriggered(int index, bool active)
{
// do nothing
}
void RadioWidget::addLayout()
{
@@ -19,8 +19,7 @@
* GNU General Public License for more details.
*/
#ifndef _RADIOWIDGET_H_
#define _RADIOWIDGET_H_
#pragma once
#include <QGridLayout>
#include <QDebug>
@@ -109,6 +108,7 @@ class RadioWidget : public QWidget
void addLabel();
void setWidget(QWidget * widget = NULL, Qt::Alignment align = Qt::AlignHCenter);
virtual void onActionToggled(int index, bool active);
virtual void onActionTriggered(int index, bool active);
QGridLayout * m_gridLayout;
QWidget * m_controlWidget;
@@ -126,5 +126,3 @@ class RadioWidget : public QWidget
};
Q_DECLARE_METATYPE(RadioWidget::RadioWidgetState)
#endif // _RADIOWIDGET_H_
@@ -19,8 +19,7 @@
* GNU General Public License for more details.
*/
#ifndef _SLIDERWIDGET_H_
#define _SLIDERWIDGET_H_
#pragma once
#include <QtGui>
#include <QSlider>
@@ -64,5 +63,3 @@ class SliderWidget : public QSlider
QString m_toolTip;
};
#endif // _SLIDERWIDGET_H_
@@ -36,17 +36,18 @@ VirtualJoystickWidget::VirtualJoystickWidget(QWidget *parent, QChar side, bool s
QWidget(parent),
stickSide(side),
prefSize(size),
hTrimWidget(NULL),
vTrimWidget(NULL),
btnHoldX(NULL),
btnHoldY(NULL),
btnFixX(NULL),
btnFixY(NULL),
nodeLabelX(NULL),
nodeLabelY(NULL),
hTrimWidget(nullptr),
vTrimWidget(nullptr),
btnHoldX(nullptr),
btnHoldY(nullptr),
btnFixX(nullptr),
btnFixY(nullptr),
nodeLabelX(nullptr),
nodeLabelY(nullptr),
m_stickScale(1024),
m_stickPressed(false)
{
isBoardSurface = Boards::isSurface(getCurrentBoard());
ar = (float)size.width() / size.height();
extraSize = QSize(0, 0);
@@ -92,6 +93,13 @@ VirtualJoystickWidget::VirtualJoystickWidget(QWidget *parent, QChar side, bool s
hTrimWidget = createTrimWidget('H');
vTrimWidget = createTrimWidget('V');
if (isBoardSurface) {
if (stickSide == 'L')
vTrimWidget->hide();
else
vTrimWidget->hide();
}
layout->addWidget(vTrimWidget, 1, colvt, 1, 1);
layout->addWidget(hTrimWidget, 2, 2, 1, 1);
@@ -109,6 +117,18 @@ VirtualJoystickWidget::VirtualJoystickWidget(QWidget *parent, QChar side, bool s
btnbox->addWidget(btnFixY = createButtonWidget(FIX_Y));
btnbox->addWidget(btnFixX = createButtonWidget(FIX_X));
btnbox->addWidget(btnHoldX = createButtonWidget(HOLD_X));
if (isBoardSurface) {
if (stickSide == 'L') {
btnHoldX->hide();
btnFixY->hide();
btnFixX->hide();
}
else {
btnHoldY->hide();
btnFixY->hide();
btnFixX->hide();
}
}
layout->addLayout(btnbox, 1, colbb, 1, 1);
@@ -171,23 +191,37 @@ void VirtualJoystickWidget::setStickAxisValue(int index, int value)
using namespace Board;
qreal rvalue = value / 1024.0f;
switch (index) {
case STICK_AXIS_LH :
if (stickSide == 'L')
setStickX(rvalue);
break;
case STICK_AXIS_RH :
if (stickSide == 'R')
setStickX(rvalue);
break;
case STICK_AXIS_LV :
if (stickSide == 'L')
setStickY(rvalue);
break;
case STICK_AXIS_RV :
if (stickSide == 'R')
setStickY(rvalue);
break;
if (isBoardSurface) {
switch (index) {
case STICK_AXIS_SURFACE_LV :
if (stickSide == 'L')
setStickY(rvalue);
break;
case STICK_AXIS_SURFACE_RH :
if (stickSide == 'R')
setStickX(rvalue);
break;
}
}
else {
switch (index) {
case STICK_AXIS_LH :
if (stickSide == 'L')
setStickX(rvalue);
break;
case STICK_AXIS_RH :
if (stickSide == 'R')
setStickX(rvalue);
break;
case STICK_AXIS_LV :
if (stickSide == 'L')
setStickY(rvalue);
break;
case STICK_AXIS_RV :
if (stickSide == 'R')
setStickY(rvalue);
break;
}
}
}
@@ -299,10 +333,24 @@ void VirtualJoystickWidget::setStickColor(const QColor & color)
void VirtualJoystickWidget::loadDefaultsForMode(const unsigned mode)
{
if (((mode & 1) && stickSide == 'L') || (!(mode & 1) && stickSide == 'R')) {
setStickConstraint(HOLD_Y, true);
setStickY(-1.0);
onNodeYChanged();
if (isBoardSurface) {
if (stickSide == 'L') {
setStickX(0.0);
setStickConstraint(FIX_X, true);
onNodeXChanged();
}
else {
setStickY(0.0);
setStickConstraint(FIX_Y, true);
onNodeYChanged();
}
}
else {
if (((mode & 1) && stickSide == 'L') || (!(mode & 1) && stickSide == 'R')) {
setStickConstraint(HOLD_Y, true);
setStickY(-1.0);
onNodeYChanged();
}
}
}
@@ -400,22 +448,22 @@ QToolButton * VirtualJoystickWidget::createButtonWidget(int type)
switch (type) {
case HOLD_Y:
btnLabel = tr("Hld Y");
tooltip = tr("Hold Vertical stick position.");
tooltip = tr("Hold Vertical position.");
icon = Simulator::SimulatorIcon("hold_y");
break;
case FIX_Y:
btnLabel = tr("Fix Y");
tooltip = tr("Prevent Vertical movement of stick.");
tooltip = tr("Prevent Vertical movement.");
icon = Simulator::SimulatorIcon("fixed_y");
break;
case FIX_X:
btnLabel = tr("Fix X");
tooltip = tr("Prevent Horizontal movement of stick.");
tooltip = tr("Prevent Horizontal movement.");
icon = Simulator::SimulatorIcon("fixed_x");
break;
case HOLD_X:
btnLabel = tr("Hld X");
tooltip = tr("Hold Horizontal stick position.");
tooltip = tr("Hold Horizontal position.");
icon = Simulator::SimulatorIcon("hold_x");
break;
default:
@@ -445,11 +493,7 @@ QLayout *VirtualJoystickWidget::createNodeValueLayout(QChar type, QLabel *& valL
val->setObjectName(QString("val_%1").arg(type));
val->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
val->setAlignment(Qt::AlignCenter);
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
val->setMinimumWidth(val->fontMetrics().width("-100 "));
#else
val->setMinimumWidth(val->fontMetrics().horizontalAdvance("-100 "));
#endif
QVBoxLayout * layout = new QVBoxLayout();
layout->setContentsMargins(2, 2, 2, 2);
layout->setSpacing(2);
@@ -464,17 +508,33 @@ int VirtualJoystickWidget::getStickIndex(QChar type)
{
using namespace Board;
if (stickSide == 'L') {
if (type == 'H')
return STICK_AXIS_LH;
else
return STICK_AXIS_LV;
if (isBoardSurface) {
if (stickSide == 'L') {
if (type == 'H')
return STICK_AXIS_SURFACE_LV;
else
return STICK_AXIS_SURFACE_LV;
}
else {
if (type == 'H')
return STICK_AXIS_SURFACE_RH;
else
return STICK_AXIS_SURFACE_RH;
}
}
else {
if (type == 'H')
return STICK_AXIS_RH;
else
return STICK_AXIS_RV;
if (stickSide == 'L') {
if (type == 'H')
return STICK_AXIS_LH;
else
return STICK_AXIS_LV;
}
else {
if (type == 'H')
return STICK_AXIS_RH;
else
return STICK_AXIS_RV;
}
}
}
@@ -482,17 +542,33 @@ int VirtualJoystickWidget::getTrimSliderType(QChar type)
{
using namespace Board;
if (stickSide == 'L') {
if (type == 'H')
return TRIM_AXIS_LH;
else
return TRIM_AXIS_LV;
if (isBoardSurface) {
if (stickSide == 'L') {
if (type == 'H')
return TRIM_AXIS_SURFACE_LH;
else
return TRIM_AXIS_SURFACE_LH;
}
else {
if (type == 'H')
return TRIM_AXIS_SURFACE_RH;
else
return TRIM_AXIS_SURFACE_RH;
}
}
else {
if (type == 'H')
return TRIM_AXIS_RH;
else
return TRIM_AXIS_RV;
if (stickSide == 'L') {
if (type == 'H')
return TRIM_AXIS_LH;
else
return TRIM_AXIS_LV;
}
else {
if (type == 'H')
return TRIM_AXIS_RH;
else
return TRIM_AXIS_RV;
}
}
}
@@ -500,45 +576,86 @@ int VirtualJoystickWidget::getTrimButtonType(QChar type, int pos)
{
using namespace Board;
if (stickSide == 'L') {
if (type == 'H') {
if (pos == 0)
return TRIM_SW_LH_DEC;
else
return TRIM_SW_LH_INC;
if (isBoardSurface) {
if (stickSide == 'L') {
if (type == 'H') {
if (pos == 0)
return TRIM_SW_SURFACE_LH_DEC;
else
return TRIM_SW_SURFACE_LH_INC;
}
else {
if (pos == 0)
return TRIM_SW_SURFACE_LH_DEC;
else
return TRIM_SW_SURFACE_LH_INC;
}
}
// right side
else {
if (pos == 0)
return TRIM_SW_LV_DEC;
else
return TRIM_SW_LV_INC;
if (type == 'H') {
if (pos == 0)
return TRIM_SW_SURFACE_RH_DEC;
else
return TRIM_SW_SURFACE_RH_INC;
}
else {
if (pos == 0)
return TRIM_SW_SURFACE_RH_DEC;
else
return TRIM_SW_SURFACE_RH_INC;
}
}
}
// right side
else {
if (type == 'H') {
if (pos == 0)
return TRIM_SW_RH_DEC;
else
return TRIM_SW_RH_INC;
if (stickSide == 'L') {
if (type == 'H') {
if (pos == 0)
return TRIM_SW_LH_DEC;
else
return TRIM_SW_LH_INC;
}
else {
if (pos == 0)
return TRIM_SW_LV_DEC;
else
return TRIM_SW_LV_INC;
}
}
// right side
else {
if (pos == 0)
return TRIM_SW_RV_DEC;
else
return TRIM_SW_RV_INC;
if (type == 'H') {
if (pos == 0)
return TRIM_SW_RH_DEC;
else
return TRIM_SW_RH_INC;
}
else {
if (pos == 0)
return TRIM_SW_RV_DEC;
else
return TRIM_SW_RV_INC;
}
}
}
}
RadioTrimWidget * VirtualJoystickWidget::getTrimWidget(int which)
{
if ((stickSide == 'L' && which == Board::TRIM_AXIS_LH) || (stickSide == 'R' && which == Board::TRIM_AXIS_RH))
return hTrimWidget;
else if ((stickSide == 'L' && which == Board::TRIM_AXIS_LV) || (stickSide == 'R' && which == Board::TRIM_AXIS_RV))
return vTrimWidget;
else
return NULL;
if (isBoardSurface) {
if ((stickSide == 'L' && which == Board::TRIM_AXIS_SURFACE_LH) || (stickSide == 'R' && which == Board::TRIM_AXIS_SURFACE_RH))
return hTrimWidget;
else
return nullptr;
}
else {
if ((stickSide == 'L' && which == Board::TRIM_AXIS_LH) || (stickSide == 'R' && which == Board::TRIM_AXIS_RH))
return hTrimWidget;
else if ((stickSide == 'L' && which == Board::TRIM_AXIS_LV) || (stickSide == 'R' && which == Board::TRIM_AXIS_RV))
return vTrimWidget;
else
return nullptr;
}
}
void VirtualJoystickWidget::onButtonChange(bool checked)
@@ -564,10 +681,26 @@ void VirtualJoystickWidget::onButtonChange(bool checked)
void VirtualJoystickWidget::updateNodeValueLabels()
{
if (nodeLabelX)
nodeLabelX->setText(QString("%1").arg(getStickX() * 100.0f, 2, 'f', 0));
if (nodeLabelY)
nodeLabelY->setText(QString("%1").arg(getStickY() * 100.0f, 2, 'f', 0));
if (isBoardSurface) {
if (nodeLabelX) {
if (stickSide == 'L')
nodeLabelX->setText(QString("%1").arg(0)); // workaround for resize event and no analog mapped to set
else
nodeLabelX->setText(QString("%1").arg(getStickX() * 100.0f, 2, 'f', 0));
}
if (nodeLabelY) {
if (stickSide == 'L')
nodeLabelY->setText(QString("%1").arg(getStickY() * 100.0f, 2, 'f', 0));
else
nodeLabelY->setText(QString("%1").arg(0)); // workaround for resize event and no analog mapped to set
}
}
else {
if (nodeLabelX)
nodeLabelX->setText(QString("%1").arg(getStickX() * 100.0f, 2, 'f', 0));
if (nodeLabelY)
nodeLabelY->setText(QString("%1").arg(getStickY() * 100.0f, 2, 'f', 0));
}
}
void VirtualJoystickWidget::onGsMouseEvent(QGraphicsSceneMouseEvent * event)
@@ -19,8 +19,7 @@
* GNU General Public License for more details.
*/
#ifndef VIRTUALJOYSTICKWIDGET_H
#define VIRTUALJOYSTICKWIDGET_H
#pragma once
#include "radiowidget.h"
@@ -62,8 +61,8 @@ class VirtualJoystickWidget : public QWidget
int getStickScale() const;
void setStickScale(int stickScale);
const RadioTrimWidget *horizontalTrim() { return hTrimWidget; }
const RadioTrimWidget *verticalTrim() { return vTrimWidget; }
const RadioTrimWidget *horizontalTrim() { return hTrimWidget; }
const RadioTrimWidget *verticalTrim() { return vTrimWidget; }
public slots:
void setStickX(qreal x);
@@ -120,6 +119,7 @@ class VirtualJoystickWidget : public QWidget
int m_yIndex;
int m_stickScale;
bool m_stickPressed;
bool isBoardSurface;
};
@@ -143,5 +143,3 @@ class CustomGraphicsScene : public QGraphicsScene
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent * event);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * event);
};
#endif // VIRTUALJOYSTICKWIDGET_H
+1
View File
@@ -23,6 +23,7 @@
#include <stdint.h>
// Match with /companion/src/simulation/simulateduiwidget.h
enum EnumKeys {
KEY_MENU,
KEY_EXIT,
+1 -1
View File
@@ -69,7 +69,7 @@ cd build
declare -a simulator_plugins=(x9lite x9lites
x7 x7access
t8 t12 t12max tx12 tx12mk2
zorro commando8 boxer pocket
zorro commando8 boxer pocket mt12
tlite tpro tprov2 tpros lr3pro t14
x9d x9dp x9dp2019 x9e
xlite xlites