clean up screenshot functions, issue #1005

This commit is contained in:
kraus 2019-10-03 10:11:52 +02:00
parent f61ef78b9d
commit 73d5224f9f
4 changed files with 31 additions and 120 deletions

View File

@ -346,9 +346,11 @@ uint8_t u8g2_UserInterfaceInputValue(u8g2_t *u8g2, const char *title, const char
int8_t getMaxCharWidth(void) { return u8g2_GetMaxCharWidth(&u8g2); }
u8g2_uint_t getHeight() { return u8g2_GetDisplayHeight(&u8g2); }
u8g2_uint_t getWidth() { return u8g2_GetDisplayWidth(&u8g2); }
};
void u8g2_print_callback(const char *s); /* U8g2lib.cpp */
class U8G2LOG : public Print
{

View File

@ -186,27 +186,28 @@ void u8g2_UpdateDisplay(u8g2_t *u8g2)
/* vertical_top memory architecture */
void u8g2_WriteBufferPBM(u8g2_t *u8g2, void (*out)(const char *s))
{
//u8x8_capture_WritePBM(u8g2_GetBufferPtr(u8g2), u8g2_GetBufferTileWidth(u8g2), u8g2_GetBufferTileHeight(u8g2), out);
u8x8_capture_write_pbm_pre(u8g2_GetBufferPtr(u8g2), u8g2_GetBufferTileWidth(u8g2), out);
u8x8_capture_write_pbm_pre(u8g2_GetBufferTileWidth(u8g2), u8g2_GetBufferTileHeight(u8g2), out);
u8x8_capture_write_pbm_buffer(u8g2_GetBufferPtr(u8g2), u8g2_GetBufferTileWidth(u8g2), u8g2_GetBufferTileHeight(u8g2), u8x8_capture_get_pixel_1, out);
}
void u8g2_WriteBufferXBM(u8g2_t *u8g2, void (*out)(const char *s))
{
u8x8_capture_WriteXBM(u8g2_GetBufferPtr(u8g2), u8g2_GetBufferTileWidth(u8g2), u8g2_GetBufferTileHeight(u8g2), out);
u8x8_capture_write_xbm_pre(u8g2_GetBufferTileWidth(u8g2), u8g2_GetBufferTileHeight(u8g2), out);
u8x8_capture_write_xbm_buffer(u8g2_GetBufferPtr(u8g2), u8g2_GetBufferTileWidth(u8g2), u8g2_GetBufferTileHeight(u8g2), u8x8_capture_get_pixel_1, out);
}
/* horizontal right memory architecture */
/* SH1122, LD7032, ST7920, ST7986, LC7981, T6963, SED1330, RA8835, MAX7219, LS0 */
void u8g2_WriteBufferPBM2(u8g2_t *u8g2, void (*out)(const char *s))
{
u8x8_capture_write_pbm_pre(u8g2_GetBufferPtr(u8g2), u8g2_GetBufferTileWidth(u8g2), out);
u8x8_capture_write_pbm_pre(u8g2_GetBufferTileWidth(u8g2), u8g2_GetBufferTileHeight(u8g2), out);
u8x8_capture_write_pbm_buffer(u8g2_GetBufferPtr(u8g2), u8g2_GetBufferTileWidth(u8g2), u8g2_GetBufferTileHeight(u8g2), u8x8_capture_get_pixel_2, out);
}
void u8g2_WriteBufferXBM2(u8g2_t *u8g2, void (*out)(const char *s))
{
u8x8_capture_WriteXBM2(u8g2_GetBufferPtr(u8g2), u8g2_GetBufferTileWidth(u8g2), u8g2_GetBufferTileHeight(u8g2), out);
u8x8_capture_write_xbm_pre(u8g2_GetBufferTileWidth(u8g2), u8g2_GetBufferTileHeight(u8g2), out);
u8x8_capture_write_xbm_buffer(u8g2_GetBufferPtr(u8g2), u8g2_GetBufferTileWidth(u8g2), u8g2_GetBufferTileHeight(u8g2), u8x8_capture_get_pixel_2, out);
}

View File

@ -1011,13 +1011,14 @@ uint8_t u8x8_capture_get_pixel_1(uint16_t x, uint16_t y, uint8_t *dest_ptr, uint
/* SH1122, LD7032, ST7920, ST7986, LC7981, T6963, SED1330, RA8835, MAX7219, LS0 */
uint8_t u8x8_capture_get_pixel_2(uint16_t x, uint16_t y, uint8_t *dest_ptr, uint8_t tile_width);
void u8x8_capture_write_pbm_pre(uint8_t tile_width, uint8_t tile_height, void (*out)(const char *s))
void u8x8_capture_write_pbm_pre(uint8_t tile_width, uint8_t tile_height, void (*out)(const char *s));
void u8x8_capture_write_pbm_buffer(uint8_t *buffer, uint8_t tile_width, uint8_t tile_height, uint8_t (*get_pixel)(uint16_t x, uint16_t y, uint8_t *dest_ptr, uint8_t tile_width), void (*out)(const char *s));
//void u8x8_capture_WritePBM(uint8_t *buffer, uint8_t tile_width, uint8_t tile_height, void (*out)(const char *s));
void u8x8_capture_WriteXBM(uint8_t *buffer, uint8_t tile_width, uint8_t tile_height, void (*out)(const char *s));
void u8x8_capture_write_xbm_pre(uint8_t tile_width, uint8_t tile_height, void (*out)(const char *s));
void u8x8_capture_write_xbm_buffer(uint8_t *buffer, uint8_t tile_width, uint8_t tile_height, uint8_t (*get_pixel)(uint16_t x, uint16_t y, uint8_t *dest_ptr, uint8_t tile_width), void (*out)(const char *s));
void u8x8_capture_WriteXBM2(uint8_t *buffer, uint8_t tile_width, uint8_t tile_height, void (*out)(const char *s));
/*==========================================*/

View File

@ -91,7 +91,6 @@ void u8x8_capture_write_pbm_buffer(uint8_t *buffer, uint8_t tile_width, uint8_t
w *= 8;
h = tile_height;
h *= 8;
for( y = 0; y < h; y++)
{
@ -106,9 +105,22 @@ void u8x8_capture_write_pbm_buffer(uint8_t *buffer, uint8_t tile_width, uint8_t
}
}
void u8x8_capture_WriteXBM(uint8_t *buffer, uint8_t tile_width, uint8_t tile_height, void (*out)(const char *s))
void u8x8_capture_write_xbm_pre(uint8_t tile_width, uint8_t tile_height, void (*out)(const char *s))
{
out("#define xbm_width ");
out(u8x8_utoa((uint16_t)tile_width*8));
out("\n");
out("#define xbm_height ");
out(u8x8_utoa((uint16_t)tile_height*8));
out("\n");
out("static unsigned char xbm_bits[] = {\n");
}
void u8x8_capture_write_xbm_buffer(uint8_t *buffer, uint8_t tile_width, uint8_t tile_height, uint8_t (*get_pixel)(uint16_t x, uint16_t y, uint8_t *dest_ptr, uint8_t tile_width), void (*out)(const char *s))
{
//u8x8_capture_t capture;
uint16_t x, y;
uint16_t w, h;
uint8_t v, b;
@ -119,19 +131,6 @@ void u8x8_capture_WriteXBM(uint8_t *buffer, uint8_t tile_width, uint8_t tile_hei
w *= 8;
h = tile_height;
h *= 8;
out("#define xbm_width ");
out(u8x8_utoa(w));
out("\n");
out("#define xbm_height ");
out(u8x8_utoa(h));
out("\n");
out("static unsigned char xbm_bits[] = {\n");
//capture.buffer = buffer;
//capture.tile_width = tile_width;
//capture.tile_height = tile_height;
y = 0;
for(;;)
@ -143,7 +142,7 @@ void u8x8_capture_WriteXBM(uint8_t *buffer, uint8_t tile_width, uint8_t tile_hei
for( b = 0; b < 8; b++ )
{
v <<= 1;
if ( u8x8_capture_get_pixel_2(x+7-b, y, buffer, tile_width) )
if ( get_pixel(x+7-b, y, buffer, tile_width) )
v |= 1;
}
out("0x");
@ -174,98 +173,6 @@ void u8x8_capture_WriteXBM(uint8_t *buffer, uint8_t tile_width, uint8_t tile_hei
}
void u8x8_capture_WritePBM2(uint8_t *buffer, uint8_t tile_width, uint8_t tile_height, void (*out)(const char *s))
{
uint16_t x, y;
uint16_t w, h;
u8x8_capture_write_pbm_pre(tile_width, tile_height, out);
w = tile_width;
w *= 8;
h = tile_height;
h *= 8;
for( y = 0; y < h; y++)
{
for( x = 0; x < w; x++)
{
if ( u8x8_capture_get_pixel_1(x, y, buffer, tile_width) )
out("1");
else
out("0");
}
out("\n");
}
}
void u8x8_capture_WriteXBM2(uint8_t *buffer, uint8_t tile_width, uint8_t tile_height, void (*out)(const char *s))
{
//u8x8_capture_t capture;
uint16_t x, y;
uint16_t w, h;
uint8_t v, b;
char s[2];
s[1] = '\0';
w = tile_width;
w *= 8;
h = tile_height;
h *= 8;
out("#define xbm_width ");
out(u8x8_utoa(w));
out("\n");
out("#define xbm_height ");
out(u8x8_utoa(h));
out("\n");
out("static unsigned char xbm_bits[] = {\n");
//capture.buffer = buffer;
//capture.tile_width = tile_width;
//capture.tile_height = tile_height;
y = 0;
for(;;)
{
x = 0;
for(;;)
{
v = 0;
for( b = 0; b < 8; b++ )
{
v <<= 1;
if ( u8x8_capture_get_pixel_2(x+7-b, y, buffer, tile_width) )
v |= 1;
}
out("0x");
s[0] = (v>>4);
if ( s[0] <= 9 )
s[0] += '0';
else
s[0] += 'a'-10;
out(s);
s[0] = (v&15);
if ( s[0] <= 9 )
s[0] += '0';
else
s[0] += 'a'-10;
out(s);
x += 8;
if ( x >= w )
break;
out(",");
}
y++;
if ( y >= h )
break;
out(",");
out("\n");
}
out("};\n");
}
/*========================================================*/