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; }
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) { 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) { 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; }