From d3952306b227c844e65f6a9824580b456dc06e99 Mon Sep 17 00:00:00 2001 From: sam Date: Tue, 5 Mar 2024 16:02:12 +0100 Subject: [PATCH 1/3] Added reset --- arduino/Screen code/writetext function.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arduino/Screen code/writetext function.ino b/arduino/Screen code/writetext function.ino index 2c63410..a5cfda2 100644 --- a/arduino/Screen code/writetext function.ino +++ b/arduino/Screen code/writetext function.ino @@ -19,7 +19,7 @@ Adafruit_ST7796S_kbv tft = Adafruit_ST7796S_kbv(TFT_CS, TFT_DC, MOSI, SCK, TFT_R void setup() { tft.begin(); // Initialize the display tft.setRotation(3); // Set the rotation to horizontal - + tft.fillScreen(ST7796S_BLACK); } void loop() { From 2b31f80655599139438170f07ff200970e25dbba Mon Sep 17 00:00:00 2001 From: sam Date: Tue, 5 Mar 2024 16:02:17 +0100 Subject: [PATCH 2/3] File creation --- arduino/Screen code/Screen-code-full/headerFile.h | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 arduino/Screen code/Screen-code-full/headerFile.h diff --git a/arduino/Screen code/Screen-code-full/headerFile.h b/arduino/Screen code/Screen-code-full/headerFile.h new file mode 100644 index 0000000..f74f963 --- /dev/null +++ b/arduino/Screen code/Screen-code-full/headerFile.h @@ -0,0 +1,6 @@ +#define TFT_CS 14 +#define TFT_DC 13 +#define TFT_RST 12 +#define MOSI 11 +#define SCK 10 +#define MISO 9 \ No newline at end of file From 698b3055a46c65b4b2ce90b4f77c841a9b9523a1 Mon Sep 17 00:00:00 2001 From: sam Date: Tue, 5 Mar 2024 16:02:34 +0100 Subject: [PATCH 3/3] File creation + text centre + split array --- .../Screen-code-full/Screen-code-full.ino | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 arduino/Screen code/Screen-code-full/Screen-code-full.ino diff --git a/arduino/Screen code/Screen-code-full/Screen-code-full.ino b/arduino/Screen code/Screen-code-full/Screen-code-full.ino new file mode 100644 index 0000000..8df2c8e --- /dev/null +++ b/arduino/Screen code/Screen-code-full/Screen-code-full.ino @@ -0,0 +1,71 @@ +#include +#include "Adafruit_GFX.h" +#include "Adafruit_ST7796S_kbv.h" +#include "headerFile.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); + + + +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); + writeText(Question[i], 3, 0, 0, 0, true); + writeText(Answer[i], 3, 0, 200, 0, 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; +} \ No newline at end of file