ulisp-esp icon indicating copy to clipboard operation
ulisp-esp copied to clipboard

using esp32 sleep function

Open dragoncoder047 opened this issue 1 year ago • 2 comments

Right now the (sleep) function doesn't actually put the CPU to sleep, it just burns time in a delay() loop.

However, the ESP32 does have a light-sleep function that preserves the state - care to try it out?

esp_sleep_enable_timer_wakeup(secs * 1000000UL);
esp_light_sleep_start();

Also, I might add that maybe you can allow (sleep) to be called with no arguments, which means indefinite sleep -- on esp32 it just directly calls esp_light_sleep_start(), on AVR it calls sleep_enable(); sleep_cpu(); without enabling the watchdog for interrupts, etc.

dragoncoder047 avatar Apr 27 '23 15:04 dragoncoder047

Yes, the sleep function puts the CPU to sleep on AVR and some ARM platforms, but I couldn't work out how to do it on the ESP32.

Also, I have done what you suggested on AVR - (sleep) goes to sleep for ever, and you could arrange an interrupt to wake you up.

I'll try implementing it on ESP32 as you've suggested.

technoblogy avatar Apr 27 '23 16:04 technoblogy

Haven't done this yet - sorry!

technoblogy avatar Jun 30 '23 10:06 technoblogy