Go Down

Topic: TFT Extension Version 2 (Read 6912 times) previous topic - next topic


Apr 17, 2016, 10:39 pm Last Edit: Jun 07, 2016, 03:07 am by HazardsMind
Funny you should mention that, I found that out myself a few days ago.  The problem was with the Radio Class, it is fixed now.  See the updated library below.  Its version 2.13

To anyone looking to use the Fontcreator sketch:
In order for you to use the newly created file, you must first make a new .c file on your computer, then once you make the font file using the Fontcreator sketch, you then copy the contents of that font file to that new .c file. Everything is there, just C&P it.

PS. The Games are still being worked on.
My GitHub:


Thanks a lot for this updated library, and very quick reply. It works great!!

Now i can implement it in de rest of my code. This is what i was looking for.

Yes, yes, yes, NOW we can... :) :) :) :) :) :) :) :) :) :)


Now i have an other issue.
Is it possible to (de-)activate buttons?

I want to create different pages on my display.  :o

I have tried to clear my display, but the buttons remain active. (As i expected ... it is another library)

Maybe it is possible to have multiple "Base" classes? And (de-) activate them when i want.


Put the radio instance in an IF statement with a flag. If the flag is true, the button works, if it is false the button is disabled.
My GitHub:


Thanks, this is a good solution!!! :o

Great work by the way!! :) :)


Hello again,

I have made a little "adjustment" to the lib. :)

The reason is:
I tried to make a page with different tabs (buttons), but for the alignment of all the buttons, i needed a lot of math to calculate all the coords of my buttons.

I am a bit lazy, so as I thought:
 -If i use the AUTO literal, in stead of entering the x2 coord, the buttons width is set automatic. (learned from the examples!!!)
 -Now all i needed was the button its "width or x2 coord" in order to create the next button at its side.
     -> this was my problem...

I started reading the files from the lib and i adjusted 2 files.

  -TFTE touchables: i added following lines in the Class Box

      int getPropsX2() //--------------------------------------------------ADDED BY ME: KRIS DE WILDE
   if(Props.x2 == AUTO)
       Props.x2 = Props.x + max(strlen(pText),strlen(npText))*(Props.FontSize? 16 : 8) + 8;//autoPadding;
   return Props.x2;

  -TFT_extentionV2: i added following lines in the Class Base:
      virtual int getPropsX2(){}   //------------------------------------ADDED BY ME: KRIS DE WILDE

In my code it comes like this:
  Ma.Coords(20, 138, AUTO, 168);
  Ma.Text("MAANDAG", "Ma", BLACK, Small);

  x2 = Ma.getPropsX2();
  Di.Coords(x2, 138, AUTO, 168);
  Di.Text("DINSDAG", "Di", BLACK, Small);

  x2 = Di.getPropsX2();
  Woe.Coords(x2, 138, AUTO, 168);
  Woe.Text("WOENSDAG", "Woe", BLACK, Small);


The Y coords are set manualy.

(The added lines are a "copy, paste" from lines in the original file).


Apr 19, 2016, 11:18 pm Last Edit: Apr 19, 2016, 11:36 pm by HazardsMind
Did you try the function "getButtonProperties()" ?

Try this:
int x2 = Ma.getButtonProperties().X2; //it does exactly what you wrote and more
My GitHub:


That actually works just as well , you're right . I thought I had a clever idea, but this would have been much easier ...

For many functions , it is difficult to make the correct format.

Just for this feature is the X2 at the end x2, no capital letter X.

int x2 = Ma.getButtonProperties().X2;   ->   int x2 = Ma.getButtonProperties().x2;

Again thanks for the help .


Yea that was just a typo. 

You have more properties too. 

struct Properties
    int x;
    int y;
    int width;
    int height;
    int x2;
    int y2;
    word C1, C2, PadColor, tColor, HFcolor;
    bool Round, Fill;
    byte PaddingSize, FontSize, HFFontSize;
My GitHub:


I don't seem to be able to get the touch to return true.

I believe the myTouch is not working.

