mirror of
https://github.com/adafruit/Adafruit_ILI9341.git
synced 2026-10-26 22:10:38 +00:00
Optimized setAddrWindow() to only set the axis which changes
This commit is contained in:
1 parent
655e7494ae
commit
7e17a48754
1 file changed
+15
-6
+15
-6
@@ -302,13 +302,22 @@ void Adafruit_ILI9341::setScrollMargins(uint16_t top, uint16_t bottom) {
|
||||
/**************************************************************************/
|
||||
void Adafruit_ILI9341::setAddrWindow(uint16_t x1, uint16_t y1, uint16_t w,
|
||||
uint16_t h) {
|
||||
static uint16_t old_x1 = 0xffff, old_x2 = 0xffff;
|
||||
static uint16_t old_y1 = 0xffff, old_y2 = 0xffff;
|
||||
|
||||
uint16_t x2 = (x1 + w - 1), y2 = (y1 + h - 1);
|
||||
writeCommand(ILI9341_CASET); // Column address set
|
||||
SPI_WRITE16(x1);
|
||||
SPI_WRITE16(x2);
|
||||
writeCommand(ILI9341_PASET); // Row address set
|
||||
SPI_WRITE16(y1);
|
||||
SPI_WRITE16(y2);
|
||||
if (x1 != old_x1 || x2 != old_x2) {
|
||||
writeCommand(ILI9341_CASET); // Column address set
|
||||
SPI_WRITE16(x1);
|
||||
SPI_WRITE16(x2);
|
||||
old_x1 = x1; old_x2 = x2;
|
||||
}
|
||||
if (y1 != old_y1 || y2 != old_y2) {
|
||||
writeCommand(ILI9341_PASET); // Row address set
|
||||
SPI_WRITE16(y1);
|
||||
SPI_WRITE16(y2);
|
||||
old_y1 = y1; old_y2 = y2;
|
||||
}
|
||||
writeCommand(ILI9341_RAMWR); // Write to RAM
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user