Go Down

Topic: New TFT Extension Library (Read 14375 times) previous topic - next topic

HazardsMind

Feb 14, 2014, 09:05 pm Last Edit: Jun 03, 2014, 05:47 pm by HazardsMind Reason: 1
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.

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

PaulS

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: [Select]
  double DIR = dir * 0.01745 + 1.57;
I hate magic numbers. You may know that they mean, but will everyone?

HazardsMind

#2
Feb 19, 2014, 03:46 pm Last Edit: Feb 19, 2014, 03:52 pm by HazardsMind Reason: 1
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?
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

PaulS

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.

HazardsMind

#4
Feb 19, 2014, 04:42 pm Last Edit: Feb 19, 2014, 08:27 pm by HazardsMind Reason: 1
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.
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

HazardsMind

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

pYro_65


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: [Select]
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: [Select]
#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: [Select]

#ifdef USING_CLASS
  //Class specific code.
#endif

HazardsMind

Ah, ok I forgot about that. Thanks again Pyro.
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

HazardsMind

#8
Feb 25, 2014, 11:55 pm Last Edit: Feb 27, 2014, 11:17 pm by HazardsMind Reason: 1
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.
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

HazardsMind

#9
Mar 03, 2014, 12:03 am Last Edit: Mar 11, 2014, 02:06 am by HazardsMind Reason: 1
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.
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

HazardsMind

#10
Mar 30, 2014, 04:58 am Last Edit: Mar 30, 2014, 10:38 am by HazardsMind Reason: 1
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.
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

robtillaart

do you have some test program to see the performance - footprint of the lib?
Rob Tillaart

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

Jeroi

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.

HazardsMind

#13
Mar 30, 2014, 05:07 pm Last Edit: Mar 30, 2014, 05:20 pm by HazardsMind Reason: 1
@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.
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

robtillaart

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.

Rob Tillaart

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

Go Up