Merge branch 'main' of ssh://gitlab.fdmci.hva.nl/propedeuse-hbo-ict/onderwijs/2023-2024/out-a-se-ti/blok-3/qaajeeqiinii59

This commit is contained in:
Sietse Jonker
2024-03-01 14:14:25 +01:00
6 changed files with 169 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
//styling still needs to be done.
//this code is to display the questions on the screen.
#include <SPI.h>
#include "Adafruit_GFX.h"
#include "Adafruit_ST7796S_kbv.h"
#define TFT_CS 14
#define TFT_DC 13
#define TFT_RST 12
#define MOSI 11
#define SCK 10
#define MISO 9
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); // Fill the screen with black color
tft.setTextColor(ST7796S_WHITE); // Set the text color to white
tft.setTextSize(2); // Set the text size to 2
Serial.begin(9600);
}
void loop() {
tft.setTextSize(2); // Set textsize
tft.setCursor(0, 0); // Set the cursor to the top left corner
//the cursor is where it types the text or shape on the screen, 0,0 is the topleft
tft.println("Hello, world!"); // Print the text
delay(2000); // Wait for 2 seconds
tft.fillScreen(ST7796S_BLACK); // Clear the screen
tft.setCursor(0, 0); // Set the cursor to the top left corner
tft.println("New text!"); // Print the new text
delay(2000); // Wait for 2 seconds
tft.fillScreen(ST7796S_BLACK); // Clear the screen
tft.setCursor(0, 0); // Set the cursor to the top left corner
tft.println(Question[1]);
delay(10000); //delay set a longer delay so the long text can write out
}

View File

@@ -8,6 +8,7 @@ nav:
- Links: opdracht/links
- 🎮 Arduino documentation:
- I2C: arduino-documentation/i2c-ESP32
- TFT screen : node-documentation/TFT-screen
- 🍓 RPi Documentation:
- Raspberry pi: Sp1SchetsProject/InfrastructuurDocumentatie/raspberryPi
- MariaDB: rpi-documentation/mariadb-installation

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

View File

@@ -0,0 +1,99 @@
# TFT screen
## Prequesites
To use the TFT screen, you need to install the following libraries:
``` SPI.h , Adafruit_GFX.h, Adafruit_ST7796S_kbv.h ```
## Programming the screen
To program the screen we need to first declare all the pins and give it to the Adafruit_ST7796S_kbv.h library. Then we need to initialize the screen and we can start using it.
```cpp
#define TFT_CS 14
#define TFT_DC 13
#define TFT_RST 12
#define MOSI 11
#define SCK 10
#define MISO 9
//simplify the name of the library and feed all the correct pins to it
Adafruit_ST7796S_kbv tft = Adafruit_ST7796S_kbv(TFT_CS, TFT_DC, MOSI, SCK, TFT_RST, MISO);
```
## Drawing on the screen
To draw on the screen we can use the following functions:
```cpp
tft.fillScreen(0x0000); //clear the screen
tft.fillRect(0, 0, 240, 240, 0xFFFF); //draw a white rectangle
tft.fillCircle(120, 120, 50, 0xF800); //draw a red circle
tft.fillTriangle(0, 0, 240, 240, 0, 240, 0x1F); //draw a blue triangle
tft.fillRoundRect(0, 0, 240, 240, 10, 0xF81F); //draw a pink rounded rectangle
tft.drawChar(120, 120, 'A', 0xFFFF, 0x0000, 2); //draw a character
tft.setTextSize(2); //set the text size
tft.setTextColor(0xFFFF); //set the text color
tft.setCursor(0, 0); //set the cursor
tft.println("Hello World!"); //print a string
```
To write Hello world on the screen we can use the following code:
```cpp
tft.fillScreen(0x0000); //clear the screen
tft.setTextSize(2); //set the text size
tft.setTextColor(0xFFFF); //set the text color
tft.setCursor(0, 0); //set the cursor so it starts at the top right, you can also make this other numbers to change the position
tft.println("Hello World!"); //print a string
```
To clear the screen for new text you can use the following code:
```cpp
tft.fillScreen(0x0000); //clear the screen
```
## Wiring
You can connect the wires to any pin except the vcc and the ground. The vcc and ground need to be connected to the 3.3v and ground of the esp32. The other pins can be connected to any pin of the esp32.
![TFT screen diagram](../assets/imagesSp2/IMG_1131.jpg)
We aren't using the cs2 and the pen pin because we arent utilizing the touch function of the screen.
```mermaid
classDiagram
writeText <|-- Adafruit_ST7796S_kbv
loop <-- writeText
class writeText{
+text
+color
+size
+posx
+posy
+writeText()
}
class Adafruit_ST7796S_kbv{
+fillScreen()
+fillRect()
+fillCircle()
+fillTriangle()
+fillRoundRect()
+drawChar()
+setTextSize()
+setTextColor()
+setCursor()
+println()
}
```
## Sources
* https://www.tinytronics.nl/en/displays/tft/4-inch-tft-display-320*480-pixels-with-touchscreen-spi-st7796s Source for Driver
* https://github.com/prenticedavid/Adafruit_ST7796S_kbv Download link for the library

View File

@@ -0,0 +1,16 @@
### Sprint 2: The product.
28 - 2 - 2024: {
At the standup we made soem finishing touches on who is gonna do what and what each role will feature.
Dano and Bram are going to start with doing research about extracting information from the PI and wil be setting up a HTML page for the information to display.
Sam and Sietse are going to be busy with connecting to the websocket and will do some minor tweaking to the current node moddel that we have.
}
29 - 2 - 2024: {
At today's standup we got together to talk about our progression in each of our tasks. Where we found that our tasks for today will be moreso the same but wit hsome minor ajusting.
Sam and Sietse will be designing the pcb aswell as making some progress on the questionaire, while Dano and Bram will be making the connection between the websocket and the devpage/ html page aswell as making some user-stories.
}
1 - 3 - 2024: {
From yesterday's standup, Sietse made a digital PCD schematic, Dano and Bram made great progress with connecting the PI to the html website and are trying to finish it today. Sam has made progress with documentation and was helping Sietse.
Today we are going to continue our tasks and try to finish these, so we can continue with our project.
}