New TFT Extension Library

Thank you HazardsMind! I updated my UTFT library provided by Henning Karlson, and that fixed my problems with compiling your examples.

Something that my be helpful for other people using your examples would be this bit of commenting, and code that was provided with the UTFT library.

// Uncomment the next two lines for the Arduino 2009/UNO
//UTFT        myGLCD(ITDB24D,19,18,17,16);   // Remember to change the model parameter to suit your display module!
//UTouch      myTouch(15,10,14,9,8);

// Uncomment the next two lines for the Arduino Mega
UTFT        myGLCD(ITDB32S, 38,39,40,41);   // Remember to change the model parameter to suit your display module!
UTouch      myTouch(6,5,4,3,2);

Thank you for your work! It will really help me make some nice display screens!

I will include those. I also need to point out that some TFT LCD you buy online may appear to have the proper UTFT and Touch libraries, but in fact they are usually modified versions(fake) made for that particular TFT display. Mine just so happens to be one of those fake displays, so I am unable to use the real UTFT library, unless I buy a new display.

But never the less I found a way around that and made this library that works for both types of displays.

New game: Missile Bomber

Objective: destroy the incoming missiles and do NOT let them fall to the ground. Each missile is enough to wipe out an entire city, and if all 20 cities are destroyed, game over.

To destroy a missile, touch the center of them. 5 points for blowing up a missile, and 50 points triggers an additional missile. (6 max)

(Please keep in mind that an Arduino is not meant to display fast moving objects, so it will slow down.)

If anyone has a Due, let me know if it is any better. A small video would be helpful.

Missile_Bomber.ino (3.07 KB)

this is really help full for the draw gauge function thanks, is it possible to to draw more than one gauge?

I could make it so you could have more than one guage, let me modify the library.

if you wouldn't mind doing that that would be fantastic.

edit: also the HorSlider and VertSlider functions can they be used as a display? for instance analogRead(A0) map the values from 0-100 then use those as a display?

edit: also the HorSlider and VertSlider functions can they be used as a display? for instance analogRead(A0) map the values from 0-100 then use those as a display?

? What kind of display? They return 0-100 as a percent, so what else do you have in mind?

Updated library with new Gauges (10 Max)

Also all _Draw functions, (TouchButton_Draw, LatchCircle_Draw, TouchTriangle_Draw. . . etc) are now able to have centered text, they don’t limit the text to the size of the “button”, sorry too much code for that.
See the Latching_Buttons example.

Question for everyone else.
The library is kinda getting out of hand with all the structs, so if anyone has a better alternative, please share it. At first I was thinking of making everything into individual classes, but then everyone would need to drastically modify there sketches to use them. So if anyone has any ideas, please share and I will see what I can do. (64.4 KB)

ok im pulling data from a megasquirt ecu via serial, i trying to make a display to show various information from the engine sensors connected to that, for instance using the slider like a bar graph to display throttle the throttle.

Oh ok, so the other way around, instead of being a slider, you want a bar graph. Yea I can do that.

Ah that would rock, just tried your update and its working good tried with 4 gauges on the screen, had them all reading from a 10k pot all working good thanks. i did try it before with just one gauge and it worked on pulling the data via serial and displaying it on the gauge as well

Library is updated with new functions, HorBarGraph and VertBarGraph. Go back to previous post and re-download. Look at [u]Horizontal_BarGraph[/u] example to see how it is used.

I also added your username to the .h file.

oh got it that rocks, with those additions gives me just what i need to continue with my project.

been playing about with this some more, i'm using a switch case from a push button input to change between 3 different pages i want it to draw that works, first page just basic prints to the screen of the sensor readings, push button then page 2 so far i'm using drawgauge to draw 2 gauges one for engine rpm and the second for throttle 0-100% they work its a bit slow drawing them at first but the needle movements are quick enough after the back ground has drawn to the screen not to much of a biggie, then page3 will be some bar graphs ect not got that far yet though. the issue im having if you cycle from page 1,2,3 back to 1 then the second time on to page 2 the backgrounds don't get drawn only the needles part of the gauges.


Would you mind sharing some of your switch case code? I am wanting to learn how to put the buttons and gauges to use but, I haven't figured it out yet.

Ok, I can make a quick function to allow you to repaint the gauge.

Function: ResetGauge( byte _ID ), This should go in the next and previous pages of the gauge. So if your gauges are on page 2, then this function needs to be in pages 1 and 3. So when you go back to page 2, the gauge will be repainted.

Library added below. (64.4 KB)

wicked il give that a go and report back thanks again, this is a basic striped down version of how i'm drawing the pages.


extern uint8_t BigFont[];

UTFT myGLCD(SSD1289,38,39,40,41); 
UTouch        myTouch(6,5,4,3,2);
TFT_Extension myTFT(&myGLCD, &myTouch, LANDSCAPE);

const int  buttonPin = A1;    // the pin that the pushbutton is attached to

int buttonPushCounter = 0;   // counter for the number of button presses
int ButtonState = 0;         // current state of the button
int lastState = 0;     // previous state of the button

void page1(){
  myGLCD.setColor(255, 0, 0);
  myGLCD.print(" page 1 ",CENTER, 80);
void page2(){
  myGLCD.setColor(0, 255, 0);
  myGLCD.print(" page 2 ",CENTER, 120);
void page3(){
  myGLCD.setColor(0, 0, 255);
  myGLCD.print(" page 3 ",CENTER, 150);

void setup() {
  pinMode(buttonPin, INPUT);
  myGLCD.setColor(0, 0, 255);
  myGLCD.print(" TEST ",CENTER, 1);


void loop() {
  ButtonState = digitalRead(buttonPin);

  if(ButtonState && ButtonState != lastState)  // button latch, no debounce needed.

    if(buttonPushCounter < 2) // This will check to see if the count is within a range of 0 - 2, and anything over that, it will reset count back to 0. Of course, this will happen anyways because count is a BYTE, and not an int or any other type.

      buttonPushCounter += 1; // same as count = count + 1;

      buttonPushCounter = 0;

  lastState = ButtonState;

  switch (buttonPushCounter) {
  case 0:    
  case 1:   

  case 2:    

You could put the reset functions inside the case statements before you load the pages. Or you can put them inside the pages themselves, whichever is easier for you.

i put them in the case statements for case 0 and 2 and now they re draw :D :D

i was having a play with this again and run in to a problem the gauges were taking a long time to draw a couple of seconds maybe and this was sometimes causing me to loose sync with the data form the ecu so i made a small edit to the library...

_Disp->fillCircle(pos_x, pos_y, rad);
//drawArc(pos_x, pos_y, rad, rad, start, stop, WHITE);
//drawArc(pos_x, pos_y, rad, 0, start, stop, BLACK);

does not look quite as cool but draws and re-draws super quick and you can still set the sweep angle for the gauge, hope you don't mind.

If it helps you then that's fine. I will try to make it faster if I can.