diff --git a/src/frsky.cpp b/src/frsky.cpp index 95572fefa..db873358b 100644 --- a/src/frsky.cpp +++ b/src/frsky.cpp @@ -1217,7 +1217,7 @@ void menuTelemetryFrsky(uint8_t event) att = (s_timerState[0]==TMR_BEEPING ? BLINK : 0); putsTime(17*FW, 0, s_timerVal[0], att, att); } - lcd_filled_rect(0, 0, DISPLAY_W, 8); + lcd_invert_line(0); if (frskyStreaming >= 0) { if (s_frsky_view < MAX_FRSKY_SCREENS) { @@ -1257,11 +1257,9 @@ void menuTelemetryFrsky(uint8_t event) uint8_t width = barCoord(value, barMin, barMax); // reversed barshade for T1/T2 - uint8_t barShade; + uint8_t barShade = ((threshold > value) ? DOTTED : SOLID); if (source == TELEM_T1 || source == TELEM_T2) - barShade = ((threshold < value) ? DOTTED : SOLID); - else - barShade = ((threshold > value) ? DOTTED : SOLID); + barShade = -barShade; lcd_filled_rect(26, y+1, width, barHeight, barShade); diff --git a/src/general_menus.cpp b/src/general_menus.cpp index e914700c5..4f7f40039 100644 --- a/src/general_menus.cpp +++ b/src/general_menus.cpp @@ -510,7 +510,7 @@ void menuGeneralSdManager(uint8_t event) switch(event) { case EVT_ENTRY: - f_chdir("/"); + f_chdir(ROOT_PATH); reusableBuffer.sd.offset = 65535; break; #if defined(ROTARY_ENCODERS) @@ -551,8 +551,12 @@ void menuGeneralSdManager(uint8_t event) else { #if defined(PCBSKY9X) uint8_t index = m_posVert-1-s_pgOfs; - char * line = reusableBuffer.sd.lines[index]; - if (!strcmp(line+strlen(line)-4, SOUNDS_EXT)) { + char * ext = reusableBuffer.sd.lines[index]; + ext += strlen(ext) - 4; + /* TODO if (!strcmp(ext, MODELS_EXT)) { + s_menu[s_menu_count++] = STR_LOAD_FILE; + } + else */ if (!strcmp(ext, SOUNDS_EXT)) { s_menu[s_menu_count++] = STR_PLAY_FILE; } #endif @@ -690,7 +694,13 @@ void menuGeneralSdManager(uint8_t event) reusableBuffer.sd.offset = s_pgOfs-1; } #if defined(PCBSKY9X) - else if (result == STR_PLAY_FILE) { + /* TODO else if (result == STR_LOAD_FILE) { + f_getcwd(lfn, SD_SCREEN_FILE_LENGTH); + strcat(lfn, "/"); + strcat(lfn, reusableBuffer.sd.lines[index]); + s_warning = eeLoadModelSD(lfn); + } + else */ if (result == STR_PLAY_FILE) { f_getcwd(lfn, SD_SCREEN_FILE_LENGTH); strcat(lfn, "/"); strcat(lfn, reusableBuffer.sd.lines[index]); diff --git a/src/lcd.cpp b/src/lcd.cpp index 92110c111..d8dc46342 100644 --- a/src/lcd.cpp +++ b/src/lcd.cpp @@ -463,6 +463,15 @@ void lcd_filled_rect(xcoord_t x, int8_t y, xcoord_t w, uint8_t h, uint8_t pat, u } } +void lcd_invert_line(int8_t y) +{ + uint8_t *p = &displayBuf[y * DISPLAY_W]; + for (xcoord_t x=0; x 0) s_editMode = 0; - if (s_editMode > 0 && m_posVert == 0 && menuTab) s_editMode = -1; + if (s_editMode > 0 && l_posVert == 0 && menuTab) s_editMode = -1; } } #else @@ -306,7 +308,7 @@ bool check(uint8_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTa if (menuTab) { uint8_t attr = 0; - if (m_posVert==0 && !s_noScroll) { + if (l_posVert==0 && !s_noScroll) { attr = INVERS; int8_t cc = curr; @@ -351,7 +353,7 @@ bool check(uint8_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTa #endif } #if defined(ROTARY_ENCODERS) - else if (m_posVert < 0) { + else if (l_posVert < 0) { lcd_putsAtt(DISPLAY_W-LEN_BACK*FW, 0, STR_BACK, INVERS); } #endif @@ -360,12 +362,12 @@ bool check(uint8_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTa if (s_editMode<=0) { if (scrollUD) { - m_posVert = limit((int8_t)0, (int8_t)(m_posVert - scrollUD), (int8_t)maxrow); - m_posHorz = min(m_posHorz, MAXCOL(m_posVert)); + l_posVert = limit((int8_t)0, (int8_t)(l_posVert - scrollUD), (int8_t)maxrow); + m_posHorz = min(m_posHorz, MAXCOL(l_posVert)); BLINK_SYNC; } - if (scrollLR && m_posVert>0) { + if (scrollLR && l_posVert>0) { m_posHorz = limit((int8_t)0, (int8_t)(m_posHorz - scrollLR), (int8_t)maxcol); BLINK_SYNC; } @@ -374,14 +376,14 @@ bool check(uint8_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTa while (!s_editMode && scrollRE) { if (scrollRE > 0) { --scrollRE; - maxcol = MAXCOL(m_posVert); + maxcol = MAXCOL(l_posVert); if (maxcol & ZCHAR) maxcol = 0; if (++m_posHorz > maxcol) { - if (m_posVert < maxrow) { - ++m_posVert; - maxcol = MAXCOL(m_posVert); + if (l_posVert < maxrow) { + ++l_posVert; + maxcol = MAXCOL(l_posVert); if (maxcol & ZCHAR) maxcol = 0; - if (maxcol < 0) m_posVert++; + if (maxcol < 0) l_posVert++; m_posHorz = 0; } else { @@ -393,15 +395,15 @@ bool check(uint8_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTa else { ++scrollRE; if (m_posHorz-- == 0) { - if (m_posVert-- <= 0) { - m_posVert = menuTab ? 0 : -1; + if (l_posVert-- <= 0) { + l_posVert = menuTab ? 0 : -1; m_posHorz = 0; scrollRE = 0; } else { - maxcol = MAXCOL(m_posVert); + maxcol = MAXCOL(l_posVert); if (maxcol & ZCHAR) maxcol = 0; - if (maxcol < 0) { --m_posVert; maxcol = MAXCOL(m_posVert); if (maxcol & ZCHAR) maxcol = 0; } + if (maxcol < 0) { --l_posVert; maxcol = MAXCOL(l_posVert); if (maxcol & ZCHAR) maxcol = 0; } m_posHorz = maxcol; } } @@ -431,7 +433,7 @@ bool check(uint8_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTa break; #endif case EVT_KEY_FIRST(KEY_MENU): - if (!menuTab || m_posVert>0) + if (!menuTab || l_posVert>0) s_editMode = (s_editMode<=0); break; case EVT_KEY_LONG(KEY_EXIT): @@ -443,7 +445,7 @@ bool check(uint8_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTa s_editMode = 0; break; } - if (m_posVert==0 || !menuTab) { + if (l_posVert==0 || !menuTab) { popMenu(); // beeps itself return false; } @@ -470,36 +472,37 @@ bool check(uint8_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTa BLINK_SYNC; break; case EVT_KEY_REPT(KEY_DOWN): //inc - if (m_posVert==maxrow) break; + if (l_posVert==maxrow) break; // no break case EVT_KEY_FIRST(KEY_DOWN): //inc if (s_editMode>0) break; do { - INC(m_posVert, maxrow); - } while(MAXCOL(m_posVert) == (uint8_t)-1); + INC(l_posVert, maxrow); + } while(MAXCOL(l_posVert) == (uint8_t)-1); #if defined(ROTARY_ENCODERS) s_editMode = 0; #endif - m_posHorz = min(m_posHorz, MAXCOL(m_posVert)); + m_posHorz = min(m_posHorz, MAXCOL(l_posVert)); BLINK_SYNC; break; case EVT_KEY_REPT(KEY_UP): //dec - if (m_posVert==0) break; + if (l_posVert==0) break; // no break case EVT_KEY_FIRST(KEY_UP): //dec if(s_editMode>0)break; do { - DEC(m_posVert,maxrow); - } while(MAXCOL(m_posVert) == (uint8_t)-1); - m_posHorz = min(m_posHorz, MAXCOL(m_posVert)); + DEC(l_posVert,maxrow); + } while(MAXCOL(l_posVert) == (uint8_t)-1); + m_posHorz = min(m_posHorz, MAXCOL(l_posVert)); BLINK_SYNC; break; } uint8_t max = menuTab ? 7 : 6; - if (m_posVert<1) s_pgOfs=0; - else if (m_posVert-s_pgOfs>max) s_pgOfs = m_posVert-max; - else if (m_posVert-s_pgOfs<1) s_pgOfs = m_posVert-1; + if (l_posVert<1) s_pgOfs=0; + else if (l_posVert-s_pgOfs>max) s_pgOfs = l_posVert-max; + else if (l_posVert-s_pgOfs<1) s_pgOfs = l_posVert-1; + m_posVert = l_posVert; return true; } diff --git a/src/myeeprom.h b/src/myeeprom.h index 3e348286a..6685f53ac 100644 --- a/src/myeeprom.h +++ b/src/myeeprom.h @@ -92,20 +92,18 @@ enum BeeperMode { }; #if defined(PCBSKY9X) -#define EXTRA_SKY9X_FIELDS \ - uint8_t speakerVolume; \ - uint8_t backlightBright; \ - int8_t currentCalib #define EXTRA_GENERAL_FIELDS \ + uint8_t speakerVolume; \ + uint8_t backlightBright; \ + int8_t currentCalib; \ int8_t temperatureWarn; \ uint8_t mAhWarn; \ uint16_t mAhUsed; \ uint32_t globalTimer; \ int8_t temperatureCalib; \ uint8_t btBaudrate; \ - uint8_t optrexDisplay + uint8_t optrexDisplay; #else -#define EXTRA_SKY9X_FIELDS #define EXTRA_GENERAL_FIELDS \ int8_t speakerVolume #endif @@ -139,7 +137,7 @@ PACK(typedef struct t_EEGeneral { int16_t calibSpanNeg[7]; int16_t calibSpanPos[7]; uint16_t chkSum; - uint8_t currModel; //0..15 + int8_t currModel; uint8_t contrast; uint8_t vBatWarn; int8_t vBatCalib; @@ -172,8 +170,6 @@ PACK(typedef struct t_EEGeneral { uint8_t unexpectedShutdown:1; uint8_t speakerPitch; - EXTRA_SKY9X_FIELDS; - EXTRA_GENERAL_FIELDS; }) EEGeneral; diff --git a/src/sdcard.h b/src/sdcard.h index 582bd9413..4bbe19b83 100644 --- a/src/sdcard.h +++ b/src/sdcard.h @@ -37,11 +37,13 @@ #include "FatFs/ff.h" #ifdef SIMU +#define ROOT_PATH "." #define MODELS_PATH "." #define LOGS_PATH "." #define SOUNDS_PATH "." #define SYSTEM_SOUNDS_PATH "." #else +#define ROOT_PATH "/" #define MODELS_PATH "/9XMODELS" #define LOGS_PATH "/9XLOGS" // no trailing slash = important #define SOUNDS_PATH "/9XSOUNDS" // no trailing slash = important diff --git a/src/simpgmspace.cpp b/src/simpgmspace.cpp index efb70cc77..b4a9e846a 100644 --- a/src/simpgmspace.cpp +++ b/src/simpgmspace.cpp @@ -309,10 +309,12 @@ FRESULT f_mount (BYTE, FATFS*) FRESULT f_open (FIL * fil, const TCHAR *name, BYTE flag) { - struct stat tmp; - if (stat(name, &tmp)) - return FR_INVALID_NAME; - fil->fsize = tmp.st_size; + if (!(flag & FA_WRITE)) { + struct stat tmp; + if (stat(name, &tmp)) + return FR_INVALID_NAME; + fil->fsize = tmp.st_size; + } fil->fs = (FATFS*)fopen(name, (flag & FA_WRITE) ? "w+" : "r+"); return FR_OK; } @@ -421,7 +423,7 @@ int f_printf (FIL *f, const TCHAR * format, ...) FRESULT f_getcwd (TCHAR *path, UINT sz_path) { - getcwd(path, sz_path); + strcpy(path, "."); return FR_OK; }