Go Down

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

HazardsMind

There will be a new update coming soon! The CustomButtons will now be compatible with the Radio button class. 
I still haven't figured out how to give them padding, but that is for another headache.

I am bringing back my Gauge class however I am deciding if I should make the arc around it move when the value changes OR use the traditional needle. I would put value in the center, but that would require me to make multiple font files or finish my scaleable font print() functions for the UTFT library. However this would require everyone to use that library instead of Henning's version.

What to do?

My GitHub:
https://github.com/AndrewMascolo?tab=repositories

HazardsMind

#31
Oct 09, 2015, 09:35 pm Last Edit: Oct 17, 2015, 07:07 am by HazardsMind
Well that was easier than I thought it would be. Here is a new library to scale your fonts. (UTFT compatible only)

I know I don't own the rights to use UTFT in the name, so that will be changed to something else when I release my TFT_ExtensionV2 update.

*Also don't use the rotateChar or option in printNumI and printNumF just yet, it's still a little buggy.

**I just found out it will not work on an Arduino Due. Anything greater than x1 and it will not show. I think it has something to do with the way the flash memory is stored, idk. **

I fixed that issue, now I just need to make it faster.
Also just for confirmation, it does work for all 3 default font sizes as well as custom fonts based on Hennings format.
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

HazardsMind

#32
Oct 17, 2015, 07:07 am Last Edit: Oct 17, 2015, 07:10 am by HazardsMind
Ok here is the updated font file. It is slightly faster and I fix the function rotateChar() and rotation options in printNumI() and printNumF().

Enjoy.
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

mpl1337

#33
Oct 18, 2015, 05:02 pm Last Edit: Oct 18, 2015, 05:02 pm by mpl1337
have a problem with sample progressBar_V2

Code: [Select]

no matching function for call to 'ProgressBar::ProgressBar(Base*, int)'

HazardsMind

#34
Oct 18, 2015, 06:02 pm Last Edit: Oct 18, 2015, 08:50 pm by HazardsMind
ProgressBar used to be what is now my Meter class, so the example sketch may have some things wrong in it.
The new constructor for ProgressBar only has one argument, not two. ProgressBar Loading(&B);


Code: [Select]
#include <UTFT.h>
#include <UTouch.h>
#include <TFT_ExtensionV2.h>

extern uint8_t BigFont[];

UTFT    myGLCD(CTE70, 25, 26, 27, 28);
//UTFT    myGLCD(CTE70, 38, 39, 40, 41);
UTouch  myTouch( 6, 5, 4, 3, 2);

Base B(&myGLCD, &myTouch);
ProgressBar Loading(&B);

void setup()
{
  Serial.begin(115200);
  myGLCD.InitLCD(LANDSCAPE);
  myGLCD.clrScr();
  myGLCD.setFont(BigFont);
  myGLCD.fillScr(0x00);
  myGLCD.setColor(0xFFFF);
  
  int Dx = myGLCD.getDisplayXSize();
  int Dy = myGLCD.getDisplayYSize();
  Loading.Coords(0, Dy/2, Dx, Dy/2);
  Loading.Attributes("NOW LOADING, PLEASE WAIT", WHITE, Big, ':');
  Loading.Progress();

}

void loop()
{

}


The reason I've been holding off releasing the new update is because a few of the classes are just visuals, you don't use the touch pad to interact with them. With this said, I am thinking of splitting the library into 2 separate libraries. This way you don't need to always have the UTouch class in your code even when you are not using it.
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

mpl1337

ok, and how works the meter class now?

HazardsMind

Not much different really as it was the old ProgressBar class that you probably have.

Be sure to change the coordinates as I am using a 7" display.
Code: [Select]

#include <UTFT.h>
#include <UTouch.h>
#include <TFT_ExtensionV2.h>

extern uint8_t BigFont[];

UTFT    myGLCD(CTE70, 25, 26, 27, 28);
UTouch  myTouch( 6, 5, 4, 3, 2);

Base B(&myGLCD, &myTouch);
Meter Voltage_Bar(&B, VERTICAL);

