This commit is contained in:
olikraus 2015-12-20 23:39:27 +01:00
parent 169ee776c2
commit 4acd2ff1be
19 changed files with 86 additions and 41 deletions

View File

@ -4,7 +4,7 @@
call sequence
u8g2_Setup_XYZ
u8g2_SetupBuffer_XYZ
u8x8_Setup_XYZ
u8x8_SetupDefaults(u8g2);
assign u8x8 callbacks
@ -246,6 +246,20 @@ struct u8g2_struct
#define u8g2_GetU8x8(u8g2) ((u8x8_t *)(u8g2))
/*==========================================*/
/* u8x8 wrapper */
#define u8g2_SetupDisplay(u8g2, display_cb, cad_cb, byte_cb, gpio_and_delay_cb) \
u8x8_Setup(u8g2_GetU8x8(u8g2), (display_cb), (cad_cb), (byte_cb), (gpio_and_delay_cb))
#define u8g2_InitDisplay(u8g2) u8x8_InitDisplay(u8g2_GetU8x8(u8g2))
#define u8g2_SetPowerSave(u8g2, is_enable) u8x8_SetPowerSave(u8g2_GetU8x8(u8g2), (is_enable))
#define u8g2_SetFlipMode(u8g2, mode) u8x8_SetFlipMode(u8g2_GetU8x8(u8g2), (mode))
#define u8g2_SetContrast(u8g2, value) u8x8_SetContrast(u8g2_GetU8x8(u8g2), (value))
#define u8g2_ClearDisplay(u8g2) u8x8_ClearDisplay(u8g2_GetU8x8(u8g2))
/*==========================================*/
/* u8g2_setup.c */
@ -254,7 +268,7 @@ extern const u8g2_cb_t u8g2_cb_r1;
extern const u8g2_cb_t u8g2_cb_r2;
extern const u8g2_cb_t u8g2_cb_r3;
void u8g2_Setup(u8g2_t *u8g2, uint8_t *buf, uint8_t tile_buf_height, const u8g2_cb_t *u8g2_cb);
void u8g2_SetupBuffer(u8g2_t *u8g2, uint8_t *buf, uint8_t tile_buf_height, const u8g2_cb_t *u8g2_cb);
@ -311,13 +325,13 @@ u8g2_uint_t u8g2_GetUTF8Width(u8g2_t *u8g2, const char *str);
/*==========================================*/
/* u8x8_d_sdl_128x64.c */
void u8g2_Setup_SDL_128x64(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb);
void u8g2_Setup_SDL_128x64_4(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb);
void u8g2_SetupBuffer_SDL_128x64(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb);
void u8g2_SetupBuffer_SDL_128x64_4(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb);
/*==========================================*/
/* u8x8_d_tga.c */
void u8g2_Setup_TGA_DESC(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb);
void u8g2_Setup_TGA_LCD(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb);
void u8g2_SetupBuffer_TGA_DESC(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb);
void u8g2_SetupBuffer_TGA_LCD(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb);

View File

