void gui_Init(u8g2_t *u8g2, uint8_t is_por) { if ( is_por == 0 ) { /* not a POR reset, so load current values */ gui_LoadData(); /* do NOT init the display, otherwise there will be some flicker visible */ /* however, the GPIO subsystem still has to be setup, so call the other init procedures */ /* this acts like a warm start for the display */ /* the display setup code for the display is NOT send */ u8x8_gpio_Init(u8g2_GetU8x8(u8g2)); u8x8_cad_Init(u8g2_GetU8x8(u8g2)); u8x8_gpio_SetReset(u8g2_GetU8x8(u8g2), 1); //u8g2_InitDisplay(u8g2); //u8x8_d_helper_display_init(u8g2_GetU8x8(u8g2)); // u8g2_SetPowerSave(u8g2, 0); // this will be done later } else { /* POR reset, so do NOT load any values (they will be 0 in the best case) */ /* instead do a proper reset of the display */ // u8x8_InitDisplay(u8g2_GetU8x8(&u8g2)); u8g2_InitDisplay(u8g2); // u8x8_SetPowerSave(u8g2_GetU8x8(&u8g2), 0); u8g2_SetPowerSave(u8g2, 0); } menu_Init(&gui_menu, u8g2); gui_SignalTimeChange(); }
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_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; }