Skip to content

Commit 576e935

Browse files
committed
2 parents 172411c + 86bc50a commit 576e935

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

Adafruit_ILI9341.cpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -302,13 +302,24 @@ void Adafruit_ILI9341::setScrollMargins(uint16_t top, uint16_t bottom) {
302302
/**************************************************************************/
303303
void Adafruit_ILI9341::setAddrWindow(uint16_t x1, uint16_t y1, uint16_t w,
304304
uint16_t h) {
305+
static uint16_t old_x1 = 0xffff, old_x2 = 0xffff;
306+
static uint16_t old_y1 = 0xffff, old_y2 = 0xffff;
307+
305308
uint16_t x2 = (x1 + w - 1), y2 = (y1 + h - 1);
306-
writeCommand(ILI9341_CASET); // Column address set
307-
SPI_WRITE16(x1);
308-
SPI_WRITE16(x2);
309-
writeCommand(ILI9341_PASET); // Row address set
310-
SPI_WRITE16(y1);
311-
SPI_WRITE16(y2);
309+
if (x1 != old_x1 || x2 != old_x2) {
310+
writeCommand(ILI9341_CASET); // Column address set
311+
SPI_WRITE16(x1);
312+
SPI_WRITE16(x2);
313+
old_x1 = x1;
314+
old_x2 = x2;
315+
}
316+
if (y1 != old_y1 || y2 != old_y2) {
317+
writeCommand(ILI9341_PASET); // Row address set
318+
SPI_WRITE16(y1);
319+
SPI_WRITE16(y2);
320+
old_y1 = y1;
321+
old_y2 = y2;
322+
}
312323
writeCommand(ILI9341_RAMWR); // Write to RAM
313324
}
314325

0 commit comments

Comments
 (0)