mirror of
https://github.com/opentx/opentx.git
synced 2025-07-14 11:59:50 +03:00
parent
00f68dadd2
commit
08de1a75e0
15 changed files with 222 additions and 66 deletions
|
@ -178,7 +178,9 @@ const SwitchInfo Boards::getSwitchInfo(Board::Type board, int index)
|
|||
{SWITCH_3POS, "SC"},
|
||||
{SWITCH_3POS, "SD"},
|
||||
{SWITCH_2POS, "SF"},
|
||||
{SWITCH_TOGGLE, "SH"}
|
||||
{SWITCH_TOGGLE, "SH"},
|
||||
{SWITCH_2POS, "SI"},
|
||||
{SWITCH_2POS, "SJ"}
|
||||
};
|
||||
if (index < DIM(switches))
|
||||
return switches[index];
|
||||
|
@ -281,7 +283,7 @@ const int Boards::getCapability(Board::Type board, Board::Capability capability)
|
|||
else if (IS_TARANIS_X9LITE(board))
|
||||
return 5;
|
||||
else if (IS_TARANIS_X7(board))
|
||||
return 6;
|
||||
return 8;
|
||||
else if (IS_TARANIS_XLITES(board))
|
||||
return 6;
|
||||
else if (IS_TARANIS_XLITE(board))
|
||||
|
|
|
@ -31,7 +31,7 @@ using namespace Board;
|
|||
#define MAX_SLIDERS(board) (IS_HORUS_X10(board) ? 4 : (Boards::getCapability(board, Board::Sliders))) //TODO need to be remove when x10 eeprom gets fixed
|
||||
#define MAX_MOUSE_ANALOGS(board) (IS_HORUS_X10(board) ? 2 : (Boards::getCapability(board, Board::MouseAnalogs))) //TODO need to be remove when x10 eeprom gets fixed
|
||||
#define MAX_GYRO_ANALOGS(board, version) (version >= 219 ? Boards::getCapability(board, Board::GyroAnalogs) : 0)
|
||||
#define MAX_SWITCHES(board, version) (Boards::getCapability(board, Board::Switches))
|
||||
#define MAX_SWITCHES(board, version) (version <= 218 && IS_TARANIS_X7(board) ? 6 : Boards::getCapability(board, Board::Switches))
|
||||
#define MAX_SWITCH_SLOTS(board, version) (IS_TARANIS_X9E(board) ? 32 : 8) // bitsize of swconfig_t / 2 (see radio/src/datastructs.h)
|
||||
#define MAX_SWITCHES_POSITION(board, version) (Boards::getCapability(board, Board::SwitchPositions))
|
||||
#define MAX_ROTARY_ENCODERS(board) (IS_SKY9X(board) ? 1 : 0)
|
||||
|
|
|
@ -403,6 +403,14 @@ enum SwitchSources {
|
|||
SWSRC_SH1,
|
||||
SWSRC_SH2,
|
||||
#endif
|
||||
#if defined(PCBX7)
|
||||
SWSRC_SI0,
|
||||
SWSRC_SI1,
|
||||
SWSRC_SI2,
|
||||
SWSRC_SJ0,
|
||||
SWSRC_SJ1,
|
||||
SWSRC_SJ2,
|
||||
#endif
|
||||
#if defined(PCBX9E)
|
||||
SWSRC_SI0,
|
||||
SWSRC_SI1,
|
||||
|
@ -436,11 +444,6 @@ enum SwitchSources {
|
|||
SWSRC_SR2,
|
||||
#endif
|
||||
SWSRC_LAST_SWITCH = SWSRC_FIRST_SWITCH + NUM_SWITCHES_POSITIONS - 1,
|
||||
#if NUM_SWITCHES >= 8
|
||||
SWSRC_TRAINER = SWSRC_SH2,
|
||||
#else
|
||||
SWSRC_TRAINER = SWSRC_LAST_SWITCH,
|
||||
#endif
|
||||
#else // neither Taranis nor Horus
|
||||
SWSRC_ID0 = SWSRC_FIRST_SWITCH,
|
||||
SWSRC_ID1,
|
||||
|
@ -523,6 +526,12 @@ enum SwitchSources {
|
|||
SWSRC_INVERT = SWSRC_COUNT+1,
|
||||
};
|
||||
|
||||
#if NUM_SWITCHES >= 8
|
||||
#define SWSRC_TRAINER SWSRC_SH2
|
||||
#else
|
||||
#define SWSRC_TRAINER SWSRC_LAST_SWITCH,
|
||||
#endif
|
||||
|
||||
#define SWSRC_LAST_TRIM (SWSRC_FIRST_TRIM + 2*NUM_TRIMS - 1)
|
||||
|
||||
enum MixSources {
|
||||
|
@ -635,6 +644,10 @@ enum MixSources {
|
|||
#if defined(PCBHORUS) || defined(PCBX9D) || defined(PCBX9DP) || defined(PCBX9E) || defined(PCBX7)
|
||||
MIXSRC_SH, LUA_EXPORT("sh", "Switch H")
|
||||
#endif
|
||||
#if defined(PCBX7)
|
||||
MIXSRC_SI, LUA_EXPORT("si", "Switch I")
|
||||
MIXSRC_SJ, LUA_EXPORT("sj", "Switch J")
|
||||
#endif
|
||||
#if defined(PCBX9E)
|
||||
MIXSRC_SI, LUA_EXPORT("si", "Switch I")
|
||||
MIXSRC_SJ, LUA_EXPORT("sj", "Switch J")
|
||||
|
@ -708,7 +721,9 @@ enum MixSources {
|
|||
MIXSRC_LAST_TELEM = MIXSRC_FIRST_TELEM+3*MAX_TELEMETRY_SENSORS-1
|
||||
};
|
||||
|
||||
#if defined(__cplusplus)
|
||||
static_assert(MIXSRC_FIRST_LOGICAL_SWITCH == MIXSRC_FIRST_SWITCH + NUM_SWITCHES, "Wrong switches definition in MIXSRC list");
|
||||
#endif
|
||||
|
||||
#define MIXSRC_FIRST (MIXSRC_NONE + 1)
|
||||
#define MIXSRC_LAST MIXSRC_LAST_CH
|
||||
|
|
|
@ -914,7 +914,7 @@ static inline void check_struct()
|
|||
CHKSIZE(RadioData, 852);
|
||||
CHKSIZE(ModelData, 6157);
|
||||
#elif defined(PCBX7)
|
||||
CHKSIZE(RadioData, 858);
|
||||
CHKSIZE(RadioData, 864);
|
||||
CHKSIZE(ModelData, 6157);
|
||||
#elif defined(PCBX9E)
|
||||
CHKSIZE(RadioData, 960);
|
||||
|
|
|
@ -109,6 +109,10 @@ enum MenuRadioHardwareItems {
|
|||
#endif
|
||||
#if NUM_SWITCHES >= 6
|
||||
ITEM_RADIO_HARDWARE_SH,
|
||||
#endif
|
||||
#if NUM_SWITCHES >= 8
|
||||
ITEM_RADIO_HARDWARE_SI,
|
||||
ITEM_RADIO_HARDWARE_SJ,
|
||||
#endif
|
||||
ITEM_RADIO_HARDWARE_BATTERY_CALIB,
|
||||
#if defined(STM32)
|
||||
|
@ -142,7 +146,9 @@ enum MenuRadioHardwareItems {
|
|||
#define POTS_ROWS NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1
|
||||
#endif
|
||||
|
||||
#if NUM_SWITCHES == 6
|
||||
#if NUM_SWITCHES == 8
|
||||
#define SWITCHES_ROWS NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1
|
||||
#elif NUM_SWITCHES == 6
|
||||
#define SWITCHES_ROWS NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1
|
||||
#elif NUM_SWITCHES == 5
|
||||
#define SWITCHES_ROWS NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1, NAVIGATION_LINE_BY_LINE|1
|
||||
|
@ -167,7 +173,7 @@ enum MenuRadioHardwareItems {
|
|||
#elif defined(PCBXLITE)
|
||||
#define SWITCH_TYPE_MAX(sw) (SWITCH_3POS)
|
||||
#else
|
||||
#define SWITCH_TYPE_MAX(sw) ((MIXSRC_SF-MIXSRC_FIRST_SWITCH == sw || MIXSRC_SH-MIXSRC_FIRST_SWITCH == sw) ? SWITCH_2POS : SWITCH_3POS)
|
||||
#define SWITCH_TYPE_MAX(sw) ((MIXSRC_SF-MIXSRC_FIRST_SWITCH == sw || MIXSRC_SH-MIXSRC_FIRST_SWITCH == sw || MIXSRC_SI-MIXSRC_FIRST_SWITCH == sw || MIXSRC_SJ-MIXSRC_FIRST_SWITCH == sw) ? SWITCH_2POS : SWITCH_3POS)
|
||||
#endif
|
||||
|
||||
#if defined(STM32)
|
||||
|
@ -291,6 +297,10 @@ void menuRadioHardware(event_t event)
|
|||
#endif
|
||||
#if NUM_SWITCHES >= 6
|
||||
case ITEM_RADIO_HARDWARE_SH:
|
||||
#endif
|
||||
#if NUM_SWITCHES >= 8
|
||||
case ITEM_RADIO_HARDWARE_SI:
|
||||
case ITEM_RADIO_HARDWARE_SJ:
|
||||
#endif
|
||||
{
|
||||
int index = k-ITEM_RADIO_HARDWARE_SA;
|
||||
|
|
|
@ -667,10 +667,10 @@ int ConvertTelemetrySource_216_to_217(int source)
|
|||
}
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
int ConvertSwitch_216_to_217(int swtch)
|
||||
int convertSwitch_216_to_217(int swtch)
|
||||
{
|
||||
if (swtch < 0)
|
||||
return -ConvertSwitch_216_to_217(-swtch);
|
||||
return -convertSwitch_216_to_217(-swtch);
|
||||
|
||||
if (swtch > SWSRC_SF0)
|
||||
swtch += 1;
|
||||
|
@ -681,18 +681,18 @@ int ConvertSwitch_216_to_217(int swtch)
|
|||
return swtch;
|
||||
}
|
||||
#else
|
||||
int ConvertSwitch_216_to_217(int swtch)
|
||||
int convertSwitch_216_to_217(int swtch)
|
||||
{
|
||||
return swtch;
|
||||
}
|
||||
#endif
|
||||
|
||||
int ConvertSwitch_217_to_218(int swtch)
|
||||
int convertSwitch_217_to_218(int swtch)
|
||||
{
|
||||
// 32 additional logical switches
|
||||
|
||||
if (swtch < 0)
|
||||
return -ConvertSwitch_217_to_218(-swtch);
|
||||
return -convertSwitch_217_to_218(-swtch);
|
||||
|
||||
if (swtch >= SWSRC_FIRST_LOGICAL_SWITCH+32)
|
||||
return swtch+32;
|
||||
|
@ -700,7 +700,7 @@ int ConvertSwitch_217_to_218(int swtch)
|
|||
return swtch;
|
||||
}
|
||||
|
||||
int ConvertSource_216_to_217(int source)
|
||||
int convertSource_216_to_217(int source)
|
||||
{
|
||||
#if defined(PCBX9E)
|
||||
// SI to SR switches added
|
||||
|
@ -714,7 +714,7 @@ int ConvertSource_216_to_217(int source)
|
|||
return source;
|
||||
}
|
||||
|
||||
int ConvertSource_217_to_218(int source)
|
||||
int convertSource_217_to_218(int source)
|
||||
{
|
||||
#if defined(PCBTARANIS)
|
||||
if (source >= MIXSRC_FIRST_LOGICAL_SWITCH + 32)
|
||||
|
@ -724,7 +724,7 @@ int ConvertSource_217_to_218(int source)
|
|||
return source;
|
||||
}
|
||||
|
||||
int ConvertGVar_216_to_217(int value)
|
||||
int convertGVar_216_to_217(int value)
|
||||
{
|
||||
if (value < -4096 + 9)
|
||||
value += 4096 - 1024;
|
||||
|
@ -826,10 +826,10 @@ void ConvertSpecialFunctions_217_to_218(CustomFunctionData_v218 * cf218, CustomF
|
|||
for (int i=0; i<MAX_SPECIAL_FUNCTIONS; i++) {
|
||||
CustomFunctionData_v218 & cf = cf218[i];
|
||||
memcpy(&cf, &cf216[i], sizeof(CustomFunctionData_v218));
|
||||
cf.swtch = ConvertSwitch_217_to_218(cf216[i].swtch);
|
||||
cf.swtch = convertSwitch_217_to_218(cf216[i].swtch);
|
||||
cf.func = cf216[i].func;
|
||||
if (cf.func == FUNC_PLAY_VALUE || cf.func == FUNC_VOLUME || (IS_ADJUST_GV_FUNC(cf.func) && cf.all.mode == FUNC_ADJUST_GVAR_SOURCE)) {
|
||||
cf.all.val = ConvertSource_217_to_218(cf.all.val);
|
||||
cf.all.val = convertSource_217_to_218(cf.all.val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -921,9 +921,9 @@ void convertModelData_216_to_217(ModelData &model)
|
|||
for (uint8_t i=0; i<2; i++) {
|
||||
TimerData_v217 & timer = newModel.timers[i];
|
||||
if (oldModel.timers[i].mode >= TMRMODE_COUNT)
|
||||
timer.mode = TMRMODE_COUNT + ConvertSwitch_216_to_217(oldModel.timers[i].mode - TMRMODE_COUNT + 1) - 1;
|
||||
timer.mode = TMRMODE_COUNT + convertSwitch_216_to_217(oldModel.timers[i].mode - TMRMODE_COUNT + 1) - 1;
|
||||
else
|
||||
timer.mode = ConvertSwitch_216_to_217(oldModel.timers[i].mode);
|
||||
timer.mode = convertSwitch_216_to_217(oldModel.timers[i].mode);
|
||||
timer.start = oldModel.timers[i].start;
|
||||
timer.countdownBeep = oldModel.timers[i].countdownBeep;
|
||||
timer.minuteBeep = oldModel.timers[i].minuteBeep;
|
||||
|
@ -945,8 +945,8 @@ void convertModelData_216_to_217(ModelData &model)
|
|||
newModel.mixData[i].mltpx = oldModel.mixData[i].mltpx;
|
||||
newModel.mixData[i].carryTrim = oldModel.mixData[i].carryTrim;
|
||||
newModel.mixData[i].mixWarn = oldModel.mixData[i].mixWarn;
|
||||
newModel.mixData[i].weight = ConvertGVar_216_to_217(oldModel.mixData[i].weight);
|
||||
newModel.mixData[i].swtch = ConvertSwitch_216_to_217(oldModel.mixData[i].swtch);
|
||||
newModel.mixData[i].weight = convertGVar_216_to_217(oldModel.mixData[i].weight);
|
||||
newModel.mixData[i].swtch = convertSwitch_216_to_217(oldModel.mixData[i].swtch);
|
||||
#if defined(PCBTARANIS)
|
||||
newModel.mixData[i].curve = oldModel.mixData[i].curve;
|
||||
#else
|
||||
|
@ -958,15 +958,15 @@ void convertModelData_216_to_217(ModelData &model)
|
|||
newModel.mixData[i].delayDown = oldModel.mixData[i].delayDown;
|
||||
newModel.mixData[i].speedUp = oldModel.mixData[i].speedUp;
|
||||
newModel.mixData[i].speedDown = oldModel.mixData[i].speedDown;
|
||||
newModel.mixData[i].srcRaw = ConvertSource_216_to_217(oldModel.mixData[i].srcRaw);
|
||||
newModel.mixData[i].offset = ConvertGVar_216_to_217(oldModel.mixData[i].offset);
|
||||
newModel.mixData[i].srcRaw = convertSource_216_to_217(oldModel.mixData[i].srcRaw);
|
||||
newModel.mixData[i].offset = convertGVar_216_to_217(oldModel.mixData[i].offset);
|
||||
memcpy(newModel.mixData[i].name, oldModel.mixData[i].name, sizeof(newModel.mixData[i].name));
|
||||
}
|
||||
for (int i=0; i<MAX_OUTPUT_CHANNELS; i++) {
|
||||
#if defined(PCBTARANIS)
|
||||
newModel.limitData[i].min = ConvertGVar_216_to_217(oldModel.limitData[i].min);
|
||||
newModel.limitData[i].max = ConvertGVar_216_to_217(oldModel.limitData[i].max);
|
||||
newModel.limitData[i].offset = ConvertGVar_216_to_217(oldModel.limitData[i].offset);
|
||||
newModel.limitData[i].min = convertGVar_216_to_217(oldModel.limitData[i].min);
|
||||
newModel.limitData[i].max = convertGVar_216_to_217(oldModel.limitData[i].max);
|
||||
newModel.limitData[i].offset = convertGVar_216_to_217(oldModel.limitData[i].offset);
|
||||
newModel.limitData[i].ppmCenter = oldModel.limitData[i].ppmCenter;
|
||||
newModel.limitData[i].symetrical = oldModel.limitData[i].symetrical;
|
||||
newModel.limitData[i].revert = oldModel.limitData[i].revert;
|
||||
|
@ -978,7 +978,7 @@ void convertModelData_216_to_217(ModelData &model)
|
|||
}
|
||||
for (int i=0; i<MAX_EXPOS; i++) {
|
||||
#if defined(PCBTARANIS)
|
||||
newModel.expoData[i].srcRaw = ConvertSource_216_to_217(oldModel.expoData[i].srcRaw);
|
||||
newModel.expoData[i].srcRaw = convertSource_216_to_217(oldModel.expoData[i].srcRaw);
|
||||
newModel.expoData[i].scale = oldModel.expoData[i].scale;
|
||||
newModel.expoData[i].carryTrim = oldModel.expoData[i].carryTrim;
|
||||
newModel.expoData[i].curve = oldModel.expoData[i].curve;
|
||||
|
@ -988,7 +988,7 @@ void convertModelData_216_to_217(ModelData &model)
|
|||
newModel.expoData[i].curveParam = oldModel.expoData[i].curveParam;
|
||||
#endif
|
||||
newModel.expoData[i].chn = oldModel.expoData[i].chn;
|
||||
newModel.expoData[i].swtch = ConvertSwitch_216_to_217(oldModel.expoData[i].swtch);
|
||||
newModel.expoData[i].swtch = convertSwitch_216_to_217(oldModel.expoData[i].swtch);
|
||||
newModel.expoData[i].flightModes = oldModel.expoData[i].flightModes;
|
||||
newModel.expoData[i].weight = oldModel.expoData[i].weight;
|
||||
newModel.expoData[i].mode = oldModel.expoData[i].mode;
|
||||
|
@ -1006,35 +1006,35 @@ void convertModelData_216_to_217(ModelData &model)
|
|||
sw.duration = oldModel.logicalSw[i].duration;
|
||||
uint8_t cstate = lswFamily(sw.func);
|
||||
if (cstate == LS_FAMILY_OFS || cstate == LS_FAMILY_COMP || cstate == LS_FAMILY_DIFF) {
|
||||
sw.v1 = ConvertSource_216_to_217((uint8_t)sw.v1);
|
||||
sw.v1 = convertSource_216_to_217((uint8_t)sw.v1);
|
||||
if (cstate == LS_FAMILY_COMP) {
|
||||
sw.v2 = ConvertSource_216_to_217((uint8_t)sw.v2);
|
||||
sw.v2 = convertSource_216_to_217((uint8_t)sw.v2);
|
||||
}
|
||||
}
|
||||
else if (cstate == LS_FAMILY_BOOL || cstate == LS_FAMILY_STICKY) {
|
||||
sw.v1 = ConvertSwitch_216_to_217(sw.v1);
|
||||
sw.v2 = ConvertSwitch_216_to_217(sw.v2);
|
||||
sw.v1 = convertSwitch_216_to_217(sw.v1);
|
||||
sw.v2 = convertSwitch_216_to_217(sw.v2);
|
||||
}
|
||||
else if (cstate == LS_FAMILY_EDGE) {
|
||||
sw.v1 = ConvertSwitch_216_to_217(sw.v1);
|
||||
sw.v1 = convertSwitch_216_to_217(sw.v1);
|
||||
}
|
||||
sw.andsw = ConvertSwitch_216_to_217(sw.andsw);
|
||||
sw.andsw = convertSwitch_216_to_217(sw.andsw);
|
||||
}
|
||||
for (int i=0; i<MAX_SPECIAL_FUNCTIONS; i++) {
|
||||
CustomFunctionData_v216 & fn = newModel.customFn[i];
|
||||
fn = oldModel.customFn[i];
|
||||
fn.swtch = ConvertSwitch_216_to_217(fn.swtch);
|
||||
fn.swtch = convertSwitch_216_to_217(fn.swtch);
|
||||
if (fn.func == FUNC_PLAY_VALUE || fn.func == FUNC_VOLUME || (IS_ADJUST_GV_FUNC(fn.func) && fn.all.mode == FUNC_ADJUST_GVAR_SOURCE)) {
|
||||
fn.all.val = ConvertSource_216_to_217(fn.all.val);
|
||||
fn.all.val = convertSource_216_to_217(fn.all.val);
|
||||
}
|
||||
}
|
||||
|
||||
newModel.swashR.collectiveSource = ConvertSource_216_to_217(newModel.swashR.collectiveSource);
|
||||
newModel.swashR.collectiveSource = convertSource_216_to_217(newModel.swashR.collectiveSource);
|
||||
// TODO other fields
|
||||
|
||||
for (int i=0; i<MAX_FLIGHT_MODES; i++) {
|
||||
newModel.flightModeData[i] = oldModel.flightModeData[i];
|
||||
newModel.flightModeData[i].swtch = ConvertSwitch_216_to_217(oldModel.flightModeData[i].swtch);
|
||||
newModel.flightModeData[i].swtch = convertSwitch_216_to_217(oldModel.flightModeData[i].swtch);
|
||||
}
|
||||
|
||||
newModel.thrTraceSrc = oldModel.thrTraceSrc;
|
||||
|
@ -1090,9 +1090,9 @@ void convertModelData_217_to_218(ModelData &model)
|
|||
newModel.header = oldModel.header;
|
||||
for (uint8_t i=0; i<MAX_TIMERS; i++) {
|
||||
if (oldModel.timers[i].mode >= TMRMODE_COUNT)
|
||||
newModel.timers[i].mode = TMRMODE_COUNT + ConvertSwitch_217_to_218(oldModel.timers[i].mode - TMRMODE_COUNT + 1) - 1;
|
||||
newModel.timers[i].mode = TMRMODE_COUNT + convertSwitch_217_to_218(oldModel.timers[i].mode - TMRMODE_COUNT + 1) - 1;
|
||||
else
|
||||
newModel.timers[i].mode = ConvertSwitch_217_to_218(oldModel.timers[i].mode);
|
||||
newModel.timers[i].mode = convertSwitch_217_to_218(oldModel.timers[i].mode);
|
||||
if (oldModel.timers[i].mode)
|
||||
TRACE("timer mode %d => %d", oldModel.timers[i].mode, newModel.timers[i].mode);
|
||||
newModel.timers[i].start = oldModel.timers[i].start;
|
||||
|
@ -1121,7 +1121,7 @@ void convertModelData_217_to_218(ModelData &model)
|
|||
newModel.mixData[i].carryTrim = oldModel.mixData[i].carryTrim;
|
||||
newModel.mixData[i].mixWarn = oldModel.mixData[i].mixWarn;
|
||||
newModel.mixData[i].weight = oldModel.mixData[i].weight;
|
||||
newModel.mixData[i].swtch = ConvertSwitch_217_to_218(oldModel.mixData[i].swtch);
|
||||
newModel.mixData[i].swtch = convertSwitch_217_to_218(oldModel.mixData[i].swtch);
|
||||
#if defined(PCBTARANIS)
|
||||
newModel.mixData[i].curve = oldModel.mixData[i].curve;
|
||||
#else
|
||||
|
@ -1133,7 +1133,7 @@ void convertModelData_217_to_218(ModelData &model)
|
|||
newModel.mixData[i].delayDown = oldModel.mixData[i].delayDown;
|
||||
newModel.mixData[i].speedUp = oldModel.mixData[i].speedUp;
|
||||
newModel.mixData[i].speedDown = oldModel.mixData[i].speedDown;
|
||||
newModel.mixData[i].srcRaw = ConvertSource_217_to_218(oldModel.mixData[i].srcRaw);
|
||||
newModel.mixData[i].srcRaw = convertSource_217_to_218(oldModel.mixData[i].srcRaw);
|
||||
newModel.mixData[i].offset = oldModel.mixData[i].offset;
|
||||
memcpy(newModel.mixData[i].name, oldModel.mixData[i].name, sizeof(newModel.mixData[i].name));
|
||||
}
|
||||
|
@ -1147,7 +1147,7 @@ void convertModelData_217_to_218(ModelData &model)
|
|||
}
|
||||
for (int i=0; i<MAX_EXPOS; i++) {
|
||||
#if defined(PCBTARANIS)
|
||||
newModel.expoData[i].srcRaw = ConvertSource_217_to_218(oldModel.expoData[i].srcRaw);
|
||||
newModel.expoData[i].srcRaw = convertSource_217_to_218(oldModel.expoData[i].srcRaw);
|
||||
newModel.expoData[i].scale = oldModel.expoData[i].scale;
|
||||
newModel.expoData[i].carryTrim = oldModel.expoData[i].carryTrim;
|
||||
newModel.expoData[i].curve = oldModel.expoData[i].curve;
|
||||
|
@ -1157,7 +1157,7 @@ void convertModelData_217_to_218(ModelData &model)
|
|||
// TODO newModel.expoData[i].curveParam = oldModel.expoData[i].curveParam;
|
||||
#endif
|
||||
newModel.expoData[i].chn = oldModel.expoData[i].chn;
|
||||
newModel.expoData[i].swtch = ConvertSwitch_217_to_218(oldModel.expoData[i].swtch);
|
||||
newModel.expoData[i].swtch = convertSwitch_217_to_218(oldModel.expoData[i].swtch);
|
||||
newModel.expoData[i].flightModes = oldModel.expoData[i].flightModes;
|
||||
newModel.expoData[i].weight = oldModel.expoData[i].weight;
|
||||
newModel.expoData[i].mode = oldModel.expoData[i].mode;
|
||||
|
@ -1180,22 +1180,22 @@ void convertModelData_217_to_218(ModelData &model)
|
|||
sw.v1 = oldModel.logicalSw[i].v1;
|
||||
sw.v2 = oldModel.logicalSw[i].v2;
|
||||
sw.v3 = oldModel.logicalSw[i].v3;
|
||||
newModel.logicalSw[i].andsw = ConvertSwitch_217_to_218(oldModel.logicalSw[i].andsw);
|
||||
newModel.logicalSw[i].andsw = convertSwitch_217_to_218(oldModel.logicalSw[i].andsw);
|
||||
sw.delay = oldModel.logicalSw[i].delay;
|
||||
sw.duration = oldModel.logicalSw[i].duration;
|
||||
uint8_t cstate = lswFamily(sw.func);
|
||||
if (cstate == LS_FAMILY_OFS || cstate == LS_FAMILY_COMP || cstate == LS_FAMILY_DIFF) {
|
||||
sw.v1 = ConvertSource_217_to_218((uint8_t)sw.v1);
|
||||
sw.v1 = convertSource_217_to_218((uint8_t)sw.v1);
|
||||
if (cstate == LS_FAMILY_COMP) {
|
||||
sw.v2 = ConvertSource_217_to_218((uint8_t)sw.v2);
|
||||
sw.v2 = convertSource_217_to_218((uint8_t)sw.v2);
|
||||
}
|
||||
}
|
||||
else if (cstate == LS_FAMILY_BOOL || cstate == LS_FAMILY_STICKY) {
|
||||
sw.v1 = ConvertSwitch_217_to_218(sw.v1);
|
||||
sw.v2 = ConvertSwitch_217_to_218(sw.v2);
|
||||
sw.v1 = convertSwitch_217_to_218(sw.v1);
|
||||
sw.v2 = convertSwitch_217_to_218(sw.v2);
|
||||
}
|
||||
else if (cstate == LS_FAMILY_EDGE) {
|
||||
sw.v1 = ConvertSwitch_217_to_218(sw.v1);
|
||||
sw.v1 = convertSwitch_217_to_218(sw.v1);
|
||||
}
|
||||
}
|
||||
ConvertSpecialFunctions_217_to_218(newModel.customFn, oldModel.customFn);
|
||||
|
@ -1203,7 +1203,7 @@ void convertModelData_217_to_218(ModelData &model)
|
|||
for (int i=0; i<MAX_FLIGHT_MODES; i++) {
|
||||
memcpy(newModel.flightModeData[i].trim, oldModel.flightModeData[i].trim, sizeof(newModel.flightModeData[i].trim));
|
||||
memcpy(newModel.flightModeData[i].name, oldModel.flightModeData[i].name, sizeof(newModel.flightModeData[i].name));
|
||||
newModel.flightModeData[i].swtch = ConvertSwitch_217_to_218(oldModel.flightModeData[i].swtch);
|
||||
newModel.flightModeData[i].swtch = convertSwitch_217_to_218(oldModel.flightModeData[i].swtch);
|
||||
newModel.flightModeData[i].fadeIn = oldModel.flightModeData[i].fadeIn;
|
||||
newModel.flightModeData[i].fadeOut = oldModel.flightModeData[i].fadeOut;
|
||||
#if defined(PCBSKY9X)
|
||||
|
@ -1223,13 +1223,13 @@ void convertModelData_217_to_218(ModelData &model)
|
|||
if (((oldModel.frsky.screensType >> (2*i)) & 0x03) == TELEMETRY_SCREEN_TYPE_VALUES) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
for (int k = 0; k < NUM_LINE_ITEMS; k++) {
|
||||
newModel.frsky.screens[i].lines[j].sources[k] = ConvertSource_217_to_218(oldModel.frsky.screens[i].lines[j].sources[k]);
|
||||
newModel.frsky.screens[i].lines[j].sources[k] = convertSource_217_to_218(oldModel.frsky.screens[i].lines[j].sources[k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (((oldModel.frsky.screensType >> (2*i)) & 0x03) == TELEMETRY_SCREEN_TYPE_GAUGES) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
newModel.frsky.screens[i].bars[j].source = ConvertSource_217_to_218(oldModel.frsky.screens[i].bars[j].source);
|
||||
newModel.frsky.screens[i].bars[j].source = convertSource_217_to_218(oldModel.frsky.screens[i].bars[j].source);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,33 @@
|
|||
|
||||
typedef ModelData ModelData_v219;
|
||||
|
||||
int convertSource_218_to_219(int source)
|
||||
{
|
||||
// on X7: 2 additional switches
|
||||
|
||||
#if defined(PCBX7)
|
||||
if (source >= MIXSRC_SI)
|
||||
source += 2;
|
||||
#endif
|
||||
|
||||
return source;
|
||||
}
|
||||
|
||||
int convertSwitch_218_to_219(int swtch)
|
||||
{
|
||||
// on X7: 2 additional switches
|
||||
|
||||
#if defined(PCBX7)
|
||||
if (swtch < 0)
|
||||
return -convertSwitch_218_to_219(-swtch);
|
||||
|
||||
if (swtch >= SWSRC_SI0)
|
||||
return swtch + 2 * 3;
|
||||
#endif
|
||||
|
||||
return swtch;
|
||||
}
|
||||
|
||||
void convertModelData_218_to_219(ModelData &model)
|
||||
{
|
||||
static_assert(sizeof(ModelData_v218) <= sizeof(ModelData), "ModelData size has been reduced");
|
||||
|
@ -48,6 +75,8 @@ void convertModelData_218_to_219(ModelData &model)
|
|||
|
||||
for (uint8_t i=0; i<MAX_MIXERS_218; i++) {
|
||||
memmove(&newModel.mixData[i], &oldModel.mixData[i], sizeof(MixData_v218));
|
||||
newModel.mixData[i].srcRaw = convertSource_218_to_219(newModel.mixData[i].srcRaw); // from newModel to avoid overwrite
|
||||
newModel.mixData[i].swtch = convertSwitch_218_to_219(newModel.mixData[i].swtch); // from newModel to avoid overwrite
|
||||
}
|
||||
|
||||
for (uint8_t i=0; i<MAX_OUTPUT_CHANNELS_218; i++) {
|
||||
|
@ -56,8 +85,8 @@ void convertModelData_218_to_219(ModelData &model)
|
|||
|
||||
for (uint8_t i=0; i<MAX_EXPOS_218; i++) {
|
||||
memmove(&newModel.expoData[i], &oldModel.expoData[i], sizeof(ExpoData_v218));
|
||||
newModel.expoData[i].offset = oldModel.expoData[i].offset;
|
||||
newModel.expoData[i].curve = oldModel.expoData[i].curve;
|
||||
newModel.expoData[i].srcRaw = convertSource_218_to_219(newModel.expoData[i].srcRaw); // from newModel to avoid overwrite
|
||||
newModel.expoData[i].swtch = convertSwitch_218_to_219(newModel.expoData[i].swtch); // from newModel to avoid overwrite
|
||||
}
|
||||
|
||||
for (uint8_t i=0; i<MAX_CURVES_218; i++) {
|
||||
|
@ -70,10 +99,31 @@ void convertModelData_218_to_219(ModelData &model)
|
|||
|
||||
for (uint8_t i=0; i<MAX_LOGICAL_SWITCHES_218; i++) {
|
||||
memmove(&newModel.logicalSw[i], &oldModel.logicalSw[i], sizeof(LogicalSwitchData_v218));
|
||||
LogicalSwitchData & sw = newModel.logicalSw[i];
|
||||
uint8_t cstate = lswFamily(sw.func);
|
||||
if (cstate == LS_FAMILY_OFS || cstate == LS_FAMILY_COMP || cstate == LS_FAMILY_DIFF) {
|
||||
LogicalSwitchData & sw = newModel.logicalSw[i];
|
||||
sw.v1 = convertSource_218_to_219((uint8_t)sw.v1);
|
||||
if (cstate == LS_FAMILY_COMP) {
|
||||
sw.v2 = convertSource_218_to_219((uint8_t)sw.v2);
|
||||
}
|
||||
}
|
||||
else if (cstate == LS_FAMILY_BOOL || cstate == LS_FAMILY_STICKY) {
|
||||
sw.v1 = convertSwitch_218_to_219(sw.v1);
|
||||
sw.v2 = convertSwitch_218_to_219(sw.v2);
|
||||
}
|
||||
else if (cstate == LS_FAMILY_EDGE) {
|
||||
sw.v1 = convertSwitch_218_to_219(sw.v1);
|
||||
}
|
||||
}
|
||||
|
||||
for (uint8_t i=0; i<MAX_SPECIAL_FUNCTIONS_218; i++) {
|
||||
memmove(&newModel.customFn[i], &oldModel.customFn[i], sizeof(CustomFunctionData_v218));
|
||||
CustomFunctionData & cf = newModel.customFn[i];
|
||||
cf.swtch = convertSwitch_218_to_219(cf.swtch);
|
||||
if (cf.func == FUNC_PLAY_VALUE || cf.func == FUNC_VOLUME || (IS_ADJUST_GV_FUNC(cf.func) && cf.all.mode == FUNC_ADJUST_GVAR_SOURCE)) {
|
||||
cf.all.val = convertSource_218_to_219(cf.all.val);
|
||||
}
|
||||
}
|
||||
|
||||
newModel.swashR = oldModel.swashR;
|
||||
|
@ -169,4 +219,24 @@ void convertModelData_218_to_219(ModelData &model)
|
|||
sizeof(newModel.screenData) +
|
||||
sizeof(newModel.topbarData))
|
||||
#endif
|
||||
|
||||
newModel.screensType = oldModel.frsky.screensType;
|
||||
memmove(&newModel.screens, &oldModel.frsky.screens, sizeof(newModel.screens));
|
||||
#if defined(PCBX7)
|
||||
for (int i=0; i<MAX_TELEMETRY_SCREENS; i++) {
|
||||
uint8_t screenType = (newModel.screensType >> (2*i)) & 0x03;
|
||||
if (screenType == TELEMETRY_SCREEN_TYPE_VALUES) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
for (int k = 0; k < NUM_LINE_ITEMS; k++) {
|
||||
newModel.screens[i].lines[j].sources[k] = convertSource_218_to_219(newModel.screens[i].lines[j].sources[k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (screenType == TELEMETRY_SCREEN_TYPE_GAUGES) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
newModel.screens[i].bars[j].source = convertSource_218_to_219(newModel.screens[i].bars[j].source);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -269,8 +269,8 @@ char * getSwitchString(char * dest, swsrc_t idx)
|
|||
else {
|
||||
*s++ = 'S';
|
||||
#if defined(PCBX7)
|
||||
if (swinfo.quot == 5)
|
||||
*s++ = 'H';
|
||||
if (swinfo.quot >= 5)
|
||||
*s++ = 'H' + swinfo.quot - 5;
|
||||
else if (swinfo.quot == 4)
|
||||
*s++ = 'F';
|
||||
else
|
||||
|
|
|
@ -274,6 +274,8 @@ void simuSetSwitch(uint8_t swtch, int8_t state)
|
|||
#if defined(PCBX7)
|
||||
SWITCH_CASE (4, SWITCHES_GPIO_REG_F, SWITCHES_GPIO_PIN_F)
|
||||
SWITCH_CASE (5, SWITCHES_GPIO_REG_H, SWITCHES_GPIO_PIN_H)
|
||||
SWITCH_CASE (6, SWITCHES_GPIO_REG_I, SWITCHES_GPIO_PIN_I)
|
||||
SWITCH_CASE (7, SWITCHES_GPIO_REG_J, SWITCHES_GPIO_PIN_J)
|
||||
#elif defined(PCBXLITES)
|
||||
SWITCH_CASE (4, SWITCHES_GPIO_REG_E, SWITCHES_GPIO_PIN_E)
|
||||
SWITCH_CASE (5, SWITCHES_GPIO_REG_F, SWITCHES_GPIO_PIN_F)
|
||||
|
|
|
@ -367,6 +367,14 @@ enum EnumSwitchesPositions
|
|||
SW_SH1,
|
||||
SW_SH2,
|
||||
#endif
|
||||
#if defined(PCBX7)
|
||||
SW_SI0,
|
||||
SW_SI1,
|
||||
SW_SI2,
|
||||
SW_SJ0,
|
||||
SW_SJ1,
|
||||
SW_SJ2,
|
||||
#endif
|
||||
#if defined(PCBX9E)
|
||||
SW_SI0,
|
||||
SW_SI1,
|
||||
|
@ -406,7 +414,7 @@ enum EnumSwitchesPositions
|
|||
#elif defined(PCBXLITE)
|
||||
#define NUM_SWITCHES 4
|
||||
#elif defined(PCBX7)
|
||||
#define NUM_SWITCHES 6
|
||||
#define NUM_SWITCHES 8
|
||||
#elif defined(PCBX9LITE)
|
||||
#define NUM_SWITCHES 5
|
||||
#elif defined(PCBX9E)
|
||||
|
@ -414,6 +422,11 @@ enum EnumSwitchesPositions
|
|||
#else
|
||||
#define NUM_SWITCHES 8
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
static_assert(NUM_SWITCHES_POSITIONS == NUM_SWITCHES * 3, "Wrong switches positions count");
|
||||
#endif
|
||||
|
||||
void keysInit(void);
|
||||
uint8_t keyState(uint8_t index);
|
||||
uint32_t switchState(uint8_t index);
|
||||
|
|
|
@ -378,6 +378,14 @@
|
|||
#define SWITCHES_GPIO_PIN_H GPIO_Pin_13 // PE.13
|
||||
#endif
|
||||
|
||||
// X7 P400 P401 headers additionnal momentary switches
|
||||
#if defined(PCBX7)
|
||||
#define SWITCHES_GPIO_REG_I GPIOC->IDR
|
||||
#define SWITCHES_GPIO_PIN_I GPIO_Pin_13 //PC.13
|
||||
#define SWITCHES_GPIO_REG_J GPIOC->IDR
|
||||
#define SWITCHES_GPIO_PIN_J GPIO_Pin_10 //PC.10
|
||||
#endif
|
||||
|
||||
#if defined(PCBX9E)
|
||||
#define SWITCHES_GPIO_REG_I_H GPIOF->IDR
|
||||
#define SWITCHES_GPIO_PIN_I_H GPIO_Pin_15 // PF.15
|
||||
|
@ -452,7 +460,7 @@
|
|||
#elif defined(PCBX7)
|
||||
#define KEYS_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_GPIOE)
|
||||
#define KEYS_GPIOA_PINS SWITCHES_GPIO_PIN_B_H
|
||||
#define KEYS_GPIOC_PINS (TRIMS_GPIO_PIN_LHR | TRIMS_GPIO_PIN_RVD | TRIMS_GPIO_PIN_RVU)
|
||||
#define KEYS_GPIOC_PINS (TRIMS_GPIO_PIN_LHR | TRIMS_GPIO_PIN_RVD | TRIMS_GPIO_PIN_RVU | SWITCHES_GPIO_PIN_I | SWITCHES_GPIO_PIN_J)
|
||||
#define KEYS_GPIOD_PINS (TRIMS_GPIO_PIN_LHL | KEYS_GPIO_PIN_MENU | KEYS_GPIO_PIN_EXIT | KEYS_GPIO_PIN_PAGE | SWITCHES_GPIO_PIN_C_L | SWITCHES_GPIO_PIN_H)
|
||||
#define KEYS_GPIOE_PINS (ROTARY_ENCODER_GPIO_PIN_A | ROTARY_ENCODER_GPIO_PIN_B | KEYS_GPIO_PIN_ENTER | TRIMS_GPIO_PIN_RHR | TRIMS_GPIO_PIN_RHL | TRIMS_GPIO_PIN_LVD | TRIMS_GPIO_PIN_LVU | SWITCHES_GPIO_PIN_C_H | SWITCHES_GPIO_PIN_D_L | SWITCHES_GPIO_PIN_D_H | SWITCHES_GPIO_PIN_B_L | SWITCHES_GPIO_PIN_A_L | SWITCHES_GPIO_PIN_A_H | SWITCHES_GPIO_PIN_F)
|
||||
#elif defined(PCBX9LITE)
|
||||
|
|
|
@ -55,3 +55,39 @@ TEST(Eeprom, ConversionX9DPFrom22)
|
|||
EXPECT_EQ(10, g_model.telemetrySensors[0].frskyInstance.physID);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PCBX7)
|
||||
TEST(Eeprom, ConversionX7From22)
|
||||
{
|
||||
loadEEPROMFile(TESTS_PATH "/tests/eeprom_22_x7.bin");
|
||||
|
||||
eepromOpen();
|
||||
convertModelData(0, 218);
|
||||
eeLoadModel(0);
|
||||
|
||||
EXPECT_ZSTREQ("Test", g_model.header.name);
|
||||
EXPECT_EQ(MODULE_TYPE_PXX_R9M, g_model.moduleData[EXTERNAL_MODULE].type);
|
||||
EXPECT_EQ(MODULE_SUBTYPE_R9M_EU, g_model.moduleData[EXTERNAL_MODULE].subType);
|
||||
EXPECT_EQ(80, g_model.mixData[0].weight);
|
||||
EXPECT_EQ(80, g_model.expoData[0].weight);
|
||||
EXPECT_EQ(MIXSRC_FIRST_TRAINER, g_model.mixData[4].srcRaw);
|
||||
EXPECT_EQ(SWSRC_TELEMETRY_STREAMING, g_model.mixData[4].swtch);
|
||||
EXPECT_EQ(SWASH_TYPE_120X, g_model.swashR.type);
|
||||
EXPECT_ZSTREQ("Thr", g_model.inputNames[0]);
|
||||
|
||||
EXPECT_ZSTREQ("Tes", g_model.telemetrySensors[0].label);
|
||||
EXPECT_EQ(10, g_model.telemetrySensors[0].id);
|
||||
EXPECT_EQ(10, g_model.telemetrySensors[0].frskyInstance.physID);
|
||||
EXPECT_EQ(-100, g_model.limitData[0].max);
|
||||
|
||||
EXPECT_EQ(10, g_model.flightModeData[0].gvars[0]);
|
||||
EXPECT_ZSTREQ("Tes", g_model.gvars[0].name);
|
||||
|
||||
EXPECT_EQ(LS_FUNC_VPOS, g_model.logicalSw[0].func);
|
||||
EXPECT_EQ(MIXSRC_FIRST_TRAINER, g_model.logicalSw[0].v1);
|
||||
EXPECT_EQ(0, g_model.logicalSw[0].v2);
|
||||
|
||||
EXPECT_EQ(TELEMETRY_SCREEN_TYPE_VALUES, g_model.screensType & 0x03);
|
||||
EXPECT_EQ(MIXSRC_FIRST_TRAINER, g_model.screens[0].lines[0].sources[0]);
|
||||
}
|
||||
#endif
|
||||
|
|
BIN
radio/src/tests/eeprom_22_x7.bin
Normal file
BIN
radio/src/tests/eeprom_22_x7.bin
Normal file
Binary file not shown.
|
@ -132,7 +132,7 @@ TEST(evalLogicalSwitches, playFile)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(PCBTARANIS) && NUM_SWITCHES >= 8
|
||||
#if defined(PCBTARANIS) && NUM_SWITCHES >= 8 && !defined(PCBX7)
|
||||
TEST(getSwitch, edgeInstant)
|
||||
{
|
||||
MODEL_RESET();
|
||||
|
|
|
@ -417,8 +417,8 @@
|
|||
#define TR_SW_VSRCRAW "\312SA\0""\312SB\0""\312SC\0""\312SD\0"
|
||||
#elif defined(PCBX7)
|
||||
#define TR_POTS_VSRCRAW "\310S1\0""\310S2\0"
|
||||
#define TR_SW_VSRCRAW "\312SA\0""\312SB\0""\312SC\0""\312SD\0""\312SF\0""\312SH\0"
|
||||
#elif defined(PCBX9LITE)
|
||||
#define TR_SW_VSRCRAW "\312SA\0""\312SB\0""\312SC\0""\312SD\0""\312SF\0""\312SH\0""\312SI\0""\312SJ\0"
|
||||
#elif defined(PCBX3)
|
||||
#define TR_POTS_VSRCRAW "\310S1\0"
|
||||
#define TR_SW_VSRCRAW "\312SA\0""\312SB\0""\312SC\0""\312SD\0""\312SE\0"
|
||||
#elif defined(PCBTARANIS)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue