Caveat: I'm not software or electrical engineer, so my knowledge is very basic.
The setup:
Teensy 4.0, 2.8" Touch TFT from PJRC, ILI9341_t3n library
The problem:
Updating the entire screen upon every change results in flicker, rendering the GUI almost unusable. I think this is obvious to others and well known. However, I haven't found any solutions other than to just write tons of code to re-draw what was changed. That's where the code blows up in complexity and is really hard for me to manage since my GUI has many elements.
My main question before the details:
Is there an easy-to-implement method to only write what was changed in the frame but also be able to use existing library methods like tft.drawRect()? I think the Teensy 4.0 has the ram to deal with brute force ways of doing it like reading the entire pixel array after creating the primitive shapes/text, then only write what's changed based on a comparison to another array.
I can't find much info (or at least info written in terms I understand). I assume it's because the microcontrollers until recently haven't had the RAM to do this? I'm using Kurt's ILI9341_t3n library which has "frame buffer" features, but I don't understand what they do just by reading the code and I can't follow the forums posts (too in the weeds/technical and/or abbreviated). I don't know how frame buffering or direct memory access works, so maybe I'm close to an answer with the work people are doing here?
If this is already doable, would someone be willing to write up a quick guide on how to implement something basic, like moving a rectangle across the screen?
Insignificant Details:
My latest idea was to see if I could just store the entire new frame in a 320x240 array of RGB565 color values and compare it to an array of the previous frame's values. Then, just draw what changed. This takes >380kb of the RAM, but it does work smoothly. However, I'm only actually moving a single pixel around with this because I don't know how to translate any other primitives (rectangles, circles, text...) into the array of pixels. Is there some way I can intercept the tft.drawRect(...); methods to put those into an array so I can manually write the pixels to the screen instead? There must be some simple way to do this that I'm just not seeing.
I'm hoping Kurt's library already can do this, but I'm just not understanding how to implement it.
Here's my hacky array comparison method that's a resource hog but works smoothly with a single-pixel animation:
The setup:
Teensy 4.0, 2.8" Touch TFT from PJRC, ILI9341_t3n library
The problem:
Updating the entire screen upon every change results in flicker, rendering the GUI almost unusable. I think this is obvious to others and well known. However, I haven't found any solutions other than to just write tons of code to re-draw what was changed. That's where the code blows up in complexity and is really hard for me to manage since my GUI has many elements.
My main question before the details:
Is there an easy-to-implement method to only write what was changed in the frame but also be able to use existing library methods like tft.drawRect()? I think the Teensy 4.0 has the ram to deal with brute force ways of doing it like reading the entire pixel array after creating the primitive shapes/text, then only write what's changed based on a comparison to another array.
I can't find much info (or at least info written in terms I understand). I assume it's because the microcontrollers until recently haven't had the RAM to do this? I'm using Kurt's ILI9341_t3n library which has "frame buffer" features, but I don't understand what they do just by reading the code and I can't follow the forums posts (too in the weeds/technical and/or abbreviated). I don't know how frame buffering or direct memory access works, so maybe I'm close to an answer with the work people are doing here?
If this is already doable, would someone be willing to write up a quick guide on how to implement something basic, like moving a rectangle across the screen?
Insignificant Details:
My latest idea was to see if I could just store the entire new frame in a 320x240 array of RGB565 color values and compare it to an array of the previous frame's values. Then, just draw what changed. This takes >380kb of the RAM, but it does work smoothly. However, I'm only actually moving a single pixel around with this because I don't know how to translate any other primitives (rectangles, circles, text...) into the array of pixels. Is there some way I can intercept the tft.drawRect(...); methods to put those into an array so I can manually write the pixels to the screen instead? There must be some simple way to do this that I'm just not seeing.
I'm hoping Kurt's library already can do this, but I'm just not understanding how to implement it.
Here's my hacky array comparison method that's a resource hog but works smoothly with a single-pixel animation:
Code:
void refresh_tft() {
for (int i = 0; i < 240; i++) {
for (int j = 0; j < 320; j++) {
if(old_pixel_arr[j][i] != new_pixel_arr[j][i]){
tft.drawPixel(j,i,new_pixel_arr[j][i]);
}
}
}
for (int i = 0; i < 240; i++) {
for (int j = 0; j < 320; j++) {
old_pixel_arr[j][i] = new_pixel_arr[j][i];
}
}
}