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

Please updated library in last REPLY.

I originally made this library for my own uses, but I feel it should be shared. It works with Henning Karlsen's UTFT and UTouch libraries and it also works with his older ITDB02 libraries. "ITDB02_Graph16 and ITDB02_Touch"

PLEASE NOTE, I am still adding functions to this library (95% Done), mostly colors and functions that allow the user to choose there colors for certain functions like the drawTriangle function.

Right now I only have a 3.2 TFT Lcd that uses the older ITDB02 libraries, so all the examples will be set for those libraries, however, it does compile with the UTFT and UTouch examples.


* TFT_Extension.zip (12.43 KB - downloaded 63 times.)
« Last Edit: June 03, 2014, 10:47:00 am by HazardsMind » Logged

Created Libraries:
TFT_Extension, OneWireKeypad, SerialServo, (UPD)WiiClassicController, VWID

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 614
Posts: 49385
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

One comment: The implementation does NOT go in the header file. Include (accidentally) that library twice, and you'll have all kinds of error messages that are hard to decipher.

Code:
  double DIR = dir * 0.01745 + 1.57;
I hate magic numbers. You may know that they mean, but will everyone?
Logged

Queens, New York
Online Online
Faraday Member
**
Karma: 99
Posts: 3635
"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 changed DIR = dir * 0.01745 + 1.57; to  DIR = dir * RAD_TO_DEG + HALF_PI;
Better yet:
Quote
double DIR = dir * RAD_TO_DEG;
  Cx = x1 + sin(DIR + deg * RAD_TO_DEG + PI) * rad;
.
.
.

Whats is wrong with the implementation? It seems to work just fine.

What would be the better way? Make a .cpp file?
« Last Edit: February 19, 2014, 09:52:14 am by HazardsMind » Logged

Created Libraries:
TFT_Extension, OneWireKeypad, SerialServo, (UPD)WiiClassicController, VWID

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 614
Posts: 49385
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Whats is wrong with the implementation? It seems to work just fine.
As long as you are careful to only include it once in the whole program. Can you guarantee that your users will do that?

Quote
What would be the better way? Make a .cpp file?
Exactly.

Quote
Ok, I changed DIR = dir * 0.01745 + 1.57; to  DIR = dir * RAD_TO_DEG + HALF_PI;
Now, that makes sense.
Logged

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

Quote
Can you guarantee that your users will do that?
No, not at all. But if (Big if)  they do everything else fine, then the worst they will get is this:
Quote
CirclePad:14: error: redefinition of 'TFT_Extension<ITDB02, ITDB02_Touch> myTFT'
CirclePad:13: error: 'TFT_Extension<ITDB02, ITDB02_Touch> myTFT' previously declared here
However it would help greatly if the Arduino software had visible line numbers on the side.



Quote
Quote
What would be the better way? Make a .cpp file?
Exactly.

By making a cpp file, I would need to include the UTFT and UTouch libraries, as well as the older ITDB02 libraries, right? What about if someone doesn't have the older libraries, the compiler will want to know where they are.

I'll figure it out.
« Last Edit: February 19, 2014, 02:27:47 pm by HazardsMind » Logged

Created Libraries:
TFT_Extension, OneWireKeypad, SerialServo, (UPD)WiiClassicController, VWID

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

@PaulS

Is there anyway I can make the precompiler detect if someone actually has the UTFT or UTouch libraries and then have the precompiler determine what lines to enable for the library to work?
Logged

Created Libraries:
TFT_Extension, OneWireKeypad, SerialServo, (UPD)WiiClassicController, VWID

North Queensland, Australia
Offline Offline
Edison Member
*
Karma: 70
Posts: 2171
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Is there anyway I can make the precompiler detect if someone actually has the UTFT or UTouch libraries and then have the precompiler determine what lines to enable for the library to work?

Yes & no, depends on where its used in the library.
If you remember back to a previous post I helped you with; the method I used there was to detect the libraries and replace functionality.  Remember this snippet:
Code:
struct MissingType{};

#ifdef LiquidCrystal_I2C_h
  typedef LiquidCrystal_I2C LCDTYPE;
#else
  typedef MissingType LCDTYPE;
#endif

