2D graphic lib for ESP-IDF ?

nmenoux
Posts: 1
Joined: Mon Jan 23, 2017 5:48 pm

2D graphic lib for ESP-IDF ?

Postby nmenoux » Mon Jan 23, 2017 6:00 pm

Hi guys,

I'm currently developing some ESP-IDF code to drive an epaper display (GDE021A1) based on the spi_master for SPI communications. It seems to work as I could draw 'something' on screen but I need some basic 2D graphic library for working on an array buffer (lines, .., draw text) before pushing it to the the display through SPI commands.

If you have any graphic libs you've already used with ESP-IDF, I would be delighted to dive in :-)

Thanks for your help,

Nicolas

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: 2D graphic lib for ESP-IDF ?

Postby kolban » Tue Jan 24, 2017 1:18 am

Howdy,
I for one have been using the Adafruit-GFX-Library running on the ESP32 to achieve a number of driver displays ... see:

https://github.com/adafruit/Adafruit-GFX-Library
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

peter_
Posts: 13
Joined: Tue Jan 31, 2017 9:57 am

Re: 2D graphic lib for ESP-IDF ?

Postby peter_ » Sat Feb 04, 2017 9:04 pm

Hello Kolban,
do you have ported the Adafruit GFX Lib to esp-idf? If yes can you post it? It would save me some redundant work.
Regards
Peter

User avatar
fasani
Posts: 197
Joined: Wed Jan 30, 2019 12:00 pm
Location: Barcelona
Contact:

Re: 2D graphic lib for ESP-IDF ?

Postby fasani » Mon May 18, 2020 11:42 am

I'm also interested on this topic, to get both Adafruit GFX and fonts working, in a Epaper new component I'm trying to make.
https://github.com/martinberlin/cale-id ... /README.md

I just started with IDF a few months ago. My idea is to make something the way GxEPD is doing on espressif32-arduino but only using IDF (No arduino as a component)
This is also a nice example made in IDF 2.0:

https://github.com/loboris/ESP32_ePaper_example

I could see functions to draw lines and shapes in the library. But I could not compile it since I want to stick to 4.0 now.
epdiy collaborator | http://fasani.de Fan of Espressif MCUs and electronic design

User avatar
fasani
Posts: 197
Joined: Wed Jan 30, 2019 12:00 pm
Location: Barcelona
Contact:

Re: 2D graphic lib for ESP-IDF ?

Postby fasani » Mon May 25, 2020 10:43 am

Yesterday night I found some time to port this library and make the Fonts part work in IDF.
This is part of my intent to port an existing Epaper espressif32-arduino Firmware into ESP-IDF. You can find it here and unless I'm missing something it can be already added as a git submodule in existing projects.

https://github.com/martinberlin/Adafrui ... ry-ESP-IDF

When linking a component like this from other components do not forget to add in the CMakeLists file:

idf_component_register(SRCS ${srcs}
REQUIRES "Adafruit-GFX"
)

So your component can extend this class. Soon I will add an Epaper driver example implementing this if someone shows interest.

Please be aware that I'm quite new to C++ OOP (About 1 and half years experience)
So my classes and OOP may not be perfect. Other than that Adafruit uses the Print namespace of Arduino, due to that, I was forced to add some classes that I didn't wanted to add. So please check the README before using this.
Is working for geometries and print/println tests this are my demo images
Attachments
epaper_demo1.jpeg
epaper_demo1.jpeg (78.18 KiB) Viewed 8553 times
epdiy collaborator | http://fasani.de Fan of Espressif MCUs and electronic design

tuupola
Posts: 7
Joined: Fri Apr 20, 2018 3:49 am

Re: 2D graphic lib for ESP-IDF ?

Postby tuupola » Mon May 25, 2020 2:38 pm

If you are looking for library to draw graphical primitives and want to get rid of Arduino stuff check HAGL. It is still work in progress but API should be 80% stable. You need to provide it with HAL which has putpixel function for your e-paper display.

https://github.com/tuupola/hagl

Mika Tuupola
https://appelsiini.net/

User avatar
fasani
Posts: 197
Joined: Wed Jan 30, 2019 12:00 pm
Location: Barcelona
Contact:

Re: 2D graphic lib for ESP-IDF ?

Postby fasani » Tue May 26, 2020 5:44 am

Nice one! You just have one star more :)

Please note that my fork does not include Arduino.h at all. I just had to include Print & Printable headers since Adafruit extends them.
But could be changed if possibly by someone's pull request that understands better than me how a GFX library works.
My assumption is that Adafruit GFX extends Print just to re-use the print/println/printf methods but it would be a lot nicer if that methods are directly inside the library.

Actually I could add just print / println as methods and get rid of Print and Printable for the good ;)
This methods should just do a for...loop and send each char to the Adafruit_GFX write function:

Code: Select all

size_t Epd::write(uint8_t v){
  Adafruit_GFX::write(v);
  return 1;
}

void Epd::print(const std::string& text){
   for(auto c : text) {
     write(uint8_t(c));
   }
}

void Epd::println(const std::string& text){
   for(auto c : text) {
     write(uint8_t(c));
   }
   write(10); // newline
}
epdiy collaborator | http://fasani.de Fan of Espressif MCUs and electronic design

Who is online

Users browsing this forum: No registered users and 186 guests