From 337ab74b8b24d710a49fa36cf8cff2c821e1d220 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Mon, 1 Aug 2016 20:44:30 +0200 Subject: [PATCH] Compilation fix --- radio/src/CMakeLists.txt | 2 +- radio/src/gui/128x64/gui.h | 5 +- radio/src/gui/212x64/gui.h | 2 +- radio/src/gui/480x272/gui.h | 2 +- radio/src/gui/{gui_helpers.h => gui_common.h} | 8 +- .../{gui_helpers.cpp => gui_common_arm.cpp} | 0 radio/src/gui/screenshot.cpp | 76 +++++++++++++++++++ 7 files changed, 85 insertions(+), 10 deletions(-) rename radio/src/gui/{gui_helpers.h => gui_common.h} (96%) rename radio/src/gui/{gui_helpers.cpp => gui_common_arm.cpp} (100%) create mode 100644 radio/src/gui/screenshot.cpp diff --git a/radio/src/CMakeLists.txt b/radio/src/CMakeLists.txt index e57a45373..22fb7c005 100644 --- a/radio/src/CMakeLists.txt +++ b/radio/src/CMakeLists.txt @@ -332,7 +332,7 @@ if(GUI) keys.cpp maths.cpp translations.cpp - gui/gui_helpers.cpp + gui/gui_common_arm.cpp ) foreach(FILE ${GUI_SRC}) set(SRC ${SRC} gui/${GUI_DIR}/${FILE}) diff --git a/radio/src/gui/128x64/gui.h b/radio/src/gui/128x64/gui.h index ba93147e5..0a2636250 100644 --- a/radio/src/gui/128x64/gui.h +++ b/radio/src/gui/128x64/gui.h @@ -21,10 +21,7 @@ #ifndef _GUI_H_ #define _GUI_H_ -#if defined(CPUARM) -#include "gui_helpers.h" -#endif - +#include "gui_common.h" #include "lcd.h" #include "menus.h" diff --git a/radio/src/gui/212x64/gui.h b/radio/src/gui/212x64/gui.h index a7209446c..cc66f1819 100644 --- a/radio/src/gui/212x64/gui.h +++ b/radio/src/gui/212x64/gui.h @@ -21,7 +21,7 @@ #ifndef _GUI_H_ #define _GUI_H_ -#include "gui_helpers.h" +#include "gui_common.h" #include "lcd.h" #include "menus.h" diff --git a/radio/src/gui/480x272/gui.h b/radio/src/gui/480x272/gui.h index 67a00ba9b..eb359ab75 100644 --- a/radio/src/gui/480x272/gui.h +++ b/radio/src/gui/480x272/gui.h @@ -21,7 +21,7 @@ #ifndef _GUI_H_ #define _GUI_H_ -#include "gui_helpers.h" +#include "gui_common.h" #include "lcd.h" #include "menus.h" #include "widgets.h" diff --git a/radio/src/gui/gui_helpers.h b/radio/src/gui/gui_common.h similarity index 96% rename from radio/src/gui/gui_helpers.h rename to radio/src/gui/gui_common.h index 6f7984b5b..3b3eed16c 100644 --- a/radio/src/gui/gui_helpers.h +++ b/radio/src/gui/gui_common.h @@ -18,9 +18,10 @@ * GNU General Public License for more details. */ -#ifndef _GUI_HELPERS_H_ -#define _GUI_HELPERS_H_ +#ifndef _GUI_COMMON_H_ +#define _GUI_COMMON_H_ +#if defined(CPUARM) typedef bool (*IsValueAvailable)(int); int circularIncDec(int current, int inc, int min, int max, IsValueAvailable isValueAvailable=NULL); @@ -59,6 +60,7 @@ bool isTelemetryFieldComparisonAvailable(int index); bool isSensorAvailable(int sensor); bool modelHasNotes(); +#endif #if defined(COLORLCD) bool isSwitchWarningStateAvailable(int state); @@ -70,4 +72,4 @@ bool isSwitchWarningStateAvailable(int state); #define IS_INSTANT_TRIM_ALLOWED() true #endif -#endif // _GUI_HELPERS_H_ +#endif // _GUI_COMMON_H_ diff --git a/radio/src/gui/gui_helpers.cpp b/radio/src/gui/gui_common_arm.cpp similarity index 100% rename from radio/src/gui/gui_helpers.cpp rename to radio/src/gui/gui_common_arm.cpp diff --git a/radio/src/gui/screenshot.cpp b/radio/src/gui/screenshot.cpp new file mode 100644 index 000000000..004563869 --- /dev/null +++ b/radio/src/gui/screenshot.cpp @@ -0,0 +1,76 @@ +/* + * Copyright (C) OpenTX + * + * Based on code named + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include "opentx.h" + +const uint8_t BMP_HEADER[] = { + 0x42, 0x4d, 0xF8, 0x1A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x00, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, LCD_W, 0x00, 0x00, 0x00, LCD_H, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x02, 0x04, 0x00, 0x00, 0xbc, 0x38, 0x00, 0x00, 0xbc, 0x38, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0xee, 0xee, 0xee, 0x00, 0xdd, 0xdd, + 0xdd, 0x00, 0xcc, 0xcc, 0xcc, 0x00, 0xbb, 0xbb, 0xbb, 0x00, 0xaa, 0xaa, 0xaa, 0x00, 0x99, 0x99, + 0x99, 0x00, 0x88, 0x88, 0x88, 0x00, 0x77, 0x77, 0x77, 0x00, 0x66, 0x66, 0x66, 0x00, 0x55, 0x55, + 0x55, 0x00, 0x44, 0x44, 0x44, 0x00, 0x33, 0x33, 0x33, 0x00, 0x22, 0x22, 0x22, 0x00, 0x11, 0x11, + 0x11, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + +const char * writeScreenshot() +{ + FIL bmpFile; + UINT written; + char filename[42]; // /SCREENSHOTS/screen-2013-01-01-123540.bmp + + // check and create folder here + strcpy_P(filename, SCREENSHOTS_PATH); + const char * error = sdCheckAndCreateDirectory(filename); + if (error) { + return error; + } + + char * tmp = strAppend(&filename[sizeof(SCREENSHOTS_PATH)-1], "/screen"); + tmp = strAppendDate(tmp, true); + strcpy(tmp, BMP_EXT); + + FRESULT result = f_open(&bmpFile, filename, FA_CREATE_ALWAYS | FA_WRITE); + if (result != FR_OK) { + return SDCARD_ERROR(result); + } + + result = f_write(&bmpFile, BMP_HEADER, sizeof(BMP_HEADER), &written); + if (result != FR_OK || written != sizeof(BMP_HEADER)) { + f_close(&bmpFile); + return SDCARD_ERROR(result); + } + + for (int y=LCD_H-1; y>=0; y-=1) { + for (int x=0; x<8*((LCD_W+7)/8); x+=2) { + uint8_t byte = getPixel(x+1, y) + (getPixel(x, y) << 4); + f_write(&bmpFile, &byte, 1, &written); + if (result != FR_OK || written != 1) { + f_close(&bmpFile); + return SDCARD_ERROR(result); + } + } + } + + f_close(&bmpFile); + + return NULL; +} \ No newline at end of file