/* * Copyright (C) EdgeTX * * Based on code named * opentx - https://github.com/opentx/opentx * th9x - http://code.google.com/p/th9x * er9x - http://code.google.com/p/er9x * gruvin9x - http://code.google.com/p/gruvin9x * * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ #include "opentx.h" #include "datastructs_219.h" #if defined(COLORLCD) #include "theme.h" #endif // // Summary of all changes between 219 & 220 // // All Radios: // =========== // // PACK(struct TimerData { // - int32_t mode:9; // timer trigger source -> off, abs, stk, stk%, sw/!sw, !m_sw/!m_sw // - uint32_t start:23; // - int32_t value:24; // + uint32_t start:22; // + int32_t swtch:10; // + int32_t value:22; // + uint32_t mode:3; // timer mode (OFF, ON, Start, THs, TH%, THt) // uint32_t countdownBeep:2; // uint32_t minuteBeep:1; // uint32_t persistent:2; // int32_t countdownStart:2; // - uint32_t direction:1; // NOBACKUP(char name[LEN_TIMER_NAME]); // }); // // enum TimerModes { // - TMRMODE_NONE,// ->OFF // - TMRMODE_ABS, // ->ON // + TMRMODE_OFF, // + TMRMODE_ON, // + TMRMODE_START, // 2 -> +1 // TMRMODE_THR, // TMRMODE_THR_REL, // - TMRMODE_THR_TRG, // ->START // - TMRMODE_COUNT // + TMRMODE_THR_START, // + TMRMODE_COUNT, // + TMRMODE_MAX = TMRMODE_COUNT - 1 // }; // // COLORLCD: // ========= // // - CHKSIZE(CustomScreenData, 610); // - CHKSIZE(Topbar::PersistentData, 216); // + CHKSIZE(CustomScreenData, 850); // + CHKTYPE(TopBarPersistentData, 300); // // - CHKSIZE(RadioData, 881); // - CHKSIZE(ModelData, 9736); // + CHKSIZE(RadioData, 901); // + CHKSIZE(ModelData, 11020); // // -> RadioData change probably comes from THEME_DATA (added parameter types) // -> ModelData: +1284 (CustomScreenData x 5 = 1200; TopBar::PersistentData: +84) // typedef TimerData TimerData_v220; static void convertToStr(char* str, size_t len) { for (size_t c = 0; c < len; c++) { str[c] = zchar2char(str[c]); } // Trim string while(len > 0 && str[len-1]) { if (str[len - 1] != ' ' && str[len - 1] != '\0') break; str[--len] = '\0'; } } #if defined(COLORLCD) extern const LayoutFactory * defaultLayout; extern OpenTxTheme * defaultTheme; #endif void convertModelData_219_to_220(ModelData &model) { ModelData* oldModelAllocated = (ModelData*)malloc(sizeof(ModelData)); ModelData& oldModel = *oldModelAllocated; memcpy(&oldModel, &model, sizeof(ModelData)); ModelData& newModel = (ModelData&)model; convertToStr(model.header.name, LEN_MODEL_NAME_219); for (uint8_t i=0; i= TMRMODE_START) { timer_219.mode += 1; } if (timer_219.mode < TMRMODE_COUNT && timer_219.mode >=0) { timer.mode = timer_219.mode; } else { timer.mode = TMRMODE_START; if (timer_219.mode > 0) timer.swtch = timer_219.mode - (TMRMODE_COUNT - 1); else timer.swtch = timer_219.mode; } timer.start = timer_219.start; } // MixData::name for (uint8_t i=0; ifunc == FUNC_PLAY_TRACK || cfn->func == FUNC_BACKGND_MUSIC) { // convertToStr(cfn->play.name, LEN_FUNCTION_NAME_219); // } // } // GVarData::name ? for (uint8_t i=0; igetId()); defaultLayout->initPersistentData(&newModel.screenData[0].layoutData); } #endif free(oldModelAllocated); } void convertRadioData_219_to_220(RadioData & settings) { TRACE("Radio conversion from v219 to v220"); settings.version = 220; settings.variant = EEPROM_VARIANT; RadioData* oldSettingsAllocated = (RadioData*)malloc(sizeof(RadioData)); RadioData& oldSettings = *oldSettingsAllocated; memcpy(&oldSettings, &settings, sizeof(RadioData)); #if defined(COLORLCD) // Clear CustomScreenData + TopBarPersistentData // as they cannot be converted (missing option types) strcpy(g_eeGeneral.themeName, defaultTheme->getName()); defaultTheme->init(); #endif for (int i = 0; i < NUM_SWITCHES_219; ++i) { char* sw_name = &(settings.switchNames[i][0]); convertToStr(sw_name, LEN_SWITCH_NAME_219); } for (int i = 0; i < NUM_STICKS_219 + NUM_POTS_219 + NUM_SLIDERS_219; ++i) { char* sw_name = &(settings.anaNames[i][0]); convertToStr(sw_name, LEN_ANA_NAME_219); } #if defined(PCBHORUS) || defined(PCBNV14) convertToStr(settings.bluetoothName, LEN_BLUETOOTH_NAME_219); #endif free(oldSettingsAllocated); }