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

ST7735 initR color tab selection problem #176

Open JSMSolns opened 1 year ago

JSMSolns commented 1 year ago

Apologies if this has been raised before but I believe there may be a bug in initR/color tab defines?

If INITR_REDTAB is selected and passed to the initR routine in Adafruit_ST7735.cpp , one might expect it to skip all the option checks and arrive at the default else condition (line 243 onwards...) } else { // colstart, rowstart left at default '0' values displayInit(Rcmd2red); _colstart = 0; _rowstart = 0;
}

however this never happens because the .h file defines INITR_REDTAB as 0x01 and at the same time defines INITR_144GREENTAB as the same value (0x01). This means that for INITR_REDTAB, the default can never be executed and instead is treated as if it is INITR_144GREENTAB which does not give the correct row/col offset values:

_line 229 } else if ((options == INITR_144GREENTAB) || (options == INITRHALLOWING)) {

Possible fix is to change the INITR_144GREENTAB to 0x03 on line 13 of AdafruitST7735.h e.g. #define INITR144GREENTAB 0x03 The only issue then would be line 259 in the Adafruit_ST7735.cpp: _tabcolor = INITR144GREENTAB;

Depending on the intended operation(???), this would need to also be changed to _tabcolor = INITRREDTAB; or left as is.

A possible temporary work-around without having to change the library would be to call initR with an undefined fixed value e.g. initR(0x06). This would force the default else (red) condition to be executed but this may not work if the library changes in future.