Merge branch '2.3' into 3djc/TX16s-2.3

This commit is contained in:
3djc
2020-04-03 09:58:55 +02:00
77 changed files with 1942 additions and 1375 deletions
@@ -46,14 +46,18 @@ void onRxOptionsUpdateConfirm(const char * result)
enum {
ITEM_RECEIVER_SETTINGS_PWM_RATE,
ITEM_RECEIVER_SETTINGS_TELEMETRY,
ITEM_RECEIVER_SETTINGS_TELEMETRY_25MW,
ITEM_RECEIVER_SETTINGS_SPORT_FPORT,
ITEM_RECEIVER_SETTINGS_CAPABILITY_NOT_SUPPORTED1,
ITEM_RECEIVER_SETTINGS_CAPABILITY_NOT_SUPPORTED2,
ITEM_RECEIVER_SETTINGS_PINMAP_FIRST
};
#define IS_RECEIVER_CAPABILITY_ENABLED(capability) (reusableBuffer.hardwareAndSettings.modules[g_moduleIdx].receivers[receiverId].information.capabilities & (1 << capability))
#define IF_RECEIVER_CAPABILITY(capability, count) uint8_t(IS_RECEIVER_CAPABILITY_ENABLED(capability) ? count : HIDDEN_ROW)
#define IF_RECEIVER_CAPABILITY(capability, count) uint8_t((reusableBuffer.hardwareAndSettings.modules[g_moduleIdx].receivers[receiverId].information.capabilities & (1 << capability)) ? count : HIDDEN_ROW)
#define CH_ENABLE_SPORT 4
#define CH_ENABLE_SBUS 5
bool menuModelReceiverOptions(event_t event)
{
@@ -76,6 +80,7 @@ bool menuModelReceiverOptions(event_t event)
SUBMENU(STR_RECEIVER_OPTIONS, ICON_MODEL_SETUP, ITEM_RECEIVER_SETTINGS_PINMAP_FIRST + outputsCount, {
0, // PWM rate
isModuleR9MAccess(g_moduleIdx) && receiverVariant == PXX2_VARIANT_EU && reusableBuffer.hardwareAndSettings.moduleSettings.txPower > 14 /*25mW*/ ? READONLY_ROW : (uint8_t)0, // Telemetry
IF_RECEIVER_CAPABILITY(RECEIVER_CAPABILITY_TELEMETRY_25MW, 0),
IF_RECEIVER_CAPABILITY(RECEIVER_CAPABILITY_FPORT, 0),
uint8_t(reusableBuffer.hardwareAndSettings.modules[g_moduleIdx].receivers[receiverId].information.capabilityNotSupported ? READONLY_ROW : HIDDEN_ROW),
uint8_t(reusableBuffer.hardwareAndSettings.modules[g_moduleIdx].receivers[receiverId].information.capabilityNotSupported ? READONLY_ROW : HIDDEN_ROW),
@@ -156,6 +161,14 @@ bool menuModelReceiverOptions(event_t event)
}
break;
case ITEM_RECEIVER_SETTINGS_TELEMETRY_25MW:
lcdDrawText(MENUS_MARGIN_LEFT, y, "25mw Tele");
reusableBuffer.hardwareAndSettings.receiverSettings.telemetry25mw = editCheckBox(reusableBuffer.hardwareAndSettings.receiverSettings.telemetry25mw, RECEIVER_OPTIONS_2ND_COLUMN, y, attr, event);
if (attr && checkIncDec_Ret) {
reusableBuffer.hardwareAndSettings.receiverSettings.dirty = RECEIVER_SETTINGS_DIRTY;
}
break;
case ITEM_RECEIVER_SETTINGS_SPORT_FPORT:
lcdDrawText(MENUS_MARGIN_LEFT, y, "F.Port");
reusableBuffer.hardwareAndSettings.receiverSettings.fport = editCheckBox(reusableBuffer.hardwareAndSettings.receiverSettings.fport, RECEIVER_OPTIONS_2ND_COLUMN, y, attr, event);
@@ -182,21 +195,43 @@ bool menuModelReceiverOptions(event_t event)
int32_t channelValue = channelOutputs[channel];
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_PIN);
lcdDrawNumber(lcdNextPos + 1, y, pin + 1);
putsChn(100, y, channel + 1, attr);
uint8_t channelMax = sentModuleChannels(g_moduleIdx) - 1;
uint8_t selectionMax = channelMax;
if (IS_RECEIVER_CAPABILITY_ENABLED(RECEIVER_CAPABILITY_ENABLE_PWM_CH5_CH6)) {
if (CH_ENABLE_SPORT == pin || CH_ENABLE_SBUS == pin) {
selectionMax += 1;
}
if (CH_ENABLE_SPORT == pin && selectionMax == channel) {
lcdDrawText(100, y, "S.PORT", attr);
}
else if (CH_ENABLE_SBUS == pin && selectionMax == channel) {
lcdDrawText(100, y, "SBUS", attr);
}
else {
putsChn(100, y, channel + 1, attr);
}
}
else {
putsChn(100, y, channel + 1, attr);
}
// Channel
if (attr) {
mapping = checkIncDec(event, mapping, 0, sentModuleChannels(g_moduleIdx) - 1);
mapping = checkIncDec(event, mapping, 0, selectionMax);
if (checkIncDec_Ret) {
reusableBuffer.hardwareAndSettings.receiverSettings.dirty = RECEIVER_SETTINGS_DIRTY;
}
}
// Bargraph
lcdDrawRect(RECEIVER_OPTIONS_2ND_COLUMN, y + 4, wbar + 1, 10);
const uint8_t lenChannel = limit<uint8_t>(1, (abs(channelValue) * wbar / 2 + lim / 2) / lim, wbar / 2);
const coord_t xChannel = (channelValue > 0) ? RECEIVER_OPTIONS_2ND_COLUMN + wbar / 2 : RECEIVER_OPTIONS_2ND_COLUMN + wbar / 2 + 1 - lenChannel;
lcdDrawSolidFilledRect(xChannel, y + 5, lenChannel, 8, TEXT_INVERTED_BGCOLOR);
if (channel <= channelMax) {
lcdDrawRect(RECEIVER_OPTIONS_2ND_COLUMN, y + 4, wbar + 1, 10);
auto lenChannel = limit<uint8_t>(1, (abs(channelValue) * wbar / 2 + lim / 2) / lim, wbar / 2);
auto xChannel = (channelValue > 0) ? RECEIVER_OPTIONS_2ND_COLUMN + wbar / 2 : RECEIVER_OPTIONS_2ND_COLUMN + wbar / 2 + 1 - lenChannel;
lcdDrawSolidFilledRect(xChannel, y + 5, lenChannel, 8, TEXT_INVERTED_BGCOLOR);
}
}
break;
}
+1 -1
View File
@@ -46,7 +46,7 @@ void showAlertBox(const char * title, const char * text, const char * action, ui
lcdRefresh();
lcdSetContrast();
waitKeysReleased();
backlightOn();
resetBacklightTimeout();
checkBacklight();
}
-9
View File
@@ -23,7 +23,6 @@
constexpr coord_t LEFT_NAME_COLUMN = MENUS_MARGIN_LEFT;
constexpr coord_t RIGHT_NAME_COLUMN = LCD_W / 2;
constexpr coord_t ANA_OFFSET = 150;
constexpr coord_t RAS_TOP_POSITION = LCD_H - 45;
bool menuRadioDiagAnalogs(event_t event)
{
@@ -49,14 +48,6 @@ bool menuRadioDiagAnalogs(event_t event)
#endif
}
// RAS
if ((isModuleXJT(INTERNAL_MODULE) && IS_INTERNAL_MODULE_ON()) || (isModulePXX1(EXTERNAL_MODULE) && !IS_INTERNAL_MODULE_ON())) {
lcdDrawText(MENUS_MARGIN_LEFT, RAS_TOP_POSITION, "RAS : ");
lcdDrawNumber(lcdNextPos, RAS_TOP_POSITION, telemetryData.swrInternal.value(), 0);
lcdDrawText(LCD_W / 2, RAS_TOP_POSITION, "XJTVER : ");
lcdDrawNumber(lcdNextPos, RAS_TOP_POSITION, telemetryData.xjtVersion, 0);
}
#if (NUM_PWMSTICKS > 0) && !defined(SIMU)
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + 8 * FH, STICKS_PWM_ENABLED() ? "Sticks: PWM" : "Sticks: ANA");
#endif
+47 -25
View File
@@ -72,6 +72,8 @@ enum MenuRadioHardwareItems {
#endif
ITEM_RADIO_HARDWARE_JITTER_FILTER,
ITEM_RADIO_HARDWARE_RAS,
#if defined(SPORT_UPDATE_PWR_GPIO)
ITEM_RADIO_HARDWARE_SPORT_UPDATE_POWER,
#endif
@@ -79,7 +81,8 @@ enum MenuRadioHardwareItems {
ITEM_RADIO_HARDWARE_MAX
};
#define HW_SETTINGS_COLUMN 150
#define HW_SETTINGS_COLUMN1 150
#define HW_SETTINGS_COLUMN2 200
#if defined(AUX_SERIAL)
#define AUX_SERIAL_ROW 0,
@@ -157,6 +160,7 @@ bool menuRadioHardware(event_t event)
AUX_SERIAL_ROW /* aux serial mode */
0, /* ADC filter */
READONLY_ROW /* RAS */,
SPORT_POWER_ROWS
1, /* Debug */
});
@@ -197,7 +201,7 @@ bool menuRadioHardware(event_t event)
case ITEM_RADIO_HARDWARE_STICK2:
case ITEM_RADIO_HARDWARE_STICK3:
case ITEM_RADIO_HARDWARE_STICK4:
editStickHardwareSettings(HW_SETTINGS_COLUMN, y, k - ITEM_RADIO_HARDWARE_STICK1, event, attr);
editStickHardwareSettings(HW_SETTINGS_COLUMN1, y, k - ITEM_RADIO_HARDWARE_STICK1, event, attr);
break;
case ITEM_RADIO_HARDWARE_LS:
@@ -211,11 +215,11 @@ bool menuRadioHardware(event_t event)
uint8_t mask = (0x01 << idx);
lcdDrawTextAtIndex(INDENT_WIDTH, y, STR_VSRCRAW, NUM_STICKS+NUM_POTS+idx+1, menuHorizontalPosition < 0 ? attr : 0);
if (ZEXIST(g_eeGeneral.anaNames[NUM_STICKS+NUM_POTS+idx]) || (attr && menuHorizontalPosition == 0))
editName(HW_SETTINGS_COLUMN, y, g_eeGeneral.anaNames[NUM_STICKS+NUM_POTS+idx], LEN_ANA_NAME, event, attr && menuHorizontalPosition == 0);
editName(HW_SETTINGS_COLUMN1, y, g_eeGeneral.anaNames[NUM_STICKS+NUM_POTS+idx], LEN_ANA_NAME, event, attr && menuHorizontalPosition == 0);
else
lcdDrawMMM(HW_SETTINGS_COLUMN, y, 0);
lcdDrawMMM(HW_SETTINGS_COLUMN1, y, 0);
uint8_t potType = (g_eeGeneral.slidersConfig & mask) >> idx;
potType = editChoice(HW_SETTINGS_COLUMN+50, y, STR_SLIDERTYPES, potType, SLIDER_NONE, SLIDER_WITH_DETENT, menuHorizontalPosition == 1 ? attr : 0, event);
potType = editChoice(HW_SETTINGS_COLUMN2, y, STR_SLIDERTYPES, potType, SLIDER_NONE, SLIDER_WITH_DETENT, menuHorizontalPosition == 1 ? attr : 0, event);
g_eeGeneral.slidersConfig &= ~mask;
g_eeGeneral.slidersConfig |= (potType << idx);
break;
@@ -236,11 +240,11 @@ bool menuRadioHardware(event_t event)
int index = k - ITEM_RADIO_HARDWARE_POT1;
lcdDrawTextAtIndex(INDENT_WIDTH, y, STR_VSRCRAW, NUM_STICKS+index+1, menuHorizontalPosition < 0 ? attr : 0);
if (ZEXIST(g_eeGeneral.anaNames[NUM_STICKS+index]) || (attr && menuHorizontalPosition == 0))
editName(HW_SETTINGS_COLUMN, y, g_eeGeneral.anaNames[NUM_STICKS+index], LEN_ANA_NAME, event, attr && menuHorizontalPosition == 0);
editName(HW_SETTINGS_COLUMN1, y, g_eeGeneral.anaNames[NUM_STICKS+index], LEN_ANA_NAME, event, attr && menuHorizontalPosition == 0);
else
lcdDrawMMM(HW_SETTINGS_COLUMN, y, 0);
lcdDrawMMM(HW_SETTINGS_COLUMN1, y, 0);
uint32_t potType = bfGet<uint32_t>(g_eeGeneral.potsConfig, 2*(index), 2);
potType = editChoice(HW_SETTINGS_COLUMN+50, y, STR_POTTYPES, potType, POT_NONE, POT_WITHOUT_DETENT, menuHorizontalPosition == 1 ? attr : 0, event);
potType = editChoice(HW_SETTINGS_COLUMN2, y, STR_POTTYPES, potType, POT_NONE, POT_WITHOUT_DETENT, menuHorizontalPosition == 1 ? attr : 0, event);
g_eeGeneral.potsConfig = bfSet<uint32_t>(g_eeGeneral.potsConfig, potType, 2*index, 2);
break;
}
@@ -264,10 +268,10 @@ bool menuRadioHardware(event_t event)
int config = SWITCH_CONFIG(index);
lcdDrawTextAtIndex(INDENT_WIDTH, y, STR_VSRCRAW, MIXSRC_FIRST_SWITCH-MIXSRC_Rud+index+1, menuHorizontalPosition < 0 ? attr : 0);
if (ZEXIST(g_eeGeneral.switchNames[index]) || (attr && menuHorizontalPosition == 0))
editName(HW_SETTINGS_COLUMN, y, g_eeGeneral.switchNames[index], LEN_SWITCH_NAME, event, menuHorizontalPosition == 0 ? attr : 0);
editName(HW_SETTINGS_COLUMN1, y, g_eeGeneral.switchNames[index], LEN_SWITCH_NAME, event, menuHorizontalPosition == 0 ? attr : 0);
else
lcdDrawMMM(HW_SETTINGS_COLUMN, y, 0);
config = editChoice(HW_SETTINGS_COLUMN+50, y, STR_SWTYPES, config, SWITCH_NONE, SWITCH_TYPE_MAX(index), menuHorizontalPosition == 1 ? attr : 0, event);
lcdDrawMMM(HW_SETTINGS_COLUMN1, y, 0);
config = editChoice(HW_SETTINGS_COLUMN2, y, STR_SWTYPES, config, SWITCH_NONE, SWITCH_TYPE_MAX(index), menuHorizontalPosition == 1 ? attr : 0, event);
if (attr && checkIncDec_Ret) {
g_eeGeneral.switchConfig = bfSet<swconfig_t>(g_eeGeneral.switchConfig, config, 2*index, 2);
}
@@ -276,18 +280,18 @@ bool menuRadioHardware(event_t event)
case ITEM_RADIO_HARDWARE_BATTERY_CALIB:
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_BATT_CALIB);
lcdDrawNumber(HW_SETTINGS_COLUMN+50, y, getBatteryVoltage(), attr|PREC2, 0, NULL, "V");
lcdDrawNumber(HW_SETTINGS_COLUMN2, y, getBatteryVoltage(), attr|PREC2, 0, NULL, "V");
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.txVoltageCalibration, -127, 127);
break;
case ITEM_RADIO_HARDWARE_RTC_BATTERY:
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_RTC_BATT);
lcdDrawNumber(HW_SETTINGS_COLUMN+50, y, getRTCBatteryVoltage(), attr|PREC2, 0, NULL, "V");
lcdDrawNumber(HW_SETTINGS_COLUMN2, y, getRTCBatteryVoltage(), attr|PREC2, 0, NULL, "V");
break;
case ITEM_RADIO_HARDWARE_SERIAL_BAUDRATE:
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_MAXBAUDRATE);
lcdDrawNumber(HW_SETTINGS_COLUMN+50, y, CROSSFIRE_BAUDRATES[g_eeGeneral.telemetryBaudrate], attr|LEFT);
lcdDrawNumber(HW_SETTINGS_COLUMN2, y, CROSSFIRE_BAUDRATES[g_eeGeneral.telemetryBaudrate], attr|LEFT);
if (attr) {
g_eeGeneral.telemetryBaudrate = DIM(CROSSFIRE_BAUDRATES) - 1 - checkIncDecModel(event, DIM(CROSSFIRE_BAUDRATES) - 1 - g_eeGeneral.telemetryBaudrate, 0, DIM(CROSSFIRE_BAUDRATES) - 1);
if (checkIncDec_Ret && IS_EXTERNAL_MODULE_ON()) {
@@ -307,40 +311,40 @@ bool menuRadioHardware(event_t event)
{
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_RTC_CHECK);
uint8_t b = 1 - g_eeGeneral.disableRtcWarning;
g_eeGeneral.disableRtcWarning = 1 - editCheckBox(b, HW_SETTINGS_COLUMN + 50, y, attr, event);
g_eeGeneral.disableRtcWarning = 1 - editCheckBox(b, HW_SETTINGS_COLUMN2, y, attr, event);
break;
}
#if defined(BLUETOOTH)
case ITEM_RADIO_HARDWARE_BLUETOOTH_MODE:
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_BLUETOOTH);
g_eeGeneral.bluetoothMode = editChoice(HW_SETTINGS_COLUMN+50, y, STR_BLUETOOTH_MODES, g_eeGeneral.bluetoothMode, BLUETOOTH_OFF, BLUETOOTH_TRAINER, attr, event);
g_eeGeneral.bluetoothMode = editChoice(HW_SETTINGS_COLUMN2, y, STR_BLUETOOTH_MODES, g_eeGeneral.bluetoothMode, BLUETOOTH_OFF, BLUETOOTH_TRAINER, attr, event);
break;
case ITEM_RADIO_HARDWARE_BLUETOOTH_PAIRING_CODE:
lcdDrawText(INDENT_WIDTH, y, STR_BLUETOOTH_PIN_CODE);
lcdDrawText(HW_SETTINGS_COLUMN+50, y, "000000", 0);
lcdDrawText(HW_SETTINGS_COLUMN2, y, "000000", 0);
break;
case ITEM_RADIO_HARDWARE_BLUETOOTH_LOCAL_ADDR:
lcdDrawText(INDENT_WIDTH, y, STR_BLUETOOTH_LOCAL_ADDR);
lcdDrawText(HW_SETTINGS_COLUMN+50, y, bluetooth.localAddr[0] == '\0' ? "---" : bluetooth.localAddr);
lcdDrawText(HW_SETTINGS_COLUMN2, y, bluetooth.localAddr[0] == '\0' ? "---" : bluetooth.localAddr);
break;
case ITEM_RADIO_HARDWARE_BLUETOOTH_DISTANT_ADDR:
lcdDrawText(INDENT_WIDTH, y, STR_BLUETOOTH_DIST_ADDR);
lcdDrawText(HW_SETTINGS_COLUMN+50, y, bluetooth.distantAddr[0] == '\0' ? "---" : bluetooth.distantAddr);
lcdDrawText(HW_SETTINGS_COLUMN2, y, bluetooth.distantAddr[0] == '\0' ? "---" : bluetooth.distantAddr);
break;
case ITEM_RADIO_HARDWARE_BLUETOOTH_NAME:
lcdDrawText(INDENT_WIDTH, y, STR_NAME);
editName(HW_SETTINGS_COLUMN+50, y, g_eeGeneral.bluetoothName, LEN_BLUETOOTH_NAME, event, attr);
editName(HW_SETTINGS_COLUMN2, y, g_eeGeneral.bluetoothName, LEN_BLUETOOTH_NAME, event, attr);
break;
#endif
#if defined(INTERNAL_MODULE_PXX1) && defined(EXTERNAL_ANTENNA)
case ITEM_RADIO_HARDWARE_EXTERNAL_ANTENNA:
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_ANTENNA);
reusableBuffer.radioHardware.antennaMode = editChoice(HW_SETTINGS_COLUMN+50, y, STR_ANTENNA_MODES, reusableBuffer.radioHardware.antennaMode, ANTENNA_MODE_INTERNAL, ANTENNA_MODE_EXTERNAL, attr, event);
reusableBuffer.radioHardware.antennaMode = editChoice(HW_SETTINGS_COLUMN2, y, 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);
@@ -360,7 +364,7 @@ bool menuRadioHardware(event_t event)
#if defined(RADIO_TX16S)
lcdDrawText(lcdNextPos, y, " (TTL)");
#endif
g_eeGeneral.auxSerialMode = editChoice(HW_SETTINGS_COLUMN+50, y, STR_AUX_SERIAL_MODES, g_eeGeneral.auxSerialMode, 0, UART_MODE_MAX, attr, event);
g_eeGeneral.auxSerialMode = editChoice(HW_SETTINGS_COLUMN2, y, STR_AUX_SERIAL_MODES, g_eeGeneral.auxSerialMode, 0, UART_MODE_MAX, attr, event);
if (attr && checkIncDec_Ret) {
auxSerialInit(g_eeGeneral.auxSerialMode, modelTelemetryProtocol());
}
@@ -371,14 +375,32 @@ bool menuRadioHardware(event_t event)
{
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_JITTER_FILTER);
uint8_t b = 1 - g_eeGeneral.jitterFilter;
g_eeGeneral.jitterFilter = 1 - editCheckBox(b, HW_SETTINGS_COLUMN+50, y, attr, event);
g_eeGeneral.jitterFilter = 1 - editCheckBox(b, HW_SETTINGS_COLUMN2, y, attr, event);
break;
}
case ITEM_RADIO_HARDWARE_RAS:
#if defined(HARDWARE_INTERNAL_RAS)
lcdDrawText(MENUS_MARGIN_LEFT, y, "RAS");
if (telemetryData.swrInternal.isFresh())
lcdDrawNumber(HW_SETTINGS_COLUMN2, y, telemetryData.swrInternal.value());
else
lcdDrawText(HW_SETTINGS_COLUMN2, y, "---");
lcdDrawText(lcdNextPos, y, "/");
#else
lcdDrawText(MENUS_MARGIN_LEFT, y, "Ext. RAS");
lcdNextPos = HW_SETTINGS_COLUMN2;
#endif
if (telemetryData.swrExternal.isFresh())
lcdDrawNumber(lcdNextPos, y, telemetryData.swrExternal.value());
else
lcdDrawText(lcdNextPos, y, "---");
break;
#if defined(SPORT_UPDATE_PWR_GPIO)
case ITEM_RADIO_HARDWARE_SPORT_UPDATE_POWER:
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_SPORT_UPDATE_POWER_MODE);
g_eeGeneral.sportUpdatePower = editChoice(HW_SETTINGS_COLUMN + 50, y, STR_SPORT_UPDATE_POWER_MODES, g_eeGeneral.sportUpdatePower, 0, 1, attr, event);
g_eeGeneral.sportUpdatePower = editChoice(HW_SETTINGS_COLUMN2, y, STR_SPORT_UPDATE_POWER_MODES, g_eeGeneral.sportUpdatePower, 0, 1, attr, event);
if (attr && checkIncDec_Ret) {
SPORT_UPDATE_POWER_INIT();
}
@@ -387,7 +409,7 @@ bool menuRadioHardware(event_t event)
case ITEM_RADIO_HARDWARE_DEBUG:
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_DEBUG);
lcdDrawText(HW_SETTINGS_COLUMN + 50, y, STR_ANALOGS_BTN, menuHorizontalPosition == 0 ? attr : 0);
lcdDrawText(HW_SETTINGS_COLUMN2, y, STR_ANALOGS_BTN, menuHorizontalPosition == 0 ? attr : 0);
lcdDrawText(lcdNextPos + 10, y, STR_KEYS_BTN, menuHorizontalPosition == 1 ? attr : 0);
if (attr && event == EVT_KEY_BREAK(KEY_ENTER)) {
if (menuHorizontalPosition == 0)
+107 -5
View File
@@ -18,7 +18,6 @@
* GNU General Public License for more details.
*/
#include <stdio.h>
#include "io/frsky_firmware_update.h"
#include "io/multi_firmware_update.h"
#include "opentx.h"
@@ -91,6 +90,49 @@ void onSdFormatConfirm(const char * result)
}
}
#if defined(PXX2)
void onUpdateConfirmation(const char * result)
{
if (result == STR_OK) {
OtaUpdateInformation * destination = moduleState[reusableBuffer.sdManager.otaUpdateInformation.module].otaUpdateInformation;
Pxx2OtaUpdate otaUpdate(reusableBuffer.sdManager.otaUpdateInformation.module, destination->candidateReceiversNames[destination->selectedReceiverIndex]);
otaUpdate.flashFirmware(destination->filename);
}
else {
moduleState[reusableBuffer.sdManager.otaUpdateInformation.module].mode = MODULE_MODE_NORMAL;
}
}
void onUpdateStateChanged()
{
if (reusableBuffer.sdManager.otaUpdateInformation.step == BIND_INFO_REQUEST) {
uint8_t modelId = reusableBuffer.sdManager.otaUpdateInformation.receiverInformation.modelID;
if (modelId > 0 && modelId < DIM(PXX2ReceiversNames)) {
if (isPXX2ReceiverOptionAvailable(modelId, RECEIVER_OPTION_OTA)) {
POPUP_CONFIRMATION(getPXX2ReceiverName(modelId), onUpdateConfirmation);
char *tmp = strAppend(reusableBuffer.sdManager.otaReceiverVersion, TR_CURRENT_VERSION);
tmp = strAppendUnsigned(tmp, 1 + reusableBuffer.sdManager.otaUpdateInformation.receiverInformation.swVersion.major);
*tmp++ = '.';
tmp = strAppendUnsigned(tmp, reusableBuffer.sdManager.otaUpdateInformation.receiverInformation.swVersion.minor);
*tmp++ = '.';
tmp = strAppendUnsigned(tmp, reusableBuffer.sdManager.otaUpdateInformation.receiverInformation.swVersion.revision);
SET_WARNING_INFO(reusableBuffer.sdManager.otaReceiverVersion, tmp - reusableBuffer.sdManager.otaReceiverVersion, 0);
}
else {
POPUP_WARNING(STR_OTA_UPDATE_ERROR);
SET_WARNING_INFO(STR_UNSUPPORTED_RX, sizeof(TR_UNSUPPORTED_RX) - 1, 0);
moduleState[reusableBuffer.sdManager.otaUpdateInformation.module].mode = MODULE_MODE_NORMAL;
}
}
else {
POPUP_WARNING(STR_OTA_UPDATE_ERROR);
SET_WARNING_INFO(STR_UNKNOWN_RX, sizeof(TR_UNKNOWN_RX) - 1, 0);
moduleState[reusableBuffer.sdManager.otaUpdateInformation.module].mode = MODULE_MODE_NORMAL;
}
}
}
#endif
void onSdManagerMenu(const char * result)
{
TCHAR lfn[_MAX_LFN+1];
@@ -203,6 +245,14 @@ void onSdManagerMenu(const char * result)
multiFlashFirmware(EXTERNAL_MODULE, lfn);
}
#endif
#if defined(PXX2)
else if (result == STR_FLASH_RECEIVER_OTA_BY_INTERNAL || result == STR_FLASH_RECEIVER_OTA_BY_EXTERNAL) {
memclear(&reusableBuffer.sdManager.otaUpdateInformation, sizeof(OtaUpdateInformation));
getSelectionFullPath(reusableBuffer.sdManager.otaUpdateInformation.filename);
reusableBuffer.sdManager.otaUpdateInformation.module = result == STR_FLASH_RECEIVER_OTA_BY_INTERNAL ? INTERNAL_MODULE : EXTERNAL_MODULE;
moduleState[reusableBuffer.sdManager.otaUpdateInformation.module].startBind(&reusableBuffer.sdManager.otaUpdateInformation, onUpdateStateChanged);
}
#endif
#if defined(LUA)
else if (result == STR_EXECUTE_FILE) {
getSelectionFullPath(lfn);
@@ -211,20 +261,47 @@ void onSdManagerMenu(const char * result)
#endif
}
#if defined(PXX2)
void onUpdateReceiverSelection(const char * result)
{
if (result != STR_EXIT) {
reusableBuffer.sdManager.otaUpdateInformation.selectedReceiverIndex = (result - reusableBuffer.sdManager.otaUpdateInformation.candidateReceiversNames[0]) / sizeof(reusableBuffer.sdManager.otaUpdateInformation.candidateReceiversNames[0]);
reusableBuffer.sdManager.otaUpdateInformation.step = BIND_INFO_REQUEST;
#if defined(SIMU)
reusableBuffer.sdManager.otaUpdateInformation.receiverInformation.modelID = 0x01;
onUpdateStateChanged();
#endif
}
else {
// the user pressed [Exit]
moduleState[reusableBuffer.sdManager.otaUpdateInformation.module].mode = MODULE_MODE_NORMAL;
}
}
#endif
bool menuRadioSdManager(event_t _event)
{
#if defined(PXX2)
if (EVT_KEY_MASK(_event) == KEY_EXIT && moduleState[reusableBuffer.sdManager.otaUpdateInformation.module].mode == MODULE_MODE_BIND) {
moduleState[reusableBuffer.sdManager.otaUpdateInformation.module].mode = MODULE_MODE_NORMAL;
CLEAR_POPUP();
killEvents(KEY_EXIT);
_event = 0;
}
#endif
event_t event = (EVT_KEY_MASK(_event) == KEY_ENTER ? 0 : _event);
SIMPLE_MENU(SD_IS_HC() ? STR_SDHC_CARD : STR_SD_CARD, RADIO_ICONS, menuTabGeneral, MENU_RADIO_SD_MANAGER, reusableBuffer.sdManager.count);
int index = menuVerticalPosition - menuVerticalOffset;
switch(_event) {
switch (_event) {
case EVT_ENTRY:
f_chdir(ROOT_PATH);
// no break;
case EVT_ENTRY_UP:
memset(&reusableBuffer.sdManager, 0, sizeof(reusableBuffer.sdManager));
memclear(&reusableBuffer.sdManager, sizeof(reusableBuffer.sdManager));
menuVerticalPosition = 0;
REFRESH_FILES();
break;
@@ -300,8 +377,12 @@ bool menuRadioSdManager(event_t _event)
if (HAS_SPORT_UPDATE_CONNECTOR() && (information.productFamily == FIRMWARE_FAMILY_RECEIVER || information.productFamily == FIRMWARE_FAMILY_SENSOR))
POPUP_MENU_ADD_ITEM(STR_FLASH_EXTERNAL_DEVICE);
#if defined(PXX2)
if (information.productFamily == FIRMWARE_FAMILY_RECEIVER)
POPUP_MENU_ADD_ITEM(STR_FLASH_RECEIVER_OTA);
if (information.productFamily == FIRMWARE_FAMILY_RECEIVER) {
if (isReceiverOTAEnabledFromModule(INTERNAL_MODULE, information.productId))
POPUP_MENU_ADD_ITEM(STR_FLASH_RECEIVER_OTA_BY_INTERNAL);
if (isReceiverOTAEnabledFromModule(EXTERNAL_MODULE, information.productId))
POPUP_MENU_ADD_ITEM(STR_FLASH_RECEIVER_OTA_BY_EXTERNAL);
}
#endif
#if defined(BLUETOOTH)
if (information.productFamily == FIRMWARE_FAMILY_BLUETOOTH_CHIP)
@@ -476,6 +557,27 @@ bool menuRadioSdManager(event_t _event)
}
}
#if defined(PXX2)
if (moduleState[reusableBuffer.sdManager.otaUpdateInformation.module].mode == MODULE_MODE_BIND) {
if (reusableBuffer.sdManager.otaUpdateInformation.step == BIND_INIT) {
if (reusableBuffer.sdManager.otaUpdateInformation.candidateReceiversCount > 0) {
if (reusableBuffer.sdManager.otaUpdateInformation.candidateReceiversCount != popupMenuItemsCount) {
CLEAR_POPUP();
popupMenuItemsCount = min<uint8_t>(reusableBuffer.sdManager.otaUpdateInformation.candidateReceiversCount,PXX2_MAX_RECEIVERS_PER_MODULE);
for (auto rx = 0; rx < popupMenuItemsCount; rx++) {
popupMenuItems[rx] = reusableBuffer.sdManager.otaUpdateInformation.candidateReceiversNames[rx];
}
//popupMenuTitle = STR_PXX2_SELECT_RX;
POPUP_MENU_START(onUpdateReceiverSelection);
}
}
else {
POPUP_WAIT(STR_WAITING_FOR_RX);
}
}
}
#endif
const char * ext = getFileExtension(reusableBuffer.sdManager.lines[index]);
if (ext && isExtensionMatching(ext, BITMAPS_EXT)) {
if (currentBitmapIndex != menuVerticalPosition) {