Xinyuan-LilyGO / LilyGo-EPD47

GNU General Public License v3.0
379 stars 119 forks source link

MicroPython? #34

Closed astranome closed 2 years ago

astranome commented 3 years ago

Hi, thanks for such a good project! Just out of curiosity - how difficult (or feasible) is to port your driver under Micropython (esp32 in particular)?

martinberlin commented 3 years ago

I made a search and seems not to be any Micropython project so far to support parallel epapers on the ESP32. Would be great to have something but the task seems complicated. If you are interested on how to do it, I highly recommend you to study EPDiy that is the C base library to support this and many other parallel epaper displays.

ondiiik commented 3 years ago

You can try this one. It has been originaly created as port for TWatch-2020, but after some time I also added support for some other boards. Board name do build correct variant for this EPD is LILYGO_T5_EINK_47. There is module epd with some basic support (can be used with framebuffer module in mode GS4_HMSB).

Just note that there is some issue related to EPD and WiFi. I don't know the real reason, but WiFi can not be used together with EPD. I resolve it by 2 staged boot. When board is woken up from deepsleep, thewn WiFi is connected and all needed stuff is loaded into flash (using littlefs to prevent from erly flash demage caused by often write attempt). When all jobs requiring WiFi are done, then board is rebooted and after reboot it print out all needed on display and go to deepsleep.

gmorell commented 2 years ago

@ondiiik Do you have a workaround for the wifi/epd issue or an example of the two stage boot in micropython? I'm curious to see how that works.

ondiiik commented 2 years ago

@ondiiik Do you have a workaround for the wifi/epd issue or an example of the two stage boot in micropython? I'm curious to see how that works.

Unfortunately only workarround I have is to boot twice. First boot activates WiFi and proceed all required communication. Board is then rebooted and results displayed on EPD. After that board goes to deep sleep. To distinguish if you shall activate WiFi or draw on screen you can use machine.reset_cause(). When you get machine.DEEPSLEEP, this means that last boot was about drawing display so now is time for WiFi.

You can have a look here on project building meteostation over this board.

Just one more note: As there is almost no way how to write reasonable amount of data (received by WiFi) which survives reboot, they have to be written into file system. This of course may drain your on board FLASH as this may happen quite often. Therefore I would suggest to use littlefs instead of FAT as it does not drain yor flash that much (and it is even faster in IO operation). Look here to see how to make littlefs on your ESP32 micropython based device.

LilyGO commented 2 years ago

Micropython is currently supported, please visit lilygo-micropython.

This issus will be closed, all about micropython, please discuss at lilygo-micropython.