ondiiik / micropython-espboards

Micropython clone with support for TWatch 2020
Other
4 stars 0 forks source link

any example for LilyGo-EPD47 #1

Open ChaoticPlex opened 3 years ago

ChaoticPlex commented 3 years ago

@ondiiik Thank you so much for your recent commit on lilygo T5-4.7, I had been searching for this since 4 months ago. I gave it a shot, managed to compile it with the BOARD=LILYGO_T5_EINK_47 parameter (despite there was some issue on the lv_bindings submodule).

however, I am struggling to find a sample code on how to utilize this. I used to work with waveshare-epd for micropython and back then I passed the spi port object during the epd object initialization, do I need to do the same here? any advice is greatly appreciated.

ondiiik commented 3 years ago

Hello,

this port is really fresh and I don't have any examples inside this project yet. However phylosophy is very similar to waveshare variant of display, so native micropython framebuf module is used. Only diference is that there i just one frame buffer as we have just one color (at least in contrast to two colors variants of display) and it is not 1-bit per pixel, but 4-bits per pixel. Also related pins are hardcoded directly inside precompiled drivers (no way to set your own inside python script). You can have a look on this simple example:

import epd
import framebuf

eink = epd.Epd()
fb   = framebuf.FrameBuffer(eink.fb(), eink.WIDTH, eink.HEIGHT, framebuf.GS4_HMSB)

for i in range(0, 260, 20):
    fb.fill_rect(i, i, eink.WIDTH - i * 2, eink.HEIGHT - i * 2, i % 16)

eink.on()
eink.clear()
eink.flush()
eink.power_off()

If you want to see some more complex example, you can have a look on this meteostation project (just note it is also not finished yet and I would expect some troubles caused e.g. by wrong configuration files ... however with correct configuration it works just fine ;-)).

BTW: What was the issue with lv_bindings you met with? My intention was to omit use of lvgl at all for this board variant.

ChaoticPlex commented 3 years ago

Thank you so much for the prompt response. Your example is more than enough, technically, I figured the most of it but checking the code, except I did not know flush() method dumps the content of the frame buffer to the display.

I guess the issue with lv_bindings is due to it being referenced in the manifest.py, despite I once tried to get those submodules manually and place them where they needed to be, after your message I decided to remove the line in the manifest file as you said it is not needed for this board.

I also checked your meteostation repo, It looks pretty darn well-organized code, I really liked checking it out. the way you used EPD over there also helped me to have my head around using the driver correctly. I however could not freeze the PyGame into the firmware as you did, but I will try more today and see how that might work out for me.

ondiiik commented 3 years ago

I however could not freeze the PyGame into the firmware as you did, but I will try more today and see how that might work out for me.

PyGame is just for simulation on PC as it allows me to tune some display stuff way faster and more comfortable. However naming is a bit confusing in this case, let me explain it ;-). Original idea behind is to have some layer allowing me to run code either on PC (in native PC python) or in ESP micropython. In very first varaint I used some QT python libraries for this purposes (therefore there is folder named qt). This part of code was designed to simulate display on PC as normal PC GUI application. After some time I found PyGame as more confortable for this simple task (just show display content), however name of folder remained qt (I shall change it in future). What is running in micropython is not located in 'qt' but in 'micropython' folder. Of course, most of micropython sources are links to qt folder, as they are the same and development is done mostly in qt directory. And to make it more optimized (at least to save piece of RAM and python runtime compiler time), there is third directory called esp32. Here is precompiled micropython bytecode which can be used instead of python scripts. This code is loaded the same way as normal python scripts, but it is already compiled into python bytecode (similarily to frozen modules), so python runtime compiler is not needed to be executed.