ASCII characters I wanted to use for a flame are not supported, but I like the aggressive red text too.
#include // Include a special library to help draw things on the screen
#include // Include another library to talk to the screen we are using
#define BTN_PIN 5 // We are using pin number 5 on the board to check if a button is pressed
#define TFT_DC 2 // Pin 2 is connected to the screen's data command line
#define TFT_CS 15 // Pin 15 is connected to the screen's chip select line
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC); // Set up the screen using the pins we just picked
bool lastButtonState = HIGH; // Remember the last time we checked the button; start by thinking it's not pressed
bool currentMessageInfo = true; // This keeps track of whether we are showing the message or not
void displayMessage(const char* message, uint16_t color) {
tft.fillScreen(ILI9341_BLACK); // Clear the whole screen and make it black
tft.setCursor(0, 0); // Put the "pen" in the top-left corner of the screen
tft.setTextColor(color); // Choose what color the words will be
tft.setTextSize(2); // Make the letters a certain size (2 times bigger)
tft.println(message); // Write the message on the screen
}
void displayFireArt() {
tft.fillScreen(ILI9341_BLACK); // Clear the whole screen and make it black
tft.setCursor(0, 0); // Put the "pen" back to the top-left corner
tft.setTextColor(ILI9341_RED); // Make the letters red this time
tft.setTextSize(1); // Make the letters smaller for the art
// Now we are drawing a fire picture using special symbols
tft.println("⠀⠀⠀⠀⠀⠀⢱⣆⠀⠀⠀⠀⠀⠀");
tft.println("⠀⠀⠀⠀⠀⠀⠈⣿⣷⡀⠀⠀⠀⠀");
tft.println("⠀⠀⠀⠀⠀⠀⢸⣿⣿⣷⣧⠀⠀⠀");
tft.println("⠀⠀⠀⠀⡀⢠⣿⡟⣿⣿⣿⡇⠀⠀");
tft.println("⠀⠀⠀⠀⣳⣼⣿⡏⢸⣿⣿⣿⢀⠀");
tft.println("⠀⠀⠀⣰⣿⣿⡿⠁⢸⣿⣿⡟⣼⡆");
tft.println("⢰⢀⣾⣿⣿⠟⠀⠀⣾⢿⣿⣿⣿⣿");
tft.println("⢸⣿⣿⣿⡏⠀⠀⠀⠃⠸⣿⣿⣿⡿");
tft.println("⢳⣿⣿⣿⠀⠀⠀⠀⠀⠀⢹⣿⡿⡁");
tft.println("⠀⠹⣿⣿⡄⠀⠀⠀⠀⠀⢠⣿⡞⠁");
tft.println("⠀⠀⠈⠛⢿⣄⠀⠀⠀⣠⠞⠋⠀⠀");
}
void setup() {
pinMode(BTN_PIN, INPUT_PULLUP); // Set the button pin to be ready to detect when it's pressed
tft.begin(); // Turn on the screen
tft.setRotation(1); // Make sure the screen is the right way around
// Show a special message with details when the screen turns on
displayMessage("IEEE Robotics and Automation Letters:\nThe deadline of review 374029 of submission 24-2685 is September 28, 2024.\nThis is 3 days from today.", ILI9341_WHITE);
}
void loop() {
bool buttonState = digitalRead(BTN_PIN); // Check if the button is being pressed right now
// See if the button was pressed or released
if (buttonState != lastButtonState) {
lastButtonState = buttonState; // Remember this new button state
if (buttonState == LOW) { // If the button is pressed
// Show the fire art instead of the message
if (currentMessageInfo) {
displayFireArt(); // Draw the fire art
currentMessageInfo = false; // We are no longer showing the message
}
} else { // If the button is released
// Go back to showing the message
if (!currentMessageInfo) {
displayMessage("IEEE Robotics and Automation Letters:\nThe deadline of review 374029 of submission 24-2685 is September 28, 2024.\nThis is 3 days from today.", ILI9341_WHITE);
currentMessageInfo = true; // Now we are showing the message again
}
}
}
delay(50); // Wait for a tiny bit so the button doesn't get confused when pressed
}