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
+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);