/*
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 = "";
#define BTN_PIN 5
#define TFT_DC 2
#define TFT_CS 15
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
void testdrawtext(char *text, uint16_t color, int size)
{
tft.setCursor(0, 0);
tft.setTextColor(color);
tft.setTextWrap(true);
tft.setTextSize(size);
tft.print(text);
}
void centerText(char *text, int y)
{
int16_t x1, y1;
uint16_t w, h;
tft.getTextBounds(text, 0, 0, &x1, &y1, &w, &h); // Calculate w/h of text
uint8_t x = (tft.width() - w) / 2;
uint8_t wd = (tft.height() - h) / 2;
tft.setCursor(x, y);
tft.print(text);
}
void drawBitmap(int16_t x, int16_t y,
const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color) {
int16_t i, j, byteWidth = (w + 7) / 8;
uint8_t byte;
for(j=0; j<h; j++) {
for(i=0; i<w; i++) {
if(i & 7) byte <<= 1;
else byte = pgm_read_byte(bitmap + j * byteWidth + i / 8);
if(byte & 0x0) tft.drawPixel(x+i, y+j, color);
}
}
}
void drawRGBBitmap(int16_t x, int16_t y,const unsigned char bitmap[], int16_t w, int16_t h) {
for (int16_t j = 0; j < h; j++) {
for (int16_t i = 0; i < w; i++) {
tft.drawPixel(x + i, y + j, bitmap[j * w + i]);
}
}
}
void setup(void)
{
Serial.begin(9600);
Serial.print(F("Hello! ST77xx TFT Test"));
tft.setRotation(2);
Serial.println(F("Initialized"));
tft.fillScreen(0xf621);
tft.setTextWrap(true);
tft.setTextSize(1);
centerText("Next Token", 40);
centerText("System", 80);
tft.setTextSize(1);
centerText("Token", 140);
tft.setTextSize(3);
centerText("02", 220);
}
void loop()
{
// animateScanBox();
delay(50); // Small delay for the animation speed
// tft.invertDisplay(true);
// delay(500);
// tft.invertDisplay(false);
// delay(500);
}