Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scrollMargin() has a typo #62

Open
prenticedavid opened this issue May 1, 2020 · 2 comments
Open

scrollMargin() has a typo #62

prenticedavid opened this issue May 1, 2020 · 2 comments

Comments

@prenticedavid
Copy link

scrollMargin() only works for bottom == 0
e.g. // TFA+VSA+BFA must equal 320
VSA = 320 - TFA - BFA; // is correct
VSA = 320 - TFA + BFA; // only ok for 320 - TFA + 0

The same problem occurs with Adafruit_HX8357 library.
You don't implement scrollMargin() on Adafruit_ST7789 or Adafruit_ST7735

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);
  }
}

David.

@KurtE
Copy link
Contributor

KurtE commented May 14, 2021

@ladyada - Ran into this when I was asked to add this to my ILI9341_t3n library.

My fix is: uint16_t middle = ILI9341_TFTHEIGHT - (top + bottom);

@ladyada
Copy link
Member

ladyada commented May 14, 2021

@KurtE thanks, please submit a PR :)

KurtE added a commit to KurtE/Adafruit_ILI9341 that referenced this issue May 14, 2021
as per issue adafruit#62

The function does not work as the computation of middle was incorrect.
it either needed to be
 uint16_t middle = ILI9341_TFTHEIGHT - top - bottom;

or what I prefer and did:
uint16_t middle = ILI9341_TFTHEIGHT - (top + bottom);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants