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.
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;
> }
>
107c111
< for (uint8_t i =0; i<5; i++ ) {
---
> for (uint8_t i =0; i<(bicolor == 0x10000 ? 5 : 6); i++ ) { // No need to run through 6th column if transparent background
108c112
< uint8_t ine = pgm_read_byte(font+(c*5)+i);
---
> uint8_t line = (i==5 ? 0 : pgm_read_byte(font+(c*5)+i);
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
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.
diffs areModified code