mirror of
https://github.com/opentx/opentx.git
synced 2025-07-26 01:35:21 +03:00
parent
f5ab145d2f
commit
c9df941ee6
8 changed files with 136 additions and 35 deletions
|
@ -30,10 +30,10 @@
|
||||||
#define CPN_MAX_CURVES 32
|
#define CPN_MAX_CURVES 32
|
||||||
#define CPN_MAX_POINTS 17
|
#define CPN_MAX_POINTS 17
|
||||||
#define CPN_MAX_GVARS 9
|
#define CPN_MAX_GVARS 9
|
||||||
#define CPN_MAX_ENCODERS 2 // rotary encoders
|
#define CPN_MAX_ENCODERS 2 // rotary encoders
|
||||||
#define CPN_MAX_CHNOUT 32 // number of real output channels
|
#define CPN_MAX_CHNOUT 32 // number of real output channels
|
||||||
#define CPN_MAX_CSW 64 // number of custom switches
|
#define CPN_MAX_LOGICAL_SWITCHES 64 // number of custom switches
|
||||||
#define CPN_MAX_CUSTOM_FUNCTIONS 64 // number of functions assigned to switches
|
#define CPN_MAX_SPECIAL_FUNCTIONS 64 // number of functions assigned to switches
|
||||||
#define CPN_MAX_MODULES 2
|
#define CPN_MAX_MODULES 2
|
||||||
#define CPN_MAX_STICKS Board::STICK_AXIS_COUNT
|
#define CPN_MAX_STICKS Board::STICK_AXIS_COUNT
|
||||||
#define CPN_MAX_TRIMS Board::TRIM_AXIS_COUNT
|
#define CPN_MAX_TRIMS Board::TRIM_AXIS_COUNT
|
||||||
|
|
|
@ -1528,9 +1528,9 @@ void ModelData::clear()
|
||||||
limitData[i].clear();
|
limitData[i].clear();
|
||||||
for (int i=0; i<CPN_MAX_STICKS; i++)
|
for (int i=0; i<CPN_MAX_STICKS; i++)
|
||||||
expoData[i].clear();
|
expoData[i].clear();
|
||||||
for (int i=0; i<CPN_MAX_CSW; i++)
|
for (int i=0; i<CPN_MAX_LOGICAL_SWITCHES; i++)
|
||||||
logicalSw[i].clear();
|
logicalSw[i].clear();
|
||||||
for (int i=0; i<CPN_MAX_CUSTOM_FUNCTIONS; i++)
|
for (int i=0; i<CPN_MAX_SPECIAL_FUNCTIONS; i++)
|
||||||
customFn[i].clear();
|
customFn[i].clear();
|
||||||
for (int i=0; i<CPN_MAX_CURVES; i++)
|
for (int i=0; i<CPN_MAX_CURVES; i++)
|
||||||
curves[i].clear(5);
|
curves[i].clear(5);
|
||||||
|
|
|
@ -81,18 +81,18 @@ class CustomFunctionsPanel : public GenericPanel
|
||||||
QSet<QString> tracksSet;
|
QSet<QString> tracksSet;
|
||||||
QSet<QString> scriptsSet;
|
QSet<QString> scriptsSet;
|
||||||
int mediaPlayerCurrent;
|
int mediaPlayerCurrent;
|
||||||
QComboBox * fswtchSwtch[CPN_MAX_CUSTOM_FUNCTIONS];
|
QComboBox * fswtchSwtch[CPN_MAX_SPECIAL_FUNCTIONS];
|
||||||
QComboBox * fswtchFunc[CPN_MAX_CUSTOM_FUNCTIONS];
|
QComboBox * fswtchFunc[CPN_MAX_SPECIAL_FUNCTIONS];
|
||||||
QCheckBox * fswtchParamGV[CPN_MAX_CUSTOM_FUNCTIONS];
|
QCheckBox * fswtchParamGV[CPN_MAX_SPECIAL_FUNCTIONS];
|
||||||
QDoubleSpinBox * fswtchParam[CPN_MAX_CUSTOM_FUNCTIONS];
|
QDoubleSpinBox * fswtchParam[CPN_MAX_SPECIAL_FUNCTIONS];
|
||||||
QTimeEdit * fswtchParamTime[CPN_MAX_CUSTOM_FUNCTIONS];
|
QTimeEdit * fswtchParamTime[CPN_MAX_SPECIAL_FUNCTIONS];
|
||||||
QPushButton * playBT[CPN_MAX_CUSTOM_FUNCTIONS];
|
QPushButton * playBT[CPN_MAX_SPECIAL_FUNCTIONS];
|
||||||
QComboBox * fswtchParamT[CPN_MAX_CUSTOM_FUNCTIONS];
|
QComboBox * fswtchParamT[CPN_MAX_SPECIAL_FUNCTIONS];
|
||||||
QComboBox * fswtchParamArmT[CPN_MAX_CUSTOM_FUNCTIONS];
|
QComboBox * fswtchParamArmT[CPN_MAX_SPECIAL_FUNCTIONS];
|
||||||
QCheckBox * fswtchEnable[CPN_MAX_CUSTOM_FUNCTIONS];
|
QCheckBox * fswtchEnable[CPN_MAX_SPECIAL_FUNCTIONS];
|
||||||
RepeatComboBox * fswtchRepeat[CPN_MAX_CUSTOM_FUNCTIONS];
|
RepeatComboBox * fswtchRepeat[CPN_MAX_SPECIAL_FUNCTIONS];
|
||||||
QComboBox * fswtchGVmode[CPN_MAX_CUSTOM_FUNCTIONS];
|
QComboBox * fswtchGVmode[CPN_MAX_SPECIAL_FUNCTIONS];
|
||||||
QSlider * fswtchBLcolor[CPN_MAX_CUSTOM_FUNCTIONS];
|
QSlider * fswtchBLcolor[CPN_MAX_SPECIAL_FUNCTIONS];
|
||||||
QMediaPlayer * mediaPlayer;
|
QMediaPlayer * mediaPlayer;
|
||||||
|
|
||||||
int selectedFunction;
|
int selectedFunction;
|
||||||
|
|
|
@ -48,16 +48,16 @@ class LogicalSwitchesPanel : public ModelPanel
|
||||||
void cswCut();
|
void cswCut();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QComboBox * csw[CPN_MAX_CSW];
|
QComboBox * csw[CPN_MAX_LOGICAL_SWITCHES];
|
||||||
QDoubleSpinBox * cswitchValue[CPN_MAX_CSW];
|
QDoubleSpinBox * cswitchValue[CPN_MAX_LOGICAL_SWITCHES];
|
||||||
QDoubleSpinBox * cswitchOffset[CPN_MAX_CSW];
|
QDoubleSpinBox * cswitchOffset[CPN_MAX_LOGICAL_SWITCHES];
|
||||||
QDoubleSpinBox * cswitchOffset2[CPN_MAX_CSW];
|
QDoubleSpinBox * cswitchOffset2[CPN_MAX_LOGICAL_SWITCHES];
|
||||||
QTimeEdit * cswitchTOffset[CPN_MAX_CSW];
|
QTimeEdit * cswitchTOffset[CPN_MAX_LOGICAL_SWITCHES];
|
||||||
QComboBox * cswitchAnd[CPN_MAX_CSW];
|
QComboBox * cswitchAnd[CPN_MAX_LOGICAL_SWITCHES];
|
||||||
QDoubleSpinBox * cswitchDuration[CPN_MAX_CSW];
|
QDoubleSpinBox * cswitchDuration[CPN_MAX_LOGICAL_SWITCHES];
|
||||||
QDoubleSpinBox * cswitchDelay[CPN_MAX_CSW];
|
QDoubleSpinBox * cswitchDelay[CPN_MAX_LOGICAL_SWITCHES];
|
||||||
QComboBox * cswitchSource1[CPN_MAX_CSW];
|
QComboBox * cswitchSource1[CPN_MAX_LOGICAL_SWITCHES];
|
||||||
QComboBox * cswitchSource2[CPN_MAX_CSW];
|
QComboBox * cswitchSource2[CPN_MAX_LOGICAL_SWITCHES];
|
||||||
QStandardItemModel * rawSwitchItemModel;
|
QStandardItemModel * rawSwitchItemModel;
|
||||||
QStandardItemModel * rawSourceItemModel;
|
QStandardItemModel * rawSourceItemModel;
|
||||||
void setSwitchWidgetVisibility(int i);
|
void setSwitchWidgetVisibility(int i);
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
// TODO here we will move a lot of functions from eeprominterface.cpp when no merge risk
|
// TODO here we will move a lot of functions from eeprominterface.cpp when no merge risk
|
||||||
|
|
||||||
void RawSource::convert(Board::Type before, Board::Type after)
|
RawSource RawSource::convert(Board::Type before, Board::Type after)
|
||||||
{
|
{
|
||||||
if (type == SOURCE_TYPE_STICK && index >= 4 + getBoardCapability(before, Board::Pots)) {
|
if (type == SOURCE_TYPE_STICK && index >= 4 + getBoardCapability(before, Board::Pots)) {
|
||||||
// 1st slider alignment
|
// 1st slider alignment
|
||||||
|
@ -57,11 +57,79 @@ void RawSource::convert(Board::Type before, Board::Type after)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
RawSwitch RawSwitch::convert(Board::Type before, Board::Type after)
|
||||||
|
{
|
||||||
|
// SWI to SWR don't exist on !X9E board
|
||||||
|
if (!IS_TARANIS_X9E(after) && IS_TARANIS_X9E(before)) {
|
||||||
|
if (type == SWITCH_TYPE_SWITCH && index >= 24) {
|
||||||
|
index = index % 24;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// No SE and SG on X7 board
|
||||||
|
if (IS_TARANIS_X7(after)) {
|
||||||
|
if (IS_TARANIS_X9(before) || IS_HORUS(before)) {
|
||||||
|
if (type == SWITCH_TYPE_SWITCH && index >= 18) {
|
||||||
|
index -= 6;
|
||||||
|
}
|
||||||
|
else if (type == SWITCH_TYPE_SWITCH && index >= 12) {
|
||||||
|
index -= 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExpoData::convert(Board::Type before, Board::Type after)
|
||||||
|
{
|
||||||
|
swtch.convert(before, after);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MixData::convert(Board::Type before, Board::Type after)
|
void MixData::convert(Board::Type before, Board::Type after)
|
||||||
{
|
{
|
||||||
srcRaw.convert(before, after);
|
srcRaw.convert(before, after);
|
||||||
|
swtch.convert(before, after);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LogicalSwitchData::convert(Board::Type before, Board::Type after)
|
||||||
|
{
|
||||||
|
CSFunctionFamily family = getFunctionFamily();
|
||||||
|
switch(family) {
|
||||||
|
case LS_FAMILY_VOFS:
|
||||||
|
val1 = RawSource(val1).convert(before, after).toValue();
|
||||||
|
break;
|
||||||
|
case LS_FAMILY_STICKY:
|
||||||
|
case LS_FAMILY_VBOOL:
|
||||||
|
val1 = RawSwitch(val1).convert(before, after).toValue();
|
||||||
|
val2 = RawSwitch(val2).convert(before, after).toValue();
|
||||||
|
break;
|
||||||
|
case LS_FAMILY_EDGE:
|
||||||
|
val1 = RawSwitch(val1).convert(before, after).toValue();
|
||||||
|
break;
|
||||||
|
case LS_FAMILY_VCOMP:
|
||||||
|
val1 = RawSource(val1).convert(before, after).toValue();
|
||||||
|
val2 = RawSource(val2).convert(before, after).toValue();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
andsw = RawSwitch(andsw).convert(before, after).toValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CustomFunctionData::convert(Board::Type before, Board::Type after)
|
||||||
|
{
|
||||||
|
swtch.convert(before, after);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlightModeData::convert(Board::Type before, Board::Type after)
|
||||||
|
{
|
||||||
|
swtch.convert(before, after);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelData::convert(Board::Type before, Board::Type after)
|
void ModelData::convert(Board::Type before, Board::Type after)
|
||||||
|
@ -70,11 +138,37 @@ void ModelData::convert(Board::Type before, Board::Type after)
|
||||||
for (int i=0; i<CPN_MAX_MIXERS; i++) {
|
for (int i=0; i<CPN_MAX_MIXERS; i++) {
|
||||||
mixData[i].convert(before, after);
|
mixData[i].convert(before, after);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i=0; i<CPN_MAX_EXPOS; i++) {
|
||||||
|
expoData[i].convert(before, after);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i=0; i<CPN_MAX_LOGICAL_SWITCHES; i++) {
|
||||||
|
logicalSw[i].convert(before, after);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i=0; i<CPN_MAX_SPECIAL_FUNCTIONS; i++) {
|
||||||
|
customFn[i].convert(before, after);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i=0; i<CPN_MAX_FLIGHT_MODES; i++) {
|
||||||
|
flightModeData[i].convert(before, after);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeneralSettings::convert(Board::Type before, Board::Type after)
|
void GeneralSettings::convert(Board::Type before, Board::Type after)
|
||||||
{
|
{
|
||||||
// Here we can add explicit conversions when moving from one board to another
|
// Here we can add explicit conversions when moving from one board to another
|
||||||
|
|
||||||
|
// No SE and SG on X7 board
|
||||||
|
if (IS_TARANIS_X7(after)) {
|
||||||
|
if (IS_TARANIS_X9(before) || IS_HORUS(before)) {
|
||||||
|
switchConfig[4] = switchConfig[5];
|
||||||
|
memcpy(switchName[4], switchName[5], sizeof(switchName[4]));
|
||||||
|
switchConfig[5] = switchConfig[7];
|
||||||
|
memcpy(switchName[5], switchName[7], sizeof(switchName[5]));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RadioData::setCurrentModel(unsigned int index)
|
void RadioData::setCurrentModel(unsigned int index)
|
||||||
|
|
|
@ -211,7 +211,7 @@ class RawSource {
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(Board::Type before, Board::Type after);
|
RawSource convert(Board::Type before, Board::Type after);
|
||||||
|
|
||||||
inline const int toValue() const
|
inline const int toValue() const
|
||||||
{
|
{
|
||||||
|
@ -287,6 +287,8 @@ class RawSwitch {
|
||||||
return (this->type != other.type) || (this->index != other.index);
|
return (this->type != other.type) || (this->index != other.index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RawSwitch convert(Board::Type before, Board::Type after);
|
||||||
|
|
||||||
RawSwitchType type;
|
RawSwitchType type;
|
||||||
int index;
|
int index;
|
||||||
};
|
};
|
||||||
|
@ -338,6 +340,7 @@ class ExpoData {
|
||||||
int carryTrim;
|
int carryTrim;
|
||||||
char name[10+1];
|
char name[10+1];
|
||||||
void clear() { memset(this, 0, sizeof(ExpoData)); }
|
void clear() { memset(this, 0, sizeof(ExpoData)); }
|
||||||
|
void convert(Board::Type before, Board::Type after);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CurvePoint {
|
class CurvePoint {
|
||||||
|
@ -468,6 +471,7 @@ class LogicalSwitchData { // Logical Switches data
|
||||||
CSFunctionFamily getFunctionFamily() const;
|
CSFunctionFamily getFunctionFamily() const;
|
||||||
unsigned int getRangeFlags() const;
|
unsigned int getRangeFlags() const;
|
||||||
QString funcToString() const;
|
QString funcToString() const;
|
||||||
|
void convert(Board::Type before, Board::Type after);
|
||||||
};
|
};
|
||||||
|
|
||||||
enum AssignFunc {
|
enum AssignFunc {
|
||||||
|
@ -536,6 +540,8 @@ class CustomFunctionData { // Function Switches data
|
||||||
static void populatePlaySoundParams(QStringList & qs);
|
static void populatePlaySoundParams(QStringList & qs);
|
||||||
static void populateHapticParams(QStringList & qs);
|
static void populateHapticParams(QStringList & qs);
|
||||||
|
|
||||||
|
void convert(Board::Type before, Board::Type after);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class FlightModeData {
|
class FlightModeData {
|
||||||
|
@ -551,6 +557,7 @@ class FlightModeData {
|
||||||
int rotaryEncoders[CPN_MAX_ENCODERS];
|
int rotaryEncoders[CPN_MAX_ENCODERS];
|
||||||
int gvars[CPN_MAX_GVARS];
|
int gvars[CPN_MAX_GVARS];
|
||||||
void clear(const int phase);
|
void clear(const int phase);
|
||||||
|
void convert(Board::Type before, Board::Type after);
|
||||||
};
|
};
|
||||||
|
|
||||||
class SwashRingData { // Swash Ring data
|
class SwashRingData { // Swash Ring data
|
||||||
|
@ -1033,8 +1040,8 @@ class ModelData {
|
||||||
ExpoData expoData[CPN_MAX_EXPOS];
|
ExpoData expoData[CPN_MAX_EXPOS];
|
||||||
|
|
||||||
CurveData curves[CPN_MAX_CURVES];
|
CurveData curves[CPN_MAX_CURVES];
|
||||||
LogicalSwitchData logicalSw[CPN_MAX_CSW];
|
LogicalSwitchData logicalSw[CPN_MAX_LOGICAL_SWITCHES];
|
||||||
CustomFunctionData customFn[CPN_MAX_CUSTOM_FUNCTIONS];
|
CustomFunctionData customFn[CPN_MAX_SPECIAL_FUNCTIONS];
|
||||||
SwashRingData swashRingData;
|
SwashRingData swashRingData;
|
||||||
unsigned int thrTraceSrc;
|
unsigned int thrTraceSrc;
|
||||||
uint64_t switchWarningStates;
|
uint64_t switchWarningStates;
|
||||||
|
@ -1200,7 +1207,7 @@ class GeneralSettings {
|
||||||
unsigned int switchUnlockStates;
|
unsigned int switchUnlockStates;
|
||||||
unsigned int hw_uartMode;
|
unsigned int hw_uartMode;
|
||||||
unsigned int backlightColor;
|
unsigned int backlightColor;
|
||||||
CustomFunctionData customFn[CPN_MAX_CUSTOM_FUNCTIONS];
|
CustomFunctionData customFn[CPN_MAX_SPECIAL_FUNCTIONS];
|
||||||
char switchName[CPN_MAX_SWITCHES][3+1];
|
char switchName[CPN_MAX_SWITCHES][3+1];
|
||||||
unsigned int switchConfig[CPN_MAX_SWITCHES];
|
unsigned int switchConfig[CPN_MAX_SWITCHES];
|
||||||
char stickName[CPN_MAX_STICKS][3+1];
|
char stickName[CPN_MAX_STICKS][3+1];
|
||||||
|
|
|
@ -321,7 +321,7 @@ void RadioOutputsWidget::setValues()
|
||||||
if (ui->logicalSwitchesWidget->isVisible()) {
|
if (ui->logicalSwitchesWidget->isVisible()) {
|
||||||
QHash<int, QLabel* >::const_iterator ls;
|
QHash<int, QLabel* >::const_iterator ls;
|
||||||
for (ls = m_logicSwitchMap.constBegin(); ls != m_logicSwitchMap.constEnd(); ++ls) {
|
for (ls = m_logicSwitchMap.constBegin(); ls != m_logicSwitchMap.constEnd(); ++ls) {
|
||||||
if (ls.key() >= CPN_MAX_CSW || (prevOutputs.vsw[ls.key()] == outputs.vsw[ls.key()] && m_lastFlightPhase > -1))
|
if (ls.key() >= CPN_MAX_LOGICAL_SWITCHES || (prevOutputs.vsw[ls.key()] == outputs.vsw[ls.key()] && m_lastFlightPhase > -1))
|
||||||
continue;
|
continue;
|
||||||
ls.value()->setBackgroundRole(outputs.vsw[ls.key()] ? QPalette::Dark : QPalette::Background);
|
ls.value()->setBackgroundRole(outputs.vsw[ls.key()] ? QPalette::Dark : QPalette::Background);
|
||||||
ls.value()->setForegroundRole(outputs.vsw[ls.key()] ? QPalette::BrightText : QPalette::WindowText);
|
ls.value()->setForegroundRole(outputs.vsw[ls.key()] ? QPalette::BrightText : QPalette::WindowText);
|
||||||
|
|
|
@ -49,7 +49,7 @@ class TxOutputs
|
||||||
public:
|
public:
|
||||||
TxOutputs() { memset(this, 0, sizeof(TxOutputs)); }
|
TxOutputs() { memset(this, 0, sizeof(TxOutputs)); }
|
||||||
int chans[CPN_MAX_CHNOUT];
|
int chans[CPN_MAX_CHNOUT];
|
||||||
bool vsw[CPN_MAX_CSW];
|
bool vsw[CPN_MAX_LOGICAL_SWITCHES];
|
||||||
int gvars[CPN_MAX_FLIGHT_MODES][CPN_MAX_GVARS];
|
int gvars[CPN_MAX_FLIGHT_MODES][CPN_MAX_GVARS];
|
||||||
unsigned int beep;
|
unsigned int beep;
|
||||||
// uint8_t phase;
|
// uint8_t phase;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue