Files
J1B3-Sensor-boxes/arduino/Screen code/writetext function.ino
2024-03-05 16:02:12 +01:00

40 lines
1.2 KiB
C++

#include <SPI.h>
#include "Adafruit_GFX.h"
#include "Adafruit_ST7796S_kbv.h"
#include "headerFile.h"
char* Question[] = {
"How clean are the toilets? (clean, normal, disgusting).",
"How clean is the study area? (clean, normal, disgusting).",
"What do you think of the temperature in the study area? (hot, perfect, cold).",
"How crowded would you say the study area is?(not at all, its fine, really crowded).",
"Is there enough help available? (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);
void setup() {
tft.begin(); // Initialize the display
tft.setRotation(3); // Set the rotation to horizontal
tft.fillScreen(ST7796S_BLACK);
}
void loop() {
writeText(Question[0], 2, 0, 0, 4000);
writeText(Question[1], 2, 0, 0, 4000);
writeText(Question[2], 2, 0, 0, 4000);
}
void writeText(char* text, int size, int posX, int posY, int screenTime){
tft.fillScreen(ST7796S_BLACK); // Fill the screen with black color
tft.setCursor(posX, posY); // Set the cursor to the top left corner
tft.setTextSize(size); // Set textsize
tft.println(text);
delay(screenTime);
}