I can get UTouch examples to work, but not ExtensionV2 to return true on touch()

it Draws with out issues.

Looking for solution.   Very simple test code below.

Code: [Select]

// ITDB02_Graph16_Demo (C)2010 Henning Karlsen
#include <UTFT.h>
//#include <ITDB02_Graph16.h>
#include <UTouch.h>
#include <TFT_ExtensionV2.h>

// Uncomment the next line for the ITDB02 Shield
//ITDB02 myGLCD(19,18,17,16);

// Uncomment the next line for the ITDB02 Mega Shield
//ITDB02 myGLCD(38,39,40,41);
UTFT    myGLCD(ITDB32S,38,39,40,41);

UTouch  myTouch( 6, 5, 4, 3, 2);
//UTouch  myTouch( 25,26,27,29,30);

Base B(&myGLCD, &myTouch); // Base class, NEEDED!!!
Box  Button(&B), Button1(&B), Button2(&B); // basic boxed buttons

boolean debugmode = true;

extern uint8_t SmallFont[];

void debug(String s) {
 if (debugmode==true) {



void setup() {
  // put your setup code here, to run once:
  if (debugmode==true) {
  Serial.println("Debug On ");

  // Setup the LCD
  myGLCD.InitLCD(LANDSCAPE); // Lan scape

  myGLCD.print("Version .01", LEFT, 227);
  // Menu button
  Button.Coords(150, 120, 210, 170);
  Button.Colors(0xD7E0, 0x001F, ROUNDED, FILL);
  Button.Text("MENU",GREEN, Big);
 void loop() {
  // put your main code here, to run repeatedly:

    if  ( Button.Touch() == true )  {
       debug("we true?");
       myGLCD.print("MENU PRESSED ", CENTER, 38);      



Are you sure your touch screen is calibrated correctly? There is nothing wrong with the code and it works on my display. 

Try the UTouch quickpaint sketch and see if it puts a dot where you touch the screen. 
My GitHub:


May 16, 2016, 01:26 am Last Edit: May 22, 2016, 02:38 am by HazardsMind
OK... so, 3 games and 1 updated ScaleFonts library.  (Sorry, it's been awhile since I could actually sit down and work on stuff, slowly getting back to the grind.)

Code Breaker and ConnectFour should be played on a 3.2" display. They will of course work on larger screens, but some text will be out of place.

WarZone should only be played on 5" or 7" displays. Right now it is set up for a 7" but with some tweaking to the battlefield coordinates, it will fit on a 5". No Bluetooth yet as I do not have another large screen to test it.

As for the ScaleFonts library, I fixed some minor bugs and added a simple method that allows the user to set boundaries for the text. Say you want the text centered in a specific place, but by using the UTFT keyword CENTER, the text will only be centered by the screen size and not where you want it.  :(
Well now I modified my library to center text based on a set area box. ie. TextBounds(x, y, x2, y2)  Enter the area you want the text to be in and now you can use the keywords CENTER and RIGHT to justify the text on screen.

Why Henning did not add this to his UTFT library is beyond me, anyways more to come.
My GitHub:


May 22, 2016, 02:38 am Last Edit: May 22, 2016, 03:00 am by HazardsMind
I just found a bug with the TFT Scalefont library and it is one that I have not seen before. Apparently there is a memory bug in the way pgm_read_byte reads the bytes between Landscape and Portrait modes. Attached is the fix for that bug.

If you guys find any bugs please report them. I welcome feedback.

PS. I put my games on my github repository.
My GitHub:


May 27, 2016, 08:04 am Last Edit: May 27, 2016, 08:15 am by makenov
thanks you a lot, Mr.HazardsMind

I've done the coding part of my project. The TF_extension helps me to display the data visually. The TFT_Scalefonts also saves my arduino NANO from lacking of memory, I can use big fonts by scaling up the default fonts, without adding new big-size fonts, which consume large amount of flash memory. The scaled-up fonts are not really "bunky", still very nice!!! but they are just little bit slower "response" compared to native-bigsize fonts.

sorry for my bad English.


My GitHub:

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131