KurtE / ILI9341_t3n

Extended ILI9341_T3 library (Teensy) including all SPI buses, Frame buffer, plus
MIT License
51 stars 23 forks source link

setscrollmargins #40

Closed CorBer closed 3 years ago

CorBer commented 3 years ago

The current calculation (thanks for adding this) follows the adafruit example which has a flaw:

uint16_t middle = _height - top + bottom; The ILI9341 expects 3 numbers following the 0x33 command, those numbers together should equal the displayheight (320pixels). So uint16_t middle=_height-top-bottom;

KurtE commented 3 years ago

You are right... See what happens when I take the Adafruit stuff without thinking about it ;)

void Adafruit_ILI9341::setScrollMargins(uint16_t top, uint16_t bottom) {
  // TFA+VSA+BFA must equal 320
  if (top + bottom <= ILI9341_TFTHEIGHT) {
    uint16_t middle = ILI9341_TFTHEIGHT - top + bottom;
    uint8_t data[6];
    data[0] = top >> 8;
    data[1] = top & 0xff;
    data[2] = middle >> 8;
    data[3] = middle & 0xff;
    data[4] = bottom >> 8;
    data[5] = bottom & 0xff;
    sendCommand(ILI9341_VSCRDEF, (uint8_t *)data, 6);
  }
}

Thanks, pushed up change... Although I simply did the (top + bottom) just to make sure it was clear

CorBer commented 3 years ago

Thanks, yeah that issue is at adafruit also for some time now ...

KurtE commented 3 years ago

Yep - I pointed it out to LadyAda, who of course said: well issue a PR ;) So just issued PR # 72