+16
-36
@@ -71,7 +71,7 @@ extern int8_t s_editMode; // global editmode
|
||||
#define INCDEC_REP10 0x40
|
||||
#define NO_DBLKEYS 0x80
|
||||
|
||||
#define INCDEC_DECLARE_VARS(f) uint8_t incdecFlag = (f); IsValueAvailable isValueAvailable = NULL
|
||||
#define INCDEC_DECLARE_VARS(f) uint8_t incdecFlag = (f); IsValueAvailable isValueAvailable = nullptr
|
||||
#define INCDEC_SET_FLAG(f) incdecFlag = (f)
|
||||
#define INCDEC_ENABLE_CHECK(fn) isValueAvailable = fn
|
||||
#define CHECK_INCDEC_PARAM(event, var, min, max) checkIncDec(event, var, min, max, incdecFlag, isValueAvailable)
|
||||
@@ -152,59 +152,39 @@ void check_simple(event_t event, uint8_t curr, const MenuHandlerFunc *menuTab, u
|
||||
void check_submenu_simple(event_t event, uint8_t maxrow);
|
||||
|
||||
void title(const char * s);
|
||||
#define TITLE(str) title(str)
|
||||
|
||||
#define MENU_TAB(...) const uint8_t mstate_tab[] = __VA_ARGS__
|
||||
|
||||
#if defined(NAVIGATION_X7)
|
||||
#define MENU_CHECK(tab, menu, lines_count) \
|
||||
check(event, menu, tab, DIM(tab), mstate_tab, DIM(mstate_tab)-1, lines_count)
|
||||
#else
|
||||
#define MENU_CHECK(tab, menu, lines_count) \
|
||||
check(event, menu, tab, DIM(tab), mstate_tab, DIM(mstate_tab)-1, (lines_count)-1)
|
||||
#endif
|
||||
check(event, menu, tab, DIM(tab), mstate_tab, DIM(mstate_tab)-1, (lines_count)-HEADER_LINE)
|
||||
|
||||
#define MENU(title, tab, menu, lines_count, ...) \
|
||||
#define MENU(name, tab, menu, lines_count, ...) \
|
||||
MENU_TAB(__VA_ARGS__); \
|
||||
MENU_CHECK(tab, menu, lines_count); \
|
||||
TITLE(title)
|
||||
title(name)
|
||||
|
||||
#if defined(NAVIGATION_X7)
|
||||
#define SIMPLE_MENU_NOTITLE(tab, menu, lines_count) \
|
||||
check_simple(event, menu, tab, DIM(tab), lines_count);
|
||||
#define SUBMENU_NOTITLE(lines_count, ...) \
|
||||
MENU_TAB(__VA_ARGS__); \
|
||||
check(event, 0, NULL, 0, mstate_tab, DIM(mstate_tab)-1, lines_count);
|
||||
#define SUBMENU(title, lines_count, ...) \
|
||||
MENU_TAB(__VA_ARGS__); \
|
||||
check(event, 0, NULL, 0, mstate_tab, DIM(mstate_tab)-1, lines_count); \
|
||||
TITLE(title)
|
||||
#define SIMPLE_SUBMENU_NOTITLE(lines_count) \
|
||||
check_submenu_simple(event, lines_count);
|
||||
#else
|
||||
check(event, 0, nullptr, 0, mstate_tab, DIM(mstate_tab)-1, (lines_count)-HEADER_LINE);
|
||||
|
||||
#define SIMPLE_MENU_NOTITLE(tab, menu, lines_count) \
|
||||
check_simple(event, menu, tab, DIM(tab), (lines_count)-1);
|
||||
#define SUBMENU_NOTITLE(lines_count, ...) \
|
||||
MENU_TAB(__VA_ARGS__); \
|
||||
check(event, 0, NULL, 0, mstate_tab, DIM(mstate_tab)-1, (lines_count)-1);
|
||||
|
||||
#define SUBMENU(title, lines_count, ...) \
|
||||
MENU_TAB(__VA_ARGS__); \
|
||||
check(event, 0, NULL, 0, mstate_tab, DIM(mstate_tab)-1, (lines_count)-1); \
|
||||
TITLE(title)
|
||||
check_simple(event, menu, tab, DIM(tab), (lines_count)-HEADER_LINE);
|
||||
|
||||
#define SIMPLE_SUBMENU_NOTITLE(lines_count) \
|
||||
check_submenu_simple(event, (lines_count)-1);
|
||||
check_submenu_simple(event, (lines_count)-HEADER_LINE);
|
||||
|
||||
#endif
|
||||
#define SUBMENU(name, lines_count, ...) \
|
||||
MENU_TAB(__VA_ARGS__); \
|
||||
check(event, 0, nullptr, 0, mstate_tab, DIM(mstate_tab)-1, (lines_count)-HEADER_LINE); \
|
||||
title(name)
|
||||
|
||||
#define SIMPLE_MENU(title, tab, menu, lines_count) \
|
||||
#define SIMPLE_MENU(name, tab, menu, lines_count) \
|
||||
SIMPLE_MENU_NOTITLE(tab, menu, lines_count); \
|
||||
TITLE(title)
|
||||
title(name)
|
||||
|
||||
#define SIMPLE_SUBMENU(title, lines_count) \
|
||||
#define SIMPLE_SUBMENU(name, lines_count) \
|
||||
SIMPLE_SUBMENU_NOTITLE(lines_count); \
|
||||
TITLE(title)
|
||||
title(name)
|
||||
|
||||
typedef int choice_t;
|
||||
|
||||
|
||||
@@ -576,24 +576,6 @@ void lcdDrawVerticalLine(coord_t x, scoord_t y, scoord_t h, uint8_t pat, LcdFlag
|
||||
}
|
||||
}
|
||||
|
||||
void drawReceiverName(coord_t x, coord_t y, uint8_t moduleIdx, uint8_t receiverIdx, LcdFlags flags)
|
||||
{
|
||||
if (isModulePXX2(moduleIdx)) {
|
||||
if (g_model.moduleData[moduleIdx].pxx2.receiverName[receiverIdx][0] != '\0')
|
||||
lcdDrawSizedText(x, y, g_model.moduleData[moduleIdx].pxx2.receiverName[receiverIdx], effectiveLen(g_model.moduleData[moduleIdx].pxx2.receiverName[receiverIdx], PXX2_LEN_RX_NAME), flags);
|
||||
else
|
||||
lcdDrawText(x, y, "---", flags);
|
||||
}
|
||||
#if defined(HARDWARE_INTERNAL_MODULE)
|
||||
else if (moduleIdx == INTERNAL_MODULE) {
|
||||
lcdDrawText(x, y, "Internal", flags);
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
lcdDrawText(x, y, "External", flags);
|
||||
}
|
||||
}
|
||||
|
||||
void lcdDrawSolidVerticalLine(coord_t x, scoord_t y, scoord_t h, LcdFlags att)
|
||||
{
|
||||
lcdDrawVerticalLine(x, y, h, SOLID, att);
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "opentx.h"
|
||||
|
||||
MenuHandlerFunc menuHandlers[5];
|
||||
uint8_t menuEvent = 0;
|
||||
uint8_t menuVerticalPositions[4];
|
||||
uint8_t menuLevel = 0;
|
||||
|
||||
void popMenu()
|
||||
{
|
||||
assert(menuLevel>0);
|
||||
menuLevel = menuLevel-1;
|
||||
menuEvent = EVT_ENTRY_UP;
|
||||
TRACE("popMenu(%d)", menuLevel);
|
||||
}
|
||||
|
||||
void abortPopMenu()
|
||||
{
|
||||
menuLevel = menuLevel + 1;
|
||||
menuEvent = 0;
|
||||
TRACE("popMenu(%d) aborted", menuLevel);
|
||||
}
|
||||
|
||||
void chainMenu(MenuHandlerFunc newMenu)
|
||||
{
|
||||
menuHandlers[menuLevel] = newMenu;
|
||||
menuEvent = EVT_ENTRY;
|
||||
TRACE("chainMenu(%d, %p)", menuLevel, newMenu);
|
||||
}
|
||||
|
||||
void pushMenu(MenuHandlerFunc newMenu)
|
||||
{
|
||||
killEvents(KEY_ENTER);
|
||||
|
||||
if (menuLevel == 0) {
|
||||
if (newMenu == menuRadioSetup)
|
||||
menuVerticalPositions[0] = 1;
|
||||
if (newMenu == menuModelSelect)
|
||||
menuVerticalPositions[0] = 0;
|
||||
}
|
||||
else {
|
||||
menuVerticalPositions[menuLevel] = menuVerticalPosition;
|
||||
}
|
||||
|
||||
menuLevel++;
|
||||
|
||||
assert(menuLevel < DIM(menuHandlers));
|
||||
|
||||
menuHandlers[menuLevel] = newMenu;
|
||||
menuEvent = EVT_ENTRY;
|
||||
TRACE("pushMenu(%d, %p)", menuLevel, newMenu);
|
||||
}
|
||||
|
||||
void menuModelNotes(event_t event)
|
||||
{
|
||||
if (event == EVT_ENTRY) {
|
||||
strcpy(s_text_file, MODELS_PATH "/");
|
||||
char *buf = strcat_modelname(&s_text_file[sizeof(MODELS_PATH)], g_eeGeneral.currModel);
|
||||
strcpy(buf, TEXT_EXT);
|
||||
}
|
||||
|
||||
menuTextView(event);
|
||||
}
|
||||
|
||||
void pushModelNotes()
|
||||
{
|
||||
pushMenu(menuModelNotes);
|
||||
}
|
||||
@@ -22,42 +22,16 @@
|
||||
#define _MENUS_H_
|
||||
|
||||
#include "keys.h"
|
||||
#include "common/stdlcd/menus.h"
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
typedef int8_t horzpos_t;
|
||||
#define NAVIGATION_LINE_BY_LINE 0x40
|
||||
#define IS_LINE_SELECTED(sub, k) ((sub)==(k) && menuHorizontalPosition < 0)
|
||||
#else
|
||||
typedef uint8_t horzpos_t;
|
||||
#define NAVIGATION_LINE_BY_LINE 0
|
||||
#define IS_LINE_SELECTED(sub, k) (false)
|
||||
#endif
|
||||
|
||||
#if defined(SDCARD)
|
||||
typedef uint16_t vertpos_t;
|
||||
#else
|
||||
typedef uint8_t vertpos_t;
|
||||
#endif
|
||||
|
||||
typedef void (*MenuHandlerFunc)(event_t event);
|
||||
|
||||
extern tmr10ms_t menuEntryTime;
|
||||
|
||||
extern vertpos_t menuVerticalPosition;
|
||||
extern horzpos_t menuHorizontalPosition;
|
||||
extern vertpos_t menuVerticalOffset;
|
||||
extern uint8_t menuCalibrationState;
|
||||
|
||||
extern MenuHandlerFunc menuHandlers[5];
|
||||
extern uint8_t menuVerticalPositions[4];
|
||||
extern uint8_t menuLevel;
|
||||
extern uint8_t menuEvent;
|
||||
|
||||
void chainMenu(MenuHandlerFunc newMenu);
|
||||
void pushMenu(MenuHandlerFunc newMenu);
|
||||
void popMenu();
|
||||
void abortPopMenu();
|
||||
|
||||
inline bool isRadioMenuDisplayed()
|
||||
{
|
||||
return menuVerticalPositions[0] == 1;
|
||||
@@ -68,11 +42,6 @@ inline bool isModelMenuDisplayed()
|
||||
return menuVerticalPositions[0] == 0;
|
||||
}
|
||||
|
||||
inline MenuHandlerFunc lastPopMenu()
|
||||
{
|
||||
return menuHandlers[menuLevel+1];
|
||||
}
|
||||
|
||||
void onMainViewMenu(const char * result);
|
||||
void menuFirstCalib(event_t event);
|
||||
void menuMainView(event_t event);
|
||||
|
||||
@@ -75,7 +75,7 @@ void menuModelFlightModeOne(event_t event)
|
||||
|
||||
check(event, 0, NULL, 0, (s_currIdx == 0) ? mstate_tab_fm1 : mstate_tab_others, DIM(mstate_tab_others)-1, ITEM_MODEL_FLIGHT_MODE_MAX - HEADER_LINE - (s_currIdx==0 ? (ITEM_MODEL_FLIGHT_MODE_FADE_IN-ITEM_MODEL_FLIGHT_MODE_SWITCH-1) : 0));
|
||||
|
||||
TITLE(STR_MENUFLIGHTMODE);
|
||||
title(STR_MENUFLIGHTMODE);
|
||||
|
||||
#define PHASE_ONE_FIRST_LINE (1+1*FH)
|
||||
#else
|
||||
|
||||
@@ -378,7 +378,7 @@ void drawOffsetBar(uint8_t x, uint8_t y, MixData * md)
|
||||
|
||||
void menuModelMixOne(event_t event)
|
||||
{
|
||||
TITLE(STR_MIXER);
|
||||
title(STR_MIXER);
|
||||
MixData * md2 = mixAddress(s_currIdx) ;
|
||||
putsChn(lcdLastRightPos+1*FW, 0, md2->destCh+1,0);
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ void putsEdgeDelayParam(coord_t x, coord_t y, LogicalSwitchData *cs, uint8_t lat
|
||||
|
||||
void menuModelLogicalSwitchOne(event_t event)
|
||||
{
|
||||
TITLE(STR_MENULOGICALSWITCH);
|
||||
title(STR_MENULOGICALSWITCH);
|
||||
|
||||
LogicalSwitchData * cs = lswAddress(s_currIdx);
|
||||
|
||||
|
||||
@@ -1,183 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <opentx.h>
|
||||
#include <math.h>
|
||||
|
||||
#define RECEIVER_OPTIONS_2ND_COLUMN (11*FW)
|
||||
|
||||
extern uint8_t g_moduleIdx;
|
||||
|
||||
void onTxOptionsUpdateConfirm(const char * result)
|
||||
{
|
||||
if (result == STR_OK) {
|
||||
reusableBuffer.hardwareAndSettings.moduleSettingsDirty = 2;
|
||||
moduleState[g_moduleIdx].writeModuleSettings(&reusableBuffer.hardwareAndSettings.moduleSettings);
|
||||
}
|
||||
else {
|
||||
popMenu();
|
||||
}
|
||||
}
|
||||
|
||||
enum {
|
||||
ITEM_MODULE_SETTINGS_EXTERNAL_ANTENNA,
|
||||
ITEM_MODULE_SETTINGS_POWER,
|
||||
ITEM_MODULE_SETTINGS_COUNT
|
||||
};
|
||||
|
||||
#define IF_MODULE_OPTIONS(option, count) uint8_t(isModuleOptionAvailable(modelId, option) ? count : HIDDEN_ROW)
|
||||
|
||||
bool isPowerAvailable(int value)
|
||||
{
|
||||
uint8_t modelId = reusableBuffer.hardwareAndSettings.modules[g_moduleIdx].information.modelID;
|
||||
uint8_t variant = reusableBuffer.hardwareAndSettings.modules[g_moduleIdx].information.variant;
|
||||
|
||||
if (modelId == PXX2_MODULE_R9M_LITE) {
|
||||
if (variant == PXX2_VARIANT_EU)
|
||||
return (value == 14 /* 25 mW */ ||
|
||||
value == 20 /* 100 mW */);
|
||||
else
|
||||
return value == 20; /* 100 mW */
|
||||
}
|
||||
else if (modelId == PXX2_MODULE_R9M || modelId == PXX2_MODULE_R9M_LITE_PRO) {
|
||||
if (variant == PXX2_VARIANT_EU)
|
||||
return (value == 14 /* 25 mW */ ||
|
||||
value == 23 /* 200 mW */ ||
|
||||
value == 27 /* 500 mW */);
|
||||
else
|
||||
return (value == 10 /* 10 mW */ ||
|
||||
value == 20 /* 100 mW */ ||
|
||||
value == 27 /* 500 mW */ ||
|
||||
value == 30 /* 1000 mW */);
|
||||
}
|
||||
else {
|
||||
return (value <= 20); /* 100 mW max for XJTs */
|
||||
}
|
||||
}
|
||||
|
||||
void menuModelModuleOptions(event_t event)
|
||||
{
|
||||
if (event == EVT_ENTRY) {
|
||||
memclear(&reusableBuffer.hardwareAndSettings, sizeof(reusableBuffer.hardwareAndSettings));
|
||||
#if defined(SIMU)
|
||||
reusableBuffer.hardwareAndSettings.moduleSettings.state = PXX2_SETTINGS_OK;
|
||||
#else
|
||||
// no need to initialize reusableBuffer.hardwareAndSettings.moduleState.state to PXX2_HARDWARE_INFO
|
||||
moduleState[g_moduleIdx].readModuleInformation(&reusableBuffer.hardwareAndSettings.modules[g_moduleIdx], PXX2_HW_INFO_TX_ID, PXX2_HW_INFO_TX_ID);
|
||||
#endif
|
||||
}
|
||||
|
||||
uint8_t modelId = reusableBuffer.hardwareAndSettings.modules[g_moduleIdx].information.modelID;
|
||||
// uint8_t variant = reusableBuffer.hardwareAndSettings.modules[g_moduleIdx].information.variant;
|
||||
|
||||
uint8_t optionsAvailable = moduleOptions[modelId] & ((1 << MODULE_OPTION_EXTERNAL_ANTENNA) | (1 << MODULE_OPTION_POWER));
|
||||
|
||||
SUBMENU_NOTITLE(ITEM_MODULE_SETTINGS_COUNT, {
|
||||
!optionsAvailable ? (uint8_t)0 : IF_MODULE_OPTIONS(MODULE_OPTION_EXTERNAL_ANTENNA, 0),
|
||||
IF_MODULE_OPTIONS(MODULE_OPTION_POWER, 0),
|
||||
});
|
||||
|
||||
if (reusableBuffer.hardwareAndSettings.moduleSettings.state == PXX2_HARDWARE_INFO && moduleState[g_moduleIdx].mode == MODULE_MODE_NORMAL) {
|
||||
if (modelId)
|
||||
moduleState[g_moduleIdx].readModuleSettings(&reusableBuffer.hardwareAndSettings.moduleSettings);
|
||||
else
|
||||
moduleState[g_moduleIdx].readModuleInformation(&reusableBuffer.hardwareAndSettings.modules[g_moduleIdx], PXX2_HW_INFO_TX_ID, PXX2_HW_INFO_TX_ID);
|
||||
}
|
||||
|
||||
if (menuEvent) {
|
||||
killEvents(KEY_EXIT);
|
||||
moduleState[g_moduleIdx].mode = MODULE_MODE_NORMAL;
|
||||
if (reusableBuffer.hardwareAndSettings.moduleSettingsDirty) {
|
||||
abortPopMenu();
|
||||
POPUP_CONFIRMATION(STR_UPDATE_TX_OPTIONS, onTxOptionsUpdateConfirm);
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (event == EVT_KEY_LONG(KEY_ENTER) && reusableBuffer.hardwareAndSettings.moduleSettingsDirty) {
|
||||
killEvents(event);
|
||||
reusableBuffer.hardwareAndSettings.moduleSettingsDirty = 0;
|
||||
moduleState[g_moduleIdx].writeModuleSettings(&reusableBuffer.hardwareAndSettings.moduleSettings);
|
||||
}
|
||||
|
||||
if (reusableBuffer.hardwareAndSettings.moduleSettingsDirty == 2 && reusableBuffer.hardwareAndSettings.moduleSettings.state == PXX2_SETTINGS_OK) {
|
||||
popMenu();
|
||||
}
|
||||
|
||||
if (modelId != 0 && mstate_tab[menuVerticalPosition] == HIDDEN_ROW) {
|
||||
menuVerticalPosition = 0;
|
||||
while (menuVerticalPosition < ITEM_MODULE_SETTINGS_COUNT && mstate_tab[menuVerticalPosition] == HIDDEN_ROW) {
|
||||
++menuVerticalPosition;
|
||||
}
|
||||
}
|
||||
|
||||
int8_t sub = menuVerticalPosition;
|
||||
lcdDrawTextAlignedLeft(0, STR_MODULE_OPTIONS);
|
||||
lcdDrawText(lcdLastRightPos + 3, 0, PXX2modulesModels[modelId]);
|
||||
lcdInvertLine(0);
|
||||
|
||||
if (reusableBuffer.hardwareAndSettings.moduleSettings.state == PXX2_SETTINGS_OK) {
|
||||
if (optionsAvailable) {
|
||||
for (uint8_t k=0; k<LCD_LINES-1; k++) {
|
||||
coord_t y = MENU_HEADER_HEIGHT + 1 + k*FH;
|
||||
uint8_t i = k + menuVerticalOffset;
|
||||
for (int j=0; j<=i; ++j) {
|
||||
if (j<(int)DIM(mstate_tab) && mstate_tab[j] == HIDDEN_ROW) {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
LcdFlags attr = (sub==i ? (s_editMode>0 ? BLINK|INVERS : INVERS) : 0);
|
||||
|
||||
switch (i) {
|
||||
case ITEM_MODULE_SETTINGS_EXTERNAL_ANTENNA:
|
||||
reusableBuffer.hardwareAndSettings.moduleSettings.externalAntenna = editCheckBox(reusableBuffer.hardwareAndSettings.moduleSettings.externalAntenna, RECEIVER_OPTIONS_2ND_COLUMN, y, "Ext. antenna", attr, event);
|
||||
if (attr && checkIncDec_Ret) {
|
||||
reusableBuffer.hardwareAndSettings.moduleSettingsDirty = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case ITEM_MODULE_SETTINGS_POWER:
|
||||
lcdDrawText(0, y, STR_POWER);
|
||||
lcdDrawNumber(RECEIVER_OPTIONS_2ND_COLUMN, y, reusableBuffer.hardwareAndSettings.moduleSettings.txPower, attr);
|
||||
lcdDrawText(lcdNextPos, y, "dBm(");
|
||||
drawPower(lcdNextPos, y, reusableBuffer.hardwareAndSettings.moduleSettings.txPower);
|
||||
lcdDrawText(lcdNextPos, y, ")");
|
||||
if (attr) {
|
||||
reusableBuffer.hardwareAndSettings.moduleSettings.txPower = checkIncDec(event, reusableBuffer.hardwareAndSettings.moduleSettings.txPower, 0, 30, 0, &isPowerAvailable);
|
||||
if (checkIncDec_Ret) {
|
||||
reusableBuffer.hardwareAndSettings.moduleSettingsDirty = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
lcdDrawCenteredText(LCD_H/2, STR_NO_TX_OPTIONS);
|
||||
s_editMode = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
lcdDrawCenteredText(LCD_H/2, STR_WAITING_FOR_TX);
|
||||
s_editMode = 0;
|
||||
}
|
||||
}
|
||||
@@ -98,7 +98,7 @@ enum MenuModelOutputsOneItems {
|
||||
|
||||
void menuModelLimitsOne(event_t event)
|
||||
{
|
||||
TITLE(STR_MENULIMITS);
|
||||
title(STR_MENULIMITS);
|
||||
LimitData * ld = limitAddress(s_currIdx);
|
||||
|
||||
putsChn(11*FW, 0, s_currIdx+1, 0);
|
||||
|
||||
@@ -1,157 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <opentx.h>
|
||||
|
||||
#define RECEIVER_OPTIONS_2ND_COLUMN 80
|
||||
|
||||
extern uint8_t g_moduleIdx;
|
||||
|
||||
void onRxOptionsUpdateConfirm(const char * result)
|
||||
{
|
||||
if (result == STR_OK) {
|
||||
reusableBuffer.hardwareAndSettings.receiverSettings.state = PXX2_SETTINGS_WRITE;
|
||||
reusableBuffer.hardwareAndSettings.receiverSettings.dirty = 2;
|
||||
reusableBuffer.hardwareAndSettings.receiverSettings.timeout = 0;
|
||||
moduleState[g_moduleIdx].mode = MODULE_MODE_RECEIVER_SETTINGS;
|
||||
}
|
||||
else {
|
||||
popMenu();
|
||||
}
|
||||
}
|
||||
|
||||
enum {
|
||||
ITEM_RECEIVER_TELEMETRY,
|
||||
ITEM_RECEIVER_PWM_RATE,
|
||||
ITEM_RECEIVER_PINMAP_FIRST
|
||||
};
|
||||
|
||||
void menuModelReceiverOptions(event_t event)
|
||||
{
|
||||
const int lim = (g_model.extendedLimits ? (512 * LIMIT_EXT_PERCENT / 100) : 512) * 2;
|
||||
uint8_t wbar = LCD_W / 2 - 20;
|
||||
auto outputsCount = min<uint8_t>(16, reusableBuffer.hardwareAndSettings.receiverSettings.outputsCount);
|
||||
|
||||
SIMPLE_SUBMENU_NOTITLE(ITEM_RECEIVER_PINMAP_FIRST + outputsCount);
|
||||
|
||||
if (event == EVT_ENTRY) {
|
||||
#if defined(SIMU)
|
||||
reusableBuffer.hardwareAndSettings.receiverSettings.state = PXX2_SETTINGS_OK;
|
||||
reusableBuffer.hardwareAndSettings.receiverSettings.outputsCount = 8;
|
||||
#else
|
||||
// no need to initialize reusableBuffer.hardwareAndSettings.receiverSettings.state to PXX2_HARDWARE_INFO
|
||||
moduleState[g_moduleIdx].readModuleInformation(&reusableBuffer.hardwareAndSettings.modules[g_moduleIdx], reusableBuffer.hardwareAndSettings.receiverSettings.receiverId, reusableBuffer.hardwareAndSettings.receiverSettings.receiverId);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (reusableBuffer.hardwareAndSettings.receiverSettings.state == PXX2_HARDWARE_INFO && moduleState[g_moduleIdx].mode == MODULE_MODE_NORMAL) {
|
||||
reusableBuffer.hardwareAndSettings.receiverSettings.state = PXX2_SETTINGS_READ;
|
||||
moduleState[g_moduleIdx].mode = MODULE_MODE_RECEIVER_SETTINGS;
|
||||
}
|
||||
|
||||
if (menuEvent) {
|
||||
killEvents(KEY_EXIT);
|
||||
moduleState[g_moduleIdx].mode = MODULE_MODE_NORMAL;
|
||||
if (reusableBuffer.hardwareAndSettings.receiverSettings.dirty) {
|
||||
abortPopMenu();
|
||||
POPUP_CONFIRMATION(STR_UPDATE_RX_OPTIONS, onRxOptionsUpdateConfirm);
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (event == EVT_KEY_LONG(KEY_ENTER) && reusableBuffer.hardwareAndSettings.receiverSettings.dirty) {
|
||||
killEvents(event);
|
||||
reusableBuffer.hardwareAndSettings.receiverSettings.state = PXX2_SETTINGS_WRITE;
|
||||
reusableBuffer.hardwareAndSettings.receiverSettings.dirty = 0;
|
||||
reusableBuffer.hardwareAndSettings.receiverSettings.timeout = 0;
|
||||
moduleState[g_moduleIdx].mode = MODULE_MODE_RECEIVER_SETTINGS;
|
||||
}
|
||||
|
||||
if (reusableBuffer.hardwareAndSettings.receiverSettings.dirty == 2 && reusableBuffer.hardwareAndSettings.receiverSettings.state == PXX2_SETTINGS_OK) {
|
||||
popMenu();
|
||||
return;
|
||||
}
|
||||
|
||||
int8_t sub = menuVerticalPosition;
|
||||
lcdDrawTextAlignedLeft(0, STR_RECEIVER_OPTIONS);
|
||||
drawReceiverName(FW * 13, 0, g_moduleIdx, reusableBuffer.hardwareAndSettings.receiverSettings.receiverId);
|
||||
lcdInvertLine(0);
|
||||
|
||||
if (reusableBuffer.hardwareAndSettings.receiverSettings.state == PXX2_SETTINGS_OK) {
|
||||
for (uint8_t k=0; k<LCD_LINES-1; k++) {
|
||||
coord_t y = MENU_HEADER_HEIGHT + 1 + k*FH;
|
||||
uint8_t i = k + menuVerticalOffset;
|
||||
LcdFlags attr = (sub==i ? (s_editMode>0 ? BLINK|INVERS : INVERS) : 0);
|
||||
|
||||
switch (i) {
|
||||
case ITEM_RECEIVER_TELEMETRY:
|
||||
reusableBuffer.hardwareAndSettings.receiverSettings.telemetryDisabled = editCheckBox(reusableBuffer.hardwareAndSettings.receiverSettings.telemetryDisabled, RECEIVER_OPTIONS_2ND_COLUMN, y, "Telem. disabled", attr, event);
|
||||
if (attr && checkIncDec_Ret) {
|
||||
reusableBuffer.hardwareAndSettings.receiverSettings.dirty = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case ITEM_RECEIVER_PWM_RATE:
|
||||
reusableBuffer.hardwareAndSettings.receiverSettings.pwmRate = editCheckBox(reusableBuffer.hardwareAndSettings.receiverSettings.pwmRate, RECEIVER_OPTIONS_2ND_COLUMN, y, isModuleR9M2(g_moduleIdx) ? "6.67ms PWM": "9ms PWM", attr, event);
|
||||
if (attr && checkIncDec_Ret) {
|
||||
reusableBuffer.hardwareAndSettings.receiverSettings.dirty = true;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// Pin
|
||||
{
|
||||
uint8_t pin = i - ITEM_RECEIVER_PINMAP_FIRST;
|
||||
if (pin < reusableBuffer.hardwareAndSettings.receiverSettings.outputsCount) {
|
||||
uint8_t channel = g_model.moduleData[g_moduleIdx].channelsStart + reusableBuffer.hardwareAndSettings.receiverSettings.outputsMapping[pin];
|
||||
int32_t channelValue = channelOutputs[channel];
|
||||
lcdDrawText(0, y, STR_PIN);
|
||||
lcdDrawNumber(lcdLastRightPos + 1, y, pin + 1);
|
||||
putsChn(7 * FW, y, channel + 1, attr);
|
||||
|
||||
// Channel
|
||||
if (attr) {
|
||||
channel = checkIncDec(event, channel, 0, sentModuleChannels(g_moduleIdx) - 1);
|
||||
if (checkIncDec_Ret) {
|
||||
reusableBuffer.hardwareAndSettings.receiverSettings.outputsMapping[pin] = channel;
|
||||
reusableBuffer.hardwareAndSettings.receiverSettings.dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Bargraph
|
||||
#if !defined(PCBX7) // X7 LCD doesn't like too many horizontal lines
|
||||
lcdDrawRect(LCD_W - 3 - wbar, y + 1, wbar + 1, 4);
|
||||
#endif
|
||||
const uint8_t lenChannel = limit<uint8_t>(1, (abs(channelValue) * wbar / 2 + lim / 2) / lim, wbar / 2);
|
||||
const coord_t xChannel = (channelValue > 0) ? LCD_W - 3 - wbar / 2 : LCD_W - 2 - wbar / 2 - lenChannel;
|
||||
lcdDrawHorizontalLine(xChannel, y + 2, lenChannel, SOLID, 0);
|
||||
lcdDrawHorizontalLine(xChannel, y + 3, lenChannel, SOLID, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
lcdDrawCenteredText(LCD_H/2, STR_WAITING_FOR_RX);
|
||||
}
|
||||
}
|
||||
@@ -278,7 +278,7 @@ void menuModelSelect(event_t event)
|
||||
drawScreenIndex(MENU_MODEL_SELECT, DIM(menuTabModel), (sub == g_eeGeneral.currModel) ? INVERS : 0);
|
||||
#endif
|
||||
|
||||
TITLE(STR_MENUMODELSEL);
|
||||
title(STR_MENUMODELSEL);
|
||||
|
||||
for (uint8_t i=0; i<NUM_BODY_LINES; i++) {
|
||||
coord_t y = MENU_HEADER_HEIGHT + 1 + i*FH;
|
||||
|
||||
@@ -76,9 +76,11 @@ enum MenuModelSetupItems {
|
||||
#endif
|
||||
ITEM_MODEL_SETUP_BEEP_CENTER,
|
||||
ITEM_MODEL_SETUP_USE_GLOBAL_FUNCTIONS,
|
||||
|
||||
#if defined(PXX2)
|
||||
ITEM_MODEL_SETUP_REGISTRATION_ID,
|
||||
#endif
|
||||
|
||||
#if defined(HARDWARE_INTERNAL_MODULE)
|
||||
ITEM_MODEL_SETUP_INTERNAL_MODULE_LABEL,
|
||||
ITEM_MODEL_SETUP_INTERNAL_MODULE_TYPE,
|
||||
@@ -95,6 +97,7 @@ enum MenuModelSetupItems {
|
||||
ITEM_MODEL_SETUP_INTERNAL_MODULE_PXX2_RECEIVER_2,
|
||||
ITEM_MODEL_SETUP_INTERNAL_MODULE_PXX2_RECEIVER_3,
|
||||
#endif
|
||||
|
||||
ITEM_MODEL_SETUP_EXTERNAL_MODULE_LABEL,
|
||||
ITEM_MODEL_SETUP_EXTERNAL_MODULE_TYPE,
|
||||
#if defined(MULTIMODULE)
|
||||
@@ -119,11 +122,13 @@ enum MenuModelSetupItems {
|
||||
ITEM_MODEL_SETUP_EXTERNAL_MODULE_PXX2_RECEIVER_1,
|
||||
ITEM_MODEL_SETUP_EXTERNAL_MODULE_PXX2_RECEIVER_2,
|
||||
ITEM_MODEL_SETUP_EXTERNAL_MODULE_PXX2_RECEIVER_3,
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
ITEM_MODEL_SETUP_EXTRA_MODULE_LABEL,
|
||||
ITEM_MODEL_SETUP_EXTRA_MODULE_CHANNELS,
|
||||
ITEM_MODEL_SETUP_EXTRA_MODULE_BIND,
|
||||
#endif
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
ITEM_MODEL_SETUP_TRAINER_LABEL,
|
||||
ITEM_MODEL_SETUP_TRAINER_MODE,
|
||||
@@ -174,21 +179,27 @@ enum MenuModelSetupItems {
|
||||
#define SW_WARN_ROWS uint8_t(NAVIGATION_LINE_BY_LINE|(getSwitchWarningsCount()-1)), uint8_t(getSwitchWarningsCount() > 5 ? TITLE_ROW : HIDDEN_ROW)
|
||||
#endif
|
||||
|
||||
#define INTERNAL_MODULE_TYPE_ROWS ((isModuleXJT(INTERNAL_MODULE) || isModulePXX2(INTERNAL_MODULE)) ? (uint8_t)1 : (uint8_t)0) // Module type + RF protocols
|
||||
#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 EXTERNAL_MODULE_BIND_ROWS() ((isModuleXJT(EXTERNAL_MODULE) && IS_D8_RX(EXTERNAL_MODULE)) || isModuleSBUS(EXTERNAL_MODULE)) ? (uint8_t)1 : (isModulePPM(EXTERNAL_MODULE) || isModulePXX(EXTERNAL_MODULE) || isModulePXX2(EXTERNAL_MODULE) || isModuleDSM2(EXTERNAL_MODULE) || isModuleMultimodule(EXTERNAL_MODULE)) ? (uint8_t)2 : HIDDEN_ROW
|
||||
|
||||
#if defined(INTERNAL_MODULE_PXX1)
|
||||
#define INTERNAL_MODULE_TYPE_ROWS ((isModuleXJT(INTERNAL_MODULE) || isModulePXX2(INTERNAL_MODULE)) ? (uint8_t)1 : (uint8_t)0) // Module type + RF protocols
|
||||
#else
|
||||
#define INTERNAL_MODULE_TYPE_ROWS (0) // Module type + RF protocols
|
||||
#endif
|
||||
|
||||
#define EXTERNAL_MODULE_BIND_ROWS ((isModuleXJT(EXTERNAL_MODULE) && IS_D8_RX(EXTERNAL_MODULE)) || isModuleSBUS(EXTERNAL_MODULE)) ? (uint8_t)1 : (isModulePPM(EXTERNAL_MODULE) || isModulePXX(EXTERNAL_MODULE) || isModulePXX2(EXTERNAL_MODULE) || isModuleDSM2(EXTERNAL_MODULE) || isModuleMultimodule(EXTERNAL_MODULE)) ? (uint8_t)2 : HIDDEN_ROW
|
||||
|
||||
#if defined(PCBSKY9X) && defined(REVX)
|
||||
#define OUTPUT_TYPE_ROWS() (isModulePPM(EXTERNAL_MODULE) ? (uint8_t)0 : HIDDEN_ROW) ,
|
||||
#define OUTPUT_TYPE_ROW (isModulePPM(EXTERNAL_MODULE) ? (uint8_t)0 : HIDDEN_ROW),
|
||||
#elif defined(PCBSKY9X)
|
||||
#define OUTPUT_TYPE_ROWS()
|
||||
#define OUTPUT_TYPE_ROW
|
||||
#endif
|
||||
|
||||
#define PORT_CHANNELS_ROWS(x) (x==EXTERNAL_MODULE ? EXTERNAL_MODULE_CHANNELS_ROWS : 0)
|
||||
#define EXTERNAL_MODULE_TYPE_ROWS (isModulePXX(EXTERNAL_MODULE) || isModulePXX2(EXTERNAL_MODULE) || isModuleDSM2(EXTERNAL_MODULE) || isModuleMultimodule(EXTERNAL_MODULE)) ? (uint8_t)1 : (uint8_t)0
|
||||
|
||||
#define POT_WARN_ITEMS() ((g_model.potsWarnMode) ? (uint8_t)(NUM_POTS+NUM_SLIDERS) : (uint8_t)0)
|
||||
#define POT_WARN_ROWS ((g_model.potsWarnMode) ? (uint8_t)(NUM_POTS+NUM_SLIDERS) : (uint8_t)0)
|
||||
#define TIMER_ROWS 2, 0, 0, 0, 0
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
@@ -230,277 +241,6 @@ enum MenuModelSetupItems {
|
||||
#define TRAINER_ROWS
|
||||
#endif
|
||||
|
||||
#if defined(PXX2)
|
||||
bool isPXX2ReceiverEmpty(uint8_t moduleIdx, uint8_t receiverIdx)
|
||||
{
|
||||
return is_memclear(g_model.moduleData[moduleIdx].pxx2.receiverName[receiverIdx], PXX2_LEN_RX_NAME);
|
||||
}
|
||||
|
||||
void removePXX2Receiver(uint8_t moduleIdx, uint8_t receiverIdx)
|
||||
{
|
||||
memclear(g_model.moduleData[moduleIdx].pxx2.receiverName[receiverIdx], PXX2_LEN_RX_NAME);
|
||||
g_model.moduleData[moduleIdx].pxx2.receivers &= ~(1 << receiverIdx);
|
||||
storageDirty(EE_MODEL);
|
||||
}
|
||||
|
||||
void removePXX2ReceiverIfEmpty(uint8_t moduleIdx, uint8_t receiverIdx)
|
||||
{
|
||||
if (isPXX2ReceiverEmpty(moduleIdx, receiverIdx)) {
|
||||
removePXX2Receiver(moduleIdx, receiverIdx);
|
||||
}
|
||||
}
|
||||
|
||||
void onPXX2R9MBindModeMenu(const char * result)
|
||||
{
|
||||
if (result == STR_8CH_WITH_TELEMETRY) {
|
||||
reusableBuffer.moduleSetup.bindInformation.lbtMode = 0;
|
||||
}
|
||||
else if (result == STR_16CH_WITH_TELEMETRY) {
|
||||
reusableBuffer.moduleSetup.bindInformation.lbtMode = 1;
|
||||
}
|
||||
else if (result == STR_16CH_WITHOUT_TELEMETRY) {
|
||||
reusableBuffer.moduleSetup.bindInformation.lbtMode = 2;
|
||||
}
|
||||
else if (result == STR_FLEX_868) {
|
||||
reusableBuffer.moduleSetup.bindInformation.flexMode = 0;
|
||||
}
|
||||
else if (result == STR_FLEX_915) {
|
||||
reusableBuffer.moduleSetup.bindInformation.flexMode = 1;
|
||||
}
|
||||
else {
|
||||
// the user pressed [Exit]
|
||||
uint8_t moduleIdx = CURRENT_MODULE_EDITED(menuVerticalPosition - HEADER_LINE);
|
||||
uint8_t receiverIdx = CURRENT_RECEIVER_EDITED(menuVerticalPosition - HEADER_LINE);
|
||||
moduleState[moduleIdx].mode = MODULE_MODE_NORMAL;
|
||||
removePXX2ReceiverIfEmpty(moduleIdx, receiverIdx);
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(SIMU)
|
||||
uint8_t moduleIdx = CURRENT_MODULE_EDITED(menuVerticalPosition - HEADER_LINE);
|
||||
uint8_t receiverIdx = CURRENT_RECEIVER_EDITED(menuVerticalPosition - HEADER_LINE);
|
||||
memcpy(g_model.moduleData[moduleIdx].pxx2.receiverName[receiverIdx], reusableBuffer.moduleSetup.bindInformation.candidateReceiversNames[reusableBuffer.moduleSetup.bindInformation.selectedReceiverIndex], PXX2_LEN_RX_NAME);
|
||||
storageDirty(EE_MODEL);
|
||||
moduleState[moduleIdx].mode = MODULE_MODE_NORMAL;
|
||||
reusableBuffer.moduleSetup.bindInformation.step = BIND_OK;
|
||||
POPUP_INFORMATION(STR_BIND_OK);
|
||||
#else
|
||||
reusableBuffer.moduleSetup.bindInformation.step = BIND_START;
|
||||
#endif
|
||||
}
|
||||
|
||||
void onPXX2BindMenu(const char * result)
|
||||
{
|
||||
if (result != STR_EXIT) {
|
||||
uint8_t moduleIdx = CURRENT_MODULE_EDITED(menuVerticalPosition - HEADER_LINE);
|
||||
reusableBuffer.moduleSetup.bindInformation.selectedReceiverIndex = (result - reusableBuffer.moduleSetup.bindInformation.candidateReceiversNames[0]) / sizeof(reusableBuffer.moduleSetup.bindInformation.candidateReceiversNames[0]);
|
||||
if (isModuleR9M2(moduleIdx) && reusableBuffer.moduleSetup.pxx2.moduleInformation.information.variant == PXX2_VARIANT_EU) {
|
||||
reusableBuffer.moduleSetup.bindInformation.step = BIND_RX_NAME_SELECTED;
|
||||
POPUP_MENU_ADD_ITEM(STR_8CH_WITH_TELEMETRY);
|
||||
POPUP_MENU_ADD_ITEM(STR_16CH_WITH_TELEMETRY);
|
||||
POPUP_MENU_ADD_ITEM(STR_16CH_WITHOUT_TELEMETRY);
|
||||
POPUP_MENU_START(onPXX2R9MBindModeMenu);
|
||||
}
|
||||
else if (isModuleR9M2(moduleIdx) && reusableBuffer.moduleSetup.pxx2.moduleInformation.information.variant == PXX2_VARIANT_FLEX) {
|
||||
reusableBuffer.moduleSetup.bindInformation.step = BIND_RX_NAME_SELECTED;
|
||||
POPUP_MENU_ADD_ITEM(STR_FLEX_868);
|
||||
POPUP_MENU_ADD_ITEM(STR_FLEX_915);
|
||||
POPUP_MENU_START(onPXX2R9MBindModeMenu);
|
||||
}
|
||||
else {
|
||||
#if defined(SIMU)
|
||||
uint8_t receiverIdx = CURRENT_RECEIVER_EDITED(menuVerticalPosition - HEADER_LINE);
|
||||
memcpy(g_model.moduleData[moduleIdx].pxx2.receiverName[receiverIdx], result, PXX2_LEN_RX_NAME);
|
||||
storageDirty(EE_MODEL);
|
||||
moduleState[moduleIdx].mode = MODULE_MODE_NORMAL;
|
||||
reusableBuffer.moduleSetup.bindInformation.step = BIND_OK;
|
||||
POPUP_INFORMATION(STR_BIND_OK);
|
||||
#else
|
||||
reusableBuffer.moduleSetup.bindInformation.step = BIND_START;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else {
|
||||
// the user pressed [Exit]
|
||||
uint8_t moduleIdx = CURRENT_MODULE_EDITED(menuVerticalPosition - HEADER_LINE);
|
||||
uint8_t receiverIdx = CURRENT_RECEIVER_EDITED(menuVerticalPosition - HEADER_LINE);
|
||||
moduleState[moduleIdx].mode = MODULE_MODE_NORMAL;
|
||||
removePXX2ReceiverIfEmpty(moduleIdx, receiverIdx);
|
||||
}
|
||||
}
|
||||
|
||||
void onResetReceiverConfirm(const char * result)
|
||||
{
|
||||
if (result == STR_OK) {
|
||||
uint8_t moduleIdx = CURRENT_MODULE_EDITED(menuVerticalPosition - HEADER_LINE);
|
||||
uint8_t receiverIdx = CURRENT_RECEIVER_EDITED(menuVerticalPosition - HEADER_LINE);
|
||||
moduleState[moduleIdx].mode = MODULE_MODE_RESET;
|
||||
removePXX2Receiver(moduleIdx, receiverIdx);
|
||||
}
|
||||
}
|
||||
|
||||
void onPXX2ReceiverMenu(const char * result)
|
||||
{
|
||||
uint8_t moduleIdx = CURRENT_MODULE_EDITED(menuVerticalPosition - HEADER_LINE);
|
||||
uint8_t receiverIdx = CURRENT_RECEIVER_EDITED(menuVerticalPosition - HEADER_LINE);
|
||||
|
||||
if (result == STR_OPTIONS) {
|
||||
memclear(&reusableBuffer.hardwareAndSettings, sizeof(reusableBuffer.hardwareAndSettings));
|
||||
reusableBuffer.hardwareAndSettings.receiverSettings.receiverId = receiverIdx;
|
||||
g_moduleIdx = moduleIdx;
|
||||
pushMenu(menuModelReceiverOptions);
|
||||
}
|
||||
else if (result == STR_BIND) {
|
||||
memclear(&reusableBuffer.moduleSetup.bindInformation, sizeof(BindInformation));
|
||||
reusableBuffer.moduleSetup.bindInformation.rxUid = receiverIdx;
|
||||
if (isModuleR9M2(moduleIdx)) {
|
||||
#if defined(SIMU)
|
||||
reusableBuffer.moduleSetup.pxx2.moduleInformation.information.modelID = 1;
|
||||
reusableBuffer.moduleSetup.pxx2.moduleInformation.information.variant = 2;
|
||||
#else
|
||||
moduleState[moduleIdx].readModuleInformation(&reusableBuffer.moduleSetup.pxx2.moduleInformation, PXX2_HW_INFO_TX_ID, PXX2_HW_INFO_TX_ID);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
moduleState[moduleIdx].startBind(&reusableBuffer.moduleSetup.bindInformation);
|
||||
}
|
||||
s_editMode = 1;
|
||||
}
|
||||
else if (result == STR_SHARE) {
|
||||
reusableBuffer.moduleSetup.pxx2.shareReceiverIndex = receiverIdx;
|
||||
moduleState[moduleIdx].mode = MODULE_MODE_SHARE;
|
||||
s_editMode = 1;
|
||||
}
|
||||
else if (result == STR_DELETE || result == STR_RESET) {
|
||||
memclear(&reusableBuffer.moduleSetup.pxx2, sizeof(reusableBuffer.moduleSetup.pxx2));
|
||||
reusableBuffer.moduleSetup.pxx2.resetReceiverIndex = receiverIdx;
|
||||
reusableBuffer.moduleSetup.pxx2.resetReceiverFlags = (result == STR_RESET ? 0xFF : 0x01);
|
||||
POPUP_CONFIRMATION(result == STR_RESET ? STR_RECEIVER_RESET : STR_RECEIVER_DELETE, onResetReceiverConfirm);
|
||||
}
|
||||
else {
|
||||
removePXX2ReceiverIfEmpty(moduleIdx, receiverIdx);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
|
||||
moduleState[moduleIdx].mode = MODULE_MODE_BIND;
|
||||
}
|
||||
|
||||
enum PopupRegisterItems {
|
||||
ITEM_REGISTER_PASSWORD,
|
||||
ITEM_REGISTER_MODULE_INDEX,
|
||||
ITEM_REGISTER_RECEIVER_NAME,
|
||||
ITEM_REGISTER_BUTTONS
|
||||
};
|
||||
|
||||
void runPopupRegister(event_t event)
|
||||
{
|
||||
uint8_t backupVerticalPosition = menuVerticalPosition;
|
||||
uint8_t backupHorizontalPosition = menuHorizontalPosition;
|
||||
uint8_t backupVerticalOffset = menuVerticalOffset;
|
||||
int8_t backupEditMode = s_editMode;
|
||||
|
||||
menuVerticalPosition = reusableBuffer.moduleSetup.pxx2.registerPopupVerticalPosition;
|
||||
menuHorizontalPosition = reusableBuffer.moduleSetup.pxx2.registerPopupHorizontalPosition;
|
||||
s_editMode = reusableBuffer.moduleSetup.pxx2.registerPopupEditMode;
|
||||
|
||||
switch (event) {
|
||||
case EVT_KEY_BREAK(KEY_ENTER):
|
||||
if (menuVerticalPosition != ITEM_REGISTER_BUTTONS) {
|
||||
break;
|
||||
}
|
||||
else if (reusableBuffer.moduleSetup.pxx2.registerStep >= REGISTER_RX_NAME_RECEIVED && menuHorizontalPosition == 0) {
|
||||
// [Enter] pressed
|
||||
reusableBuffer.moduleSetup.pxx2.registerStep = REGISTER_RX_NAME_SELECTED;
|
||||
backupEditMode = EDIT_MODIFY_FIELD; // so that the [Register] button blinks and the REGISTER process can continue
|
||||
}
|
||||
// no break
|
||||
|
||||
case EVT_KEY_LONG(KEY_EXIT):
|
||||
s_editMode = 0;
|
||||
// no break;
|
||||
|
||||
case EVT_KEY_BREAK(KEY_EXIT):
|
||||
if (s_editMode <= 0) {
|
||||
warningText = nullptr;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (warningText) {
|
||||
const uint8_t dialogRows[] = { 0, 0, uint8_t(reusableBuffer.moduleSetup.pxx2.registerStep < REGISTER_RX_NAME_RECEIVED ? READONLY_ROW : 0), uint8_t(reusableBuffer.moduleSetup.pxx2.registerStep < REGISTER_RX_NAME_RECEIVED ? 0 : 1)};
|
||||
check(event, 0, nullptr, 0, dialogRows, 3, 4 - HEADER_LINE); // TODO add a comment for 3 - HEADER_LINE once understood
|
||||
|
||||
drawMessageBox(warningText);
|
||||
|
||||
// registration password
|
||||
lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y - 4, STR_REG_ID);
|
||||
editName(WARNING_LINE_X + 8*FW, WARNING_LINE_Y - 4, g_model.modelRegistrationID, PXX2_LEN_REGISTRATION_ID, event, menuVerticalPosition == ITEM_REGISTER_PASSWORD);
|
||||
|
||||
// loop index (will be removed in future)
|
||||
lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y - 4 + FH, "UID");
|
||||
lcdDrawNumber(WARNING_LINE_X + 8*FW, WARNING_LINE_Y - 4 + FH, reusableBuffer.moduleSetup.pxx2.registerLoopIndex, menuVerticalPosition == ITEM_REGISTER_MODULE_INDEX ? (s_editMode ? INVERS + BLINK : INVERS) : 0);
|
||||
if (menuVerticalPosition == ITEM_REGISTER_MODULE_INDEX && s_editMode) {
|
||||
CHECK_INCDEC_MODELVAR_ZERO(event, reusableBuffer.moduleSetup.pxx2.registerLoopIndex, 2);
|
||||
}
|
||||
|
||||
// RX name
|
||||
if (reusableBuffer.moduleSetup.pxx2.registerStep < REGISTER_RX_NAME_RECEIVED) {
|
||||
lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y - 4 + 2 * FH, STR_WAITING);
|
||||
lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y - 2 + 3 * FH, TR_EXIT, menuVerticalPosition == ITEM_REGISTER_BUTTONS ? INVERS : 0);
|
||||
}
|
||||
else {
|
||||
lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y - 4 + 2 * FH, STR_RX_NAME);
|
||||
editName(WARNING_LINE_X + 8*FW, WARNING_LINE_Y - 4 + 2 * FH, reusableBuffer.moduleSetup.pxx2.registerRxName, PXX2_LEN_RX_NAME, event, menuVerticalPosition == ITEM_REGISTER_RECEIVER_NAME);
|
||||
lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y - 2 + 3 * FH, TR_ENTER, menuVerticalPosition == ITEM_REGISTER_BUTTONS && menuHorizontalPosition == 0 ? INVERS : 0);
|
||||
lcdDrawText(WARNING_LINE_X + 8*FW, WARNING_LINE_Y - 2 + 3 * FH, TR_EXIT, menuVerticalPosition == ITEM_REGISTER_BUTTONS && menuHorizontalPosition == 1 ? INVERS : 0);
|
||||
}
|
||||
|
||||
reusableBuffer.moduleSetup.pxx2.registerPopupVerticalPosition = menuVerticalPosition;
|
||||
reusableBuffer.moduleSetup.pxx2.registerPopupHorizontalPosition = menuHorizontalPosition;
|
||||
reusableBuffer.moduleSetup.pxx2.registerPopupEditMode = s_editMode;
|
||||
}
|
||||
|
||||
menuVerticalPosition = backupVerticalPosition;
|
||||
menuHorizontalPosition = backupHorizontalPosition;
|
||||
menuVerticalOffset = backupVerticalOffset;
|
||||
s_editMode = backupEditMode;
|
||||
}
|
||||
|
||||
void startRegisterDialog(uint8_t module)
|
||||
{
|
||||
memclear(&reusableBuffer.moduleSetup.pxx2, sizeof(reusableBuffer.moduleSetup.pxx2));
|
||||
reusableBuffer.moduleSetup.pxx2.registerPopupVerticalPosition = ITEM_REGISTER_BUTTONS;
|
||||
moduleState[module].mode = MODULE_MODE_REGISTER;
|
||||
s_editMode = 0;
|
||||
killAllEvents();
|
||||
POPUP_INPUT("", runPopupRegister);
|
||||
}
|
||||
|
||||
#if defined(BLUETOOTH)
|
||||
void onBluetoothConnectMenu(const char * result)
|
||||
{
|
||||
@@ -516,20 +256,26 @@ void onBluetoothConnectMenu(const char * result)
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "common/stdlcd/model_setup_pxx1.cpp"
|
||||
|
||||
#if defined(PXX2)
|
||||
#include "common/stdlcd/model_setup_pxx2.cpp"
|
||||
#endif
|
||||
|
||||
#if defined(HARDWARE_INTERNAL_MODULE)
|
||||
#define INTERNAL_MODULE_ROWS \
|
||||
LABEL(InternalModule), \
|
||||
INTERNAL_MODULE_TYPE_ROWS, \
|
||||
INTERNAL_MODULE_CHANNELS_ROWS, \
|
||||
IF_NOT_ACCESS_MODULE_RF(INTERNAL_MODULE, IF_INTERNAL_MODULE_ON(HAS_RF_PROTOCOL_MODELINDEX(g_model.moduleData[INTERNAL_MODULE].rfProtocol) ? (uint8_t)2 : (uint8_t)1)), \
|
||||
IF_ACCESS_MODULE_RF(INTERNAL_MODULE, 0), \
|
||||
IF_ACCESS_MODULE_RF(INTERNAL_MODULE, 0), /* RxNum */ \
|
||||
ANTENNA_ROW \
|
||||
IF_INTERNAL_MODULE_ON(FAILSAFE_ROWS(INTERNAL_MODULE)), \
|
||||
IF_ACCESS_MODULE_RF(INTERNAL_MODULE, 1), \
|
||||
IF_PXX2_MODULE(INTERNAL_MODULE, 0), \
|
||||
IF_ACCESS_MODULE_RF(INTERNAL_MODULE, 0), \
|
||||
IF_ACCESS_MODULE_RF(INTERNAL_MODULE, 0), \
|
||||
IF_ACCESS_MODULE_RF(INTERNAL_MODULE, 0),
|
||||
IF_INTERNAL_MODULE_ON(FAILSAFE_ROWS(INTERNAL_MODULE)), /* Failsafe */ \
|
||||
IF_ACCESS_MODULE_RF(INTERNAL_MODULE, 1), /* Range check and Register buttons */ \
|
||||
IF_PXX2_MODULE(INTERNAL_MODULE, 0), /* Module options */ \
|
||||
IF_ACCESS_MODULE_RF(INTERNAL_MODULE, 0), /* Receiver 1 */ \
|
||||
IF_ACCESS_MODULE_RF(INTERNAL_MODULE, 0), /* Receiver 2 */ \
|
||||
IF_ACCESS_MODULE_RF(INTERNAL_MODULE, 0), /* Receiver 3 */
|
||||
#else
|
||||
#define INTERNAL_MODULE_ROWS
|
||||
#endif
|
||||
@@ -565,7 +311,7 @@ void menuModelSetup(event_t event)
|
||||
0, // Checklist
|
||||
0, // Throttle warning
|
||||
SW_WARN_ROWS, // Switch warning
|
||||
POT_WARN_ITEMS(), // Pot warning
|
||||
POT_WARN_ROWS, // Pot warning
|
||||
|
||||
NUM_STICKS + NUM_POTS + NUM_SLIDERS - 1, // Center beeps
|
||||
0, // Global functions
|
||||
@@ -579,7 +325,7 @@ void menuModelSetup(event_t event)
|
||||
MULTIMODULE_SUBTYPE_ROWS(EXTERNAL_MODULE)
|
||||
MULTIMODULE_STATUS_ROWS
|
||||
EXTERNAL_MODULE_CHANNELS_ROWS,
|
||||
IF_NOT_ACCESS_MODULE_RF(EXTERNAL_MODULE, EXTERNAL_MODULE_BIND_ROWS()), // line reused for PPM: PPM settings
|
||||
IF_NOT_ACCESS_MODULE_RF(EXTERNAL_MODULE, EXTERNAL_MODULE_BIND_ROWS), // line reused for PPM: PPM settings
|
||||
IF_ACCESS_MODULE_RF(EXTERNAL_MODULE, 0), // RxNum
|
||||
IF_NOT_PXX2_MODULE(EXTERNAL_MODULE, EXTERNAL_MODULE_OPTION_ROW),
|
||||
MULTIMODULE_MODULE_ROWS
|
||||
@@ -600,8 +346,8 @@ void menuModelSetup(event_t event)
|
||||
MULTIMODULE_SUBTYPE_ROWS(EXTERNAL_MODULE)
|
||||
MULTIMODULE_STATUS_ROWS
|
||||
EXTERNAL_MODULE_CHANNELS_ROWS,
|
||||
EXTERNAL_MODULE_BIND_ROWS(),
|
||||
OUTPUT_TYPE_ROWS()
|
||||
EXTERNAL_MODULE_BIND_ROWS,
|
||||
OUTPUT_TYPE_ROW
|
||||
EXTERNAL_MODULE_OPTION_ROW,
|
||||
MULTIMODULE_MODULE_ROWS
|
||||
EXTERNAL_MODULE_POWER_ROW,
|
||||
@@ -612,6 +358,11 @@ void menuModelSetup(event_t event)
|
||||
#endif
|
||||
|
||||
MENU_CHECK(menuTabModel, MENU_MODEL_SETUP, HEADER_LINE + ITEM_MODEL_SETUP_LINES_COUNT);
|
||||
title(STR_MENUSETUP);
|
||||
|
||||
if (event == EVT_ENTRY) {
|
||||
reusableBuffer.moduleSetup.r9mPower = g_model.moduleData[EXTERNAL_MODULE].pxx.power;
|
||||
}
|
||||
|
||||
#if (defined(DSM2) || defined(PXX))
|
||||
if (menuEvent) {
|
||||
@@ -622,12 +373,6 @@ void menuModelSetup(event_t event)
|
||||
}
|
||||
#endif
|
||||
|
||||
TITLE(STR_MENUSETUP);
|
||||
|
||||
if (event == EVT_ENTRY) {
|
||||
reusableBuffer.moduleSetup.r9mPower = g_model.moduleData[EXTERNAL_MODULE].pxx.power;
|
||||
}
|
||||
|
||||
uint8_t sub = menuVerticalPosition - HEADER_LINE;
|
||||
|
||||
for (uint8_t i=0; i<NUM_BODY_LINES; ++i) {
|
||||
@@ -1012,7 +757,8 @@ void menuModelSetup(event_t event)
|
||||
lcdDrawTextAlignedLeft(y, TR_INTERNALRF);
|
||||
break;
|
||||
|
||||
case ITEM_MODEL_SETUP_INTERNAL_MODULE_TYPE: {
|
||||
case ITEM_MODEL_SETUP_INTERNAL_MODULE_TYPE:
|
||||
{
|
||||
lcdDrawTextAlignedLeft(y, STR_MODE);
|
||||
#if defined(INTERNAL_MODULE_PXX1)
|
||||
lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN, y, STR_INTERNAL_MODULE_PROTOCOLS, g_model.moduleData[INTERNAL_MODULE].type, menuHorizontalPosition==0 ? attr : 0);
|
||||
|
||||
@@ -173,7 +173,7 @@ void menuCommonCalib(event_t event)
|
||||
void menuRadioCalibration(event_t event)
|
||||
{
|
||||
check_submenu_simple(event, 0);
|
||||
TITLE(STR_MENUCALIBRATION);
|
||||
title(STR_MENUCALIBRATION);
|
||||
menuCommonCalib(READ_ONLY() ? 0 : event);
|
||||
if (menuEvent) {
|
||||
menuCalibrationState = CALIB_START;
|
||||
|
||||
@@ -63,7 +63,7 @@ void menuRadioModulesVersion(event_t event)
|
||||
return;
|
||||
}
|
||||
|
||||
TITLE(STR_MENU_MODULES_RX_VERSION);
|
||||
title(STR_MENU_MODULES_RX_VERSION);
|
||||
|
||||
if (event == EVT_ENTRY || get_tmr10ms() >= reusableBuffer.hardwareAndSettings.updateTime) {
|
||||
// menuVerticalOffset = 0;
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
void menuStatisticsView(event_t event)
|
||||
{
|
||||
TITLE(STR_MENUSTAT);
|
||||
title(STR_MENUSTAT);
|
||||
|
||||
switch (event) {
|
||||
case EVT_KEY_FIRST(KEY_UP):
|
||||
@@ -116,7 +116,7 @@ void menuStatisticsView(event_t event)
|
||||
|
||||
void menuStatisticsDebug(event_t event)
|
||||
{
|
||||
TITLE(STR_MENUDEBUG);
|
||||
title(STR_MENUDEBUG);
|
||||
|
||||
switch (event) {
|
||||
case EVT_KEY_LONG(KEY_ENTER):
|
||||
@@ -242,7 +242,7 @@ void menuStatisticsDebug(event_t event)
|
||||
#if defined(STM32)
|
||||
void menuStatisticsDebug2(event_t event)
|
||||
{
|
||||
TITLE(STR_MENUDEBUG);
|
||||
title(STR_MENUDEBUG);
|
||||
|
||||
switch (event) {
|
||||
case EVT_KEY_FIRST(KEY_ENTER):
|
||||
|
||||
Reference in New Issue
Block a user