Go Down

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

HazardsMind

#60
Apr 17, 2016, 10:39 pm Last Edit: Apr 18, 2016, 12:08 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:
https://github.com/AndrewMascolo?tab=repositories

KrisDW

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... :) :) :) :) :) :) :) :) :) :)

KrisDW

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.

HazardsMind

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:
https://github.com/AndrewMascolo?tab=repositories

KrisDW

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

Great work by the way!! :) :)







KrisDW

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.Colors(LIGHT_YELLOW, YELLOW, SQUARED, FILL);
  Ma.Text("MAANDAG", "Ma", BLACK, Small);
  Ma.Draw();

  x2 = Ma.getPropsX2();
  Di.Coords(x2, 138, AUTO, 168);
  Di.Colors(LIGHT_YELLOW, YELLOW, SQUARED, FILL);
  Di.Text("DINSDAG", "Di", BLACK, Small);
  Di.Draw();

  x2 = Di.getPropsX2();
  Woe.Coords(x2, 138, AUTO, 168);
  Woe.Colors(LIGHT_YELLOW, YELLOW, SQUARED, FILL);
  Woe.Text("WOENSDAG", "Woe", BLACK, Small);
  Woe.Draw();

etc.

The Y coords are set manualy.

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

HazardsMind

#66
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:
https://github.com/AndrewMascolo?tab=repositories

KrisDW

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 .

HazardsMind

Yea that was just a typo. 

You have more properties too. 

Quote
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;
   }Props;
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

yahoolane

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
// USE ME
//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) {

  Serial.println(s);
   delay(1000);

 }
 
}


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

  // Setup the LCD
  myGLCD.InitLCD(LANDSCAPE); // Lan scape
  myGLCD.setFont(SmallFont);
  myTouch.InitTouch(LANDSCAPE);
  myTouch.setPrecision(PREC_HI);
  myGLCD.clrScr();

  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);
  Button.Draw();
  
}
 void loop() {
  // put your main code here, to run repeatedly:
//debug("Loop");


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


}

HazardsMind

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:
https://github.com/AndrewMascolo?tab=repositories

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!

Arduino
via Egeo 16
Torino, 10131
Italy