1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-25 17:25:13 +03:00

XJT2 channel count can only be 8, 16 or 24

This commit is contained in:
3djc 2019-02-22 10:31:54 +01:00
parent a90b1c43de
commit 16e54f27e0
4 changed files with 19 additions and 8 deletions

View file

@ -1099,7 +1099,7 @@ void menuModelSetup(event_t event)
CHECK_INCDEC_MODELVAR_ZERO(event, moduleData.channelsStart, 32-8-moduleData.channelsCount);
break;
case 1:
CHECK_INCDEC_MODELVAR(event, moduleData.channelsCount, -4, min<int8_t>(maxModuleChannels_M8(moduleIdx), 32-8-moduleData.channelsStart));
CHECK_INCDEC_MODELVAR_CHECK(event, moduleData.channelsCount, -4, min<int8_t>(maxModuleChannels_M8(moduleIdx), 32-8-moduleData.channelsStart), isInternalModuleChannelCountAvailable);
if ((k == ITEM_MODEL_EXTERNAL_MODULE_CHANNELS && g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_PPM)) {
SET_DEFAULT_PPM_FRAME_LENGTH(moduleIdx);
}

View file

@ -56,6 +56,7 @@ bool isSwitchAvailableInTimers(int swtch);
bool isR9MModeAvailable(int mode);
bool isR9ModuleRunning(int module);
bool isR9MMFlex(int module);
bool isInternalModuleChannelCountAvailable(int module);
bool isExternalModuleAvailable(int module);
bool isInternalModuleAvailable(int module);
bool isRfProtocolAvailable(int protocol);
@ -115,7 +116,7 @@ void runFatalErrorScreen(const char * message);
void lcdDrawMMM(coord_t x, coord_t y, LcdFlags flags=0);
// model_setup Defines that are used in all uis in the same way
#define INTERNAL_MODULE_CHANNELS_ROWS IF_INTERNAL_MODULE_ON((isModuleXJT2(INTERNAL_MODULE) ? (uint8_t)0 : (uint8_t)1))
#define INTERNAL_MODULE_CHANNELS_ROWS IF_INTERNAL_MODULE_ON((uint8_t)1)
#define EXTERNAL_MODULE_CHANNELS_ROWS IF_EXTERNAL_MODULE_ON((isModuleXJT2(EXTERNAL_MODULE) || isModuleDSM2(EXTERNAL_MODULE) || isModuleCrossfire(EXTERNAL_MODULE) || isModuleSBUS(EXTERNAL_MODULE) || (isModuleMultimodule(EXTERNAL_MODULE) && g_model.moduleData[EXTERNAL_MODULE].getMultiProtocol(true) != MM_RF_PROTO_DSM2)) ? (uint8_t)0 : (uint8_t)1)

View file

@ -515,6 +515,16 @@ bool isR9MMFlex(int module)
return g_model.moduleData[module].r9m.region == MODULE_R9M_REGION_FLEX;
}
bool isInternalModuleChannelCountAvailable(int channels)
{
if (g_model.moduleData[INTERNAL_MODULE].type == MODULE_TYPE_XJT2) {
if ( channels % 8 != 0)
return false;
}
return true;
}
bool isInternalModuleAvailable(int module)
{
if (module == MODULE_TYPE_NONE)

View file

@ -199,8 +199,8 @@ inline bool isModuleDSM2(uint8_t idx)
}
#endif
// order is the same as in enum Protocols in myeeprom.h (none, ppm, pxx, dsm, crossfire, multi, r9m, sbus)
static const int8_t maxChannelsModules[] = { 0, 8, 8, -2, 8, 4, 8, 8}; // relative to 8!
// order is the same as in enum Protocols in myeeprom.h (none, ppm, pxx, pxx2, dsm, crossfire, multi, r9m, r9m2, sbus)
static const int8_t maxChannelsModules[] = { 0, 8, 8, 16, -2, 8, 4, 8, 16, 8}; // relative to 8!
static const int8_t maxChannelsXJT[] = { 0, 8, 0, 4 }; // relative to 8!
constexpr int8_t MAX_TRAINER_CHANNELS_M8 = MAX_TRAINER_CHANNELS - 8;
@ -242,7 +242,7 @@ inline int8_t sentModuleChannels(uint8_t idx)
{
if (isModuleCrossfire(idx))
return CROSSFIRE_CHANNELS_COUNT;
else if ((isModuleMultimodule(idx) && !isModuleMultimoduleDSM2(idx)) || isModuleXJT2(idx))
else if (isModuleMultimodule(idx) && !isModuleMultimoduleDSM2(idx))
return 16;
else
return 8 + g_model.moduleData[idx].channelsCount;