Pages: 1 ... 3 4 [5]   Go Down
Author Topic: New TFT Extension Library  (Read 9751 times)
0 Members and 1 Guest are viewing this topic.
Queens, New York
Online Online
Faraday Member
**
Karma: 84
Posts: 3400
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I should have mentioned this earlier, if you look at the code for drawArc, you will see
Quote
for(float rotate = start; rotate <= stop; rotate+=0.5)
To draw an arc that spans 0 - 180 degrees, with a radius of 50 pixels and filled in, it takes 12.9 seconds. However if I make it increment by 1 instead of 0.5, then the time is cut in half, 6.5 seconds. There is a reason why it takes SO long to make the gauge, and that is because of the appearance. If I make it increment by 0.5, the gauge is filled and it looks good, no dead spots. However (you can try this if you want) if I make it increment by 1, then yes it will take half the time, but it won't look as nice.

Maybe I make it an option, Appearance vs Speed, and have it draw the gauges based on that setting.

There is always a method to the madness.
« Last Edit: May 21, 2014, 07:16:43 pm by HazardsMind » Logged

Created Libraries:
NPV2 (NewPasswordV2),  TFT_Extension, OneWireKeypad, SerialServo.
Will provide libraries if asked in PM or forum.

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 211
Posts: 13477
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


small test -     // cos = sqrt(1-sin*sin);  to calculate a faster cos()
"draw"  your conclusions.

Code:
// Released to the public domain
uint32_t start;
uint32_t stop;
float deg_to_rad = 3.14159265/180;
int x;
int y;


void setup()
{
  Serial.begin(115200);
  Serial.println("Start ");

  start = micros();
  drawGauge(100, 10);
  stop = micros();
  Serial.println(stop - start);

  start = micros();
  drawGauge1(100, 10);
  stop = micros();
  Serial.println(stop - start);
  Serial.println(x);
  Serial.println(y);
}

void loop()
{
}

void drawGauge(int value, int rad)
{
  x = sin((value-90) * deg_to_rad) * (rad-2);
  y = cos((value-90) * deg_to_rad) * (rad-2);
}

void drawGauge1(int value, int rad)
{
  x = sin((value-90) * deg_to_rad);
  y = sqrt(1-x*x) * (rad-2);            // cos = sqrt(1-sin*sin)
  x = x * (rad-2);
}
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 5
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

iv got one more for you how could i get the HorBarGraph function to be at 0% on the left hand side and 100% on the right? as its going the opposite way atm?
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 211
Posts: 13477
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

do   value =  100-value  ?
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Queens, New York
Online Online
Faraday Member
**
Karma: 84
Posts: 3400
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I figured someone would want that so I modded the code to have it display both ways with a boolean variable.
Unfortunately, I am not home right now, so I can't post the library at the moment.
Logged

Created Libraries:
NPV2 (NewPasswordV2),  TFT_Extension, OneWireKeypad, SerialServo.
Will provide libraries if asked in PM or forum.

Queens, New York
Online Online
Faraday Member
**
Karma: 84
Posts: 3400
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Update: look at SliderBar_Horizontal sketch.

Default is LTR.

Working on new Keyboard layout and adding sendable Smiley faces.

* TFT_Extension.zip (64.79 KB - downloaded 13 times.)
Logged

Created Libraries:
NPV2 (NewPasswordV2),  TFT_Extension, OneWireKeypad, SerialServo.
Will provide libraries if asked in PM or forum.

Offline Offline
Newbie
*
Karma: 5
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok got it great work. smiley-cool
Logged

Queens, New York
Online Online
Faraday Member
**
Karma: 84
Posts: 3400
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Minor Update: Added new functions for _Draw buttons.

User gromgsxr got me thinking, my buttons use locks to prevent them from constantly redrawing on screen, so, if you want to use them in a menu system, they wont redraw when you reenter the screen. It is the exact same issue gromgsxr was having with his gauges, once he left the screen and came back, they wouldn't redraw. Well these new functions will (as there names imply) fix that issue as either individually or all (of the same type) at once.

New Functions:
ResetTouchButton(byte ID);
ResetTouchCircle(byte ID);
ResetTouchTriangle(byte ID);
ResetLatchButton(byte ID);
ResetLatchCircle(byte ID);
ResetLatchTriangle(byte ID);
ResetAllTouchButton();
ResetAllTouchCircle();
ResetAllTouchTriangle();
ResetAllLatchButton();
ResetAllLatchCircle();
ResetAllLatchTriangle();

Added:
The rounded_Square function draws MUCH faster.

