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);
}
const char *writeScreenshot(const char *filename)
const char *writeScreenshot()
{
FIL bmpFile;
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) {
return SDCARD_ERROR(result);
}

View file

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

View file

@ -239,7 +239,7 @@ void lcdOff();
#endif
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)
#define BLINK_ON_PHASE (0)

View file

@ -49,7 +49,7 @@ uint8_t logDelay;
#define get3PosState(sw) (switchState(SW_ ## sw ## 0) ? -1 : (switchState(SW_ ## sw ## 2) ? 1 : 0))
const pm_char * openLogs()
const pm_char *openLogs()
{
// Determine and set log file filename
FRESULT result;
@ -59,8 +59,8 @@ const pm_char * openLogs()
if (!sdMounted())
return STR_NO_SDCARD;
// check and create folder here
strcpy_P(filename, STR_LOGS_PATH);
result = f_opendir(&folder, filename);
if (result != FR_OK) {
if (result == FR_NO_PATH)

View file

@ -40,11 +40,12 @@
#include "FatFs/ff.h"
#define ROOT_PATH "/"
#define MODELS_PATH ROOT_PATH "MODELS"
#define LOGS_PATH ROOT_PATH "LOGS" // no trailing slash = important
#define SOUNDS_PATH ROOT_PATH "SOUNDS/en" // no trailing slash = important
#define MODELS_PATH ROOT_PATH "MODELS" // no trailing slash = important
#define LOGS_PATH ROOT_PATH "LOGS"
#define SCREENSHOTS_PATH ROOT_PATH "SCREENSHOTS"
#define SOUNDS_PATH ROOT_PATH "SOUNDS/en"
#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 FIRMWARES_PATH ROOT_PATH "FIRMWARES"
#define EEPROMS_PATH ROOT_PATH "EEPROMS"