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(); }
/* this is a helper function for the U8X8_MSG_DISPLAY_INIT function. It can be called within the display callback function to carry out the usual standard tasks. */ void u8x8_d_helper_display_init(u8x8_t *u8x8) { /* 2) apply port directions to the GPIO lines and apply default values for the IO lines*/ u8x8_gpio_Init(u8x8); u8x8_cad_Init(u8x8); /* 3) do reset */ u8x8_gpio_SetReset(u8x8, 1); u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_MILLI, u8x8->display_info->reset_pulse_width_ms); u8x8_gpio_SetReset(u8x8, 0); u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_MILLI, u8x8->display_info->reset_pulse_width_ms); u8x8_gpio_SetReset(u8x8, 1); u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_MILLI, u8x8->display_info->post_reset_wait_ms); }