@ -9,7 +9,7 @@
/*============================================*/
void u8g2_Setup(u8g2_t *u8g2, uint8_t *buf, uint8_t tile_buf_height, const u8g2_cb_t *u8g2_cb)
void u8g2_SetupBuffer(u8g2_t *u8g2, uint8_t *buf, uint8_t tile_buf_height, const u8g2_cb_t *u8g2_cb)
{
u8g2->tile_buf_ptr = buf;
u8g2->tile_buf_height = tile_buf_height;

View File

@ -352,11 +352,13 @@ uint8_t u8x8_DrawTile(u8x8_t *u8x8, uint8_t x, uint8_t y, uint8_t cnt, uint8_t *
/*
After a call to u8x8_SetupDefaults,
setup u8x8 memory structures & inform callbacks
This function is also called from u8x8_Setup(), so do not call u8x8_SetupMemory()
directly, but use u8x8_Setup() instead.
*/
void u8x8_SetupMemory(u8x8_t *u8x8);
/*
After calling u8x8_SetupMemory(), init the display hardware itself.
After calling u8x8_SetupMemory()/u8x8_Setup(), init the display hardware itself.
This will will the first time, u8x8 talks to the display.
It will init the display, but keep display in power save mode.
Usually this command must be followed by u8x8_SetPowerSave()

View File

@ -333,13 +333,13 @@ void u8x8_Setup_SSD1306_128x64_NONAME(u8x8_t *u8x8)
u8x8_SetupMemory(u8x8);
}
void u8g2_Setup_SSD1306_128x64_NONAME_1(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb)
void u8g2_SetupBuffer_SSD1306_128x64_NONAME_1(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb)
{
static uint8_t buf[128*8];
u8x8_Setup_SSD1306_128x64_NONAME(u8g2_GetU8x8(u8g2));
u8g2_Setup(u8g2, buf, 1, u8g2_cb);
u8g2_SetupBuffer(u8g2, buf, 1, u8g2_cb);
}
@ -350,7 +350,7 @@ uint8_t tile[8] = { 0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0 };
void setup(void)
{
//u8x8_Setup_UC1701_DOGS102(&u8g2);
u8g2_Setup_SSD1306_128x64_NONAME_1(&u8g2, &u8g2_cb_r0);
u8g2_SetupBuffer_SSD1306_128x64_NONAME_1(&u8g2, &u8g2_cb_r0);
u8x8_InitDisplay(u8g2_GetU8x8(&u8g2));
u8x8_SetPowerSave(u8g2_GetU8x8(&u8g2), 0);
u8g2_SetFont(&u8g2, u8g2_font_helvB18_tr);

View File

@ -267,23 +267,23 @@ void u8x8_Setup_SDL_128x64(u8x8_t *u8x8)
u8x8_SetupMemory(u8x8);
}
void u8g2_Setup_SDL_128x64(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb)
void u8g2_SetupBuffer_SDL_128x64(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb)
{
static uint8_t buf[128*8];
u8x8_Setup_SDL_128x64(u8g2_GetU8x8(u8g2));
u8g2_Setup(u8g2, buf, 8, u8g2_cb);
u8g2_SetupBuffer(u8g2, buf, 8, u8g2_cb);
}
void u8g2_Setup_SDL_128x64_4(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb)
void u8g2_SetupBuffer_SDL_128x64_4(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb)
{
static uint8_t buf[128*3];
u8x8_Setup_SDL_128x64(u8g2_GetU8x8(u8g2));
u8g2_Setup(u8g2, buf, 3, u8g2_cb);
u8g2_SetupBuffer(u8g2, buf, 3, u8g2_cb);
}

View File

@ -11,7 +11,7 @@ int main(void)
int k;
int i;
u8g2_Setup_SDL_128x64_4(&u8g2, &u8g2_cb_r0);
u8g2_SetupBuffer_SDL_128x64_4(&u8g2, &u8g2_cb_r0);
u8x8_InitDisplay(u8g2_GetU8x8(&u8g2));
u8x8_SetPowerSave(u8g2_GetU8x8(&u8g2), 0);

View File

@ -56,7 +56,7 @@ u8g2_t u8g2;
int main(void)
{
u8g2_Setup_SDL_128x64(&u8g2, &u8g2_cb_r0);
u8g2_SetupBuffer_SDL_128x64(&u8g2, &u8g2_cb_r0);
u8x8_InitDisplay(u8g2_GetU8x8(&u8g2));
u8x8_SetPowerSave(u8g2_GetU8x8(&u8g2), 0);

View File

@ -11,7 +11,7 @@ int main(void)
int k;
int i;
u8g2_Setup_SDL_128x64_4(&u8g2, &u8g2_cb_r0);
u8g2_SetupBuffer_SDL_128x64_4(&u8g2, &u8g2_cb_r0);
u8x8_InitDisplay(u8g2_GetU8x8(&u8g2));
u8x8_SetPowerSave(u8g2_GetU8x8(&u8g2), 0);
u8g2_SetFont(&u8g2, u8g2_font_helvB18_tr);

View File

@ -202,7 +202,7 @@ int main(void)
int x, y;
int k;
u8g2_Setup_SDL_128x64(&u8g2, &u8g2_cb_r0);
u8g2_SetupBuffer_SDL_128x64(&u8g2, &u8g2_cb_r0);
u8x8_InitDisplay(u8g2_GetU8x8(&u8g2));
u8x8_SetPowerSave(u8g2_GetU8x8(&u8g2), 0);
u8g2_SetFont(&u8g2, u8g2_font_helvB18_tr);

View File

@ -11,7 +11,7 @@ int main(void)
int k;
int i;
u8g2_Setup_SDL_128x64_4(&u8g2, &u8g2_cb_r0);
u8g2_SetupBuffer_SDL_128x64_4(&u8g2, &u8g2_cb_r0);
u8x8_InitDisplay(u8g2_GetU8x8(&u8g2));
u8x8_SetPowerSave(u8g2_GetU8x8(&u8g2), 0);

View File

@ -296,7 +296,7 @@ int main(void)
int k;
int i;
u8g2_Setup_SDL_128x64_4(&u8g2, &u8g2_cb_r0);
u8g2_SetupBuffer_SDL_128x64_4(&u8g2, &u8g2_cb_r0);
u8x8_InitDisplay(u8g2_GetU8x8(&u8g2));
u8x8_SetPowerSave(u8g2_GetU8x8(&u8g2), 0);
//u8g2_SetFont(&u8g2, u8g2_font_helvB18_tr);

View File

@ -58,7 +58,7 @@ const uint8_t bdf_font[762] U8G2_FONT_SECTION("bdf_font") = {
int main(void)
{
uint8_t tile[8] = { 0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0 };
u8g2_SetupStdio(&u8g2);
u8g2_SetupBufferStdio(&u8g2);
u8g2_display_Init(&u8g2);
u8g2_display_PowerUp(&u8g2);

View File

@ -284,12 +284,12 @@ void u8x8_Setup_TGA_DESC(u8x8_t *u8x8)
u8x8_SetupMemory(u8x8);
}
void u8g2_Setup_TGA_DESC(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb)
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_Setup(u8g2, buf, 1, u8g2_cb);
u8g2_SetupBuffer(u8g2, buf, 1, u8g2_cb);
}
/*==========================================*/
@ -393,12 +393,12 @@ void u8x8_Setup_TGA_LCD(u8x8_t *u8x8)
u8x8_SetupMemory(u8x8);
}
void u8g2_Setup_TGA_LCD(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb)
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_Setup(u8g2, buf, 1, u8g2_cb);
u8g2_SetupBuffer(u8g2, buf, 1, u8g2_cb);
}

