Skip to content

Commit

Permalink
fix: Incorrect MPM module status (#4198)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelcoeffic committed Oct 15, 2023
1 parent b22a1b5 commit ee9d50d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
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

0 comments on commit ee9d50d

Please sign in to comment.