void setup()
{
  Serial.begin(115200);
  myGLCD.InitLCD(LANDSCAPE);
  myGLCD.clrScr();
  myGLCD.setFont(BigFont);
  myTouch.InitTouch(LANDSCAPE);
  myTouch.setPrecision(PREC_MEDIUM);
  myGLCD.setBackColor(TRANSPARENT);
  myGLCD.fillScr(BLACK);

  Voltage_Bar.Coords(600, 150, 690, 350); // FIRST, must set coordinates before setting Range and optional starting value
  Voltage_Bar.Attributes(ROUNDED, FILL);  //
  Voltage_Bar.Colors(RED, YELLOW, GREEN, BLACK ); // Optional but good to have some color
  Voltage_Bar.Percentages(90, 50); // RED starts at 90% from bottom, YELLOW start at 50% and GREEN starts at 0
  Voltage_Bar.SetDirection(BTT); // bottom to top   // Optional
  Voltage_Bar.SetRange(0, 1023);                 // SECOND, Must be set after coordinates
  Voltage_Bar.SetStartingValue(0);                // THIRD (Optional, but must be set after range)
  Voltage_Bar.HeaderText("VOLTS", WHITE, (byte)Big);
  Voltage_Bar.ProgressText(WHITE, GREY, Big, BOTTOM);
  Voltage_Bar.Draw();
 
  for (int i = 0; i <= 1024; i += 16) // demo voltage
  {
    Voltage_Bar.SetValue(i);
    Voltage_Bar.Progress();
  }

}

void loop() {
  // put your main code here, to run repeatedly:

}
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

mpl1337

thx works perfekt :)

but

Voltage_Bar.SetDirection(BTT); // bottom to top   // Optional

have try TTB LTR RTL.... nothings works

HazardsMind

#38
Oct 25, 2015, 08:33 pm Last Edit: Nov 12, 2015, 02:10 am by HazardsMind
I have not put those in yet.

Don't worry they will be in the next update as well as a DoubleClick option for each button type.
Also, and this may take some time, but I am making the library compatible with the Adafruit libraries like the Adafruit_ILI9341 and GFX libraries.

I am also finishing up the Gauge Class to have numbers in the center now that I finished my Scalefont library. The Arc around the gauge will move, so no more needle, but if enough people ask for it then I guess I will add it in.

Good things come to those who wait.  :smiley-wink:

Update as of 10/31/2015:
Meter class with Vertical and Horizontal orientations is done.
DoubleClick is done
Gauge class is done. (no needle)
Gauge class including ScaleFonts library is done.
Adafruit compatibility is not 100% done.
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

HazardsMind

#39
Nov 12, 2015, 02:09 am Last Edit: Nov 16, 2015, 12:44 am by HazardsMind
Ok, this is not 100% complete as the Adafruit conversion is proving to be a bit more of a ball breaker than I expected. But as I work on that, I want to release the UTFT side of the library. There will be another update that has the adafruit part finished, when I'll be done is hard to say, but I should have it soon. Also in the next update I was thinking of making my buttons compatible with my ScaleFont library too, but that is probably going to be the last thing I do with the library.

Another thing, I will have an updated library description finished hopefully by saturday or sunday, so for those of you who are having a difficult time, help is on the way.

The Adafruit part is included with this, but again it is not "done". It will work and compile and the buttons work too, but there are things that I still want to improve upon like the gauge class. Right now (in just the adafruit side) it is slow, but it will be fixed in the next update.

(I dont remember if I changed anything in the ScaleFonts library, but if something is off, please leave a comment and I will post the correct version).
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

HazardsMind

Ok Version 2.10 is done. It includes working Adafruit_ILI9341 code and updated description documentation.
The Adafruit side is 99.9% identical to the UTFT side, however a few minor tweaks were needed to be added to get it to work properly. 

I only have a few displays that work with UTFT, Adafruit_ILI9341 and TFTv2 libraries, so I will make my library compatible with all three, but if there is a specific library that you want it to be compatible with, then I will need a link to both the display and working library.

Aside from minor bugs and compatibility with other libraries, I don't think I have anymore to add. I put in all that I wanted to, but again if there is something that someone would like to see added, I will be happy to do so.

From here out I will be more focused on my games which I kinda put aside, but I will slowly get them finished.

Thank you all for downloading my library. Enjoy.
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

HazardsMind

#41
Nov 28, 2015, 07:23 am Last Edit: Dec 15, 2015, 05:10 pm by HazardsMind
Update: Version 2.11
This update is optional, so I will leave the previous version up too.

Added in the following functions:
  • getBackColor (Adafruit only)
  • getState (All button types)
  • getButtonPressedColor (All button types)
  • getButtonReleasedColor (All button types)
  • getButtonTextColor (Box and Circle buttons)
  • getButtonPaddingColor (Box and Circle buttons)
  • getButtonHeadFootColor (Box and Circle buttons)
  • getText *requires buffer* (Box and Circle buttons)
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

mpl1337

Have a little problem:

i try o design a menu:

Code: [Select]
Box Button(&B),
    Button1(&B),
    Button2(&B),
    Button11(&B),
    Button12(&B),
    Button13(&B),
    Button14(&B); // basic boxed buttons

