EEPROM conversions on sky9x
This commit is contained in:
@@ -44,7 +44,9 @@ PACK(typedef struct {
|
|||||||
int8_t weight;
|
int8_t weight;
|
||||||
uint8_t curveMode;
|
uint8_t curveMode;
|
||||||
char name[LEN_EXPOMIX_NAME];
|
char name[LEN_EXPOMIX_NAME];
|
||||||
|
#if defined(PCBTARANIS)
|
||||||
uint8_t spare[2];
|
uint8_t spare[2];
|
||||||
|
#endif
|
||||||
int8_t curveParam;
|
int8_t curveParam;
|
||||||
}) ExpoData_v215;
|
}) ExpoData_v215;
|
||||||
|
|
||||||
@@ -445,60 +447,86 @@ void ConvertModel_215_to_216(ModelData &model)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (uint8_t i=0; i<64; i++) {
|
for (uint8_t i=0; i<64; i++) {
|
||||||
MixData & mix = g_model.mixData[i];
|
MixData * mix = &g_model.mixData[i];
|
||||||
|
MixData_v215 * oldMix = &oldModel.mixData[i];
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
mix.destCh = oldModel.mixData[i].destCh;
|
mix->destCh = oldMix->destCh;
|
||||||
mix.phases = oldModel.mixData[i].phases;
|
mix->phases = oldMix->phases;
|
||||||
mix.mltpx = oldModel.mixData[i].mltpx;
|
mix->mltpx = oldMix->mltpx;
|
||||||
if (oldModel.mixData[i].carryTrim == TRIM_OFF) mix.carryTrim = TRIM_OFF;
|
if (oldMix->carryTrim == TRIM_OFF) mix->carryTrim = TRIM_OFF;
|
||||||
mix.weight = ConvertGVAR_215_to_216(oldModel.mixData[i].weight);
|
mix->weight = ConvertGVAR_215_to_216(oldMix->weight);
|
||||||
mix.swtch = ConvertSwitch_215_to_216(oldModel.mixData[i].swtch);
|
mix->swtch = ConvertSwitch_215_to_216(oldMix->swtch);
|
||||||
if (oldModel.mixData[i].curveMode==0/*differential*/) {
|
if (oldMix->curveMode==0/*differential*/) {
|
||||||
mix.curve.type = CURVE_REF_DIFF;
|
mix->curve.type = CURVE_REF_DIFF;
|
||||||
mix.curve.value = oldModel.mixData[i].curveParam;
|
mix->curve.value = oldMix->curveParam;
|
||||||
}
|
}
|
||||||
else if (oldModel.mixData[i].curveParam <= 6) {
|
else if (oldMix->curveParam <= 6) {
|
||||||
mix.curve.type = CURVE_REF_FUNC;
|
mix->curve.type = CURVE_REF_FUNC;
|
||||||
mix.curve.value = oldModel.mixData[i].curveParam;
|
mix->curve.value = oldMix->curveParam;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mix.curve.type = CURVE_REF_CUSTOM;
|
mix->curve.type = CURVE_REF_CUSTOM;
|
||||||
mix.curve.value = oldModel.mixData[i].curveParam - 6;
|
mix->curve.value = oldMix->curveParam - 6;
|
||||||
|
}
|
||||||
|
mix->mixWarn = oldMix->mixWarn;
|
||||||
|
mix->delayUp = oldMix->delayUp;
|
||||||
|
mix->delayDown = oldMix->delayDown;
|
||||||
|
mix->speedUp = oldMix->speedUp;
|
||||||
|
mix->speedDown = oldMix->speedDown;
|
||||||
|
mix->srcRaw = oldMix->srcRaw;
|
||||||
|
if (mix->srcRaw > 4 || oldMix->noExpo)
|
||||||
|
mix->srcRaw = ConvertSource_215_to_216(mix->srcRaw);
|
||||||
|
mix->offset = ConvertGVAR_215_to_216(oldMix->offset);
|
||||||
|
memcpy(mix->name, oldMix->name, LEN_EXPOMIX_NAME);
|
||||||
|
if (!GV_IS_GV_VALUE(mix->weight, 500, 500) && !GV_IS_GV_VALUE(mix->offset, 500, 500)) {
|
||||||
|
mix->offset = divRoundClosest(mix->offset * mix->weight, 100);
|
||||||
}
|
}
|
||||||
mix.mixWarn = oldModel.mixData[i].mixWarn;
|
|
||||||
mix.delayUp = oldModel.mixData[i].delayUp;
|
|
||||||
mix.delayDown = oldModel.mixData[i].delayDown;
|
|
||||||
mix.speedUp = oldModel.mixData[i].speedUp;
|
|
||||||
mix.speedDown = oldModel.mixData[i].speedDown;
|
|
||||||
mix.srcRaw = oldModel.mixData[i].srcRaw;
|
|
||||||
if (mix.srcRaw > 4 || oldModel.mixData[i].noExpo)
|
|
||||||
mix.srcRaw = ConvertSource_215_to_216(mix.srcRaw);
|
|
||||||
mix.offset = ConvertGVAR_215_to_216(oldModel.mixData[i].offset);
|
|
||||||
memcpy(mix.name, oldModel.mixData[i].name, LEN_EXPOMIX_NAME);
|
|
||||||
#else
|
#else
|
||||||
memcpy(&mix, &oldModel.mixData[i], sizeof(mix));
|
mix->destCh = oldMix->destCh;
|
||||||
|
mix->mixWarn = oldMix->mixWarn;
|
||||||
|
mix->phases = oldMix->phases;
|
||||||
|
mix->curveMode = oldMix->curveMode;
|
||||||
|
mix->noExpo = oldMix->noExpo;
|
||||||
|
mix->carryTrim = oldMix->carryTrim;
|
||||||
|
mix->mltpx = oldMix->mltpx;
|
||||||
|
mix->weight = oldMix->weight;
|
||||||
|
mix->swtch = oldMix->swtch;
|
||||||
|
mix->curveParam = oldMix->curveParam;
|
||||||
|
mix->delayUp = oldMix->delayUp;
|
||||||
|
mix->delayDown = oldMix->delayDown;
|
||||||
|
mix->speedUp = oldMix->speedUp;
|
||||||
|
mix->speedDown = oldMix->speedDown;
|
||||||
|
mix->srcRaw = oldMix->srcRaw;
|
||||||
|
mix->offset = oldMix->offset;
|
||||||
|
memcpy(mix->name, oldMix->name, LEN_EXPOMIX_NAME);
|
||||||
#endif
|
#endif
|
||||||
if (!GV_IS_GV_VALUE(mix.weight, 500, 500) && !GV_IS_GV_VALUE(mix.offset, 500, 500)) {
|
|
||||||
mix.offset = divRoundClosest(mix.offset * mix.weight, 100);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for (uint8_t i=0; i<32; i++) {
|
for (uint8_t i=0; i<32; i++) {
|
||||||
|
#if defined(PCBTARANIS)
|
||||||
g_model.limitData[i].min = 10 * oldModel.limitData[i].min;
|
g_model.limitData[i].min = 10 * oldModel.limitData[i].min;
|
||||||
g_model.limitData[i].max = 10 * oldModel.limitData[i].max;
|
g_model.limitData[i].max = 10 * oldModel.limitData[i].max;
|
||||||
|
#else
|
||||||
|
g_model.limitData[i].min = oldModel.limitData[i].min;
|
||||||
|
g_model.limitData[i].max = oldModel.limitData[i].max;
|
||||||
|
#endif
|
||||||
g_model.limitData[i].ppmCenter = oldModel.limitData[i].ppmCenter;
|
g_model.limitData[i].ppmCenter = oldModel.limitData[i].ppmCenter;
|
||||||
g_model.limitData[i].offset = oldModel.limitData[i].offset;
|
g_model.limitData[i].offset = oldModel.limitData[i].offset;
|
||||||
g_model.limitData[i].symetrical = oldModel.limitData[i].symetrical;
|
g_model.limitData[i].symetrical = oldModel.limitData[i].symetrical;
|
||||||
g_model.limitData[i].revert = oldModel.limitData[i].revert;
|
g_model.limitData[i].revert = oldModel.limitData[i].revert;
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
memcpy(&g_model.limitData[i].name, &oldModel.limitData[i].name, LEN_CHANNEL_NAME);
|
memcpy(g_model.limitData[i].name, oldModel.limitData[i].name, LEN_CHANNEL_NAME);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
int indexes[NUM_STICKS] = { 0, 0, 0, 0 };
|
|
||||||
for (uint8_t i=0; i<32; i++) {
|
|
||||||
if (oldModel.expoData[i].mode) {
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
uint8_t chn = oldModel.expoData[i].chn;
|
int indexes[NUM_STICKS] = { 0, 0, 0, 0 };
|
||||||
if (!oldModel.expoData[i].swtch && !oldModel.expoData[i].phases) {
|
#endif
|
||||||
|
for (uint8_t i=0; i<32; i++) {
|
||||||
|
ExpoData * expo = &g_model.expoData[i];
|
||||||
|
ExpoData_v215 * oldExpo = &oldModel.expoData[i];
|
||||||
|
if (oldExpo->mode) {
|
||||||
|
#if defined(PCBTARANIS)
|
||||||
|
uint8_t chn = oldExpo->chn;
|
||||||
|
if (!oldExpo->swtch && !oldExpo->phases) {
|
||||||
indexes[chn] = -1;
|
indexes[chn] = -1;
|
||||||
}
|
}
|
||||||
else if (indexes[chn] != -1) {
|
else if (indexes[chn] != -1) {
|
||||||
@@ -507,29 +535,36 @@ void ConvertModel_215_to_216(ModelData &model)
|
|||||||
for (uint8_t j=chn+1; j<NUM_STICKS; j++) {
|
for (uint8_t j=chn+1; j<NUM_STICKS; j++) {
|
||||||
indexes[j] = i+1;
|
indexes[j] = i+1;
|
||||||
}
|
}
|
||||||
g_model.expoData[i].srcRaw = MIXSRC_Rud+chn;
|
expo->srcRaw = MIXSRC_Rud+chn;
|
||||||
g_model.expoData[i].chn = chn;
|
expo->chn = chn;
|
||||||
g_model.expoData[i].mode = oldModel.expoData[i].mode;
|
expo->mode = oldExpo->mode;
|
||||||
g_model.expoData[i].swtch = ConvertSwitch_215_to_216(oldModel.expoData[i].swtch);
|
expo->swtch = ConvertSwitch_215_to_216(oldExpo->swtch);
|
||||||
g_model.expoData[i].phases = oldModel.expoData[i].phases;
|
expo->phases = oldExpo->phases;
|
||||||
g_model.expoData[i].weight = oldModel.expoData[i].weight;
|
expo->weight = oldExpo->weight;
|
||||||
memcpy(&g_model.expoData[i].name, &oldModel.expoData[i].name, LEN_EXPOMIX_NAME);
|
memcpy(expo->name, oldExpo->name, LEN_EXPOMIX_NAME);
|
||||||
if (oldModel.expoData[i].curveMode==0/*expo*/) {
|
if (oldExpo->curveMode==0/*expo*/) {
|
||||||
if (oldModel.expoData[i].curveParam) {
|
if (oldExpo->curveParam) {
|
||||||
g_model.expoData[i].curve.type = CURVE_REF_EXPO;
|
expo->curve.type = CURVE_REF_EXPO;
|
||||||
g_model.expoData[i].curve.value = oldModel.expoData[i].curveParam;
|
expo->curve.value = oldExpo->curveParam;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (oldModel.expoData[i].curveParam <= 6) {
|
else if (oldExpo->curveParam <= 6) {
|
||||||
g_model.expoData[i].curve.type = CURVE_REF_FUNC;
|
expo->curve.type = CURVE_REF_FUNC;
|
||||||
g_model.expoData[i].curve.value = oldModel.expoData[i].curveParam;
|
expo->curve.value = oldExpo->curveParam;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
g_model.expoData[i].curve.type = CURVE_REF_CUSTOM;
|
expo->curve.type = CURVE_REF_CUSTOM;
|
||||||
g_model.expoData[i].curve.value = oldModel.expoData[i].curveParam - 7;
|
expo->curve.value = oldExpo->curveParam - 7;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
memcpy(&g_model.expoData[i], &oldModel.expoData[i], sizeof(g_model.expoData[i]));
|
expo->mode = oldExpo->mode;
|
||||||
|
expo->chn = oldExpo->chn;
|
||||||
|
expo->curveMode = oldExpo->curveMode;
|
||||||
|
expo->swtch = oldExpo->swtch;
|
||||||
|
expo->phases = oldExpo->phases;
|
||||||
|
expo->weight = oldExpo->weight;
|
||||||
|
memcpy(expo->name, oldExpo->name, LEN_EXPOMIX_NAME);
|
||||||
|
expo->curveParam = oldExpo->curveParam;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -540,7 +575,7 @@ void ConvertModel_215_to_216(ModelData &model)
|
|||||||
for (int i=NUM_STICKS-1; i>=0; i--) {
|
for (int i=NUM_STICKS-1; i>=0; i--) {
|
||||||
int idx = indexes[i];
|
int idx = indexes[i];
|
||||||
if (idx >= 0) {
|
if (idx >= 0) {
|
||||||
ExpoData *expo = expoAddress(idx);
|
ExpoData * expo = expoAddress(idx);
|
||||||
memmove(expo+1, expo, (MAX_EXPOS-(idx+1))*sizeof(ExpoData));
|
memmove(expo+1, expo, (MAX_EXPOS-(idx+1))*sizeof(ExpoData));
|
||||||
memclear(expo, sizeof(ExpoData));
|
memclear(expo, sizeof(ExpoData));
|
||||||
expo->srcRaw = MIXSRC_Rud + i;
|
expo->srcRaw = MIXSRC_Rud + i;
|
||||||
@@ -806,12 +841,7 @@ bool eeConvert()
|
|||||||
MESSAGE(STR_EEPROMWARN, STR_EEPROM_CONVERTING, NULL, AU_EEPROM_FORMATTING); // TODO translations
|
MESSAGE(STR_EEPROMWARN, STR_EEPROM_CONVERTING, NULL, AU_EEPROM_FORMATTING); // TODO translations
|
||||||
|
|
||||||
// General Settings conversion
|
// General Settings conversion
|
||||||
#if defined(PCBTARANIS)
|
loadGeneralSettings();
|
||||||
theFile.openRlc(0);
|
|
||||||
theFile.readRlc((uint8_t*)&g_eeGeneral, sizeof(g_eeGeneral));
|
|
||||||
#else
|
|
||||||
#pragma message("TODO openRlc for sky9x")
|
|
||||||
#endif
|
|
||||||
if (g_eeGeneral.version == 215) ConvertGeneralSettings_215_to_216(g_eeGeneral);
|
if (g_eeGeneral.version == 215) ConvertGeneralSettings_215_to_216(g_eeGeneral);
|
||||||
s_eeDirtyMsk = EE_GENERAL;
|
s_eeDirtyMsk = EE_GENERAL;
|
||||||
eeCheck(true);
|
eeCheck(true);
|
||||||
@@ -822,16 +852,9 @@ bool eeConvert()
|
|||||||
uint8_t currModel = g_eeGeneral.currModel;
|
uint8_t currModel = g_eeGeneral.currModel;
|
||||||
for (uint8_t id=0; id<MAX_MODELS; id++) {
|
for (uint8_t id=0; id<MAX_MODELS; id++) {
|
||||||
lcd_hline(61, 6*FH+5, 10+id*2, FORCE);
|
lcd_hline(61, 6*FH+5, 10+id*2, FORCE);
|
||||||
// lcd_putsnAtt(61, 7*FH)
|
|
||||||
lcdRefresh();
|
lcdRefresh();
|
||||||
if (eeModelExists(id)) {
|
if (eeModelExists(id)) {
|
||||||
// TODO loadModel without anything else
|
loadModel(id);
|
||||||
#if defined(PCBTARANIS)
|
|
||||||
theFile.openRlc(FILE_MODEL(id));
|
|
||||||
theFile.readRlc((uint8_t*)&g_model, sizeof(g_model));
|
|
||||||
#else
|
|
||||||
#pragma message("TODO openRlc for sky9x")
|
|
||||||
#endif
|
|
||||||
int version = conversionVersionStart;
|
int version = conversionVersionStart;
|
||||||
if (version == 215) {
|
if (version == 215) {
|
||||||
version = 216;
|
version = 216;
|
||||||
|
|||||||
+20
-12
@@ -317,20 +317,28 @@ uint32_t get_current_block_number( uint32_t block_no, uint16_t *p_size, uint32_t
|
|||||||
return block_no ;
|
return block_no ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For conversions ...
|
||||||
|
void loadGeneralSettings()
|
||||||
|
{
|
||||||
|
memset(&g_eeGeneral, 0, sizeof(g_eeGeneral));
|
||||||
|
uint16_t size = min<int>(File_system[0].size, sizeof(g_eeGeneral));
|
||||||
|
if (size) {
|
||||||
|
read32_eeprom_data((File_system[0].block_no << 12) + sizeof(struct t_eeprom_header), (uint8_t *)&g_eeGeneral, size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void loadModel(int index)
|
||||||
|
{
|
||||||
|
memset(&g_model, 0, sizeof(g_model));
|
||||||
|
int size = min<int>(File_system[index+1].size, sizeof(g_model));
|
||||||
|
if (size > 256) { // if loaded a fair amount
|
||||||
|
read32_eeprom_data((File_system[index+1].block_no << 12) + sizeof(struct t_eeprom_header), (uint8_t *)&g_model, size) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool eeLoadGeneral()
|
bool eeLoadGeneral()
|
||||||
{
|
{
|
||||||
uint16_t size = File_system[0].size;
|
loadGeneralSettings();
|
||||||
|
|
||||||
memset(&g_eeGeneral, 0, sizeof(EEGeneral));
|
|
||||||
|
|
||||||
if (size > sizeof(EEGeneral)) {
|
|
||||||
size = sizeof(EEGeneral) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (size) {
|
|
||||||
read32_eeprom_data( ( File_system[0].block_no << 12) + sizeof( struct t_eeprom_header), ( uint8_t *)&g_eeGeneral, size) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_eeGeneral.version != EEPROM_VER) {
|
if (g_eeGeneral.version != EEPROM_VER) {
|
||||||
TRACE("EEPROM version %d instead of %d", g_eeGeneral.version, EEPROM_VER);
|
TRACE("EEPROM version %d instead of %d", g_eeGeneral.version, EEPROM_VER);
|
||||||
if (!eeConvert())
|
if (!eeConvert())
|
||||||
|
|||||||
@@ -101,5 +101,8 @@ const pm_char * eeBackupModel(uint8_t i_fileSrc);
|
|||||||
const pm_char * eeRestoreModel(uint8_t i_fileDst, char *model_name);
|
const pm_char * eeRestoreModel(uint8_t i_fileDst, char *model_name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void loadGeneralSettings();
|
||||||
|
void loadModel(int index);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -868,6 +868,23 @@ void RlcFile::DisplayProgressBar(uint8_t x)
|
|||||||
#define CHECK_EEPROM_VARIANT() (1)
|
#define CHECK_EEPROM_VARIANT() (1)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// For conversions ...
|
||||||
|
#if defined(CPUARM)
|
||||||
|
void loadGeneralSettings()
|
||||||
|
{
|
||||||
|
memset(&g_eeGeneral, 0, sizeof(g_eeGeneral));
|
||||||
|
theFile.openRlc(FILE_GENERAL);
|
||||||
|
theFile.readRlc((uint8_t*)&g_eeGeneral, sizeof(g_eeGeneral));
|
||||||
|
}
|
||||||
|
|
||||||
|
void loadModel(int index)
|
||||||
|
{
|
||||||
|
memset(&g_model, 0, sizeof(g_model));
|
||||||
|
theFile.openRlc(FILE_MODEL(index));
|
||||||
|
theFile.readRlc((uint8_t*)&g_model, sizeof(g_model));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool eeLoadGeneral()
|
bool eeLoadGeneral()
|
||||||
{
|
{
|
||||||
theFile.openRlc(FILE_GENERAL);
|
theFile.openRlc(FILE_GENERAL);
|
||||||
|
|||||||
@@ -241,4 +241,10 @@ const pm_char * eeBackupModel(uint8_t i_fileSrc);
|
|||||||
const pm_char * eeRestoreModel(uint8_t i_fileDst, char *model_name);
|
const pm_char * eeRestoreModel(uint8_t i_fileDst, char *model_name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// For conversions
|
||||||
|
#if defined(CPUARM)
|
||||||
|
void loadGeneralSettings();
|
||||||
|
void loadModel(int index);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -439,7 +439,7 @@ PACK(typedef struct t_CurveRef {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
PACK(typedef struct t_ExpoData {
|
PACK(typedef struct {
|
||||||
uint8_t srcRaw;
|
uint8_t srcRaw;
|
||||||
uint16_t scale;
|
uint16_t scale;
|
||||||
uint8_t chn;
|
uint8_t chn;
|
||||||
@@ -550,7 +550,7 @@ PACK(typedef struct t_LimitData {
|
|||||||
#define DELAY_MAX (25*DELAY_STEP) /* 25 seconds */
|
#define DELAY_MAX (25*DELAY_STEP) /* 25 seconds */
|
||||||
#define SLOW_MAX (25*SLOW_STEP) /* 25 seconds */
|
#define SLOW_MAX (25*SLOW_STEP) /* 25 seconds */
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
PACK(typedef struct t_MixData {
|
PACK(typedef struct {
|
||||||
uint8_t destCh;
|
uint8_t destCh;
|
||||||
uint16_t phases;
|
uint16_t phases;
|
||||||
uint8_t mltpx:2; // multiplex method: 0 means +=, 1 means *=, 2 means :=
|
uint8_t mltpx:2; // multiplex method: 0 means +=, 1 means *=, 2 means :=
|
||||||
|
|||||||
Reference in New Issue
Block a user