adafruit/TFTLCD-Library — Issue #3: Improvements to TFTLCD Library
Author: owendelong
Created: 2012-02-15 04:55:05+00:00
State: open

The following small diff adds the ability to have a text background color, including the special 0x10000 color which represents transparent background (don't draw on the background) to preserve the existing behavior. For backwards compatibility, the default text background color is initialized as transparent.

Known issue: There are 1 pixel gaps to the right of each character. I will probably clean this up eventually, but, since my requirement was to be able to repeatedly draw over existing text on an already filled background, this didn't even show up in my normal usage. I find it useful as it is and perhaps others will as well.

diffs are Modified code

% diff ~/Desktop/tftlcd/TFTLCD.h TFTLCD.h
99a100
> void setTextBGColor(uint32_t c); // 16 bit color but special 0x10000 for transparent.
156a158
> uint32_t textbgcolor;

% diff ~/Desktop/tftlcd/TFTLCD.cpp TFTLCD.cpp
76a77,80
> void TFTLCD::setTextBGColor(uint32_t c) {
> textbgcolor = c;
> }
>
116a121,127
> else if (textbgcolor != 0x10000) // If not transparent bg color
> {
> if (size == 1) // default size
> drawPixel(x+i, y+j, textbgcolor & 0xffff);
> else // big size
> fillRect(x+i*size, y+j*size, size, size, textbgcolor&0xffff);
> }
669a681
> textbgcolor = 0x10000;	// Default to transparent