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

SPORT power handling #3636

Merged
merged 1 commit into from
Jun 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
29 changes: 12 additions & 17 deletions radio/src/gui/common/stdlcd/radio_hardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <opentx.h>
#include "hal/adc_driver.h"
#include "io/frsky_firmware_update.h"

#if defined(CROSSFIRE)
#include "telemetry/crossfire.h"
Expand Down Expand Up @@ -132,9 +133,7 @@ enum {

ITEM_RADIO_HARDWARE_JITTER_FILTER,
ITEM_RADIO_HARDWARE_RAS,
#if defined(SPORT_UPDATE_PWR_GPIO)
ITEM_RADIO_HARDWARE_SPORT_UPDATE_POWER,
#endif
ITEM_RADIO_HARDWARE_DEBUG,
#if defined(EEPROM)
ITEM_RADIO_BACKUP_EEPROM,
Expand Down Expand Up @@ -274,11 +273,7 @@ static uint8_t _dispSerialPort(uint8_t port_nr)
#define HW_SETTINGS_COLUMN2 (HW_SETTINGS_COLUMN1 + 5*FW)
#endif

#if defined(SPORT_UPDATE_PWR_GPIO)
#define SPORT_POWER_ROWS 0,
#else
#define SPORT_POWER_ROWS
#endif
#define SPORT_PWR_ROW (hasSportPower() ? (uint8_t)0 : HIDDEN_ROW)

#if defined(EEPROM)
#define EEPROM_ROWS 0 /* EEPROM backup */, 0 /* Factory reset */,
Expand Down Expand Up @@ -326,7 +321,7 @@ void menuRadioHardware(event_t event)
SERIAL_PORT_ROWS
0 /* ADC filter */,
READONLY_ROW /* RAS */,
SPORT_POWER_ROWS
SPORT_PWR_ROW,
1 /* debugs */,
EEPROM_ROWS
});
Expand Down Expand Up @@ -666,15 +661,15 @@ void menuRadioHardware(event_t event)
lcdDrawText(lcdNextPos, y, "---");
break;

// TODO: this is board specific, do something about it!
// #if defined(SPORT_UPDATE_PWR_GPIO)
// case ITEM_RADIO_HARDWARE_SPORT_UPDATE_POWER:
// g_eeGeneral.sportUpdatePower = editChoice(HW_SETTINGS_COLUMN2, y, STR_SPORT_UPDATE_POWER_MODE, STR_SPORT_UPDATE_POWER_MODES, g_eeGeneral.sportUpdatePower, 0, 1, attr, event);
// if (attr && checkIncDec_Ret) {
// SPORT_UPDATE_POWER_INIT();
// }
// break;
// #endif
case ITEM_RADIO_HARDWARE_SPORT_UPDATE_POWER:
g_eeGeneral.sportUpdatePower = editChoice(HW_SETTINGS_COLUMN2, y, STR_SPORT_UPDATE_POWER_MODE, STR_SPORT_UPDATE_POWER_MODES, g_eeGeneral.sportUpdatePower, 0, 1, attr, event);
if (attr && checkIncDec_Ret) {
auto mod_desc = modulePortGetModuleDescription(SPORT_MODULE);
if (mod_desc && mod_desc->set_pwr) {
mod_desc->set_pwr(g_eeGeneral.sportUpdatePower);
}
}
break;

case ITEM_RADIO_HARDWARE_DEBUG:
lcdDrawTextAlignedLeft(y, STR_DEBUG);
Expand Down
9 changes: 9 additions & 0 deletions radio/src/gui/gui_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,14 @@ bool isSerialModeAvailable(uint8_t port_nr, int mode)
return true;
}

bool hasSportPower() {
auto mod_desc = modulePortGetModuleDescription(SPORT_MODULE);
if (mod_desc && mod_desc->set_pwr) {
return true;
}
return false;
}

bool isSwitchAvailableInLogicalSwitches(int swtch)
{
return isSwitchAvailable(swtch, LogicalSwitchesContext);
Expand Down Expand Up @@ -1123,6 +1131,7 @@ int getFirstAvailable(int min, int max, IsValueAvailable isValueAvailable)
}
return retval;
}

#if defined(MULTIMODULE)

const uint8_t getMaxMultiOptions()
Expand Down
1 change: 1 addition & 0 deletions radio/src/gui/gui_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ uint8_t getTelemetrySensorsCount();
bool isTelemetryFieldComparisonAvailable(int index);
bool isSensorAvailable(int sensor);
bool isRssiSensorAvailable(int sensor);
bool hasSportPower();

bool modelHasNotes();

Expand Down