adafruit / Adafruit-ST7735-Library

This is a library for the Adafruit 1.8" SPI display http://www.adafruit.com/products/358 and http://www.adafruit.com/products/618
https://learn.adafruit.com/1-8-tft-display
547 stars 303 forks source link

Add support for displays with blacktab colors and greentab offsets #193

Open samo-sk opened 11 months ago

samo-sk commented 11 months ago

This change fixes #191, #180 and #154 by creating a flag named INITR_BLACKTAB_OFFSETS for initR for the displays described in the issue reports. When initR is called with this flag, the commands for second stage initialization of greentab displays are used, but MADCTL is modified like when INITR_BLACKTAB is used. I have also modified Adafruit_ST7735::setRotation, as it alters MADCTL. I have simplified the function to avoid repeating code for checking if the color order flag in MADCTL should be changed. This change is tested, it works on the mentioned displays and doesn't alter the functionality when INITR_BLACKTAB or INITR_GREENTAB is used. This pull request aims to fix the same issue as #168, which contains a bug that causes an erroneous modification of its behavior when initR is used with INITR_GREENTAB, which I have described in comments below that pull request. My pull request doesn't modify the examples, as I wasn't sure if adding a commented out initR with INITR_BLACKTAB_OFFSETS to e.g. graphicstest is suitable, as this type of displays isn't an official one. PS: In #191, I was told to contact Deek-Robot rather than submitting a pull request myself. I decided otherwise, as their website doesn't list my TFT as one of their products (even though the URL of the company is written on the display) and I didn't want to risk waiting for a long time if I can fix this myself. Another reason is that this issue isn't exclusive to Deek-Robot displays.