fix: Companion will set critical radio general settings to profile defaults if mismatched boards (#1575)
* Do not import potentially conflicting radio settings * Revert "Do not import potentially conflicting radio settings" This reverts commit 06a19c04d6de341568362b87311264081aa3d38f. * Override critical general settings to defaults when board mismatch
This commit is contained in:
@@ -264,6 +264,12 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
|
|||||||
// If conversion should rename file with _converted suffix as done for bin
|
// If conversion should rename file with _converted suffix as done for bin
|
||||||
// Need to pass back messages and flags like converted so they can be handled in a more suitable section
|
// Need to pass back messages and flags like converted so they can be handled in a more suitable section
|
||||||
|
|
||||||
|
// Note: This is part of an interim workaround to ensure critical settings are set to profile board defaults
|
||||||
|
// TODO: remove and let board conversion occur as for eeprom and profile
|
||||||
|
// this will require yaml import of general and model settings to be refactored to not use current firmware
|
||||||
|
bool needsConversion = false;
|
||||||
|
//
|
||||||
|
|
||||||
rhs.variant = Board::BOARD_UNKNOWN;
|
rhs.variant = Board::BOARD_UNKNOWN;
|
||||||
|
|
||||||
std::string flavour;
|
std::string flavour;
|
||||||
@@ -280,6 +286,7 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
flavour = fw->getFlavour().toStdString();
|
flavour = fw->getFlavour().toStdString();
|
||||||
|
needsConversion = true;
|
||||||
}
|
}
|
||||||
else if (fw->getFlavour().toStdString() != flavour) {
|
else if (fw->getFlavour().toStdString() != flavour) {
|
||||||
auto msfw = Firmware::getFirmwareForFlavour(QString(flavour.c_str()));
|
auto msfw = Firmware::getFirmwareForFlavour(QString(flavour.c_str()));
|
||||||
@@ -290,8 +297,10 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
|
|||||||
// TODO: this triggers an error in the calling code so we need a graceful way to handle
|
// TODO: this triggers an error in the calling code so we need a graceful way to handle
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
needsConversion = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: do not override here
|
||||||
rhs.variant = fw->getBoard();
|
rhs.variant = fw->getBoard();
|
||||||
|
|
||||||
YamlCalibData calib;
|
YamlCalibData calib;
|
||||||
@@ -399,6 +408,11 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
|
|||||||
// OneBit sampling (X9D only?)
|
// OneBit sampling (X9D only?)
|
||||||
node["uartSampleMode"] >> rhs.uartSampleMode;
|
node["uartSampleMode"] >> rhs.uartSampleMode;
|
||||||
|
|
||||||
|
// override critical settings after import
|
||||||
|
// TODO: for consistency move up call stack to use existing eeprom and profile conversions
|
||||||
|
if (needsConversion)
|
||||||
|
rhs.init();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} // namespace YAML
|
} // namespace YAML
|
||||||
|
|||||||
@@ -70,12 +70,14 @@ bool GeneralSettings::isSliderAvailable(int index) const
|
|||||||
return sliderConfig[index] != Board::SLIDER_NONE;
|
return sliderConfig[index] != Board::SLIDER_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
GeneralSettings::GeneralSettings()
|
void GeneralSettings::clear()
|
||||||
{
|
{
|
||||||
memset(reinterpret_cast<void *>(this), 0, sizeof(GeneralSettings));
|
memset(reinterpret_cast<void *>(this), 0, sizeof(GeneralSettings));
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
contrast = 25;
|
void GeneralSettings::init()
|
||||||
|
{
|
||||||
for (int i = 0; i < CPN_MAX_ANALOGS; ++i) {
|
for (int i = 0; i < CPN_MAX_ANALOGS; ++i) {
|
||||||
calibMid[i] = 0x200;
|
calibMid[i] = 0x200;
|
||||||
calibSpanNeg[i] = 0x180;
|
calibSpanNeg[i] = 0x180;
|
||||||
@@ -247,8 +249,6 @@ GeneralSettings::GeneralSettings()
|
|||||||
|
|
||||||
internalModule = g.profile[g.sessionId()].defaultInternalModule();
|
internalModule = g.profile[g.sessionId()].defaultInternalModule();
|
||||||
|
|
||||||
const char * themeName = IS_FLYSKY_NV14(board) ? "FlySky" : "EdgeTX";
|
|
||||||
RadioTheme::init(themeName, themeData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeneralSettings::setDefaultControlTypes(Board::Type board)
|
void GeneralSettings::setDefaultControlTypes(Board::Type board)
|
||||||
|
|||||||
@@ -141,7 +141,9 @@ class GeneralSettings {
|
|||||||
enum TelemetryBaudrate {
|
enum TelemetryBaudrate {
|
||||||
};
|
};
|
||||||
|
|
||||||
GeneralSettings();
|
GeneralSettings() { clear(); }
|
||||||
|
void clear();
|
||||||
|
void init();
|
||||||
void convert(RadioDataConversionState & cstate);
|
void convert(RadioDataConversionState & cstate);
|
||||||
|
|
||||||
void setDefaultControlTypes(Board::Type board);
|
void setDefaultControlTypes(Board::Type board);
|
||||||
|
|||||||
Reference in New Issue
Block a user