...

loop:
Menu();

loop end


Code: [Select]
void Menu(){
 


  Button1.Coords(0, 430, 100, 480);
  Button1.Colors(0xD7E0, 0x001F, SQUARED, FILL);
  Button1.Text("Home", WHITE, Big);
  Button1.Draw();

  Button2.Coords(100, 430, 200, 480);
  Button2.Colors(0xD7E0, 0x001F, SQUARED, FILL);
  Button2.Text("Setup", WHITE, Big);
  Button2.Draw();


  if (Button1.Touch()) {
    myGLCD.clrScr();
    Mainpage();
  }

  if (Button2.Touch()) {
    myGLCD.clrScr();
    Settank();
  }
 
 
}


void Mainpage(){

    Voltage_Bar.SetValue(total);
    Voltage_Bar.Progress();

    prozent1 = eemax / 100;
    prozent2 = total / prozent1;

    sprintf(buf,"%02d:%02d:%02d", hour(), minute(), second());
    sprintf(buf2,"%02d", prozent2);

    CTE_LCD.Put_Text("Max:", 10, 10,BVS_15);
    CTE_LCD.Put_Text("Min:", 10, 30,BVS_15);
    CTE_LCD.Put_Text("LVL:", 10, 50,BVS_15);
    CTE_LCD.Put_Text("Temp:", 10, 70,BVS_15);
    CTE_LCD.Put_Text("Hum:", 10, 90,BVS_15);
    CTE_LCD.Put_Text("Temp2:", 10, 110,BVS_15);
    CTE_LCD.Put_Text("eemin:", 10, 150,BVS_15);
    CTE_LCD.Put_Text("eemax:", 10, 170,BVS_15);

    CTE_LCD.Put_NumI(maxlvl, 60, 10, 2,BVS_15);
    CTE_LCD.Put_NumI(minlvl, 60, 30, 2,BVS_15);

    CTE_LCD.Put_NumI(eemin, 60, 150, 2,BVS_15);
    CTE_LCD.Put_NumI(eemax, 60, 170, 2,BVS_15);
   
    Serial.println(eemin);
    Serial.println(eemax);

    Serial.println(sizemin);
    Serial.println(sizemax);

    CTE_LCD.Put_NumI(DHTTemp, 60, 70, 4,BVS_15);
    CTE_LCD.Put_NumI(DHTHum, 60, 90, 4,BVS_15);
    CTE_LCD.Put_Text(buf2, 60, 50,BVS_15);

   
    CTE_LCD.Put_Text(buf, 60, 200,BVS_15);
//    CTE_LCD.Put_NumI(currentMillis, 60, 450,BVS_15);
    CTE_LCD.Put_NumI(DSTemp0, 60,110,BVS_15);
    Menu();
 
}

void Settank () {

CTE_LCD.Put_Text("Tank Pegel definieren", 230, 20,BVS_34);

CTE_LCD.Put_Text("Min Wert festlegen:", 30, 100,BVS_15);
myGLCD.printNumI(total, 200, 100, 5);

  Button11.Coords(300, 100, 380, 150);
  Button11.Colors(0xD7E0, 0x001F, SQUARED, FILL);
  Button11.Text("Ok", WHITE, Big);
  Button11.Draw();

  if (Button11.Touch()) {
    minlvl = total;
    write(minlvl, 0);
    CTE_LCD.Put_Text("Ok!", 30, 130,BVS_15);
  }


CTE_LCD.Put_Text("Max Wert festlegen:", 30, 200,BVS_15);
myGLCD.printNumI(total, 200, 200, 5);


  Button12.Coords(300, 200, 380, 250);
  Button12.Colors(0xD7E0, 0x001F, SQUARED, FILL);
  Button12.Text("Ok", WHITE, Big);
  Button12.Draw();

  if (Button12.Touch()) {
    maxlvl = total;
    write(maxlvl, 4);
    CTE_LCD.Put_Text("Ok!", 30, 230,BVS_15);
  }

  Menu();
}


so: when arduino starts i see my 2 buttons.. when i touch Home or Setup i see one of this 2 Pages but the "menu" is crap :D whats my problem ? :)

HazardsMind

You are constantly setting and drawing the buttons in your Menu(). Put setting for the buttons in the setup() function and just call the touch functions. If you are going to change the screens then you will also need to ReDraw the buttons too
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

mpl1337

Ok thx i try it :) is there a switch or a option in the keyboard class for a only numeric keyboard 0-9, enter, back... I want to try to make a keyboard for time switches .. only time input/edit for a text box..

Go Up