#include <SPI.h>
//#include <Adafruit_GFX.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <XPT2046_Touchscreen.h>
#define TFT_CS 15 // Chip select pin
#define TFT_DC 2 // Data/Command pin
#define TFT_RST 4 // Reset pin, -1 means no reset pin
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
XPT2046_Touchscreen ts(TFT_CS);
void setup() {
Serial.begin(115200);
tft.begin();
// touchscreen.begin();
tft.setRotation(1); // Set rotation if needed
tft.fillScreen(ILI9341_WHITE); // Clear screen with white background
drawBellIcon(120, 160); // Call function to draw bell icon
}
void drawBellIcon(int x, int y) {
// Draw the bell body
tft.fillCircle(x, y, 20, ILI9341_YELLOW); // Bell dome
tft.fillRect(x-20 , y, 40, 20, ILI9341_YELLOW); // Bell base
// Draw the clapper
tft.fillCircle(x, y + 20, 5, ILI9341_YELLOW); // Clapper in red
// Draw the handle
tft.fillRect(x-5 , y-30 , 10, 10, ILI9341_YELLOW); // Handle on top
/*
// Draw alarm indicators (e.g., lines or circles around the bell)
tft.drawLine(x - 30, y - 30, x + 30, y - 30, ILI9341_RED); // Top line
tft.drawLine(x - 30, y + 30, x + 30, y + 30, ILI9341_RED); // Bottom line
tft.drawLine(x - 30, y - 30, x - 30, y + 30, ILI9341_RED); // Left line
tft.drawLine(x + 30, y - 30, x + 30, y + 30, ILI9341_RED); // Right line*/
}
void loop() {
if (ts.touched()) {
TS_Point p = ts.getPoint();
if (p.x > 100 && p.x < 140 && p.y > 80 && p.y < 140) { // Check if touch is within bell icon bounds
Serial.println("Bell icon touched!");
// Add any additional actions here (e.g., play sound)
}
}
}