How to use 4.2" 400x300 eink display using espidf framework instead of arduino framework with an esp-32 s3

Hello,

I bought the WeAct Studio eink screen I mention on the title, from AliExpress, but now I see that all the official examples in github use the arduino framework, and as long as I want to use esp-idf for my whole project, I wonder if you can give me a hand about the steps I should do to work with this e-ink model.

By the way, I develop with vsc and a project I have created with the PlatformIO addon choosing to work with the esp-idf framework.

My initial intention is to learn esp-idf instead of using the arduino fw as the 1st one is the “pro”, for serious people, you know.

I know the arduino fw also has the library GXEPD2 so I’d like an equivalent but for esp-idf.

Thanks for your help,

Roger

If you want to stay with pure ESP-IDF and not have “Arduino-ESP32 core on top of ESP-IDF”, then you need a driver for that epaper display in ESP-IDF.

Reading

the 4.2" versions seem to be using the SSD1683 driver chip.

The ESP-IDF component https://components.espressif.com/components/antunesls/despi_c02_driver/versions/0.0.2/readme seems to implement that. (Original repo: https://github.com/antunesls/esp32-despi_co02)

You can add ESP-IDF components to your PlatformIO-based ESP-IDF project by putting the dependencies in the idf_component.yml file, see e.g. here.

Hello,

Thank you! I will test this asap. It seems it may work for my screen!

Best regards,

Roger

I am looking at the driver, and I can see examples to draw text and partial refresh

Forgive my ignorance: what should I use to draw graphics, images and use fonts? Maybe a library like LVGL?

Or … would it be better to include the arduino core to my project to be able to use GxEPD2_BW?

I would like to implement it as it would be in a professional environment, and not doing a frankenstein approach caused to not having a global understanding.

Thanks again,

Roger

The above mentioned esp32-despi_co02 repo gives you access to the bare “push this framebuffer (or partial framebuffer) onto the epaper display”. It only has one hardcoded font file and no graphic shapes function available.

To fill that gap, you can use one of various libraries.

LVGL is definitely available and integrable for ESP-IDF (see https://lvgl.io/docs/open/integration/chip_vendors/espressif/add_lvgl_to_esp32_idf_project). It has various function for user interface and graphics primitives. You could integrate with your ePaper driver as well, so that it automatically pushes the finished framebuffer onto the display. LVGL is a “big” project though, so I also expect very large code and RAM sizes. But if you want a complex UI anyway, it might be what you need.

A more lightweight alternative is the u8g2. You’d have to create a dummy u8g2 device that has a specific framebuffer but then you can use its graphics primitives and vast (and extensible) list of available fonts. It’s been added to the ESP-IDF registry at https://components.espressif.com/components/nixy4/u8g2/. For a reference code, see u8g2 + epaper reference ESP-IDF · GitHub.

For converting image files to displayable images, you can already use the driver as-is with the partial screen update function and converters like https://javl.github.io/image2cpp/. Just upload an image, set the output type to “Arduino core, single bitmap” and draw mode of “Horizontal - 1 bit per pixel” and you get the byte array for the image that you can put into the partial draw image function at together with the desired location and dimensions of the image. (Notes: ESP-IDF has no PROGMEM so just delete that in the output code. Also try “Swap bits in byte” if the order seems swapped.).

WOW! That was an EXCELLENT ANSWER!

Thank you for all your interest you put in it, and the very detailed instructions; As long as I have an esp32 s3, I will try the first option if the ram amount is enough for my project.

Best regards!

Roger