This method allows you to keep all your missing class stuff in one place, which would suit a well built template and not need to be modified at all. An alternative is to use:
Code:
#ifdef LiquidCrystal_I2C_h
  #define USING_CLASS
#endif

But everywhere the class is used, you need to wrap its code in preprocessor tags to allow or prevent it from compiling:
Code:
#ifdef USING_CLASS
  //Class specific code.
#endif
Logged


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

Ah, ok I forgot about that. Thanks again Pyro.
Logged

Created Libraries:
TFT_Extension, OneWireKeypad, SerialServo, (UPD)WiiClassicController, VWID

Queens, New York
Online Online
Faraday Member
**
Karma: 99
Posts: 3635
"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: I added a new function, TextButton, and for right now, it will display text in the center of the button (the outline of the button still needs to be drawn separately) and you can still use it as a normal button. I am still working on the library and if I can get the TextButton function to work properly, I will do the same to the rest of the buttons.

I also added a wall ball game.

* TFT_Extension.zip (15.73 KB - downloaded 24 times.)
« Last Edit: February 27, 2014, 05:17:04 pm by HazardsMind » Logged

Created Libraries:
TFT_Extension, OneWireKeypad, SerialServo, (UPD)WiiClassicController, VWID

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

Library updated. Added Connect Four game.

Note: I'm currently working on the AI for the connect four game and as of this version, the computer is really dumb. If you look at the function to play against the computer, you'll see its just a few random functions and nothing else. So I am working on making it a bit more of a challenge, and so far it is going good.

After I get the AI to work, I am going to make the game wireless. Maybe not WiFi right now, because I don't have a WiFi module, but it will definitely be Bluetooth.

* TFT_Extension.zip (18.43 KB - downloaded 43 times.)
« Last Edit: March 10, 2014, 08:06:46 pm by HazardsMind » Logged

Created Libraries:
TFT_Extension, OneWireKeypad, SerialServo, (UPD)WiiClassicController, VWID

Queens, New York
Online Online
Faraday Member
**
Karma: 99
Posts: 3635
"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 got a nice little update on the library, I added quite a few new functions which may look confusing to use, but I provided example sketches on how to use them. I also a library description (.docx), hopefully it will clear up any questions.

New Functions:
TouchButton_Draw   
LatchButton_Draw   
TouchCircle_Draw   
LatchCircle_Draw   
TouchTriangle_Draw
LatchTriangle
LatchTriangle_Draw

SetTouchButtonColors   
SetTouchCircleColors   
SetLatchButtonColors   
SetLatchCircleColors   
SetTouchTriangleColors   
SetLatchTriangleColors

   
The Connect Four game is nearly complete, I just need to fix the computers diagonal blocking algorithm and make it bluetooth capable. 

I am still adding things to the library but at the length it is right now (+50 functions), there is still work to be done before I consider it complete.

There are a couple of sketches I provided that are still set to the old libraries but its not difficult to change them to the newer ones.

Try it out.

* TFT_Extension.zip (37.29 KB - downloaded 24 times.)
« Last Edit: March 30, 2014, 03:38:34 am by HazardsMind » Logged

Created Libraries:
TFT_Extension, OneWireKeypad, SerialServo, (UPD)WiiClassicController, VWID

Global Moderator
Netherlands
Online Online
Shannon Member
*****
Karma: 217
Posts: 13739
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 you have some test program to see the performance - footprint of the lib?
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: 1
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello I like your extension but I did reorganize your filestructure to the Default Arduino file structure so examples work right after you have copied the new lib into the libraries. File attached.

* TFT_extension.zip (38.25 KB - downloaded 25 times.)
Logged

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

@robtillaart Not at the moment no. Actually what would be the best way to do that?

@Jeroi Thanks, I know the filing structure is bad, I didn't think anyone would mind it, but I will change it.
« Last Edit: March 30, 2014, 10:20:55 am by HazardsMind » Logged

Created Libraries:
TFT_Extension, OneWireKeypad, SerialServo, (UPD)WiiClassicController, VWID

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

you could simply write a small sketch as a sample program that measures the time for every function. And yes some depend on the params e.g. fill square will be slower for large squares but the example sketch will run the same test for every display.

Logged

Rob Tillaart

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

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