I have to create a weather station for my hnc electronics course using arduino
I have a tft touchscreen and want to create buttons, I have a start screen and I want a menu button at the bottom. most of what I have done so far is copy and paste. I can get the start page working. this just shows the title, my name and sensor names. at the bottom I have a rectangle with menu written in it. I have tried to make this a button by using parts of the examples that come with the libraries. but I cant get the button to work.
#include <UTFT.h>
#include <UTouch.h>
#include <UTFT_Buttons.h>
// Declare which fonts we will be using
extern uint8_t BigFont[];
extern uint8_t SevenSegNumFont[];
UTFT myGLCD(ITDB32S,38,39,40,41);
UTouch myTouch(6,5,4,3,2);
UTFT_Buttons myButtons(&myGLCD, &myTouch);
void start()
{
//set colour for the title, display title and position on x axis(center) and position on y axis(0, 16)
myGLCD.setColor(0, 0, 255);
myGLCD.print("WEATHER STATION", CENTER, 0);
myGLCD.print("PROJECT", CENTER, 16);
//set colour to red, name and sensor names with positions
myGLCD.setColor(255, 0, 50);
myGLCD.print("By Simon Bradley", CENTER, 32);
myGLCD.print(" -DHT22", CENTER, 48);
myGLCD.print(" -BMP108", CENTER, 64);
myGLCD.print(" -LDR", CENTER, 80);
//set colour to green, more names and positions
myGLCD.setColor(0, 255, 0);
myGLCD.print("ARDUINO PROJECT", CENTER, 112);
myGLCD.print("Engineering Science", CENTER, 144);
//set colour to blue create menu button
myGLCD.setColor(0, 0, 255);
myGLCD.fillRoundRect (118, 170, 199, 199);
myGLCD.setColor(255, 255, 255);
myGLCD.drawRoundRect (118, 170, 199,199 );
myGLCD.print("Menu", CENTER, 176);
}
void setup()
{
myGLCD.InitLCD();
myGLCD.clrScr();
myGLCD.setFont(BigFont);
myTouch.InitTouch();
myTouch.setPrecision(PREC_MEDIUM);
myButtons.setTextFont(BigFont);
start();
}
void loop()
{
int menu;
menu = myButtons.addButton( 118, 170, 199, 199, "menu", 0);
myButtons.drawButtons();
while(1)
{
if (myTouch.dataAvailable() == true)
{
pressed_button = myButtons.checkButtons();
if (pressed_button==menu)
myGLCD.clrScr();
myGLCD.setColor(255,255,255);
myGLCD.print("MENU ", CENTER, 0);
}
}
}
this is what I have so far. im new to this and understand some things, enough to create a start page. when I try to compile this it comes up with an error saying "pressed button not declared". I don't understand what the "true" coment means in this - if (myTouch.dataAvailable() == true)
im thinking that because of this - myTouch.dataAvailable()
I should use a myTouch.readData() or something like that?
any help would be great, I intend to document my project to help others so your help will go further!
happy new year
simon