fix(cpn): Default calibration values for 6POS switch (#4271)
This commit is contained in:
@@ -87,12 +87,6 @@ void GeneralSettings::clear()
|
|||||||
|
|
||||||
void GeneralSettings::init()
|
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();
|
Firmware * firmware = Firmware::getCurrentVariant();
|
||||||
Board::Type board = firmware->getBoard();
|
Board::Type board = firmware->getBoard();
|
||||||
|
|
||||||
@@ -125,6 +119,18 @@ void GeneralSettings::init()
|
|||||||
|
|
||||||
setDefaultControlTypes(board);
|
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
|
backlightMode = 3; // keys and sticks
|
||||||
backlightDelay = 2; // 2 * 5 = 10 secs
|
backlightDelay = 2; // 2 * 5 = 10 secs
|
||||||
inactivityTimer = 10;
|
inactivityTimer = 10;
|
||||||
@@ -689,6 +695,21 @@ QString GeneralSettings::hatsModeToString() const
|
|||||||
return hatsModeToString(hatsMode);
|
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
|
// static
|
||||||
QString GeneralSettings::hatsModeToString(int value)
|
QString GeneralSettings::hatsModeToString(int value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -195,6 +195,7 @@ class GeneralSettings {
|
|||||||
int getDefaultStick(unsigned int channel) const;
|
int getDefaultStick(unsigned int channel) const;
|
||||||
RawSource getDefaultSource(unsigned int channel) const;
|
RawSource getDefaultSource(unsigned int channel) const;
|
||||||
int getDefaultChannel(unsigned int stick) const;
|
int getDefaultChannel(unsigned int stick) const;
|
||||||
|
bool fix6POSCalibration();
|
||||||
|
|
||||||
char semver[8 + 1];
|
char semver[8 + 1];
|
||||||
unsigned int version;
|
unsigned int version;
|
||||||
|
|||||||
@@ -1277,6 +1277,9 @@ bool MdiChild::loadFile(const QString & filename, bool resetCurrentFile)
|
|||||||
setCurrentFile(filename);
|
setCurrentFile(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (radioData.generalSettings.fix6POSCalibration())
|
||||||
|
setModified();
|
||||||
|
|
||||||
// set after successful import
|
// set after successful import
|
||||||
if (getStorageType(filename) == STORAGE_TYPE_YML)
|
if (getStorageType(filename) == STORAGE_TYPE_YML)
|
||||||
setModified();
|
setModified();
|
||||||
@@ -1664,6 +1667,9 @@ void MdiChild::openModelTemplate(int row)
|
|||||||
QMessageBox::warning(this, CPN_STR_TTL_WARNING, warning);
|
QMessageBox::warning(this, CPN_STR_TTL_WARNING, warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (radioData.generalSettings.fix6POSCalibration())
|
||||||
|
setModified();
|
||||||
|
|
||||||
radioData.models[row] = data.models[0];
|
radioData.models[row] = data.models[0];
|
||||||
|
|
||||||
// reset module bindings
|
// reset module bindings
|
||||||
|
|||||||
Reference in New Issue
Block a user