Update for spelling etc. in comments!
This commit is contained in:
1 parent
aefcf5af63
commit
d506a3c49d
197 files changed
+1006
-757
No files matched your search
@@ -74,7 +74,7 @@ void setup() {
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
|
||||
// Create the clock face sprite
|
||||
//face.setColorDepth(8); // 8 bit will work, but reduces effectiveness of anti-aliasing
|
||||
//face.setcolorDepth(8); // 8-bit will work, but reduces effectiveness of anti-aliasing
|
||||
face.createSprite(FACE_W, FACE_H);
|
||||
|
||||
// Only 1 font used in the sprite, so can remain loaded
|
||||
@@ -138,7 +138,7 @@ static void renderFace(float t) {
|
||||
|
||||
// Draw digits around clock perimeter
|
||||
for (uint32_t h = 1; h <= 12; h++) {
|
||||
getCoord(CLOCK_R, CLOCK_R, &xp, &yp, dialOffset, h * 360.0 / 12);
|
||||
getcoord(CLOCK_R, CLOCK_R, &xp, &yp, dialOffset, h * 360.0 / 12);
|
||||
face.drawNumber(h, xp, 2 + yp);
|
||||
}
|
||||
|
||||
@@ -147,12 +147,12 @@ static void renderFace(float t) {
|
||||
face.drawString("TFT_eSPI", CLOCK_R, CLOCK_R * 0.75);
|
||||
|
||||
// Draw minute hand
|
||||
getCoord(CLOCK_R, CLOCK_R, &xp, &yp, M_HAND_LENGTH, m_angle);
|
||||
getcoord(CLOCK_R, CLOCK_R, &xp, &yp, M_HAND_LENGTH, m_angle);
|
||||
face.drawWideLine(CLOCK_R, CLOCK_R, xp, yp, 6.0f, CLOCK_FG);
|
||||
face.drawWideLine(CLOCK_R, CLOCK_R, xp, yp, 2.0f, CLOCK_BG);
|
||||
|
||||
// Draw hour hand
|
||||
getCoord(CLOCK_R, CLOCK_R, &xp, &yp, H_HAND_LENGTH, h_angle);
|
||||
getcoord(CLOCK_R, CLOCK_R, &xp, &yp, H_HAND_LENGTH, h_angle);
|
||||
face.drawWideLine(CLOCK_R, CLOCK_R, xp, yp, 6.0f, CLOCK_FG);
|
||||
face.drawWideLine(CLOCK_R, CLOCK_R, xp, yp, 2.0f, CLOCK_BG);
|
||||
|
||||
@@ -160,7 +160,7 @@ static void renderFace(float t) {
|
||||
face.fillSmoothCircle(CLOCK_R, CLOCK_R, 4, CLOCK_FG);
|
||||
|
||||
// Draw cecond hand
|
||||
getCoord(CLOCK_R, CLOCK_R, &xp, &yp, S_HAND_LENGTH, s_angle);
|
||||
getcoord(CLOCK_R, CLOCK_R, &xp, &yp, S_HAND_LENGTH, s_angle);
|
||||
face.drawWedgeLine(CLOCK_R, CLOCK_R, xp, yp, 2.5, 1.0, SECCOND_FG);
|
||||
face.pushSprite(5, 5, TFT_TRANSPARENT);
|
||||
}
|
||||
@@ -170,7 +170,7 @@ static void renderFace(float t) {
|
||||
// =========================================================================
|
||||
// Coordinates are returned to caller via the xp and yp pointers
|
||||
#define DEG2RAD 0.0174532925
|
||||
void getCoord(int16_t x, int16_t y, float *xp, float *yp, int16_t r, float a)
|
||||
void getcoord(int16_t x, int16_t y, float *xp, float *yp, int16_t r, float a)
|
||||
{
|
||||
float sx1 = cos( (a - 90) * DEG2RAD);
|
||||
float sy1 = sin( (a - 90) * DEG2RAD);
|
||||
|
||||
@@ -31,16 +31,16 @@ WiFiUDP udp;
|
||||
// Settings
|
||||
//====================================================================================
|
||||
|
||||
#define TIMEZONE UK // See below for other "Zone references", UK, usMT etc
|
||||
#define TIMEZONE UK // See below for other "Zone references", UK, usMT etc.
|
||||
|
||||
#ifdef ESP32 // Temporary fix, ESP8266 fails to communicate with some servers...
|
||||
// Try to use pool url instead so the server IP address is looked up from those available
|
||||
// Try to use pool URL instead so the server IP address is looked up from those available
|
||||
// (use a pool server in your own country to improve response time and reliability)
|
||||
//const char* ntpServerName = "time.nist.gov";
|
||||
//const char* ntpServerName = "pool.ntp.org";
|
||||
const char* ntpServerName = "time.google.com";
|
||||
#else
|
||||
// Try to use pool url instead so the server IP address is looked up from those available
|
||||
// Try to use pool URL instead so the server IP address is looked up from those available
|
||||
// (use a pool server in your own country to improve response time and reliability)
|
||||
// const char* ntpServerName = "time.nist.gov";
|
||||
const char* ntpServerName = "pool.ntp.org";
|
||||
|
||||
@@ -43,7 +43,7 @@ OpenFontRender ofr;
|
||||
uint32_t runTime = 0; // time for next update
|
||||
|
||||
int reading = 0; // Value to be displayed
|
||||
int d = 0; // Variable used for the sinewave test waveform
|
||||
int d = 0; // Variable used for the sine wave test waveform
|
||||
bool range_error = 0;
|
||||
int8_t ramp = 1;
|
||||
|
||||
@@ -109,12 +109,12 @@ void loop() {
|
||||
}
|
||||
|
||||
#ifdef DRAW_DIGITS
|
||||
ofr.unloadFont(); // Recover space used by font metrics etc
|
||||
ofr.unloadFont(); // Recover space used by font metrics etc.
|
||||
#endif
|
||||
}
|
||||
|
||||
// #########################################################################
|
||||
// Draw the meter on the screen, returns x coord of righthand side
|
||||
// Draw the meter on the screen, returns x coord of right-hand side
|
||||
// #########################################################################
|
||||
// x,y is centre of meter, r the radius, val a number in range 0-100
|
||||
// units is the meter scale label
|
||||
@@ -154,10 +154,10 @@ void ringMeter(int x, int y, int r, int val, const char *units)
|
||||
|
||||
|
||||
// The OpenFontRender library only has simple print functions...
|
||||
// Digit jiggle for chaging values often happens with proportional fonts because
|
||||
// Digit jiggle for changing values often happens with proportional fonts because
|
||||
// digit glyph width varies ( 1 narrower that 4 for example). This code prints up to
|
||||
// 3 digits with even spacing.
|
||||
// A few experiemntal fudge factors are used here to position the
|
||||
// A few experimental fudge factors are used here to position the
|
||||
// digits in the sprite...
|
||||
// Create a sprite to draw the digits into
|
||||
uint8_t w = ofr.getTextWidth("444");
|
||||
@@ -167,12 +167,12 @@ void ringMeter(int x, int y, int r, int val, const char *units)
|
||||
char str_buf[8]; // Buffed for string
|
||||
itoa (val, str_buf, 10); // Convert value to string (null terminated)
|
||||
uint8_t ptr = 0; // Pointer to a digit character
|
||||
uint8_t dx = 4; // x offfset for cursor position
|
||||
uint8_t dx = 4; // x offset for cursor position
|
||||
if (val < 100) dx = ofr.getTextWidth("4") / 2; // Adjust cursor x for 2 digits
|
||||
if (val < 10) dx = ofr.getTextWidth("4"); // Adjust cursor x for 1 digit
|
||||
while ((uint8_t)str_buf[ptr] != 0) ptr++; // Count the characters
|
||||
while (ptr) {
|
||||
ofr.setCursor(w - dx - w / 20, -h / 2.5); // Offset cursor position in sprtie
|
||||
ofr.setcursor(w - dx - w / 20, -h / 2.5); // Offset cursor position in sprite
|
||||
ofr.rprintf(str_buf + ptr - 1); // Draw a character
|
||||
str_buf[ptr - 1] = 0; // Replace character with a null
|
||||
dx += 1 + w / 3; // Adjust cursor for next character
|
||||
@@ -185,12 +185,12 @@ void ringMeter(int x, int y, int r, int val, const char *units)
|
||||
ofr.setDrawer(tft);
|
||||
ofr.setFontColor(TFT_GOLD, DARKER_GREY);
|
||||
ofr.setFontSize(r / 2.0);
|
||||
ofr.setCursor(x, y + (r * 0.4));
|
||||
ofr.setcursor(x, y + (r * 0.4));
|
||||
ofr.cprintf("Watts");
|
||||
}
|
||||
#endif
|
||||
|
||||
//ofr.unloadFont(); // Recover space used by font metrics etc
|
||||
//ofr.unloadFont(); // Recover space used by font metrics etc.
|
||||
|
||||
// Allocate a value to the arc thickness dependant of radius
|
||||
uint8_t thickness = r / 5;
|
||||
|
||||
@@ -44,7 +44,7 @@ void loop()
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Return a 16 bit rainbow colour
|
||||
// Return a 16-bit rainbow colour
|
||||
// -------------------------------------------------------------------------
|
||||
unsigned int rainbow(byte value)
|
||||
{
|
||||
@@ -54,7 +54,7 @@ unsigned int rainbow(byte value)
|
||||
|
||||
value = value%192;
|
||||
|
||||
byte red = 0; // Red is the top 5 bits of a 16 bit colour value
|
||||
byte red = 0; // Red is the top 5 bits of a 16-bit colour value
|
||||
byte green = 0; // Green is the middle 6 bits, but only top 5 bits used here
|
||||
byte blue = 0; // Blue is the bottom 5 bits
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Sketch to demonstrate smooth (anti-aliased) graphics funtions:
|
||||
// Sketch to demonstrate smooth (anti-aliased) graphics functions:
|
||||
// Smooth graphics result in less pixel resolution jaggedness.
|
||||
|
||||
#include <TFT_eSPI.h> // Master copy here: https://github.com/Bodmer/TFT_eSPI
|
||||
@@ -35,7 +35,7 @@ void loop() {
|
||||
// drawSpot is for small anti-aliased circles, coordinates and radius are
|
||||
// floating point to allow sub-pixel positioning (large circles will
|
||||
// be slow to draw). Use fillSmoothCircle() for large circles.
|
||||
// In this case black is the backgorund colour for the anti-aliasing
|
||||
// In this case black is the background colour for the anti-aliasing
|
||||
float x = 10.5;
|
||||
float y = 10.5;
|
||||
float r = 8.6;
|
||||
@@ -43,7 +43,7 @@ void loop() {
|
||||
|
||||
// Fill sprite with a colour
|
||||
spr.fillSprite(TFT_RED);
|
||||
// Draw spot in sprite, the backgorund colour is ommitted so function
|
||||
// Draw spot in sprite, the background colour is omitted so function
|
||||
// reads background colour for aliasing. (To use this method with direct write
|
||||
// to TFT (tft.drawSpot...) requires the capability to read data from the TFT!)
|
||||
spr.drawSpot(x, y, r, TFT_WHITE);
|
||||
@@ -63,7 +63,7 @@ void loop() {
|
||||
int w1 = r1 / 25;
|
||||
int w2 = r2 / 20;
|
||||
|
||||
// The following will be updated by the getCoord function
|
||||
// The following will be updated by the getcoord function
|
||||
float px1 = 0.0;
|
||||
float py1 = 0.0;
|
||||
float px2 = 0.0;
|
||||
@@ -72,7 +72,7 @@ void loop() {
|
||||
// Wedge line function, an anti-aliased wide line between 2 points, with different
|
||||
// line widths at the two ends. Background colour is black.
|
||||
for (int angle = -130; angle <= 130; angle += 10) {
|
||||
getCoord(cx, cy, &px1, &py1, &px2, &py2, r1, r2, angle);
|
||||
getcoord(cx, cy, &px1, &py1, &px2, &py2, r1, r2, angle);
|
||||
uint16_t colour = rainbow(map(angle, -130, 130, 0, 127));
|
||||
if (angle > 45) colour = TFT_DARKGREY;
|
||||
tft.drawWedgeLine(px1, py1, px2, py2, w1, w2, colour, TFT_BLACK);
|
||||
@@ -82,7 +82,7 @@ void loop() {
|
||||
tft.fillSmoothCircle(cx, cy, r1 - 8, TFT_MAROON, TFT_BLACK);
|
||||
|
||||
// Draw a white dial pointer using wedge line function
|
||||
getCoord(cx, cy, &px1, &py1, &px2, &py2, 0, r1 - 10, 45);
|
||||
getcoord(cx, cy, &px1, &py1, &px2, &py2, 0, r1 - 10, 45);
|
||||
// Magenta wedge line pointer on red background
|
||||
// Line tapers from radius 5 to zero
|
||||
tft.drawWedgeLine(cx, cy, px2, py2, 5, 0, TFT_WHITE, TFT_MAROON);
|
||||
@@ -133,7 +133,7 @@ void loop() {
|
||||
// =========================================================================
|
||||
// Coordinates are returned to caller via the xp and yp pointers
|
||||
#define DEG2RAD 0.0174532925
|
||||
void getCoord(int16_t x, int16_t y, float *xp1, float *yp1, float *xp2, float *yp2, int16_t r1, int16_t r2, float a)
|
||||
void getcoord(int16_t x, int16_t y, float *xp1, float *yp1, float *xp2, float *yp2, int16_t r1, int16_t r2, float a)
|
||||
{
|
||||
float sx = cos( (a - 90) * DEG2RAD);
|
||||
float sy = sin( (a - 90) * DEG2RAD);
|
||||
@@ -144,14 +144,14 @@ void getCoord(int16_t x, int16_t y, float *xp1, float *yp1, float *xp2, float *y
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// Return a 16 bit rainbow colour
|
||||
// Return a 16-bit rainbow colour
|
||||
// =========================================================================
|
||||
unsigned int rainbow(byte value)
|
||||
{
|
||||
// Value is expected to be in range 0-127
|
||||
// The value is converted to a spectrum colour from 0 = blue through to 127 = red
|
||||
|
||||
byte red = 0; // Red is the top 5 bits of a 16 bit colour value
|
||||
byte red = 0; // Red is the top 5 bits of a 16-bit colour value
|
||||
byte green = 0;// Green is the middle 6 bits
|
||||
byte blue = 0; // Blue is the bottom 5 bits
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ void setup(void) {
|
||||
|
||||
void loop() {
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
tft.setCursor(0, 0);
|
||||
tft.setcursor(0, 0);
|
||||
|
||||
// Draw some random smooth rounded rectangles
|
||||
for (int i = 0; i < 20; i++)
|
||||
@@ -30,7 +30,7 @@ void loop() {
|
||||
delay(2000);
|
||||
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
tft.setCursor(0, 0);
|
||||
tft.setcursor(0, 0);
|
||||
|
||||
// Draw some random minimum thickness smooth rounded rectangles
|
||||
for (int i = 0; i < 20; i++)
|
||||
|
||||
Reference in new issue
Block a user