#include #include "Adafruit_GFX.h" #include "Adafruit_ST7796S_kbv.h" #include "headerFile.h" #include "displayText.h" int i = 0; char* Question[] = { "How clean are the toilets?", "How clean is the study area?", "What do you think of the temperature in the study area?", "How crowded would you say the study area is?", "Is there enough help available?" }; char* Answer[] = { "clean, normal, disgusting", "clean, normal, disgusting", "hot, perfect, cold", "not at all, its fine, really crowded", "no, decently, yes" }; //simplify the name of the library Adafruit_ST7796S_kbv tft = Adafruit_ST7796S_kbv(TFT_CS, TFT_DC, MOSI, SCK, TFT_RST, MISO); DisplayText displayText(tft); void setup() { tft.begin(); // Initialize the display tft.setRotation(3); // Set the rotation to horizontal tft.fillScreen(ST7796S_BLACK); } void loop() { i++; if (i == 5) { i = 0; } tft.fillScreen(ST7796S_BLACK); // Fill the screen with black color // writeText(Question[0], 2, 50, 0, 0); // writeText(Answer[0], 2, 50, 300, 4000); displayText.writeText(Question[i], 3, 0, 0, 0, true, false); displayText.writeText(Answer[i], 3, 0, 200, 0, true, true); delay(10000); } // void writeText(char* text, int size, int posX, int posY, int screenTime, bool center){ // //if true overwrites x // if (center){ // posX = centerText(text); // } // tft.setCursor(posX, posY); // Set the cursor to the top left corner // tft.setTextSize(size); // Set textsize // tft.println(text); // delay(screenTime); // } // int centerText(char* text) { // int16_t x1, y1; // uint16_t w, h; // tft.getTextBounds(text, 0, 0, &x1, &y1, &w, &h); // Calculate the width of the text // int x = (tft.width() - w) / 2; // Calculate the x-coordinate for the centered text // return x; // }