feat: ELRS bind command support (#4907)

This commit is contained in:
3djc
2024-06-02 12:03:15 +10:00
committed by GitHub
parent c81c8b5354
commit d45450921d
30 changed files with 174 additions and 29 deletions
+6 -1
View File
@@ -1837,7 +1837,10 @@ void menuModelSetup(event_t event)
l_posHorz += 1;
}
if (isModuleBindRangeAvailable(moduleIdx)) {
lcdDrawText(bindButtonPos, y, STR_MODULE_BIND, l_posHorz == 1 ? attr : 0);
if (TELEMETRY_STREAMING() && isModuleELRS(moduleIdx))
lcdDrawText(bindButtonPos, y, STR_MODULE_UNBIND, l_posHorz == 1 ? attr : 0);
else
lcdDrawText(bindButtonPos, y, STR_MODULE_BIND, l_posHorz == 1 ? attr : 0);
if (isModuleRangeAvailable(moduleIdx)) {
lcdDrawText(lcdNextPos + 2, y, STR_MODULE_RANGE, l_posHorz == 2 ? attr : 0);
}
@@ -1881,6 +1884,8 @@ void menuModelSetup(event_t event)
}
else {
newFlag = MODULE_MODE_BIND;
if (isModuleELRS(moduleIdx))
AUDIO_PLAY(AU_SPECIAL_SOUND_CHEEP); // Since ELRS bind is just one frame, we need to play the sound manually
}
if (!event && (oldFlag != newFlag) &&
+6 -1
View File
@@ -1562,7 +1562,10 @@ void menuModelSetup(event_t event)
l_posHorz += 1;
}
if (isModuleBindRangeAvailable(moduleIdx)) {
lcdDrawText(bindButtonPos, y, STR_MODULE_BIND, l_posHorz == 1 ? attr : 0);
if (TELEMETRY_STREAMING() && isModuleCrossfire(moduleIdx))
lcdDrawText(bindButtonPos, y, STR_MODULE_UNBIND, l_posHorz == 1 ? attr : 0);
else
lcdDrawText(bindButtonPos, y, STR_MODULE_BIND, l_posHorz == 1 ? attr : 0);
if (isModuleRangeAvailable(moduleIdx)) {
lcdDrawText(lcdNextPos + FW, y, STR_MODULE_RANGE, l_posHorz == 2 ? attr : 0);
}
@@ -1600,6 +1603,8 @@ void menuModelSetup(event_t event)
}
else {
newFlag = MODULE_MODE_BIND;
if (isModuleCrossfire(moduleIdx))
AUDIO_PLAY(AU_SPECIAL_SOUND_CHEEP); // Since ELRS bind is just one frame, we need to play the sound manually
}
if (!event && (oldFlag != newFlag) &&
+18 -1
View File
@@ -102,6 +102,8 @@ class ModuleWindow : public Window
void startRSSIDialog(std::function<void()> closeHandler = nullptr);
void updateIDStaticText(int mdIdx);
void checkEvents() override;
};
struct FailsafeChoice : public Window {
@@ -156,6 +158,19 @@ ModuleWindow::ModuleWindow(Window* parent, uint8_t moduleIdx) :
lv_obj_add_event_cb(lvobj, mw_refresh_cb, LV_EVENT_REFRESH, this);
}
void ModuleWindow::checkEvents()
{
if (bindButton != nullptr) {
if (TELEMETRY_STREAMING() && isModuleELRS(moduleIdx))
bindButton->setText(STR_MODULE_UNBIND);
else if (isModuleELRS(moduleIdx))
bindButton->setText(STR_MODULE_BIND);
bindButton->show(isModuleBindRangeAvailable(moduleIdx));
}
Window::checkEvents();
}
void ModuleWindow::updateIDStaticText(int mdIdx)
{
if (idUnique == nullptr) return;
@@ -280,7 +295,7 @@ void ModuleWindow::updateModule()
}
});
if (isModuleBindRangeAvailable(moduleIdx)) {
if (isModuleBindRangeAvailable(moduleIdx) || isModuleCrossfire(moduleIdx)) {
bindButton = new TextButton(box, rect_t{}, STR_MODULE_BIND);
bindButton->setPressHandler([=]() -> uint8_t {
if (moduleState[moduleIdx].mode == MODULE_MODE_RANGECHECK) {
@@ -312,6 +327,8 @@ void ModuleWindow::updateModule()
}
#endif
moduleState[moduleIdx].mode = MODULE_MODE_BIND;
if (isModuleELRS(moduleIdx))
AUDIO_PLAY(AU_SPECIAL_SOUND_CHEEP); // Since ELRS bind is just one frame, we need to play the sound manually
#if defined(AFHDS2)
if (isModuleAFHDS2A(moduleIdx)) {
resetPulsesAFHDS2();
+3 -1
View File
@@ -126,7 +126,7 @@ class VersionDialog : public BaseDialog
new StaticText(int_rx_name_w, rect_t{}, "");
int_rx_name_w->hide();
// internal reciever status
// internal receiver status
int_rx_status_w = form->newLine(grid);
new StaticText(int_rx_status_w, rect_t{}, STR_STATUS);
int_rx_status =
@@ -195,6 +195,8 @@ class VersionDialog : public BaseDialog
// snprintf(statusText, 64, "%d Hz %" PRIu32 " Err", hz, telemetryErrors);
snprintf(statusText, 64, "%d Hz", hz);
status->setText(statusText);
snprintf(statusText, 64, "%s V%u.%u.%u", crossfireModuleStatus[module].name, crossfireModuleStatus[module].major, crossfireModuleStatus[module].minor, crossfireModuleStatus[module].revision);
name->setText(statusText);
module_status_w->show();
}
#endif
+20 -7
View File
@@ -32,7 +32,7 @@
#define MENU_BODY_TOP (FH + 1)
#define MENU_BODY_BOTTOM (LCD_H)
#if defined(PXX2)
#if defined(PXX2) || defined(CROSSFIRE)
constexpr uint8_t COLUMN2_X = 10 * FW;
#endif
@@ -84,7 +84,8 @@ void drawPXX2FullVersion(coord_t x, coord_t y, PXX2Version hwVersion, PXX2Versio
lcdDrawText(lcdNextPos, y, "/");
drawPXX2Version(lcdNextPos, y, swVersion);
}
#endif
#if defined(PXX2) || defined(CROSSFIRE)
void menuRadioModulesVersion(event_t event)
{
if (menuEvent) {
@@ -95,8 +96,8 @@ void menuRadioModulesVersion(event_t event)
}
title(STR_MENU_MODULES_RX_VERSION);
if (event == EVT_ENTRY) {
#if defined(PXX2)
if (event == EVT_ENTRY) {
memclear(&reusableBuffer.hardwareAndSettings.modules, sizeof(reusableBuffer.hardwareAndSettings.modules));
}
@@ -116,6 +117,7 @@ void menuRadioModulesVersion(event_t event)
reusableBuffer.hardwareAndSettings.updateTime = get_tmr10ms() + 1000 /* 10s*/;
}
#endif
coord_t y = (FH + 1) - menuVerticalOffset * FH;
@@ -166,6 +168,14 @@ void menuRadioModulesVersion(event_t event)
1000000 / getMixerSchedulerPeriod()/*, UINT32_C(telemetryErrors)*/);
lcdDrawText(COLUMN2_X, y, statusText);
y += FH;
lcdDrawText(INDENT_WIDTH, y, crossfireModuleStatus[module].name);
lcdDrawChar(lcdNextPos + 5, y, 'V');
lcdDrawNumber(lcdNextPos, y, crossfireModuleStatus[module].major);
lcdDrawChar(lcdNextPos, y, '.');
lcdDrawNumber(lcdNextPos, y, crossfireModuleStatus[module].minor);
lcdDrawChar(lcdNextPos, y, '.');
lcdDrawNumber(lcdNextPos, y, crossfireModuleStatus[module].revision);
y += FH;
continue;
}
#endif
@@ -174,12 +184,14 @@ void menuRadioModulesVersion(event_t event)
y += FH;
continue;
}
#if defined(PXX2)
uint8_t modelId = reusableBuffer.hardwareAndSettings.modules[module]
.information.modelID;
lcdDrawText(COLUMN2_X, y, getPXX2ModuleName(modelId));
#endif
}
y += FH;
#if defined(PXX2)
// Module version
if (y >= MENU_BODY_TOP && y < MENU_BODY_BOTTOM) {
if (reusableBuffer.hardwareAndSettings.modules[module].information.modelID) {
@@ -211,6 +223,7 @@ void menuRadioModulesVersion(event_t event)
y += FH;
}
}
#endif
}
uint8_t lines = (y - (FH + 1)) / FH + menuVerticalOffset;
@@ -243,7 +256,7 @@ enum MenuRadioVersionItems
#if defined(PCBTARANIS)
ITEM_RADIO_FIRMWARE_OPTIONS,
#endif
#if defined(PXX2)
#if defined(PXX2) || defined(CROSSFIRE)
ITEM_RADIO_MODULES_VERSION,
#endif
ITEM_RADIO_VERSION_COUNT
@@ -266,7 +279,7 @@ void menuRadioVersion(event_t event)
}
#endif
#if defined(PXX2)
#if defined(PXX2) || defined(CROSSFIRE)
lcdDrawText(INDENT_WIDTH, y, BUTTON(TR_MODULES_RX_VERSION), menuVerticalPosition == ITEM_RADIO_MODULES_VERSION ? INVERS : 0);
y += FH;
if (menuVerticalPosition == ITEM_RADIO_MODULES_VERSION && event == EVT_KEY_BREAK(KEY_ENTER)) {
+3
View File
@@ -1261,6 +1261,9 @@ uint8_t MENU_FIRST_LINE_EDIT(const uint8_t * horTab, uint8_t horTabMax)
uint8_t MODULE_BIND_ROWS(int moduleIdx)
{
if (isModuleELRS(moduleIdx) && (crossfireModuleStatus[moduleIdx].major >= 4 || (crossfireModuleStatus[moduleIdx].major == 3 && crossfireModuleStatus[moduleIdx].minor >= 4)))
return 1;
if (isModuleCrossfire(moduleIdx))
return 0;