Reduce RF_PROTO_OFF logic, disable R9M Sport out when internal telemetry is on (#5159)
* Remove most of the special logic associated with RF_PROTO_OFF This simplifies code in many areas since the internal module does not require special handling and also fixes a few bugs with INTERNAL_PPM * Disable R9M sport option if internal module has telemetry * Fix X12s build * Use macros instead of direct comparisions * Fix sport bit sent the wrong way. Rename S.port out to Telemetry * Compile fix
This commit is contained in:
committed by
Bertrand Songis
parent
8e84724c62
commit
e16b48db30
@@ -127,13 +127,8 @@ enum MenuModelSetupItems {
|
||||
#else
|
||||
#define INTERNAL_MODULE_MODE_ROWS (IS_MODULE_XJT(INTERNAL_MODULE) ? (uint8_t)1 : (uint8_t)0) // Module type + RF protocols
|
||||
#endif
|
||||
#if defined(TARANIS_INTERNAL_PPM)
|
||||
#define IF_INTERNAL_MODULE_ON(x) (g_model.moduleData[INTERNAL_MODULE].type == MODULE_TYPE_NONE ? HIDDEN_ROW : (uint8_t)(x))
|
||||
#else
|
||||
#define IF_INTERNAL_MODULE_ON(x) (g_model.moduleData[INTERNAL_MODULE].rfProtocol == RF_PROTO_OFF ? HIDDEN_ROW : (uint8_t)(x))
|
||||
#endif
|
||||
|
||||
#define IF_EXTERNAL_MODULE_ON(x) (g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_NONE ? HIDDEN_ROW : (uint8_t)(x))
|
||||
#define IF_INTERNAL_MODULE_ON(x) (IS_INTERNAL_MODULE_ENABLED()? (uint8_t)(x) : HIDDEN_ROW )
|
||||
#define IF_EXTERNAL_MODULE_ON(x) (IS_EXTERNAL_MODULE_ENABLED()? (uint8_t)(x) : HIDDEN_ROW)
|
||||
#define INTERNAL_MODULE_CHANNELS_ROWS IF_INTERNAL_MODULE_ON(1)
|
||||
#define EXTERNAL_MODULE_BIND_ROWS() (IS_MODULE_XJT(EXTERNAL_MODULE) && IS_D8_RX(EXTERNAL_MODULE)) ? (uint8_t)1 : (IS_MODULE_PPM(EXTERNAL_MODULE) || IS_MODULE_PXX(EXTERNAL_MODULE) || IS_MODULE_DSM2(EXTERNAL_MODULE) || IS_MODULE_MULTIMODULE(EXTERNAL_MODULE)) ? (uint8_t)2 : HIDDEN_ROW
|
||||
|
||||
@@ -684,6 +679,8 @@ void menuModelSetup(event_t event)
|
||||
g_model.moduleData[0].type = MODULE_TYPE_XJT;
|
||||
g_model.moduleData[0].channelsStart = 0;
|
||||
g_model.moduleData[0].channelsCount = DEFAULT_CHANNELS(INTERNAL_MODULE);
|
||||
if (g_model.moduleData[INTERNAL_MODULE].rfProtocol == RF_PROTO_OFF)
|
||||
g_model.moduleData[INTERNAL_MODULE].type = MODULE_TYPE_NONE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1082,7 +1079,13 @@ void menuModelSetup(event_t event)
|
||||
}
|
||||
#endif
|
||||
if (IS_MODULE_R9M(moduleIdx)) {
|
||||
g_model.moduleData[moduleIdx].pxx.sport_out = editCheckBox(g_model.moduleData[EXTERNAL_MODULE].pxx.sport_out, MODEL_SETUP_2ND_COLUMN, y, STR_SPORT_OUT, attr, event);
|
||||
if (IS_TELEMETRY_INTERNAL_MODULE) {
|
||||
lcdDrawTextAlignedLeft(y, STR_SPORT_OUT);
|
||||
lcdDrawText(MODEL_SETUP_2ND_COLUMN, y, STR_DISABLE_INTERNAL);
|
||||
}
|
||||
else {
|
||||
g_model.moduleData[moduleIdx].pxx.sport_out = editCheckBox(g_model.moduleData[EXTERNAL_MODULE].pxx.sport_out, MODEL_SETUP_2ND_COLUMN, y, STR_SPORT_OUT, attr, event);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ enum MenuModelTelemetryFrskyItems {
|
||||
|
||||
|
||||
#if defined (PCBTARANIS)
|
||||
#define TELEMETRY_TYPE_SHOW_TELEMETRY (g_model.moduleData[INTERNAL_MODULE].rfProtocol == RF_PROTO_OFF && g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_PPM) ? (uint8_t)0 : HIDDEN_ROW
|
||||
#define TELEMETRY_TYPE_SHOW_TELEMETRY (! IS_INTERNAL_MODULE_ENABLED() && g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_PPM) ? (uint8_t)0 : HIDDEN_ROW
|
||||
#elif defined (CPUARM)
|
||||
#define TELEMETRY_TYPE_SHOW_TELEMETRY (g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_PPM) ? (uint8_t)0 : HIDDEN_ROW
|
||||
#endif
|
||||
|
||||
@@ -231,14 +231,13 @@ int getSwitchWarningsCount()
|
||||
return count;
|
||||
}
|
||||
|
||||
#define IF_INTERNAL_MODULE_ON(x) (IS_INTERNAL_MODULE_ENABLED() ? (uint8_t)(x) : HIDDEN_ROW)
|
||||
#if defined(TARANIS_INTERNAL_PPM)
|
||||
#define IF_INTERNAL_MODULE_ON(x) (g_model.moduleData[INTERNAL_MODULE].type == MODULE_TYPE_NONE ? HIDDEN_ROW : (uint8_t)(x))
|
||||
#define INTERNAL_MODULE_MODE_ROWS (IS_MODULE_XJT(INTERNAL_MODULE) ? (uint8_t)1 : (uint8_t)0) // Module type + RF protocols
|
||||
#else
|
||||
#define IF_INTERNAL_MODULE_ON(x) (g_model.moduleData[INTERNAL_MODULE].rfProtocol == RF_PROTO_OFF ? HIDDEN_ROW : (uint8_t)(x))
|
||||
#define INTERNAL_MODULE_MODE_ROWS 0 // (OFF / RF protocols)
|
||||
#endif
|
||||
#define IF_EXTERNAL_MODULE_ON(x) (g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_NONE ? HIDDEN_ROW : (uint8_t)(x))
|
||||
#define IF_EXTERNAL_MODULE_ON(x) (IS_EXTERNAL_MODULE_ENABLED() ? (uint8_t)(x) : HIDDEN_ROW)
|
||||
#define INTERNAL_MODULE_CHANNELS_ROWS IF_INTERNAL_MODULE_ON(1)
|
||||
#define PORT_CHANNELS_ROWS(x) (x==INTERNAL_MODULE ? INTERNAL_MODULE_CHANNELS_ROWS : (x==EXTERNAL_MODULE ? EXTERNAL_MODULE_CHANNELS_ROWS : 1))
|
||||
|
||||
@@ -704,11 +703,14 @@ void menuModelSetup(event_t event)
|
||||
lcdDrawTextAlignedLeft(y, STR_MODE);
|
||||
lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN, y, STR_XJT_PROTOCOLS, 1+g_model.moduleData[0].rfProtocol, attr);
|
||||
if (attr) {
|
||||
g_model.moduleData[INTERNAL_MODULE].rfProtocol = checkIncDec(event, g_model.moduleData[INTERNAL_MODULE].rfProtocol, RF_PROTO_OFF, RF_PROTO_LAST, EE_MODEL, isRfProtocolAvailable);
|
||||
g_model.moduleData[INTERNAL_MODULE].rfProtocol = checkIncDec(event, g_model.moduleData[INTERNAL_MODULE].rfProtocol, -1, RF_PROTO_LAST, EE_MODEL, isRfProtocolAvailable);
|
||||
|
||||
if (checkIncDec_Ret) {
|
||||
g_model.moduleData[INTERNAL_MODULE].type = MODULE_TYPE_XJT;
|
||||
g_model.moduleData[INTERNAL_MODULE].channelsStart = 0;
|
||||
g_model.moduleData[INTERNAL_MODULE].channelsCount = DEFAULT_CHANNELS(INTERNAL_MODULE);
|
||||
if (g_model.moduleData[INTERNAL_MODULE].rfProtocol == RF_PROTO_OFF)
|
||||
g_model.moduleData[INTERNAL_MODULE].type = MODULE_TYPE_NONE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1079,7 +1081,13 @@ void menuModelSetup(event_t event)
|
||||
}
|
||||
#endif
|
||||
if (IS_MODULE_R9M(moduleIdx)) {
|
||||
g_model.moduleData[moduleIdx].pxx.sport_out = editCheckBox(g_model.moduleData[EXTERNAL_MODULE].pxx.sport_out, MODEL_SETUP_2ND_COLUMN, y, STR_SPORT_OUT, attr, event);
|
||||
if (IS_TELEMETRY_INTERNAL_MODULE) {
|
||||
lcdDrawTextAlignedLeft(y, STR_SPORT_OUT);
|
||||
lcdDrawText(MODEL_SETUP_2ND_COLUMN, y, STR_DISABLE_INTERNAL);
|
||||
}
|
||||
else {
|
||||
g_model.moduleData[moduleIdx].pxx.sport_out = editCheckBox(g_model.moduleData[EXTERNAL_MODULE].pxx.sport_out, MODEL_SETUP_2ND_COLUMN, y, STR_SPORT_OUT, attr, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -88,7 +88,7 @@ enum MenuModelTelemetryFrskyItems {
|
||||
#endif
|
||||
#define RSSI_ROWS LABEL(RSSI), 0, 0, 0,
|
||||
#define VARIO_RANGE_ROWS 3
|
||||
#define TELEMETRY_TYPE_ROWS (g_model.moduleData[INTERNAL_MODULE].rfProtocol == RF_PROTO_OFF && g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_PPM) ? (uint8_t)0 : HIDDEN_ROW,
|
||||
#define TELEMETRY_TYPE_ROWS (!IS_INTERNAL_MODULE_ENABLED() && g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_PPM) ? (uint8_t)0 : HIDDEN_ROW,
|
||||
|
||||
enum SensorFields {
|
||||
SENSOR_FIELD_NAME,
|
||||
@@ -516,7 +516,7 @@ void menuModelTelemetryFrsky(event_t event)
|
||||
|
||||
case ITEM_TELEMETRY_RSSI_LABEL:
|
||||
#if defined(MULTIMODULE)
|
||||
if (g_model.moduleData[INTERNAL_MODULE].rfProtocol == RF_PROTO_OFF &&
|
||||
if (g_model.moduleData[INTERNAL_MODULE].type != MODULE_TYPE_XJT &&
|
||||
g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_MULTIMODULE &&
|
||||
g_model.moduleData[EXTERNAL_MODULE].getMultiProtocol(false) == MM_RF_PROTO_FS_AFHDS2A)
|
||||
lcdDrawTextAlignedLeft(y, PSTR("RSNR"));
|
||||
|
||||
@@ -209,8 +209,8 @@ int getSwitchWarningsCount()
|
||||
return count;
|
||||
}
|
||||
|
||||
#define IF_INTERNAL_MODULE_ON(x) (g_model.moduleData[INTERNAL_MODULE].rfProtocol == RF_PROTO_OFF ? HIDDEN_ROW : (uint8_t)(x))
|
||||
#define IF_EXTERNAL_MODULE_ON(x) (g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_NONE ? HIDDEN_ROW : (uint8_t)(x))
|
||||
#define IF_INTERNAL_MODULE_ON(x) (IS_INTERNAL_MODULE_ENABLED() ? (uint8_t)(x) : HIDDEN_ROW)
|
||||
#define IF_EXTERNAL_MODULE_ON(x) (IS_EXTERNAL_MODULE_ENABLED() ? (uint8_t)(x) : HIDDEN_ROW)
|
||||
|
||||
#define INTERNAL_MODULE_MODE_ROWS (uint8_t)0
|
||||
#define INTERNAL_MODULE_CHANNELS_ROWS IF_INTERNAL_MODULE_ON(1)
|
||||
@@ -624,7 +624,10 @@ bool menuModelSetup(event_t event)
|
||||
g_model.moduleData[0].type = MODULE_TYPE_XJT;
|
||||
g_model.moduleData[0].channelsStart = 0;
|
||||
g_model.moduleData[0].channelsCount = DEFAULT_CHANNELS(INTERNAL_MODULE);
|
||||
if (g_model.moduleData[INTERNAL_MODULE].rfProtocol == RF_PROTO_OFF)
|
||||
g_model.moduleData[INTERNAL_MODULE].type = MODULE_TYPE_NONE;
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -978,8 +981,13 @@ bool menuModelSetup(event_t event)
|
||||
#endif
|
||||
if (IS_MODULE_R9M(moduleIdx)) {
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_SPORT_OUT);
|
||||
g_model.moduleData[moduleIdx].pxx.sport_out = editCheckBox(g_model.moduleData[EXTERNAL_MODULE].pxx.sport_out, MODEL_SETUP_2ND_COLUMN, y, attr, event);
|
||||
if (IS_TELEMETRY_INTERNAL_MODULE) {
|
||||
lcdDrawText(MODEL_SETUP_2ND_COLUMN, y, STR_DISABLE_INTERNAL);
|
||||
}
|
||||
else {
|
||||
g_model.moduleData[moduleIdx].pxx.sport_out = editCheckBox(g_model.moduleData[EXTERNAL_MODULE].pxx.sport_out, MODEL_SETUP_2ND_COLUMN, y, attr, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ITEM_MODEL_EXTERNAL_MODULE_POWER: {
|
||||
|
||||
@@ -158,7 +158,8 @@ const mm_protocol_definition *getMultiProtocolDefinition (uint8_t protocol);
|
||||
#define IS_R9M_OR_XJTD16(x) ((IS_MODULE_XJT(x) && g_model.moduleData[x].rfProtocol== RF_PROTO_X16) || IS_MODULE_R9M(x))
|
||||
|
||||
#define FAILSAFE_ROWS(x) ((IS_MODULE_XJT(x) && HAS_RF_PROTOCOL_FAILSAFE(g_model.moduleData[x].rfProtocol)) || MULTIMODULE_HASFAILSAFE(x) || IS_MODULE_R9M(x)) ? (g_model.moduleData[x].failsafeMode==FAILSAFE_CUSTOM ? (uint8_t)1 : (uint8_t)0) : HIDDEN_ROW
|
||||
#define EXTERNAL_MODULE_OPTION_ROW (IS_MODULE_R9M(EXTERNAL_MODULE) ? (uint8_t) 0 : MULTIMODULE_OPTIONS_ROW)
|
||||
#define R9M_OPTION_ROW (IS_TELEMETRY_INTERNAL_MODULE ? TITLE_ROW : (uint8_t) 0)
|
||||
#define EXTERNAL_MODULE_OPTION_ROW (IS_MODULE_R9M(EXTERNAL_MODULE) ? R9M_OPTION_ROW : MULTIMODULE_OPTIONS_ROW)
|
||||
#define EXTERNAL_MODULE_POWER_ROW (IS_MODULE_MULTIMODULE(EXTERNAL_MODULE) || IS_MODULE_R9M(EXTERNAL_MODULE)) ? (uint8_t) 0 : HIDDEN_ROW
|
||||
|
||||
void editStickHardwareSettings(coord_t x, coord_t y, int idx, event_t event, LcdFlags flags);
|
||||
|
||||
@@ -490,7 +490,7 @@ bool isSourceAvailableInResetSpecialFunction(int index)
|
||||
bool isModuleAvailable(int module)
|
||||
{
|
||||
#if defined(CROSSFIRE) && !defined(PCBFLAMENCO)
|
||||
if (module == MODULE_TYPE_CROSSFIRE && g_model.moduleData[INTERNAL_MODULE].rfProtocol != RF_PROTO_OFF) {
|
||||
if (module == MODULE_TYPE_CROSSFIRE && g_model.moduleData[INTERNAL_MODULE].type != MODULE_TYPE_NONE) {
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
@@ -563,7 +563,7 @@ bool isTrainerModeAvailable(int mode)
|
||||
#elif defined(PCBX9E)
|
||||
bool isTrainerModeAvailable(int mode)
|
||||
{
|
||||
if (IS_EXTERNAL_MODULE_PRESENT() && (mode == TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE || mode == TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE))
|
||||
if (IS_EXTERNAL_MODULE_ENABLED() && (mode == TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE || mode == TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE))
|
||||
return false;
|
||||
#if defined(DEBUG)
|
||||
else if (mode == TRAINER_MODE_MASTER_BLUETOOTH || mode == TRAINER_MODE_MASTER_BATTERY_COMPARTMENT)
|
||||
@@ -577,7 +577,7 @@ bool isTrainerModeAvailable(int mode)
|
||||
#elif defined(PCBX9)
|
||||
bool isTrainerModeAvailable(int mode)
|
||||
{
|
||||
if (IS_EXTERNAL_MODULE_PRESENT() && (mode == TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE || mode == TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE))
|
||||
if (IS_EXTERNAL_MODULE_ENABLED() && (mode == TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE || mode == TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE))
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user