/*
ESP32 HTTPClient Jokes API Example
https://wokwi.com/projects/342032431249883731
Copyright (C) 2022, Uri Shaked
*/
#include <WiFi.h>
#include <HTTPClient.h>
#include <ArduinoJson.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
const char* ssid = "Wokwi-GUEST";
const char* password = "";
int ascendente = 5; // Exemplo de valor, você pode alterar conforme necessário
#define BTN_PIN 5
#define TFT_DC 2
#define TFT_CS 15
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
void nextJoke() {
tft.setTextColor(ILI9341_WHITE);
tft.println("\nLoading joke...");
tft.setTextColor(ILI9341_GREEN);
}
void setup() {
pinMode(BTN_PIN, INPUT_PULLUP);
tft.begin();
//tft.setRotation(3);
tft.fillScreen(ILI9341_BLACK);
// Desenhe a barra
desenharBarra(ascendente);
}
void loop() {
// Aqui você pode alterar o valor de 'ascendente' conforme necessário e chamar 'desenharBarra' novamente
// Para este exemplo, vamos aumentar o valor de 'ascendente' a cada segundo
delay(1000);
ascendente = (ascendente % 10) + 1;
desenharBarra(ascendente);
}
void desenharBarra(int valor) {
// Limpe a área da barra
tft.fillRect(50, 20, 20, 200, ILI9341_BLACK);
// Desenhe a barra progressiva
int alturaBloco = 200 / 10;
for (int i = 0; i < valor; i++) {
tft.fillRect(50, 220 - (i + 1) * alturaBloco, 20, alturaBloco, ILI9341_GREEN);
}
}Loading
epaper-2in9
epaper-2in9