5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
23 const uint8_t BMP_HEADER
[] = {
24 0x42, 0x4d, 0xF8, 0x1A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x00, 0x00, 0x00, 0x28, 0x00,
25 0x00, 0x00, LCD_W
, 0x00, 0x00, 0x00, LCD_H
, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00,
26 0x00, 0x00, 0x02, 0x04, 0x00, 0x00, 0xbc, 0x38, 0x00, 0x00, 0xbc, 0x38, 0x00, 0x00, 0x00, 0x00,
27 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0xee, 0xee, 0xee, 0x00, 0xdd, 0xdd,
28 0xdd, 0x00, 0xcc, 0xcc, 0xcc, 0x00, 0xbb, 0xbb, 0xbb, 0x00, 0xaa, 0xaa, 0xaa, 0x00, 0x99, 0x99,
29 0x99, 0x00, 0x88, 0x88, 0x88, 0x00, 0x77, 0x77, 0x77, 0x00, 0x66, 0x66, 0x66, 0x00, 0x55, 0x55,
30 0x55, 0x00, 0x44, 0x44, 0x44, 0x00, 0x33, 0x33, 0x33, 0x00, 0x22, 0x22, 0x22, 0x00, 0x11, 0x11,
31 0x11, 0x00, 0x00, 0x00, 0x00, 0x00
34 const char * writeScreenshot()
38 char filename
[42]; // /SCREENSHOTS/screen-2013-01-01-123540.bmp
40 // check and create folder here
41 strcpy_P(filename
, SCREENSHOTS_PATH
);
42 const char * error
= sdCheckAndCreateDirectory(filename
);
47 char * tmp
= strAppend(&filename
[sizeof(SCREENSHOTS_PATH
)-1], "/screen");
48 tmp
= strAppendDate(tmp
, true);
51 FRESULT result
= f_open(&bmpFile
, filename
, FA_CREATE_ALWAYS
| FA_WRITE
);
52 if (result
!= FR_OK
) {
53 return SDCARD_ERROR(result
);
56 result
= f_write(&bmpFile
, BMP_HEADER
, sizeof(BMP_HEADER
), &written
);
57 if (result
!= FR_OK
|| written
!= sizeof(BMP_HEADER
)) {
59 return SDCARD_ERROR(result
);
62 for (int y
=LCD_H
-1; y
>=0; y
-=1) {
63 for (int x
=0; x
<8*((LCD_W
+7)/8); x
+=2) {
64 uint8_t byte
= getPixel(x
+1, y
) + (getPixel(x
, y
) << 4);
65 f_write(&bmpFile
, &byte
, 1, &written
);
66 if (result
!= FR_OK
|| written
!= 1) {
68 return SDCARD_ERROR(result
);