Skip to content
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
16 changes: 16 additions & 0 deletions companion/src/firmwares/boardjson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,12 @@ const int BoardJson::getCapability(const Board::Capability capability) const
case Board::HasBlingLEDS:
return m_hardware.has_bling_leds;

case Board::StatusLedColors:
return m_hardware.status_led_colors;

case Board::HasStatusLedPwm:
return m_hardware.status_led_pwm;

case Board::HasColorLcd:
return m_display.color;

Expand Down Expand Up @@ -1280,6 +1286,16 @@ bool BoardJson::loadFile(Board::Type board, QString hwdefn, InputsTable * inputs
cfs.groups = cfs_leds_per_switch ? cfs_led_strip_length / (2 * cfs_leds_per_switch) : 0;
cfs.rgb_led = cfs.groups > 0;
hardware.has_bling_leds = o.value("bling_led_strip_length").toInt();

if (o.value("status_leds").toBool()) {
if (o.value("status_led_rgb_strip").toBool())
hardware.status_led_colors = 0b111;
else
hardware.status_led_colors = (o.contains("led_red_gpio") ? 0b001 : 0) |
(o.contains("led_green_gpio") ? 0b010 : 0) |
(o.contains("led_blue_gpio") ? 0b100 : 0);
}
hardware.status_led_pwm = o.contains("status_led_pwm_timer");
}

