Merge remote-tracking branch 'origin/elecpower/cpn-refactor-radio-settings' into elecpower/cpn-refactor-gen-settings
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "boards.h"
|
||||
#include "macros.h"
|
||||
#include "compounditemmodels.h"
|
||||
|
||||
// TODO remove all those constants
|
||||
// Update: These are now all only used within this class.
|
||||
@@ -374,7 +375,7 @@ int Boards::getCapability(Board::Type board, Board::Capability capability)
|
||||
case MultiposPotsPositions:
|
||||
return IS_HORUS_OR_TARANIS(board) ? 6 : 0;
|
||||
|
||||
case Switches:
|
||||
case Board::Switches:
|
||||
if (IS_TARANIS_X9E(board))
|
||||
return 18;
|
||||
else if (board == Board::BOARD_TARANIS_X9LITE)
|
||||
@@ -410,11 +411,11 @@ int Boards::getCapability(Board::Type board, Board::Capability capability)
|
||||
else if (IS_HORUS_X12S(board))
|
||||
return 8;
|
||||
else
|
||||
return getCapability(board, Switches);
|
||||
return getCapability(board, Board::Switches);
|
||||
|
||||
case SwitchPositions:
|
||||
if (IS_HORUS_OR_TARANIS(board))
|
||||
return getCapability(board, Switches) * 3;
|
||||
return getCapability(board, Board::Switches) * 3;
|
||||
else
|
||||
return 9;
|
||||
|
||||
@@ -425,10 +426,14 @@ int Boards::getCapability(Board::Type board, Board::Capability capability)
|
||||
return 4;
|
||||
|
||||
case NumTrimSwitches:
|
||||
return getCapability(board, NumTrims) * 2;
|
||||
}
|
||||
return getCapability(board, Board::NumTrims) * 2;
|
||||
|
||||
return 0;
|
||||
case HasRTC:
|
||||
return IS_STM32(board) ? true : false;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
QString Boards::getAxisName(int index)
|
||||
@@ -444,7 +449,7 @@ QString Boards::getAxisName(int index)
|
||||
if (index < (int)DIM(axes))
|
||||
return axes[index];
|
||||
else
|
||||
return tr("Unknown");
|
||||
return CPN_STR_UNKNOWN_ITEM;
|
||||
}
|
||||
|
||||
QString Boards::getAnalogInputName(Board::Type board, int index)
|
||||
@@ -595,6 +600,96 @@ QString Boards::getBoardName(Board::Type board)
|
||||
case BOARD_RADIOMASTER_T8:
|
||||
return "Radiomaster T8";
|
||||
default:
|
||||
return tr("Unknown");
|
||||
return CPN_STR_UNKNOWN_ITEM;
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
QString Boards::potTypeToString(int value)
|
||||
{
|
||||
switch(value) {
|
||||
case POT_NONE:
|
||||
return tr("None");
|
||||
case POT_WITH_DETENT:
|
||||
return tr("Pot with detent");
|
||||
case POT_MULTIPOS_SWITCH:
|
||||
return tr("Multi pos switch");
|
||||
case POT_WITHOUT_DETENT:
|
||||
return tr("Pot without detent");
|
||||
default:
|
||||
return CPN_STR_UNKNOWN_ITEM;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// static
|
||||
QString Boards::sliderTypeToString(int value)
|
||||
{
|
||||
switch(value) {
|
||||
case SLIDER_NONE:
|
||||
return tr("None");
|
||||
case SLIDER_WITH_DETENT:
|
||||
return tr("Slider with detent");
|
||||
default:
|
||||
return CPN_STR_UNKNOWN_ITEM;
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
QString Boards::switchTypeToString(int value)
|
||||
{
|
||||
switch(value) {
|
||||
case SWITCH_NOT_AVAILABLE:
|
||||
return tr("None");
|
||||
case SWITCH_TOGGLE:
|
||||
return tr("2 Positions Toggle");
|
||||
case SWITCH_2POS:
|
||||
return tr("2 Positions");
|
||||
case SWITCH_3POS:
|
||||
return tr("3 Positions");
|
||||
default:
|
||||
return CPN_STR_UNKNOWN_ITEM;
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
AbstractStaticItemModel * Boards::potTypeItemModel()
|
||||
{
|
||||
AbstractStaticItemModel * mdl = new AbstractStaticItemModel();
|
||||
mdl->setName(AIM_BOARDS_POT_TYPE);
|
||||
|
||||
for (int i = 0; i < POT_TYPE_COUNT; i++) {
|
||||
mdl->appendToItemList(potTypeToString(i), i);
|
||||
}
|
||||
|
||||
mdl->loadItemList();
|
||||
return mdl;
|
||||
}
|
||||
|
||||
// static
|
||||
AbstractStaticItemModel * Boards::sliderTypeItemModel()
|
||||
{
|
||||
AbstractStaticItemModel * mdl = new AbstractStaticItemModel();
|
||||
mdl->setName(AIM_BOARDS_SLIDER_TYPE);
|
||||
|
||||
for (int i = 0; i < SLIDER_TYPE_COUNT; i++) {
|
||||
mdl->appendToItemList(sliderTypeToString(i), i);
|
||||
}
|
||||
|
||||
mdl->loadItemList();
|
||||
return mdl;
|
||||
}
|
||||
|
||||
// static
|
||||
AbstractStaticItemModel * Boards::switchTypeItemModel()
|
||||
{
|
||||
AbstractStaticItemModel * mdl = new AbstractStaticItemModel();
|
||||
mdl->setName(AIM_BOARDS_SWITCH_TYPE);
|
||||
|
||||
for (int i = 0; i < SWITCH_TYPE_COUNT; i++) {
|
||||
mdl->appendToItemList(switchTypeToString(i), i, true, 0, (i < SWITCH_3POS ? SwitchTypeFlag2Pos : SwitchTypeFlag3Pos));
|
||||
}
|
||||
|
||||
mdl->loadItemList();
|
||||
return mdl;
|
||||
}
|
||||
|
||||
@@ -18,13 +18,19 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef _BOARDS_H_
|
||||
#define _BOARDS_H_
|
||||
#pragma once
|
||||
|
||||
#include <QtCore>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
class AbstractStaticItemModel;
|
||||
|
||||
// identiying names of static abstract item models
|
||||
constexpr char AIM_BOARDS_POT_TYPE[] {"boards.pottype"};
|
||||
constexpr char AIM_BOARDS_SLIDER_TYPE[] {"boards.slidertype"};
|
||||
constexpr char AIM_BOARDS_SWITCH_TYPE[] {"boards.switchtype"};
|
||||
|
||||
// TODO create a Board class with all these functions
|
||||
|
||||
namespace Board {
|
||||
@@ -64,13 +70,15 @@ namespace Board {
|
||||
POT_NONE,
|
||||
POT_WITH_DETENT,
|
||||
POT_MULTIPOS_SWITCH,
|
||||
POT_WITHOUT_DETENT
|
||||
POT_WITHOUT_DETENT,
|
||||
POT_TYPE_COUNT
|
||||
};
|
||||
|
||||
enum SliderType
|
||||
{
|
||||
SLIDER_NONE,
|
||||
SLIDER_WITH_DETENT
|
||||
SLIDER_WITH_DETENT,
|
||||
SLIDER_TYPE_COUNT
|
||||
};
|
||||
|
||||
enum SwitchType
|
||||
@@ -78,7 +86,8 @@ namespace Board {
|
||||
SWITCH_NOT_AVAILABLE,
|
||||
SWITCH_TOGGLE,
|
||||
SWITCH_2POS,
|
||||
SWITCH_3POS
|
||||
SWITCH_3POS,
|
||||
SWITCH_TYPE_COUNT
|
||||
};
|
||||
|
||||
enum StickAxes {
|
||||
@@ -130,7 +139,8 @@ namespace Board {
|
||||
SwitchPositions,
|
||||
FactoryInstalledSwitches,
|
||||
NumTrims,
|
||||
NumTrimSwitches
|
||||
NumTrimSwitches,
|
||||
HasRTC
|
||||
};
|
||||
|
||||
struct SwitchInfo
|
||||
@@ -149,6 +159,13 @@ namespace Board {
|
||||
unsigned int position;
|
||||
};
|
||||
|
||||
enum SwitchTypeMasks {
|
||||
SwitchTypeFlag2Pos = 0x01,
|
||||
SwitchTypeFlag3Pos = 0x02,
|
||||
SwitchTypeContext2Pos = SwitchTypeFlag2Pos,
|
||||
SwitchTypeContext3Pos = SwitchTypeFlag2Pos | SwitchTypeFlag3Pos
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
class Boards
|
||||
@@ -182,6 +199,12 @@ class Boards
|
||||
static QString getAnalogInputName(Board::Type board, int index);
|
||||
static bool isBoardCompatible(Board::Type board1, Board::Type board2);
|
||||
static QString getBoardName(Board::Type board);
|
||||
static QString potTypeToString(int value);
|
||||
static QString sliderTypeToString(int value);
|
||||
static QString switchTypeToString(int value);
|
||||
static AbstractStaticItemModel * potTypeItemModel();
|
||||
static AbstractStaticItemModel * sliderTypeItemModel();
|
||||
static AbstractStaticItemModel * switchTypeItemModel();
|
||||
|
||||
protected:
|
||||
|
||||
@@ -361,5 +384,3 @@ inline bool IS_ACCESS_RADIO(Board::Type board, const QString & id)
|
||||
return (IS_TARANIS_XLITES(board) || IS_TARANIS_X9LITE(board) || board == Board::BOARD_TARANIS_X9DP_2019 || board == Board::BOARD_X10_EXPRESS || IS_TARANIS_X7_ACCESS(board) ||
|
||||
(IS_FAMILY_HORUS_OR_T16(board) && id.contains("internalaccess")));
|
||||
}
|
||||
|
||||
#endif // _BOARDS_H_
|
||||
|
||||
@@ -134,7 +134,6 @@ enum Capability {
|
||||
VirtualInputs,
|
||||
InputsLength,
|
||||
TrainerInputs,
|
||||
RtcTime,
|
||||
SportTelemetry,
|
||||
LuaScripts,
|
||||
LuaInputsPerScript,
|
||||
@@ -153,7 +152,13 @@ enum Capability {
|
||||
HasSwitchableJack,
|
||||
HasSportConnector,
|
||||
PwrButtonPress,
|
||||
Sensors
|
||||
Sensors,
|
||||
HasAuxSerialMode,
|
||||
HasAux2SerialMode,
|
||||
HasBluetooth,
|
||||
HasAntennaChoice,
|
||||
HasADCJitterFilter,
|
||||
HasTelemetryBaudrate
|
||||
};
|
||||
|
||||
class EEPROMInterface
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "appdata.h"
|
||||
#include "eeprominterface.h"
|
||||
#include "radiodataconversionstate.h"
|
||||
#include "compounditemmodels.h"
|
||||
|
||||
const uint8_t chout_ar[] = { // 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,
|
||||
@@ -36,7 +37,7 @@ bool GeneralSettings::switchPositionAllowedTaranis(int index) const
|
||||
if (index == 0)
|
||||
return true;
|
||||
|
||||
div_t qr = div(abs(index)-1, 3);
|
||||
div_t qr = div(abs(index) - 1, 3);
|
||||
|
||||
if (index < 0 && switchConfig[qr.quot] != Board::SWITCH_3POS)
|
||||
return false;
|
||||
@@ -53,14 +54,14 @@ bool GeneralSettings::switchSourceAllowedTaranis(int index) const
|
||||
|
||||
bool GeneralSettings::isPotAvailable(int index) const
|
||||
{
|
||||
if (index < 0 || index > getBoardCapability(getCurrentBoard(), Board::Pots))
|
||||
if (index < 0 || index > Boards::getCapability(getCurrentBoard(), Board::Pots))
|
||||
return false;
|
||||
return potConfig[index] != Board::POT_NONE;
|
||||
}
|
||||
|
||||
bool GeneralSettings::isSliderAvailable(int index) const
|
||||
{
|
||||
if (index < 0 || index > getBoardCapability(getCurrentBoard(), Board::Sliders))
|
||||
if (index < 0 || index > Boards::getCapability(getCurrentBoard(), Board::Sliders))
|
||||
return false;
|
||||
return sliderConfig[index] != Board::SLIDER_NONE;
|
||||
}
|
||||
@@ -71,7 +72,7 @@ GeneralSettings::GeneralSettings()
|
||||
|
||||
contrast = 25;
|
||||
|
||||
for (int i=0; i < CPN_MAX_ANALOGS; ++i) {
|
||||
for (int i = 0; i < CPN_MAX_ANALOGS; ++i) {
|
||||
calibMid[i] = 0x200;
|
||||
calibSpanNeg[i] = 0x180;
|
||||
calibSpanPos[i] = 0x180;
|
||||
@@ -128,7 +129,7 @@ GeneralSettings::GeneralSettings()
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < 4; i++) {
|
||||
trainer.mix[i].mode = 2; // replace (:=)
|
||||
trainer.mix[i].mode = TrainerMix::TRN_MIX_MODE_SUBST;
|
||||
trainer.mix[i].src = i;
|
||||
trainer.mix[i].weight = 100;
|
||||
}
|
||||
@@ -387,3 +388,265 @@ void GeneralSettings::convert(RadioDataConversionState & cstate)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QString GeneralSettings::antennaModeToString() const
|
||||
{
|
||||
return antennaModeToString(antennaMode);
|
||||
}
|
||||
|
||||
QString GeneralSettings::bluetoothModeToString() const
|
||||
{
|
||||
return bluetoothModeToString(bluetoothMode);
|
||||
}
|
||||
|
||||
QString GeneralSettings::auxSerialModeToString() const
|
||||
{
|
||||
return auxSerialModeToString(auxSerialMode);
|
||||
}
|
||||
|
||||
QString GeneralSettings::telemetryBaudrateToString() const
|
||||
{
|
||||
return telemetryBaudrateToString(telemetryBaudrate);
|
||||
}
|
||||
|
||||
// static
|
||||
QString GeneralSettings::antennaModeToString(int value)
|
||||
{
|
||||
Board::Type board = getCurrentBoard();
|
||||
|
||||
switch(value) {
|
||||
case ANTENNA_MODE_INTERNAL:
|
||||
return tr("Internal");
|
||||
case ANTENNA_MODE_ASK:
|
||||
return tr("Ask");
|
||||
case ANTENNA_MODE_PER_MODEL:
|
||||
return tr("Per model");
|
||||
case ANTENNA_MODE_EXTERNAL:
|
||||
// case ANTENNA_MODE_INTERNAL_EXTERNAL:
|
||||
return IS_HORUS_X12S(board) ? tr("Internal + External") : tr("External");
|
||||
default:
|
||||
return CPN_STR_UNKNOWN_ITEM;
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
QString GeneralSettings::bluetoothModeToString(int value)
|
||||
{
|
||||
Board::Type board = getCurrentBoard();
|
||||
|
||||
switch(value) {
|
||||
case BLUETOOTH_MODE_OFF:
|
||||
return tr("OFF");
|
||||
case BLUETOOTH_MODE_ENABLED:
|
||||
// case BLUETOOTH_MODE_TELEMETRY:
|
||||
return IS_TARANIS_X9E(board) ? tr("Enabled") : tr("Telemetry");
|
||||
case BLUETOOTH_MODE_TRAINER:
|
||||
return tr("Trainer");
|
||||
default:
|
||||
return CPN_STR_UNKNOWN_ITEM;
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
QString GeneralSettings::auxSerialModeToString(int value)
|
||||
{
|
||||
switch(value) {
|
||||
case AUX_SERIAL_OFF:
|
||||
return tr("OFF");
|
||||
case AUX_SERIAL_TELE_MIRROR:
|
||||
return tr("Telemetry Mirror");
|
||||
case AUX_SERIAL_TELE_IN:
|
||||
return tr("Telemetry In");
|
||||
case AUX_SERIAL_SBUS_TRAINER:
|
||||
return tr("SBUS Trainer");
|
||||
case AUX_SERIAL_LUA:
|
||||
return tr("LUA");
|
||||
default:
|
||||
return CPN_STR_UNKNOWN_ITEM;
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
QString GeneralSettings::telemetryBaudrateToString(int value)
|
||||
{
|
||||
switch(value) {
|
||||
case 0:
|
||||
return "400000";
|
||||
case 1:
|
||||
return "115200";
|
||||
default:
|
||||
return CPN_STR_UNKNOWN_ITEM;
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
FieldRange GeneralSettings::getPPM_MultiplierRange()
|
||||
{
|
||||
FieldRange result;
|
||||
|
||||
result.min = 0;
|
||||
result.max = 5;
|
||||
result.decimals = 1;
|
||||
result.step = 0.1;
|
||||
result.offset = 10;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// static
|
||||
FieldRange GeneralSettings::getTxVoltageCalibrationRange()
|
||||
{
|
||||
FieldRange result;
|
||||
|
||||
result.decimals = 1;
|
||||
result.max = 9.9;
|
||||
result.min = -result.max;
|
||||
result.step = 0.1;
|
||||
result.unit = tr("v");
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// static
|
||||
FieldRange GeneralSettings::getTxCurrentCalibration()
|
||||
{
|
||||
FieldRange result;
|
||||
|
||||
result.max = 49;
|
||||
result.min = -result.max;
|
||||
result.unit = tr("mA");
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// static
|
||||
AbstractStaticItemModel * GeneralSettings::antennaModeItemModel()
|
||||
{
|
||||
AbstractStaticItemModel * mdl = new AbstractStaticItemModel();
|
||||
mdl->setName(AIM_GS_ANTENNAMODE);
|
||||
|
||||
for (int i = ANTENNA_MODE_FIRST; i <= ANTENNA_MODE_LAST; i++) {
|
||||
mdl->appendToItemList(antennaModeToString(i), i);
|
||||
}
|
||||
|
||||
mdl->loadItemList();
|
||||
return mdl;
|
||||
}
|
||||
|
||||
// static
|
||||
AbstractStaticItemModel * GeneralSettings::bluetoothModeItemModel()
|
||||
{
|
||||
AbstractStaticItemModel * mdl = new AbstractStaticItemModel();
|
||||
mdl->setName(AIM_GS_BLUETOOTHMODE);
|
||||
|
||||
for (int i = 0; i < BLUETOOTH_MODE_COUNT; i++) {
|
||||
mdl->appendToItemList(bluetoothModeToString(i), i);
|
||||
}
|
||||
|
||||
mdl->loadItemList();
|
||||
return mdl;
|
||||
}
|
||||
|
||||
// static
|
||||
AbstractStaticItemModel * GeneralSettings::auxSerialModeItemModel()
|
||||
{
|
||||
AbstractStaticItemModel * mdl = new AbstractStaticItemModel();
|
||||
mdl->setName(AIM_GS_AUXSERIALMODE);
|
||||
|
||||
for (int i = 0; i < AUX_SERIAL_COUNT; i++) {
|
||||
mdl->appendToItemList(auxSerialModeToString(i), i);
|
||||
}
|
||||
|
||||
mdl->loadItemList();
|
||||
return mdl;
|
||||
}
|
||||
|
||||
// static
|
||||
AbstractStaticItemModel * GeneralSettings::telemetryBaudrateItemModel()
|
||||
{
|
||||
AbstractStaticItemModel * mdl = new AbstractStaticItemModel();
|
||||
mdl->setName(AIM_GS_TELEMETRYBAUDRATE);
|
||||
|
||||
for (int i = 0; i <= 1; i++) {
|
||||
mdl->appendToItemList(telemetryBaudrateToString(i), i);
|
||||
}
|
||||
|
||||
mdl->loadItemList();
|
||||
return mdl;
|
||||
}
|
||||
|
||||
/*
|
||||
TrainerMix
|
||||
*/
|
||||
|
||||
QString TrainerMix::modeToString() const
|
||||
{
|
||||
return modeToString(mode);
|
||||
}
|
||||
|
||||
QString TrainerMix::srcToString() const
|
||||
{
|
||||
return srcToString(src);
|
||||
}
|
||||
|
||||
// static
|
||||
FieldRange TrainerMix::getWeightRange()
|
||||
{
|
||||
FieldRange result;
|
||||
|
||||
result.decimals = 0;
|
||||
result.max = 125;
|
||||
result.min = -result.max;
|
||||
result.step = 1;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// static
|
||||
QString TrainerMix::modeToString(int value)
|
||||
{
|
||||
switch(value) {
|
||||
case TRN_MIX_MODE_OFF:
|
||||
return tr("OFF");
|
||||
case TRN_MIX_MODE_ADD:
|
||||
return tr("+= (Sum)");
|
||||
case TRN_MIX_MODE_SUBST:
|
||||
return tr(":= (Replace)");
|
||||
default:
|
||||
return CPN_STR_UNKNOWN_ITEM;
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
QString TrainerMix::srcToString(int value)
|
||||
{
|
||||
return tr("CH%1").arg(value + 1);
|
||||
}
|
||||
|
||||
// static
|
||||
AbstractStaticItemModel * TrainerMix::modeItemModel()
|
||||
{
|
||||
AbstractStaticItemModel * mdl = new AbstractStaticItemModel();
|
||||
mdl->setName(AIM_TRAINERMIX_MODE);
|
||||
|
||||
for (int i = 0; i < TRN_MIX_MODE_COUNT; i++) {
|
||||
mdl->appendToItemList(modeToString(i), i);
|
||||
}
|
||||
|
||||
mdl->loadItemList();
|
||||
return mdl;
|
||||
}
|
||||
|
||||
// static
|
||||
AbstractStaticItemModel * TrainerMix::srcItemModel()
|
||||
{
|
||||
AbstractStaticItemModel * mdl = new AbstractStaticItemModel();
|
||||
mdl->setName(AIM_TRAINERMIX_SRC);
|
||||
|
||||
for (int i = 0; i < Boards::getCapability(getCurrentBoard(), Board::Sticks); i++) {
|
||||
mdl->appendToItemList(srcToString(i), i);
|
||||
}
|
||||
|
||||
mdl->loadItemList();
|
||||
return mdl;
|
||||
}
|
||||
|
||||
@@ -18,13 +18,13 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef GENERALSETTINGS_H
|
||||
#define GENERALSETTINGS_H
|
||||
#pragma once
|
||||
|
||||
#include "boards.h"
|
||||
#include "constants.h"
|
||||
#include "customfunctiondata.h"
|
||||
#include "rawsource.h"
|
||||
#include "datahelpers.h"
|
||||
|
||||
#include <QtCore>
|
||||
|
||||
@@ -32,6 +32,15 @@ class Firmware;
|
||||
class ModelData;
|
||||
class GeneralSettings;
|
||||
class RadioDataConversionState;
|
||||
class AbstractStaticItemModel;
|
||||
|
||||
// identiying names of static abstract item models
|
||||
constexpr char AIM_GS_ANTENNAMODE[] {"gs.antennamode"};
|
||||
constexpr char AIM_GS_BLUETOOTHMODE[] {"gs.bluetoothmode"};
|
||||
constexpr char AIM_GS_AUXSERIALMODE[] {"gs.auxserialmode"};
|
||||
constexpr char AIM_GS_TELEMETRYBAUDRATE[] {"gs.telemetrybaudrate"};
|
||||
constexpr char AIM_TRAINERMIX_MODE[] {"trainermix.mode"};
|
||||
constexpr char AIM_TRAINERMIX_SRC[] {"trainermix.src"};
|
||||
|
||||
enum UartModes {
|
||||
UART_MODE_NONE,
|
||||
@@ -42,23 +51,52 @@ enum UartModes {
|
||||
};
|
||||
|
||||
class TrainerMix {
|
||||
Q_DECLARE_TR_FUNCTIONS(TrainerMix)
|
||||
|
||||
public:
|
||||
enum TrainerMixModes {
|
||||
TRN_MIX_MODE_OFF,
|
||||
TRN_MIX_MODE_ADD,
|
||||
TRN_MIX_MODE_SUBST,
|
||||
TRN_MIX_MODE_COUNT
|
||||
};
|
||||
|
||||
TrainerMix() { clear(); }
|
||||
|
||||
unsigned int src; // 0-7 = ch1-8
|
||||
RawSwitch swtch;
|
||||
int weight;
|
||||
unsigned int mode; // off, add-mode, subst-mode
|
||||
|
||||
void clear() { memset(reinterpret_cast<void *>(this), 0, sizeof(TrainerMix)); }
|
||||
QString modeToString() const;
|
||||
QString srcToString() const;
|
||||
|
||||
static FieldRange getWeightRange();
|
||||
static QString modeToString(int value);
|
||||
static QString srcToString(int value);
|
||||
static AbstractStaticItemModel * modeItemModel();
|
||||
static AbstractStaticItemModel * srcItemModel();
|
||||
};
|
||||
|
||||
class TrainerData {
|
||||
public:
|
||||
TrainerData() { clear(); }
|
||||
int calib[4];
|
||||
TrainerMix mix[4];
|
||||
|
||||
int calib[4];
|
||||
TrainerMix mix[4];
|
||||
|
||||
void clear() { memset(reinterpret_cast<void *>(this), 0, sizeof(TrainerData)); }
|
||||
};
|
||||
|
||||
constexpr int CURR_MODEL_FILENAME_LEN {16};
|
||||
constexpr int OWNER_NAME_LEN {10};
|
||||
constexpr int BLUETOOTH_NAME_LEN {10};
|
||||
constexpr int TTS_LANGUAGE_LEN {2};
|
||||
constexpr int HARDWARE_NAME_LEN {3};
|
||||
constexpr int THEME_NAME_LEN {8};
|
||||
constexpr int REGISTRATION_ID_LEN {8};
|
||||
|
||||
class GeneralSettings {
|
||||
Q_DECLARE_TR_FUNCTIONS(GeneralSettings)
|
||||
|
||||
@@ -71,6 +109,36 @@ class GeneralSettings {
|
||||
BEEPER_ALL = 1
|
||||
};
|
||||
|
||||
enum BluetoothMode {
|
||||
BLUETOOTH_MODE_OFF,
|
||||
BLUETOOTH_MODE_ENABLED,
|
||||
BLUETOOTH_MODE_TELEMETRY = BLUETOOTH_MODE_ENABLED,
|
||||
BLUETOOTH_MODE_TRAINER,
|
||||
BLUETOOTH_MODE_COUNT
|
||||
};
|
||||
|
||||
enum AntennaMode {
|
||||
ANTENNA_MODE_INTERNAL = -2,
|
||||
ANTENNA_MODE_FIRST = ANTENNA_MODE_INTERNAL,
|
||||
ANTENNA_MODE_ASK,
|
||||
ANTENNA_MODE_PER_MODEL,
|
||||
ANTENNA_MODE_EXTERNAL,
|
||||
ANTENNA_MODE_INTERNAL_EXTERNAL = ANTENNA_MODE_EXTERNAL,
|
||||
ANTENNA_MODE_LAST = ANTENNA_MODE_INTERNAL_EXTERNAL
|
||||
};
|
||||
|
||||
enum AuxSerialMode {
|
||||
AUX_SERIAL_OFF,
|
||||
AUX_SERIAL_TELE_MIRROR,
|
||||
AUX_SERIAL_TELE_IN,
|
||||
AUX_SERIAL_SBUS_TRAINER,
|
||||
AUX_SERIAL_LUA,
|
||||
AUX_SERIAL_COUNT
|
||||
};
|
||||
|
||||
enum TelemetryBaudrate {
|
||||
};
|
||||
|
||||
GeneralSettings();
|
||||
void convert(RadioDataConversionState & cstate);
|
||||
|
||||
@@ -81,61 +149,61 @@ class GeneralSettings {
|
||||
|
||||
unsigned int version;
|
||||
unsigned int variant;
|
||||
int calibMid[CPN_MAX_ANALOGS];
|
||||
int calibSpanNeg[CPN_MAX_ANALOGS];
|
||||
int calibSpanPos[CPN_MAX_ANALOGS];
|
||||
unsigned int currModelIndex;
|
||||
char currModelFilename[16+1];
|
||||
unsigned int contrast;
|
||||
unsigned int vBatWarn;
|
||||
int txVoltageCalibration;
|
||||
int txCurrentCalibration;
|
||||
int vBatMin;
|
||||
int vBatMax;
|
||||
int backlightMode;
|
||||
int calibMid[CPN_MAX_ANALOGS];
|
||||
int calibSpanNeg[CPN_MAX_ANALOGS];
|
||||
int calibSpanPos[CPN_MAX_ANALOGS];
|
||||
unsigned int currModelIndex;
|
||||
char currModelFilename[CURR_MODEL_FILENAME_LEN + 1];
|
||||
unsigned int contrast;
|
||||
unsigned int vBatWarn;
|
||||
int txVoltageCalibration;
|
||||
int txCurrentCalibration;
|
||||
int vBatMin;
|
||||
int vBatMax;
|
||||
int backlightMode;
|
||||
TrainerData trainer;
|
||||
unsigned int view; // main screen view // TODO enum
|
||||
bool disableThrottleWarning;
|
||||
bool fai;
|
||||
bool disableMemoryWarning;
|
||||
unsigned int view; // main screen view // TODO enum
|
||||
bool disableThrottleWarning;
|
||||
bool fai;
|
||||
bool disableMemoryWarning;
|
||||
BeeperMode beeperMode;
|
||||
bool disableAlarmWarning;
|
||||
bool disableRssiPoweroffAlarm;
|
||||
unsigned int usbMode;
|
||||
unsigned int jackMode;
|
||||
bool sportPower;
|
||||
bool disableAlarmWarning;
|
||||
bool disableRssiPoweroffAlarm;
|
||||
unsigned int usbMode;
|
||||
unsigned int jackMode;
|
||||
bool sportPower;
|
||||
BeeperMode hapticMode;
|
||||
unsigned int stickMode; // TODO enum
|
||||
int timezone;
|
||||
bool adjustRTC;
|
||||
bool optrexDisplay;
|
||||
unsigned int inactivityTimer;
|
||||
unsigned int telemetryBaudrate;
|
||||
bool minuteBeep;
|
||||
bool preBeep;
|
||||
bool flashBeep;
|
||||
unsigned int splashMode;
|
||||
unsigned int stickMode; // TODO enum
|
||||
int timezone;
|
||||
bool adjustRTC;
|
||||
bool optrexDisplay;
|
||||
unsigned int inactivityTimer;
|
||||
unsigned int telemetryBaudrate;
|
||||
bool minuteBeep;
|
||||
bool preBeep;
|
||||
bool flashBeep;
|
||||
unsigned int splashMode;
|
||||
int splashDuration;
|
||||
unsigned int backlightDelay;
|
||||
unsigned int templateSetup; //RETA order according to chout_ar array
|
||||
int PPM_Multiplier;
|
||||
int hapticLength;
|
||||
unsigned int reNavigation;
|
||||
unsigned int backlightDelay;
|
||||
unsigned int templateSetup; //RETA order according to chout_ar array
|
||||
int PPM_Multiplier;
|
||||
int hapticLength;
|
||||
unsigned int reNavigation;
|
||||
unsigned int stickReverse;
|
||||
unsigned int speakerPitch;
|
||||
int hapticStrength;
|
||||
unsigned int speakerMode;
|
||||
char ownerName[10+1];
|
||||
int beeperLength;
|
||||
unsigned int gpsFormat;
|
||||
int speakerVolume;
|
||||
unsigned int backlightBright;
|
||||
unsigned int backlightOffBright;
|
||||
unsigned int speakerPitch;
|
||||
int hapticStrength;
|
||||
unsigned int speakerMode;
|
||||
char ownerName[OWNER_NAME_LEN + 1];
|
||||
int beeperLength;
|
||||
unsigned int gpsFormat;
|
||||
int speakerVolume;
|
||||
unsigned int backlightBright;
|
||||
unsigned int backlightOffBright;
|
||||
int switchesDelay;
|
||||
unsigned int mAhWarn;
|
||||
unsigned int mAhUsed;
|
||||
unsigned int globalTimer;
|
||||
char bluetoothName[10+1];
|
||||
char bluetoothName[BLUETOOTH_NAME_LEN + 1];
|
||||
unsigned int bluetoothBaudrate;
|
||||
unsigned int bluetoothMode;
|
||||
unsigned int sticksGain;
|
||||
@@ -145,7 +213,7 @@ class GeneralSettings {
|
||||
bool rtcCheckDisable;
|
||||
bool keysBacklight;
|
||||
unsigned int imperial;
|
||||
char ttsLanguage[2+1];
|
||||
char ttsLanguage[TTS_LANGUAGE_LEN + 1];
|
||||
int beepVolume;
|
||||
int wavVolume;
|
||||
int varioVolume;
|
||||
@@ -156,33 +224,47 @@ class GeneralSettings {
|
||||
unsigned int mavbaud;
|
||||
unsigned int switchUnlockStates;
|
||||
unsigned int auxSerialMode;
|
||||
unsigned int aux2SerialMode;
|
||||
int antennaMode;
|
||||
unsigned int backlightColor;
|
||||
CustomFunctionData customFn[CPN_MAX_SPECIAL_FUNCTIONS];
|
||||
char switchName[CPN_MAX_SWITCHES][3+1];
|
||||
char switchName[CPN_MAX_SWITCHES][HARDWARE_NAME_LEN + 1];
|
||||
unsigned int switchConfig[CPN_MAX_SWITCHES];
|
||||
char stickName[CPN_MAX_STICKS][3+1];
|
||||
char potName[CPN_MAX_KNOBS][3+1];
|
||||
char stickName[CPN_MAX_STICKS][HARDWARE_NAME_LEN + 1];
|
||||
char potName[CPN_MAX_KNOBS][HARDWARE_NAME_LEN + 1];
|
||||
unsigned int potConfig[CPN_MAX_KNOBS];
|
||||
char sliderName[CPN_MAX_SLIDERS][3+1];
|
||||
char sliderName[CPN_MAX_SLIDERS][HARDWARE_NAME_LEN + 1];
|
||||
unsigned int sliderConfig[CPN_MAX_SLIDERS];
|
||||
|
||||
char themeName[8+1];
|
||||
typedef uint8_t ThemeOptionData[8+1];
|
||||
char themeName[THEME_NAME_LEN + 1];
|
||||
typedef uint8_t ThemeOptionData[8 + 1];
|
||||
ThemeOptionData themeOptionValue[5];
|
||||
|
||||
char registrationId[8+1];
|
||||
|
||||
char registrationId[REGISTRATION_ID_LEN + 1];
|
||||
int gyroMax;
|
||||
int gyroOffset;
|
||||
|
||||
int pwrOnSpeed;
|
||||
int pwrOffSpeed;
|
||||
|
||||
|
||||
bool switchPositionAllowedTaranis(int index) const;
|
||||
bool switchSourceAllowedTaranis(int index) const;
|
||||
bool isPotAvailable(int index) const;
|
||||
bool isSliderAvailable(int index) const;
|
||||
QString antennaModeToString() const;
|
||||
QString bluetoothModeToString() const;
|
||||
QString auxSerialModeToString() const;
|
||||
QString telemetryBaudrateToString() const;
|
||||
|
||||
static QString antennaModeToString(int value);
|
||||
static QString bluetoothModeToString(int value);
|
||||
static QString auxSerialModeToString(int value);
|
||||
static QString telemetryBaudrateToString(int value);
|
||||
static FieldRange getPPM_MultiplierRange();
|
||||
static FieldRange getTxVoltageCalibrationRange();
|
||||
static FieldRange getTxCurrentCalibration();
|
||||
static AbstractStaticItemModel * antennaModeItemModel();
|
||||
static AbstractStaticItemModel * bluetoothModeItemModel();
|
||||
static AbstractStaticItemModel * auxSerialModeItemModel();
|
||||
static AbstractStaticItemModel * telemetryBaudrateItemModel();
|
||||
};
|
||||
|
||||
|
||||
#endif // GENERALSETTINGS_H
|
||||
|
||||
@@ -2760,7 +2760,7 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, Board::Type
|
||||
if (version >= 218) {
|
||||
internalField.Append(new UnsignedField<4>(this, generalData.auxSerialMode));
|
||||
if (IS_FAMILY_HORUS_OR_T16(board) && version >= 219) {
|
||||
internalField.Append(new SpareBitsField<4>(this));
|
||||
internalField.Append(new UnsignedField<4>(this, generalData.aux2SerialMode));
|
||||
}
|
||||
else {
|
||||
for (uint8_t i=0; i<SLIDERS_CONFIG_SIZE(board,version); i++) {
|
||||
|
||||
@@ -663,8 +663,6 @@ int OpenTxFirmware::getCapability(::Capability capability)
|
||||
return HAS_LARGE_LCD(board) ? 4 : 3;
|
||||
case TrainerInputs:
|
||||
return 16;
|
||||
case RtcTime:
|
||||
return 1;
|
||||
case LuaScripts:
|
||||
return IS_HORUS_OR_TARANIS(board) && id.contains("lua") ? 7 : 0;
|
||||
case LuaInputsPerScript:
|
||||
@@ -725,6 +723,19 @@ int OpenTxFirmware::getCapability(::Capability capability)
|
||||
return 60;
|
||||
else
|
||||
return 40;
|
||||
case HasAuxSerialMode:
|
||||
return (IS_FAMILY_HORUS_OR_T16(board) && !IS_TARANIS_SMALL(board)) ? true : false;
|
||||
case HasAux2SerialMode:
|
||||
return (IS_FAMILY_HORUS_OR_T16(board) && !IS_TARANIS_SMALL(board)) ? true : false;
|
||||
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)) ? true : false;
|
||||
case HasAntennaChoice:
|
||||
return ((IS_FAMILY_HORUS_OR_T16(board) && board != Board::BOARD_X10_EXPRESS) || (IS_TARANIS_XLITE(board) && !IS_TARANIS_XLITES(board))) ? true : false;
|
||||
case HasADCJitterFilter:
|
||||
return IS_HORUS_OR_TARANIS(board) ? true : false;
|
||||
case HasTelemetryBaudrate:
|
||||
return IS_HORUS_OR_TARANIS(board) ? true : false;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user