fix(cpn): Default calibration values for 6POS switch (#4271)

This commit is contained in:
philmoz
2023-11-10 19:20:20 +10:00
committed by GitHub
parent da0950c952
commit 33fd6791ac
3 changed files with 34 additions and 6 deletions
+27 -6
View File
@@ -87,12 +87,6 @@ void GeneralSettings::clear()
void GeneralSettings::init()
{
for (int i = 0; i < CPN_MAX_ANALOGS; ++i) {
calibMid[i] = 0x200;
calibSpanNeg[i] = 0x180;
calibSpanPos[i] = 0x180;
}
Firmware * firmware = Firmware::getCurrentVariant();
Board::Type board = firmware->getBoard();
@@ -125,6 +119,18 @@ void GeneralSettings::init()
setDefaultControlTypes(board);
for (int i = 0; i < CPN_MAX_ANALOGS; ++i) {
if ((i >= CPN_MAX_STICKS) && (i < CPN_MAX_STICKS + CPN_MAX_POTS) && (potConfig[i-CPN_MAX_STICKS] == Board::POT_MULTIPOS_SWITCH)) {
calibMid[i] = 773;;
calibSpanNeg[i] = 5388;
calibSpanPos[i] = 9758;
} else {
calibMid[i] = 0x200;
calibSpanNeg[i] = 0x180;
calibSpanPos[i] = 0x180;
}
}
backlightMode = 3; // keys and sticks
backlightDelay = 2; // 2 * 5 = 10 secs
inactivityTimer = 10;
@@ -689,6 +695,21 @@ QString GeneralSettings::hatsModeToString() const
return hatsModeToString(hatsMode);
}
bool GeneralSettings::fix6POSCalibration()
{
bool changed = false;
// Fix default 6POS calibration
for (int i = CPN_MAX_STICKS; i < CPN_MAX_STICKS+CPN_MAX_POTS; i += 1) {
if ((potConfig[i-CPN_MAX_STICKS] == Board::POT_MULTIPOS_SWITCH) && (calibMid[i] == 0x200) && (calibSpanNeg[i] == 0x180) && (calibSpanPos[i] == 0x180)) {
calibMid[i] = 773;;
calibSpanNeg[i] = 5388;
calibSpanPos[i] = 9758;
changed = true;
}
}
return changed;
}
// static
QString GeneralSettings::hatsModeToString(int value)
{
@@ -195,6 +195,7 @@ class GeneralSettings {
int getDefaultStick(unsigned int channel) const;
RawSource getDefaultSource(unsigned int channel) const;
int getDefaultChannel(unsigned int stick) const;
bool fix6POSCalibration();
char semver[8 + 1];
unsigned int version;
+6
View File
@@ -1277,6 +1277,9 @@ bool MdiChild::loadFile(const QString & filename, bool resetCurrentFile)
setCurrentFile(filename);
}
if (radioData.generalSettings.fix6POSCalibration())
setModified();
// set after successful import
if (getStorageType(filename) == STORAGE_TYPE_YML)
setModified();
@@ -1664,6 +1667,9 @@ void MdiChild::openModelTemplate(int row)
QMessageBox::warning(this, CPN_STR_TTL_WARNING, warning);
}
if (radioData.generalSettings.fix6POSCalibration())
setModified();
radioData.models[row] = data.models[0];
// reset module bindings