if (obj.value("hardware").isObject()) {
Expand Down
2 changes: 2 additions & 0 deletions companion/src/firmwares/boardjson.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ class BoardJson
struct HardwareDefn {
int has_audio_mute = 0;
int has_bling_leds = 0;
int status_led_colors = 0; // bit 0 red, 1 green, 2 blue
int status_led_pwm = 0;
int has_ext_module_support = 0;
int has_int_module_support = 0;
int sport_max_baudrate = 0;
Expand Down
3 changes: 3 additions & 0 deletions companion/src/firmwares/boards.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ namespace Board {
HasAux2SerialMode,
HasBacklightColor,
HasBlingLEDS,
HasStatusLedPwm,
StatusLedColors,
HasBluetooth,
HasColorLcd,
HasExternalAntenna,
Expand Down Expand Up @@ -899,3 +901,4 @@ inline bool IS_ACCESS_RADIO(Board::Type board, const QString & id)
return IS_ACCESS_RADIO(board) ||
(IS_FAMILY_HORUS_OR_T16(board) && id.contains("internalaccess"));
}

20 changes: 20 additions & 0 deletions companion/src/firmwares/edgetx/yaml_generalsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,14 @@ static const YamlLookupTable hatsModeLut = {
{ GeneralSettings::HATSMODE_SWITCHABLE, "SWITCHABLE" },
};

// must match enum StatusLedColor in the firmware, as the yaml generator names it
static const YamlLookupTable statusLedColorLut = {
{ GeneralSettings::STATUS_LED_COLOR_DEFAULT, "LED_COLOR_DEFAULT" },
{ GeneralSettings::STATUS_LED_COLOR_RED, "LED_COLOR_RED" },
{ GeneralSettings::STATUS_LED_COLOR_GREEN, "LED_COLOR_GREEN" },
{ GeneralSettings::STATUS_LED_COLOR_BLUE, "LED_COLOR_BLUE" },
};

static const YamlLookupTable QMPageLut = {
{ GeneralSettings::QM_NONE, "NONE" },
{ GeneralSettings::QM_OPEN_QUICK_MENU, "OPEN_QUICK_MENU" },
Expand Down Expand Up @@ -378,6 +386,12 @@ Node convert<GeneralSettings>::encode(const GeneralSettings& rhs)
node["backlightSrc"] = rhs.backlightSrc;
node["volumeSrc"] = rhs.volumeSrc;

node["statusLedDim"] = rhs.statusLedDim;
node["statusLedSrc"] = rhs.statusLedSrc;
node["statusLedError"] = statusLedColorLut << rhs.statusLedError;
node["statusLedReady"] = statusLedColorLut << rhs.statusLedReady;
node["statusLedEmit"] = statusLedColorLut << rhs.statusLedEmit;

// Radio level tabs control (global settings)
if (hasColorLcd)
node["radioThemesDisabled"] = (int)rhs.radioThemesDisabled;
Expand Down Expand Up @@ -731,6 +745,12 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
node["backlightSrc"] >> rhs.backlightSrc;
node["volumeSrc"] >> rhs.volumeSrc;

node["statusLedDim"] >> rhs.statusLedDim;
node["statusLedSrc"] >> rhs.statusLedSrc;
node["statusLedError"] >> statusLedColorLut >> rhs.statusLedError;
node["statusLedReady"] >> statusLedColorLut >> rhs.statusLedReady;
node["statusLedEmit"] >> statusLedColorLut >> rhs.statusLedEmit;

// Radio level tabs control (global settings)
node["radioThemesDisabled"] >> rhs.radioThemesDisabled;
node["radioGFDisabled"] >> rhs.radioGFDisabled;
Expand Down
13 changes: 13 additions & 0 deletions companion/src/firmwares/generalsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,19 @@ class GeneralSettings {
RawSource backlightSrc;
RawSource volumeSrc;

unsigned int statusLedDim;
RawSource statusLedSrc;
enum StatusLedColor {
STATUS_LED_COLOR_DEFAULT,
STATUS_LED_COLOR_RED,
STATUS_LED_COLOR_GREEN,
STATUS_LED_COLOR_BLUE,
};

unsigned int statusLedError;
unsigned int statusLedReady;
unsigned int statusLedEmit;

// Radio level tabs control (global settings)
bool radioThemesDisabled;
bool radioGFDisabled;
Expand Down
86 changes: 86 additions & 0 deletions companion/src/generaledit/generalsetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ constexpr char FIM_TEMPLATESETUP[] {"Template Setup"};
constexpr char FIM_BACKLIGHTMODE[] {"Backlight Mode"};
constexpr char FIM_CONTROLSRC[] {"Control Source"};

static void populateStatusLedColorCB(QComboBox * cb, int available, unsigned int value)
{
cb->clear();
cb->addItem(QObject::tr("Default"), GeneralSettings::STATUS_LED_COLOR_DEFAULT);
if (available & 0b001) cb->addItem(QObject::tr("Red"), GeneralSettings::STATUS_LED_COLOR_RED);
if (available & 0b010) cb->addItem(QObject::tr("Green"), GeneralSettings::STATUS_LED_COLOR_GREEN);
if (available & 0b100) cb->addItem(QObject::tr("Blue"), GeneralSettings::STATUS_LED_COLOR_BLUE);
// a colour this radio lacks shows as Default, which is what the radio does
cb->setCurrentIndex(qMax(0, cb->findData(value)));
}

GeneralSetupPanel::GeneralSetupPanel(QWidget * parent, GeneralSettings & generalSettings,
Firmware * firmware, CompoundItemModelFactory * sharedItemModels):
GeneralPanel(parent, generalSettings, firmware),
Expand Down Expand Up @@ -66,6 +77,38 @@ ui(new Ui::GeneralSetup)
if (ui->brightCtrl_CB->currentIndex() < 0 && generalSettings.backlightSrc.toValue() == 0)
ui->brightCtrl_CB->setCurrentIndex(Helpers::getFirstPosValueIndex(ui->brightCtrl_CB));

if (Boards::getCapability(board, Board::HasStatusLedPwm)) {
ui->statusLedBright_SB->setValue(100 - generalSettings.statusLedDim);

ui->statusLedCtrl_CB->setSizeAdjustPolicy(QComboBox::AdjustToContents);
ui->statusLedCtrl_CB->setModel(panelFilteredModels->getItemModel(FIM_CONTROLSRC));
ui->statusLedCtrl_CB->setCurrentIndex(ui->statusLedCtrl_CB->findData(generalSettings.statusLedSrc.toValue()));
if (ui->statusLedCtrl_CB->currentIndex() < 0 && generalSettings.statusLedSrc.toValue() == 0)
ui->statusLedCtrl_CB->setCurrentIndex(Helpers::getFirstPosValueIndex(ui->statusLedCtrl_CB));
}
else {
ui->label_statusLedBright->hide();
ui->statusLedBright_SB->hide();
ui->label_statusLedCtrl->hide();
ui->statusLedCtrl_CB->hide();
}

// a colour per phase needs at least two colours to choose from
int ledColors = Boards::getCapability(board, Board::StatusLedColors);
if (qPopulationCount((quint32)ledColors) >= 2) {
populateStatusLedColorCB(ui->statusLedError_CB, ledColors, generalSettings.statusLedError);
populateStatusLedColorCB(ui->statusLedReady_CB, ledColors, generalSettings.statusLedReady);
populateStatusLedColorCB(ui->statusLedEmit_CB, ledColors, generalSettings.statusLedEmit);
}
else {
ui->label_statusLedError->hide();
ui->statusLedError_CB->hide();
ui->label_statusLedReady->hide();
ui->statusLedReady_CB->hide();
ui->label_statusLedEmit->hide();
ui->statusLedEmit_CB->hide();
}

ui->backlightswCB->setModel(panelFilteredModels->getItemModel(FIM_BACKLIGHTMODE));
ui->backlightswCB->setCurrentIndex(ui->backlightswCB->findData(generalSettings.backlightMode));

Expand Down Expand Up @@ -721,6 +764,49 @@ void GeneralSetupPanel::on_brightCtrl_CB_currentIndexChanged(int index)
}
}

void GeneralSetupPanel::on_statusLedBright_SB_editingFinished()
{
if (!lock) {
// the radio steps in tens, keep typed values on the same grid
int value = qBound(10, (ui->statusLedBright_SB->value() + 5) / 10 * 10, 100);
ui->statusLedBright_SB->setValue(value);
generalSettings.statusLedDim = 100 - value;
emit modified();
}
}

void GeneralSetupPanel::on_statusLedCtrl_CB_currentIndexChanged(int index)
{
if (!lock) {
generalSettings.statusLedSrc = RawSource(ui->statusLedCtrl_CB->itemData(ui->statusLedCtrl_CB->currentIndex()).toInt());
emit modified();
}
}

void GeneralSetupPanel::on_statusLedError_CB_currentIndexChanged(int index)
{
if (!lock) {
generalSettings.statusLedError = ui->statusLedError_CB->itemData(index).toUInt();
emit modified();
}
}

void GeneralSetupPanel::on_statusLedReady_CB_currentIndexChanged(int index)
{
if (!lock) {
generalSettings.statusLedReady = ui->statusLedReady_CB->itemData(index).toUInt();
emit modified();
}
}

void GeneralSetupPanel::on_statusLedEmit_CB_currentIndexChanged(int index)
{
if (!lock) {
generalSettings.statusLedEmit = ui->statusLedEmit_CB->itemData(index).toUInt();
emit modified();
}
}

void GeneralSetupPanel::on_volume_SL_valueChanged()
{
if (!lock) {
Expand Down
5 changes: 5 additions & 0 deletions companion/src/generaledit/generalsetup.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ class GeneralSetupPanel : public GeneralPanel
void on_OFFBright_SB_editingFinished();
void on_brightCtrl_CB_currentIndexChanged(int index);
void on_volumeCtrl_CB_currentIndexChanged(int index);
void on_statusLedBright_SB_editingFinished();
void on_statusLedCtrl_CB_currentIndexChanged(int index);
void on_statusLedError_CB_currentIndexChanged(int index);
void on_statusLedReady_CB_currentIndexChanged(int index);
void on_statusLedEmit_CB_currentIndexChanged(int index);
void on_countrycode_CB_currentIndexChanged(int index);
void on_units_CB_currentIndexChanged(int index);
void on_ppm_units_CB_currentIndexChanged(int index);
Expand Down
63 changes: 63 additions & 0 deletions companion/src/generaledit/generalsetup.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1985,6 +1985,69 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item row="30" column="0">
<widget class="QLabel" name="label_statusLedBright">
<property name="text">
<string>Status LED brightness</string>
</property>
</widget>
</item>
<item row="30" column="1">
<widget class="QSpinBox" name="statusLedBright_SB">
<property name="suffix">
<string> %</string>
</property>
<property name="minimum">
<number>10</number>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="singleStep">
<number>10</number>
</property>
</widget>
</item>
<item row="31" column="0">
<widget class="QLabel" name="label_statusLedCtrl">
<property name="text">
<string>Status LED control</string>
</property>
</widget>
</item>
<item row="31" column="1">
<widget class="QComboBox" name="statusLedCtrl_CB"/>
</item>
<item row="32" column="0">
<widget class="QLabel" name="label_statusLedError">
<property name="text">
<string>Status LED error colour</string>
</property>
</widget>
</item>
<item row="32" column="1">
<widget class="QComboBox" name="statusLedError_CB"/>
</item>
<item row="33" column="0">
<widget class="QLabel" name="label_statusLedReady">
<property name="text">
<string>Status LED ready colour</string>
</property>
</widget>
</item>
<item row="33" column="1">
<widget class="QComboBox" name="statusLedReady_CB"/>
</item>
<item row="34" column="0">
<widget class="QLabel" name="label_statusLedEmit">
<property name="text">
<string>Status LED transmitting colour</string>
</property>
</widget>
</item>
<item row="34" column="1">
<widget class="QComboBox" name="statusLedEmit_CB"/>
</item>
<item row="35" column="0">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
Expand Down
8 changes: 0 additions & 8 deletions radio/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@ else()
option(ALL_LANGUAGES "Enable runtime language selection" OFF)
endif()

if(PCB STREQUAL X7 AND PCBREV STREQUAL LR3PRO)
option(POWER_LED_BLUE "Override Power LED to be normally Blue" ON)
else()
option(POWER_LED_BLUE "Override Power LED to be normally Blue" OFF)
endif()

# since we reset all default CMAKE compiler flags for firmware builds, provide an alternate way for user to specify additional flags.
set(FIRMWARE_C_FLAGS "" CACHE STRING "Additional flags for firmware target c compiler (note: all CMAKE_C_FLAGS[_*] are ignored for firmware/bootloader).")
Expand Down Expand Up @@ -565,9 +560,6 @@ if(USBJ_EX)
)
endif()

if(POWER_LED_BLUE)
add_definitions(-DPOWER_LED_BLUE)
endif()

foreach(FILE ${TARGET_SRC})
set(SRC targets/${TARGET_DIR}/${FILE} ${SRC})
Expand Down
Loading
Loading