View File

@ -61,7 +61,7 @@ int main(void)
int k;
int i;
u8g2_Setup_TGA_LCD(&u8g2, &u8g2_cb_r0);
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);

View File

@ -81,7 +81,7 @@ int main(void)
u8x8_DrawString(&desc, 0, 0, "Description");
*/
u8g2_Setup_TGA_DESC(&desc, &u8g2_cb_r0);
u8g2_SetupBuffer_TGA_DESC(&desc, &u8g2_cb_r0);
u8x8_InitDisplay(u8g2_GetU8x8(&desc));
u8x8_SetPowerSave(u8g2_GetU8x8(&desc), 0);
u8x8_ClearDisplay(u8g2_GetU8x8(&desc));

View File

@ -12,7 +12,7 @@ int main(void)
int k;
int i;
u8g2_Setup_TGA_DESC(&u8g2, &u8g2_cb_r0);
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);

View File

@ -22,14 +22,14 @@ struct controller
struct controller controller_list[] =
{
{
"SSD1306", 16, 8, "u8x8_cad_001",
"ssd1306", 16, 8, "u8x8_cad_001",
{
{ "128x64_noname" },
{ NULL }
}
},
{
"UC1701", 9, 8, "u8x8_cad_001",
"uc1701", 9, 8, "u8x8_cad_001",
{
{ "dogs102" },
{ NULL }
@ -43,11 +43,20 @@ char *strlowercase(const char *s)
{
int i, len = strlen(s);
static char buf[1024];
for( i = 0; i < len; i++ )
for( i = 0; i <= len; i++ )
buf[i] = tolower(s[i]);
return buf;
}
char *struppercase(const char *s)
{
int i, len = strlen(s);
static char buf[1024];
for( i = 0; i <= len; i++ )
buf[i] = toupper(s[i]);
return buf;
}
/*===========================================*/
FILE *buf_code_fp;
@ -58,6 +67,22 @@ FILE *setup_code_fp;
/*===========================================*/
void do_display(int controller_idx, int display_idx, const char *postfix)
{
fprintf(setup_code_fp, "uint8_t *u8g2_Setup_");
fprintf(setup_code_fp, "%s_", strlowercase(controller_list[controller_idx].name));
fprintf(setup_code_fp, "%s_", strlowercase(controller_list[controller_idx].display_list[display_idx].name));
fprintf(setup_code_fp, "%s(uint8_t *u8g2, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb)\n", postfix);
fprintf(setup_code_fp, "{\n");
fprintf(setup_code_fp, " u8g2_SetupDisplay(u8x8_d_");
fprintf(setup_code_fp, "%s_", strlowercase(controller_list[controller_idx].name));
fprintf(setup_code_fp, "%s, ", strlowercase(controller_list[controller_idx].display_list[display_idx].name));
fprintf(setup_code_fp, "%s, ", controller_list[controller_idx].cad);
fprintf(setup_code_fp, "byte_cb, gpio_and_delay_cb);");
fprintf(setup_code_fp, "}\n");
}
void do_controller_buffer_code(int idx, const char *postfix, int buf_len, int rows)
{
int display_idx;
@ -77,6 +102,7 @@ void do_controller_buffer_code(int idx, const char *postfix, int buf_len, int ro
while( controller_list[idx].display_list[display_idx].name != NULL )
{
printf("%s\n", controller_list[idx].display_list[display_idx].name);
do_display(idx, display_idx, postfix);
display_idx++;
}
@ -105,7 +131,7 @@ int main(void)
fprintf(buf_header_fp, "/* start of generated code, codebuild, u8g2 project */\n");
setup_code_fp = fopen("u8g2_setup.c", "w");
fprintf(buf_code_fp, "/* start of generated code, codebuild, u8g2 project */\n");
fprintf(setup_code_fp, "/* start of generated code, codebuild, u8g2 project */\n");
do_controller_list();
@ -114,6 +140,9 @@ int main(void)
fprintf(buf_header_fp, "/* end of generated code */\n");
fclose(buf_header_fp);
fprintf(setup_code_fp, "/* end of generated code */\n");
fclose(setup_code_fp);
return 0;
}

View File

@ -14,7 +14,7 @@ extern const uint8_t *u8g2_font_list[] ;
extern char *u8g2_font_names[] ;
#ifdef BUILD2
extern void u8g2_Setup_TGA(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb);
extern void u8g2_SetupBuffer_TGA(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb);
extern void tga_save(const char *name);
#endif
@ -664,7 +664,7 @@ void overviewpic(int i, int fm, char *fms, int bm, char *bms, int mm, char *mms)
{
printf("8x8 font overview picture %s\n", target_font_identifier);
u8g2_Setup_TGA(&u8g2, &u8g2_cb_r0);
u8g2_SetupBuffer_TGA(&u8g2, &u8g2_cb_r0);
u8x8_InitDisplay(u8g2_GetU8x8(&u8g2));
u8x8_SetPowerSave(u8g2_GetU8x8(&u8g2), 0);
//u8x8_ClearDisplay(u8g2_GetU8x8(&u8g2));
@ -700,7 +700,7 @@ void overviewpic(int i, int fm, char *fms, int bm, char *bms, int mm, char *mms)
else if ( fm == FM_C )
{
printf("overview picture %s\n", target_font_identifier);
u8g2_Setup_TGA(&u8g2, &u8g2_cb_r0);
u8g2_SetupBuffer_TGA(&u8g2, &u8g2_cb_r0);
u8x8_InitDisplay(u8g2_GetU8x8(&u8g2));
u8x8_SetPowerSave(u8g2_GetU8x8(&u8g2), 0);
//u8g2_SetFont(&u8g2, u8g2_font_helvB14_tr);
@ -733,7 +733,7 @@ void overviewshortpic(int i, int fm, char *fms, int bm, char *bms, int mm, char
if ( fm == FM_8 )
{
printf("8x8 font short overview picture %s\n", target_font_identifier);
u8g2_Setup_TGA(&u8g2, &u8g2_cb_r0);
u8g2_SetupBuffer_TGA(&u8g2, &u8g2_cb_r0);
u8x8_InitDisplay(u8g2_GetU8x8(&u8g2));
u8x8_SetPowerSave(u8g2_GetU8x8(&u8g2), 0);
//u8x8_ClearDisplay(u8g2_GetU8x8(&u8g2));
@ -756,7 +756,7 @@ void overviewshortpic(int i, int fm, char *fms, int bm, char *bms, int mm, char
else if ( fm == FM_C )
{
printf("short overview picture %s\n", target_font_identifier);
u8g2_Setup_TGA(&u8g2, &u8g2_cb_r0);
u8g2_SetupBuffer_TGA(&u8g2, &u8g2_cb_r0);
u8x8_InitDisplay(u8g2_GetU8x8(&u8g2));
u8x8_SetPowerSave(u8g2_GetU8x8(&u8g2), 0);
//u8g2_SetFont(&u8g2, u8g2_font_helvB14_tr);
@ -807,7 +807,7 @@ void generate_font_list(int i, int fm, char *fms, int bm, char *bms, int mm, cha
}
else if ( fm == FM_C )
{
u8g2_Setup_TGA(&u8g2, &u8g2_cb_r0);
u8g2_SetupBuffer_TGA(&u8g2, &u8g2_cb_r0);
u8x8_InitDisplay(u8g2_GetU8x8(&u8g2));
u8x8_SetPowerSave(u8g2_GetU8x8(&u8g2), 0);
if ( u8g2_font_list[u8g2_fnt_cnt] != NULL )

View File

@ -261,11 +261,11 @@ void u8x8_Setup_TGA(u8x8_t *u8x8)
u8x8_SetupMemory(u8x8);
}
void u8g2_Setup_TGA(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb)
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_Setup(u8g2, buf, 8, u8g2_cb);
u8g2_SetupBuffer(u8g2, buf, 8, u8g2_cb);
}