/*******************************************************************
ESP32 Cheap Yellow Display.
https://github.com/witnessmenow/ESP32-Cheap-Yellow-Display
If you find what I do useful and would like to support me,
please consider becoming a sponsor on Github
https://github.com/sponsors/witnessmenow/
Written by Brian Lough
YouTube: https://www.youtube.com/brianlough
Twitter: https://twitter.com/witnessmenow
*******************************************************************/
// Make sure to copy the UserSetup.h file into the library as
// per the Github Instructions. The pins are defined in there.
// Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH
// Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters
// Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters
// Note the following larger fonts are primarily numeric only!
// Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm
// Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:-.
// Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-.
#include "User_Setup.h"
#include <TFT_eSPI.h>
// deg2rad * degrees = radians
#define DEG2RAD (3.14159265/180.0)
TFT_eSPI tft = TFT_eSPI();
int cx = 160;
int cy = 120;
int radius = 100;
int startAngle = 270;
int endAngle = 120;
unsigned int color = 0;
void drawChord(int x, int y, int radius, int startAngle, int endAngle, unsigned int color) {
float sx = cos((startAngle - 90) * DEG2RAD);
float sy = sin((startAngle - 90) * DEG2RAD);
int x1 = sx * radius + cx;
int y1 = sy * radius + cy;
float ex = cos((endAngle - 90) * DEG2RAD);
float ey = sin((endAngle - 90) * DEG2RAD);
int x2 = ex * radius + cx;
int y2 = ey * radius + cy;
tft.drawLine(x1, y1, x2, y2, color);
}
void setup() {
tft.init();
tft.setRotation(1);
tft.fillScreen(TFT_BLACK);
//drawChord();
}
void loop() {
tft.drawCircle(cx, cy, radius, TFT_WHITE);
tft.setCursor(cx-2, 10);
tft.print("N");
drawChord(cx, cy, radius, startAngle, endAngle, TFT_YELLOW);
delay(4000);
}