feat(el18): Use trim hats as keys for navigation (#3894)
Co-authored-by: elecpower <neilh713@tpg.com.au> Co-authored-by: Peter Feerick <peter.feerick@gmail.com>
This commit is contained in:
co-authored by
elecpower
Peter Feerick
parent
b733ec4eae
commit
f40fa1a64b
@@ -117,6 +117,12 @@ const YamlLookupTable internalModuleLut = {
|
||||
{ MODULE_TYPE_LEMON_DSMP, "TYPE_LEMON_DSMP" },
|
||||
};
|
||||
|
||||
static const YamlLookupTable hatsModeLut = {
|
||||
{ GeneralSettings::HATSMODE_TRIMS_ONLY, "TRIMS_ONLY" },
|
||||
{ GeneralSettings::HATSMODE_KEYS_ONLY, "KEYS_ONLY" },
|
||||
{ GeneralSettings::HATSMODE_SWITCHABLE, "SWITCHABLE" },
|
||||
};
|
||||
|
||||
YamlTelemetryBaudrate::YamlTelemetryBaudrate(
|
||||
const unsigned int* moduleBaudrate)
|
||||
{
|
||||
@@ -181,6 +187,7 @@ Node convert<GeneralSettings>::encode(const GeneralSettings& rhs)
|
||||
node["disableAlarmWarning"] = (int)rhs.disableAlarmWarning;
|
||||
node["disableRssiPoweroffAlarm"] = (int)rhs.disableRssiPoweroffAlarm;
|
||||
node["USBMode"] = rhs.usbMode;
|
||||
node["hatsMode"] = hatsModeLut << rhs.hatsMode;
|
||||
node["stickDeadZone"] = rhs.stickDeadZone;
|
||||
node["jackMode"] = rhs.jackMode;
|
||||
node["hapticMode"] = rhs.hapticMode;
|
||||
@@ -431,6 +438,7 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
|
||||
node["disableAlarmWarning"] >> rhs.disableAlarmWarning;
|
||||
node["disableRssiPoweroffAlarm"] >> rhs.disableRssiPoweroffAlarm;
|
||||
node["USBMode"] >> rhs.usbMode;
|
||||
node["hatsMode"] >> hatsModeLut >> rhs.hatsMode;
|
||||
node["stickDeadZone"] >> rhs.stickDeadZone;
|
||||
node["jackMode"] >> rhs.jackMode;
|
||||
node["hapticMode"] >> rhs.hapticMode;
|
||||
|
||||
@@ -88,6 +88,13 @@ static const YamlLookupTable usbJoystickIfModeLut = {
|
||||
{ 2, "MULTIAXIS" },
|
||||
};
|
||||
|
||||
static const YamlLookupTable hatsModeLut = {
|
||||
{ GeneralSettings::HATSMODE_TRIMS_ONLY, "TRIMS_ONLY" },
|
||||
{ GeneralSettings::HATSMODE_KEYS_ONLY, "KEYS_ONLY" },
|
||||
{ GeneralSettings::HATSMODE_SWITCHABLE, "SWITCHABLE" },
|
||||
{ GeneralSettings::HATSMODE_GLOBAL, "GLOBAL" },
|
||||
};
|
||||
|
||||
struct YamlTrim {
|
||||
int mode = 0;
|
||||
int ref = 0;
|
||||
@@ -1104,6 +1111,7 @@ Node convert<ModelData>::encode(const ModelData& rhs)
|
||||
}
|
||||
|
||||
node["modelRegistrationID"] = rhs.registrationId;
|
||||
node["hatsMode"] = hatsModeLut << rhs.hatsMode;
|
||||
|
||||
if (Boards::getCapability(board, Board::FunctionSwitches)) {
|
||||
node["functionSwitchConfig"] = rhs.functionSwitchConfig;
|
||||
@@ -1342,6 +1350,7 @@ bool convert<ModelData>::decode(const Node& node, ModelData& rhs)
|
||||
|
||||
node["view"] >> rhs.view;
|
||||
node["modelRegistrationID"] >> rhs.registrationId;
|
||||
node["hatsMode"] >> hatsModeLut >> rhs.hatsMode;
|
||||
|
||||
node["functionSwitchConfig"] >> rhs.functionSwitchConfig;
|
||||
node["functionSwitchGroup"] >> rhs.functionSwitchGroup;
|
||||
|
||||
@@ -129,6 +129,8 @@ void GeneralSettings::init()
|
||||
backlightDelay = 2; // 2 * 5 = 10 secs
|
||||
inactivityTimer = 10;
|
||||
|
||||
hatsMode = HATSMODE_SWITCHABLE;
|
||||
|
||||
// backlightBright = 0; // 0 = 100%
|
||||
|
||||
if (IS_FAMILY_HORUS_OR_T16(board)) {
|
||||
@@ -675,6 +677,42 @@ AbstractStaticItemModel * GeneralSettings::uartSampleModeItemModel()
|
||||
return mdl;
|
||||
}
|
||||
|
||||
QString GeneralSettings::hatsModeToString() const
|
||||
{
|
||||
return hatsModeToString(hatsMode);
|
||||
}
|
||||
|
||||
// static
|
||||
QString GeneralSettings::hatsModeToString(int value)
|
||||
{
|
||||
switch(value) {
|
||||
case HATSMODE_TRIMS_ONLY:
|
||||
return tr("Trims only");
|
||||
case HATSMODE_KEYS_ONLY:
|
||||
return tr("Keys only");
|
||||
case HATSMODE_SWITCHABLE:
|
||||
return tr("Switchable");
|
||||
case HATSMODE_GLOBAL:
|
||||
return tr("Global");
|
||||
default:
|
||||
return CPN_STR_UNKNOWN_ITEM;
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
AbstractStaticItemModel * GeneralSettings::hatsModeItemModel(bool radio_setup)
|
||||
{
|
||||
AbstractStaticItemModel * mdl = new AbstractStaticItemModel();
|
||||
mdl->setName(AIM_GS_HATSMODE);
|
||||
|
||||
for (int i = 0; i < HATSMODE_COUNT; i++) {
|
||||
mdl->appendToItemList(hatsModeToString(i), i, i == HATSMODE_GLOBAL && radio_setup ? false : true);
|
||||
}
|
||||
|
||||
mdl->loadItemList();
|
||||
return mdl;
|
||||
}
|
||||
|
||||
/*
|
||||
TrainerMix
|
||||
*/
|
||||
|
||||
@@ -42,6 +42,7 @@ constexpr char AIM_GS_SERIALMODE[] {"gs.serialmode"};
|
||||
constexpr char AIM_GS_INTMODULEBAUDRATE[] {"gs.intmodulebaudrate"};
|
||||
constexpr char AIM_GS_STICKDEADZONE[] {"gs.stickdeadzone"};
|
||||
constexpr char AIM_GS_UARTSAMPLEMODE[] {"gs.uartsamplemode"};
|
||||
constexpr char AIM_GS_HATSMODE[] {"gs.hatsmode"};
|
||||
constexpr char AIM_TRAINERMIX_MODE[] {"trainermix.mode"};
|
||||
constexpr char AIM_TRAINERMIX_SRC[] {"trainermix.src"};
|
||||
|
||||
@@ -171,6 +172,14 @@ class GeneralSettings {
|
||||
UART_SAMPLE_MODE_COUNT
|
||||
};
|
||||
|
||||
enum HatsMode {
|
||||
HATSMODE_TRIMS_ONLY,
|
||||
HATSMODE_KEYS_ONLY,
|
||||
HATSMODE_SWITCHABLE,
|
||||
HATSMODE_GLOBAL,
|
||||
HATSMODE_COUNT
|
||||
};
|
||||
|
||||
GeneralSettings() { clear(); }
|
||||
void clear();
|
||||
void init();
|
||||
@@ -206,6 +215,7 @@ class GeneralSettings {
|
||||
bool disableAlarmWarning;
|
||||
bool disableRssiPoweroffAlarm;
|
||||
unsigned int usbMode;
|
||||
unsigned int hatsMode;
|
||||
unsigned int stickDeadZone;
|
||||
unsigned int jackMode;
|
||||
bool sportPower;
|
||||
@@ -311,6 +321,7 @@ class GeneralSettings {
|
||||
QString serialPortModeToString(int port_nr) const;
|
||||
QString internalModuleBaudrateToString() const;
|
||||
QString uartSampleModeToString() const;
|
||||
QString hatsModeToString() const;
|
||||
|
||||
static QString antennaModeToString(int value);
|
||||
static QString bluetoothModeToString(int value);
|
||||
@@ -319,6 +330,7 @@ class GeneralSettings {
|
||||
static FieldRange getPPM_MultiplierRange();
|
||||
static FieldRange getTxCurrentCalibration();
|
||||
static QString uartSampleModeToString(int value);
|
||||
static QString hatsModeToString(int value);
|
||||
|
||||
static AbstractStaticItemModel * antennaModeItemModel(bool model_setup = false);
|
||||
static AbstractStaticItemModel * bluetoothModeItemModel();
|
||||
@@ -326,4 +338,5 @@ class GeneralSettings {
|
||||
static AbstractStaticItemModel * internalModuleBaudrateItemModel();
|
||||
static AbstractStaticItemModel * stickDeadZoneItemModel();
|
||||
static AbstractStaticItemModel * uartSampleModeItemModel();
|
||||
static AbstractStaticItemModel * hatsModeItemModel(bool radio_setup = true);
|
||||
};
|
||||
|
||||
@@ -181,6 +181,8 @@ void ModelData::clear()
|
||||
|
||||
const char * layoutId = "Layout2P1"; // currently all using same default though might change for NV14
|
||||
RadioLayout::init(layoutId, customScreens);
|
||||
|
||||
hatsMode = GeneralSettings::HATSMODE_GLOBAL;
|
||||
}
|
||||
|
||||
bool ModelData::isEmpty() const
|
||||
|
||||
@@ -192,6 +192,7 @@ class ModelData {
|
||||
unsigned int view;
|
||||
|
||||
char registrationId[8+1];
|
||||
unsigned int hatsMode;
|
||||
|
||||
// Radio level tabs control (global settings)
|
||||
unsigned int radioThemesDisabled;
|
||||
|
||||
Reference in New Issue
Block a user