Module options
This commit is contained in:
@@ -171,10 +171,9 @@ void title(const char * s);
|
||||
#if defined(PCBX7) || defined(PCBX3)
|
||||
#define SIMPLE_MENU_NOTITLE(tab, menu, lines_count) \
|
||||
check_simple(event, menu, tab, DIM(tab), lines_count);
|
||||
#define SUBMENU_NOTITLE(lines_count, ...) { \
|
||||
#define SUBMENU_NOTITLE(lines_count, ...) \
|
||||
MENU_TAB(__VA_ARGS__); \
|
||||
check(event, 0, NULL, 0, mstate_tab, DIM(mstate_tab)-1, lines_count); \
|
||||
}
|
||||
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); \
|
||||
@@ -184,10 +183,9 @@ void title(const char * s);
|
||||
#else
|
||||
#define SIMPLE_MENU_NOTITLE(tab, menu, lines_count) \
|
||||
check_simple(event, menu, tab, DIM(tab), (lines_count)-1);
|
||||
#define SUBMENU_NOTITLE(lines_count, ...) { \
|
||||
#define SUBMENU_NOTITLE(lines_count, ...) \
|
||||
MENU_TAB(__VA_ARGS__); \
|
||||
check(event, 0, NULL, 0, mstate_tab, DIM(mstate_tab)-1, (lines_count)-1); \
|
||||
}
|
||||
check(event, 0, NULL, 0, mstate_tab, DIM(mstate_tab)-1, (lines_count)-1);
|
||||
|
||||
#define SUBMENU(title, lines_count, ...) \
|
||||
MENU_TAB(__VA_ARGS__); \
|
||||
|
||||
@@ -37,16 +37,42 @@ void onTxOptionsUpdateConfirm(const char * result)
|
||||
}
|
||||
}
|
||||
|
||||
enum MenuModelModuleOptionsItems {
|
||||
enum {
|
||||
ITEM_MODULE_SETTINGS_RF_PROTOCOL,
|
||||
ITEM_MODULE_SETTINGS_EXTERNAL_ANTENNA,
|
||||
ITEM_MODULE_SETTINGS_POWER,
|
||||
ITEM_MODULE_SETTINGS_COUNT
|
||||
};
|
||||
|
||||
extern uint8_t moduleOptions[];
|
||||
|
||||
#define IF_MODULE_OPTIONS(option, count) uint8_t((moduleOptions[modelId] & (1 << option)) ? count : HIDDEN_ROW)
|
||||
|
||||
void menuModelModuleOptions(event_t event)
|
||||
{
|
||||
SIMPLE_SUBMENU_NOTITLE(ITEM_MODULE_SETTINGS_COUNT);
|
||||
uint8_t modelId = reusableBuffer.hardwareAndSettings.modules[g_moduleIdx].information.modelID;
|
||||
|
||||
SUBMENU_NOTITLE(ITEM_MODULE_SETTINGS_COUNT, {
|
||||
IF_MODULE_OPTIONS(0, 0),
|
||||
IF_MODULE_OPTIONS(1, 0),
|
||||
IF_MODULE_OPTIONS(2, 0),
|
||||
});
|
||||
|
||||
if (event == EVT_ENTRY) {
|
||||
#if defined(SIMU)
|
||||
reusableBuffer.hardwareAndSettings.moduleSettings.state = PXX2_SETTINGS_OK;
|
||||
#else
|
||||
// no need to initialize reusableBuffer.hardwareAndSettings.moduleSettings.state to PXX2_HARDWARE_INFO
|
||||
reusableBuffer.hardwareAndSettings.modules[g_moduleIdx].current = PXX2_HW_INFO_TX_ID;
|
||||
reusableBuffer.hardwareAndSettings.modules[g_moduleIdx].maximum = PXX2_HW_INFO_TX_ID;
|
||||
moduleSettings[g_moduleIdx].mode = MODULE_MODE_GET_HARDWARE_INFO;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (reusableBuffer.hardwareAndSettings.moduleSettings.state == PXX2_HARDWARE_INFO && moduleSettings[g_moduleIdx].mode == MODULE_MODE_NORMAL) {
|
||||
reusableBuffer.hardwareAndSettings.moduleSettings.state = PXX2_SETTINGS_READ;
|
||||
moduleSettings[g_moduleIdx].mode = MODULE_MODE_MODULE_SETTINGS;
|
||||
}
|
||||
|
||||
if (menuEvent) {
|
||||
moduleSettings[g_moduleIdx].mode = MODULE_MODE_NORMAL;
|
||||
@@ -59,27 +85,31 @@ void menuModelModuleOptions(event_t event)
|
||||
}
|
||||
}
|
||||
|
||||
if (event == EVT_KEY_LONG(KEY_ENTER) && reusableBuffer.hardwareAndSettings.moduleSettings.dirty) {
|
||||
killEvents(event);
|
||||
reusableBuffer.hardwareAndSettings.moduleSettings.state = PXX2_SETTINGS_WRITE;
|
||||
reusableBuffer.hardwareAndSettings.moduleSettings.dirty = 0;
|
||||
reusableBuffer.hardwareAndSettings.moduleSettings.timeout = 0;
|
||||
moduleSettings[g_moduleIdx].mode = MODULE_MODE_MODULE_SETTINGS;
|
||||
}
|
||||
|
||||
if (reusableBuffer.hardwareAndSettings.moduleSettings.dirty == 2 && reusableBuffer.hardwareAndSettings.moduleSettings.state == PXX2_SETTINGS_OK) {
|
||||
popMenu();
|
||||
}
|
||||
|
||||
int8_t sub = menuVerticalPosition;
|
||||
|
||||
lcdDrawTextAlignedLeft(0, "Module options");
|
||||
lcdInvertLine(0);
|
||||
|
||||
if (event == EVT_ENTRY) {
|
||||
#if defined(SIMU)
|
||||
reusableBuffer.hardwareAndSettings.moduleSettings.state = PXX2_SETTINGS_OK;
|
||||
#else
|
||||
moduleSettings[g_moduleIdx].mode = MODULE_MODE_MODULE_SETTINGS;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (reusableBuffer.hardwareAndSettings.moduleSettings.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;
|
||||
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) {
|
||||
|
||||
@@ -39,9 +39,9 @@ void onRxOptionsUpdateConfirm(const char * result)
|
||||
}
|
||||
|
||||
enum {
|
||||
ITEM_RECEIVER_TELEMETRY,
|
||||
ITEM_RECEIVER_PWM_RATE,
|
||||
ITEM_RECEIVER_PINMAP_FIRST
|
||||
ITEM_RECEIVER_TELEMETRY,
|
||||
ITEM_RECEIVER_PWM_RATE,
|
||||
ITEM_RECEIVER_PINMAP_FIRST
|
||||
};
|
||||
|
||||
void menuModelReceiverOptions(event_t event)
|
||||
@@ -58,6 +58,8 @@ void menuModelReceiverOptions(event_t event)
|
||||
reusableBuffer.hardwareAndSettings.receiverSettings.outputsCount = 8;
|
||||
#else
|
||||
// no need to initialize reusableBuffer.hardwareAndSettings.receiverSettings.state to PXX2_HARDWARE_INFO
|
||||
reusableBuffer.hardwareAndSettings.modules[g_moduleIdx].current = reusableBuffer.hardwareAndSettings.receiverSettings.receiverId;
|
||||
reusableBuffer.hardwareAndSettings.modules[g_moduleIdx].maximum = reusableBuffer.hardwareAndSettings.receiverSettings.receiverId;
|
||||
moduleSettings[g_moduleIdx].mode = MODULE_MODE_GET_HARDWARE_INFO;
|
||||
#endif
|
||||
}
|
||||
@@ -92,7 +94,6 @@ void menuModelReceiverOptions(event_t event)
|
||||
}
|
||||
|
||||
int8_t sub = menuVerticalPosition;
|
||||
|
||||
lcdDrawTextAlignedLeft(0, STR_RECEIVER_OPTIONS);
|
||||
drawReceiverName(FW * 13, 0, reusableBuffer.hardwareAndSettings.receiverSettings.receiverId);
|
||||
lcdInvertLine(0);
|
||||
|
||||
@@ -61,6 +61,18 @@ static const char * const modulesModels[] = {
|
||||
"R9MLite-PRO",
|
||||
};
|
||||
|
||||
/* order: RF Protocol, External antenna, Power */
|
||||
uint8_t moduleOptions[] = {
|
||||
0b00000010, // None
|
||||
0b11111011, // XJT
|
||||
0b11111011, // IXJT
|
||||
0b11111011, // IXJT-PRO
|
||||
0b11111011, // IXJT-S
|
||||
0b11111100, // R9M
|
||||
0b11111100, // R9MLite
|
||||
0b11111100, // R9MLite-PRO
|
||||
};
|
||||
|
||||
static const char * const receiversModels[] = {
|
||||
"---",
|
||||
"X8R",
|
||||
@@ -105,15 +117,15 @@ void menuRadioModulesVersion(event_t event)
|
||||
memclear(&reusableBuffer.hardwareAndSettings.modules, sizeof(reusableBuffer.hardwareAndSettings.modules));
|
||||
|
||||
if (isModulePXX2(INTERNAL_MODULE) && IS_INTERNAL_MODULE_ON()) {
|
||||
moduleSettings[INTERNAL_MODULE].mode = MODULE_MODE_GET_HARDWARE_INFO;
|
||||
reusableBuffer.hardwareAndSettings.modules[INTERNAL_MODULE].current = PXX2_HW_INFO_TX_ID;
|
||||
reusableBuffer.hardwareAndSettings.modules[INTERNAL_MODULE].maximum = MAX_RECEIVERS_PER_MODULE - 1;
|
||||
moduleSettings[INTERNAL_MODULE].mode = MODULE_MODE_GET_HARDWARE_INFO;
|
||||
}
|
||||
|
||||
if (isModulePXX2(EXTERNAL_MODULE) && IS_EXTERNAL_MODULE_ON()) {
|
||||
moduleSettings[EXTERNAL_MODULE].mode = MODULE_MODE_GET_HARDWARE_INFO;
|
||||
reusableBuffer.hardwareAndSettings.modules[EXTERNAL_MODULE].current = PXX2_HW_INFO_TX_ID;
|
||||
reusableBuffer.hardwareAndSettings.modules[EXTERNAL_MODULE].maximum = MAX_RECEIVERS_PER_MODULE - 1;
|
||||
moduleSettings[EXTERNAL_MODULE].mode = MODULE_MODE_GET_HARDWARE_INFO;
|
||||
}
|
||||
|
||||
reusableBuffer.hardwareAndSettings.updateTime = get_tmr10ms() + 1000 /* 10s*/;
|
||||
|
||||
Reference in New Issue
Block a user