I got everything working the way I like so far: partial updates, sensors updating only when data arrives and stuff like that, but when I try to add deep sleep, the display seems to reset (flashing and erasing) every time it wakes up. I don’t want that, I want it to reset/full update only every so many updates, with deep sleep in between.
I’m not sure how deep sleep actually works. It is my understanding that it effectively shuts down and boots up every deep sleep cycle, so the on_shutdown and on_boot are called every time. That would also mean that all objects are recreated from scratch. It’s not some kind of PC hibernate where the RAM is written to disk and then reloaded, right?
That means setup() is called each wake up and judging from the code, that would call setup_pins_(), which will in turn call reset_(), explaining the observed behaviour. Or am I missing something?
Not setting the reset_pin (if that’s possible) might avoid this, but you would not be able to reset ever…
I also noticed a deep_sleep() function. Is that something that you need to call yourself (in on_shutdown), or is that somehow done automagically?
I also noticed the at_update_ property, which is initialized to 0 and works together with the full_update_every flag. You get a full update when at_update_ is 0, which is incremented each update and then modulo of full_update_every_. So if the objects are re-initialized every wake-up they will do a full update every time…
Is what I’m trying to achieve not possible, or am I missing something obvious?
The deep sleep component does indeed cause a full shutdown and boot each cycle.
epaper screens have 2 sleep states: normal sleep, and deep sleep. In normal sleep, the latest screen data is retained, and a reset is not needed, but more power is required (about 20µA). In real deep sleep, the data is lost and a full reset is needed, but less power is consumed (about 5µA).
The deep_sleep() function of the waveshare epaper is automatically called from the on_safe_shutdown hook in the waveshare component, which in turn is called from the App.run_safe_shutdown_hooks(), being called when the deep sleep component goes to sleep.
So my epaper display is always put into deep sleep when the ESP goes into deep sleep.
For use cases where the screen is very rarely updated, that might be the best option, but for my application (a thermostat) it would be nice if one could chose that.
Maybe I’ll have a stab at getting it to behave the way I want it, but that will require some experimentation, it seems!
No, that didn’t seem to work at the time I was implementing this with my ePaper (TTGO T5 2.13 inch with DKE display). I managed to get it to somewhat do what I like by changing the code a bit and saving the number of updates to flash.
If I find some time in the near future, I’ll revisit this and check if I maybe overlooked something.
The problem I have now is that the first update seems to take too long after wakeup, which is not ideal for a thermostat.