/*
Simple "Hello World" for ILI9341 LCD
https://wokwi.com/arduino/projects/308024602434470466
*/
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#define TFT_DC 9
#define TFT_CS 10
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
#define BROWN 0x79E0
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
void drawVerticalText(const char* text, int x, int y) {
int yOffset = 16; // Adjust this value based on the text size and spacing
for (int i = 0; i < strlen(text); i++) {
tft.setCursor(x, y + i * yOffset);
tft.print(text[i]);
}
}
void setup() {
tft.begin();
tft.setRotation(3);
tft.fillScreen(WHITE);
tft.setTextSize(1);
tft.setTextColor(BLACK);
int width_stairs = 20;
// Stair 1 (left side)
tft.drawRect(0,0,width_stairs,240,BROWN);
for (int y = 10; y <= 240; y += 10) {
tft.drawFastHLine(0, y, width_stairs, BROWN); // (x, y, width, color)
}
// Stair 2 (right side)
tft.drawRect(300,0,width_stairs,240,BROWN);
for (int y = 10; y <= 240; y += 10) {
tft.drawFastHLine(300, y, width_stairs, BROWN); // (x, y, width, color)
}
// Horizontal line
// Level 4
tft.drawFastHLine(0, 60, 320, BROWN); // (x, y, width, color)
// Level 3
tft.drawFastHLine(0, 120, 320, BROWN); // (x, y, width, color)
// Level 2
tft.drawFastHLine(0, 180, 320, BROWN); // (x, y, width, color)
// Vertical line
tft.drawFastVLine(76, 0, 240, BROWN);
tft.drawFastVLine(132, 0, 240, BROWN);
tft.drawFastVLine(188, 0, 240, BROWN);
tft.drawFastVLine(244, 0, 240, BROWN);
// room number (Level 4)
tft.setCursor(45,30);
tft.print("X");
tft.setCursor(96,30);
tft.print("401");
tft.setCursor(160,30);
tft.print("X");
tft.setCursor(208,30);
tft.print("404");
tft.setCursor(272,30);
tft.print("X");
// room number (Level 3)
tft.setCursor(40,90);
tft.print("301");
tft.setCursor(96,90);
tft.print("304");
tft.setCursor(160,90);
tft.print("X");
tft.setCursor(208,90);
tft.print("305");
tft.setCursor(264,90);
tft.print("306");
// room number (Level 2)
tft.setCursor(40,150);
tft.print("201");
tft.setCursor(96,150);
tft.print("204");
tft.setCursor(148,143);
tft.print("Surau");
tft.setCursor(147,157);
tft.print("Lelaki");
tft.setCursor(208,150);
tft.print("213");
tft.setCursor(264,150);
tft.print("214");
// // room number (Level 1)
tft.setCursor(40,210);
tft.print("104");
tft.setCursor(104,210);
tft.print("X");
tft.setCursor(160,210);
tft.print("X");
tft.setCursor(216,210);
tft.print("X");
tft.setCursor(264,210);
tft.print("105");
}
void loop() { }