mirror of
https://github.com/opentx/opentx.git
synced 2025-07-24 08:45:24 +03:00
Bsongis/access registration id reinit when zero (#6700)
ACCESS registration ID reinitialized when zero (coming from Companion) Fix incorrect module settings on model load
This commit is contained in:
parent
0fe2b8918b
commit
02d07c4d2d
5 changed files with 29 additions and 19 deletions
|
@ -2498,9 +2498,6 @@ void OpenTxModelData::beforeExport()
|
|||
{
|
||||
// qDebug() << QString("before export model") << modelData.name;
|
||||
|
||||
for (int module=0; module<2; module++) {
|
||||
}
|
||||
|
||||
if (IS_HORUS(board)) {
|
||||
uint32_t newSwitchWarningStates = 0;
|
||||
for (int i = 0; i < MAX_SWITCHES(board, version); i++) {
|
||||
|
@ -2517,11 +2514,6 @@ void OpenTxModelData::afterImport()
|
|||
{
|
||||
qCDebug(eepromImport) << QString("OpenTxModelData::afterImport()") << modelData.name;
|
||||
|
||||
// ??? what's this ???
|
||||
if (IS_HORUS(board)) {
|
||||
modelData.moduleData[0].protocol = PULSES_PXX_XJT_X16;
|
||||
}
|
||||
|
||||
if (IS_HORUS(board)) {
|
||||
uint32_t newSwitchWarningStates = 0;
|
||||
for (int i = 0; i < MAX_SWITCHES(board, version); i++) {
|
||||
|
@ -2534,8 +2526,9 @@ void OpenTxModelData::afterImport()
|
|||
modelData.switchWarningStates = newSwitchWarningStates;
|
||||
}
|
||||
|
||||
if (version <= 218 && IS_HORUS_X10(board) && modelData.thrTraceSrc > 3)
|
||||
if (version <= 218 && IS_HORUS_X10(board) && modelData.thrTraceSrc > 3) {
|
||||
modelData.thrTraceSrc += 2;
|
||||
}
|
||||
}
|
||||
|
||||
OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, Board::Type board, unsigned int version, unsigned int variant):
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
void eeLoadModel(uint8_t index)
|
||||
{
|
||||
if (index < MAX_MODELS) {
|
||||
|
||||
preModelLoad();
|
||||
|
||||
uint16_t size = eeLoadModelData(index);
|
||||
|
@ -111,6 +110,8 @@ bool storageReadRadioSettings(bool allowFixes)
|
|||
}
|
||||
}
|
||||
|
||||
postRadioSettingsLoad();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -169,6 +169,8 @@ const char * loadRadioSettings(const char * path)
|
|||
convertRadioData(version);
|
||||
}
|
||||
|
||||
postRadioSettingsLoad();
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ void storageReadAll();
|
|||
void storageDirty(uint8_t msk);
|
||||
void storageCheck(bool immediately);
|
||||
void storageFlushCurrentModel();
|
||||
|
||||
void postRadioSettingsLoad();
|
||||
void preModelLoad();
|
||||
void postModelLoad(bool alarms);
|
||||
|
||||
|
|
|
@ -53,20 +53,34 @@ void preModelLoad()
|
|||
|
||||
pauseMixerCalculations();
|
||||
}
|
||||
#if defined(PCBTARANIS) || defined(PCBHORUS)
|
||||
static void fixUpModel()
|
||||
|
||||
void postRadioSettingsLoad()
|
||||
{
|
||||
// Ensure that when rfProtocol is MODULE_SUBTYPE_PXX1_OFF the type of the module is MODULE_TYPE_NONE
|
||||
if (g_model.moduleData[INTERNAL_MODULE].type == MODULE_TYPE_XJT_PXX1 && g_model.moduleData[INTERNAL_MODULE].rfProtocol == MODULE_SUBTYPE_PXX1_OFF)
|
||||
g_model.moduleData[INTERNAL_MODULE].type = MODULE_TYPE_NONE;
|
||||
}
|
||||
#if defined(PXX2)
|
||||
if (is_memclear(g_eeGeneral.ownerRegistrationID, PXX2_LEN_REGISTRATION_ID)) {
|
||||
setDefaultOwnerId();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void postModelLoad(bool alarms)
|
||||
{
|
||||
#if defined(PCBTARANIS) || defined(PCBHORUS)
|
||||
fixUpModel();
|
||||
#if defined(PXX2)
|
||||
if (is_memclear(g_model.modelRegistrationID, PXX2_LEN_REGISTRATION_ID)) {
|
||||
memcpy(g_model.modelRegistrationID, g_eeGeneral.ownerRegistrationID, PXX2_LEN_REGISTRATION_ID);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(HARDWARE_INTERNAL_MODULE)
|
||||
if (!isInternalModuleAvailable(g_model.moduleData[INTERNAL_MODULE].type)) {
|
||||
memclear(&g_model.moduleData[INTERNAL_MODULE], sizeof(ModuleData));
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!isExternalModuleAvailable(g_model.moduleData[EXTERNAL_MODULE].type)) {
|
||||
memclear(&g_model.moduleData[EXTERNAL_MODULE], sizeof(ModuleData));
|
||||
}
|
||||
|
||||
AUDIO_FLUSH();
|
||||
flightReset(false);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue