Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: MPM module status #4198

Merged
merged 2 commits into from
Oct 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions radio/src/gui/colorlcd/module_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,15 @@ void ModuleWindow::updateModule()
auto line = newLine(&grid);
new StaticText(line, rect_t{}, STR_RF_POWER, 0, COLOR_THEME_PRIMARY1);
rfPower = new Choice(line, rect_t{}, 0, 0, GET_SET_DEFAULT(md->pxx.power));
line = newLine(&grid);
new StaticText(line, rect_t{}, STR_MODULE_TELEMETRY, 0, COLOR_THEME_PRIMARY1);
new DynamicText(line, rect_t{}, [=] () {
if (modulePortHasRx(moduleIdx)) {
return std::string(STR_MODULE_TELEM_ON);
} else {
return std::string(STR_DISABLE_INTERNAL);
}
});
}

#if defined(PXX2)
Expand Down
8 changes: 8 additions & 0 deletions radio/src/hal/module_port.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,11 @@ int8_t modulePortGetModuleForPort(uint8_t port)

return -1;
}

bool modulePortHasRx(uint8_t module)
{
auto mod_st = modulePortGetState(module);
if (!mod_st) return false;

return mod_st && mod_st->rx.port;
}
2 changes: 2 additions & 0 deletions radio/src/hal/module_port.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,5 @@ bool modulePortIsPortUsedByModule(uint8_t module, uint8_t port);
bool modulePortIsPortUsed(uint8_t port);

int8_t modulePortGetModuleForPort(uint8_t port);

bool modulePortHasRx(uint8_t module);
2 changes: 1 addition & 1 deletion radio/src/pulses/multi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ static void setupPulsesMulti(uint8_t*& p_buf, uint8_t module)
}

// Invert telemetry if needed
uint8_t disableTelemetry = modulePortIsPortUsedByModule(module, ETX_MOD_PORT_SPORT) ? 0 : 1;
uint8_t disableTelemetry = modulePortHasRx(module) ? 0 : 1;
if (invert[module] & 0x80 && !disableTelemetry) {
if (getMultiModuleStatus(module).isValid()) {
invert[module] &= 0x08; // Telemetry received, stop searching
Expand Down
2 changes: 1 addition & 1 deletion radio/src/telemetry/multi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ static void processMultiTelemetryPaket(const uint8_t * packet, uint8_t module)
void MultiModuleStatus::getStatusString(char * statusText) const
{
if (!isValid()) {
if (!modulePortIsPortUsedByModule(getModuleIndex(), ETX_MOD_PORT_SPORT)) {
if (!modulePortHasRx(getModuleIndex())) {
strcpy(statusText, STR_DISABLE_INTERNAL);
} else {
strcpy(statusText, STR_MODULE_NO_TELEMETRY);
Expand Down