I have a 2.8 inch TFT LCD from Adafruit driven by an ILI9341. To draw on the LCD, I use the commands 0x2A
to set the width, 0x2B
to set the height, and 0x2C
to color each pixel (I2C). My problem is that I currently draw the background as a rectangle, and then each rectangle required. This creates a displeasing look since the colors start to mix and create disturbing, angled lines between the smaller rectangles. These are the functions I use to draw:
void drawRectangle(long sX, long sY, long eX, long eY, uint16_t clr) {
send32bitData(0x2A, (sX << 16) | eX);
send32bitData(0x2B, (sY << 16) | eY);
oneColor(clr, (eX - sX + 1) * (eY - sY + 1));
}
void oneColor(uint16_t clr, long area) {
uint8_t hi = clr >> 8;
uint8_t lo = clr;
uint8_t dHi = clr >> 6, bHi = clr >> 14, dLo = clr << 2, bLo = clr >> 6;
sendCommand(0x2C, true);
PORTC = 0x6;
for (long i = area; i--; i > 0) {
PORTC = 0x6;
PORTD = dHi;
PORTB = bHi;
PORTC = 0x2;
PORTC = 0x6;
PORTD = dLo;
PORTB = bLo;
PORTC = 0x2;
}
PORTC = 0x7;
}
Here's a video of that line. I'm assuming that I'm drawing wrong. I'd like to keep a huge array with colors for each pixel, but I have an Arduino Uno that 2048 bytes of variable space. If I had that array, then I would draw one rectangle for the whole screen and send each color to the memory. One thing that worked was drawing extremely slow. But, that's slow... I want to draw at ~70 fps while keeping each frame smooth.