TFT Extension Version 2

As the subject implies, I have a new version of my TFT Extension library. It is still under construction, but it can be useful as it currently stands.

I don't have any documentation yet, but you should be able to see how the library works from the example sketches.

I do plan on bringing back the keyboard from the first version and also including a way to make custom shaped buttons.

Enjoy.

Not intended for beginners, but it may help the learning process

Quick update! (not posting the library yet, sorry)

Not only was I able fill a custom button in the shape of a crescent moon, but the button can also register a touch point within it.

Woot.

I will post the library once I write up the library description.

Check for it either Friday or Saturday.

Good night guys.

Here it is, the updated library with custom buttons. I also added a library description in the Documents folder.

Thank you to everyone who downloaded the first one I posted, I hope you all found this library to be helpful.

Now for the mobile keyboard.

**Issue with library, download the newest one below or change the .h file.

Sorry Sorry, For those 4 who downloaded the new version, there was an issue with the latch function for the custom button, but it is fixed now.

Below is the full file, or if you want you can just replace the .h file that you currently have with the one below.

See newest post for the updated TFT_ExtensionV2.h file.

Hi HazardsMind,

Great library, good work.

I'm playing with the vertical slider.

Whats the best way to use the slide as a PWM O/P for LED brightness?

Regards.

Dizzwold.

Set the range from 0 to 255.

myTFT.SetRange(0, 255, 1); // low, High, Increments (increments is optional and the default value is 1)

Hi HazardsMind,

It doesn't like 'myTFT'.

Should i include;

TFT_Extension myTFT(&myGLCD, &myTouch);

as well as;

Base B(&myGLCD, &myTouch);

Regards.

Dizzwold.

Correction:

Yes, A possible issue I just thought of is the increments I designed the code to automatically make incremental bars, basically divide it into segments based on the height of the slider and the difference of the range values.

If you have a slider that is only 100 pixels in height but the range is set to 0 - 255 at 1 increment, then you most likely won't see anything, however it will still function.

Based on that issue, I will make the incremental bars optional.

I'll work on that when I get home tonight.

Why use both libraries?

As per the issue foreseen with the Sliders, there is now the option to show the bars "Bars" or to not show them "NoBars"

To choose between the two, you add either Bars or NoBars to the end of the Padding function.
Ex:
Slider.Padding(2, BLUE, Bars);

You will most likely not see the bars if the difference of the set range divided by the incremental value is greater than the overall height or width of the slider. NoBars fixes this by just giving you a solid bar.

Attached is the updated keywords file and .h file. (No new examples have been made yet)

Hi HazardsMind,

OK, getting to grips with the V2 library, and figured out not to use 'myTFT', but to use SlideV.

Regarding using the slider to control PWM o/p for the brightness of a TFT backlight, i was going about it the 'long way', when i glanced at the Keywords, and spotted 'GetValue'.

Can i use 'GetValue', to get the value of where the slider's position is to then o/p a PWM?

I haven't got very far with the code, but like i say i was using 'pinMode, analogWrite' etc then spotted 'GetValue'.

Dizzwold.

// Use IDE 1.0.6 or 1.5.x
#include <UTFT.h>
#include <UTouch.h>
#include <TFT_ExtensionV2.h>

int ledPin = 7;
int ledLevel = 0;
char value[9] = {0};

extern uint8_t SmallFont[];

UTFT    myGLCD(ILI9327, 38, 39, 40, 41);
UTouch  myTouch( 6, 5, 4, 3, 2);

Base B(&myGLCD, &myTouch);

Slider SlideV(&B, VERTICAL);


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

  SlideV.Padding(2, GREEN, Bars);
  SlideV.Coords(10, 50, 40, 145);
  SlideV.Colors(GREEN, RED, ROUNDED, FILL);
  SlideV.SetDirection(BTT); // bottom to top
  SlideV.Draw();
  
  SlideV.SetRange(1, 255, 25);
  SlideV.SetValue(150);
  
  pinMode(ledPin, OUTPUT);
  analogWrite(ledPin, ledLevel = 150);
}

void loop()
{
  SlideV.SetValue(SlideV.Touch());
}

/code]

No, .Touch() will return the value from the slider.

SlideV.SetValue(SlideV.Touch());

GetValue was mainly for the .Touch() function and should have been private. As it is only helpful if you Set a value first.

You don't need to set the value to the same value its already at. Just read the value from SliderV.Touch().
SetValue allows the user to set the value to whatever they want (given it is within the setrange). My example was to show how one slider can change another based on that function.

Hi HazardsMind,

Something like this;

Dizzwold.

// Use IDE 1.0.6 or 1.5.x
#include <UTFT.h>
#include <UTouch.h>
#include <TFT_ExtensionV2.h>

int ledPin = 7;
int ledLevel = 0;
char value[9] = {0};

extern uint8_t SmallFont[];

UTFT    myGLCD(ILI9327, 38, 39, 40, 41);
UTouch  myTouch( 6, 5, 4, 3, 2);

Base B(&myGLCD, &myTouch);

Slider SlideV(&B, VERTICAL);


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

  SlideV.Padding(2, GREEN, Bars);
  SlideV.Coords(10, 50, 40, 145);
  SlideV.Colors(GREEN, RED, ROUNDED, FILL);
  SlideV.SetDirection(BTT); // bottom to top
  SlideV.Draw();
  
  SlideV.SetRange(25, 255, 25);
  
  pinMode(ledPin, OUTPUT);
}

void loop()
{
  SlideV.SetValue(SlideV.Touch());
  analogWrite(ledPin, SlideV.Touch());
}

/code]

Take this out, its not needed.

SlideV.SetValue(SlideV.Touch());

Quick update, not releasing the library just yet though. I fixed the issues with the slider class, to where I added a new function called SetStartingValue( int ). This is to go into the setup function and based on the range you set with the SetRange function, it will output that value as well as move the slider accordingly.

Another minor addition was made to the swipe class, in which I added a simple function to show the swip area based on the set coordinates.

Now the major addition I made to this library is the keyboard. I currently have a working keyboard that can be stretched to fit any screen (although not recommended for screens smaller than 320x240 resolution).
The reason I am not releasing this new update is because of the amount of memory the keyboard class takes up.
Shockingly, the keyboard class by itself as it currently stands, it takes up about 31K of memory!

I want to try to cut that down and maybe redesign the structure of the keyboard class to something more practical in terms of memory usage.

More to come.

I haven't had a whole lot of time to work on the library, but here it is as it currently stands.

Hi HazardsMind,

What is this thing on the stick.

LOL.

Dizzwold.

Screen shot 2015-08-01 at 15.36.21.png

What is this thing on the stick.

It's a corn-dog. A hot dog dipped in a cornmeal batter and deep-fried. Very tasty with hot mustard.

They're a staple at county fairs.

Ah, Ok.

Looks good, sounds good, but may-not-be from a health point.

Would i be corrrect to have a Simpsons moment and say;

"Hmm CornDog"?

Dizzwold.

Hello Everybody, and first of all many thx to HazardsMind for his work.

I'm new from the Forum.

I've downloaded and work some days with the TFT_ExtensionV2 and I've a question about the slider.

How is possible to change the color of text that plot "SlideV.Touch"?
I.e. I've a button (ON/OFF) and a Slider.
When the button is "OFF" the text background is "red". When the button turn "ON" the background go "red".

Many thanks