1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-23 08:15:17 +03:00

Date+Time append to screenshots filenames

This commit is contained in:
bsongis 2015-02-15 13:39:35 +01:00
parent 3c4a23a3c6
commit 23c4712bbf
5 changed files with 27 additions and 10 deletions

View file

@ -223,12 +223,28 @@ inline display_t getPixel(unsigned int x, unsigned int y)
return (y & 1) ? (*p >> 4) : (*p & 0x0F); return (y & 1) ? (*p >> 4) : (*p & 0x0F);
} }
const char *writeScreenshot(const char *filename) const char *writeScreenshot()
{ {
FIL bmpFile; FIL bmpFile;
UINT written; UINT written;
char filename[48]; // /SCREENSHOTS/screenshot-2013-01-01-12-35-40.bmp
DIR folder;
FRESULT result = f_open(&bmpFile, filename, FA_CREATE_ALWAYS | FA_WRITE); // check and create folder here
strcpy_P(filename, SCREENSHOTS_PATH);
FRESULT result = f_opendir(&folder, filename);
if (result != FR_OK) {
if (result == FR_NO_PATH)
result = f_mkdir(filename);
if (result != FR_OK)
return SDCARD_ERROR(result);
}
char *tmp = strAppend(&filename[sizeof(SCREENSHOTS_PATH)-1], "/screenshot");
tmp = strAppendDate(tmp, true);
strcpy(tmp, BITMAPS_EXT);
result = f_open(&bmpFile, filename, FA_CREATE_ALWAYS | FA_WRITE);
if (result != FR_OK) { if (result != FR_OK) {
return SDCARD_ERROR(result); return SDCARD_ERROR(result);
} }

View file

@ -546,7 +546,7 @@ void evalFunctions()
#if defined(PCBTARANIS) #if defined(PCBTARANIS)
case FUNC_SCREENSHOT: case FUNC_SCREENSHOT:
if (!(functionsContext.activeSwitches & switch_mask)) { if (!(functionsContext.activeSwitches & switch_mask)) {
writeScreenshot("screenshot.bmp"); writeScreenshot();
} }
break; break;
#endif #endif

View file

@ -239,7 +239,7 @@ void lcdOff();
#endif #endif
const char *bmpLoad(uint8_t *dest, const char *filename, const unsigned int width, const unsigned int height); const char *bmpLoad(uint8_t *dest, const char *filename, const unsigned int width, const unsigned int height);
const char *writeScreenshot(const char *filename); const char *writeScreenshot();
#if defined(BOOT) #if defined(BOOT)
#define BLINK_ON_PHASE (0) #define BLINK_ON_PHASE (0)

View file

@ -59,8 +59,8 @@ const pm_char * openLogs()
if (!sdMounted()) if (!sdMounted())
return STR_NO_SDCARD; return STR_NO_SDCARD;
// check and create folder here
strcpy_P(filename, STR_LOGS_PATH); strcpy_P(filename, STR_LOGS_PATH);
result = f_opendir(&folder, filename); result = f_opendir(&folder, filename);
if (result != FR_OK) { if (result != FR_OK) {
if (result == FR_NO_PATH) if (result == FR_NO_PATH)

View file

@ -40,11 +40,12 @@
#include "FatFs/ff.h" #include "FatFs/ff.h"
#define ROOT_PATH "/" #define ROOT_PATH "/"
#define MODELS_PATH ROOT_PATH "MODELS" #define MODELS_PATH ROOT_PATH "MODELS" // no trailing slash = important
#define LOGS_PATH ROOT_PATH "LOGS" // no trailing slash = important #define LOGS_PATH ROOT_PATH "LOGS"
#define SOUNDS_PATH ROOT_PATH "SOUNDS/en" // no trailing slash = important #define SCREENSHOTS_PATH ROOT_PATH "SCREENSHOTS"
#define SOUNDS_PATH ROOT_PATH "SOUNDS/en"
#define SOUNDS_PATH_LNG_OFS (sizeof(SOUNDS_PATH)-3) #define SOUNDS_PATH_LNG_OFS (sizeof(SOUNDS_PATH)-3)
#define SYSTEM_SUBDIR "SYSTEM" // no trailing slash = important #define SYSTEM_SUBDIR "SYSTEM"
#define BITMAPS_PATH ROOT_PATH "BMP" #define BITMAPS_PATH ROOT_PATH "BMP"
#define FIRMWARES_PATH ROOT_PATH "FIRMWARES" #define FIRMWARES_PATH ROOT_PATH "FIRMWARES"
#define EEPROMS_PATH ROOT_PATH "EEPROMS" #define EEPROMS_PATH ROOT_PATH "EEPROMS"