I'm using the RA8875 display driver board and a 5.0" 800x480 TFT LCD display from Adafruit. Using an Arduino Due and interfacing with the display using SPI.
I'm trying to generate a heat map of sorts on the LCD using X and Y data points that correlate to a pixel/region of screen and an analog input that correlates to a certain color.
As I have the code right now - I am using the fillRoundRect command to fill an area of the screen with a color but if the Due recieves the same X/Y data or close to it - I will get overlapping rectangles or just covering up of the previous rectangle.
I tried to resolve this by declaring previousX and previousY variables but it didn't work. See below/attached for the code displaying the data.
Is there a way to instruct the LCD/RA8875 to not overwrite pixels that it has already colored in/displayed something on?
Once a portion of the screen has been filled in - I want it to be permanent.
Any help you can provide is greatly appreciated. Thank you
void DisplayData() {
screenX = Xaverage * Xratio;
screenY = 480 - (Yaverage * Yratio);
if (y >= 0 && screenY < 480 && x >= 0 && screenX <= 800) {
if (previousX != screenX && previousY != screenY) {
previousX = screenX;
previousY = screenY;
if (average > 2000) {
tft.fillRoundRect(screenX, screenY, 20, 20, 5, RA8875_WHITE);
}
if (1900 < average && average <= 2000) {
tft.fillRoundRect(screenX, screenY, 20, 20, 5, RA8875_YELLOW);
}
if (1600 < average && average <= 1900 ) {
tft.fillRoundRect(screenX, screenY, 20, 20, 5, RA8875_ORANGE);
}
if (1200 < average && average <= 1600) {
tft.fillRoundRect(screenX, screenY, 20, 20, 5, RA8875_RED);
}
if (900 < average && average <= 1200) {
tft.fillRoundRect(screenX, screenY, 20, 20, 5, RA8875_PURPLE);
}
if (200 < average && average <= 900) {
tft.fillRoundRect(screenX, screenY, 20, 20, 5, RA8875_NAVY);
}
if (average <= 200) {
tft.fillRoundRect(screenX, screenY, 20, 20, 5, RA8875_BLACK);
}
}
}
}
DisplayData.ino (1.13 KB)