Add new background fill approach to smooth fonts
A new background rendering approach is used for smooth fonts which almost eliminates flicker. tft.print... can now be used with a background rendered for smooth fonts. Font_Demo_1/2/3... examples have been updated. A new "docs" folder has been created and files moved there. The Tools folder now only contains support tools. #1757 fixed by using Arduino calls. A new USER_SETUP_ID parameter can be added to setup files and checked via a new verifySetupID(id); function. Version raised to v2.4.50
@ -58,7 +58,7 @@ void TFT_eSPI::loadFont(String fontName, bool flash)
|
||||
|
||||
The bitmaps start next at 24 + (28 * gCount) bytes from the start of the file.
|
||||
Each pixel is 1 byte, an 8 bit Alpha value which represents the transparency from
|
||||
0xFF foreground colour, 0x00 background. The sketch uses a linear interpolation
|
||||
0xFF foreground colour, 0x00 background. The library uses a linear interpolation
|
||||
between the foreground and background RGB component colours. e.g.
|
||||
pixelRed = ((fgRed * alpha) + (bgRed * (255 - alpha))/255
|
||||
To gain a performance advantage fixed point arithmetic is used with rounding and
|
||||
@ -86,7 +86,7 @@ void TFT_eSPI::loadFont(String fontName, bool flash)
|
||||
// | gHeight ....@@@@@..@@ + + <-- baseline
|
||||
// | | ...........@@ |
|
||||
// | | ...........@@ | gdY is the offset to the top edge of the bitmap
|
||||
// | | .@@.......@@. descent plot top edge of bitmap at (cursorY + yAdvance - gdY)
|
||||
// | | .@@.......@@. descent plot top edge of bitmap at (cursorY + ascent - gdY)
|
||||
// | + x..@@@@@@@..x | x marks the corner pixels of the bitmap
|
||||
// | |
|
||||
// +---------------------------+ yAdvance is y delta for the next line, font size or (ascent + descent)
|
||||
@ -206,7 +206,7 @@ void TFT_eSPI::loadMetrics(void)
|
||||
|
||||
// Different glyph sets have different ascent values not always based on "d", so we could get
|
||||
// the maximum glyph ascent by checking all characters. BUT this method can generate bad values
|
||||
// for non-existant glyphs, so we will reply on processing for the value and disable this code for now...
|
||||
// for non-existent glyphs, so we will reply on processing for the value and disable this code for now...
|
||||
/*
|
||||
if (gdY[gNum] > gFont.maxAscent)
|
||||
{
|
||||
@ -316,7 +316,7 @@ uint32_t TFT_eSPI::readInt32(void)
|
||||
|
||||
#ifdef FONT_FS_AVAILABLE
|
||||
if (fs_font) {
|
||||
val |= fontFile.read() << 24;
|
||||
val = fontFile.read() << 24;
|
||||
val |= fontFile.read() << 16;
|
||||
val |= fontFile.read() << 8;
|
||||
val |= fontFile.read();
|
||||
@ -324,7 +324,7 @@ uint32_t TFT_eSPI::readInt32(void)
|
||||
else
|
||||
#endif
|
||||
{
|
||||
val |= pgm_read_byte(fontPtr++) << 24;
|
||||
val = pgm_read_byte(fontPtr++) << 24;
|
||||
val |= pgm_read_byte(fontPtr++) << 16;
|
||||
val |= pgm_read_byte(fontPtr++) << 8;
|
||||
val |= pgm_read_byte(fontPtr++);
|
||||
@ -362,16 +362,27 @@ void TFT_eSPI::drawGlyph(uint16_t code)
|
||||
uint16_t fg = textcolor;
|
||||
uint16_t bg = textbgcolor;
|
||||
|
||||
// Check if cursor has moved
|
||||
if (last_cursor_x != cursor_x)
|
||||
{
|
||||
bg_cursor_x = cursor_x;
|
||||
last_cursor_x = cursor_x;
|
||||
}
|
||||
|
||||
if (code < 0x21)
|
||||
{
|
||||
if (code == 0x20) {
|
||||
//if (fg!=bg) fillRect(cursor_x, cursor_y, gFont.spaceWidth, gFont.yAdvance, bg);
|
||||
if (_fillbg) fillRect(bg_cursor_x, cursor_y, (cursor_x + gFont.spaceWidth) - bg_cursor_x, gFont.yAdvance, bg);
|
||||
cursor_x += gFont.spaceWidth;
|
||||
bg_cursor_x = cursor_x;
|
||||
last_cursor_x = cursor_x;
|
||||
return;
|
||||
}
|
||||
|
||||
if (code == '\n') {
|
||||
cursor_x = 0;
|
||||
bg_cursor_x = 0;
|
||||
last_cursor_x = 0;
|
||||
cursor_y += gFont.yAdvance;
|
||||
if (textwrapY && (cursor_y >= height())) cursor_y = 0;
|
||||
return;
|
||||
@ -388,6 +399,7 @@ void TFT_eSPI::drawGlyph(uint16_t code)
|
||||
{
|
||||
cursor_y += gFont.yAdvance;
|
||||
cursor_x = 0;
|
||||
bg_cursor_x = 0;
|
||||
}
|
||||
if (textwrapY && ((cursor_y + gFont.yAdvance) >= height())) cursor_y = 0;
|
||||
if (cursor_x == 0) cursor_x -= gdX[gNum];
|
||||
@ -398,7 +410,7 @@ void TFT_eSPI::drawGlyph(uint16_t code)
|
||||
#ifdef FONT_FS_AVAILABLE
|
||||
if (fs_font)
|
||||
{
|
||||
fontFile.seek(gBitmap[gNum], fs::SeekSet); // This is taking >30ms for a significant position shift
|
||||
fontFile.seek(gBitmap[gNum], fs::SeekSet);
|
||||
pbuffer = (uint8_t*)malloc(gWidth[gNum]);
|
||||
}
|
||||
#endif
|
||||
@ -406,15 +418,46 @@ void TFT_eSPI::drawGlyph(uint16_t code)
|
||||
int16_t cy = cursor_y + gFont.maxAscent - gdY[gNum];
|
||||
int16_t cx = cursor_x + gdX[gNum];
|
||||
|
||||
int16_t xs = cx;
|
||||
uint32_t dl = 0;
|
||||
// if (cx > width() && bg_cursor_x > width()) return;
|
||||
// if (cursor_y > height()) return;
|
||||
|
||||
int16_t fxs = cx;
|
||||
uint32_t fl = 0;
|
||||
int16_t bxs = cx;
|
||||
uint32_t bl = 0;
|
||||
int16_t bx = 0;
|
||||
uint8_t pixel;
|
||||
|
||||
startWrite(); // Avoid slow ESP32 transaction overhead for every pixel
|
||||
|
||||
//if (fg!=bg) fillRect(cursor_x, cursor_y, gxAdvance[gNum], gFont.yAdvance, bg);
|
||||
int16_t fillwidth = 0;
|
||||
uint16_t fillheight = 0;
|
||||
|
||||
for (int y = 0; y < gHeight[gNum]; y++)
|
||||
// Fill area above glyph
|
||||
if (_fillbg) {
|
||||
fillwidth = (cursor_x + gxAdvance[gNum]) - bg_cursor_x;
|
||||
if (fillwidth > 0) {
|
||||
fillheight = gFont.maxAscent - gdY[gNum];
|
||||
if (fillheight > 0) {
|
||||
fillRect(bg_cursor_x, cursor_y, fillwidth, fillheight, textbgcolor);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Could be negative
|
||||
fillwidth = 0;
|
||||
}
|
||||
|
||||
// Fill any area to left of glyph
|
||||
if (bg_cursor_x < cx) fillRect(bg_cursor_x, cy, cx - bg_cursor_x, gHeight[gNum], textbgcolor);
|
||||
// Set x position in glyph area where background starts
|
||||
if (bg_cursor_x > cx) bx = bg_cursor_x - cx;
|
||||
// Fill any area to right of glyph
|
||||
if (cx + gWidth[gNum] < cursor_x + gxAdvance[gNum]) {
|
||||
fillRect(cx + gWidth[gNum], cy, (cursor_x + gxAdvance[gNum]) - (cx + gWidth[gNum]), gHeight[gNum], textbgcolor);
|
||||
}
|
||||
}
|
||||
|
||||
for (int32_t y = 0; y < gHeight[gNum]; y++)
|
||||
{
|
||||
#ifdef FONT_FS_AVAILABLE
|
||||
if (fs_font) {
|
||||
@ -432,7 +475,8 @@ void TFT_eSPI::drawGlyph(uint16_t code)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
for (int x = 0; x < gWidth[gNum]; x++)
|
||||
|
||||
for (int32_t x = 0; x < gWidth[gNum]; x++)
|
||||
{
|
||||
#ifdef FONT_FS_AVAILABLE
|
||||
if (fs_font) pixel = pbuffer[x];
|
||||
@ -442,28 +486,44 @@ void TFT_eSPI::drawGlyph(uint16_t code)
|
||||
|
||||
if (pixel)
|
||||
{
|
||||
if (bl) { drawFastHLine( bxs, y + cy, bl, bg); bl = 0; }
|
||||
if (pixel != 0xFF)
|
||||
{
|
||||
if (dl) {
|
||||
if (dl==1) drawPixel(xs, y + cy, fg);
|
||||
else drawFastHLine( xs, y + cy, dl, fg);
|
||||
dl = 0;
|
||||
if (fl) {
|
||||
if (fl==1) drawPixel(fxs, y + cy, fg);
|
||||
else drawFastHLine( fxs, y + cy, fl, fg);
|
||||
fl = 0;
|
||||
}
|
||||
if (getColor) bg = getColor(x + cx, y + cy);
|
||||
drawPixel(x + cx, y + cy, alphaBlend(pixel, fg, bg));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dl==0) xs = x + cx;
|
||||
dl++;
|
||||
if (fl==0) fxs = x + cx;
|
||||
fl++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dl) { drawFastHLine( xs, y + cy, dl, fg); dl = 0; }
|
||||
if (fl) { drawFastHLine( fxs, y + cy, fl, fg); fl = 0; }
|
||||
if (_fillbg) {
|
||||
if (x >= bx) {
|
||||
if (bl==0) bxs = x + cx;
|
||||
bl++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dl) { drawFastHLine( xs, y + cy, dl, fg); dl = 0; }
|
||||
if (fl) { drawFastHLine( fxs, y + cy, fl, fg); fl = 0; }
|
||||
if (bl) { drawFastHLine( bxs, y + cy, bl, bg); bl = 0; }
|
||||
}
|
||||
|
||||
// Fill area below glyph
|
||||
if (fillwidth > 0) {
|
||||
fillheight = (cursor_y + gFont.yAdvance) - (cy + gHeight[gNum]);
|
||||
if (fillheight > 0) {
|
||||
fillRect(bg_cursor_x, cy + gHeight[gNum], fillwidth, fillheight, textbgcolor);
|
||||
}
|
||||
}
|
||||
|
||||
if (pbuffer) free(pbuffer);
|
||||
@ -472,10 +532,12 @@ void TFT_eSPI::drawGlyph(uint16_t code)
|
||||
}
|
||||
else
|
||||
{
|
||||
// Not a Unicode in font so draw a rectangle and move on cursor
|
||||
// Point code not in font so draw a rectangle and move on cursor
|
||||
drawRect(cursor_x, cursor_y + gFont.maxAscent - gFont.ascent, gFont.spaceWidth, gFont.ascent, fg);
|
||||
cursor_x += gFont.spaceWidth + 1;
|
||||
}
|
||||
bg_cursor_x = cursor_x;
|
||||
last_cursor_x = cursor_x;
|
||||
}
|
||||
|
||||
/***************************************************************************************
|
||||
@ -511,12 +573,9 @@ void TFT_eSPI::showFont(uint32_t td)
|
||||
setCursor(cursorX, cursorY);
|
||||
drawGlyph(gUnicode[i]);
|
||||
cursorX += gxAdvance[i];
|
||||
//cursorX += printToSprite( cursorX, cursorY, i );
|
||||
yield();
|
||||
}
|
||||
|
||||
delay(timeDelay);
|
||||
fillScreen(textbgcolor);
|
||||
//fontFile.close();
|
||||
|
||||
}
|
||||
|
@ -133,17 +133,7 @@ uint8_t TFT_eSPI::readByte(void)
|
||||
***************************************************************************************/
|
||||
void TFT_eSPI::busDir(uint32_t mask, uint8_t mode)
|
||||
{
|
||||
gpioMode(TFT_D0, mode);
|
||||
gpioMode(TFT_D1, mode);
|
||||
gpioMode(TFT_D2, mode);
|
||||
gpioMode(TFT_D3, mode);
|
||||
gpioMode(TFT_D4, mode);
|
||||
gpioMode(TFT_D5, mode);
|
||||
gpioMode(TFT_D6, mode);
|
||||
gpioMode(TFT_D7, mode);
|
||||
return;
|
||||
/*
|
||||
// Arduino generic native function, but slower
|
||||
// Arduino generic native function
|
||||
pinMode(TFT_D0, mode);
|
||||
pinMode(TFT_D1, mode);
|
||||
pinMode(TFT_D2, mode);
|
||||
@ -152,7 +142,7 @@ void TFT_eSPI::busDir(uint32_t mask, uint8_t mode)
|
||||
pinMode(TFT_D5, mode);
|
||||
pinMode(TFT_D6, mode);
|
||||
pinMode(TFT_D7, mode);
|
||||
return; //*/
|
||||
return;
|
||||
}
|
||||
|
||||
/***************************************************************************************
|
||||
@ -161,14 +151,8 @@ void TFT_eSPI::busDir(uint32_t mask, uint8_t mode)
|
||||
***************************************************************************************/
|
||||
void TFT_eSPI::gpioMode(uint8_t gpio, uint8_t mode)
|
||||
{
|
||||
if(mode == INPUT) GPIO.enable_w1tc = ((uint32_t)1 << gpio);
|
||||
else GPIO.enable_w1ts = ((uint32_t)1 << gpio);
|
||||
|
||||
ESP_REG(DR_REG_IO_MUX_BASE + esp32_gpioMux[gpio].reg) // Register lookup
|
||||
= ((uint32_t)2 << FUN_DRV_S) // Set drive strength 2
|
||||
| (FUN_IE) // Input enable
|
||||
| ((uint32_t)2 << MCU_SEL_S); // Function select 2
|
||||
GPIO.pin[gpio].val = 1; // Set pin HIGH
|
||||
pinMode(pin, mode);
|
||||
digitalWrite(pin, HIGH);
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
#endif // #ifdef TFT_PARALLEL_8_BIT
|
||||
|
@ -292,11 +292,9 @@
|
||||
|
||||
#elif defined (ILI9225_DRIVER) // Needs gaps between commands + data bytes, so use slower transfer functions
|
||||
|
||||
// These all end in 8 bit mode
|
||||
// Warning: these all end in 8 bit SPI mode!
|
||||
#define tft_Write_8(C) spi.transfer(C);
|
||||
|
||||
// Note: the following macros do not wait for the end of transmission
|
||||
|
||||
#define tft_Write_16(C) spi.transfer16(C)
|
||||
|
||||
#define tft_Write_16N(C) spi.transfer16(C)
|
||||
|
11
TFT_config.h
@ -1,5 +1,14 @@
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
/* Support file for ESP32 IDF use */
|
||||
/* See library docs folder */
|
||||
/* */
|
||||
/* DO NOT EDIT THIS FILE */
|
||||
/* */
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* @file utility.h
|
||||
* @file TFT_config.h
|
||||
* @author Ricard Bitriá Ribes (https://github.com/dracir9)
|
||||
* Created Date: 22-01-2022
|
||||
* -----
|
||||
|
78
TFT_eSPI.cpp
@ -262,7 +262,7 @@ bool TFT_eSPI::checkViewport(int32_t x, int32_t y, int32_t w, int32_t h)
|
||||
|
||||
/***************************************************************************************
|
||||
** Function name: resetViewport
|
||||
** Description: Reset viewport to whle TFT screen, datum at 0,0
|
||||
** Description: Reset viewport to whole TFT screen, datum at 0,0
|
||||
***************************************************************************************/
|
||||
void TFT_eSPI::resetViewport(void)
|
||||
{
|
||||
@ -442,12 +442,15 @@ TFT_eSPI::TFT_eSPI(int16_t w, int16_t h)
|
||||
resetViewport();
|
||||
|
||||
rotation = 0;
|
||||
cursor_y = cursor_x = 0;
|
||||
cursor_y = cursor_x = last_cursor_x = bg_cursor_x = 0;
|
||||
textfont = 1;
|
||||
textsize = 1;
|
||||
textcolor = bitmap_fg = 0xFFFF; // White
|
||||
textbgcolor = bitmap_bg = 0x0000; // Black
|
||||
padX = 0; // No padding
|
||||
padX = 0; // No padding
|
||||
|
||||
_fillbg = false; // Smooth font only at the moment, force text background fill
|
||||
|
||||
isDigits = false; // No bounding box adjustment
|
||||
textwrapX = true; // Wrap text at end of line when using print stream
|
||||
textwrapY = false; // Wrap text at bottom of screen when using print stream
|
||||
@ -2723,10 +2726,14 @@ void TFT_eSPI::setTextColor(uint16_t c)
|
||||
** Function name: setTextColor
|
||||
** Description: Set the font foreground and background colour
|
||||
***************************************************************************************/
|
||||
void TFT_eSPI::setTextColor(uint16_t c, uint16_t b)
|
||||
// Smooth fonts use the background colour for anti-aliasing and by default the
|
||||
// background is not filled. If bgfill = true, then a smooth font background fill will
|
||||
// be used.
|
||||
void TFT_eSPI::setTextColor(uint16_t c, uint16_t b, bool bgfill)
|
||||
{
|
||||
textcolor = c;
|
||||
textbgcolor = b;
|
||||
_fillbg = bgfill;
|
||||
}
|
||||
|
||||
|
||||
@ -3180,6 +3187,12 @@ void TFT_eSPI::setWindow(int32_t x0, int32_t y0, int32_t x1, int32_t y1)
|
||||
// write to RAM
|
||||
DC_C; tft_Write_8(TFT_RAMWR);
|
||||
DC_D;
|
||||
// Temporary solution is to include the RP2040 code here
|
||||
#if (defined(ARDUINO_ARCH_RP2040) || defined (ARDUINO_ARCH_MBED)) && !defined(RP2040_PIO_INTERFACE)
|
||||
// For ILI9225 and RP2040 the slower Arduino SPI transfer calls were used, so need to swap back to 16 bit mode
|
||||
while (spi_get_hw(SPI_X)->sr & SPI_SSPSR_BSY_BITS) {};
|
||||
hw_write_masked(&spi_get_hw(SPI_X)->cr0, (16 - 1) << SPI_SSPCR0_DSS_LSB, SPI_SSPCR0_DSS_BITS);
|
||||
#endif
|
||||
#elif defined (SSD1351_DRIVER)
|
||||
if (rotation & 1) {
|
||||
swap_coord(x0, y0);
|
||||
@ -3730,7 +3743,7 @@ uint16_t TFT_eSPI::drawPixel(int32_t x, int32_t y, uint32_t color, uint8_t alpha
|
||||
void TFT_eSPI::fillSmoothCircle(int32_t x, int32_t y, int32_t r, uint32_t color, uint32_t bg_color)
|
||||
{
|
||||
if (r <= 0) return;
|
||||
|
||||
|
||||
inTransaction = true;
|
||||
|
||||
drawFastHLine(x - r, y, 2 * r + 1, color);
|
||||
@ -3786,9 +3799,14 @@ void TFT_eSPI::fillSmoothRoundRect(int32_t x, int32_t y, int32_t w, int32_t h, i
|
||||
int32_t xs = 0;
|
||||
int32_t cx = 0;
|
||||
|
||||
// Limit radius to half width or height
|
||||
if (r > w/2) r = w/2;
|
||||
if (r > h/2) r = h/2;
|
||||
|
||||
y += r;
|
||||
h -= 2*r;
|
||||
fillRect(x, y, w, h + 1, color);
|
||||
fillRect(x, y, w, h, color);
|
||||
h--;
|
||||
x += r;
|
||||
w -= 2*r+1;
|
||||
int32_t r1 = r * r;
|
||||
@ -4989,17 +5007,6 @@ int16_t TFT_eSPI::drawString(const char *string, int32_t poX, int32_t poY, uint8
|
||||
|
||||
#ifdef SMOOTH_FONT
|
||||
if(fontLoaded) {
|
||||
if (textcolor!=textbgcolor) fillRect(poX, poY, cwidth, cheight, textbgcolor);
|
||||
/*
|
||||
// The above only works for a single text line, not if the text is going to wrap...
|
||||
// So need to use code like this in a while loop to fix it:
|
||||
if (textwrapX && (cursor_x + width * textsize > width())) {
|
||||
cursor_y += height;
|
||||
cursor_x = 0;
|
||||
}
|
||||
if (textwrapY && (cursor_y >= (int32_t)height())) cursor_y = 0;
|
||||
cursor_x += drawChar(uniCode, cursor_x, cursor_y, textfont);
|
||||
*/
|
||||
setCursor(poX, poY);
|
||||
|
||||
while (n < len) {
|
||||
@ -5312,6 +5319,21 @@ SPIClass& TFT_eSPI::getSPIinstance(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/***************************************************************************************
|
||||
** Function name: verifySetupID
|
||||
** Description: Compare the ID if USER_SETUP_ID defined in user setup file
|
||||
***************************************************************************************/
|
||||
bool TFT_eSPI::verifySetupID(uint32_t id)
|
||||
{
|
||||
#if defined (USER_SETUP_ID)
|
||||
if (USER_SETUP_ID == id) return true;
|
||||
#else
|
||||
id = id; // Avoid warning
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
/***************************************************************************************
|
||||
** Function name: getSetup
|
||||
** Description: Get the setup details for diagnostic and sketch access
|
||||
@ -5320,6 +5342,18 @@ void TFT_eSPI::getSetup(setup_t &tft_settings)
|
||||
{
|
||||
// tft_settings.version is set in header file
|
||||
|
||||
#if defined (USER_SETUP_INFO)
|
||||
tft_settings.setup_info = USER_SETUP_INFO;
|
||||
#else
|
||||
tft_settings.setup_info = "NA";
|
||||
#endif
|
||||
|
||||
#if defined (USER_SETUP_ID)
|
||||
tft_settings.setup_id = USER_SETUP_ID;
|
||||
#else
|
||||
tft_settings.setup_id = 0;
|
||||
#endif
|
||||
|
||||
#if defined (PROCESSOR_ID)
|
||||
tft_settings.esp = PROCESSOR_ID;
|
||||
#else
|
||||
@ -5341,6 +5375,16 @@ void TFT_eSPI::getSetup(setup_t &tft_settings)
|
||||
#ifdef SPI_READ_FREQUENCY
|
||||
tft_settings.tft_rd_freq = SPI_READ_FREQUENCY/100000;
|
||||
#endif
|
||||
#ifdef TFT_SPI_PORT
|
||||
tft_settings.port = TFT_SPI_PORT;
|
||||
#else
|
||||
tft_settings.port = 255;
|
||||
#endif
|
||||
#ifdef RP2040_PIO_SPI
|
||||
tft_settings.interface = 0x10;
|
||||
#else
|
||||
tft_settings.interface = 0x0;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(TFT_SPI_OVERLAP)
|
||||
|
47
TFT_eSPI.h
@ -16,7 +16,7 @@
|
||||
#ifndef _TFT_eSPIH_
|
||||
#define _TFT_eSPIH_
|
||||
|
||||
#define TFT_ESPI_VERSION "2.4.45"
|
||||
#define TFT_ESPI_VERSION "2.4.50"
|
||||
|
||||
// Bit level feature flags
|
||||
// Bit 0 set: viewport capability
|
||||
@ -28,7 +28,7 @@
|
||||
|
||||
//Standard support
|
||||
#ifdef TFT_eSPI_COMPONENT
|
||||
#include "TFT_config.h"
|
||||
#include "TFT_config.h"
|
||||
#endif
|
||||
|
||||
#include <Arduino.h>
|
||||
@ -95,10 +95,12 @@
|
||||
#endif
|
||||
|
||||
// Some ST7789 boards do not work with Mode 0
|
||||
#if defined(ST7789_DRIVER) || defined(ST7789_2_DRIVER)
|
||||
#define TFT_SPI_MODE SPI_MODE3
|
||||
#else
|
||||
#define TFT_SPI_MODE SPI_MODE0
|
||||
#ifndef TFT_SPI_MODE
|
||||
#if defined(ST7789_DRIVER) || defined(ST7789_2_DRIVER)
|
||||
#define TFT_SPI_MODE SPI_MODE3
|
||||
#else
|
||||
#define TFT_SPI_MODE SPI_MODE0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// If the XPT2046 SPI frequency is not defined, set a default
|
||||
@ -317,23 +319,15 @@ static const uint16_t default_4bit_palette[] PROGMEM = {
|
||||
typedef struct
|
||||
{
|
||||
String version = TFT_ESPI_VERSION;
|
||||
String setup_info; // Setup reference name available to use in a user setup
|
||||
uint32_t setup_id; // ID available to use in a user setup
|
||||
int32_t esp; // Processor code
|
||||
uint8_t trans; // SPI transaction support
|
||||
uint8_t serial; // Serial (SPI) or parallel
|
||||
uint8_t port; // SPI port
|
||||
uint8_t overlap; // ESP8266 overlap mode
|
||||
/*
|
||||
#if defined (ESP32) // TODO: make generic for other processors
|
||||
#if defined (USE_HSPI_PORT)
|
||||
uint8_t port = HSPI;
|
||||
#else
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||
uint8_t port = VSPI;
|
||||
#else
|
||||
uint8_t port = FSPI;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
*/
|
||||
uint8_t interface; // Interface type
|
||||
|
||||
uint16_t tft_driver; // Hexadecimal code
|
||||
uint16_t tft_width; // Rotation 0 width and height
|
||||
uint16_t tft_height;
|
||||
@ -583,7 +577,7 @@ class TFT_eSPI : public Print { friend class TFT_eSprite; // Sprite class has ac
|
||||
getCursorY(void); // Read current cursor y position
|
||||
|
||||
void setTextColor(uint16_t color), // Set character (glyph) color only (background not over-written)
|
||||
setTextColor(uint16_t fgcolor, uint16_t bgcolor),// Set character (glyph) foreground and backgorund colour
|
||||
setTextColor(uint16_t fgcolor, uint16_t bgcolor, bool bgfill = false), // Set character (glyph) foreground and background colour, optional background fill for smooth fonts
|
||||
setTextSize(uint8_t size); // Set character size multiplier (this increases pixel size)
|
||||
|
||||
void setTextWrap(bool wrapX, bool wrapY = false); // Turn on/off wrapping of text in TFT width and/or height
|
||||
@ -733,6 +727,7 @@ class TFT_eSPI : public Print { friend class TFT_eSprite; // Sprite class has ac
|
||||
|
||||
// Used for diagnostic sketch to see library setup adopted by compiler, see Section 7 above
|
||||
void getSetup(setup_t& tft_settings); // Sketch provides the instance to populate
|
||||
bool verifySetupID(uint32_t id);
|
||||
|
||||
// Global variables
|
||||
static SPIClass& getSPIinstance(void); // Get SPI class handle
|
||||
@ -835,6 +830,8 @@ class TFT_eSPI : public Print { friend class TFT_eSprite; // Sprite class has ac
|
||||
bool _vpOoB;
|
||||
|
||||
int32_t cursor_x, cursor_y, padX; // Text cursor x,y and padding setting
|
||||
int32_t bg_cursor_x; // Background fill cursor
|
||||
int32_t last_cursor_x; // Previous text cursor position when fill used
|
||||
|
||||
uint32_t fontsloaded; // Bit field of fonts loaded
|
||||
|
||||
@ -854,6 +851,8 @@ class TFT_eSPI : public Print { friend class TFT_eSprite; // Sprite class has ac
|
||||
|
||||
uint32_t _lastColor; // Buffered value of last colour used
|
||||
|
||||
bool _fillbg; // Fill background flag (just for for smooth fonts at the moment)
|
||||
|
||||
#if defined (SSD1963_DRIVER)
|
||||
uint16_t Cswap; // Swap buffer for SSD1963
|
||||
uint8_t r6, g6, b6; // RGB buffer for SSD1963
|
||||
@ -868,7 +867,13 @@ class TFT_eSPI : public Print { friend class TFT_eSprite; // Sprite class has ac
|
||||
***************************************************************************************/
|
||||
// Load the Touch extension
|
||||
#ifdef TOUCH_CS
|
||||
#include "Extensions/Touch.h" // Loaded if TOUCH_CS is defined by user
|
||||
#if defined (TFT_PARALLEL_8_BIT) || defined (RP2040_PIO_INTERFACE)
|
||||
#error >>>>------>> Touch functions not supported in 8 bit parallel mode or with RP2040 PIO.
|
||||
#else
|
||||
#include "Extensions/Touch.h" // Loaded if TOUCH_CS is defined by user
|
||||
#endif
|
||||
#else
|
||||
#warning >>>>------>> TOUCH_CS pin not defined, TFT_eSPI touch functions will not be available!
|
||||
#endif
|
||||
|
||||
// Load the Anti-aliased font extension
|
||||
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
@ -8,6 +8,8 @@
|
||||
// run without the need to make any more changes for a particular hardware setup!
|
||||
// Note that some sketches are designed for a particular TFT pixel width/height
|
||||
|
||||
// User defined information reported by "Read_User_Setup" test & diagnostics example
|
||||
#define USER_SETUP_INFO "User_Setup"
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
|
@ -1,5 +1,6 @@
|
||||
// This setup is for the RP2040 processor only when used with 8 bit parallel displays
|
||||
// See SetupX_Template.h for all options available
|
||||
#define USER_SETUP_ID 100
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Interface
|
||||
|
@ -1,5 +1,6 @@
|
||||
// This setup is for the RP2040 processor only when used with 8 bit parallel displays
|
||||
// See SetupX_Template.h for all options available
|
||||
#define USER_SETUP_ID 101
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Interface
|
||||
|
@ -1,5 +1,6 @@
|
||||
// This setup is for the RP2040 processor only when used with 8 bit parallel displays
|
||||
// See SetupX_Template.h for all options available
|
||||
#define USER_SETUP_ID 102
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Interface
|
||||
|
@ -1,5 +1,6 @@
|
||||
// This setup is for the RP2040 processor only when used with 8 bit parallel displays
|
||||
// See SetupX_Template.h for all options available
|
||||
#define USER_SETUP_ID 103
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Interface
|
||||
|
@ -1,5 +1,6 @@
|
||||
// This setup is for the RP2040 processor only when used with 8 bit parallel displays
|
||||
// See SetupX_Template.h for all options available
|
||||
#define USER_SETUP_ID 104
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Interface
|
||||
|
@ -1,5 +1,6 @@
|
||||
// For ESP8266
|
||||
// See SetupX_Template.h for all options available
|
||||
#define USER_SETUP_ID 10
|
||||
|
||||
#define RPI_DISPLAY_TYPE
|
||||
#define ILI9486_DRIVER
|
||||
|
@ -1,5 +1,7 @@
|
||||
// For ESP32
|
||||
// See SetupX_Template.h for all options available
|
||||
#define USER_SETUP_ID 11
|
||||
|
||||
#define RPI_DISPLAY_TYPE
|
||||
#define ILI9486_DRIVER
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// See SetupX_Template.h for all options available
|
||||
#define USER_SETUP_ID 12
|
||||
|
||||
//Setup file for the M5Stack Basic Core
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// ST7789 135 x 240 display with no chip select line
|
||||
#define USER_SETUP_ID 135
|
||||
|
||||
#define ST7789_DRIVER // Configure all registers
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// ST7789 135 x 240 display with no chip select line
|
||||
#define USER_SETUP_ID 136
|
||||
|
||||
#define ST7789_DRIVER // Configure all registers
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// LilyGo T-Display RP2040 (ST7789 135 x 240 display)
|
||||
#define USER_SETUP_ID 137
|
||||
|
||||
#define ST7789_DRIVER // Configure all registers
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// See SetupX_Template.h for all options available
|
||||
#define USER_SETUP_ID 13
|
||||
|
||||
#define ESP32_PARALLEL
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// See SetupX_Template.h for all options available
|
||||
#define USER_SETUP_ID 14
|
||||
|
||||
#define TFT_PARALLEL_8_BIT
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// See SetupX_Template.h for all options available
|
||||
#define USER_SETUP_ID 15
|
||||
|
||||
#define HX8357D_DRIVER
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// See SetupX_Template.h for all options available
|
||||
#define USER_SETUP_ID 16
|
||||
|
||||
#define ESP32_PARALLEL
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// See SetupX_Template.h for all options available
|
||||
#define USER_SETUP_ID 17
|
||||
|
||||
#define EPD_DRIVER // ePaper driver
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// See SetupX_Template.h for all options available
|
||||
#define USER_SETUP_ID 18
|
||||
|
||||
#define ST7789_DRIVER
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// See SetupX_Template.h for all options available
|
||||
#define USER_SETUP_ID 19
|
||||
|
||||
#define ESP32_PARALLEL
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// See SetupX_Template.h for all options available
|
||||
#define USER_SETUP_ID 1
|
||||
|
||||
#define ILI9341_DRIVER
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// See SetupX_Template.h for all options available
|
||||
#define USER_SETUP_ID 200
|
||||
|
||||
#define GC9A01_DRIVER
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
// If this file is edited correctly then all the library example sketches should
|
||||
// run without the need to make any more changes for a particular hardware setup!
|
||||
// Note that some sketches are designed for a particular TFT pixel width/height
|
||||
#define USER_SETUP_ID 201
|
||||
|
||||
// User defined setup
|
||||
#define ST7796_DRIVER
|
||||
|
@ -1,4 +1,5 @@
|
||||
// See SetupX_Template.h for all options available
|
||||
#define USER_SETUP_ID 202
|
||||
|
||||
#define SSD1351_DRIVER
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// ST7789 240 x 280 display with no chip select line
|
||||
#define USER_SETUP_ID 203
|
||||
|
||||
#define ST7789_DRIVER // Configure all registers
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// See SetupX_Template.h for all options available
|
||||
#define USER_SETUP_ID 20
|
||||
|
||||
#define ILI9488_DRIVER
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// See SetupX_Template.h for all options available
|
||||
#define USER_SETUP_ID 21
|
||||
|
||||
#define ILI9488_DRIVER
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Setup for the TTGO T4 v1.1 ("Bitcoin Tracker") ESP32 board with 2.2" ILI9341 display
|
||||
#define USER_SETUP_ID 22
|
||||
|
||||
// See SetupX_Template.h for all options available
|
||||
|
||||
@ -15,6 +16,8 @@
|
||||
#define TFT_DC 26 // pin 32 for TTGO T4 v1.3
|
||||
#define TFT_RST 5
|
||||
|
||||
#define TOUCH_CS -1
|
||||
|
||||
#define LOAD_GLCD
|
||||
#define LOAD_FONT2
|
||||
#define LOAD_FONT4
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Setup for the TTGO T4 v1.3 ESP32 board with 2.2" ILI9341 display
|
||||
#define USER_SETUP_ID 99922
|
||||
|
||||
// See SetupX_Template.h for all options available
|
||||
|
||||
@ -12,7 +13,7 @@
|
||||
#define TFT_SCLK 18
|
||||
|
||||
#define TFT_CS 27
|
||||
#define TFT_DC 32 // pin 26 for TTGO T4 v1.1
|
||||
#define TFT_DC 32 // pin 26 for TTGO T4 v1.3
|
||||
#define TFT_RST 5
|
||||
|
||||
#define LOAD_GLCD
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Setup for the TTGO TM (Music) ESP32 board with 2.4" ST7789V display
|
||||
#define USER_SETUP_ID 23
|
||||
|
||||
// See SetupX_Template.h for all options available
|
||||
|
||||
@ -14,6 +15,8 @@
|
||||
#define TFT_DC 16
|
||||
#define TFT_RST 17
|
||||
|
||||
#define TOUCH_CS -1
|
||||
|
||||
#define TFT_WIDTH 240
|
||||
#define TFT_HEIGHT 320
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// ST7789 240 x 240 display with no chip select line
|
||||
#define USER_SETUP_ID 24
|
||||
|
||||
#define ST7789_DRIVER // Configure all registers
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Setup for the TTGO T Display
|
||||
#define USER_SETUP_ID 25
|
||||
|
||||
// See SetupX_Template.h for all options available
|
||||
|
||||
@ -18,6 +19,8 @@
|
||||
#define TFT_DC 16
|
||||
#define TFT_RST 23
|
||||
|
||||
#define TOUCH_CS -1
|
||||
|
||||
#define TFT_BL 4 // Display backlight control pin
|
||||
|
||||
#define TFT_BACKLIGHT_ON HIGH // HIGH or LOW are options
|
||||
|
@ -1,3 +1,5 @@
|
||||
#define USER_SETUP_ID 26
|
||||
|
||||
#define ST7735_DRIVER
|
||||
|
||||
#define TFT_WIDTH 80
|
||||
|
@ -7,6 +7,8 @@
|
||||
// If this file is edited correctly then all the library example sketches should
|
||||
// run without the need to make any more changes for a particular hardware setup!
|
||||
|
||||
#define USER_SETUP_ID 27
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 0. Call up the right driver file and any options for it
|
||||
|
@ -6,6 +6,7 @@
|
||||
//
|
||||
// If this file is edited correctly then all the library example sketches should
|
||||
// run without the need to make any more changes for a particular hardware setup!
|
||||
#define USER_SETUP_ID 28
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
|
@ -2,6 +2,7 @@
|
||||
///////////////////////////////////////////////////
|
||||
// Setup for STM32 Nucleo and ILI9341 display //
|
||||
///////////////////////////////////////////////////
|
||||
#define USER_SETUP_ID 29
|
||||
|
||||
// Last update by Bodmer: 28/11/19
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// See SetupX_Template.h for all options available
|
||||
#define USER_SETUP_ID 2
|
||||
|
||||
#define ST7735_DRIVER
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
////////////////////////////////////////////////////
|
||||
// Setup for Nucleo 64 or 144 and ILI9341 display //
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define USER_SETUP_ID 30
|
||||
|
||||
// See SetupX_Template.h for all options available
|
||||
|
||||
// Define STM32 to invoke optimised processor support
|
||||
|
@ -1,7 +1,7 @@
|
||||
////////////////////////////////////////////////////
|
||||
// Setup for Nucleo 64 or 144 and ILI9341 display //
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
#define USER_SETUP_ID 31
|
||||
|
||||
// See SetupX_Template.h for all options available
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Setup for STM32F103 (e.g. Blue Pill) and ILI9341 display //
|
||||
//////////////////////////////////////////////////////////////
|
||||
#define USER_SETUP_ID 32
|
||||
|
||||
// Last update by Bodmer: 14/1/20
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
// Setup for STM32 Nucleo and ILI9341 display //
|
||||
///////////////////////////////////////////////////
|
||||
#define USER_SETUP_ID 33
|
||||
|
||||
// Last update by Bodmer: 28/11/19
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
////////////////////////////////////////////////////
|
||||
// Setup for Nucleo 64 or 144 and ILI9341 display //
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
#define USER_SETUP_ID 34
|
||||
// See SetupX_Template.h for all options available
|
||||
|
||||
// Define STM32 to invoke optimised processor support
|
||||
|
@ -1,7 +1,7 @@
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Setup for STM32 and ILI9341 display //
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
#define USER_SETUP_ID 35
|
||||
// Last update by Bodmer: 28/3/20
|
||||
|
||||
// Define STM32 to invoke STM32 optimised driver
|
||||
|
@ -1,4 +1,5 @@
|
||||
// See SetupX_Template.h for all options available
|
||||
#define USER_SETUP_ID 36
|
||||
|
||||
#define RPI_DISPLAY_TYPE
|
||||
#define ST7796_DRIVER
|
||||
|
@ -1,4 +1,5 @@
|
||||
// See SetupX_Template.h for all options available
|
||||
#define USER_SETUP_ID 3
|
||||
|
||||
#define ILI9163_DRIVER
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Setup for ESP32 and ST7735 80 x 160 TFT
|
||||
|
||||
#define USER_SETUP_ID 43
|
||||
// See SetupX_Template.h for all options available
|
||||
|
||||
#define ST7735_DRIVER
|
||||
|
@ -1,3 +1,4 @@
|
||||
#define USER_SETUP_ID 44
|
||||
|
||||
#define ST7789_DRIVER
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
#define USER_SETUP_ID 45
|
||||
|
||||
#define ST7789_DRIVER
|
||||
|
||||
#define TFT_WIDTH 240
|
||||
|
@ -1,3 +1,5 @@
|
||||
#define USER_SETUP_ID 46
|
||||
|
||||
#define GC9A01_DRIVER
|
||||
|
||||
#define TFT_MISO 19
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Config for two ST7735 128 x 128 displays for Animated_Eyes example
|
||||
#define USER_SETUP_ID 47
|
||||
|
||||
#define ST7735_DRIVER // Configure all registers
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// See SetupX_Template.h for all options available
|
||||
#define USER_SETUP_ID 4
|
||||
|
||||
#define S6D02A1_DRIVER
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
//
|
||||
// If this file is edited correctly then all the library example sketches should
|
||||
// run without the need to make any more changes for a particular hardware setup!
|
||||
|
||||
#define USER_SETUP_ID 50
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 0. Call up the right driver file and any options for it
|
||||
|
@ -1,3 +1,5 @@
|
||||
#define USER_SETUP_ID 51
|
||||
|
||||
#define ILI9481_DRIVER
|
||||
|
||||
#define TFT_BL 12 // LED back-light control pin
|
||||
|
@ -1,3 +1,5 @@
|
||||
#define USER_SETUP_ID 52
|
||||
|
||||
#define ST7796_DRIVER
|
||||
|
||||
#define TFT_BL 12 // LED back-light control pin
|
||||
|
@ -1,4 +1,5 @@
|
||||
// See SetupX_Template.h for all options available
|
||||
#define USER_SETUP_ID 5
|
||||
|
||||
#define RPI_ILI9486_DRIVER // 20MHz maximum SPI
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
// run without the need to make any more changes for a particular hardware setup!
|
||||
// Note that some sketches are designed for a particular TFT pixel width/height
|
||||
|
||||
|
||||
#define USER_SETUP_ID 60
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 1. Call up the right driver file and any options for it
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Setup file for RP2040 and SPI ILI9341 display using PIO for the display interface
|
||||
|
||||
#define USER_SETUP_ID 61
|
||||
// The PIO can only be user with Earle Philhower's RP2040 board package:
|
||||
// https://github.com/earlephilhower/arduino-pico
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
// run without the need to make any more changes for a particular hardware setup!
|
||||
// Note that some sketches are designed for a particular TFT pixel width/height
|
||||
|
||||
|
||||
#define USER_SETUP_ID 62
|
||||
// ##################################################################################
|
||||
//
|
||||
// Section 1. Call up the right driver file and any options for it
|
||||
|
@ -1,4 +1,5 @@
|
||||
// See SetupX_Template.h for all options available
|
||||
#define USER_SETUP_ID 6
|
||||
|
||||
#define RPI_ILI9486_DRIVER // 20MHz maximum SPI
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Setup for the ESP32 S2 with ILI9341 display
|
||||
// Note SPI DMA with ESP32 S2 is not currently supported
|
||||
|
||||
#define USER_SETUP_ID 70
|
||||
// See SetupX_Template.h for all options available
|
||||
#define ILI9341_DRIVER
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Setup for the ESP32 S2 with ST7789 display
|
||||
// Note SPI DMA with ESP32 S2 is not currently supported
|
||||
|
||||
#define USER_SETUP_ID 71
|
||||
// See SetupX_Template.h for all options available
|
||||
|
||||
#define ST7789_DRIVER // Configure all registers
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Support for 1.47" 320x172 Round Rectangle Color IPS TFT Display
|
||||
#define USER_SETUP_ID 71
|
||||
|
||||
#define ST7789_DRIVER // Full configuration option, define additional parameters below for this display
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// See SetupX_Template.h for all options available
|
||||
#define USER_SETUP_ID 7
|
||||
|
||||
#define ST7735_DRIVER
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// See SetupX_Template.h for all options available
|
||||
#define USER_SETUP_ID 8
|
||||
|
||||
#define ILI9163_DRIVER
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// See SetupX_Template.h for all options available
|
||||
#define USER_SETUP_ID 9
|
||||
|
||||
#define ST7735_DRIVER
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
// run without the need to make any more changes for a particular hardware setup!
|
||||
// Note that some sketches are designed for a particular TFT pixel width/height
|
||||
|
||||
#define USER_SETUP_ID 0xFFFFFFFF
|
||||
|
||||
// ##################################################################################
|
||||
//
|
||||
|
Before Width: | Height: | Size: 135 KiB After Width: | Height: | Size: 135 KiB |
Before Width: | Height: | Size: 126 KiB After Width: | Height: | Size: 126 KiB |
Before Width: | Height: | Size: 381 KiB After Width: | Height: | Size: 381 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
@ -119,20 +119,22 @@ void loop() {
|
||||
//tft.fillScreen(TFT_BLACK);
|
||||
|
||||
// Draw changing numbers - does not work unless a filled rectangle is drawn over the old text
|
||||
for (int i = 0; i <= 20; i++)
|
||||
for (int i = 0; i <= 99; i++)
|
||||
{
|
||||
tft.setCursor(50, 50);
|
||||
tft.setTextColor(TFT_GREEN, TFT_BLACK); // TFT_BLACK is used for anti-aliasing only
|
||||
// By default background fill is off
|
||||
tft.print(" "); // Overprinting old number with spaces DOES NOT WORK!
|
||||
tft.setTextColor(TFT_GREEN, TFT_BLACK);
|
||||
tft.setCursor(50, 50);
|
||||
tft.print(i / 10.0, 1);
|
||||
|
||||
tft.fillRect (50, 90, 60, 40, TFT_BLACK); // Overprint with a filled rectangle
|
||||
tft.setTextColor(TFT_GREEN, TFT_BLACK);
|
||||
// Adding a parameter "true" to the setTextColor() function fills character background
|
||||
// This extra parameter is only for smooth fonts!
|
||||
tft.setTextColor(TFT_GREEN, TFT_BLACK, true);
|
||||
tft.setCursor(50, 90);
|
||||
tft.print(i / 10.0, 1);
|
||||
|
||||
//delay (200);
|
||||
delay (200);
|
||||
}
|
||||
|
||||
delay(5000);
|
||||
|
@ -89,7 +89,8 @@ void loop() {
|
||||
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
|
||||
tft.setTextColor(TFT_GREEN, TFT_BLUE); // Change the font colour and the background colour
|
||||
// The "true" parameter forces background drawing for smooth fonts
|
||||
tft.setTextColor(TFT_GREEN, TFT_BLUE, true); // Change the font colour and the background colour
|
||||
|
||||
tft.drawString("36pt font", xpos, ypos);
|
||||
|
||||
@ -99,11 +100,14 @@ void loop() {
|
||||
tft.setTextPadding(100);
|
||||
|
||||
// Draw changing numbers - likely to flicker using this plot method!
|
||||
for (int i = 0; i <= 20; i++) {
|
||||
for (int i = 0; i <= 99; i++) {
|
||||
tft.drawFloat(i / 10.0, 1, xpos, ypos);
|
||||
delay (200);
|
||||
}
|
||||
|
||||
// Turn off text padding by setting value to 0
|
||||
tft.setTextPadding(0);
|
||||
|
||||
tft.unloadFont(); // Remove the font to recover memory used
|
||||
|
||||
delay(5000);
|
||||
@ -119,7 +123,7 @@ void loop() {
|
||||
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
|
||||
tft.setTextColor(TFT_DARKGREY, TFT_BLACK);
|
||||
tft.setTextColor(TFT_DARKGREY, TFT_BLACK, false);
|
||||
|
||||
// Use middle of screen as datum
|
||||
xpos = tft.width() /2;
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
This sketch uses method 3, the font characters are first plotted in a Sprite, then the
|
||||
Sprite is pushed to the screen. This method is very flexible and the Sprite can be
|
||||
created, deleted, resized as needed. To render anit-aliased fonts well the Sprite
|
||||
created, deleted, resized as needed. To render anti-aliased fonts well the Sprite
|
||||
needs to be 16 bit. The fonts will render in 1 bit per pixel sprites but there
|
||||
will then be no anti-aliasing. Using 1 bit per pixel Sprites is however useful
|
||||
to use the extended Unicode range in fonts on mono displays like ePaper.
|
||||
|
@ -3,7 +3,7 @@
|
||||
for rendering anti-aliased fonts on an arbitrary background. This is achieved
|
||||
by reading the pixel color at each point on the screen. The TFT must support
|
||||
reading the graphics RAM of the screen memory. This sketch has been tested with
|
||||
ILI9241 and ILI9481 serial and parallel screens.
|
||||
ILI9341 and ILI9481 serial and parallel screens.
|
||||
|
||||
The TFT_eSPI library must be given the name of the function in the sketch
|
||||
that will return the pixel color at a position x,y on the TFT. In this
|
||||
|
@ -140,13 +140,15 @@ void loop() {
|
||||
for (int i = 0; i <= 20; i++)
|
||||
{
|
||||
tft.setCursor(50, 50);
|
||||
tft.setTextColor(TFT_GREEN, TFT_BLACK); // TFT_BLACK is used for anti-aliasing only
|
||||
// By default background fill is off
|
||||
tft.print(" "); // Overprinting old number with spaces DOES NOT WORK!
|
||||
tft.setTextColor(TFT_GREEN, TFT_BLACK);
|
||||
tft.setCursor(50, 50);
|
||||
tft.print(i / 10.0, 1);
|
||||
|
||||
tft.fillRect (50, 90, 60, 40, TFT_BLACK); // Overprint with a filled rectangle
|
||||
tft.setTextColor(TFT_GREEN, TFT_BLACK);
|
||||
// Adding a parameter "true" to the setTextColor() function fills character background
|
||||
// This extra parameter is only for smooth fonts!
|
||||
tft.setTextColor(TFT_GREEN, TFT_BLACK, true);
|
||||
tft.setCursor(50, 90);
|
||||
tft.print(i / 10.0, 1);
|
||||
|
||||
|
@ -108,7 +108,8 @@ void loop() {
|
||||
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
|
||||
tft.setTextColor(TFT_GREEN, TFT_BLUE); // Change the font colour and the background colour
|
||||
// The "true" parameter forces background drawing for smooth fonts
|
||||
tft.setTextColor(TFT_GREEN, TFT_BLUE, true); // Change the font colour and the background colour
|
||||
|
||||
tft.drawString("36pt font", xpos, ypos);
|
||||
|
||||
@ -123,6 +124,9 @@ void loop() {
|
||||
delay (200);
|
||||
}
|
||||
|
||||
// Turn off text padding by setting value to 0
|
||||
tft.setTextPadding(0);
|
||||
|
||||
tft.unloadFont(); // Remove the font to recover memory used
|
||||
|
||||
delay(5000);
|
||||
@ -138,7 +142,7 @@ void loop() {
|
||||
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
|
||||
tft.setTextColor(TFT_DARKGREY, TFT_BLACK);
|
||||
tft.setTextColor(TFT_DARKGREY, TFT_BLACK, false);
|
||||
|
||||
// Use middle of screen as datum
|
||||
xpos = tft.width() /2;
|
||||
|
@ -141,13 +141,15 @@ void loop() {
|
||||
for (int i = 0; i <= 20; i++)
|
||||
{
|
||||
tft.setCursor(50, 50);
|
||||
tft.setTextColor(TFT_GREEN, TFT_BLACK); // TFT_BLACK is used for anti-aliasing only
|
||||
// By default background fill is off
|
||||
tft.print(" "); // Overprinting old number with spaces DOES NOT WORK!
|
||||
tft.setTextColor(TFT_GREEN, TFT_BLACK);
|
||||
tft.setCursor(50, 50);
|
||||
tft.print(i / 10.0, 1);
|
||||
|
||||
tft.fillRect (50, 90, 60, 40, TFT_BLACK); // Overprint with a filled rectangle
|
||||
tft.setTextColor(TFT_GREEN, TFT_BLACK);
|
||||
// Adding a parameter "true" to the setTextColor() function fills character background
|
||||
// This extra parameter is only for smooth fonts!
|
||||
tft.setTextColor(TFT_GREEN, TFT_BLACK, true);
|
||||
tft.setCursor(50, 90);
|
||||
tft.print(i / 10.0, 1);
|
||||
|
||||
|
@ -109,7 +109,8 @@ void loop() {
|
||||
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
|
||||
tft.setTextColor(TFT_GREEN, TFT_BLUE); // Change the font colour and the background colour
|
||||
// The "true" parameter forces background drawing for smooth fonts
|
||||
tft.setTextColor(TFT_GREEN, TFT_BLUE, true); // Change the font colour and the background colour
|
||||
|
||||
tft.drawString("36pt font", xpos, ypos);
|
||||
|
||||
@ -124,6 +125,9 @@ void loop() {
|
||||
delay (200);
|
||||
}
|
||||
|
||||
// Turn off text padding by setting value to 0
|
||||
tft.setTextPadding(0);
|
||||
|
||||
tft.unloadFont(); // Remove the font to recover memory used
|
||||
|
||||
delay(5000);
|
||||
@ -139,7 +143,7 @@ void loop() {
|
||||
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
|
||||
tft.setTextColor(TFT_DARKGREY, TFT_BLACK);
|
||||
tft.setTextColor(TFT_DARKGREY, TFT_BLACK, false);
|
||||
|
||||
// Use middle of screen as datum
|
||||
xpos = tft.width() /2;
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "TFT_eSPI",
|
||||
"version": "2.4.45",
|
||||
"version": "2.4.50",
|
||||
"keywords": "Arduino, tft, display, ttgo, LilyPi, WT32-SC01, ePaper, display, Pico, RP2040 Nano Connect, RP2040, STM32, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9481, ILI9486, ILI9488, ST7789, ST7796, RM68140, SSD1351, SSD1963, ILI9225, HX8357D, GC9A01, R61581",
|
||||
"description": "A TFT and ePaper SPI graphics library with optimisation for Raspberry Pi Pico, RP2040, ESP8266, ESP32 and STM32",
|
||||
"repository":
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=TFT_eSPI
|
||||
version=2.4.45
|
||||
version=2.4.50
|
||||
author=Bodmer
|
||||
maintainer=Bodmer
|
||||
sentence=TFT graphics library for Arduino processors with performance optimisation for RP2040, STM32, ESP8266 and ESP32
|
||||
|