Resume program at position after sleep mode?

  • Hi,
    I have a rather big program that has quite a few functions. I would also like to save some battery and therefore I want to send my M5Stack into sleep mode.

    Program start;
    execute SETUP() once: function A(), function B(), C();

    LOOP(): function D(), function E(), START HERE SLEEP.

    When sleep is over, my program starts again at the beginning executing the SETUP() function. Is there any way to resume my program where it stopped? Like with the next line of code or with the next function? I do not want to start again at setup().

    LOOP(): function D(), function E(), START HERE SLEEP; Wake up from sleep; Resume with function F(), function G(). Start again with LOOP() function D(), E(), sleep,...

  • light sleep should do the job, but I have to do some testing.

    Are there any data or "connections" lost after you wake up from light sleep?