
Originally Posted by
KurtE
When you mention switching to different library and causing more trouble than it is worth... Would be interesting to know what the issue may be.
Kurt,
My application utilizes a numeric keypad along with a decimal point, a DEL and a SET button which all use the Adafruit_GFX_Button helper class. All of this is on a touchscreen of course. The UI was pretty much finished except for fixing the code for the DEL button, which you know, erases the last entered number and updates the value display. The DEL button routine eventually calls tft.fillRect(TEXT_X + 2, TEXT_Y + 10, TEXT_W-10, TEXT_H-20,ILI9341_BLACK); before doing the tft.print(textfield), so this solved the Opaque text drawing issue when trying to use Arial_24_Bold font. Otherwise the UI code is pretty much complete.
The T3N code besides a few issues with the font naming of the header files (to be expected), the biggest issue (if you want to call it that) was the parameter changes in Adafruit_GFX_Button initButton(). Apparently, the code in the T3N tree now wants textSizeX, and textSizeY instead of a single textsize parameter. No worries. Took a look at the T3N header file and noticed the functions getTextSizeX() and getTextSizeY() and figured I'd just pass these functions to initButton(), but quickly found out those functions have not been implemented yet. So wasn't sure just how or where to get the values initButton() expected. I did plug in some numbers to get the code to compile, but couldn't get the text to fit inside the buttons. So it was at this point I determined I had reached the point of diminishing returns and just implemented a simple fillRect in the DEL key part of the code prior to updating the display with the new voltage. No worries.
To be more specific about the original code in T3, making note of K_TEXTSIZE:
Code:
{
tft.setRotation(1);
tft.fillScreen(ILI9341_BLACK);
#define K_X 80
#define K_Y 90
#define K_W 60
#define K_H 30
#define K_SPACING_X 20
#define K_SPACING_Y 12
#define K_TEXTSIZE 2
#define SET_X 220
#define SET_Y 38
#define SET_W 60
#define SET_H 30
#define DP 9
#define DEL 11
#define SET 12
char keyLabel[13][5] = {"1", "2", "3",
"4", "5", "6",
"7", "8", "9",
".", "0", "DEL",
"SET "};
uint16_t keyColor = ILI9341_BLUE;
Adafruit_GFX_Button numKey[13];
tft.setFont(Arial_16_Bold);
for (uint8_t row = 0; row < 4; row++) {
for (uint8_t col = 0; col < 3; col++) {
numKey[col + row * 3].initButton( &tft,
K_X + col * (K_W + K_SPACING_X),
K_Y + row * (K_H + K_SPACING_Y),
K_W,
K_H,
ILI9341_YELLOW,
keyColor,
ILI9341_WHITE,
keyLabel[col + row * 3],
K_TEXTSIZE);
numKey[col + row * 3].drawButton();
}
}
numKey[SET].initButton( &tft,
SET_X,
SET_Y,
SET_W,
SET_H,
ILI9341_YELLOW,
ILI9341_DARKGREEN,
ILI9341_WHITE,
keyLabel[SET],
K_TEXTSIZE);
numKey[SET].drawButton();
tft.drawRect(TEXT_X, TEXT_Y, TEXT_W, TEXT_H, ILI9341_WHITE);
}
The above code should be complete enough to run on your own kit, of course after adding the proper tft configuration ETC. Of course, the code just draws the buttons, I didn't bother to include the code that processes them. To be honest, I really not sure what role K_TEXTSIZE plays in the above code using Arial_Bold font. I have not really experimented much beyond trying different values that finally worked. As far as the T3N code goes, I would have put more effort in getting it working right had I known about it prior to the project, but I was so far along with my projects UI at this point with the generic T3 code that it just didn't make sense to go off on a tangent for something as simple as getting the DEL key to update the display correctly.
Now with all of that having been said, this doesn't mean that once my project is fully up and running on the Teensy 3.2 (I've still got the HW changes to do), I'd be more than happy to get the T3N code working on it. But like I said, I want to get the projects UI completely finished, then do the HW so I can start designing the new PCB.
So I hope my reasons for saying what I did and why make more sense now.
Cheers,
KG5NII