Execute code before callback is triggerd to play sound

For a reason that its too late to fix now i have implemented sound in my GUI by changing a global extern variable value, using an adapted lvgl demo (lv_printer_demo) written in c++ which then triggers a condition in the loop in arduino c file that plays a sound. So basically the code between the c and c++ files communicates by these variable changes.

The problem is that there is now huge delay until the sound is played when a callback is triggered through a button, especially if there in an animation. Is there a way of executing a block of code before the callback is triggered that would allow the code in main loop to called (an play a sound) and then go into the callback code as usual?

Not really. The right approach is to add this block of code to the beginning of the callback. :slightly_smiling_face: