https://toitlang.org/ logo
Support for ESP32 Power Management
# help
i
I was wondering if Toit does support the power management features implemented in esp-idf? https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/power_management.html For battery-powered devices, this helps keep power consumption minimal.
f
we found that the only option to run on battery is to go to deep-sleep as often as possible. If your use-case is different, let us know, and I can see if we should expose the power-management functions.
i
Yes, we go to deep-sleep as often as possible, but when using esp-idf framework, we also enable pm to save few more milliamps when esp is running
f
We are basically talking about the
esp_pm_configure
function. Right? So if I add a
pm_configure max_freq_mhz min_freq_mhz light_sleep_enable
function that would be enough. Or do you need more of the API?
i
Yes, this would be great. I also use the
esp_pm_lock_*
api functions to prevent entering light sleep, but for now I could simply use
esp_pm_configure
to disable automatic light sleep when needed.
f
I will try to find some time to expose the functions then. Feel free to ping me from time to time
i
Thanks a lot!
f
I just wrote a PR that exposes the config functions.
Adding support for the locks is also relatively easy, but would take me a few minutes. For now I will leave it unimplemented, but ping us, if you start needing it.
i
Great, thanks a lot! I will try probably next week and report back here.
f
Couldn't resist... Now also added support for the lock class. All still under review, but I hope it will be committed today and that we will do a new release soon.