Let's speed up DrawLine and DrawPixel?
-
The esp32 is a beast and can fill byte arrays in a blink and the ILI is a fast controller when sent tons of data in one batch, as proof is the arkanoid example, and all other bitmap based M5 games.
So I'm thinking that the Display.cpp library is doing things inefficiently. DrawPixel is writing to the SPI (hardware?) byte by byte as we send them.
So a better way to feed the screen would be to batch commands.
Display.BeginCommand();
do the draw thingies and then
Display.Dispatch()
so DrawPixel would only fill a static array and the Dispatch command sends that to the ILI frame buffer.
There are libraries for arduino that do just that.
And if I know it, someone else already ported it over to M5. Google not collaborating, anyone has seen that? -
It looks like someone already did it
https://github.com/Bodmer/TFT_eSPI -
@daslolo Yep. And I managed to integrate this to the M5Stack library. I am doing tests, but so far so good. I've run a few modified sketches without issue. The TFT_ArcFill example is quite impressive.
Replacing the Display.h/.cpp files with the TFT_eSPI library was pretty easy. The Display library has a couple of M5-specific functions, but once added to the driver, everything works well:
void setBrightness(uint8_t); //Specific to M5Stack void sleep(); //Specific to M5Stack
There may be others, I'll see what happens when I compile the non-touch examples.
-
@dda 在 Let's speed up DrawLine and DrawPixel? 中说:
Yep. And I managed to integrate this to the M5Stack library. I am doing tests, but so far so good. I've run a few modified sketches without issue. The TFT_ArcFill example is quite impressive.
.
.
.
There may be others, I'll see what happens when I compile the non-touch examples.TFT_eSPI is the best lib, we added m5stack support some time ago:
https://github.com/Bodmer/TFT_eSPI/pull/88
btw, m5stack display lib based on the early version of TFT_eSPI
but since then, TFT_eSPI has developed a LOT!!!P.S. for advanced GUI we also added m5stack support for GUIslice:
https://github.com/ImpulseAdventure/GUIslice/pull/34
which uses TFT_eSPI as display driver. -
-
@jimit Now all we need is to have that officially included in the M5Stack library.
-
@dda - good point!
-
@dda how much faster is it?
-
I compiled the first example after making the necessary changes doe the M5Stack without errors. However, it would not load onto my M5Stack.
-
@pkourany inside user_setup.h comment out the generic setups and uncomment m5. Then most examples work.
Result: same performances as m5 lib.
EDIT: even with SPI_FREQUENCY at 80,000,000 ... weird -
Bodmer wrote a nice article on this https://github.com/Bodmer/TFT_eSPI/issues/121#issuecomment-380245040
When un-commenting Display.h/#define SPI_FREQUENCY 40000000, fillscreen nearly doubles.
80M doesn't work on some M5.