mirror of
https://github.com/Valeh2012/PersonalVotingMachine
synced 2025-12-10 18:45:17 +02:00
first commit
This commit is contained in:
4
basic-setup/components/u8g2/sys/tga/README
Normal file
4
basic-setup/components/u8g2/sys/tga/README
Normal file
@@ -0,0 +1,4 @@
|
||||
To generate (TGA) image files using u8g2 on a regular (non-Arduino)
|
||||
system, have a look at the sys/bitmap directory, which is the
|
||||
recommended way to approach this. This sys/tga directory is mostly kept
|
||||
around for compatibility and to generate u8g2 manual images.
|
||||
416
basic-setup/components/u8g2/sys/tga/common/u8x8_d_tga.c
Normal file
416
basic-setup/components/u8g2/sys/tga/common/u8x8_d_tga.c
Normal file
@@ -0,0 +1,416 @@
|
||||
|
||||
#include "u8g2.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define FACTOR 3
|
||||
#define XOFFSET (FACTOR*64)
|
||||
#define YOFFSET (FACTOR*32)
|
||||
#define DEFAULT_WIDTH (FACTOR*128)
|
||||
#define DEFAULT_HEIGHT (FACTOR*64)
|
||||
|
||||
|
||||
uint16_t tga_max_x;
|
||||
uint16_t tga_max_y;
|
||||
|
||||
static uint16_t tga_width;
|
||||
static uint16_t tga_height;
|
||||
static uint8_t *tga_data = NULL;
|
||||
|
||||
uint8_t tga_is_transparent = 0;
|
||||
|
||||
uint8_t tga_fg_r = 0;
|
||||
uint8_t tga_fg_g = 0;
|
||||
uint8_t tga_fg_b = 0;
|
||||
|
||||
uint8_t tga_bg_r = 255;
|
||||
uint8_t tga_bg_g = 255;
|
||||
uint8_t tga_bg_b = 255;
|
||||
|
||||
uint8_t tga_desc_fg_r = 0;
|
||||
uint8_t tga_desc_fg_g = 0;
|
||||
uint8_t tga_desc_fg_b = 255;
|
||||
|
||||
uint8_t tga_desc_bg_r = 0;
|
||||
uint8_t tga_desc_bg_g = 0;
|
||||
uint8_t tga_desc_bg_b = 0;
|
||||
|
||||
uint8_t tga_lcd_fg_r = 0;
|
||||
uint8_t tga_lcd_fg_g = 0;
|
||||
uint8_t tga_lcd_fg_b = 0;
|
||||
|
||||
uint8_t tga_lcd_bg_r = 255;
|
||||
uint8_t tga_lcd_bg_g = 255;
|
||||
uint8_t tga_lcd_bg_b = 255;
|
||||
|
||||
int tga_init(uint16_t w, uint16_t h)
|
||||
{
|
||||
tga_max_x = 0;
|
||||
tga_max_y = 0;
|
||||
tga_width = 0;
|
||||
tga_height = 0;
|
||||
if ( tga_data != NULL )
|
||||
free(tga_data);
|
||||
tga_data = (uint8_t *)malloc(w*h*3);
|
||||
if ( tga_data == NULL )
|
||||
return 0;
|
||||
tga_width = w;
|
||||
tga_height = h;
|
||||
memset(tga_data, 255, tga_width*tga_height*3);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void tga_set_pixel(uint16_t x, uint16_t y, uint16_t f)
|
||||
{
|
||||
uint8_t *p;
|
||||
uint16_t xx,yy;
|
||||
for( yy = y; yy < y+f; yy++ )
|
||||
{
|
||||
for( xx = x; xx < x+f; xx++ )
|
||||
{
|
||||
if ( yy < tga_height && xx < tga_width )
|
||||
{
|
||||
//printf ("(%d %d) ", xx, yy);
|
||||
p = tga_data + (tga_height-yy-1)*tga_width*3 + xx*3;
|
||||
*p++ = tga_fg_b;
|
||||
*p++ = tga_fg_g;
|
||||
*p++ = tga_fg_r;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void tga_clr_pixel(uint16_t x, uint16_t y, uint16_t f)
|
||||
{
|
||||
uint8_t *p;
|
||||
uint16_t xx,yy;
|
||||
if ( tga_is_transparent )
|
||||
return;
|
||||
for( yy = y; yy < y+f; yy++ )
|
||||
{
|
||||
for( xx = x; xx < x+f; xx++ )
|
||||
{
|
||||
|
||||
p = tga_data + (tga_height-yy-1)*tga_width*3 + xx*3;
|
||||
*p++ = tga_bg_b;
|
||||
*p++ = tga_bg_g;
|
||||
*p++ = tga_bg_r;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void tga_set_8pixel(int x, int y, uint8_t pixel, uint16_t f)
|
||||
{
|
||||
int cnt = 8;
|
||||
while( cnt > 0 )
|
||||
{
|
||||
if ( (pixel & 1) != 0 )
|
||||
{
|
||||
tga_set_pixel(x,y, f);
|
||||
}
|
||||
else
|
||||
{
|
||||
tga_clr_pixel(x,y, f);
|
||||
}
|
||||
pixel >>= 1;
|
||||
y+=f;
|
||||
cnt--;
|
||||
}
|
||||
}
|
||||
|
||||
void tga_set_multiple_8pixel(int x, int y, int cnt, uint8_t *pixel, uint16_t f)
|
||||
{
|
||||
uint8_t b;
|
||||
while( cnt > 0 )
|
||||
{
|
||||
b = *pixel;
|
||||
tga_set_8pixel(x, y, b, f);
|
||||
x+=f;
|
||||
pixel++;
|
||||
cnt--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void tga_write_byte(FILE *fp, uint8_t byte)
|
||||
{
|
||||
fputc(byte, fp);
|
||||
}
|
||||
|
||||
void tga_write_word(FILE *fp, uint16_t word)
|
||||
{
|
||||
tga_write_byte(fp, word&255);
|
||||
tga_write_byte(fp, word>>8);
|
||||
}
|
||||
|
||||
void tga_save(const char *name)
|
||||
{
|
||||
FILE *fp;
|
||||
if ( tga_data == NULL )
|
||||
return;
|
||||
|
||||
printf("tga_save: File %s with %dx%d pixel\n", name, tga_width, tga_height);
|
||||
|
||||
fp = fopen(name, "wb");
|
||||
if ( fp != NULL )
|
||||
{
|
||||
tga_write_byte(fp, 0); /* no ID */
|
||||
tga_write_byte(fp, 0); /* no color map */
|
||||
tga_write_byte(fp, 2); /* uncompressed true color */
|
||||
tga_write_word(fp, 0);
|
||||
tga_write_word(fp, 0);
|
||||
tga_write_byte(fp, 0);
|
||||
tga_write_word(fp, 0); /* x origin */
|
||||
tga_write_word(fp, 0); /* y origin */
|
||||
tga_write_word(fp, tga_width); /* width */
|
||||
tga_write_word(fp, tga_height); /* height */
|
||||
tga_write_byte(fp, 24); /* color depth */
|
||||
tga_write_byte(fp, 0);
|
||||
fwrite(tga_data, tga_width*tga_height*3, 1, fp);
|
||||
tga_write_word(fp, 0);
|
||||
tga_write_word(fp, 0);
|
||||
tga_write_word(fp, 0);
|
||||
tga_write_word(fp, 0);
|
||||
fwrite("TRUEVISION-XFILE.", 18, 1, fp);
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
void tga_save_png(const char *name)
|
||||
{
|
||||
char convert_cmd[1024*2];
|
||||
tga_save("tmp.tga");
|
||||
sprintf(convert_cmd, "convert tmp.tga -trim %s", name );
|
||||
system(convert_cmd);
|
||||
}
|
||||
|
||||
/*==========================================*/
|
||||
/* tga description procedures */
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_tga_desc_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 0,
|
||||
/* pre_chip_disable_wait_ns = */ 0,
|
||||
/* reset_pulse_width_ms = */ 0,
|
||||
/* post_reset_wait_ms = */ 0,
|
||||
/* sda_setup_time_ns = */ 0,
|
||||
/* sck_pulse_width_ns = */ 0,
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 1,
|
||||
/* i2c_bus_clock_100kHz = */ 0,
|
||||
/* data_setup_time_ns = */ 0,
|
||||
/* write_pulse_width_ns = */ 0,
|
||||
/* tile_width = */ (2*XOFFSET+DEFAULT_WIDTH)/8,
|
||||
/* tile_hight = */ (2*YOFFSET+DEFAULT_HEIGHT)/8,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ (2*XOFFSET+DEFAULT_WIDTH),
|
||||
/* pixel_height = */ (2*YOFFSET+DEFAULT_HEIGHT)
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8x8_d_tga_desc(u8x8_t *u8g2, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
u8g2_uint_t x, y, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8g2, &u8x8_tga_desc_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8g2);
|
||||
if ( tga_data == NULL )
|
||||
tga_init(2*XOFFSET+DEFAULT_WIDTH, 2*YOFFSET+DEFAULT_HEIGHT);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
|
||||
tga_fg_r = tga_desc_fg_r;
|
||||
tga_fg_g = tga_desc_fg_g;
|
||||
tga_fg_b = tga_desc_fg_b;
|
||||
|
||||
tga_bg_r = tga_desc_bg_r;
|
||||
tga_bg_g = tga_desc_bg_g;
|
||||
tga_bg_b = tga_desc_bg_b;
|
||||
|
||||
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
//printf("U8X8_MSG_DISPLAY_DRAW_TILE x=%d, ", x);
|
||||
x *= 8;
|
||||
x += u8g2->x_offset;
|
||||
|
||||
y = ((u8x8_tile_t *)arg_ptr)->y_pos;
|
||||
//printf("y=%d, c=%d\n", y, ((u8x8_tile_t *)arg_ptr)->cnt);
|
||||
y *= 8;
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
tga_set_multiple_8pixel(x, y, c*8, ptr, 1);
|
||||
arg_int--;
|
||||
x += c*8;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void u8x8_Setup_TGA_DESC(u8x8_t *u8x8)
|
||||
{
|
||||
/* setup defaults */
|
||||
u8x8_SetupDefaults(u8x8);
|
||||
|
||||
/* setup specific callbacks */
|
||||
u8x8->display_cb = u8x8_d_tga_desc;
|
||||
|
||||
/* setup display info */
|
||||
u8x8_SetupMemory(u8x8);
|
||||
}
|
||||
|
||||
void u8g2_SetupBuffer_TGA_DESC(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb)
|
||||
{
|
||||
static uint8_t buf[(XOFFSET+DEFAULT_WIDTH)*8];
|
||||
|
||||
u8x8_Setup_TGA_DESC(u8g2_GetU8x8(u8g2));
|
||||
u8g2_SetupBuffer(u8g2, buf, 1, u8g2_ll_hvline_vertical_top_lsb, u8g2_cb);
|
||||
}
|
||||
|
||||
/*==========================================*/
|
||||
/* tga LCD procedures */
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_tga_lcd_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 0,
|
||||
/* pre_chip_disable_wait_ns = */ 0,
|
||||
/* reset_pulse_width_ms = */ 0,
|
||||
/* post_reset_wait_ms = */ 0,
|
||||
/* sda_setup_time_ns = */ 0,
|
||||
/* sck_pulse_width_ns = */ 0,
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 1,
|
||||
/* i2c_bus_clock_100kHz = */ 0,
|
||||
/* data_setup_time_ns = */ 0,
|
||||
/* write_pulse_width_ns = */ 0,
|
||||
/* tile_width = */ (DEFAULT_WIDTH)/FACTOR/8,
|
||||
/* tile_hight = */ (DEFAULT_HEIGHT)/FACTOR/8,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ (DEFAULT_WIDTH)/FACTOR,
|
||||
/* pixel_height = */ (DEFAULT_HEIGHT)/FACTOR
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8x8_d_tga_lcd(u8x8_t *u8g2, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
u8g2_uint_t x, y, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8g2, &u8x8_tga_lcd_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8g2);
|
||||
if ( tga_data == NULL )
|
||||
tga_init(2*XOFFSET+DEFAULT_WIDTH, 2*YOFFSET+DEFAULT_HEIGHT);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
|
||||
tga_fg_r = tga_lcd_fg_r;
|
||||
tga_fg_g = tga_lcd_fg_g;
|
||||
tga_fg_b = tga_lcd_fg_b;
|
||||
|
||||
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
//printf("U8X8_MSG_DISPLAY_DRAW_TILE x=%d, ", x);
|
||||
x *= 8;
|
||||
x += u8g2->x_offset;
|
||||
x *= FACTOR;
|
||||
x += XOFFSET;
|
||||
|
||||
y = ((u8x8_tile_t *)arg_ptr)->y_pos;
|
||||
//printf("y=%d, c=%d\n", y, ((u8x8_tile_t *)arg_ptr)->cnt);
|
||||
y *= 8;
|
||||
y *= FACTOR;
|
||||
y += YOFFSET;
|
||||
|
||||
do
|
||||
{
|
||||
|
||||
if ( (x/8+y/8) & 1 )
|
||||
{
|
||||
tga_bg_r = tga_lcd_bg_r;
|
||||
tga_bg_g = tga_lcd_bg_g;
|
||||
tga_bg_b = tga_lcd_bg_b;
|
||||
}
|
||||
else
|
||||
{
|
||||
tga_bg_r = (tga_lcd_bg_r*10)/11;
|
||||
tga_bg_g = (tga_lcd_bg_g*10)/11;
|
||||
tga_bg_b = (tga_lcd_bg_b*10)/11;
|
||||
}
|
||||
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
tga_set_multiple_8pixel(x, y, c*8, ptr, FACTOR);
|
||||
arg_int--;
|
||||
x += c*8*FACTOR;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void u8x8_Setup_TGA_LCD(u8x8_t *u8x8)
|
||||
{
|
||||
/* setup defaults */
|
||||
u8x8_SetupDefaults(u8x8);
|
||||
|
||||
/* setup specific callbacks */
|
||||
u8x8->display_cb = u8x8_d_tga_lcd;
|
||||
|
||||
/* setup display info */
|
||||
u8x8_SetupMemory(u8x8);
|
||||
}
|
||||
|
||||
void u8g2_SetupBuffer_TGA_LCD(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb)
|
||||
{
|
||||
static uint8_t buf[(DEFAULT_WIDTH/FACTOR)*8];
|
||||
|
||||
u8x8_Setup_TGA_LCD(u8g2_GetU8x8(u8g2));
|
||||
u8g2_SetupBuffer(u8g2, buf, 1, u8g2_ll_hvline_vertical_top_lsb, u8g2_cb);
|
||||
}
|
||||
|
||||
|
||||
|
||||
12
basic-setup/components/u8g2/sys/tga/example/Makefile
Normal file
12
basic-setup/components/u8g2/sys/tga/example/Makefile
Normal file
@@ -0,0 +1,12 @@
|
||||
CFLAGS = -g -Wall -I../../../csrc/. `sdl2-config --cflags` -DU8G2_16BIT
|
||||
|
||||
SRC = $(shell ls ../../../csrc/*.c) $(shell ls ../common/*.c ) main.c
|
||||
|
||||
OBJ = $(SRC:.c=.o)
|
||||
|
||||
u8g2_tga: $(OBJ)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) `sdl2-config --libs` -o u8g2_tga
|
||||
|
||||
clean:
|
||||
-rm $(OBJ) u8g2_tga
|
||||
|
||||
125
basic-setup/components/u8g2/sys/tga/example/main.c
Normal file
125
basic-setup/components/u8g2/sys/tga/example/main.c
Normal file
@@ -0,0 +1,125 @@
|
||||
|
||||
#include "u8g2.h"
|
||||
#include <stdio.h>
|
||||
|
||||
const uint8_t bdf_font[762] U8X8_FONT_SECTION("bdf_font") = {
|
||||
32,126,0,0,0,0,0,0,0,0,0,0,0,95,95,0,
|
||||
0,0,0,7,7,0,7,7,0,0,20,127,127,28,127,127,
|
||||
20,0,0,36,42,127,127,42,18,0,70,102,48,24,12,102,
|
||||
98,0,48,122,79,93,55,122,72,0,0,0,0,7,7,0,
|
||||
0,0,0,0,28,62,99,65,0,0,0,0,65,99,62,28,
|
||||
0,0,0,0,0,0,0,0,0,0,0,8,8,62,62,8,
|
||||
8,0,0,0,128,224,96,0,0,0,0,8,8,8,8,8,
|
||||
8,0,0,0,0,96,96,0,0,0,96,48,24,12,6,3,
|
||||
1,0,62,127,81,73,69,127,62,0,0,64,66,127,127,64,
|
||||
64,0,0,114,123,73,73,111,102,0,0,34,97,73,73,127,
|
||||
54,0,24,20,82,127,127,80,16,0,0,39,111,73,73,121,
|
||||
51,0,0,62,127,73,73,123,50,0,0,3,1,113,125,15,
|
||||
7,0,0,54,127,73,73,127,54,0,0,38,111,73,73,127,
|
||||
62,0,0,0,0,108,108,0,0,0,0,0,128,236,108,0,
|
||||
0,0,0,8,28,54,99,65,0,0,0,36,36,36,36,36,
|
||||
36,0,0,65,99,54,28,8,0,0,0,2,3,81,89,15,
|
||||
6,0,62,127,65,93,93,95,30,0,0,124,126,19,19,126,
|
||||
124,0,65,127,127,73,73,127,54,0,28,62,99,65,65,99,
|
||||
34,0,65,127,127,65,99,62,28,0,65,127,127,73,93,65,
|
||||
99,0,65,127,127,73,29,1,3,0,60,126,67,65,81,115,
|
||||
114,0,0,127,127,8,8,127,127,0,0,65,65,127,127,65,
|
||||
65,0,48,112,64,65,127,63,1,0,65,127,127,8,28,119,
|
||||
99,0,65,127,127,65,64,96,112,0,127,127,14,28,14,127,
|
||||
127,0,127,127,6,12,24,127,127,0,28,62,99,65,99,62,
|
||||
28,0,65,127,127,73,9,7,6,0,60,126,67,81,51,110,
|
||||
92,0,65,127,127,9,25,63,102,0,0,38,111,73,73,123,
|
||||
50,0,0,3,65,127,127,65,3,0,0,63,127,64,64,127,
|
||||
63,0,0,31,63,96,96,63,31,0,127,127,48,24,48,127,
|
||||
127,0,97,115,30,12,30,115,97,0,0,7,79,120,120,79,
|
||||
7,0,71,99,113,89,77,103,115,0,0,0,127,127,65,65,
|
||||
0,0,1,3,6,12,24,48,96,0,0,0,65,65,127,127,
|
||||
0,0,8,12,6,3,6,12,8,0,0,0,0,0,0,0,
|
||||
0,0,0,0,2,6,12,8,0,0,32,116,84,84,60,120,
|
||||
64,0,67,63,127,68,68,124,56,0,0,56,124,68,68,108,
|
||||
40,0,56,124,68,69,63,127,64,0,0,56,124,84,84,92,
|
||||
24,0,0,72,126,127,73,3,2,0,0,152,188,164,164,252,
|
||||
124,0,65,127,127,8,4,124,120,0,0,0,68,125,125,64,
|
||||
0,0,0,96,224,128,132,252,125,0,65,127,127,16,56,108,
|
||||
68,0,0,0,65,127,127,64,0,0,120,124,12,56,12,124,
|
||||
120,0,4,124,120,4,4,120,120,0,0,56,124,68,68,124,
|
||||
56,0,132,252,248,164,36,60,24,0,24,60,36,164,248,252,
|
||||
132,0,68,124,120,68,12,8,0,0,0,72,92,84,84,116,
|
||||
32,0,0,4,63,127,68,100,32,0,0,60,124,64,64,124,
|
||||
124,0,0,28,60,96,96,60,28,0,60,124,96,56,96,124,
|
||||
60,0,68,108,56,16,56,108,68,0,0,156,188,160,160,252,
|
||||
124,0,0,76,100,116,92,76,68,0,0,65,65,119,62,8,
|
||||
8,0,0,0,0,127,127,0,0,0,0,8,8,62,119,65,
|
||||
65,0,2,3,1,3,2,1,1,0};
|
||||
|
||||
|
||||
u8g2_t u8g2;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int x, y;
|
||||
int k;
|
||||
int i;
|
||||
|
||||
u8g2_SetupBuffer_TGA_LCD(&u8g2, &u8g2_cb_r0);
|
||||
u8x8_InitDisplay(u8g2_GetU8x8(&u8g2));
|
||||
u8x8_SetPowerSave(u8g2_GetU8x8(&u8g2), 0);
|
||||
u8g2_SetFont(&u8g2, u8g2_font_helvB18_tr);
|
||||
|
||||
x = 50;
|
||||
y = 30+0;
|
||||
|
||||
|
||||
#ifdef U8G2_WITH_HVLINE_COUNT
|
||||
u8g2.hv_cnt = 0UL;
|
||||
#endif /* U8G2_WITH_HVLINE_COUNT */
|
||||
|
||||
/*
|
||||
u8g2_ClearBuffer(&u8g2);
|
||||
|
||||
u8g2_SetFontDirection(&u8g2, 0);
|
||||
u8g2_DrawStr(&u8g2, x, y, "ABC");
|
||||
u8g2_SetFontDirection(&u8g2, 1);
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
u8g2_SetFontDirection(&u8g2, 2);
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
u8g2_SetFontDirection(&u8g2, 3);
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
|
||||
u8g2_SendBuffer(&u8g2);
|
||||
*/
|
||||
|
||||
u8g2_FirstPage(&u8g2);
|
||||
i = 0;
|
||||
do
|
||||
{
|
||||
u8g2_SetFontDirection(&u8g2, 0);
|
||||
u8g2_DrawStr(&u8g2, x, y, "ABC");
|
||||
u8g2_SetFontDirection(&u8g2, 1);
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
u8g2_SetFontDirection(&u8g2, 2);
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
u8g2_SetFontDirection(&u8g2, 3);
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
if ( i == 1 )
|
||||
{
|
||||
u8g2_DrawHVLine(&u8g2, u8g2.user_x0, u8g2.user_y0, 1, 0);
|
||||
u8g2_DrawHVLine(&u8g2, u8g2.user_x0, u8g2.user_y1-1, 1, 0);
|
||||
u8g2_DrawHVLine(&u8g2, u8g2.user_x1-1, u8g2.user_y1-1, 1, 0);
|
||||
u8g2_DrawHVLine(&u8g2, u8g2.user_x1-1, u8g2.user_y0, 1, 0);
|
||||
|
||||
}
|
||||
|
||||
i++;
|
||||
|
||||
|
||||
} while( u8g2_NextPage(&u8g2) );
|
||||
#ifdef U8G2_WITH_HVLINE_COUNT
|
||||
printf("hv cnt: %ld\n", u8g2.hv_cnt);
|
||||
#endif /* U8G2_WITH_HVLINE_COUNT */
|
||||
|
||||
tga_save("u8g2.tga");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
12
basic-setup/components/u8g2/sys/tga/hello_world_8x8/Makefile
Normal file
12
basic-setup/components/u8g2/sys/tga/hello_world_8x8/Makefile
Normal file
@@ -0,0 +1,12 @@
|
||||
CFLAGS = -g -Wall -I../../../csrc/. `sdl2-config --cflags` -DU8G2_16BIT
|
||||
|
||||
SRC = $(shell ls ../../../csrc/*.c) $(shell ls ../common/*.c ) main.c
|
||||
|
||||
OBJ = $(SRC:.c=.o)
|
||||
|
||||
u8g2_tga: $(OBJ)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) `sdl2-config --libs` -o u8g2_tga
|
||||
|
||||
clean:
|
||||
-rm $(OBJ) u8g2_tga
|
||||
|
||||
19
basic-setup/components/u8g2/sys/tga/hello_world_8x8/main.c
Normal file
19
basic-setup/components/u8g2/sys/tga/hello_world_8x8/main.c
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
#include "u8x8.h"
|
||||
|
||||
u8x8_t u8x8;
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
u8x8_Setup_TGA_DESC(&u8x8);
|
||||
u8x8_InitDisplay(&u8x8);
|
||||
u8x8_SetPowerSave(&u8x8, 0);
|
||||
|
||||
u8x8_SetFont(&u8x8, u8x8_font_amstrad_cpc_extended_r );
|
||||
u8x8_DrawString(&u8x8, 0, 0, "Hello World!");
|
||||
|
||||
tga_save("u8x8.tga");
|
||||
return 0;
|
||||
}
|
||||
|
||||
19
basic-setup/components/u8g2/sys/tga/mapgen/Makefile
Normal file
19
basic-setup/components/u8g2/sys/tga/mapgen/Makefile
Normal file
@@ -0,0 +1,19 @@
|
||||
CFLAGS = -g -Wall -I../../../csrc/. -I../../../tools/ugl/. -DU8G2_16BIT -DUGL_TEST
|
||||
|
||||
SRC = $(shell ls ../../../csrc/*.c) mapgen.c u8g2_d_tga.c
|
||||
SRC += ../../../tools/ugl/ugl_arrays.c
|
||||
SRC += ../../../tools/ugl/ugl_error.c
|
||||
SRC += ../../../tools/ugl/ugl_parse.c
|
||||
SRC += ../../../tools/ugl/ugl_bc.c
|
||||
|
||||
OBJ = $(SRC:.c=.o)
|
||||
|
||||
map.c: mapgen gm.map
|
||||
./mapgen -o map.c gm.map
|
||||
|
||||
mapgen: $(OBJ)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) -o mapgen
|
||||
|
||||
clean:
|
||||
-rm $(OBJ) mapgen map.c
|
||||
|
||||
204
basic-setup/components/u8g2/sys/tga/mapgen/gm.map
Normal file
204
basic-setup/components/u8g2/sys/tga/mapgen/gm.map
Normal file
@@ -0,0 +1,204 @@
|
||||
#
|
||||
# gm.map
|
||||
#
|
||||
# Syntax:
|
||||
# 'hash' introduces a comment
|
||||
# tile <ascii> <mapto> <top> <right> <bottom> <left>
|
||||
# map the <ascii> code to the specified <mapto> code, if the other for tiles match
|
||||
# If one of the other four tiles is 0, then ignore this tile (wildcard)
|
||||
# thing ... same as tile, but can be redefined at any time, should redefine to char
|
||||
# itemkey <iname> <ascii> <bg-tile> ... similar thing, but will connect to an item and assign the <backgroundmapto> instead
|
||||
#
|
||||
# summery:
|
||||
# tile: static fixed thing for all maps
|
||||
# thing: static thing for some maps
|
||||
# itemkey: dynamic objects like changing doors, boxes or monsters
|
||||
#
|
||||
# item <iname> <foregroundmapto>
|
||||
# defines a global template for an object.
|
||||
# anyting on the map, which might disappear, move or change has to be an item
|
||||
# itemuse <iname> <ascii>
|
||||
# only within active map. <mapto> will be the background tile for the char
|
||||
# the current foreground tile might still be differrent and is set during iteminit
|
||||
# connects the ascii char with the given ascii char on the map to get the xy pos.
|
||||
# iteminit <iname>
|
||||
# <procedure>
|
||||
# endproc
|
||||
# procedure, which is called, when the item is created,
|
||||
# receives position, where it should be created on the map
|
||||
# itemhit <iname>
|
||||
# procedure, which is called, when the item is hit by something
|
||||
# - returns 0 if the item hitting item has to be stopped
|
||||
# - may move itself
|
||||
# - may change its own shape (tile)
|
||||
# - may modify its status
|
||||
# endproc
|
||||
#
|
||||
# example "normal door, status=closed"
|
||||
# 1. hit: status=open, change tile to open door, return 0
|
||||
# 2. hit: return 1 (hero can pass)
|
||||
# example "creature, status=5 life"
|
||||
# 1. hit: get hitting obj attac damage, reduce life --> status=2, apply attack damage hitting object, return 0
|
||||
# 2. hit: get hitting obj attac damage, reduce life --> status=0, remove object from map, return 0
|
||||
# 3. hero can continue
|
||||
#
|
||||
# itemstep <iname>
|
||||
# executed every step
|
||||
# - moving items can move towards hero or others
|
||||
# endproc
|
||||
# mapinit
|
||||
# executed during map init
|
||||
# endproc
|
||||
#
|
||||
#
|
||||
# map <name> <width> <height>
|
||||
# Create a map with the given name and size. this must be followed by :
|
||||
# endmap
|
||||
# Finish the current map
|
||||
#
|
||||
tile 32 32 # map space to space
|
||||
tile '+ $80 0 '- '| 0
|
||||
tile '+ $80 0 '- '+ 0
|
||||
tile '+ $80 0 '+ '| 0
|
||||
tile '+ $80 0 '+ '+ 0
|
||||
|
||||
tile '+ $81 0 0 '| '-
|
||||
tile '+ $81 0 0 '+ '-
|
||||
tile '+ $81 0 0 '| '+
|
||||
tile '+ $81 0 0 '+ '+
|
||||
|
||||
tile '+ $82 '| '- 0 0
|
||||
tile '+ $82 '+ '- 0 0
|
||||
tile '+ $82 '| '+ 0 0
|
||||
tile '+ $82 '+ '+ 0 0
|
||||
|
||||
tile '+ $83 '| 0 0 '-
|
||||
tile '+ $83 '+ 0 0 '-
|
||||
tile '+ $83 '| 0 0 '+
|
||||
tile '+ $83 '+ 0 0 '+
|
||||
|
||||
tile '+ $84 '| '- '| 0
|
||||
tile '+ $84 '+ '- '| 0
|
||||
tile '+ $84 '| '+ '| 0
|
||||
tile '+ $84 '+ '+ '| 0
|
||||
tile '+ $84 '| '- '+ 0
|
||||
tile '+ $84 '+ '- '+ 0
|
||||
tile '+ $84 '| '+ '+ 0
|
||||
tile '+ $84 '+ '+ '+ 0
|
||||
|
||||
|
||||
tile '+ $85 '| 0 '| '-
|
||||
tile '+ $85 '+ 0 '| '-
|
||||
tile '+ $85 '| 0 '+ '-
|
||||
tile '+ $85 '+ 0 '+ '-
|
||||
tile '+ $85 '| 0 '| '+
|
||||
tile '+ $85 '+ 0 '| '+
|
||||
tile '+ $85 '| 0 '+ '+
|
||||
tile '+ $85 '+ 0 '+ '+
|
||||
|
||||
tile '+ $86 0 '- '| '-
|
||||
tile '+ $86 0 '+ '| '-
|
||||
tile '+ $86 0 '- '+ '-
|
||||
tile '+ $86 0 '+ '+ '-
|
||||
tile '+ $86 0 '- '| '+
|
||||
tile '+ $86 0 '+ '| '+
|
||||
tile '+ $86 0 '- '+ '+
|
||||
tile '+ $86 0 '+ '+ '+
|
||||
|
||||
tile '+ $87 '| '- 0 '-
|
||||
tile '+ $87 '+ '- 0 '-
|
||||
tile '+ $87 '| '+ 0 '-
|
||||
tile '+ $87 '+ '+ 0 '-
|
||||
tile '+ $87 '| '- 0 '+
|
||||
tile '+ $87 '+ '- 0 '+
|
||||
tile '+ $87 '| '+ 0 '+
|
||||
tile '+ $87 '+ '+ 0 '+
|
||||
|
||||
tile '+ $88 '| '- '| '-
|
||||
tile '+ $88 '+ '- '| '-
|
||||
tile '+ $88 '| '+ '| '-
|
||||
tile '+ $88 '+ '+ '| '-
|
||||
tile '+ $88 '| '- '+ '-
|
||||
tile '+ $88 '+ '- '+ '-
|
||||
tile '+ $88 '| '+ '+ '-
|
||||
tile '+ $88 '+ '+ '+ '-
|
||||
tile '+ $88 '| '- '| '+
|
||||
tile '+ $88 '+ '- '| '+
|
||||
tile '+ $88 '| '+ '| '+
|
||||
tile '+ $88 '+ '+ '| '+
|
||||
tile '+ $88 '| '- '+ '+
|
||||
tile '+ $88 '+ '- '+ '+
|
||||
tile '+ $88 '| '+ '+ '+
|
||||
tile '+ $88 '+ '+ '+ '+
|
||||
|
||||
|
||||
tile '| $7e 0 0 '| 0
|
||||
tile '| $7e 0 0 '+ 0
|
||||
tile '| $7f 0 0 0 0
|
||||
tile '- $7d 0 0 0 0
|
||||
|
||||
tile '. $6a # stone 2
|
||||
tile ': $6b # stone 3
|
||||
|
||||
thing 'f $74 # fire
|
||||
thing '^ $73 # door open
|
||||
thing 'C $79 # cupboard
|
||||
thing 'S $7a # bookshelf
|
||||
thing 'c $78 # chair
|
||||
thing 't $7b # table
|
||||
thing 'T $7c # throne
|
||||
thing 'h $9c # chest
|
||||
|
||||
thing 'H $92 # hut
|
||||
thing 'K $93 # kingdom
|
||||
|
||||
item normal_door $72 # $72 = door closed --> inital tile
|
||||
itemkey normal_door 'x $73 # $73 = door open --> this will be placed on the map, the item can destroy itself, but this tile will stay
|
||||
|
||||
iteminit normal_door
|
||||
print(add(1,2))
|
||||
print(add(3,4))
|
||||
print(add(1234,5678))
|
||||
endproc
|
||||
|
||||
itemhit normal_door
|
||||
endproc
|
||||
|
||||
itemstep normal_door
|
||||
endproc
|
||||
|
||||
|
||||
|
||||
map test 20 9
|
||||
mapinit
|
||||
setPos(3,2)
|
||||
setItemPos(0)
|
||||
|
||||
endproc
|
||||
|
||||
: K H
|
||||
: . .
|
||||
: ...........
|
||||
: . .
|
||||
:+-----^--x--C--S---+
|
||||
:| T f|
|
||||
:|ctc h |
|
||||
:| c |
|
||||
:+-----^-----x------+
|
||||
|
||||
endmap
|
||||
|
||||
thing 'S $54 # Spider
|
||||
thing 'k $a0 # key
|
||||
map first 12 12
|
||||
:+---+ +---+
|
||||
:| | | |
|
||||
:+-+ +--+ | |
|
||||
: | +-+ |
|
||||
: | | |
|
||||
: | |
|
||||
: +-+ -----+
|
||||
: | Sk|
|
||||
: +------+
|
||||
endmap
|
||||
|
||||
43
basic-setup/components/u8g2/sys/tga/mapgen/map.h
Normal file
43
basic-setup/components/u8g2/sys/tga/mapgen/map.h
Normal file
@@ -0,0 +1,43 @@
|
||||
|
||||
|
||||
|
||||
#ifndef _MAP_H
|
||||
#define _MAP_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
struct _item_onmap_struct
|
||||
{
|
||||
uint8_t x;
|
||||
uint8_t y;
|
||||
uint8_t template_index;
|
||||
uint8_t option;
|
||||
};
|
||||
typedef struct _item_onmap_struct item_onmap_t;
|
||||
|
||||
struct _map_struct
|
||||
{
|
||||
unsigned char *data;
|
||||
item_onmap_t *onmap_list;
|
||||
uint16_t init_proc;
|
||||
uint8_t onmap_cnt;
|
||||
uint8_t width;
|
||||
uint8_t height;
|
||||
};
|
||||
typedef struct _map_struct map_t;
|
||||
|
||||
struct _item_template_struct
|
||||
{
|
||||
uint16_t init_proc;
|
||||
uint16_t hit_proc;
|
||||
uint16_t step_proc;
|
||||
uint8_t fg_tile; /* for tga output and inital tile */
|
||||
};
|
||||
typedef struct _item_template_struct item_template_t;
|
||||
|
||||
extern unsigned char map_code[] ;
|
||||
extern item_template_t item_template_list[];
|
||||
extern map_t map_list[];
|
||||
|
||||
#endif
|
||||
1097
basic-setup/components/u8g2/sys/tga/mapgen/mapgen.c
Normal file
1097
basic-setup/components/u8g2/sys/tga/mapgen/mapgen.c
Normal file
File diff suppressed because it is too large
Load Diff
271
basic-setup/components/u8g2/sys/tga/mapgen/u8g2_d_tga.c
Normal file
271
basic-setup/components/u8g2/sys/tga/mapgen/u8g2_d_tga.c
Normal file
@@ -0,0 +1,271 @@
|
||||
|
||||
#include "u8g2.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
//#define FACTOR 3
|
||||
//#define XOFFSET (FACTOR*32)
|
||||
//#define YOFFSET (FACTOR*32)
|
||||
#define DEFAULT_WIDTH (512+512)
|
||||
#define DEFAULT_HEIGHT (1024+512+256)
|
||||
|
||||
|
||||
uint16_t tga_max_x;
|
||||
uint16_t tga_max_y;
|
||||
size_t tga_max_offset = 0;
|
||||
|
||||
static uint16_t tga_width;
|
||||
static uint16_t tga_height;
|
||||
static uint8_t *tga_data = NULL;
|
||||
uint8_t tga_r = 0;
|
||||
uint8_t tga_g = 0;
|
||||
uint8_t tga_b = 0;
|
||||
|
||||
uint8_t tga_desc_r = 0;
|
||||
uint8_t tga_desc_g = 0;
|
||||
uint8_t tga_desc_b = 0;
|
||||
|
||||
int tga_init(uint16_t w, uint16_t h)
|
||||
{
|
||||
tga_max_x = 0;
|
||||
tga_max_y = 0;
|
||||
tga_width = 0;
|
||||
tga_height = 0;
|
||||
tga_max_offset = 0;
|
||||
if ( tga_data != NULL )
|
||||
{
|
||||
tga_data = (uint8_t *)realloc(tga_data, w*h*3);
|
||||
}
|
||||
else
|
||||
{
|
||||
tga_data = (uint8_t *)malloc(w*h*3);
|
||||
}
|
||||
if ( tga_data == NULL )
|
||||
return 0;
|
||||
memset(tga_data, 255, (long)w*(long)h*3L);
|
||||
tga_width = w;
|
||||
tga_height = h;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void tga_set_pixel(uint16_t x, uint16_t y, uint16_t f)
|
||||
{
|
||||
uint8_t *p;
|
||||
uint16_t xx,yy;
|
||||
size_t offset;
|
||||
for( yy = y; yy < y+f; yy++ )
|
||||
{
|
||||
for( xx = x; xx < x+f; xx++ )
|
||||
{
|
||||
if ( yy < tga_height && xx < tga_width )
|
||||
{
|
||||
//printf ("(%d %d) ", xx, yy);
|
||||
offset = (tga_height-yy-1)*tga_width*3 + xx*3;
|
||||
p = tga_data + offset;
|
||||
if ( tga_max_offset < offset )
|
||||
tga_max_offset = offset;
|
||||
*p++ = tga_b;
|
||||
*p++ = tga_g;
|
||||
*p++ = tga_r;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void tga_clr_pixel(uint16_t x, uint16_t y, uint16_t f)
|
||||
{
|
||||
uint8_t *p;
|
||||
size_t offset;
|
||||
uint16_t xx,yy;
|
||||
for( yy = y; yy < y+f; yy++ )
|
||||
{
|
||||
for( xx = x; xx < x+f; xx++ )
|
||||
{
|
||||
offset = (tga_height-yy-1)*tga_width*3 + xx*3;
|
||||
p = tga_data + offset;
|
||||
*p++ = 255;
|
||||
*p++ = 255;
|
||||
*p++ = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void tga_set_8pixel(int x, int y, uint8_t pixel, uint16_t f)
|
||||
{
|
||||
int cnt = 8;
|
||||
while( cnt > 0 )
|
||||
{
|
||||
if ( (pixel & 1) != 0 )
|
||||
{
|
||||
tga_set_pixel(x,y, f);
|
||||
}
|
||||
else
|
||||
{
|
||||
tga_clr_pixel(x,y, f);
|
||||
}
|
||||
pixel >>= 1;
|
||||
y+=f;
|
||||
cnt--;
|
||||
}
|
||||
}
|
||||
|
||||
void tga_set_multiple_8pixel(int x, int y, int cnt, uint8_t *pixel, uint16_t f)
|
||||
{
|
||||
uint8_t b;
|
||||
while( cnt > 0 )
|
||||
{
|
||||
b = *pixel;
|
||||
tga_set_8pixel(x, y, b, f);
|
||||
x+=f;
|
||||
pixel++;
|
||||
cnt--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void tga_write_byte(FILE *fp, uint8_t byte)
|
||||
{
|
||||
fputc(byte, fp);
|
||||
}
|
||||
|
||||
void tga_write_word(FILE *fp, uint16_t word)
|
||||
{
|
||||
tga_write_byte(fp, word&255);
|
||||
tga_write_byte(fp, word>>8);
|
||||
}
|
||||
|
||||
void tga_save(const char *name)
|
||||
{
|
||||
FILE *fp;
|
||||
if ( tga_data == NULL )
|
||||
return;
|
||||
|
||||
//printf("tga_save: File %s with %dx%d pixel\n", name, tga_width, tga_height);
|
||||
|
||||
fp = fopen(name, "wb");
|
||||
if ( fp != NULL )
|
||||
{
|
||||
tga_write_byte(fp, 0); /* no ID */
|
||||
tga_write_byte(fp, 0); /* no color map */
|
||||
tga_write_byte(fp, 2); /* uncompressed true color */
|
||||
tga_write_word(fp, 0);
|
||||
tga_write_word(fp, 0);
|
||||
tga_write_byte(fp, 0);
|
||||
tga_write_word(fp, 0); /* x origin */
|
||||
tga_write_word(fp, 0); /* y origin */
|
||||
tga_write_word(fp, tga_width); /* width */
|
||||
tga_write_word(fp, tga_height); /* height */
|
||||
tga_write_byte(fp, 24); /* color depth */
|
||||
tga_write_byte(fp, 0);
|
||||
fwrite(tga_data, tga_width*tga_height*3, 1, fp);
|
||||
tga_write_word(fp, 0);
|
||||
tga_write_word(fp, 0);
|
||||
tga_write_word(fp, 0);
|
||||
tga_write_word(fp, 0);
|
||||
fwrite("TRUEVISION-XFILE.", 18, 1, fp);
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
/*==========================================*/
|
||||
/* tga procedures */
|
||||
|
||||
|
||||
u8x8_display_info_t u8x8_tga_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 0,
|
||||
/* pre_chip_disable_wait_ns = */ 0,
|
||||
/* reset_pulse_width_ms = */ 0,
|
||||
/* post_reset_wait_ms = */ 0,
|
||||
/* sda_setup_time_ns = */ 0,
|
||||
/* sck_pulse_width_ns = */ 0,
|
||||
/* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
|
||||
/* spi_mode = */ 1,
|
||||
/* i2c_bus_clock_100kHz = */ 0,
|
||||
/* data_setup_time_ns = */ 0,
|
||||
/* write_pulse_width_ns = */ 0,
|
||||
/* tile_width = */ (DEFAULT_WIDTH)/8,
|
||||
/* tile_hight = */ (DEFAULT_HEIGHT)/8,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
DEFAULT_WIDTH,
|
||||
DEFAULT_HEIGHT
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8x8_d_tga(u8x8_t *u8g2, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
u8g2_uint_t x, y, c;
|
||||
uint8_t *ptr;
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
u8x8_d_helper_display_setup_memory(u8g2, &u8x8_tga_info);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
u8x8_d_helper_display_init(u8g2);
|
||||
//if ( tga_data == NULL )
|
||||
tga_init(u8x8_tga_info.pixel_width, u8x8_tga_info.pixel_height);
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
break;
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
|
||||
tga_r = tga_desc_r;
|
||||
tga_g = tga_desc_g;
|
||||
tga_b = tga_desc_b;
|
||||
|
||||
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
//printf("U8X8_MSG_DISPLAY_DRAW_TILE x=%d, ", x);
|
||||
x *= 8;
|
||||
x += u8g2->x_offset;
|
||||
|
||||
y = ((u8x8_tile_t *)arg_ptr)->y_pos;
|
||||
//printf("y=%d, c=%d\n", y, ((u8x8_tile_t *)arg_ptr)->cnt);
|
||||
y *= 8;
|
||||
|
||||
do
|
||||
{
|
||||
c = ((u8x8_tile_t *)arg_ptr)->cnt;
|
||||
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
tga_set_multiple_8pixel(x, y, c*8, ptr, 1);
|
||||
arg_int--;
|
||||
} while( arg_int > 0 );
|
||||
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void u8x8_Setup_TGA(u8x8_t *u8x8)
|
||||
{
|
||||
/* setup defaults */
|
||||
u8x8_SetupDefaults(u8x8);
|
||||
|
||||
/* setup specific callbacks */
|
||||
u8x8->display_cb = u8x8_d_tga;
|
||||
|
||||
/* setup display info */
|
||||
u8x8_SetupMemory(u8x8);
|
||||
}
|
||||
|
||||
void u8g2_SetupBuffer_TGA(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb)
|
||||
{
|
||||
static uint8_t buf[(DEFAULT_WIDTH)*8*8];
|
||||
|
||||
u8x8_Setup_TGA(u8g2_GetU8x8(u8g2));
|
||||
u8g2_SetupBuffer(u8g2, buf, 8, u8g2_ll_hvline_vertical_top_lsb, u8g2_cb);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
CFLAGS = -g -Wall -I../../../csrc/. `sdl2-config --cflags` -DU8G2_16BIT
|
||||
|
||||
SRC = $(shell ls ../../../csrc/*.c) $(shell ls ../common/*.c ) main.c
|
||||
|
||||
OBJ = $(SRC:.c=.o)
|
||||
|
||||
u8g2_tga: $(OBJ)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) `sdl2-config --libs` -o u8g2_tga
|
||||
|
||||
clean:
|
||||
-rm $(OBJ) u8g2_tga
|
||||
|
||||
262
basic-setup/components/u8g2/sys/tga/ref_man_pics_8x8/main.c
Normal file
262
basic-setup/components/u8g2/sys/tga/ref_man_pics_8x8/main.c
Normal file
@@ -0,0 +1,262 @@
|
||||
|
||||
#include "u8x8.h"
|
||||
#include "u8g2.h"
|
||||
|
||||
|
||||
|
||||
extern uint8_t tga_is_transparent;
|
||||
|
||||
extern uint8_t tga_desc_fg_r;
|
||||
extern uint8_t tga_desc_fg_g;
|
||||
extern uint8_t tga_desc_fg_b;
|
||||
|
||||
extern uint8_t tga_desc_bg_r;
|
||||
extern uint8_t tga_desc_bg_g;
|
||||
extern uint8_t tga_desc_bg_b;
|
||||
|
||||
extern uint8_t tga_lcd_fg_r;
|
||||
extern uint8_t tga_lcd_fg_g;
|
||||
extern uint8_t tga_lcd_fg_b;
|
||||
|
||||
extern uint8_t tga_lcd_bg_r;
|
||||
extern uint8_t tga_lcd_bg_g;
|
||||
extern uint8_t tga_lcd_bg_b;
|
||||
|
||||
extern void tga_save_png(const char *name);
|
||||
|
||||
u8x8_t u8x8;
|
||||
u8g2_t desc;
|
||||
|
||||
void ra(uint8_t tx, uint8_t ty, const char *s)
|
||||
{
|
||||
int x,y, i, w;
|
||||
x = tx*8*3+64*3 + 4;
|
||||
y = ty*8*3+32*3 + 4*3;
|
||||
for( i = 0; i < 6; i++)
|
||||
{
|
||||
u8g2_DrawHVLine(&desc, x-2*i, y-i, 1+2*i, 1);
|
||||
u8g2_DrawHVLine(&desc, x-2*i-1, y-i, 1+2*i, 1);
|
||||
}
|
||||
u8g2_DrawHVLine(&desc, x-30, y-1, 28, 0);
|
||||
u8g2_DrawHVLine(&desc, x-30, y, 20, 0);
|
||||
u8g2_DrawHVLine(&desc, x-30, y+1, 28, 0);
|
||||
|
||||
w = u8g2_GetStrWidth(&desc, s);
|
||||
u8g2_DrawStr(&desc, x-34-w, y+u8g2_GetAscent(&desc)/2, s);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
/*
|
||||
tga_desc_fg_r = 100;
|
||||
tga_desc_fg_g = 118;
|
||||
tga_desc_fg_b = 135;
|
||||
*/
|
||||
|
||||
tga_desc_fg_r = 106;
|
||||
tga_desc_fg_g = 0;
|
||||
tga_desc_fg_b = 255;
|
||||
|
||||
tga_desc_bg_r = 255;
|
||||
tga_desc_bg_g = 255;
|
||||
tga_desc_bg_b = 255;
|
||||
|
||||
tga_lcd_fg_r = 0;
|
||||
tga_lcd_fg_g = 0;
|
||||
tga_lcd_fg_b = 0;
|
||||
|
||||
tga_lcd_bg_r = 240;
|
||||
tga_lcd_bg_g = 163;
|
||||
tga_lcd_bg_b = 10;
|
||||
|
||||
/*
|
||||
u8x8_Setup_TGA_DESC(&desc);
|
||||
u8x8_InitDisplay(&desc);
|
||||
u8x8_SetPowerSave(&desc, 0);
|
||||
u8x8_ClearDisplay(&desc);
|
||||
u8x8_SetFont(&desc, u8x8_font_amstrad_cpc_extended_r);
|
||||
u8x8_DrawString(&desc, 0, 0, "Description");
|
||||
*/
|
||||
|
||||
u8g2_SetupBuffer_TGA_DESC(&desc, &u8g2_cb_r0);
|
||||
u8x8_InitDisplay(u8g2_GetU8x8(&desc));
|
||||
u8x8_SetPowerSave(u8g2_GetU8x8(&desc), 0);
|
||||
u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
|
||||
|
||||
|
||||
u8x8_Setup_TGA_LCD(&u8x8);
|
||||
u8x8_InitDisplay(&u8x8);
|
||||
|
||||
u8x8_ClearDisplay(&u8x8);
|
||||
u8x8_SetPowerSave(&u8x8, 0);
|
||||
u8x8_SetFont(&u8x8, u8x8_font_amstrad_cpc_extended_r);
|
||||
u8x8_DrawString(&u8x8, 0, 0, "Hello World!");
|
||||
|
||||
tga_is_transparent = 1;
|
||||
u8g2_FirstPage(&desc);
|
||||
do
|
||||
{
|
||||
u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
|
||||
ra(0,0, "x=0, y=0");
|
||||
} while( u8g2_NextPage(&desc) );
|
||||
tga_is_transparent = 0;
|
||||
|
||||
|
||||
//tga_save("u8x8.tga");
|
||||
tga_save_png("u8x8_hello_world.png");
|
||||
|
||||
|
||||
u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
|
||||
u8x8_ClearDisplay(&u8x8);
|
||||
u8x8_SetPowerSave(&u8x8, 0);
|
||||
u8x8_SetFont(&u8x8, u8x8_font_amstrad_cpc_extended_r);
|
||||
u8x8_DrawString(&u8x8, 0, 0, "A");
|
||||
u8x8_DrawString(&u8x8, u8x8_GetCols(&u8x8)-1, u8x8_GetRows(&u8x8)-1, "B");
|
||||
|
||||
tga_is_transparent = 1;
|
||||
u8g2_FirstPage(&desc);
|
||||
do
|
||||
{
|
||||
u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
|
||||
ra(0,0, "x=0, y=0");
|
||||
ra(15,7, "x=15, y=7");
|
||||
} while( u8g2_NextPage(&desc) );
|
||||
tga_is_transparent = 0;
|
||||
|
||||
tga_save_png("u8x8_tile_size.png");
|
||||
|
||||
u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
|
||||
u8x8_ClearDisplay(&u8x8);
|
||||
u8x8_SetPowerSave(&u8x8, 0);
|
||||
u8x8_SetFont(&u8x8, u8x8_font_amstrad_cpc_extended_r);
|
||||
u8x8_SetInverseFont(&u8x8, 1);
|
||||
u8x8_DrawString(&u8x8, 2, 2, "Inverse");
|
||||
u8x8_SetInverseFont(&u8x8, 0);
|
||||
u8x8_DrawString(&u8x8, 2, 3, "Normal");
|
||||
|
||||
tga_is_transparent = 1;
|
||||
u8g2_FirstPage(&desc);
|
||||
do
|
||||
{
|
||||
u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
|
||||
ra(2,2, "x=2, y=2");
|
||||
ra(2,3, "x=2, y=3");
|
||||
} while( u8g2_NextPage(&desc) );
|
||||
tga_is_transparent = 0;
|
||||
|
||||
tga_save_png("u8x8_inverse.png");
|
||||
|
||||
u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
|
||||
u8x8_ClearDisplay(&u8x8);
|
||||
u8x8_SetPowerSave(&u8x8, 0);
|
||||
u8x8_SetInverseFont(&u8x8, 0);
|
||||
u8x8_SetFont(&u8x8, u8x8_font_amstrad_cpc_extended_f);
|
||||
u8x8_DrawString(&u8x8, 2, 2, "Umlaut \xe4\xf6\xfc");
|
||||
|
||||
tga_is_transparent = 1;
|
||||
u8g2_FirstPage(&desc);
|
||||
do
|
||||
{
|
||||
u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
|
||||
ra(2,2, "x=2, y=2");
|
||||
} while( u8g2_NextPage(&desc) );
|
||||
tga_is_transparent = 0;
|
||||
|
||||
tga_save_png("u8x8_umlaut.png");
|
||||
|
||||
|
||||
u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
|
||||
u8x8_ClearDisplay(&u8x8);
|
||||
u8x8_SetPowerSave(&u8x8, 0);
|
||||
u8x8_SetInverseFont(&u8x8, 0);
|
||||
u8x8_SetFont(&u8x8, u8x8_font_amstrad_cpc_extended_f);
|
||||
{
|
||||
uint8_t tiles[16] = { 0x0f,0x0f,0x0f,0x0f,0xf0,0xf0,0xf0,0xf0, 1, 3, 7, 15, 31, 63, 127, 255};
|
||||
u8x8_DrawTile(&u8x8, 1, 3, 2, tiles);
|
||||
|
||||
tga_is_transparent = 1;
|
||||
u8g2_FirstPage(&desc);
|
||||
do
|
||||
{
|
||||
u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
|
||||
ra(1,3, "x=1, y=3");
|
||||
} while( u8g2_NextPage(&desc) );
|
||||
tga_is_transparent = 0;
|
||||
}
|
||||
tga_save_png("u8x8_draw_tile.png");
|
||||
|
||||
u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
|
||||
u8x8_ClearDisplay(&u8x8);
|
||||
u8x8_SetPowerSave(&u8x8, 0);
|
||||
u8x8_SetInverseFont(&u8x8, 0);
|
||||
//u8x8_SetFont(&u8x8, u8x8_font_pressstart2p_f);
|
||||
u8x8_SetFont(&u8x8, u8x8_font_amstrad_cpc_extended_f);
|
||||
u8x8_DrawString(&u8x8, 1, 1, "U8x8");
|
||||
u8x8_Draw2x2String(&u8x8, 1, 3, "U8x8");
|
||||
|
||||
tga_is_transparent = 1;
|
||||
u8g2_FirstPage(&desc);
|
||||
do
|
||||
{
|
||||
u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
|
||||
ra(1,1, "x=1, y=1");
|
||||
ra(1,3, "x=1, y=3");
|
||||
} while( u8g2_NextPage(&desc) );
|
||||
tga_is_transparent = 0;
|
||||
|
||||
tga_save_png("u8x8_2x2.png");
|
||||
|
||||
/*=========================================*/
|
||||
|
||||
u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
|
||||
u8x8_ClearDisplay(&u8x8);
|
||||
u8x8_SetPowerSave(&u8x8, 0);
|
||||
u8x8_SetInverseFont(&u8x8, 0);
|
||||
//u8x8_SetFont(&u8x8, u8x8_font_pressstart2p_f);
|
||||
u8x8_SetFont(&u8x8, u8x8_font_amstrad_cpc_extended_f);
|
||||
u8x8_DrawString(&u8x8, 1, 1, "Hello World");
|
||||
u8x8_Draw1x2String(&u8x8, 1, 3, "Hello World");
|
||||
|
||||
tga_is_transparent = 1;
|
||||
u8g2_FirstPage(&desc);
|
||||
do
|
||||
{
|
||||
u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
|
||||
ra(1,1, "x=1, y=1");
|
||||
ra(1,3, "x=1, y=3");
|
||||
} while( u8g2_NextPage(&desc) );
|
||||
tga_is_transparent = 0;
|
||||
|
||||
tga_save_png("u8x8_1x2.png");
|
||||
|
||||
/*=========================================*/
|
||||
|
||||
u8x8_ClearDisplay(u8g2_GetU8x8(&desc));
|
||||
u8x8_ClearDisplay(&u8x8);
|
||||
u8x8_SetPowerSave(&u8x8, 0);
|
||||
u8x8_SetInverseFont(&u8x8, 0);
|
||||
//u8x8_SetFont(&u8x8, u8x8_font_pressstart2p_f);
|
||||
u8x8_SetFont(&u8x8, u8x8_font_amstrad_cpc_extended_r);
|
||||
u8x8_Draw2x2String(&u8x8, 1, 1, "U8x8");
|
||||
u8x8_SetFont(&u8x8, u8x8_font_px437wyse700b_2x2_r);
|
||||
u8x8_DrawString(&u8x8, 1, 3, "U8x8");
|
||||
|
||||
tga_is_transparent = 1;
|
||||
u8g2_FirstPage(&desc);
|
||||
do
|
||||
{
|
||||
u8g2_SetFont(&desc, u8g2_font_helvB18_tf);
|
||||
ra(1,1, "x=1, y=1");
|
||||
ra(1,3, "x=1, y=3");
|
||||
} while( u8g2_NextPage(&desc) );
|
||||
tga_is_transparent = 0;
|
||||
|
||||
tga_save_png("u8x8_font_2x2.png");
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
CFLAGS = -g -Wall -I../../../csrc/. `sdl2-config --cflags` -DU8G2_16BIT -DU8G2_REF_MAN_PIC
|
||||
|
||||
|
||||
SRC = $(shell ls ../../../csrc/*.c) $(shell ls ../common/*.c ) main.c
|
||||
|
||||
OBJ = $(SRC:.c=.o)
|
||||
|
||||
u8g2_tga: $(OBJ)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) `sdl2-config --libs` -o u8g2_tga
|
||||
|
||||
clean:
|
||||
-rm $(OBJ) u8g2_tga
|
||||
|
||||
1062
basic-setup/components/u8g2/sys/tga/ref_man_pics_u8g2/main.c
Normal file
1062
basic-setup/components/u8g2/sys/tga/ref_man_pics_u8g2/main.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,12 @@
|
||||
CFLAGS = -g -Wall -I../../../csrc/. `sdl2-config --cflags` -DU8G2_16BIT
|
||||
|
||||
SRC = $(shell ls ../../../csrc/*.c) $(shell ls ../common/*.c ) main.c
|
||||
|
||||
OBJ = $(SRC:.c=.o)
|
||||
|
||||
u8g2_tga: $(OBJ)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) `sdl2-config --libs` -o u8g2_tga
|
||||
|
||||
clean:
|
||||
-rm $(OBJ) u8g2_tga
|
||||
|
||||
76
basic-setup/components/u8g2/sys/tga/text_picture_loop/main.c
Normal file
76
basic-setup/components/u8g2/sys/tga/text_picture_loop/main.c
Normal file
@@ -0,0 +1,76 @@
|
||||
|
||||
#include "u8g2.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
|
||||
u8g2_t u8g2;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int x, y;
|
||||
int k;
|
||||
int i;
|
||||
|
||||
u8g2_SetupBuffer_TGA_DESC(&u8g2, &u8g2_cb_r0);
|
||||
u8x8_InitDisplay(u8g2_GetU8x8(&u8g2));
|
||||
u8x8_SetPowerSave(u8g2_GetU8x8(&u8g2), 0);
|
||||
u8g2_SetFont(&u8g2, u8g2_font_helvB18_tr);
|
||||
|
||||
x = 50;
|
||||
y = 30+0;
|
||||
|
||||
|
||||
#ifdef U8G2_WITH_HVLINE_COUNT
|
||||
u8g2.hv_cnt = 0UL;
|
||||
#endif /* U8G2_WITH_HVLINE_COUNT */
|
||||
|
||||
/*
|
||||
u8g2_ClearBuffer(&u8g2);
|
||||
|
||||
u8g2_SetFontDirection(&u8g2, 0);
|
||||
u8g2_DrawStr(&u8g2, x, y, "ABC");
|
||||
u8g2_SetFontDirection(&u8g2, 1);
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
u8g2_SetFontDirection(&u8g2, 2);
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
u8g2_SetFontDirection(&u8g2, 3);
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
|
||||
u8g2_SendBuffer(&u8g2);
|
||||
*/
|
||||
|
||||
u8g2_FirstPage(&u8g2);
|
||||
i = 0;
|
||||
do
|
||||
{
|
||||
u8g2_SetFontDirection(&u8g2, 0);
|
||||
u8g2_DrawStr(&u8g2, x, y, "ABC");
|
||||
u8g2_SetFontDirection(&u8g2, 1);
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
u8g2_SetFontDirection(&u8g2, 2);
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
u8g2_SetFontDirection(&u8g2, 3);
|
||||
u8g2_DrawStr(&u8g2, x, y, "abc");
|
||||
if ( i == 1 )
|
||||
{
|
||||
u8g2_DrawHVLine(&u8g2, u8g2.user_x0, u8g2.user_y0, 1, 0);
|
||||
u8g2_DrawHVLine(&u8g2, u8g2.user_x0, u8g2.user_y1-1, 1, 0);
|
||||
u8g2_DrawHVLine(&u8g2, u8g2.user_x1-1, u8g2.user_y1-1, 1, 0);
|
||||
u8g2_DrawHVLine(&u8g2, u8g2.user_x1-1, u8g2.user_y0, 1, 0);
|
||||
|
||||
}
|
||||
|
||||
i++;
|
||||
|
||||
|
||||
} while( u8g2_NextPage(&u8g2) );
|
||||
#ifdef U8G2_WITH_HVLINE_COUNT
|
||||
printf("hv cnt: %ld\n", u8g2.hv_cnt);
|
||||
#endif /* U8G2_WITH_HVLINE_COUNT */
|
||||
|
||||
tga_save("u8g2.tga");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
12
basic-setup/components/u8g2/sys/tga/word_cloud/Makefile
Normal file
12
basic-setup/components/u8g2/sys/tga/word_cloud/Makefile
Normal file
@@ -0,0 +1,12 @@
|
||||
CFLAGS = -g -Wall -I../../../csrc/. -DU8G2_16BIT
|
||||
|
||||
SRC = $(shell ls ../../../csrc/*.c) $(shell ls ../common/*.c ) main.c
|
||||
|
||||
OBJ = $(SRC:.c=.o)
|
||||
|
||||
u8g2_tga: $(OBJ)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) -o u8g2_tga
|
||||
|
||||
clean:
|
||||
-rm $(OBJ) u8g2_tga
|
||||
|
||||
735
basic-setup/components/u8g2/sys/tga/word_cloud/main.c
Normal file
735
basic-setup/components/u8g2/sys/tga/word_cloud/main.c
Normal file
@@ -0,0 +1,735 @@
|
||||
|
||||
#include "u8g2.h"
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#define WORD_CLOUD_MAX_X 600
|
||||
|
||||
extern uint8_t tga_is_transparent;
|
||||
|
||||
extern uint8_t tga_desc_fg_r;
|
||||
extern uint8_t tga_desc_fg_g;
|
||||
extern uint8_t tga_desc_fg_b;
|
||||
|
||||
extern uint8_t tga_desc_bg_r;
|
||||
extern uint8_t tga_desc_bg_g;
|
||||
extern uint8_t tga_desc_bg_b;
|
||||
|
||||
extern uint8_t tga_lcd_fg_r;
|
||||
extern uint8_t tga_lcd_fg_g;
|
||||
extern uint8_t tga_lcd_fg_b;
|
||||
|
||||
extern uint8_t tga_lcd_bg_r;
|
||||
extern uint8_t tga_lcd_bg_g;
|
||||
extern uint8_t tga_lcd_bg_b;
|
||||
|
||||
extern void tga_save_png(const char *name);
|
||||
|
||||
|
||||
struct _box_t
|
||||
{
|
||||
uint32_t w, h;
|
||||
};
|
||||
typedef struct _box_t box_t;
|
||||
|
||||
struct _pos_t
|
||||
{
|
||||
uint32_t x, y;
|
||||
};
|
||||
typedef struct _pos_t pos_t;
|
||||
|
||||
struct _pbox_t // placed box
|
||||
{
|
||||
pos_t pos;
|
||||
int box_idx;
|
||||
};
|
||||
typedef struct _pbox_t pbox_t;
|
||||
|
||||
#define BOX_LIST_MAX 50
|
||||
box_t box_list[BOX_LIST_MAX];
|
||||
char box_word[BOX_LIST_MAX][64];
|
||||
const uint8_t *box_font[BOX_LIST_MAX];
|
||||
int box_cnt = 0;
|
||||
|
||||
int box_index[BOX_LIST_MAX];
|
||||
|
||||
#define PLACE_OPTION_MAX 100
|
||||
int place_option_cnt = 0;
|
||||
pos_t place_option_list[PLACE_OPTION_MAX];
|
||||
|
||||
#define PLACED_BOX_MAX 100
|
||||
int placed_box_cnt = 0;
|
||||
pbox_t placed_box_list[PLACED_BOX_MAX];
|
||||
uint32_t placed_box_area_max_x;
|
||||
uint32_t placed_box_area_max_y;
|
||||
uint32_t placed_box_area_value;
|
||||
|
||||
/*============================================*/
|
||||
|
||||
int place_option_find(pos_t *p)
|
||||
{
|
||||
int i;
|
||||
for( i = 0; i < place_option_cnt; i++ )
|
||||
{
|
||||
if ( place_option_list[i].x == p->x && place_option_list[i].y == p->y)
|
||||
return i; // place option already exists
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void place_option_add(pos_t *p)
|
||||
{
|
||||
int i;
|
||||
assert(place_option_cnt < PLACE_OPTION_MAX);
|
||||
|
||||
if ( place_option_find(p) >= 0 )
|
||||
return; // place option already exists
|
||||
|
||||
// the placement option also must not be part of any existing box
|
||||
for( i = 2; i < placed_box_cnt; i++ )
|
||||
{
|
||||
if ( p->x >= placed_box_list[i].pos.x && p->x < placed_box_list[i].pos.x + box_list[placed_box_list[i].box_idx].w )
|
||||
if ( p->y >= placed_box_list[i].pos.y && p->y < placed_box_list[i].pos.y + box_list[placed_box_list[i].box_idx].h )
|
||||
return; // place option would be inside an existing box
|
||||
}
|
||||
|
||||
// place option does not exist, add new place option
|
||||
|
||||
place_option_list[place_option_cnt] = *p;
|
||||
place_option_cnt++;
|
||||
}
|
||||
|
||||
void place_option_by_xy(uint32_t x, uint32_t y)
|
||||
{
|
||||
pos_t p;
|
||||
p.x = x;
|
||||
p.y = y;
|
||||
place_option_add(&p);
|
||||
}
|
||||
|
||||
void place_option_delete(int idx)
|
||||
{
|
||||
if ( idx < 0 || idx >= place_option_cnt )
|
||||
return;
|
||||
for( ; idx+1 < place_option_cnt; idx++ )
|
||||
{
|
||||
place_option_list[idx] = place_option_list[idx+1];
|
||||
}
|
||||
place_option_cnt--;
|
||||
}
|
||||
|
||||
/*============================================*/
|
||||
|
||||
// p is copyied, b only the address is stored
|
||||
pbox_t *placed_box_push(pos_t *p, int box_idx)
|
||||
{
|
||||
assert(placed_box_cnt < PLACED_BOX_MAX);
|
||||
|
||||
|
||||
// place the new box
|
||||
placed_box_list[placed_box_cnt].pos = *p;
|
||||
placed_box_list[placed_box_cnt].box_idx = box_idx;
|
||||
placed_box_cnt++;
|
||||
return placed_box_list+placed_box_cnt-1;
|
||||
}
|
||||
|
||||
void placed_box_pop(void)
|
||||
{
|
||||
assert(placed_box_cnt > 0);
|
||||
placed_box_cnt--;
|
||||
}
|
||||
|
||||
uint32_t placed_box_calculate_max_area(void)
|
||||
{
|
||||
int i;
|
||||
placed_box_area_max_y = 0;
|
||||
placed_box_area_max_x = 0;
|
||||
for( i = 2; i < placed_box_cnt; i++ )
|
||||
{
|
||||
|
||||
if ( placed_box_area_max_y < placed_box_list[i].pos.y + box_list[placed_box_list[i].box_idx].h )
|
||||
placed_box_area_max_y = placed_box_list[i].pos.y + box_list[placed_box_list[i].box_idx].h;
|
||||
if ( placed_box_area_max_x < placed_box_list[i].pos.x + box_list[placed_box_list[i].box_idx].w )
|
||||
placed_box_area_max_x = placed_box_list[i].pos.x + box_list[placed_box_list[i].box_idx].w;
|
||||
}
|
||||
|
||||
if ( placed_box_area_max_x > WORD_CLOUD_MAX_X )
|
||||
// weight of y is higher, so this should give a more wider picture
|
||||
placed_box_area_value = placed_box_area_max_x*5 + placed_box_area_max_y ;
|
||||
else
|
||||
// weight of y is higher, so this should give a more wider picture
|
||||
placed_box_area_value = placed_box_area_max_x + placed_box_area_max_y *5;
|
||||
return placed_box_area_value;
|
||||
}
|
||||
|
||||
/*============================================*/
|
||||
|
||||
int is_intersection(pos_t *p1, box_t *b1, pos_t *p2, box_t *b2)
|
||||
{
|
||||
pos_t q1 = *p1;
|
||||
pos_t q2 = *p2;
|
||||
q1.x += b1->w;
|
||||
q1.y += b1->h;
|
||||
q2.x += b2->w;
|
||||
q2.y += b2->h;
|
||||
|
||||
if ( p1->x >= q2.x || q1.x <= p2->x )
|
||||
return 0;
|
||||
if ( p1->y >= q2.y || q1.y <= p2->y )
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int is_intersection_with_placed_box(pos_t *p1, box_t *b1, int idx)
|
||||
{
|
||||
return is_intersection(p1, b1, &(placed_box_list[idx].pos), box_list+placed_box_list[idx].box_idx );
|
||||
}
|
||||
|
||||
int is_any_intersection(pos_t *p1, box_t *b1)
|
||||
{
|
||||
int i;
|
||||
// start with the third box, because the first two are boundary boxes
|
||||
for( i = 2; i < placed_box_cnt; i++ )
|
||||
{
|
||||
if ( is_intersection_with_placed_box(p1, b1, i) != 0 )
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// add new place options by a give pbox
|
||||
void place_option_by_pbox(pbox_t *pbox)
|
||||
{
|
||||
int i, found_i;
|
||||
uint32_t y, x;
|
||||
uint32_t max_y, max_x;
|
||||
|
||||
// from the lower left corner, search towards the left until another box is hit.
|
||||
y = pbox->pos.y + box_list[pbox->box_idx].h;
|
||||
max_x = 0;
|
||||
found_i = -1;
|
||||
for( i = 0; i < placed_box_cnt; i++ )
|
||||
{
|
||||
if ( placed_box_list+i != pbox ) // do not check ourself
|
||||
{
|
||||
if ( placed_box_list[i].pos.x <= pbox->pos.x )
|
||||
{
|
||||
if ( y >= placed_box_list[i].pos.y && y < placed_box_list[i].pos.y + box_list[placed_box_list[i].box_idx].h )
|
||||
{
|
||||
// left box found, but is it max?
|
||||
// must use >= here, because the initial boxes have zero area
|
||||
if ( max_x <= placed_box_list[i].pos.x + box_list[placed_box_list[i].box_idx].w )
|
||||
{
|
||||
max_x = placed_box_list[i].pos.x + box_list[placed_box_list[i].box_idx].w;
|
||||
found_i = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (found_i >= 0)
|
||||
place_option_by_xy(max_x, y);
|
||||
|
||||
|
||||
// from the upper right corner, search towards the top until another box is hit.
|
||||
x = pbox->pos.x + box_list[pbox->box_idx].w;
|
||||
max_y = 0;
|
||||
found_i = -1;
|
||||
for( i = 0; i < placed_box_cnt; i++ )
|
||||
{
|
||||
if ( placed_box_list+i != pbox ) // do not check ourself
|
||||
{
|
||||
if ( placed_box_list[i].pos.y <= pbox->pos.y )
|
||||
{
|
||||
if ( x >= placed_box_list[i].pos.x && x < placed_box_list[i].pos.x + box_list[placed_box_list[i].box_idx].w )
|
||||
{
|
||||
// upper box found, but is it the next ?
|
||||
// must use >= here, because the initial boxes have zero area
|
||||
if ( max_y <= placed_box_list[i].pos.y + box_list[placed_box_list[i].box_idx].h )
|
||||
{
|
||||
max_y = placed_box_list[i].pos.y + box_list[placed_box_list[i].box_idx].h;
|
||||
found_i = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (found_i >= 0)
|
||||
place_option_by_xy(x, max_y);
|
||||
|
||||
}
|
||||
|
||||
void add_all_place_options(void)
|
||||
{
|
||||
int i;
|
||||
//place_option_cnt = 0; // clear the place option list
|
||||
for( i = 2; i < placed_box_cnt; i++ )
|
||||
{
|
||||
place_option_by_pbox(placed_box_list+i);
|
||||
}
|
||||
}
|
||||
|
||||
void show(void)
|
||||
{
|
||||
pos_t p;
|
||||
box_t b;
|
||||
int i;
|
||||
b.w = 1;
|
||||
b.h = 1;
|
||||
for( p.y = 0; p.y < 30; p.y++ )
|
||||
{
|
||||
for( p.x = 0; p.x < 60; p.x++ )
|
||||
{
|
||||
|
||||
for( i = 0; i < place_option_cnt; i++ )
|
||||
{
|
||||
if ( place_option_list[i].x == p.x && place_option_list[i].y == p.y )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( i < place_option_cnt )
|
||||
{
|
||||
printf("*");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
for( i = 0; i < placed_box_cnt; i++ )
|
||||
{
|
||||
if ( is_intersection_with_placed_box(&p, &b, i) != 0 )
|
||||
break;
|
||||
}
|
||||
if ( i < placed_box_cnt )
|
||||
{
|
||||
printf("%c", i+'a');
|
||||
}
|
||||
else
|
||||
{
|
||||
printf(" ");
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
void init(void)
|
||||
{
|
||||
pos_t p;
|
||||
|
||||
|
||||
box_list[0].w = 0x0ffffffff;
|
||||
box_list[0].h = 0;
|
||||
|
||||
box_list[1].w = 0;
|
||||
box_list[1].h = 0x0ffffffff;
|
||||
|
||||
box_cnt = 2;
|
||||
|
||||
p.x = 0;
|
||||
p.y = 0;
|
||||
placed_box_push(&p, 0);
|
||||
|
||||
p.x = 0;
|
||||
p.y = 0;
|
||||
placed_box_push(&p, 1);
|
||||
|
||||
// create one place option at the upper left
|
||||
place_option_by_xy(0, 0);
|
||||
|
||||
}
|
||||
|
||||
void do_best_place(int box_idx)
|
||||
{
|
||||
int i;
|
||||
int found_i;
|
||||
pbox_t *pbox;
|
||||
uint32_t value;
|
||||
uint32_t lowest_value;
|
||||
|
||||
found_i = -1;
|
||||
lowest_value = 0x0ffffffff;
|
||||
for( i = 0; i < place_option_cnt; i++ )
|
||||
{
|
||||
// check whether this placement would generate an intersection
|
||||
if ( is_any_intersection(place_option_list+i, box_list+box_idx) == 0 )
|
||||
{
|
||||
// place the box at the position
|
||||
pbox = placed_box_push(place_option_list+i, box_idx);
|
||||
value = placed_box_calculate_max_area();
|
||||
/*
|
||||
if ( value == 0x0ffffffff )
|
||||
{
|
||||
value = pbox->pos.y;
|
||||
}
|
||||
else
|
||||
*/
|
||||
{
|
||||
value *= 8;
|
||||
value += pbox->pos.x;
|
||||
value += pbox->pos.y;
|
||||
}
|
||||
|
||||
// greedy algorithm: We search for the lowest area increase
|
||||
if ( lowest_value > value )
|
||||
{
|
||||
lowest_value = value ;
|
||||
found_i = i;
|
||||
}
|
||||
|
||||
placed_box_pop();
|
||||
}
|
||||
}
|
||||
|
||||
if ( found_i >= 0 )
|
||||
{
|
||||
|
||||
// now permanently place the box
|
||||
pbox = placed_box_push(place_option_list+found_i, box_idx);
|
||||
|
||||
// delete the position from the place option list
|
||||
place_option_delete(found_i);
|
||||
|
||||
// calculate new place options with the new box
|
||||
//place_option_by_pbox(pbox);
|
||||
|
||||
// recalculate all place options
|
||||
add_all_place_options();
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(found_i >= 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Linear Congruential Generator (LCG)
|
||||
z = (a*z + c) % m;
|
||||
m = 256 (8 Bit)
|
||||
|
||||
for period:
|
||||
a-1: dividable by 2
|
||||
a-1: multiple of 4
|
||||
c: not dividable by 2
|
||||
|
||||
c = 17
|
||||
a-1 = 64 --> a = 65
|
||||
*/
|
||||
uint8_t cloud_z = 127; // start value
|
||||
uint8_t cloud_rnd(void) {
|
||||
cloud_z = (uint8_t)((uint16_t)65*(uint16_t)cloud_z + (uint16_t)17);
|
||||
return (uint8_t)cloud_z;
|
||||
}
|
||||
|
||||
|
||||
//u8g2_IsAllValidUTF8
|
||||
|
||||
char *cloud_utf8[] =
|
||||
{
|
||||
"µC"
|
||||
"Numérique"
|
||||
"像素",
|
||||
"屏幕",
|
||||
"图形",
|
||||
"Ψηφιακή",
|
||||
"Οθόνη",
|
||||
"Γραφικά",
|
||||
"アイコン、",
|
||||
"ビットマップ",
|
||||
"キャラクター、",
|
||||
"전자", "엔지니어", "장치", "하드웨어",
|
||||
"Ingeniør", "Skærm",
|
||||
"Gerät",
|
||||
"Sprzęt",
|
||||
"Računar", "Ugrađen",
|
||||
"Grafică",
|
||||
"экран",
|
||||
"Графика",
|
||||
"Значок",
|
||||
"Фонт", "екран", "рачунар", "уграђен",
|
||||
"พิกเซล",
|
||||
"หน้าจอ",
|
||||
"กราฟิก",
|
||||
"Gömülü",
|
||||
"ĂăĚěŇň",
|
||||
"ÄäÖöÜü",
|
||||
"Ææ",
|
||||
"E=mc²"
|
||||
};
|
||||
|
||||
char *cloud_str[] =
|
||||
{
|
||||
"Pixel",
|
||||
"Screen",
|
||||
"Graphics",
|
||||
"Icon",
|
||||
"Bitmap",
|
||||
"Character",
|
||||
"Glyph",
|
||||
"Font",
|
||||
"Display",
|
||||
"Computer",
|
||||
"Embedded",
|
||||
"Electronics",
|
||||
"Engineer",
|
||||
"Device",
|
||||
"Hardware",
|
||||
"Software",
|
||||
"Science",
|
||||
"Digital",
|
||||
"Arduino",
|
||||
"U8g2"
|
||||
};
|
||||
|
||||
char *cloud_simple[] =
|
||||
{
|
||||
"U8g2",
|
||||
"Abc",
|
||||
"XYZ",
|
||||
"Aa",
|
||||
"Xy"
|
||||
};
|
||||
|
||||
|
||||
|
||||
void cloud_add(u8g2_t *u8g2, const uint8_t *font, char *word)
|
||||
{
|
||||
u8g2_uint_t extra = 8;
|
||||
u8g2_SetFont(u8g2, font);
|
||||
box_list[box_cnt].w = u8g2_GetUTF8Width(u8g2, word) + extra;
|
||||
box_list[box_cnt].h = u8g2_GetAscent(u8g2) - u8g2_GetDescent(u8g2) + extra;
|
||||
strcpy(box_word[box_cnt], word);
|
||||
//puts(word);
|
||||
box_font[box_cnt] = font;
|
||||
box_cnt++;
|
||||
}
|
||||
|
||||
void cloud_auto_add(u8g2_t *u8g2, const uint8_t *font)
|
||||
{
|
||||
int i, n, cnt;
|
||||
|
||||
u8g2_SetFont(u8g2, font);
|
||||
|
||||
|
||||
if ( u8g2_GetAscent(u8g2) - u8g2_GetDescent(u8g2) > 30 )
|
||||
{
|
||||
n = sizeof(cloud_simple)/sizeof(*cloud_simple);
|
||||
|
||||
cnt = 0;
|
||||
for( i = 0; i < n; i++ )
|
||||
{
|
||||
if ( u8g2_IsAllValidUTF8(u8g2, cloud_simple[i]) != 0 )
|
||||
{
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
|
||||
if ( cnt > 0 )
|
||||
{
|
||||
cnt = cloud_rnd() % cnt;
|
||||
|
||||
for( i = 0; i < n; i++ )
|
||||
{
|
||||
if ( u8g2_IsAllValidUTF8(u8g2, cloud_simple[i]) != 0 )
|
||||
{
|
||||
if ( cnt == 0 )
|
||||
break;
|
||||
cnt--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( i < n )
|
||||
{
|
||||
cloud_add(u8g2, font, cloud_simple[i]);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
n = sizeof(cloud_utf8)/sizeof(*cloud_utf8);
|
||||
//printf("n=%d\n", n);
|
||||
|
||||
cnt = 0;
|
||||
for( i = 0; i < n; i++ )
|
||||
{
|
||||
if ( u8g2_IsAllValidUTF8(u8g2, cloud_utf8[i]) != 0 )
|
||||
{
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
|
||||
if ( cnt > 0 )
|
||||
{
|
||||
cnt = cloud_rnd() % cnt;
|
||||
|
||||
for( i = 0; i < n; i++ )
|
||||
{
|
||||
if ( u8g2_IsAllValidUTF8(u8g2, cloud_utf8[i]) != 0 )
|
||||
{
|
||||
if ( cnt == 0 )
|
||||
break;
|
||||
cnt--;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
i = n;
|
||||
}
|
||||
|
||||
if ( i < n )
|
||||
{
|
||||
cloud_add(u8g2, font, cloud_utf8[i]);
|
||||
return;
|
||||
}
|
||||
|
||||
n = sizeof(cloud_str)/sizeof(*cloud_str);
|
||||
//printf("n=%d\n", n);
|
||||
i = cloud_rnd() % n;
|
||||
cloud_add(u8g2, font, cloud_str[i]);
|
||||
|
||||
}
|
||||
|
||||
void cloud_init(void)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
void cloud_calculate(uint8_t z)
|
||||
{
|
||||
int i;
|
||||
int a, b, t;
|
||||
|
||||
cloud_z = z;
|
||||
|
||||
for( i = 0; i < box_cnt; i++ )
|
||||
{
|
||||
box_index[i] = i;
|
||||
}
|
||||
|
||||
for ( i = 0; i < box_cnt / 2; i++ )
|
||||
{
|
||||
a = cloud_rnd() % (box_cnt-2);
|
||||
a += 2;
|
||||
b = cloud_rnd() % (box_cnt-2);
|
||||
b += 2;
|
||||
t = box_index[a];
|
||||
box_index[a] = box_index[b];
|
||||
box_index[b] = t;
|
||||
}
|
||||
|
||||
for( i = 2; i < box_cnt; i++ )
|
||||
do_best_place(box_index[i]);
|
||||
}
|
||||
|
||||
|
||||
void cloud_draw(u8g2_t *u8g2)
|
||||
{
|
||||
int i;
|
||||
for( i = 2; i < placed_box_cnt; i++ )
|
||||
{
|
||||
|
||||
u8g2_SetFont(u8g2, box_font[placed_box_list[i].box_idx]);
|
||||
u8g2_DrawUTF8(u8g2,
|
||||
placed_box_list[i].pos.x,
|
||||
placed_box_list[i].pos.y,
|
||||
box_word[placed_box_list[i].box_idx]);
|
||||
}
|
||||
}
|
||||
|
||||
u8g2_t u8g2;
|
||||
|
||||
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
||||
tga_desc_fg_r = 0;
|
||||
tga_desc_fg_g = 0;
|
||||
tga_desc_fg_b = 0;
|
||||
|
||||
tga_desc_bg_r = 255;
|
||||
tga_desc_bg_g = 255;
|
||||
tga_desc_bg_b = 255;
|
||||
|
||||
u8g2_SetupBuffer_TGA_DESC(&u8g2, &u8g2_cb_r0);
|
||||
u8x8_InitDisplay(u8g2_GetU8x8(&u8g2));
|
||||
u8x8_SetPowerSave(u8g2_GetU8x8(&u8g2), 0);
|
||||
u8g2_SetFont(&u8g2, u8g2_font_helvB18_tr);
|
||||
u8g2_SetFontPosTop(&u8g2);
|
||||
|
||||
cloud_init();
|
||||
/*
|
||||
cloud_add(&u8g2, u8g2_font_helvR12_tr, "Embedded");
|
||||
cloud_add(&u8g2, u8g2_font_helvB12_tr, "Electronics");
|
||||
cloud_add(&u8g2, u8g2_font_helvR14_tr, "Arduino");
|
||||
cloud_add(&u8g2, u8g2_font_helvB14_tr, "Font");
|
||||
cloud_add(&u8g2, u8g2_font_helvR18_tr, "Controller");
|
||||
cloud_add(&u8g2, u8g2_font_helvB18_tr, "U8g2");
|
||||
cloud_add(&u8g2, u8g2_font_helvR24_tr, "ABC");
|
||||
cloud_add(&u8g2, u8g2_font_helvB24_tr, "XYZ");
|
||||
*/
|
||||
cloud_auto_add(&u8g2, u8g2_font_helvR12_tr);
|
||||
cloud_auto_add(&u8g2, u8g2_font_helvB12_tr);
|
||||
cloud_auto_add(&u8g2, u8g2_font_helvR14_tr);
|
||||
cloud_auto_add(&u8g2, u8g2_font_helvB14_tr);
|
||||
cloud_auto_add(&u8g2, u8g2_font_helvR18_tr);
|
||||
cloud_auto_add(&u8g2, u8g2_font_helvB18_tr);
|
||||
|
||||
cloud_auto_add(&u8g2, u8g2_font_gb16st_t_3);
|
||||
cloud_auto_add(&u8g2, u8g2_font_wqy12_t_gb2312);
|
||||
cloud_auto_add(&u8g2, u8g2_font_wqy14_t_gb2312);
|
||||
cloud_auto_add(&u8g2, u8g2_font_b10_t_japanese2);
|
||||
cloud_auto_add(&u8g2, u8g2_font_b16_b_t_japanese3);
|
||||
cloud_auto_add(&u8g2, u8g2_font_cu12_t_greek);
|
||||
cloud_auto_add(&u8g2, u8g2_font_cu12_t_cyrillic);
|
||||
cloud_auto_add(&u8g2, u8g2_font_unifont_t_korean2);
|
||||
cloud_auto_add(&u8g2, u8g2_font_unifont_t_polish);
|
||||
|
||||
cloud_auto_add(&u8g2, u8g2_font_logisoso54_tf);
|
||||
|
||||
cloud_auto_add(&u8g2, u8g2_font_gb16st_t_3);
|
||||
cloud_auto_add(&u8g2, u8g2_font_wqy12_t_gb2312);
|
||||
cloud_auto_add(&u8g2, u8g2_font_wqy14_t_gb2312);
|
||||
cloud_auto_add(&u8g2, u8g2_font_b10_t_japanese2);
|
||||
cloud_auto_add(&u8g2, u8g2_font_b16_b_t_japanese3);
|
||||
cloud_auto_add(&u8g2, u8g2_font_cu12_t_greek);
|
||||
cloud_auto_add(&u8g2, u8g2_font_cu12_t_cyrillic);
|
||||
cloud_auto_add(&u8g2, u8g2_font_unifont_t_korean2);
|
||||
cloud_auto_add(&u8g2, u8g2_font_unifont_t_polish);
|
||||
cloud_auto_add(&u8g2, u8g2_font_logisoso58_tf);
|
||||
|
||||
|
||||
cloud_calculate(4);
|
||||
|
||||
|
||||
u8g2_FirstPage(&u8g2);
|
||||
do
|
||||
{
|
||||
cloud_draw(&u8g2);
|
||||
/*
|
||||
u8g2_DrawFrame(&u8g2,
|
||||
placed_box_list[i].pos.x,
|
||||
placed_box_list[i].pos.y,
|
||||
box_list[placed_box_list[i].box_idx].w,
|
||||
box_list[placed_box_list[i].box_idx].h);
|
||||
*/
|
||||
|
||||
//u8g2_SetFont(&u8g2, u8g2_font_helvB18_tr);
|
||||
// u8g2_DrawStr(&u8g2, 20, 20, "abc");
|
||||
|
||||
} while( u8g2_NextPage(&u8g2) );
|
||||
//tga_save("u8g2.tga");
|
||||
tga_save_png("u8g2.png");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user