This commit is contained in:
Bertrand Songis
2019-02-08 15:31:23 +01:00
parent f696050350
commit c73746ef1c
5 changed files with 45 additions and 26 deletions
+9 -4
View File
@@ -311,7 +311,7 @@ void menuModelSetup(event_t event)
IF_PXX2(0), // Model Number
ANTENNA_ROW
IF_PXX2_RECEIVER_DISPLAYED(INTERNAL_MODULE, 0, 1), // Range check and Register buttons
IF_PXX2_RECEIVER_DISPLAYED(INTERNAL_MODULE, 0, 0), // Receiver Number
IF_PXX2_RECEIVER_DISPLAYED(INTERNAL_MODULE, 0, HIDDEN_ROW), // Receiver Number
IF_PXX2_RECEIVER_DISPLAYED(INTERNAL_MODULE, 0, 0), // Receiver Range
IF_PXX2_RECEIVER_DISPLAYED(INTERNAL_MODULE, 0, 0), // Receiver Telemetry
IF_PXX2_RECEIVER_DISPLAYED(INTERNAL_MODULE, 0, 1), // Receiver Bind/Delete
@@ -801,7 +801,11 @@ void menuModelSetup(event_t event)
if (attr && (editMode>0 || p1valdiff)) {
switch (menuHorizontalPosition) {
case 0:
g_model.moduleData[EXTERNAL_MODULE].type = checkIncDec(event, g_model.moduleData[EXTERNAL_MODULE].type, MODULE_TYPE_NONE, IS_TRAINER_EXTERNAL_MODULE() ? MODULE_TYPE_NONE : MODULE_TYPE_COUNT-1, EE_MODEL, isModuleAvailable);
g_model.moduleData[EXTERNAL_MODULE].type = checkIncDec(event, g_model.moduleData[EXTERNAL_MODULE].type,
MODULE_TYPE_NONE,
IS_TRAINER_EXTERNAL_MODULE() ? MODULE_TYPE_NONE :
MODULE_TYPE_COUNT - 1, EE_MODEL,
isExternalModuleAvailable);
if (checkIncDec_Ret) {
g_model.moduleData[EXTERNAL_MODULE].rfProtocol = 0;
g_model.moduleData[EXTERNAL_MODULE].channelsStart = 0;
@@ -1092,10 +1096,12 @@ void menuModelSetup(event_t event)
if (g_model.moduleData[INTERNAL_MODULE].pxx2.receivers[0].enabled) {
g_model.moduleData[INTERNAL_MODULE].pxx2.receivers[1].enabled = 0x01;
memcpy(&g_model.moduleData[INTERNAL_MODULE].pxx2.receivers[1].channelMapping, DEFAULT_CHANNEL_MAPPING, sizeof(uint64_t));
menuVerticalPosition = ITEM_MODEL_INTERNAL_MODULE_PXX2_RECEIVER_2_BIND_DEL + 1;
}
else {
g_model.moduleData[INTERNAL_MODULE].pxx2.receivers[0].enabled = 0x01;
memcpy(&g_model.moduleData[INTERNAL_MODULE].pxx2.receivers[0].channelMapping, DEFAULT_CHANNEL_MAPPING, sizeof(uint64_t));
menuVerticalPosition = ITEM_MODEL_INTERNAL_MODULE_PXX2_RECEIVER_1_BIND_DEL + 1;
}
s_editMode = 0;
}
@@ -1107,7 +1113,6 @@ void menuModelSetup(event_t event)
uint8_t receiverIdx = CURRENT_RECEIVER_EDITED(k);
lcdDrawTextAlignedLeft(y, INDENT "Receiver");
lcdDrawNumber(lcdLastRightPos + 3, y, receiverIdx + 1);
}
break;
@@ -1145,7 +1150,7 @@ void menuModelSetup(event_t event)
{
uint8_t receiverIdx = CURRENT_RECEIVER_EDITED(k);
for (uint8_t pos=0; pos<PXX2_LEN_REGISTRATION_ID; pos++) {
lcdDrawHexChar(6 + pos*FW*2, y, g_model.moduleData[INTERNAL_MODULE].pxx2.receivers[receiverIdx].rxID[pos], menuHorizontalPosition==pos ? attr : 0);
lcdDrawHexChar(6 + pos*FW*2, y, g_model.moduleData[INTERNAL_MODULE].pxx2.receivers[receiverIdx].rxID[pos], 0);
}
lcdDrawText(MODEL_SETUP_2ND_COLUMN, y, STR_MODULE_BIND, menuHorizontalPosition==0 ? attr : 0);
lcdDrawText(MODEL_SETUP_2ND_COLUMN+MODEL_SETUP_RANGE_OFS, y, STR_DEL_BUTTON, menuHorizontalPosition==1 ? attr : 0);
+3 -1
View File
@@ -717,7 +717,9 @@ bool menuModelSetup(event_t event)
if (attr && s_editMode>0) {
switch (menuHorizontalPosition) {
case 0:
g_model.moduleData[EXTERNAL_MODULE].type = checkIncDec(event, g_model.moduleData[EXTERNAL_MODULE].type, MODULE_TYPE_NONE, MODULE_TYPE_COUNT-1, EE_MODEL, isModuleAvailable);
g_model.moduleData[EXTERNAL_MODULE].type = checkIncDec(event, g_model.moduleData[EXTERNAL_MODULE].type,
MODULE_TYPE_NONE, MODULE_TYPE_COUNT - 1, EE_MODEL,
isExternalModuleAvailable);
if (checkIncDec_Ret) {
g_model.moduleData[EXTERNAL_MODULE].rfProtocol = 0;
g_model.moduleData[EXTERNAL_MODULE].channelsStart = 0;
+1 -1
View File
@@ -56,7 +56,7 @@ bool isSwitchAvailableInTimers(int swtch);
bool isR9MModeAvailable(int mode);
bool isR9ModuleRunning(int module);
bool isR9MMFlex(int module);
bool isModuleAvailable(int module);
bool isExternalModuleAvailable(int module);
bool isInternalModuleAvailable(int module);
bool isRfProtocolAvailable(int protocol);
bool isTelemetryProtocolAvailable(int protocol);
+1 -1
View File
@@ -526,7 +526,7 @@ bool isInternalModuleAvailable(int module)
return false;
}
bool isModuleAvailable(int module)
bool isExternalModuleAvailable(int module)
{
#if defined(CROSSFIRE)
if (module == MODULE_TYPE_CROSSFIRE && g_model.moduleData[INTERNAL_MODULE].type != MODULE_TYPE_NONE) {
+31 -19
View File
@@ -27,44 +27,56 @@ ModuleSettings moduleSettings[NUM_MODULES];
ModulePulsesData modulePulsesData[NUM_MODULES] __DMA;
TrainerPulsesData trainerPulsesData __DMA;
uint8_t getModuleType(uint8_t module)
{
uint8_t type = g_model.moduleData[module].type;
if (module == INTERNAL_MODULE && isInternalModuleAvailable(type)) {
return type;
}
if (module == EXTERNAL_MODULE && isExternalModuleAvailable(type)) {
return type;
}
return MODULE_TYPE_NONE;
}
uint8_t getRequiredProtocol(uint8_t module)
{
uint8_t required_protocol;
uint8_t protocol;
switch (g_model.moduleData[module].type) {
switch (getModuleType(module)) {
case MODULE_TYPE_PPM:
required_protocol = PROTOCOL_CHANNELS_PPM;
protocol = PROTOCOL_CHANNELS_PPM;
break;
case MODULE_TYPE_XJT:
required_protocol = PROTOCOL_CHANNELS_PXX;
protocol = PROTOCOL_CHANNELS_PXX;
break;
case MODULE_TYPE_XJT2:
case MODULE_TYPE_R9M:
required_protocol = PROTOCOL_CHANNELS_PXX2;
protocol = PROTOCOL_CHANNELS_PXX2;
break;
case MODULE_TYPE_SBUS:
required_protocol = PROTOCOL_CHANNELS_SBUS;
protocol = PROTOCOL_CHANNELS_SBUS;
break;
#if defined(MULTIMODULE)
case MODULE_TYPE_MULTIMODULE:
required_protocol = PROTOCOL_CHANNELS_MULTIMODULE;
protocol = PROTOCOL_CHANNELS_MULTIMODULE;
break;
#endif
#if defined(DSM2)
case MODULE_TYPE_DSM2:
required_protocol = limit<uint8_t>(PROTOCOL_CHANNELS_DSM2_LP45, PROTOCOL_CHANNELS_DSM2_LP45+g_model.moduleData[module].rfProtocol, PROTOCOL_CHANNELS_DSM2_DSMX);
protocol = limit<uint8_t>(PROTOCOL_CHANNELS_DSM2_LP45, PROTOCOL_CHANNELS_DSM2_LP45+g_model.moduleData[module].rfProtocol, PROTOCOL_CHANNELS_DSM2_DSMX);
// The module is set to OFF during one second before BIND start
{
static tmr10ms_t bindStartTime = 0;
if (moduleSettings[module].mode == MODULE_MODE_BIND) {
if (bindStartTime == 0) bindStartTime = get_tmr10ms();
if ((tmr10ms_t)(get_tmr10ms() - bindStartTime) < 100) {
required_protocol = PROTOCOL_CHANNELS_NONE;
protocol = PROTOCOL_CHANNELS_NONE;
break;
}
}
@@ -77,27 +89,27 @@ uint8_t getRequiredProtocol(uint8_t module)
#if defined(CROSSFIRE)
case MODULE_TYPE_CROSSFIRE:
required_protocol = PROTOCOL_CHANNELS_CROSSFIRE;
protocol = PROTOCOL_CHANNELS_CROSSFIRE;
break;
#endif
default:
required_protocol = PROTOCOL_CHANNELS_NONE;
protocol = PROTOCOL_CHANNELS_NONE;
break;
}
if (s_pulses_paused) {
required_protocol = PROTOCOL_CHANNELS_NONE;
protocol = PROTOCOL_CHANNELS_NONE;
}
#if 0
// will need an EEPROM conversion
if (moduleSettings[module].mode == MODULE_OFF) {
required_protocol = PROTOCOL_CHANNELS_NONE;
protocol = PROTOCOL_CHANNELS_NONE;
}
#endif
return required_protocol;
return protocol;
}
void setupPulsesPXX(uint8_t module)
@@ -258,18 +270,18 @@ void setupPulses(uint8_t module, uint8_t protocol)
bool setupPulses(uint8_t module)
{
uint8_t required_protocol = getRequiredProtocol(module);
uint8_t protocol = getRequiredProtocol(module);
heartbeat |= (HEART_TIMER_PULSES << module);
if (moduleSettings[module].protocol != required_protocol) {
if (moduleSettings[module].protocol != protocol) {
disablePulses(module, moduleSettings[module].protocol);
moduleSettings[module].protocol = required_protocol;
enablePulses(module, required_protocol);
moduleSettings[module].protocol = protocol;
enablePulses(module, protocol);
return false;
}
else {
setupPulses(module, required_protocol);
setupPulses(module, protocol);
return true;
}
}