Skip to content

Commit

Permalink
Merge pull request #64 from bitbank2/master
Browse files Browse the repository at this point in the history
Optimized setAddrWindow() to only set the axis which changes
  • Loading branch information
makermelissa authored Jun 2, 2022
2 parents 172411c + 576e935 commit cf31049
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions Adafruit_ILI9341.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,13 +302,24 @@ 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
}

Expand Down

0 comments on commit cf31049

Please sign in to comment.