diff --git a/src/file.cpp b/src/file.cpp index 964e2edb5..778e40c29 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -201,20 +201,16 @@ bool EFile::exists(uint8_t i_fileId) return eeFs.files[i_fileId].startBlk; } +/* + * swap two files in eeprom + * called in sync AND async mode as it is a single write operation + */ void EFile::swap(uint8_t i_fileId1, uint8_t i_fileId2) { -#ifdef EEPROM_ASYNC_WRITE - s_sync_write = true; -#endif - DirEnt tmp = eeFs.files[i_fileId1]; eeFs.files[i_fileId1] = eeFs.files[i_fileId2]; eeFs.files[i_fileId2] = tmp; EeFsFlush(); - -#ifdef EEPROM_ASYNC_WRITE - s_sync_write = false; -#endif } void EFile::rm(uint8_t i_fileId) diff --git a/src/gruvin9x.h b/src/gruvin9x.h index 00c8cb11d..144fb1fdf 100644 --- a/src/gruvin9x.h +++ b/src/gruvin9x.h @@ -522,7 +522,7 @@ extern uint16_t s_traceCnt; const prog_char *get_switches_string() ; uint16_t getTmr16KHz(); -unsigned int stack_free(); +uint16_t stack_free(); void checkLowEEPROM(); void checkTHR(); diff --git a/src/model_menus.cpp b/src/model_menus.cpp index 880a44cb4..611193976 100644 --- a/src/model_menus.cpp +++ b/src/model_menus.cpp @@ -202,7 +202,13 @@ void menuProcModelSelect(uint8_t event) s_copyTgtOfs--; m_posVert = (m_posVert+1) % MAX_MODELS; } +#ifdef EEPROM_ASYNC_WRITE + s_sync_write = true; +#endif EFile::swap(FILE_MODEL(sub), FILE_MODEL(m_posVert)); +#ifdef EEPROM_ASYNC_WRITE + s_sync_write = false; +#endif if (m_posVert == g_eeGeneral.currModel) { g_eeGeneral.currModel = sub; STORE_GENERALVARS; @@ -223,34 +229,33 @@ void menuProcModelSelect(uint8_t event) killEvents(_event); break; case EVT_KEY_BREAK(KEY_MENU): - if (EFile::exists(FILE_MODEL(sub)) && !s_copyTgtOfs) { + if (s_copyTgtOfs) { + s_copyTgtOfs = 0; + s_copyMode = 0; + } + else if (EFile::exists(FILE_MODEL(sub))) { s_copyMode = (s_copyMode == COPY_MODE ? MOVE_MODE : COPY_MODE); s_copySrcRow = -1; - break; } - // no break + break; case EVT_KEY_LONG(KEY_MENU): if (s_copyTgtOfs) { s_copyTgtOfs = 0; + s_copyMode = 0; } else { eeCheck(true); // force writing of current model data before this is changed - eeLoadModel(sub); if (g_eeGeneral.currModel != sub) { g_eeGeneral.currModel = sub; STORE_GENERALVARS; } + eeLoadModel(sub); } - s_copyMode = 0; killEvents(_event); break; case EVT_KEY_FIRST(KEY_LEFT): case EVT_KEY_FIRST(KEY_RIGHT): if (sub == g_eeGeneral.currModel) { - if (!EFile::exists(FILE_MODEL(sub))) { - eeCheck(true); // force writing of current model data before this is changed - eeLoadModel(sub); - } chainMenu(_event == EVT_KEY_FIRST(KEY_RIGHT) ? menuProcModel : menuTabModel[DIM(menuTabModel)-1]); return; } @@ -273,7 +278,13 @@ void menuProcModelSelect(uint8_t event) } else { // only swap the model with its neighbor +#ifdef EEPROM_ASYNC_WRITE + s_sync_write = true; +#endif EFile::swap(FILE_MODEL(oldSub), FILE_MODEL(sub)); +#ifdef EEPROM_ASYNC_WRITE + s_sync_write = false; +#endif if (oldSub == g_eeGeneral.currModel) { g_eeGeneral.currModel = sub; STORE_GENERALVARS; @@ -303,7 +314,7 @@ void menuProcModelSelect(uint8_t event) if (s_copyMode && k==sub) { if (s_copyMode == COPY_MODE) lcd_putc(20*FW+2, y, '+'); - lcd_rect(8, y-1, DISPLAY_W-1-7, 9); + lcd_rect(8, y-1, DISPLAY_W-1-7, 9, s_copyMode == COPY_MODE ? 0xff : 0x55); lcd_filled_rect(9, y, DISPLAY_W-1-9, 7); } } @@ -919,7 +930,7 @@ bool swapExpoMix(uint8_t expo, uint8_t &idx, uint8_t up) return result; } -void editExpoVals(uint8_t event, uint8_t which, bool edit, uint8_t y, uint8_t idt) +inline void editExpoVals(uint8_t event, uint8_t which, bool edit, uint8_t y, uint8_t idt) { uint8_t invBlk = edit ? INVERS : 0; // if(edit && stopBlink) invBlk = INVERS; @@ -959,20 +970,12 @@ void editExpoVals(uint8_t event, uint8_t which, bool edit, uint8_t y, uint8_t id lcd_putsnAtt(6*FW, y, PSTR("---PosNeg")+9-3*ed->mode, 3, invBlk); if(edit) ed->mode = 4 - checkIncDecModel(event, 4-ed->mode, 1, 3); break; - case 6: - lcd_putsAtt(0*FW, y, PSTR("Delete"), invBlk); - if(edit && event==EVT_KEY_FIRST(KEY_MENU)) { - deleteExpoMix(1, idt); - killEvents(event); - popMenu(); - } - break; } } void menuProcExpoOne(uint8_t event) { - SIMPLE_SUBMENU("EXPO/DR", 7); + SIMPLE_SUBMENU("EXPO/DR", 6); ExpoData *ed = expoaddress(s_currIdx); @@ -1017,7 +1020,7 @@ void menuProcExpoOne(uint8_t event) void menuProcMixOne(uint8_t event) { - SIMPLE_SUBMENU_NOTITLE(14); + SIMPLE_SUBMENU_NOTITLE(13); TITLEP(s_currCh ? PSTR("INSERT MIX ") : PSTR("EDIT MIX ")); MixData *md2 = mixaddress(s_currIdx) ; putsChn(lcd_lastPos+1*FW,0,md2->destCh,0); @@ -1102,14 +1105,6 @@ void menuProcMixOne(uint8_t event) lcd_outdezAtt(FW*16,y,md2->speedUp,attr); if(attr) CHECK_INCDEC_MODELVAR( event, md2->speedUp, 0,15); break; - case 13: lcd_putsAtt( 2*FW,y,PSTR("DELETE MIX [MENU]"),attr); - if(attr && event==EVT_KEY_LONG(KEY_MENU)){ - killEvents(event); - deleteExpoMix(0, s_currIdx); - beepWarn1(); - popMenu(); - } - break; } } } diff --git a/src/pers.cpp b/src/pers.cpp index c764a3f93..0aae48795 100644 --- a/src/pers.cpp +++ b/src/pers.cpp @@ -286,6 +286,7 @@ void eeLoadModel(uint8_t id) if (sz != sizeof(ModelData)) { // alert("Error Loading Model"); modelDefault(id); + eeCheck(true); } resetTimer1();