Hi @mjs513,
I was playing around with the ILI9341_t3n stuff and it gets sort of interesting.
Obviously if we change the text drawing code would also need to change the text bounds code as well to match.
Also I am not sure about how if ever we properly support:: Adafruit_GFX_Button button;
That is we have:
Code:
// To avoid conflict when also using Adafruit_GFX or any Adafruit library
// which depends on Adafruit_GFX, #include the Adafruit library *BEFORE*
// you #include ILI9341_t3.h.
// Warning the implemention of class needs to be here, else the code
// compiled in the c++ file will cause duplicate defines in the link phase.
#ifndef _ADAFRUIT_GFX_H
class Adafruit_GFX_Button {
public:
Adafruit_GFX_Button(void) { _gfx = NULL; }
void initButton(ILI9341_t3n *gfx, int16_t x, int16_t y,
uint8_t w, uint8_t h,
uint16_t outline, uint16_t fill, uint16_t textcolor,
const char *label, uint8_t textsize_x, uint8_t textsize_y)
...
But now suppose you do include Adafruit_GFX like the comments mentioned...
In Adafruit that class is defined like:
Code:
/// A simple drawn button UI element
class Adafruit_GFX_Button {
public:
Adafruit_GFX_Button(void);
// "Classic" initButton() uses center & size
void initButton(Adafruit_GFX *gfx, int16_t x, int16_t y,
uint16_t w, uint16_t h, uint16_t outline, uint16_t fill,
uint16_t textcolor, char *label, uint8_t textsize);
void initButton(Adafruit_GFX *gfx, int16_t x, int16_t y,
uint16_t w, uint16_t h, uint16_t outline, uint16_t fill,
uint16_t textcolor, char *label, uint8_t textsize_x, uint8_t textsize_y);
Then in our code we do something like:
Code:
button.initButton(&tft, 200, 125, 100, 40, ILI9341_GREEN, ILI9341_YELLOW, ILI9341_RED, "UP", 1, 1);
Which compiles fine if Adafruit_GFX is not included. But if it is included. This will fail to compile as there is no way to cast TFT to Adafruit_GFX class...
This issue is not new, probably has happened for a long time with ili9341_t3 library... Just not sure how best to resolve...
Probably the simplest is to simply change names of the class?
Currently in the FB test program, I commented out the use of the buttons, until I figure out what to do...
Also had the bounds function draw the rectangle around calculated rect to see how far off... St
Code:
void printTextSizes(const char *sz) {
Serial.printf("%s(%d,%d): SPL:%u ", sz, tft.getCursorX(), tft.getCursorY(), tft.strPixelLen(sz));
int16_t x, y;
uint16_t w, h;
tft.getTextBounds(sz, tft.getCursorX(), tft.getCursorY(), &x, &y, &w, &h);
Serial.printf(" Rect(%d, %d, %u %u)\n", x, y, w, h);
tft.drawRect(x, y, w, h, ILI9341_GREEN);
}
void drawTextScreen(bool fOpaque) {
SetupOrClearClipRectAndOffsets();
tft.setTextSize(1);
uint32_t start_time = millis();
tft.useFrameBuffer(use_fb);
tft.fillScreen(use_fb ? ILI9341_RED : ILI9341_BLACK);
tft.setFont(Arial_40_Bold);
if (fOpaque)
tft.setTextColor(ILI9341_WHITE, use_fb ? ILI9341_BLACK : ILI9341_RED);
else
tft.setTextColor(ILI9341_WHITE);
tft.setCursor(0, 5);
tft.println("AbCdEfGhIj");
tft.setFont(Arial_28_Bold);
tft.println("0123456789!@#$");
#if 0
tft.setFont(Arial_20_Bold);
tft.println("abcdefghijklmnopq");
tft.setFont(Arial_14_Bold);
tft.println("ABCDEFGHIJKLMNOPQRST");
tft.setFont(Arial_10_Bold);
tft.println("0123456789zyxwvutu");
#endif
tft.setFont(&FreeMonoBoldOblique12pt7b);
printTextSizes("AdaFruit");
tft.println("AdaFruit");
tft.setFont(&FreeSerif12pt7b);
printTextSizes("FreeSan12");
tft.println("FreeSan12");
tft.setFont();
tft.setTextSize(1,2);
printTextSizes("Sys(1,2)");
tft.println("Sys(1,2)");
tft.setTextSize(1);
printTextSizes("System");
tft.println("System");
tft.setTextSize(1);
tft.updateScreen();
DBGSerial.printf("Use FB: %d OP: %d, DT: %d OR: %d\n", use_fb, fOpaque, use_set_origin, millis() - start_time);
}