0% found this document useful (0 votes)
138 views

TFT Program

The document defines code for an Arduino project that uses a touchscreen and LCD display. It includes libraries for graphics, touchscreen handling, and LCD control. Pin definitions are provided for connecting the touchscreen and LCD. Functions are defined to initialize the display, draw menu screens, and handle touch input to navigate between menu options for food types (e.g. North Indian, South Indian). Touch coordinates and pressure thresholds are used to detect user input and transitions between menu screens.

Uploaded by

Puneeth Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
138 views

TFT Program

The document defines code for an Arduino project that uses a touchscreen and LCD display. It includes libraries for graphics, touchscreen handling, and LCD control. Pin definitions are provided for connecting the touchscreen and LCD. Functions are defined to initialize the display, draw menu screens, and handle touch input to navigate between menu options for food types (e.g. North Indian, South Indian). Touch coordinates and pressure thresholds are used to detect user input and transitions between menu screens.

Uploaded by

Puneeth Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

#include <Adafruit_GFX.

h> // Adafruit's core graphics library


#include <Adafruit_TFTLCD.h> // Adafruit's hardware-specific library
#include <TouchScreen.h> //Touchscreen library
#include <Fonts/Org_01.h> //Include a different font

bool backsensed = false;


bool resetsensed = false;

//Sense touch trough these pins


#define YP A3 // must be an analog pin
#define XM A2 // must be an analog pin
#define YM 9 // can be a digital pin
#define XP 8 // can be a digital pin

#define TS_MINX 100


#define TS_MINY 120
#define TS_MAXX 920
#define TS_MAXY 940
//Create the touchscreen object
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300); //
(data,data,data,data,sensitivity);
//Some of the tft pins
#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
// Optional, used to reset the display
#define LCD_RESET A4
#define REDBAR_MINX 80
#define GREENBAR_MINX 130
#define BLUEBAR_MINX 180
#define BAR_MINY 30
#define BAR_HEIGHT 250
#define BAR_WIDTH 30
//Create the tft object
Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);

// Define some TFT readable colour codes to human readable names


#define BLACK 0x0000
int BLUE = tft.color565(50, 50, 255);
#define DARKBLUE 0x0010
#define VIOLET 0x8888
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
#define GREY tft.color565(64, 64, 64);
#define GOLD 0xFEA0
#define BROWN 0xA145
#define SILVER 0xC618
#define LIME 0x07E0
int currentpcolour;

//Minimum and maximum pressure to sense the touch


#define MINPRESSURE 10
#define MAXPRESSURE 1000
#define DRAW_LOOP_INTERVAL 50 //The interval used instead of delay();

#define addr 0
int currentpage;
void drawHome()
{

tft.fillScreen(CYAN);
tft.drawRoundRect(0, 0, 319, 240, 8, WHITE); //Page border

tft.fillRoundRect(60, 180, 200, 40, 8, RED);


tft.drawRoundRect(60, 180, 200, 40, 8, WHITE); //chats

tft.fillRoundRect(60, 140, 200, 40, 8, RED);


tft.drawRoundRect(60, 140, 200, 40, 8, WHITE); //chineese

tft.fillRoundRect(60, 100, 200, 40, 8, RED);


tft.drawRoundRect(60, 100, 200, 40, 8, WHITE); //south indian

tft.fillRoundRect(60, 60, 200, 40, 8, RED);


tft.drawRoundRect(60, 60, 200, 40, 8, WHITE); //north indian

tft.setCursor(20, 10);
tft.setTextSize(3);
tft.setFont();
tft.setTextColor(YELLOW);
tft.print("Techno!!");

tft.setCursor(70, 35);
tft.setTextSize(2);
tft.setTextColor(BLACK);
tft.print("menu orders");
tft.setTextColor(BLACK);

tft.setCursor(90, 76);
tft.print("North Indian");

tft.setCursor(85, 195);
tft.print(" Chats");

tft.setCursor(107, 155);
tft.print("Chineese");

tft.setCursor(85, 112);
tft.print("South Indian");
}

void setup()
{
tft.reset();
tft.begin(tft.readID());
Serial.begin(9600);
Serial.println();
Serial.print("reading id...");
delay(500);
Serial.println(tft.readID(), HEX);
tft.fillScreen(BLACK);
tft.setRotation(1);
currentpage = 0;
tft.setTextSize(3);
tft.setTextColor(WHITE);
tft.setCursor(50, 140);
tft.print("Welcome");

tft.setTextColor(tft.color565(255, 255, 0));


tft.setCursor(30, 70);
tft.print("By:");

tft.setCursor(30, 100);
tft.print("Techno!!");

for (int i; i < 250; i++)


{
tft.fillRect(BAR_MINY - 10, BLUEBAR_MINX, i, 10, RED);
delay(10);
}
tft.fillScreen(BLACK);

drawHome();

}
void loop()
{

digitalWrite(13, HIGH);
TSPoint p = ts.getPoint(); // Read touchscreen
digitalWrite(13, LOW);

pinMode(XM, OUTPUT);
pinMode(YP, OUTPUT);

if (currentpage == 0)
{
if (p.z > 10 && p.z < 1000)
{
if (p.x > 736 && p.x < 855 && p.y > 255 && p.y < 725 && p.z > MINPRESSURE &&
p.z < MAXPRESSURE)
{
Serial.println("Chats");

tft.fillRoundRect(60, 180, 200, 40, 8, WHITE);

delay(70);
tft.fillRoundRect(60, 180, 200, 40, 8, RED);
tft.drawRoundRect(60, 180, 200, 40, 8, WHITE);
tft.setCursor(85, 195);

tft.println(" Chats");
delay(70);
}

// delay(500);

currentpage = 1;

tft.fillScreen(CYAN);
tft.drawRoundRect(0, 0, 319, 240, 8, WHITE); //Page border

tft.fillRoundRect(60, 180, 200, 40, 8, RED);


tft.drawRoundRect(60, 180, 200, 40, 8, WHITE); //Game

tft.fillRoundRect(60, 140, 200, 40, 8, RED); //RGB led


tft.drawRoundRect(60, 140, 200, 40, 8, WHITE);

tft.fillRoundRect(60, 100, 200, 40, 8, RED);


tft.drawRoundRect(60, 100, 200, 40, 8, WHITE); //Oscilloscope

tft.fillRoundRect(60, 60, 200, 40, 8, RED);


tft.drawRoundRect(60, 60, 200, 40, 8, WHITE);

tft.setCursor(90, 76);
tft.print("North Indian");

tft.setCursor(85, 195);
tft.print(" Chats");

tft.setCursor(107, 155);
tft.print("Chineese");

tft.setCursor(85, 112);
tft.print("South Indian");
// delay(500);
}
else if (p.x > 600 && p.x < 683 && p.y > 275 && p.y < 750)
{
Serial.println("Chineese");

tft.fillRoundRect(60, 140, 200, 40, 8, WHITE); //rgb led


delay(70);

tft.fillRoundRect(60, 140, 200, 40, 8, RED); //rgb led


tft.drawRoundRect(60, 140, 200, 40, 8, WHITE); //rgb led
tft.setCursor(107, 155);

tft.print("Chineese");
delay(70);

currentpage = 2;
tft.fillScreen(CYAN);
tft.drawRoundRect(0, 0, 319, 240, 8, WHITE); //Page border

tft.fillRoundRect(60, 180, 200, 40, 8, RED);


tft.drawRoundRect(60, 180, 200, 40, 8, WHITE); //Game

tft.fillRoundRect(60, 140, 200, 40, 8, RED); //RGB led


tft.drawRoundRect(60, 140, 200, 40, 8, WHITE);

tft.fillRoundRect(60, 100, 200, 40, 8, RED);


tft.drawRoundRect(60, 100, 200, 40, 8, WHITE); //Oscilloscope

tft.fillRoundRect(60, 60, 200, 40, 8, RED);


tft.drawRoundRect(60, 60, 200, 40, 8, WHITE);

tft.setCursor(90, 76);
tft.print("North Indian");
tft.setCursor(85, 195);
tft.print(" Chats");

tft.setCursor(107, 155);
tft.print("Chineese");

tft.setCursor(85, 112);
tft.print("South Indian");
// delay(500);
}
if (p.x > 500 && p.x < 525 && p.y > 271 && p.y < 725)
{
Serial.println("Oscilloscope");

currentpage = 3;

tft.fillRoundRect(60, 100, 200, 40, 8, WHITE);


delay(70);

tft.fillRoundRect(60, 100, 200, 40, 8, RED);


tft.drawRoundRect(60, 100, 200, 40, 8, WHITE);

tft.setCursor(85, 112);
tft.print("South Indian");
delay(70);

tft.setCursor(90, 76);
tft.print("North Indian");
tft.setCursor(85, 195);
tft.print(" Chats");

tft.setCursor(107, 155);
tft.print("Chineese");

tft.setCursor(85, 112);
tft.print("South Indian");
// delay(500);
}
}
}

You might also like