mirror of
https://github.com/opentx/opentx.git
synced 2025-07-16 21:05:26 +03:00
R9M Lite BIND / TX OPTIONS / RX OPTIONS reviewed
This commit is contained in:
parent
4c8c979e12
commit
ac2ce487fa
7 changed files with 97 additions and 54 deletions
|
@ -1206,12 +1206,31 @@ void menuModelSetup(event_t event)
|
|||
|
||||
drawReceiverName(MODEL_SETUP_2ND_COLUMN, y, moduleIdx, receiverIdx, attr);
|
||||
|
||||
if (s_editMode && isModuleR9MAccess(moduleIdx) && moduleState[moduleIdx].mode == MODULE_MODE_NORMAL && moduleInformation.information.modelID) {
|
||||
moduleInformation.information.modelID = 0;
|
||||
if (s_editMode && isModuleR9MAccess(moduleIdx) && moduleState[moduleIdx].mode == MODULE_MODE_NORMAL && reusableBuffer.moduleSetup.bindInformation.step < 0) {
|
||||
lcdDrawNumber(lcdNextPos, y, reusableBuffer.moduleSetup.bindInformation.step);
|
||||
if (reusableBuffer.moduleSetup.bindInformation.step == BIND_MODULE_TX_INFORMATION_REQUEST && moduleInformation.information.modelID) {
|
||||
// For R9M ACCESS the module information has been requested to know if we are in EU mode. We just receive it here and continue
|
||||
if (moduleInformation.information.variant == PXX2_VARIANT_EU) {
|
||||
// In EU mode we will need the power of the module to know if telemetry can be proposed
|
||||
reusableBuffer.moduleSetup.bindInformation.step = BIND_MODULE_TX_SETTINGS_REQUEST;
|
||||
#if defined(SIMU)
|
||||
reusableBuffer.moduleSetup.pxx2.moduleSettings.txPower = 14;
|
||||
#else
|
||||
moduleState[moduleIdx].readModuleSettings(&reusableBuffer.moduleSetup.pxx2.moduleSettings);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
reusableBuffer.moduleSetup.bindInformation.step = 0;
|
||||
moduleState[moduleIdx].startBind(&reusableBuffer.moduleSetup.bindInformation);
|
||||
}
|
||||
|
||||
if (attr && (moduleState[moduleIdx].mode == 0 || s_editMode == 0)) {
|
||||
}
|
||||
else if (reusableBuffer.moduleSetup.bindInformation.step == BIND_MODULE_TX_SETTINGS_REQUEST && reusableBuffer.moduleSetup.pxx2.moduleSettings.txPower > 0) {
|
||||
// We just receive the module settings (for TX power)
|
||||
reusableBuffer.moduleSetup.bindInformation.step = 0;
|
||||
moduleState[moduleIdx].startBind(&reusableBuffer.moduleSetup.bindInformation);
|
||||
}
|
||||
}
|
||||
else if (attr && (moduleState[moduleIdx].mode == MODULE_MODE_NORMAL || s_editMode == 0)) {
|
||||
if (moduleState[moduleIdx].mode) {
|
||||
moduleState[moduleIdx].mode = 0;
|
||||
removePXX2ReceiverIfEmpty(moduleIdx, receiverIdx);
|
||||
|
|
|
@ -26,9 +26,10 @@
|
|||
extern uint8_t g_moduleIdx;
|
||||
|
||||
enum {
|
||||
MODULE_SETTINGS_OK,
|
||||
MODULE_SETTINGS_DIRTY,
|
||||
MODULE_SETTINGS_WRITING,
|
||||
MODULE_SETTINGS_OK = 0,
|
||||
MODULE_SETTINGS_DIRTY = 1,
|
||||
MODULE_SETTINGS_REBIND = 2,
|
||||
MODULE_SETTINGS_WRITING = 4,
|
||||
};
|
||||
|
||||
void onTxOptionsUpdateConfirm(const char * result)
|
||||
|
@ -45,6 +46,7 @@ void onTxOptionsUpdateConfirm(const char * result)
|
|||
enum {
|
||||
ITEM_MODULE_SETTINGS_EXTERNAL_ANTENNA,
|
||||
ITEM_MODULE_SETTINGS_POWER,
|
||||
ITEM_MODULE_SETTINGS_TELEMETRY,
|
||||
ITEM_MODULE_SETTINGS_COUNT
|
||||
};
|
||||
|
||||
|
@ -57,8 +59,8 @@ bool isPowerAvailable(int value)
|
|||
|
||||
if (modelId == PXX2_MODULE_R9M_LITE) {
|
||||
if (variant == PXX2_VARIANT_EU)
|
||||
return (value == 14 /* 25 mW */ ||
|
||||
value == 20 /* 100 mW */);
|
||||
return (value == 14 /* 25 mW with telemetry */ ||
|
||||
value == 20 /* 100 mW without telemetry */);
|
||||
else
|
||||
return value == 20; /* 100 mW */
|
||||
}
|
||||
|
@ -94,13 +96,14 @@ void menuModelModuleOptions(event_t event)
|
|||
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_MODULE_OPTIONS(MODULE_OPTION_POWER, reusableBuffer.hardwareAndSettings.modules[g_moduleIdx].information.variant == PXX2_VARIANT_EU && reusableBuffer.hardwareAndSettings.moduleSettings.txPower > 14 ? READONLY_ROW : HIDDEN_ROW)
|
||||
});
|
||||
|
||||
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
|
||||
if (!modelId)
|
||||
moduleState[g_moduleIdx].readModuleInformation(&reusableBuffer.hardwareAndSettings.modules[g_moduleIdx], PXX2_HW_INFO_TX_ID, PXX2_HW_INFO_TX_ID);
|
||||
else
|
||||
moduleState[g_moduleIdx].readModuleSettings(&reusableBuffer.hardwareAndSettings.moduleSettings);
|
||||
}
|
||||
|
||||
if (menuEvent) {
|
||||
|
@ -166,11 +169,19 @@ void menuModelModuleOptions(event_t event)
|
|||
lcdDrawText(lcdNextPos, y, ")");
|
||||
if (attr) {
|
||||
reusableBuffer.hardwareAndSettings.moduleSettings.txPower = checkIncDec(event, reusableBuffer.hardwareAndSettings.moduleSettings.txPower, 0, 30, 0, &isPowerAvailable);
|
||||
if (checkIncDec_Ret) {
|
||||
reusableBuffer.hardwareAndSettings.moduleSettings.dirty = MODULE_SETTINGS_DIRTY;
|
||||
if (checkIncDec_Ret)
|
||||
reusableBuffer.hardwareAndSettings.moduleSettings.dirty = MODULE_SETTINGS_DIRTY | MODULE_SETTINGS_REBIND;
|
||||
if (s_editMode == 0 && (reusableBuffer.hardwareAndSettings.moduleSettings.dirty & MODULE_SETTINGS_REBIND)) {
|
||||
reusableBuffer.hardwareAndSettings.moduleSettings.dirty &= ~MODULE_SETTINGS_REBIND;
|
||||
POPUP_WARNING(STR_REBIND);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ITEM_MODULE_SETTINGS_TELEMETRY:
|
||||
// only displayed in EU mode when TX power > 25mW
|
||||
lcdDrawText(RECEIVER_OPTIONS_2ND_COLUMN, y, "Telem OFF", attr | SMLSIZE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,11 +24,17 @@
|
|||
|
||||
extern uint8_t g_moduleIdx;
|
||||
|
||||
enum {
|
||||
RECEIVER_SETTINGS_OK = 0,
|
||||
RECEIVER_SETTINGS_DIRTY = 1,
|
||||
RECEIVER_SETTINGS_WRITING = 2,
|
||||
};
|
||||
|
||||
void onRxOptionsUpdateConfirm(const char * result)
|
||||
{
|
||||
if (result == STR_OK) {
|
||||
reusableBuffer.hardwareAndSettings.receiverSettings.state = PXX2_SETTINGS_WRITE;
|
||||
reusableBuffer.hardwareAndSettings.receiverSettings.dirty = 2;
|
||||
reusableBuffer.hardwareAndSettings.receiverSettings.dirty = RECEIVER_SETTINGS_WRITING;
|
||||
reusableBuffer.hardwareAndSettings.receiverSettings.timeout = 0;
|
||||
moduleState[g_moduleIdx].mode = MODULE_MODE_RECEIVER_SETTINGS;
|
||||
}
|
||||
|
@ -38,8 +44,8 @@ void onRxOptionsUpdateConfirm(const char * result)
|
|||
}
|
||||
|
||||
enum {
|
||||
ITEM_RECEIVER_SETTINGS_TELEMETRY,
|
||||
ITEM_RECEIVER_SETTINGS_PWM_RATE,
|
||||
ITEM_RECEIVER_SETTINGS_TELEMETRY,
|
||||
ITEM_RECEIVER_SETTINGS_SPORT_FPORT,
|
||||
ITEM_RECEIVER_SETTINGS_CAPABILITY_NOT_SUPPORTED1,
|
||||
ITEM_RECEIVER_SETTINGS_CAPABILITY_NOT_SUPPORTED2,
|
||||
|
@ -62,7 +68,21 @@ void menuModelReceiverOptions(event_t event)
|
|||
reusableBuffer.hardwareAndSettings.receiverSettings.outputsCount = 8;
|
||||
#endif
|
||||
}
|
||||
else if (menuEvent) {
|
||||
|
||||
uint8_t receiverId = reusableBuffer.hardwareAndSettings.receiverSettings.receiverId;
|
||||
uint8_t receiverModelId = reusableBuffer.hardwareAndSettings.modules[g_moduleIdx].receivers[receiverId].information.modelID;
|
||||
uint8_t receiverVariant = reusableBuffer.hardwareAndSettings.modules[g_moduleIdx].receivers[receiverId].information.variant;
|
||||
|
||||
SUBMENU_NOTITLE(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_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),
|
||||
0 // channels ...
|
||||
});
|
||||
|
||||
if (menuEvent) {
|
||||
killEvents(KEY_EXIT);
|
||||
moduleState[g_moduleIdx].mode = MODULE_MODE_NORMAL;
|
||||
if (reusableBuffer.hardwareAndSettings.receiverSettings.dirty) {
|
||||
|
@ -74,37 +94,27 @@ void menuModelReceiverOptions(event_t event)
|
|||
}
|
||||
}
|
||||
|
||||
uint8_t receiverId = reusableBuffer.hardwareAndSettings.receiverSettings.receiverId;
|
||||
uint8_t modelId = reusableBuffer.hardwareAndSettings.modules[g_moduleIdx].receivers[receiverId].information.modelID;
|
||||
|
||||
SUBMENU_NOTITLE(ITEM_RECEIVER_SETTINGS_PINMAP_FIRST + outputsCount, {
|
||||
0, // Telemetry
|
||||
0, // PWM rate
|
||||
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),
|
||||
0 // channels ...
|
||||
});
|
||||
|
||||
if (reusableBuffer.hardwareAndSettings.receiverSettings.state == PXX2_HARDWARE_INFO && moduleState[g_moduleIdx].mode == MODULE_MODE_NORMAL) {
|
||||
if (modelId)
|
||||
moduleState[g_moduleIdx].readReceiverSettings(&reusableBuffer.hardwareAndSettings.receiverSettings);
|
||||
else
|
||||
if (!receiverModelId)
|
||||
moduleState[g_moduleIdx].readModuleInformation(&reusableBuffer.hardwareAndSettings.modules[g_moduleIdx], receiverId, receiverId);
|
||||
else if (isModuleR9MAccess(g_moduleIdx) && receiverVariant == PXX2_VARIANT_EU && !reusableBuffer.hardwareAndSettings.moduleSettings.txPower)
|
||||
moduleState[g_moduleIdx].readModuleSettings(&reusableBuffer.hardwareAndSettings.moduleSettings);
|
||||
else
|
||||
moduleState[g_moduleIdx].readReceiverSettings(&reusableBuffer.hardwareAndSettings.receiverSettings);
|
||||
}
|
||||
|
||||
if (event == EVT_KEY_LONG(KEY_ENTER) && reusableBuffer.hardwareAndSettings.receiverSettings.dirty) {
|
||||
killEvents(event);
|
||||
reusableBuffer.hardwareAndSettings.receiverSettings.dirty = 0;
|
||||
reusableBuffer.hardwareAndSettings.receiverSettings.dirty = RECEIVER_SETTINGS_OK;
|
||||
moduleState[g_moduleIdx].writeReceiverSettings(&reusableBuffer.hardwareAndSettings.receiverSettings);
|
||||
}
|
||||
|
||||
if (reusableBuffer.hardwareAndSettings.receiverSettings.dirty == 2 && reusableBuffer.hardwareAndSettings.receiverSettings.state == PXX2_SETTINGS_OK) {
|
||||
if (reusableBuffer.hardwareAndSettings.receiverSettings.dirty == RECEIVER_SETTINGS_WRITING && reusableBuffer.hardwareAndSettings.receiverSettings.state == PXX2_SETTINGS_OK) {
|
||||
popMenu();
|
||||
return;
|
||||
}
|
||||
|
||||
if (modelId != 0 && mstate_tab[menuVerticalPosition] == HIDDEN_ROW) {
|
||||
if (receiverModelId && mstate_tab[menuVerticalPosition] == HIDDEN_ROW) {
|
||||
menuVerticalPosition = 0;
|
||||
while (menuVerticalPosition < ITEM_RECEIVER_SETTINGS_PINMAP_FIRST && mstate_tab[menuVerticalPosition] == HIDDEN_ROW) {
|
||||
++menuVerticalPosition;
|
||||
|
@ -128,24 +138,24 @@ void menuModelReceiverOptions(event_t event)
|
|||
LcdFlags attr = (sub==i ? (s_editMode>0 ? BLINK|INVERS : INVERS) : 0);
|
||||
|
||||
switch (i) {
|
||||
case ITEM_RECEIVER_SETTINGS_TELEMETRY:
|
||||
reusableBuffer.hardwareAndSettings.receiverSettings.telemetryDisabled = editCheckBox(reusableBuffer.hardwareAndSettings.receiverSettings.telemetryDisabled, RECEIVER_OPTIONS_2ND_COLUMN, y, STR_TELEMETRY_DISABLED, attr, event);
|
||||
if (attr && checkIncDec_Ret) {
|
||||
reusableBuffer.hardwareAndSettings.receiverSettings.dirty = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case ITEM_RECEIVER_SETTINGS_PWM_RATE:
|
||||
reusableBuffer.hardwareAndSettings.receiverSettings.pwmRate = editCheckBox(reusableBuffer.hardwareAndSettings.receiverSettings.pwmRate, RECEIVER_OPTIONS_2ND_COLUMN, y, isModuleR9MAccess(g_moduleIdx) ? "6.67ms PWM": "9ms PWM", attr, event);
|
||||
if (attr && checkIncDec_Ret) {
|
||||
reusableBuffer.hardwareAndSettings.receiverSettings.dirty = true;
|
||||
reusableBuffer.hardwareAndSettings.receiverSettings.dirty = RECEIVER_SETTINGS_DIRTY;
|
||||
}
|
||||
break;
|
||||
|
||||
case ITEM_RECEIVER_SETTINGS_TELEMETRY:
|
||||
reusableBuffer.hardwareAndSettings.receiverSettings.telemetryDisabled = editCheckBox(reusableBuffer.hardwareAndSettings.receiverSettings.telemetryDisabled, RECEIVER_OPTIONS_2ND_COLUMN, y, STR_TELEMETRY_DISABLED, attr, event);
|
||||
if (attr && checkIncDec_Ret) {
|
||||
reusableBuffer.hardwareAndSettings.receiverSettings.dirty = RECEIVER_SETTINGS_DIRTY;
|
||||
}
|
||||
break;
|
||||
|
||||
case ITEM_RECEIVER_SETTINGS_SPORT_FPORT:
|
||||
reusableBuffer.hardwareAndSettings.receiverSettings.fport = editCheckBox(reusableBuffer.hardwareAndSettings.receiverSettings.fport, RECEIVER_OPTIONS_2ND_COLUMN, y, "F.Port", attr, event);
|
||||
if (attr && checkIncDec_Ret) {
|
||||
reusableBuffer.hardwareAndSettings.receiverSettings.dirty = true;
|
||||
reusableBuffer.hardwareAndSettings.receiverSettings.dirty = RECEIVER_SETTINGS_DIRTY;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -173,7 +183,7 @@ void menuModelReceiverOptions(event_t event)
|
|||
if (attr) {
|
||||
mapping = checkIncDec(event, mapping, 0, sentModuleChannels(g_moduleIdx) - 1);
|
||||
if (checkIncDec_Ret) {
|
||||
reusableBuffer.hardwareAndSettings.receiverSettings.dirty = true;
|
||||
reusableBuffer.hardwareAndSettings.receiverSettings.dirty = RECEIVER_SETTINGS_DIRTY;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -82,9 +82,10 @@ void onPXX2BindMenu(const char * result)
|
|||
reusableBuffer.moduleSetup.bindInformation.selectedReceiverIndex = (result - reusableBuffer.moduleSetup.bindInformation.candidateReceiversNames[0]) / sizeof(reusableBuffer.moduleSetup.bindInformation.candidateReceiversNames[0]);
|
||||
if (isModuleR9MAccess(moduleIdx) && reusableBuffer.moduleSetup.pxx2.moduleInformation.information.variant == PXX2_VARIANT_EU) {
|
||||
reusableBuffer.moduleSetup.bindInformation.step = BIND_RX_NAME_SELECTED;
|
||||
POPUP_MENU_ADD_ITEM(STR_16CH_WITH_TELEMETRY);
|
||||
POPUP_MENU_ADD_ITEM(STR_16CH_WITHOUT_TELEMETRY);
|
||||
POPUP_MENU_START(onPXX2R9MBindModeMenu);
|
||||
if (reusableBuffer.moduleSetup.pxx2.moduleSettings.txPower <= 14)
|
||||
onPXX2R9MBindModeMenu(STR_16CH_WITH_TELEMETRY);
|
||||
else
|
||||
onPXX2R9MBindModeMenu(STR_16CH_WITHOUT_TELEMETRY);
|
||||
}
|
||||
else if (isModuleR9MAccess(moduleIdx) && reusableBuffer.moduleSetup.pxx2.moduleInformation.information.variant == PXX2_VARIANT_FLEX) {
|
||||
reusableBuffer.moduleSetup.bindInformation.step = BIND_RX_NAME_SELECTED;
|
||||
|
@ -140,6 +141,7 @@ void onPXX2ReceiverMenu(const char * result)
|
|||
memclear(&reusableBuffer.moduleSetup.bindInformation, sizeof(BindInformation));
|
||||
reusableBuffer.moduleSetup.bindInformation.rxUid = receiverIdx;
|
||||
if (isModuleR9MAccess(moduleIdx)) {
|
||||
reusableBuffer.moduleSetup.bindInformation.step = BIND_MODULE_TX_INFORMATION_REQUEST;
|
||||
#if defined(SIMU)
|
||||
reusableBuffer.moduleSetup.pxx2.moduleInformation.information.modelID = 1;
|
||||
reusableBuffer.moduleSetup.pxx2.moduleInformation.information.variant = 2;
|
||||
|
|
|
@ -1129,6 +1129,7 @@ union ReusableBuffer
|
|||
};
|
||||
uint8_t resetReceiverFlags;
|
||||
ModuleInformation moduleInformation;
|
||||
ModuleSettings moduleSettings;
|
||||
} pxx2;
|
||||
#if defined(BLUETOOTH)
|
||||
struct {
|
||||
|
@ -1168,10 +1169,8 @@ union ReusableBuffer
|
|||
struct {
|
||||
ModuleInformation modules[NUM_MODULES];
|
||||
uint32_t updateTime;
|
||||
union {
|
||||
ModuleSettings moduleSettings;
|
||||
ReceiverSettings receiverSettings;
|
||||
};
|
||||
ReceiverSettings receiverSettings; // when dealing with receiver settings, we also need module settings
|
||||
} hardwareAndSettings;
|
||||
|
||||
struct {
|
||||
|
|
|
@ -133,7 +133,7 @@ class ReceiverSettings {
|
|||
|
||||
class BindInformation {
|
||||
public:
|
||||
uint8_t step;
|
||||
int8_t step;
|
||||
uint32_t timeout;
|
||||
char candidateReceiversNames[PXX2_MAX_RECEIVERS_PER_MODULE][PXX2_LEN_RX_NAME + 1];
|
||||
uint8_t candidateReceiversCount;
|
||||
|
|
|
@ -143,6 +143,8 @@ enum PXX2RegisterSteps {
|
|||
};
|
||||
|
||||
enum PXX2BindSteps {
|
||||
BIND_MODULE_TX_INFORMATION_REQUEST = -2,
|
||||
BIND_MODULE_TX_SETTINGS_REQUEST = -1,
|
||||
BIND_INIT,
|
||||
BIND_RX_NAME_SELECTED,
|
||||
BIND_INFO_REQUEST,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue