#include <Adafruit_GFX.h> // Core graphics library
#include <SPI.h> // Include SPI library for display
#include <Adafruit_ILI9341.h>
#include <Arduino.h> // Include Arduino Library for FT6206
#include <Adafruit_FT6206.h>
#include "displaySetup.h"// Include the display setup file
#include "definitions.h" // Include definitions
#include "function_prototypes.h"// Include function prototypes
#include "globalV.h" // Include global variables file
#include "touchscreen.h" // Include touchscreen file
#include "utility.h" // Include utility functions file
#include "display.h" // Include display functions file
#include "handling.h" // Include handling functions file
#include "gameLogic.h" // Include game logic functions file
#define DEBUG_MODE true
// Setup and Loop Functions
void setup() {
Serial.begin(115200); // Initialize serial communication
Serial.println("Initializing...");
// Initialize display
display.begin();
display.setRotation(0);
// Initialize touchscreen
Wire.setPins(10, 8); // Redefine I2C pins for ESP32
if (!ctp.begin(40)) {
Serial.println("Couldn't start touchscreen controller");
while (1); // Halt program execution if touchscreen initialization fails
}
Serial.println("Setup complete.");
clearScreen(); // Clear the display
displayWelcomeScreen(); // Display the welcome screen
displayAccess(); // Display the Access screen
}
void loop() {
if (currentLevel[0] == -1) {
displayButtons();
} else {
handleGuessInput();
if (gameInProgress) {
displayTime();
delay(500); // Delay of 500 milliseconds for smoother updates
}
}
}