Update TFT_eSPI to v2.5.43
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -190,7 +190,7 @@ void ringMeter(int x, int y, int r, int val, const char *units)
|
||||
}
|
||||
#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);
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user