So I simply left this as the example. If I had wrote it, I probably wouldn't be initiating things repeatedly in the loop. So I moved it out just in case to look like this:
// UTFT_Buttons_Bitmap_Demo (C)2013 Henning Karlsen
// web: http://www.henningkarlsen.com/electronics
//
// A small demo to demonstrate the use of some of the
// functions of the UTFT_Buttons add-on library.
//
// This demo was made for modules with a screen resolution
// of 320x240 pixels, but should work on larger screens as
// well.
//
// This demo will not work on Arduino 2009/Uno/Leonardo
// due to the size of the images.
//
// This program requires both the UTFT and UTouch libraries
// in addition to the UTFT_Buttons add-on library.
//
// This code block is only needed to support multiple
// MCU architectures in a single sketch.
#if defined(__AVR__)
#define imagedatatype unsigned int
#elif defined(__PIC32MX__)
#define imagedatatype unsigned short
#elif defined(__arm__)
#define imagedatatype unsigned short
#endif
// End of multi-architecture block
#include <UTFT.h>
#include <UTouch.h>
#include <UTFT_Buttons.h>
// Declare which fonts we will be using
extern uint8_t BigFont[];
// Declare which bitmaps we will be using
extern imagedatatype cat[];
extern imagedatatype dog[];
extern imagedatatype bird[];
extern imagedatatype monkey[];
// Set up UTFT...
// Set the pins to the correct ones for your development board
// -----------------------------------------------------------
// Standard Arduino 2009/Uno/Leonardo shield : NOT SUPPORTED DUE TO LACK OF MEMORY
// Standard Arduino Mega/Due shield : <display model>,38,39,40,41
// CTE TFT LCD/SD Shield for Arduino Due : <display model>,25,26,27,28
// Standard chipKit Uno32/uC32 : <display model>,34,35,36,37
// Standard chipKit Max32 : <display model>,82,83,84,85
// AquaLEDSource All in One Super Screw Shield : <display model>,82,83,84,85
//
// Remember to change the model parameter to suit your display module!
UTFT myGLCD(ITDB32S,38,39,40,41);
// Set up UTouch...
// Set the pins to the correct ones for your development board
// -----------------------------------------------------------
// Standard Arduino 2009/Uno/Leonardo shield : NOT SUPPORTED DUE TO LACK OF MEMORY
// Standard Arduino Mega/Due shield : 6,5,4,3,2
// CTE TFT LCD/SD Shield for Arduino Due : 6,5,4,3,2
// Standard chipKit Uno32/uC32 : 20,21,22,23,24
// Standard chipKit Max32 : 62,63,64,65,66
// AquaLEDSource All in One Super Screw Shield : 62,63,64,65,66
UTouch myTouch(6,5,4,3,2);
// Finally we set up UTFT_Buttons :)
UTFT_Buttons myButtons(&myGLCD, &myTouch);
int but1, but2, but3, but4, but5, pressed_button;
void setup()
{
myGLCD.InitLCD();
myGLCD.clrScr();
myGLCD.setFont(BigFont);
myTouch.InitTouch();
myTouch.setPrecision(PREC_MEDIUM);
myButtons.setTextFont(BigFont);
but1 = myButtons.addButton( 10, 10, 80, 60, cat);
but2 = myButtons.addButton( 120, 10, 80, 60, dog);
but3 = myButtons.addButton( 10, 80, 80, 60, bird);
but4 = myButtons.addButton( 120, 80, 80, 60, monkey, BUTTON_NO_BORDER);
but5 = myButtons.addButton( 10, 150, 190, 30, "Disable Dog");
myButtons.drawButtons();
}
void loop()
{
myGLCD.print("You pressed:", 10, 200);
myGLCD.setColor(VGA_BLACK);
myGLCD.setBackColor(VGA_WHITE);
myGLCD.print("None ", 10, 220);
while(1)
{
if (myTouch.dataAvailable() == true)
{
pressed_button = myButtons.checkButtons();
if (pressed_button==but5)
if (myButtons.buttonEnabled(but2))
{
myButtons.disableButton(but2);
myButtons.relabelButton(but5, "Enable Dog", true);
myButtons.drawButton(but2);
}
else
{
myButtons.enableButton(but2);
myButtons.relabelButton(but5, "Disable Dog", true);
myButtons.drawButton(but2);
}
if (pressed_button==but1)
myGLCD.print("Cat ", 10, 220);
if (pressed_button==but2)
myGLCD.print("Dog ", 10, 220);
if (pressed_button==but3)
myGLCD.print("Bird ", 10, 220);
if (pressed_button==but4)
myGLCD.print("Monkey ", 10, 220);
if (pressed_button==-1)
myGLCD.print("None ", 10, 220);
}
}
}
I still can't get the touch screen to register a touch. I also bought a 4gb sd card and formatted it to FAT, but I still can't read that either. For that, I'm using the following example from UTFT:
// Demo_Landscape (C)2013 Henning Karlsen
// web: http://www.henningkarlsen.com/electronics
//
// This program is a demo of the loadBitmap()-function.
//
// This program requires UTFT_tinyFAT, UTFT v2.41 or higher,
// as well as tinyFAT v3.0 or higher.
//
// The image files must be present in the root folder
// of a FAT16 formatted SDcard in the module cardslot.
//
// Please note that this demo only supports the following
// display sizes:
// 220x176
// 320x240
// 400x240
// 480x272
// 800x480
#include <tinyFAT.h>
#include <UTFT.h>
#include <UTFT_tinyFAT.h>
// Declare which fonts we will be using
extern uint8_t SmallFont[];
UTFT myGLCD(ITDB32S, 38, 39, 40, 41); // Remember to change the model parameter to suit your display module!
UTFT_tinyFAT myFiles(&myGLCD);
// List of filenames for pictures to display.
char* files320[]={"PIC301.RAW", "PIC302.RAW", "PIC303.RAW", "PIC304.RAW", "PIC305.RAW", "PIC306.RAW", "PIC307.RAW", "PIC308.RAW", "PIC309.RAW", "PIC310.RAW"}; // 320x240
char* files400[]={"PIC401.RAW", "PIC402.RAW", "PIC403.RAW", "PIC404.RAW", "PIC405.RAW", "PIC406.RAW", "PIC407.RAW", "PIC408.RAW", "PIC409.RAW", "PIC410.RAW"}; // 400x240
char* files220[]={"PIC601.RAW", "PIC602.RAW", "PIC603.RAW", "PIC604.RAW", "PIC605.RAW", "PIC606.RAW", "PIC607.RAW", "PIC608.RAW", "PIC609.RAW", "PIC610.RAW"}; // 220x176
char* files480[]={"PIC701.RAW", "PIC702.RAW", "PIC703.RAW", "PIC704.RAW", "PIC705.RAW", "", "", "", "", ""}; // 480x272
char* files800[]={"PIC801.RAW", "PIC802.RAW", "PIC803.RAW", "PIC804.RAW", "PIC805.RAW", "", "", "", "", ""}; // 800x480
char* files[10];
int picsize_x, picsize_y;
boolean display_rendertime=false; // Set this to true if you want the rendertime to be displayed after a picture is loaded
boolean display_filename=true; // Set this to false to disable showing of filename
word res;
long sm, em;
void setup()
{
myGLCD.InitLCD();
myGLCD.clrScr();
file.initFAT();
myGLCD.setColor(255,255,255);
myGLCD.setFont(SmallFont);
picsize_x=myGLCD.getDisplayXSize();
picsize_y=myGLCD.getDisplayYSize();
switch (picsize_x)
{
case 220:
for (int z=0; z<sizeof(files220)/sizeof(*files220);z++)
files[z] = files220[z];
break;
case 320:
for (int z=0; z<sizeof(files320)/sizeof(*files320);z++)
files[z] = files320[z];
break;
case 400:
for (int z=0; z<sizeof(files400)/sizeof(*files400);z++)
files[z] = files400[z];
break;
case 480:
for (int z=0; z<sizeof(files480)/sizeof(*files480);z++)
files[z] = files480[z];
break;
case 800:
for (int z=0; z<sizeof(files800)/sizeof(*files800);z++)
files[z] = files800[z];
break;
}
}
void loop()
{
for (int i=0; i<(sizeof(files)/sizeof(*files)); i++)
{
if (files[i]!="")
{
sm=millis();
res=myFiles.loadBitmap(0, 0, picsize_x, picsize_y, files[i]);
em=millis();
if (res!=0)
{
if (res==0x10)
{
myGLCD.print("File not found...", 0, 0);
myGLCD.print(files[i], 0, 14);
}
else
{
myGLCD.print("ERROR: ", 0, 0);
myGLCD.printNumI(res, 56, 0);
}
delay(3000);
myGLCD.clrScr();
}
else
{
if (display_rendertime==true)
{
myGLCD.print("Rendertime (secs):", 0, 0);
myGLCD.printNumF(float((em-sm)/1000.0), 2, 160,0);
}
if (display_filename==true)
{
myGLCD.print(files[i], CENTER, myGLCD.getDisplayYSize()-12);
}
delay(3000);
}
}
}
}
This is really driving me nuts, is it possible they sent me a piece of crap and I need a new one?