pictographer
Well-known member
The readRect() and writeRect() functions produce a slight color shift. I would assume that reading a rectangular region and writing it back to the exact same location should not change the display. If you look closely at the display after running the program below, you'll see that the checkerboard pattern is subtly messed up. Some of the squares are split into a lighter part resulting from readRect/writeRect and a darker part with the correct color.
My first guess is that this is a result of the way the colors are packed into 16-bit integers. I don't know whether the problem occurs during reading or writing. Should be possible to figure it out by printing the color values before and after.
Here's the test case. I observed this on a T3.0 running Arduino 1.0.6 and Teensyduino 1.21-test4.
By the way, the copyright year on the Teensy Loader 'About' window probably ought to be updated to a range, e.g. "Copyright © 2013-2015, PJRC.COM, LLC".
The photo above shows the issue. Sorry the illustration is so subtle. The white lines point to the 50x50 squares that are color shifted but shouldn't be. The effect is easiest to see at the perimeter of these squares where the checkerboard pattern isn't quite right. All of the 10x10 squares should be a single color.
My first guess is that this is a result of the way the colors are packed into 16-bit integers. I don't know whether the problem occurs during reading or writing. Should be possible to figure it out by printing the color values before and after.
Here's the test case. I observed this on a T3.0 running Arduino 1.0.6 and Teensyduino 1.21-test4.
By the way, the copyright year on the Teensy Loader 'About' window probably ought to be updated to a range, e.g. "Copyright © 2013-2015, PJRC.COM, LLC".
Code:
#include "SPI.h"
#include "ILI9341_t3.h"
ILI9341_t3 d = ILI9341_t3(10, 9);
uint16_t buf[50 * 50];
void drawBackground() {
d.fillScreen(ILI9341_BLACK);
for (int x = 0; x < d.width(); x += 20) {
for (int y = 0; y < d.height(); y += 20) {
d.fillRect(x, y, 10, 10, d.color565(31, 31+x, 31+y));
d.fillRect(x + 10, y + 10, 10, 10, d.color565(31+x, 31+y, 31));
}
}
for (int x = 15; x < d.width(); x += 100) {
d.readRect(x, 55, 50, 50, buf);
// The following line should not change the display because it
// simply copies a region back from whence it came. The colors are
// altered slightly.
d.writeRect(x, 55, 50, 50, buf);
d.drawLine(2, 30, x, 54, ILI9341_WHITE);
}
for (int i = 0; i < 2; ++i) {
if (i == 0) {
d.setTextColor(ILI9341_BLACK, ILI9341_BLACK);
} else {
d.setTextColor(ILI9341_WHITE, ILI9341_WHITE);
}
d.setCursor(1 - i, 5 - i);
d.print("Every square should be a single color\n"
"but readRect/writeRect changes the colors,\n"
"so some of the squares are split.");
}
}
void setup() {
d.begin();
d.setTextColor(ILI9341_WHITE, ILI9341_WHITE);
d.setRotation(1);
drawBackground();
}
void loop() {}
The photo above shows the issue. Sorry the illustration is so subtle. The white lines point to the 50x50 squares that are color shifted but shouldn't be. The effect is easiest to see at the perimeter of these squares where the checkerboard pattern isn't quite right. All of the 10x10 squares should be a single color.