/* ESP32 Screen Circular Progress
Displays a circle in "orbit" around the center of the screen
*/
#include <TFT_eSPI.h>
#include <SPI.h> // this is needed for display
// The display also uses hardware SPI, plus #9 & #10
#define TFT_CS 15
#define TFT_DC 2
#define TFT_MOSI 23
#define TFT_SCLK 18
TFT_eSPI tft = TFT_eSPI(); // Invoke custom library with default width and height
// TFT_eSprite img = TFT_eSprite(&tft);
void setup(void) {
Serial.begin(115200);
tft.begin();
tft.setRotation(0);
Serial.println("TFT set up");
// img.createSprite(240, 200);
}
void loop() {
renderCircleLoadingFrame();
}
float angle = 0;
int centerX = 120;
int centerY = 60;
int radius = 40;
int x = 0;
int y = 0;
void renderCircleLoadingFrame() {
delay(10);
tft.fillCircle(x, y, 8 , TFT_BLACK);
angle -= 0.1;
if (angle <= 0) angle = 2 * PI;
x = sin(angle) * radius + centerX;
y = cos(angle) * radius + centerY;
tft.fillCircle(x, y, 8 ,TFT_BLUE);
tft.fillRect(0, 0, 24, 24, TFT_BLACK);
tft.drawString(String(angle), 0, 0, 2);
// img.pushSprite(0,0);
}