How to clear the display before application is terminated?

Description

How to clear the display before application is terminated (and the system is powered down)

What MCU/Processor/Board and compiler are you using?

  • Raspberry PI with 3.5 LCD touch panel
    • USE_FBDEV
    • USE_EVDEV
  • gcc (Raspbian 8.3.0-6+rpi1) 8.3.0

What do you want to achieve?

My GUI contains a button to terminate the program and shutdown the Raspberry PI.
After pressing the confirmation button the screen should be cleared before the the system is going down to indicate that the request is accepted (because the shutdown takes some time).

What have you tried so far?

If the shutdown is requested by the user the function powerOffSystem() is called.

It seems that there is no frame buffer update before the program is terminated or the shutdown process is called and therefore the display shows the last content and not a cleared screen.

So how can I force an update ?

Code to reproduce

void powerOffSystem(void)
{
  // shutdown system
  LV_LOG_INFO("shutdown system due to  user request");
  lv_obj_clean(lv_scr_act());
  lv_obj_invalidate(lv_scr_act()); // no frame buffer update ?
  // system("sudo poweroff");
  exit(0); // same if program is terminated
}

Thanks !

You should call lv_refr_now() to force a screen refresh immediately.

1 Like

perfect - thanks !

lv_refr_now(lv_disp_get_default());

did the trick