diff --git a/src/eeprom_avr.cpp b/src/eeprom_avr.cpp index 5dbbe1787..e98b6dc75 100644 --- a/src/eeprom_avr.cpp +++ b/src/eeprom_avr.cpp @@ -529,18 +529,30 @@ bool RlcFile::copy(uint8_t i_fileDst, uint8_t i_fileSrc) #ifdef SDCARD const pm_char * eeArchiveModel(uint8_t i_fileSrc) { - char buf[15]; + char *buf = reusableBuffer.model_name; FIL archiveFile; - eeLoadModelName(i_fileSrc, buf); + FRESULT result = f_mount(0, &g_FATFS_Obj); + if (result != FR_OK) { + return PSTR("SDCARD F/S ERROR"); // TODO ... + } - FRESULT result = f_open(&archiveFile, buf, FA_OPEN_ALWAYS | FA_WRITE); + strcpy_P(buf, PSTR(LOG_PATH "/Twister.bin")); // TODO Not PSTR everywhere ... +/* eeLoadModelName(i_fileSrc, &buf[sizeof(LOG_PATH)+1]); + uint8_t i = sizeof(LOG_PATH)+1; + while (i7*FH) return; }subN++; @@ -168,9 +169,7 @@ void menuProcSetup(uint8_t event) #endif if(s_pgOfs7*FH) return; }subN++; @@ -187,9 +186,7 @@ void menuProcSetup(uint8_t event) #ifdef HAPTIC if(s_pgOfs7*FH) return; }subN++; @@ -204,7 +201,7 @@ void menuProcSetup(uint8_t event) if(s_pgOfs7*FH) return; }subN++; @@ -257,9 +254,7 @@ void menuProcSetup(uint8_t event) }subN++; if(s_pgOfs7*FH) return; }subN++; @@ -318,10 +313,8 @@ void menuProcSetup(uint8_t event) }subN++; if(s_pgOfs7*FH) return; + g_eeGeneral.switchWarning = selectMenuItem(y, STR_SWITCHWARNING, STR_WARNSW, g_eeGeneral.switchWarning, -1, 1, sub==subN, event); + if((y+=FH)>7*FH) return; }subN++; if(s_pgOfsAETR for (uint8_t i=1; i<=4; i++) - putsChnLetter((16+i)*FW, y, channel_order(i), attr); + putsChnLetter(GENERAL_PARAM_OFS - FW + i*FW, y, channel_order(i), attr); if(attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.templateSetup, 0, 23); if((y+=FH)>7*FH) return; }subN++; diff --git a/src/gruvin9x/logs.cpp b/src/gruvin9x/logs.cpp index 0ec1960c9..f7804d1a2 100644 --- a/src/gruvin9x/logs.cpp +++ b/src/gruvin9x/logs.cpp @@ -49,11 +49,11 @@ void initLogs() if (g_oLogFile.fs) f_close(&g_oLogFile); g_logState = 0; - strcpy_P(g_logFilename, PSTR(LOG_PATH "M00_000.CSV")); + strcpy_P(g_logFilename, PSTR(LOG_PATH "/M00_000.CSV")); // Set log file model number uint8_t num = g_eeGeneral.currModel + 1; - char *n = &g_logFilename[11]; // TODO constant + char *n = &g_logFilename[sizeof(LOG_PATH) + 3]; *n = (char)((num % 10) + '0'); *(--n) = (char)((num / 10) + '0'); @@ -74,7 +74,7 @@ void initLogs() f_close(&g_oLogFile); // bump log file counter (file extension) - n = &g_logFilename[15]; + n = &g_logFilename[sizeof(LOG_PATH) + 7]; if (++*n > '9') { *n='0'; diff --git a/src/model_menus.cpp b/src/model_menus.cpp index 90b9ccf10..94caf3653 100644 --- a/src/model_menus.cpp +++ b/src/model_menus.cpp @@ -242,12 +242,13 @@ void menuProcModelSelect(uint8_t event) killEvents(event); if (g_eeGeneral.currModel != sub) { #if defined(SDCARD) - s_menu[s_menu_count++] = STR_LOAD_MODEL; if (eeModelExists(sub)) { + s_menu[s_menu_count++] = STR_LOAD_MODEL; s_menu[s_menu_count++] = STR_ARCHIVE_MODEL; s_menu[s_menu_count++] = STR_DELETE_MODEL;; } else { + s_menu[s_menu_count++] = STR_CREATE_MODEL; s_menu[s_menu_count++] = STR_RESTORE_MODEL;; } #else @@ -364,13 +365,16 @@ void menuProcModelSelect(uint8_t event) if (s_sdcard_error) { s_warning = s_sdcard_error; displayWarning(event); - s_warning = NULL; + if (s_warning) + s_warning = NULL; + else + s_sdcard_error = NULL; } if (s_menu_count) { const pm_char * result = displayMenu(event); if (result) { - if (result == STR_LOAD_MODEL) { + if (result == STR_LOAD_MODEL || result == STR_CREATE_MODEL) { displayPopup(STR_LOADINGMODEL); eeCheck(true); // force writing of current model data before this is changed if (g_eeGeneral.currModel != sub) { @@ -381,6 +385,8 @@ void menuProcModelSelect(uint8_t event) } else if (result == STR_ARCHIVE_MODEL) { s_sdcard_error = eeArchiveModel(sub); + if (!s_sdcard_error) + eeDeleteModel(sub); // delete the model, it's archived! } else if (result == STR_RESTORE_MODEL) { // TODO diff --git a/src/o9xstrings.cpp b/src/o9xstrings.cpp index a03366e97..a82920cfb 100644 --- a/src/o9xstrings.cpp +++ b/src/o9xstrings.cpp @@ -309,6 +309,7 @@ const pm_char STR_CURRENT[] PROGMEM = TR_CURRENT; #if defined(SDCARD) const pm_char STR_LOAD_MODEL[] PROGMEM = TR_LOAD_MODEL; +const pm_char STR_CREATE_MODEL[] PROGMEM = TR_CREATE_MODEL; const pm_char STR_ARCHIVE_MODEL[] PROGMEM = TR_ARCHIVE_MODEL; const pm_char STR_DELETE_MODEL[] PROGMEM = TR_DELETE_MODEL; const pm_char STR_RESTORE_MODEL[] PROGMEM = TR_RESTORE_MODEL; diff --git a/src/o9xstrings.h b/src/o9xstrings.h index cb4679805..04e18ab3e 100644 --- a/src/o9xstrings.h +++ b/src/o9xstrings.h @@ -368,6 +368,7 @@ extern const pm_char STR_CURRENT[]; #if defined(SDCARD) extern const pm_char STR_LOAD_MODEL[]; +extern const pm_char STR_CREATE_MODEL[]; extern const pm_char STR_ARCHIVE_MODEL[]; extern const pm_char STR_DELETE_MODEL[]; extern const pm_char STR_RESTORE_MODEL[]; diff --git a/src/open9x.h b/src/open9x.h index c0318fa05..f3f4c8b09 100644 --- a/src/open9x.h +++ b/src/open9x.h @@ -583,7 +583,7 @@ extern uint8_t s_eeDirtyMsk; #if defined (PCBARM) #ifndef SIMU -#define BACKLIGHT_ON (PWM->PWM_CH_NUM[0].PWM_CDTY = 0/*TODO g_eeGeneral.bright*/) +#define BACKLIGHT_ON (PWM->PWM_CH_NUM[0].PWM_CDTY = g_eeGeneral.backlightBright) #define BACKLIGHT_OFF (PWM->PWM_CH_NUM[0].PWM_CDTY = 100) #else #define BACKLIGHT_ON @@ -835,10 +835,10 @@ union ReusableBuffer { #if !defined(PCBARM) uint8_t eefs_buffer[BLOCKS]; // used by EeFsck - - char model_name[sizeof(g_model.name)]; // used by menuProcModelSelect #endif + char model_name[42]; // used by menuProcModelSelect and for SD card archive / restore + struct { int16_t midVals[7]; diff --git a/src/simu.cpp b/src/simu.cpp index fc2780549..e0a5d0ede 100644 --- a/src/simu.cpp +++ b/src/simu.cpp @@ -247,8 +247,13 @@ void Open9xSim::refreshDiplay() { if (lcd_refresh) { lcd_refresh = false; +#if defined(PCBV4) + if(portc & 1<setOffColor(FXRGB(150,200,152)); + else bmf->setOffColor(FXRGB(200,200,200)); +#else if(portb & 1<setOffColor(FXRGB(150,200,152)); else bmf->setOffColor(FXRGB(200,200,200)); +#endif for(int x=0;x