External antenna configuration: proposal for #4285 (#6656)

External antenna configuration
This commit is contained in:
Bertrand Songis
2019-09-06 11:26:18 +02:00
committed by GitHub
parent 5d2aefaefb
commit 6c530c6f7b
80 changed files with 1669 additions and 1253 deletions
@@ -24,26 +24,26 @@ void onBindMenu(const char * result)
uint8_t moduleIdx = CURRENT_MODULE_EDITED(menuVerticalPosition - HEADER_LINE);
if (result == STR_BINDING_1_8_TELEM_ON) {
g_model.moduleData[moduleIdx].pxx.receiver_telem_off = false;
g_model.moduleData[moduleIdx].pxx.receiver_channel_9_16 = false;
g_model.moduleData[moduleIdx].pxx.receiverTelemetryOff = false;
g_model.moduleData[moduleIdx].pxx.receiverHigherChannels = false;
if (isModuleR9MLiteNonPro(moduleIdx) && isModuleR9M_LBT(moduleIdx)) {
g_model.moduleData[moduleIdx].pxx.power = R9M_LITE_LBT_POWER_25_8CH;
}
}
else if (result == STR_BINDING_1_8_TELEM_OFF) {
g_model.moduleData[moduleIdx].pxx.receiver_telem_off = true;
g_model.moduleData[moduleIdx].pxx.receiver_channel_9_16 = false;
g_model.moduleData[moduleIdx].pxx.receiverTelemetryOff = true;
g_model.moduleData[moduleIdx].pxx.receiverHigherChannels = false;
if (isModuleR9MLiteNonPro(moduleIdx) && isModuleR9M_LBT(moduleIdx)) {
g_model.moduleData[moduleIdx].pxx.power = R9M_LITE_LBT_POWER_100_16CH_NOTELEM;
}
}
else if (result == STR_BINDING_9_16_TELEM_ON) {
g_model.moduleData[moduleIdx].pxx.receiver_telem_off = false;
g_model.moduleData[moduleIdx].pxx.receiver_channel_9_16 = true;
g_model.moduleData[moduleIdx].pxx.receiverTelemetryOff = false;
g_model.moduleData[moduleIdx].pxx.receiverHigherChannels = true;
}
else if (result == STR_BINDING_9_16_TELEM_OFF) {
g_model.moduleData[moduleIdx].pxx.receiver_telem_off = true;
g_model.moduleData[moduleIdx].pxx.receiver_channel_9_16 = true;
g_model.moduleData[moduleIdx].pxx.receiverTelemetryOff = true;
g_model.moduleData[moduleIdx].pxx.receiverHigherChannels = true;
}
else {
return;
@@ -66,13 +66,13 @@ void startBindMenu(uint8_t moduleIdx)
POPUP_MENU_ADD_ITEM(STR_BINDING_9_16_TELEM_OFF);
}
if (isBindCh9To16Allowed(moduleIdx) && g_model.moduleData[moduleIdx].pxx.receiver_channel_9_16) {
if (isBindCh9To16Allowed(moduleIdx) && g_model.moduleData[moduleIdx].pxx.receiverHigherChannels) {
selection += 1;
if (isTelemAllowedOnBind(moduleIdx))
selection += 1;
}
if (isTelemAllowedOnBind(moduleIdx) && g_model.moduleData[moduleIdx].pxx.receiver_telem_off)
if (isTelemAllowedOnBind(moduleIdx) && g_model.moduleData[moduleIdx].pxx.receiverTelemetryOff)
selection += 1;
POPUP_MENU_SELECT_ITEM(selection);
+11 -6
View File
@@ -107,11 +107,14 @@ enum
inline void POPUP_CONFIRMATION(const char * s, PopupMenuHandler handler)
{
warningText = s;
warningInfoText = nullptr;
warningType = WARNING_TYPE_CONFIRM;
popupFunc = runPopupWarning;
popupMenuHandler = handler;
if (s != warningText) {
killAllEvents();
warningText = s;
warningInfoText = nullptr;
warningType = WARNING_TYPE_CONFIRM;
popupFunc = runPopupWarning;
popupMenuHandler = handler;
}
}
inline void POPUP_INPUT(const char * s, PopupFunc func)
@@ -144,8 +147,9 @@ enum
inline void POPUP_MENU_ADD_ITEM(const char * s)
{
popupMenuOffsetType = MENU_OFFSET_INTERNAL;
if (popupMenuItemsCount < POPUP_MENU_MAX_LINES)
if (popupMenuItemsCount < POPUP_MENU_MAX_LINES) {
popupMenuItems[popupMenuItemsCount++] = s;
}
}
#if defined(SDCARD)
@@ -162,6 +166,7 @@ inline void POPUP_MENU_SELECT_ITEM(uint8_t index)
inline void POPUP_MENU_START(PopupMenuHandler handler)
{
if (handler != popupMenuHandler) {
killAllEvents();
AUDIO_KEY_PRESS();
popupMenuHandler = handler;
}
+43 -1
View File
@@ -18,7 +18,7 @@
* GNU General Public License for more details.
*/
#include "opentx.h"
#include <opentx.h>
#if defined(PCBSKY9X)
#define HW_SETTINGS_COLUMN (2+(15*FW))
@@ -169,6 +169,10 @@ enum {
ITEM_RADIO_HARDWARE_BLUETOOTH_NAME,
#endif
#if defined(INTERNAL_MODULE_PXX1) && defined(EXTERNAL_ANTENNA)
ITEM_RADIO_HARDWARE_EXTERNAL_ANTENNA,
#endif
#if defined(AUX_SERIAL)
ITEM_RADIO_HARDWARE_AUX_SERIAL_MODE,
#endif
@@ -221,6 +225,23 @@ enum {
#define BLUETOOTH_ROWS uint8_t(IS_BLUETOOTH_CHIP_PRESENT() ? 0 : HIDDEN_ROW), uint8_t(g_eeGeneral.bluetoothMode == BLUETOOTH_TELEMETRY ? -1 : HIDDEN_ROW), uint8_t(g_eeGeneral.bluetoothMode == BLUETOOTH_OFF ? HIDDEN_ROW : -1), uint8_t(g_eeGeneral.bluetoothMode == BLUETOOTH_OFF ? HIDDEN_ROW : -1), uint8_t(g_eeGeneral.bluetoothMode == BLUETOOTH_OFF ? HIDDEN_ROW : 0),
#endif
#if defined(INTERNAL_MODULE_PXX1) && defined(EXTERNAL_ANTENNA)
#define EXTERNAL_ANTENNA_ROW 0,
void onHardwareAntennaSwitchConfirm(const char * result)
{
if (result == STR_OK) {
// Switch to external antenna confirmation
g_eeGeneral.antennaMode = reusableBuffer.radioHardware.antennaMode;
storageDirty(EE_GENERAL);
}
else {
reusableBuffer.radioHardware.antennaMode = g_eeGeneral.antennaMode;
}
}
#else
#define EXTERNAL_ANTENNA_ROW
#endif
#if defined(PCBX9LITE)
#define SWITCH_TYPE_MAX(sw) (sw == MIXSRC_SD-MIXSRC_FIRST_SWITCH ? SWITCH_2POS : SWITCH_3POS)
#elif defined(PCBXLITES)
@@ -298,6 +319,8 @@ void menuRadioHardware(event_t event)
BLUETOOTH_ROWS
EXTERNAL_ANTENNA_ROW
AUX_SERIAL_ROWS
0 /* ADC filter */,
@@ -324,6 +347,9 @@ void menuRadioHardware(event_t event)
}
else if (event == EVT_ENTRY) {
enableVBatBridge();
#if defined(INTERNAL_MODULE_PXX1) && defined(EXTERNAL_ANTENNA)
reusableBuffer.radioHardware.antennaMode = g_eeGeneral.antennaMode;
#endif
}
for (uint8_t i=0; i<NUM_BODY_LINES; i++) {
@@ -546,6 +572,22 @@ void menuRadioHardware(event_t event)
break;
#endif
#if defined(INTERNAL_MODULE_PXX1) && defined(EXTERNAL_ANTENNA)
case ITEM_RADIO_HARDWARE_EXTERNAL_ANTENNA:
reusableBuffer.radioHardware.antennaMode = editChoice(HW_SETTINGS_COLUMN2, y, STR_ANTENNA, STR_ANTENNA_MODES, reusableBuffer.radioHardware.antennaMode, ANTENNA_MODE_INTERNAL, ANTENNA_MODE_EXTERNAL, attr, event);
if (!s_editMode && reusableBuffer.radioHardware.antennaMode != g_eeGeneral.antennaMode) {
if (!isExternalAntennaEnabled() && (reusableBuffer.radioHardware.antennaMode == ANTENNA_MODE_EXTERNAL || (reusableBuffer.radioHardware.antennaMode == ANTENNA_MODE_PER_MODEL && g_model.moduleData[INTERNAL_MODULE].pxx.antennaMode == ANTENNA_MODE_EXTERNAL))) {
POPUP_CONFIRMATION(STR_ANTENNACONFIRM1, onHardwareAntennaSwitchConfirm);
SET_WARNING_INFO(STR_ANTENNACONFIRM2, sizeof(TR_ANTENNACONFIRM2), 0);
}
else {
g_eeGeneral.antennaMode = reusableBuffer.radioHardware.antennaMode;
checkExternalAntenna();
}
}
break;
#endif
#if defined(AUX_SERIAL)
case ITEM_RADIO_HARDWARE_AUX_SERIAL_MODE:
g_eeGeneral.auxSerialMode = editChoice(HW_SETTINGS_COLUMN2, y, STR_AUX_SERIAL_MODE, STR_AUX_SERIAL_MODES, g_eeGeneral.auxSerialMode, 0, UART_MODE_MAX, attr, event);
+4 -4
View File
@@ -85,16 +85,16 @@ void menuRadioTools(event_t event)
uint8_t index = 0;
#if defined(PXX2)
if (isPXX2ModuleOptionAvailable(reusableBuffer.hardwareAndSettings.modules[INTERNAL_MODULE].information.modelID, MODULE_OPTION_SPECTRUM_ANALYSER))
if (isPXX2ModuleOptionAvailable(reusableBuffer.radioTools.modules[INTERNAL_MODULE].information.modelID, MODULE_OPTION_SPECTRUM_ANALYSER))
addRadioModuleTool(index++, STR_SPECTRUM_ANALYSER_INT, menuRadioSpectrumAnalyser, INTERNAL_MODULE);
if (isPXX2ModuleOptionAvailable(reusableBuffer.hardwareAndSettings.modules[INTERNAL_MODULE].information.modelID, MODULE_OPTION_POWER_METER))
if (isPXX2ModuleOptionAvailable(reusableBuffer.radioTools.modules[INTERNAL_MODULE].information.modelID, MODULE_OPTION_POWER_METER))
addRadioModuleTool(index++, STR_POWER_METER_INT, menuRadioPowerMeter, INTERNAL_MODULE);
if (isPXX2ModuleOptionAvailable(reusableBuffer.hardwareAndSettings.modules[EXTERNAL_MODULE].information.modelID, MODULE_OPTION_SPECTRUM_ANALYSER))
if (isPXX2ModuleOptionAvailable(reusableBuffer.radioTools.modules[EXTERNAL_MODULE].information.modelID, MODULE_OPTION_SPECTRUM_ANALYSER))
addRadioModuleTool(index++, STR_SPECTRUM_ANALYSER_EXT, menuRadioSpectrumAnalyser, EXTERNAL_MODULE);
if (isPXX2ModuleOptionAvailable(reusableBuffer.hardwareAndSettings.modules[EXTERNAL_MODULE].information.modelID, MODULE_OPTION_POWER_METER))
if (isPXX2ModuleOptionAvailable(reusableBuffer.radioTools.modules[EXTERNAL_MODULE].information.modelID, MODULE_OPTION_POWER_METER))
addRadioModuleTool(index++, STR_POWER_METER_EXT, menuRadioPowerMeter, EXTERNAL_MODULE);
#endif