#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <SPI.h>
#define TFT_DC 32
#define TFT_CS 5
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
#define botaoBaixo 2 //azul
#define botaoSelecionar 4 //verde
#define botaoCima 15 //amarelo
int tela;
void telaInicial(int *tela){
int retorno = 1;
int posicaoDoCursor = 2;
while(retorno = 1)
{
if(posicaoDoCursor == 2)
{
tft.setCursor(0,0); // faz com que a tela print o display no mesmo lugar (SEMPRE SETAR!!!)
tft.setTextSize(3);
tft.println("Tela Inicial: "); //println = printar em uma linha (ja tem quebra de linha)
tft.setTextSize(2);
tft.println("");
tft.write(16); //mostrar caractere especial (CONFERIR TABELA) 16 = setinha/cursor;
tft.println("Temperatura");
tft.println(" Modo");
}
if(posicaoDoCursor == 3)
{
tft.setCursor(0,0);
tft.setTextSize(3);
tft.println("Tela Inicial: ");
tft.setTextSize(2);
tft.println("");
tft.println(" Temperatura");
tft.write(16);
tft.println("Modo");
}
if(digitalRead(botaoBaixo) == 0 && posicaoDoCursor != 3)
{
posicaoDoCursor++;
//tft.fillRect(0,25,12,80, ILI9341_RED); //modelo tft.fillRect(x,y,w,h, cor);
delay(150);
}
if(digitalRead(botaoCima) == 0 && posicaoDoCursor != 3){
posicaoDoCursor++;
delay(150);
}
}
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
tft.begin();
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(2);
tft.setRotation(1);
tft.fillScreen(ILI9341_BLACK);
tela = 1;
pinMode(botaoBaixo, INPUT_PULLUP);
pinMode(botaoSelecionar, INPUT_PULLUP);
pinMode(botaoCima, INPUT_PULLUP);
}
void loop() {
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
switch(tela){
case 1: {
telaInicial(&tela);
break;
}
}
}