[Horus] Screenshots special function. Woot!
This commit is contained in:
@@ -197,8 +197,6 @@ inline display_t getPixel(uint8_t x, uint8_t y)
|
||||
return ((pixel & mask) ? 0xf : 0);
|
||||
}
|
||||
|
||||
const char * writeScreenshot();
|
||||
|
||||
uint8_t getTextWidth(const char * s, uint8_t len=0, LcdFlags flags=0);
|
||||
|
||||
#endif // _LCD_H_
|
||||
|
||||
@@ -170,7 +170,6 @@ void lcdDrawBitmap(coord_t x, coord_t y, const uint8_t * img, coord_t offset=0,
|
||||
void lcdClear();
|
||||
|
||||
uint8_t * lcdLoadBitmap(uint8_t * dest, const char * filename, uint16_t width, uint16_t height);
|
||||
const char * writeScreenshot();
|
||||
|
||||
#if defined(BOOT)
|
||||
#define BLINK_ON_PHASE (0)
|
||||
|
||||
@@ -5,6 +5,7 @@ set(SRC
|
||||
${SRC}
|
||||
gui/navigation/common.cpp
|
||||
gui/navigation/navigation_${NAVIGATION_TYPE}.cpp
|
||||
gui/screenshot.cpp
|
||||
)
|
||||
|
||||
string(TOUPPER ${NAVIGATION_TYPE} NAVIGATION_TYPE)
|
||||
|
||||
@@ -163,4 +163,6 @@ inline uint8_t MULTIMODULE_RFPROTO_COLUMNS(uint8_t moduleIdx)
|
||||
|
||||
void editStickHardwareSettings(coord_t x, coord_t y, int idx, event_t event, LcdFlags flags);
|
||||
|
||||
const char * writeScreenshot();
|
||||
|
||||
#endif // _GUI_COMMON_H_
|
||||
|
||||
@@ -20,9 +20,27 @@
|
||||
|
||||
#include "opentx.h"
|
||||
|
||||
constexpr uint16_t BMP_HEADERSIZE = 0x76;
|
||||
|
||||
#if defined(COLORLCD)
|
||||
constexpr uint8_t BMP_BITS_PER_PIXEL = 32;
|
||||
#else
|
||||
constexpr uint8_t BMP_BITS_PER_PIXEL = 4;
|
||||
#endif
|
||||
|
||||
constexpr uint32_t BMP_FILESIZE = uint32_t(BMP_HEADERSIZE + (LCD_W * LCD_H) * BMP_BITS_PER_PIXEL / 8);
|
||||
|
||||
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,
|
||||
'B', 'M',
|
||||
/* file size */ BMP_FILESIZE & 0xFF, (BMP_FILESIZE >> 8) & 0xFF, (BMP_FILESIZE >> 16) & 0xFF, (BMP_FILESIZE >> 24) & 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
/* header size */ BMP_HEADERSIZE, 0x00, 0x00, 0x00,
|
||||
/* extra header size */ 0x28, 0x00, 0x00, 0x00,
|
||||
/* width */ LCD_W & 0xFF, LCD_W >> 8, 0x00, 0x00,
|
||||
/* height */ LCD_H & 0xFF, LCD_H >> 8, 0x00, 0x00,
|
||||
/* planes */ 0x01, 0x00,
|
||||
/* depth */ BMP_BITS_PER_PIXEL, 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,
|
||||
@@ -59,18 +77,30 @@ const char * writeScreenshot()
|
||||
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) {
|
||||
#if defined(COLORLCD)
|
||||
for (int y = LCD_H - 1; y >= 0; y--) {
|
||||
for (int x = 0; x < LCD_W; x++) {
|
||||
display_t pixel = *lcd->getPixelPtr(x, y);
|
||||
uint32_t dst = (0xFF << 24) + (GET_RED(pixel) << 16) + (GET_GREEN(pixel) << 8) + (GET_BLUE(pixel) << 0);
|
||||
if (f_write(&bmpFile, &dst, sizeof(dst), &written) != FR_OK || written != sizeof(dst)) {
|
||||
f_close(&bmpFile);
|
||||
return SDCARD_ERROR(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
for (int y=LCD_H-1; y>=0; y-=1) {
|
||||
for (int x=0; x<8*((LCD_W+7)/8); x+=2) {
|
||||
display_t byte = getPixel(x+1, y) + (getPixel(x, y) << 4);
|
||||
if (f_write(&bmpFile, &byte, 1, &written) != FR_OK || written != 1) {
|
||||
f_close(&bmpFile);
|
||||
return SDCARD_ERROR(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
f_close(&bmpFile);
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user