int main(void) { u8g2_SetupBuffer_Utf8(&u8g2, U8G2_R0); u8g2_InitDisplay(&u8g2); u8g2_SetPowerSave(&u8g2, 0); u8g2_SetFont(&u8g2, u8g2_font_6x13_tf); u8g2_SetFontDirection(&u8g2, 0); u8g2_FirstPage(&u8g2); do { u8g2_DrawRBox(&u8g2, 2, 3, 8, 9, 3); u8g2_DrawRBox(&u8g2, 12, 3, 5, 13, 2); u8g2_DrawRBox(&u8g2, 12,17, 13, 3, 1); u8g2_DrawRFrame(&u8g2, 2,21, 11, 7, 3); u8g2_DrawRFrame(&u8g2, 25,24, 27, 5, 2); u8g2_DrawRFrame(&u8g2, 23,22, 31, 9, 3); u8g2_DrawStr(&u8g2, 30, 10, "RBox"); u8g2_DrawStr(&u8g2, 30, 20, "RFrame"); } while( u8g2_NextPage(&u8g2) ); utf8_show(); return 0; }
int main(void) { uint8_t i, cnt; u8g2_SetupBuffer_Utf8(&u8g2, &u8g2_cb_r0); u8x8_InitDisplay(u8g2_GetU8x8(&u8g2)); u8x8_SetPowerSave(u8g2_GetU8x8(&u8g2), 0); u8g2_SetFont(&u8g2, u8g2_font_helvB10_tr); #ifdef U8G2_WITH_HVLINE_COUNT u8g2.hv_cnt = 0UL; #endif /* U8G2_WITH_HVLINE_COUNT */ u8g2_FirstPage(&u8g2); i = 0; cnt = u8x8_GetStringLineCnt(str); do { for( i = 0; i < cnt; i++ ) { u8g2_DrawStr(&u8g2, 0, i*12+11, u8x8_GetStringLine(i, str)); } } while( u8g2_NextPage(&u8g2) ); #ifdef U8G2_WITH_HVLINE_COUNT printf("hv cnt: %ld\n", u8g2.hv_cnt); #endif /* U8G2_WITH_HVLINE_COUNT */ utf8_show(); return 0; }
void write_tga_map(const char *filename) { static u8g2_t u8g2; int x, y, i; unsigned tile; if ( map_phase != PHASE_MAPDATA ) return; u8x8_tga_info.tile_width = map_width*2; u8x8_tga_info.tile_height = map_height*2; u8x8_tga_info.pixel_width = map_width*16; u8x8_tga_info.pixel_height = map_height*16; u8g2_SetupBuffer_TGA(&u8g2, &u8g2_cb_r0); u8x8_InitDisplay(u8g2_GetU8x8(&u8g2)); u8x8_SetPowerSave(u8g2_GetU8x8(&u8g2), 0); u8g2_SetFont(&u8g2, scrollosprites); u8g2_FirstPage(&u8g2); do { for( y = 0; y < map_height; y++ ) { for( x = 0; x < map_width; x++ ) { tile = map2[y][x]; /* check if there is a fg_tile, if so, use that tile instead */ for( i = 0; i < tile_cnt; i++ ) { if ( tile_list[i].item_index >= 0 ) { if ( tile_list[i].ascii == map[y][x] ) { tile = item_list[tile_list[i].item_index].fg_tile; } } } u8g2_DrawGlyph(&u8g2, x*16, y*16+16, tile); } } } while( u8g2_NextPage(&u8g2) ); tga_save(filename); }
int main(void) { u8g2_SetupBuffer_Utf8(&u8g2, &u8g2_cb_r0); u8x8_InitDisplay(u8g2_GetU8x8(&u8g2)); u8x8_SetPowerSave(u8g2_GetU8x8(&u8g2), 0); u8g2_SetFont(&u8g2, u8g2_font_unifont_t_chinese2); u8g2_SetFontDirection(&u8g2, 0); u8g2_FirstPage(&u8g2); do { u8g2_DrawUTF8(&u8g2, 2, 15, "你好世界"); u8g2_DrawStr(&u8g2, 2, 30, "Hello World"); } while( u8g2_NextPage(&u8g2) ); utf8_show(); return 0; }
int main(void) { int y; u8g2_SetupBuffer_Utf8(&u8g2, &u8g2_cb_r0); u8x8_InitDisplay(u8g2_GetU8x8(&u8g2)); u8x8_SetPowerSave(u8g2_GetU8x8(&u8g2), 0); u8g2_SetFont(&u8g2, u8g2_font_5x7_tr); u8g2_SetFontDirection(&u8g2, 0); #ifdef U8G2_WITH_HVLINE_COUNT u8g2.hv_cnt = 0UL; #endif /* U8G2_WITH_HVLINE_COUNT */ u8g2_FirstPage(&u8g2); do { for( y = 3; y < 21; y++ ) { u8g2_DrawHLine(&u8g2, 3, y, 11); } u8g2_DrawStr(&u8g2, 17, 8, "Test Inter-"); u8g2_DrawStr(&u8g2, 17, 16, "section:"); u8g2_DrawStr(&u8g2, 17, 24, "One Block"); } while( u8g2_NextPage(&u8g2) ); #ifdef U8G2_WITH_HVLINE_COUNT printf("hv cnt: %ld\n", u8g2.hv_cnt); #endif /* U8G2_WITH_HVLINE_COUNT */ utf8_show(); return 0; }
int main(void) { u8g2_SetupBuffer_Utf8(&u8g2, U8G2_R0); u8g2_InitDisplay(&u8g2); u8g2_SetPowerSave(&u8g2, 0); u8g2_SetFont(&u8g2, u8g2_font_6x13_tf); u8g2_SetFontDirection(&u8g2, 0); u8g2_FirstPage(&u8g2); do { u8g2_DrawXBM(&u8g2, 1, 1, 19, 29, b); u8g2_DrawStr(&u8g2, 30, 20, "XBM"); } while( u8g2_NextPage(&u8g2) ); utf8_show(); return 0; }
int main(void) { int x, y; int k; int i; 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_tn); x = 50; y = 30; for(;;) { #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, "123"); u8g2_SetFontDirection(&u8g2, 1); u8g2_DrawStr(&u8g2, x, y, "123"); u8g2_SetFontDirection(&u8g2, 2); u8g2_DrawStr(&u8g2, x, y, "123"); u8g2_SetFontDirection(&u8g2, 3); u8g2_DrawStr(&u8g2, x, y, "123"); 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 */ do { k = u8g_sdl_get_key(); } while( k < 0 ); if ( k == 273 ) y -= 7; if ( k == 274 ) y += 7; if ( k == 276 ) x -= 7; if ( k == 275 ) x += 7; if ( k == 'e' ) y -= 1; if ( k == 'x' ) y += 1; if ( k == 's' ) x -= 1; if ( k == 'd' ) x += 1; if ( k == 'q' ) break; } //u8x8_Set8x8Font(u8g2_GetU8x8(&u8g2), bdf_font); //u8x8_Draw8x8String(u8g2_GetU8x8(&u8g2), 0, 0, "Hello World!"); return 0; }
int main(void) { uint32_t screen = 0; u8g2_t u8g2; /* initialize to stdout */ #if TEST_U8G2_OUTPUT == TEST_U8G2_OUTPUT_STDOUT puts("initializing to stdout."); u8g2_SetupBuffer_Utf8(&u8g2, U8G2_R0); #endif /* initialize to virtual SDL (native only) */ #if TEST_U8G2_OUTPUT == TEST_U8G2_OUTPUT_SDL puts("initializing to SDL."); u8g2_SetupBuffer_SDL_128x64_4(&u8g2, U8G2_R0); #endif /* initialize to SPI */ #if TEST_U8G2_OUTPUT == TEST_U8G2_OUTPUT_SPI puts("initializing to SPI."); TEST_U8G2_DISPLAY(&u8g2, U8G2_R0, u8x8_byte_riotos_hw_spi, u8x8_gpio_and_delay_riotos); u8g2_SetPins(&u8g2, pins, pins_enabled); u8g2_SetDevice(&u8g2, TEST_U8G2_SPI); #endif /* initialize to I2C */ #if TEST_U8G2_OUTPUT == TEST_U8G2_OUTPUT_I2C puts("initializing to I2C."); TEST_U8G2_DISPLAY(&u8g2, U8G2_R0, u8x8_byte_riotos_hw_i2c, u8x8_gpio_and_delay_riotos); u8g2_SetPins(&u8g2, pins, pins_enabled); u8g2_SetDevice(&u8g2, TEST_U8G2_I2C); u8g2_SetI2CAddress(&u8g2, TEST_U8G2_ADDR); #endif /* initialize the display */ puts("Initializing display."); u8g2_InitDisplay(&u8g2); u8g2_SetPowerSave(&u8g2, 0); /* start drawing in a loop */ puts("Drawing on screen."); while (true) { u8g2_FirstPage(&u8g2); do { u8g2_SetDrawColor(&u8g2, 1); u8g2_SetFont(&u8g2, u8g2_font_helvB12_tf); if (screen == 0) { u8g2_DrawStr(&u8g2, 12, 22, "THIS"); } else if (screen == 1) { u8g2_DrawStr(&u8g2, 24, 22, "IS"); } else if (screen == 2) { u8g2_DrawBitmap(&u8g2, 0, 0, 8, 32, logo); } } while (u8g2_NextPage(&u8g2)); #if TEST_U8G2_OUTPUT == TEST_U8G2_OUTPUT_STDOUT /* transfer screen buffer to stdout */ utf8_show(); #endif /* show screen in next iteration */ screen = (screen + 1) % 3; /* sleep a little */ xtimer_sleep(1); } return 0; }
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; }