Merge against latest 2.3
This commit is contained in:
@@ -524,14 +524,14 @@ PACK(typedef struct {
|
||||
ScriptData_v216 scriptsData[MAX_SCRIPTS]; \
|
||||
char inputNames[MAX_INPUTS][LEN_INPUT_NAME]; \
|
||||
uint8_t nPotsToWarn; \
|
||||
int8_t potPosition[NUM_POTS+NUM_SLIDERS]; \
|
||||
int8_t potsWarnPosition[NUM_POTS+NUM_SLIDERS]; \
|
||||
uint8_t spare[2];
|
||||
#elif defined(PCBSKY9X)
|
||||
#define MODELDATA_EXTRA_216 \
|
||||
uint8_t externalModule; \
|
||||
ModuleData_v216 moduleData[NUM_MODULES+1]; \
|
||||
uint8_t nPotsToWarn; \
|
||||
int8_t potPosition[NUM_POTS+NUM_SLIDERS]; \
|
||||
int8_t potsWarnPosition[NUM_POTS+NUM_SLIDERS]; \
|
||||
uint8_t rxBattAlarms[2];
|
||||
#endif
|
||||
|
||||
@@ -1070,7 +1070,7 @@ void convertModelData_216_to_217(ModelData &model)
|
||||
#endif
|
||||
newModel.potsWarnMode = oldModel.nPotsToWarn >> 6;
|
||||
newModel.potsWarnEnabled = oldModel.nPotsToWarn & 0x1f;
|
||||
memcpy(newModel.potsWarnPosition, oldModel.potPosition, sizeof(newModel.potsWarnPosition));
|
||||
memcpy(newModel.potsWarnPosition, oldModel.potsWarnPosition, sizeof(newModel.potsWarnPosition));
|
||||
}
|
||||
|
||||
void convertModelData_217_to_218(ModelData &model)
|
||||
|
||||
@@ -59,7 +59,7 @@ int convertSource_218_to_219(int source)
|
||||
#endif
|
||||
|
||||
#if defined(PCBX10)
|
||||
if ((source == MIXSRC_EXT1) || (source == MIXSRC_EXT2))
|
||||
if (source == MIXSRC_EXT1 || source == MIXSRC_EXT2)
|
||||
source += 2;
|
||||
#endif
|
||||
|
||||
@@ -70,8 +70,8 @@ int convertSwitch_218_to_219(int swtch)
|
||||
{
|
||||
// on X7: 2 additional switches
|
||||
// on X9D / X9D+: 1 additional switch
|
||||
// on xlite : 2 more storage switches
|
||||
|
||||
// on XLite: 2 additional storage switches
|
||||
// on X10: 2 additional pots => 12 multipos switches
|
||||
#if defined(PCBX7) || defined(PCBHORUS) || defined(PCBX9D) || defined(PCBX9DP) || defined(PCBXLITE)
|
||||
if (swtch < 0)
|
||||
return -convertSwitch_218_to_219(-swtch);
|
||||
@@ -95,6 +95,9 @@ int convertSwitch_218_to_219(int swtch)
|
||||
#if defined(PCBHORUS)
|
||||
if (swtch >= SWSRC_SI0)
|
||||
swtch += 2 * 3;
|
||||
#endif
|
||||
|
||||
#if defined(PCBX10)
|
||||
if (swtch >= SWSRC_FIRST_MULTIPOS_SWITCH + 3 * XPOTS_MULTIPOS_COUNT)
|
||||
swtch += 2 * XPOTS_MULTIPOS_COUNT;
|
||||
#endif
|
||||
@@ -120,6 +123,10 @@ void convertModelData_218_to_219(ModelData &model)
|
||||
// 4 bytes more for the ModelHeader::bitmap
|
||||
memclear(&newModel.header.bitmap[10], 4);
|
||||
memcpy(newModel.timers, oldModel.timers, offsetof(ModelData_v218, mixData) - offsetof(ModelData_v218, timers));
|
||||
|
||||
// trainer battery compartment removed
|
||||
if (newModel.trainerData.mode >= TRAINER_MODE_MASTER_BLUETOOTH)
|
||||
newModel.trainerData.mode -= 1;
|
||||
#endif
|
||||
|
||||
memclear(newModel.mixData, sizeof(ModelData_v219) - offsetof(ModelData_v219, mixData));
|
||||
@@ -128,6 +135,14 @@ void convertModelData_218_to_219(ModelData &model)
|
||||
zchar2str(name, oldModel.header.name, LEN_MODEL_NAME);
|
||||
TRACE("Model %s conversion from v218 to v219", name);
|
||||
|
||||
for (uint8_t i=0; i<MAX_TIMERS_218; i++) {
|
||||
TimerData & timer = newModel.timers[i];
|
||||
if (timer.mode >= TMRMODE_COUNT)
|
||||
timer.mode = TMRMODE_COUNT + convertSwitch_218_to_219(oldModel.timers[i].mode - TMRMODE_COUNT + 1) - 1;
|
||||
else if (timer.mode < 0)
|
||||
timer.mode = convertSwitch_218_to_219(oldModel.timers[i].mode);
|
||||
}
|
||||
|
||||
for (uint8_t i=0; i<MAX_MIXERS_218; i++) {
|
||||
memmove(&newModel.mixData[i], &oldModel.mixData[i], sizeof(MixData_v218));
|
||||
newModel.mixData[i].srcRaw = convertSource_218_to_219(newModel.mixData[i].srcRaw); // from newModel to avoid overwrite
|
||||
@@ -142,6 +157,10 @@ void convertModelData_218_to_219(ModelData &model)
|
||||
memmove(&newModel.expoData[i], &oldModel.expoData[i], sizeof(ExpoData_v218));
|
||||
newModel.expoData[i].srcRaw = convertSource_218_to_219(newModel.expoData[i].srcRaw); // from newModel to avoid overwrite
|
||||
newModel.expoData[i].swtch = convertSwitch_218_to_219(newModel.expoData[i].swtch); // from newModel to avoid overwrite
|
||||
#if LCD_W == 212
|
||||
newModel.expoData[i].offset = oldModel.expoData[i].offset; // 212x64: expo name has been reduced to 6 chars instead of 8
|
||||
newModel.expoData[i].curve = oldModel.expoData[i].curve; // 212x64: expo name has been reduced to 6 chars instead of 8
|
||||
#endif
|
||||
}
|
||||
|
||||
for (uint8_t i=0; i<MAX_CURVES_218; i++) {
|
||||
|
||||
@@ -166,8 +166,8 @@ PACK(typedef struct {
|
||||
struct {
|
||||
uint8_t power:2; // 0=10 mW, 1=100 mW, 2=500 mW, 3=1W
|
||||
uint8_t spare1:2;
|
||||
uint8_t receiver_telem_off:1; // false = receiver telem enabled
|
||||
uint8_t receiver_channel_9_16:1; // false = pwm out 1-8, true 9-16
|
||||
uint8_t receiverTelemetryOff:1; // false = receiver telem enabled
|
||||
uint8_t receiverHigherChannels:1; // false = pwm out 1-8, true 9-16
|
||||
uint8_t external_antenna:1; // false = internal antenna, true = external antenna
|
||||
uint8_t fast:1;
|
||||
uint8_t spare2;
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
void eeLoadModel(uint8_t index)
|
||||
{
|
||||
if (index < MAX_MODELS) {
|
||||
|
||||
preModelLoad();
|
||||
|
||||
uint16_t size = eeLoadModelData(index);
|
||||
@@ -86,17 +85,18 @@ void eeLoadModelHeaders()
|
||||
}
|
||||
}
|
||||
|
||||
void storageClearRadioSetting()
|
||||
void storageClearRadioSettings()
|
||||
{
|
||||
memclear(&g_eeGeneral, sizeof(RadioData));
|
||||
}
|
||||
|
||||
void storageReadRadioSettings(bool allowConversion)
|
||||
bool storageReadRadioSettings(bool allowFixes)
|
||||
{
|
||||
if (g_eeGeneral.version != 0)
|
||||
return;
|
||||
|
||||
if (!eepromOpen() || !eeLoadGeneral(allowConversion)) {
|
||||
if (!eepromOpen() || !eeLoadGeneral(allowFixes)) {
|
||||
if (!allowFixes) {
|
||||
storageClearRadioSettings();
|
||||
return false;
|
||||
}
|
||||
storageEraseAll(true);
|
||||
}
|
||||
else {
|
||||
@@ -109,6 +109,10 @@ void storageReadRadioSettings(bool allowConversion)
|
||||
currentLanguagePack = languagePacks[i];
|
||||
}
|
||||
}
|
||||
|
||||
postRadioSettingsLoad();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void storageReadCurrentModel()
|
||||
@@ -118,7 +122,7 @@ void storageReadCurrentModel()
|
||||
|
||||
void storageReadAll()
|
||||
{
|
||||
storageReadRadioSettings(true);
|
||||
storageReadRadioSettings();
|
||||
storageReadCurrentModel();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,11 +28,11 @@ void eeLoadModel(uint8_t id);
|
||||
uint8_t eeFindEmptyModel(uint8_t id, bool down);
|
||||
void selectModel(uint8_t sub);
|
||||
|
||||
extern ModelHeader modelHeaders[MAX_MODELS];
|
||||
void eeLoadModelHeader(uint8_t id, ModelHeader *header);
|
||||
void eeLoadModelHeaders();
|
||||
extern ModelHeader modelHeaders[MAX_MODELS];
|
||||
void eeLoadModelHeader(uint8_t id, ModelHeader *header);
|
||||
void eeLoadModelHeaders();
|
||||
|
||||
void storageClearRadioSetting();
|
||||
void storageReadRadioSettings(bool allowConversion);
|
||||
void storageClearRadioSettings();
|
||||
bool storageReadRadioSettings(bool allowFixes = true);
|
||||
void storageReadCurrentModel();
|
||||
|
||||
|
||||
@@ -256,21 +256,17 @@ void writeModel(int index)
|
||||
writeFile(index+1, (uint8_t *)&g_model, sizeof(g_model));
|
||||
}
|
||||
|
||||
bool eeLoadGeneral(bool allowConversion)
|
||||
bool eeLoadGeneral(bool allowFixes)
|
||||
{
|
||||
eeLoadGeneralSettingsData();
|
||||
|
||||
if (g_eeGeneral.version != EEPROM_VER) {
|
||||
TRACE("EEPROM version %d instead of %d", g_eeGeneral.version, EEPROM_VER);
|
||||
#if defined(PCBSKY9X)
|
||||
if (!allowConversion) {
|
||||
storageClearRadioSetting();
|
||||
return true; // prevent eeprom from being wiped
|
||||
}
|
||||
|
||||
if (!eeConvert()) {
|
||||
if (!allowFixes)
|
||||
return false; // prevent eeprom from being wiped
|
||||
if (!eeConvert())
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include <inttypes.h>
|
||||
#include <stdint.h>
|
||||
|
||||
bool eeLoadGeneral(bool allowConversion);
|
||||
bool eeLoadGeneral(bool allowFixes);
|
||||
void eeDeleteModel( uint8_t id );
|
||||
bool eeCopyModel(uint8_t dst, uint8_t src);
|
||||
void eeSwapModels(uint8_t id1, uint8_t id2);
|
||||
|
||||
@@ -757,7 +757,7 @@ uint16_t eeLoadModelData(uint8_t index)
|
||||
return theFile.readRlc((uint8_t*)&g_model, sizeof(g_model));
|
||||
}
|
||||
|
||||
bool eeLoadGeneral(bool allowConversion)
|
||||
bool eeLoadGeneral(bool allowFixes)
|
||||
{
|
||||
theFile.openRlc(FILE_GENERAL);
|
||||
if (theFile.readRlc((uint8_t*)&g_eeGeneral, 3) == 3 && g_eeGeneral.version == EEPROM_VER) {
|
||||
@@ -794,16 +794,14 @@ bool eeLoadGeneral(bool allowConversion)
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(EEPROM_CONVERSIONS)
|
||||
if (g_eeGeneral.version != EEPROM_VER) {
|
||||
if (!allowConversion) {
|
||||
storageClearRadioSetting();
|
||||
return true; // prevent eeprom from being wiped
|
||||
}
|
||||
TRACE("EEPROM version %d instead of %d", g_eeGeneral.version, EEPROM_VER);
|
||||
if (!eeConvert()) {
|
||||
if (!allowFixes)
|
||||
return false; // prevent eeprom from being wiped
|
||||
if (!eeConvert())
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
#else
|
||||
|
||||
@@ -176,11 +176,10 @@ const char * eeRestoreModel(uint8_t i_fileDst, char *model_name);
|
||||
|
||||
// For conversions
|
||||
void loadRadioSettings();
|
||||
void loadModel(int index, bool alarms=true);
|
||||
|
||||
bool eepromOpen();
|
||||
void eeLoadModelName(uint8_t id, char * name);
|
||||
bool eeLoadGeneral(bool allowConversion);
|
||||
bool eeLoadGeneral(bool allowFixes);
|
||||
|
||||
// For EEPROM backup/restore
|
||||
inline bool isEepromStart(const void * buffer)
|
||||
|
||||
@@ -173,6 +173,8 @@ const char * loadRadioSettings(const char * path)
|
||||
}
|
||||
#endif
|
||||
|
||||
postRadioSettingsLoad();
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,9 +49,10 @@ void storageReadAll();
|
||||
void storageDirty(uint8_t msk);
|
||||
void storageCheck(bool immediately);
|
||||
void storageFlushCurrentModel();
|
||||
|
||||
void postRadioSettingsLoad();
|
||||
void preModelLoad();
|
||||
void postModelLoad(bool alarms);
|
||||
void checkExternalAntenna();
|
||||
|
||||
#if defined(EEPROM_RLC)
|
||||
#include "eeprom_common.h"
|
||||
|
||||
@@ -53,20 +53,92 @@ void preModelLoad()
|
||||
|
||||
pauseMixerCalculations();
|
||||
}
|
||||
#if defined(PCBFRSKY)
|
||||
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
|
||||
}
|
||||
|
||||
#if defined(EXTERNAL_ANTENNA) && defined(INTERNAL_MODULE_PXX1)
|
||||
void onAntennaSelection(const char * result)
|
||||
{
|
||||
if (result == STR_USE_INTERNAL_ANTENNA) {
|
||||
globalData.externalAntennaEnabled = false;
|
||||
}
|
||||
else if (result == STR_USE_EXTERNAL_ANTENNA) {
|
||||
globalData.externalAntennaEnabled = true;
|
||||
}
|
||||
else {
|
||||
checkExternalAntenna();
|
||||
}
|
||||
}
|
||||
|
||||
void onAntennaSwitchConfirm(const char * result)
|
||||
{
|
||||
if (result == STR_OK) {
|
||||
// Switch to external antenna confirmation
|
||||
globalData.externalAntennaEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
void checkExternalAntenna()
|
||||
{
|
||||
if (isModuleXJT(INTERNAL_MODULE)) {
|
||||
if (g_eeGeneral.antennaMode == ANTENNA_MODE_EXTERNAL) {
|
||||
globalData.externalAntennaEnabled = true;
|
||||
}
|
||||
else if (g_eeGeneral.antennaMode == ANTENNA_MODE_PER_MODEL && g_model.moduleData[INTERNAL_MODULE].pxx.antennaMode == ANTENNA_MODE_EXTERNAL) {
|
||||
if (!globalData.externalAntennaEnabled) {
|
||||
#if defined(COLORLCD)
|
||||
#warning "Antenna confirmation dialog needed"
|
||||
#else
|
||||
POPUP_CONFIRMATION(STR_ANTENNACONFIRM1, onAntennaSwitchConfirm);
|
||||
SET_WARNING_INFO(STR_ANTENNACONFIRM2, sizeof(TR_ANTENNACONFIRM2), 0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else if (g_eeGeneral.antennaMode == ANTENNA_MODE_ASK || (g_eeGeneral.antennaMode == ANTENNA_MODE_PER_MODEL && g_model.moduleData[INTERNAL_MODULE].pxx.antennaMode == ANTENNA_MODE_ASK)) {
|
||||
globalData.externalAntennaEnabled = false;
|
||||
#if defined(COLORLCD)
|
||||
#warning "Antenna confirmation dialog needed"
|
||||
#else
|
||||
POPUP_MENU_ADD_ITEM(STR_USE_INTERNAL_ANTENNA);
|
||||
POPUP_MENU_ADD_ITEM(STR_USE_EXTERNAL_ANTENNA);
|
||||
POPUP_MENU_START(onAntennaSelection);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
globalData.externalAntennaEnabled = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
globalData.externalAntennaEnabled = false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void postModelLoad(bool alarms)
|
||||
{
|
||||
#if defined(PCBFRSKY)
|
||||
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);
|
||||
|
||||
@@ -78,7 +150,10 @@ void postModelLoad(bool alarms)
|
||||
TelemetrySensor & sensor = g_model.telemetrySensors[i];
|
||||
if (sensor.type == TELEM_TYPE_CALCULATED && sensor.persistent) {
|
||||
telemetryItems[i].value = sensor.persistentValue;
|
||||
telemetryItems[i].lastReceived = TELEMETRY_VALUE_OLD; // #3595: make value visible even before the first new value is received)
|
||||
telemetryItems[i].timeout = 0; // make value visible even before the first new value is received)
|
||||
}
|
||||
else {
|
||||
telemetryItems[i].timeout = TELEMETRY_SENSOR_TIMEOUT_UNAVAILABLE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,6 +180,7 @@ void postModelLoad(bool alarms)
|
||||
|
||||
LOAD_MODEL_BITMAP();
|
||||
LUA_LOAD_MODEL_SCRIPTS();
|
||||
|
||||
SEND_FAILSAFE_1S();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user