feat: simple global control for backlight/brightness and volume (#6684)

This commit is contained in:
philmoz
2026-01-04 17:56:50 +10:00
committed by GitHub
parent 586a567b0b
commit e80406b274
71 changed files with 812 additions and 374 deletions
+10
View File
@@ -752,6 +752,11 @@ bool BoardJson::isInputFlex(const InputDefn & defn)
return defn.type == Board::AIT_FLEX;
}
const bool BoardJson::isInputFlexGyroAxis(int index) const
{
return (index >=0 && index < (int)m_inputs->size()) ? isInputFlexGyroAxis(m_inputs->at(index)) : false;
}
// static
bool BoardJson::isInputFlexGyroAxis(const InputDefn & defn)
{
@@ -761,6 +766,11 @@ bool BoardJson::isInputFlexGyroAxis(const InputDefn & defn)
val[0] == 'T' && val[1] == 'I' && val[2] == 'L' && val[3] == 'T' && val[4] == '_' && (val[5] == 'X' || val[5] == 'Y'));
}
const bool BoardJson::isInputFlexJoystickAxis(int index) const
{
return (index >=0 && index < (int)m_inputs->size()) ? isInputFlexJoystickAxis(m_inputs->at(index)) : false;
}
// static
bool BoardJson::isInputFlexJoystickAxis(const InputDefn & defn)
{
+2
View File
@@ -130,6 +130,8 @@ class BoardJson
const bool isInputCalibrated(int index) const;
const bool isInputConfigurable(int index) const;
const bool isInputIgnored(int index) const;
const bool isInputFlexGyroAxis(int index) const;
const bool isInputFlexJoystickAxis(int index) const;
const bool isInputFlexPot(int index) const;
const bool isInputFlexSwitch(int index) const;
const bool isInputStick(int index) const;
+5
View File
@@ -1159,6 +1159,11 @@ bool Boards::isInputConfigurable(int index, Board::Type board)
return getBoardJson(board)->isInputConfigurable(index);
}
bool Boards::isInputGyroAxis(int index, Board::Type board)
{
return getBoardJson(board)->isInputFlexGyroAxis(index);
}
bool Boards::isInputIgnored(int index, Board::Type board)
{
return getBoardJson(board)->isInputIgnored(index);
+1
View File
@@ -454,6 +454,7 @@ class Boards
static bool isInputAvailable(int index, Board::Type board = Board::BOARD_UNKNOWN);
static bool isInputCalibrated(int index, Board::Type board = Board::BOARD_UNKNOWN);
static bool isInputConfigurable(int index, Board::Type board = Board::BOARD_UNKNOWN);
static bool isInputGyroAxis(int index, Board::Type board = Board::BOARD_UNKNOWN);
static bool isInputIgnored(int index, Board::Type board = Board::BOARD_UNKNOWN);
static bool isInputPot(int index, Board::Type board = Board::BOARD_UNKNOWN);
static bool isInputStick(int index, Board::Type board = Board::BOARD_UNKNOWN);
@@ -25,6 +25,7 @@
#include "yaml_calibdata.h"
#include "yaml_switchconfig.h"
#include "yaml_moduledata.h"
#include "yaml_rawsource.h"
#include "eeprominterface.h"
#include "edgetxinterface.h"
@@ -370,6 +371,9 @@ Node convert<GeneralSettings>::encode(const GeneralSettings& rhs)
if (hasColorLcd)
node["selectedTheme"] = rhs.selectedTheme;
node["backlightSrc"] = rhs.backlightSrc;
node["volumeSrc"] = rhs.volumeSrc;
// Radio level tabs control (global settings)
if (hasColorLcd)
node["radioThemesDisabled"] = (int)rhs.radioThemesDisabled;
@@ -694,6 +698,9 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
node["selectedTheme"] >> rhs.selectedTheme;
node["backlightSrc"] >> rhs.backlightSrc;
node["volumeSrc"] >> rhs.volumeSrc;
// Radio level tabs control (global settings)
node["radioThemesDisabled"] >> rhs.radioThemesDisabled;
node["radioGFDisabled"] >> rhs.radioGFDisabled;
@@ -432,6 +432,11 @@ void GeneralSettings::convert(RadioDataConversionState & cstate)
customFn[i].convert(cstate.withComponentIndex(i));
}
cstate.setComponent("");
cstate.setSubComp(tr("Backlight Source"));
backlightSrc.convert(cstate);
cstate.setSubComp(tr("Volume Source"));
volumeSrc.convert(cstate);
}
QString GeneralSettings::antennaModeToString() const
@@ -394,6 +394,9 @@ class GeneralSettings {
char selectedTheme[SELECTED_THEME_NAME_LEN + 1];
RawSource backlightSrc;
RawSource volumeSrc;
// Radio level tabs control (global settings)
bool radioThemesDisabled;
bool radioGFDisabled;
+8 -1
View File
@@ -280,7 +280,10 @@ bool RawSource::isStick(Board::Type board) const
return false;
}
bool RawSource::isAvailable(const ModelData * const model, const GeneralSettings * const gs, Board::Type board) const
bool RawSource::isAvailable(const ModelData * const model,
const GeneralSettings * const gs,
Board::Type board,
const int flags) const
{
if (type == SOURCE_TYPE_NONE && index == 0)
return true;
@@ -392,6 +395,10 @@ bool RawSource::isAvailable(const ModelData * const model, const GeneralSettings
gs->serialPort[GeneralSettings::SP_AUX2] == GeneralSettings::AUX_SERIAL_SPACEMOUSE))))
return false;
if (type == SOURCE_TYPE_INPUT && (flags & AVAILABLE_CONTROLSRC) &&
Boards::isInputGyroAxis(abs(index) - 1, board))
return false;
return true;
}
+10 -1
View File
@@ -248,6 +248,12 @@ class RawSource {
AllSourceGroups = InputSourceGroups | GVarsGroup | TelemGroup | ScriptsGroup
};
// flags to refine isAvailable
enum AvailableFlags {
AVAILABLE_ALL,
AVAILABLE_CONTROLSRC = 0x001
};
RawSource() { clear(); }
explicit RawSource(int value):
@@ -272,7 +278,10 @@ class RawSource {
RawSourceRange getRange(const ModelData * model, const GeneralSettings & settings, unsigned int flags=0) const;
bool isStick(Board::Type board = Board::BOARD_UNKNOWN) const;
bool isTimeBased(Board::Type board = Board::BOARD_UNKNOWN) const;
bool isAvailable(const ModelData * const model = nullptr, const GeneralSettings * const gs = nullptr, Board::Type board = Board::BOARD_UNKNOWN) const;
bool isAvailable(const ModelData * const model = nullptr,
const GeneralSettings * const gs = nullptr,
Board::Type board = Board::BOARD_UNKNOWN,
const int flags = 0) const;
bool isSet() const { return type != SOURCE_TYPE_NONE || index != 0; }
void clear() { type = SOURCE_TYPE_NONE; index = 0; }
static StringTagMappingTable getSpecialTypesLookupTable();