Go Down

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

HazardsMind

Apr 16, 2015, 06:17 pm Last Edit: Apr 26, 2015, 05:51 pm by HazardsMind
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**
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

HazardsMind

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

HazardsMind

#2
Apr 25, 2015, 07:11 am Last Edit: Apr 26, 2015, 04:36 am by HazardsMind
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.
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

HazardsMind

#3
Apr 26, 2015, 04:34 am Last Edit: May 12, 2015, 02:31 am by HazardsMind
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.
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

dizzwold

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.
I'm not a student or a lecturer. I'm a hobbyist.

HazardsMind

Set the range from 0 to 255.

myTFT.SetRange(0, 255, 1); // low, High, Increments (increments is optional and the default value is 1)
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

dizzwold

Hi HazardsMind,

 It doesn't like 'myTFT'.

 Should i include;

TFT_Extension myTFT(&myGLCD, &myTouch);

 as well as;

Base B(&myGLCD, &myTouch);

 Regards.

 Dizzwold.
I'm not a student or a lecturer. I'm a hobbyist.

HazardsMind

#7
May 11, 2015, 07:08 pm Last Edit: May 11, 2015, 07:10 pm by HazardsMind
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?
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

HazardsMind

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

dizzwold

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.

Code: [Select]
// 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]
I'm not a student or a lecturer. I'm a hobbyist.

HazardsMind

#10
May 12, 2015, 04:16 pm Last Edit: May 12, 2015, 04:24 pm by HazardsMind
No, .Touch() will return the value from the slider.


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

dizzwold

Hi HazardsMind,

 Something like this;

Dizzwold.

Code: [Select]
// 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]
I'm not a student or a lecturer. I'm a hobbyist.

HazardsMind

Take this out, its not needed.

Quote
SlideV.SetValue(SlideV.Touch());
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

HazardsMind

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

HazardsMind

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

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

Go Up