#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#define TFT_DC 2
#define TFT_CS 15
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
// Dummy variable names
const char* dummyT1 = "T1";
const char* dummyT2 = "T2";
const char* dummyT3 = "T3";
const char* dummyT4 = "T4";
const char* Flow = "Flow";
void setup() {
tft.begin();
tft.setRotation(3); // Adjust based on your setup
tft.fillScreen(ILI9341_BLACK); // Clear the screen
// Draw the pattern
drawPattern();
}
void loop() {
// Nothing here
}
void drawPattern() {
// Set text color and size
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(1);
// Draw the dummy variables
tft.setCursor(152, 10); // Position for T2
tft.println(dummyT2);
tft.setCursor(62, 40); // Position for T3
tft.println(dummyT3);
tft.setCursor(180, 55); // Position for T4
tft.println(dummyT4);
tft.setCursor(18, 120); // Position for Flow
tft.println(Flow);
tft.setCursor(100, 120); // Position for Flow
tft.println(dummyT1);
// Draw the pixel pattern
drawPixelPattern();
//Additional Info
drawAdditionalInfo();
drawFilledLeftArrow(62,68,18,ILI9341_RED);
}
void drawPixelPattern() {
// Fill the area with the pattern based on the provided layout
const uint16_t x_offset = 5; // X offset for centering
const uint16_t y_offset = 5; // Y offset for starting position
// Each '#' will be represented by a filled rectangle
// The pattern provided in the 220x300 area is represented by '#' and spaces
// Each '#' will be 10 pixels wide and 10 pixels high
int width = 5;
int height = 5;
uint16_t color = ILI9341_RED; // Color for the '#' symbols
// Correct pattern layout based on your provided example
const char* pattern[29] = {
"..........................................",
"...........######.........................",
"..........#......#.........................",
".........##.....########.................",
"........#.........#....#.................",
".......#...........#...#.................",
"......###############..#.................",
".......#...............#..................",
".......#...............#.....############.",
".......#...............#.....#..........#.",
".......#...............#.....#..........#.",
".......#...............#######..........#.",
".......#.....................#..........#.",
".......#.....................#..........#.",
".......#######################..........#.",
".........#.........#.........############.",
".........#.........#.......................",
".........#.........#.......................",
".........#.........#.......................",
".........#.........#.......................",
".........#.........#.......................",
".##########.....##########..................",
".#........#.....#........#..................",
".#........#.....#........#..................",
".#........#.....#........#..................",
".#........#.....#........#..................",
".#........#.....#........#..................",
".##########.....##########..................",
"............................................"
};
// Loop through the pattern array to draw it on the screen
for (int y = 0; y < 29; y++) {
for (int x = 0; x < 42; x++) { // Adjust the width for the correct number of characters
if (pattern[y][x] == '#') {
tft.fillRect(x * width + x_offset, y * height + y_offset, width, height, color);
}
}
}
}
void drawAdditionalInfo() {
// Set text color and size for additional info
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(1);
// Draw additional information on the right side of the display
int x_position = 215; // Adjust the X position for the right side
int y_position = 75; // Starting Y position
// Displaying each line of information
tft.setCursor(x_position, y_position);
tft.println("Mode: STANDBY ONLY");
tft.setCursor(x_position, y_position + 20); // Next line
tft.println("dT: -0.5 dec");
tft.setCursor(x_position, y_position + 40); // Next line
tft.println("Pump: ON");
tft.setCursor(x_position, y_position + 60); // Next line
tft.println("Energy: 4.07Kw");
tft.setCursor(x_position, y_position + 80); // Next line
tft.println("\"HC200 V4.03\"");
}
void drawFilledLeftArrow(int x, int y, int size, uint16_t color) {
// Calculate the vertices of the triangle
int x1 = x; // Left tip of the arrow
int y1 = y + size / 2; // Middle height
int x2 = x + size; // Right point of the arrow
int y2 = y; // Top height of the arrow
int x3 = x + size; // Right point of the arrow
int y3 = y + size; // Bottom height of the arrow
// Draw the filled triangle (left arrow)
tft.fillTriangle(x1, y1, x2, y2, x3, y3, color);
}