Disseste para usar a função millis() em vez do delay, mas eu acho que não vai resultar, porque como estou a trabalhar com um display touchscreen, na programação eu tenho que esperar pelo touch.
TSPoint waitTouch()
{
TSPoint p;
do {
p = ts.getPoint();
pinMode(XM, OUTPUT);
pinMode(YP, OUTPUT);
} while ((p.z < MINPRESSURE ) || (p.z > MAXPRESSURE));
p.x = map(p.x, TS_MINX, TS_MAXX, 0, 240);
p.y = map(p.y, TS_MINY, TS_MAXY, 0, 320);
return p;
}
E depois não consigo que a parte onde está o millis deixe que mostre as linhas de código por 4 segundos.
void loop()
{
if (estado_menu == 0)
{
tft.fillScreen(PRETO);
pag_inicial();
tft.setFont();
TSPoint p = waitTouch();
if ((p.x > 20) && (p.x <= 300) && (p.y > 80) && (p.y <= 160))
{
estado_menu = 1;
Stepper_porta.step(300);
}
}
if (estado_menu == 1)
{
while((millis() - valor_millis) >= 4000)
{
tft.fillScreen(PRETO);
tft.setFont(&FreeSansBold9pt7b);
tft.setCursor(50, 120);
tft.setTextColor(VERMELHO);
tft.setTextSize(2);
tft.print("Para que piso\n\n");
tft.setCursor(40, 160);
tft.setTextColor(VERMELHO);
tft.setTextSize(2);
tft.print("Que deseja ir?");
valor_millis = millis();
}
tft.fillScreen(PRETO);
botoes_pisos();
TSPoint p = waitTouch();
if ((p.x > 20) && (p.x <= 290) && (p.y > 40) && (p.y <= 110))//se clicar no botao1
{
if (piso_elevador == ler_microswitch0)
{
while((millis() - valor_millis) <= 4000)
{
tft.fillScreen(PRETO);
tft.setFont(&FreeSansBold9pt7b);
tft.setCursor(55, 120);
tft.setTextColor(VERMELHO);
tft.setTextSize(2);
tft.print("Encontra-se\n\n");
tft.setCursor(67, 160);
tft.setTextColor(VERMELHO);
tft.setTextSize(2);
tft.print("Nesse piso!");
tft.setFont();
valor_millis = millis();
}
}