diff --git a/src/Makefile b/src/Makefile index 145206d2e..6e0b3c0b9 100644 --- a/src/Makefile +++ b/src/Makefile @@ -104,9 +104,13 @@ DSM2 = NO SOMO = NO # TRANSLATIONS -# Values = en, +# Values = en, fr, se TRANSLATIONS = EN +# UNITS +# Values = imperial, metric +UNITS = METRIC + # EEPROM_PROGRESS_BAR # Values = YES, NO EEPROM_PROGRESS_BAR = NO @@ -212,6 +216,10 @@ EXTRAINCDIRS = . translations CPPDEFS += -DTRANSLATIONS_$(TRANSLATIONS) +ifeq ($(UNITS), IMPERIAL) + CPPDEFS += -DIMPERIAL_UNITS +endif + # If POT1/POTS/RE1 is used for fields modification ifeq ($(NAVIGATION), POT1) CPPDEFS += -DNAVIGATION_POT1 @@ -315,7 +323,7 @@ ifeq ($(PCB), V4) endif ifeq ($(SDCARD), YES) - CPPDEFS += -DSDCARD + CPPDEFS += -DSDCARD CPPSRC += gruvin9x/logs.cpp MODS:=${MODS}S endif diff --git a/src/eeprom_avr.cpp b/src/eeprom_avr.cpp index e98b6dc75..0f7758558 100644 --- a/src/eeprom_avr.cpp +++ b/src/eeprom_avr.cpp @@ -531,34 +531,47 @@ const pm_char * eeArchiveModel(uint8_t i_fileSrc) { char *buf = reusableBuffer.model_name; FIL archiveFile; + UINT written; FRESULT result = f_mount(0, &g_FATFS_Obj); if (result != FR_OK) { - return PSTR("SDCARD F/S ERROR"); // TODO ... + return SDCARD_ERROR(result); } - 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 (isizeof(MODELS_PATH)-1) { + if (!len && buf[i]) + len = i+1; + if (len) + buf[i] = idx2char(buf[i]); + i--; } - strcpy_P(&buf[i], PSTR(".bin")); // TODO Not PSTR everywhere ... -*/ + strcpy_P(&buf[len], PSTR(".bin")); // TODO Not PSTR everywhere ... + result = f_open(&archiveFile, buf, FA_OPEN_ALWAYS | FA_WRITE); if (result != FR_OK) { return SDCARD_ERROR(result); } + result = f_write(&archiveFile, &g_eeGeneral.myVers, 1, &written); + if (result != FR_OK) { + return SDCARD_ERROR(result); + } + EFile theFile2; theFile2.openRd(FILE_MODEL(i_fileSrc)); - uint8_t len; - while ((len=theFile2.read((uint8_t *)buf, 15))) - { - for (uint8_t i=0; i>= 6 ; + } + if (unit == UNIT_METERS) { + // m to ft *105/32 + val = val * 3 + ( val >> 2 ) + (val >> 5) ; + unit = UNIT_MAX; + } +#endif + lcd_outdezAtt(x, (att & DBLSIZE ? y - FH : y), val, att & (~NO_UNIT)); // TODO we could add this test inside lcd_outdezAtt! if (~att & NO_UNIT && unit != UNIT_RAW) lcd_putsiAtt(lcd_lastPos/*+1*/, y, STR_VTELEMUNIT, unit, 0); @@ -864,6 +877,7 @@ static const pm_uint8_t bchunit_ar[] PROGMEM = { UNIT_DEGREES, // T2 UNIT_KMH, // Speed UNIT_METERS, // Dist + UNIT_METERS, // GPS Alt }; void putsTelemetryChannel(uint8_t x, uint8_t y, uint8_t channel, int16_t val, uint8_t att) diff --git a/src/frsky.h b/src/frsky.h index 9da0a0e8d..cd5b96f1d 100644 --- a/src/frsky.h +++ b/src/frsky.h @@ -71,7 +71,7 @@ class FrskyData: public FrskyRSSI { #if defined(FRSKY_HUB) PACK(struct FrskyHubData { int16_t baroAltitudeOffset;// spare reused - int16_t gpsAltitude_bp; // 0x01 before punct + int16_t gpsAltitude_bp; // 0x01 before punct int16_t temperature1; // 0x02 -20 .. 250 deg. celcius uint16_t rpm; // 0x03 0..60,000 revs. per minute uint16_t fuelLevel; // 0x04 0, 25, 50, 75, 100 percent diff --git a/src/general_menus.cpp b/src/general_menus.cpp index c3196304a..4b17f2e78 100644 --- a/src/general_menus.cpp +++ b/src/general_menus.cpp @@ -333,23 +333,21 @@ void menuProcSetup(uint8_t event) if (sub==subN) CHECK_INCDEC_GENVAR(event, g_eeGeneral.timezone, -12, 12); if((y+=FH)>7*FH) return; - }subN++; + }subN++; if(s_pgOfs7*FH) return; - }subN++; + }subN++; #endif if(s_pgOfsAETR - for (uint8_t i=1; i<=4; i++) - 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; + uint8_t attr = sub==subN?INVERS:0; + lcd_putsLeft( y,STR_RXCHANNELORD);// RAET->AETR + for (uint8_t i=1; i<=4; i++) + 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++; if(s_pgOfs0=opened, <0=error const pm_char * g_logError = NULL; +// TODO initSDCard() void initLogs() { // Determine and set log file filename @@ -65,6 +66,18 @@ void initLogs() return; } + DIR dir; + result = f_opendir(&dir, MODELS_PATH); + if (result != FR_OK) { + if (result == FR_NO_PATH) + result = f_mkdir(MODELS_PATH); + if (result != FR_OK) { + g_logState = -result; + g_logError = PSTR("Check " MODELS_PATH " folder"); + return; + } + } + // Loop, skipping over any existing log files ... _000, _001, etc. until we have a unique file name while (1) { diff --git a/src/gruvin9x/logs.h b/src/gruvin9x/logs.h index 578ef9e2f..1139db8fc 100644 --- a/src/gruvin9x/logs.h +++ b/src/gruvin9x/logs.h @@ -34,9 +34,10 @@ #ifndef LOGS_H #define LOGS_H -#define LOG_PATH "/O9XLOGS" // no trailing slash = important +#define LOG_PATH "/9XLOGS" // no trailing slash = important +#define MODELS_PATH "/9XMODELS" -extern char g_logFilename[21]; // "/O9XLOGS/M00_000.CSV\0" max required length = 21 +extern char g_logFilename[21]; // "/9XLOGS/M00_000.CSV\0" max required length = 21 extern int8_t g_logState; // 0=closed, >0 = opened, <0 is error extern FATFS g_FATFS_Obj; extern FIL g_oLogFile; diff --git a/src/main_views.cpp b/src/main_views.cpp index 2db573484..55bc122a1 100644 --- a/src/main_views.cpp +++ b/src/main_views.cpp @@ -93,7 +93,7 @@ void menuMainView(uint8_t event) break; case EVT_KEY_BREAK(KEY_RIGHT): case EVT_KEY_BREAK(KEY_LEFT): - if (view_base == e_inputs) { + if (view_base <= e_inputs) { g_eeGeneral.view ^= ALTERNATE_VIEW; eeDirty(EE_GENERAL); AUDIO_KEYPAD_UP(); @@ -235,11 +235,10 @@ void menuMainView(uint8_t event) } } - if(view_base PSIZE(TR_CURRENT_CALIB) ? PSIZE(TR_BATT_CALIB) : PSIZE(TR_CURRENT_CALIB)) +#else +#define LEN_CALIB_FIELDS PSIZE(TR_BATT_CALIB) #endif #if defined(SDCARD) diff --git a/src/open9x.cpp b/src/open9x.cpp index 3dd6316f4..f3a978e9b 100644 --- a/src/open9x.cpp +++ b/src/open9x.cpp @@ -426,8 +426,9 @@ int16_t getValue(uint8_t i) else if(i