* TFT_Extension.zip (64.93 KB - downloaded 10 times.)
« Last Edit: May 25, 2014, 05:53:05 pm by HazardsMind » Logged

Created Libraries:
NPV2 (NewPasswordV2),  TFT_Extension, OneWireKeypad, SerialServo.
Will provide libraries if asked in PM or forum.

Queens, New York
Online Online
Faraday Member
**
Karma: 84
Posts: 3400
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Notice:
I have a few new functions coming out soon. One is already done and its called TouchCircleByQuad
Basically it will return the quadrant of which you touched, (1,2,3 and 4) or you can specify a specific quadrant(s) and it will return true if it/they are touched.

The other two are Swipe and SwipeFromArea.
Swipe: Will return a value based on the direction you swiped on the screen from your initial touch(anywhere on screen). 1 = up, 2 = down, 3 = left and 4 = right. I am still fine tuning this function but it's not 100% yet.

SwipeFromArea: Needs an area to swipe from and a direction(x1, y1, x2, y2). This function will allow you to do things like, do something when only the bottom left side of the screen is swiped to the right or you can add multiple functions to do different things. Not 100% yet either.

I am also thinking of adding double tap buttons, but I don't know if they are really needed. But if someone wants them, I will add them.
« Last Edit: June 05, 2014, 04:03:52 pm by HazardsMind » Logged

Created Libraries:
NPV2 (NewPasswordV2),  TFT_Extension, OneWireKeypad, SerialServo.
Will provide libraries if asked in PM or forum.

Queens, New York
Online Online
Faraday Member
**
Karma: 84
Posts: 3400
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

UPDATE!

Library is below.

* TFT_Extension.zip (72.79 KB - downloaded 11 times.)
Logged

Created Libraries:
NPV2 (NewPasswordV2),  TFT_Extension, OneWireKeypad, SerialServo.
Will provide libraries if asked in PM or forum.

Queens, New York
Online Online
Faraday Member
**
Karma: 84
Posts: 3400
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Slight update:
I fixed some things in the Smiley face function and got rid of the extra pixel at 0 deg.

And put the keyboard characters in the PROGMEM


* TFT_Extension.zip (73.04 KB - downloaded 9 times.)
« Last Edit: June 15, 2014, 12:00:27 am by HazardsMind » Logged

Created Libraries:
NPV2 (NewPasswordV2),  TFT_Extension, OneWireKeypad, SerialServo.
Will provide libraries if asked in PM or forum.

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 211
Posts: 13477
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

good work!

small bug in the latest version  in the CPP file on the top
Code:
#include "TFT_Extension_old.h"

Think it is time to include a version string in the library like
Code:
#define TFT_EXTENSION_VERSION "TFT EXT LIB V0.1.00" 


Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Queens, New York
Online Online
Faraday Member
**
Karma: 84
Posts: 3400
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Edit:
Sorry about that.

As for the version, there is most likely going to be one more coming out and that's the new keyboard layouts (iOS and Android style) and maybe a clock face, maybe.

Other than that, I think i'm finally done.

But I'll add the version in.

Below is just the .cpp file, you can replace the one you have with this one.

* TFT_Extension.cpp (96.52 KB - downloaded 10 times.)
« Last Edit: June 15, 2014, 09:54:37 pm by HazardsMind » Logged

Created Libraries:
NPV2 (NewPasswordV2),  TFT_Extension, OneWireKeypad, SerialServo.
Will provide libraries if asked in PM or forum.

Queens, New York
Online Online
Faraday Member
**
Karma: 84
Posts: 3400
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, I think this is going to be the last update for this library, but I may tweak somethings here and there.

I started making this library, before it was ever a library, meaning at the time I was just adding functions to Karlsen's ITDB02 libraries, trying to make them better and more functional. Then before long I had written a LOT of new functions and decided to take what I made and make my own library that others can use. Its taken a collective 13 months, of both my ideas and help from other users (their names are in the .h file).

Thank you for finding this library helpful, and as always if there is something you want to add, by all means let me know. This is the last update from my ideas (because I'm all out), but if someone else has anything good that they want to add, I will add it.

Thank you again.

Edit: being that the iPhone and Android keyboards are very similar, I just made one new keyboard style, so now the library has Standard_Keyboard and Mobile_KeyBoard

* TFT_Extension.zip (74.69 KB - downloaded 18 times.)
« Last Edit: July 06, 2014, 07:33:11 pm by HazardsMind » Logged

Created Libraries:
NPV2 (NewPasswordV2),  TFT_Extension, OneWireKeypad, SerialServo.
Will provide libraries if asked in PM or forum.

Pages: 1 ... 3 4 [5]   Go Up
Jump to: