#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
// Include the necessary libraries for your Wi-Fi module (e.g., ESP8266)
#include <WiFi.h>
// Define TFT screen pins
#define TFT_CS 10
#define TFT_DC 9
#define TFT_RST 8
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
// Define Wi-Fi credentials
const char *ssid = "your-ssid";
const char *password = "your-password";
// Define speaker pin
#define SPEAKER_PIN 7
// Function prototypes
void displayWelcomePage();
void displayFoodMenu();
void displayDrinkMenu();
void displayOrderProcessing();
void displayThankYou();
void setup() {
// Initialize TFT screen
tft.begin();
tft.setRotation(1); // Adjust the rotation if needed
// Initialize Wi-Fi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
// Initialize speaker
pinMode(SPEAKER_PIN, OUTPUT);
// Display welcome page initially
displayWelcomePage();
}
void loop() {
// Your main loop code goes here
// For simplicity, you can use a button press to trigger menu changes
// For now, let's just loop indefinitely
while (true) {
displayFoodMenu(); // Display food menu
delay(5000); // Wait for 5 seconds
displayDrinkMenu(); // Display drink menu
delay(5000); // Wait for 5 seconds
displayOrderProcessing(); // Display order processing page
delay(3000); // Wait for 3 seconds
displayThankYou(); // Display thank you page
delay(5000); // Wait for 5 seconds
}
}
void displayWelcomePage() {
tft.fillScreen(ILI9341_BLACK);
tft.setTextSize(3);
tft.setTextColor(ILI9341_WHITE);
tft.setCursor(30, 100);
tft.print("Welcome to");
tft.setCursor(30, 150);
tft.print("Smart Desk");
delay(2000); // Display welcome page for 2 seconds
}
void displayFoodMenu() {
tft.fillScreen(ILI9341_BLACK);
tft.setTextSize(2);
tft.setTextColor(ILI9341_WHITE);
tft.setCursor(10, 20);
tft.print("Today's Food Items");
// Display 3x3 food menu items (you can customize this based on your actual menu)
for (int row = 0; row < 3; row++) {
for (int col = 0; col < 3; col++) {
tft.setCursor(10 + col * 80, 50 + row * 40);
tft.print("Food Item");
}
}
// You can add button logic here to detect selection
// For simplicity, let's wait for 5 seconds
delay(5000);
}
void displayDrinkMenu() {
tft.fillScreen(ILI9341_BLACK);
tft.setTextSize(2);
tft.setTextColor(ILI9341_WHITE);
tft.setCursor(10, 20);
tft.print("Today's Drinks");
// Display 2x2 drink menu items (you can customize this based on your actual menu)
for (int row = 0; row < 2; row++) {
for (int col = 0; col < 2; col++) {
tft.setCursor(10 + col * 120, 50 + row * 60);
tft.print("Drink Item");
}
}
// You can add button logic here to detect selection
// For simplicity, let's wait for 5 seconds
delay(5000);
}
void displayOrderProcessing() {
tft.fillScreen(ILI9341_BLACK);
tft.setTextSize(2);
tft.setTextColor(ILI9341_WHITE);
tft.setCursor(30, 100);
tft.print("Order Processing");
delay(3000); // Display order processing for 3 seconds
}
void displayThankYou() {
tft.fillScreen(ILI9341_BLACK);
tft.setTextSize(2);
tft.setTextColor(ILI9341_WHITE);
tft.setCursor(30, 100);
tft.print("Thank You!");
delay(2000); // Display thank you page for 2 seconds
}