Since January I have been thinking about how to reduce the flashing effect of redrawing characters on the Adafruit 2.2" TFT display running off of an Arduino. Initially I thought I was doing something wrong but then I saw that other projects experience the same slow screen redraw performance. This post isn't about rewriting/optimizing the ILI9340 library that talks to the display. I'm not a good enough programmer to even think about digging into that code. Also I don't think it really is a problem with the library or the display itself. I've seen videos with this display hooked up to a Raspberry Pi smoothly playing video files. I suspect the limitation is the CPU and/or RAM of the Arduino. For my speedometer project I wanted to use an Arduino because it starts up almost instantly and I don't have to worry about shutting it down which is not the case with a Raspberry Pi.
So my goal was to optimize the refresh rate by reducing the amount of screen redraw to the smallest amount possible. To do this I first draw the static elements on the screen (the red box and the mph text). These are never redrawn. Redrawing static items causes a flashing effect. Then the speed value is only updated if it changes. When it does change only digits that have changed are redrawn. For example say the speed is 35 mph and then on the next loop the speed is 36 mph. The 5 would be drawn over with black and then the 6 is drawn in white. This performs the least amount of screen drawing possible.
Here is a video of the progress so far. The code is below the video.
Here is the code
Hello,
ReplyDeleteIn case you are still interested, I "re-mixed" (re-wrote) the Adafruit GFX library and some drivers (including IL9341 & IL9342) to squeeze out any wasted cycles (there were a lot). My "PDQ" version is sketch compatible with Adafruit GFX (with a tiny change to init), so you might give it a try (should be "drop in"). All the code and an example sketch/benchmark is at https://github.com/XarkLabs/PDQ_GFX_Libs. You can see a speedup of about 3.5x to 13x (depending on the primitive). Smaller code size too.
Enjoy,
Xark
why i got this im new in arduino Documents\Arduino\sketch_apr05b\sketch_apr05b.ino:2:26: fatal error: Adafruit_GFX.h: No such file or directory
ReplyDelete#include "Adafruit_GFX.h"
^
compilation terminated.
exit status 1
Error de compilaciĆ³n
I think you just need to add the Adafruit-GFX library to your Aduino IDE. https://github.com/adafruit/Adafruit-GFX-Library
Deleteit does not work i am also having the same issues
ReplyDeleteThanks for posting this. Your example saved me tons of time. I'm putting together a display for my car that will show metrics that are available on the OBDII bus. (I'm using a Freematics OBDII Arduino interface). Thanks again!
ReplyDeletetft.setTextColor (textColor, BLACK);
ReplyDeleteno coding necessary...
:)