Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
TFT_eSPI
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
TFT_eSPI
Commits
b6db90ad
Commit
b6db90ad
authored
Feb 03, 2022
by
Bodmer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new anit-aliased graphics functions
Examples to follow.
parent
97ca3fdb
Changes
9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
408 additions
and
56 deletions
+408
-56
Extensions/Sprite.cpp
Extensions/Sprite.cpp
+2
-2
Extensions/Sprite.h
Extensions/Sprite.h
+6
-2
Processors/TFT_eSPI_ESP32.h
Processors/TFT_eSPI_ESP32.h
+4
-0
Processors/TFT_eSPI_RP2040.h
Processors/TFT_eSPI_RP2040.h
+13
-1
TFT_eSPI.cpp
TFT_eSPI.cpp
+324
-39
TFT_eSPI.h
TFT_eSPI.h
+48
-10
keywords.txt
keywords.txt
+9
-0
library.json
library.json
+1
-1
library.properties
library.properties
+1
-1
No files found.
Extensions/Sprite.cpp
View file @
b6db90ad
...
...
@@ -1292,7 +1292,7 @@ void TFT_eSprite::setWindow(int32_t x0, int32_t y0, int32_t x1, int32_t y1)
** Function name: pushColor
** Description: Send a new pixel to the set window
***************************************************************************************/
void
TFT_eSprite
::
pushColor
(
uint
32
_t
color
)
void
TFT_eSprite
::
pushColor
(
uint
16
_t
color
)
{
if
(
!
_created
)
return
;
...
...
@@ -1334,7 +1334,7 @@ void TFT_eSprite::pushColor(uint32_t color)
** Function name: pushColor
** Description: Send a "len" new pixels to the set window
***************************************************************************************/
void
TFT_eSprite
::
pushColor
(
uint
32_t
color
,
uint16
_t
len
)
void
TFT_eSprite
::
pushColor
(
uint
16_t
color
,
uint32
_t
len
)
{
if
(
!
_created
)
return
;
...
...
Extensions/Sprite.h
View file @
b6db90ad
...
...
@@ -63,9 +63,9 @@ class TFT_eSprite : public TFT_eSPI {
// Colours are converted to the set Sprite colour bit depth
setWindow
(
int32_t
x0
,
int32_t
y0
,
int32_t
x1
,
int32_t
y1
),
// Push a color (aka singe pixel) to the screen
pushColor
(
uint
32
_t
color
),
pushColor
(
uint
16
_t
color
),
// Push len colors (pixels) to the screen
pushColor
(
uint
32_t
color
,
uint16
_t
len
),
pushColor
(
uint
16_t
color
,
uint32
_t
len
),
// Push a pixel preformatted as a 8 or 16 bit colour (avoids conversion overhead)
writeColor
(
uint16_t
color
),
...
...
@@ -149,6 +149,10 @@ class TFT_eSprite : public TFT_eSPI {
// Reserve memory for the Sprite and return a pointer
void
*
callocSprite
(
int16_t
width
,
int16_t
height
,
uint8_t
frames
=
1
);
// Override the non-inlined TFT_eSPI functions
void
begin_nin_write
(
void
)
{
;
}
void
end_nin_write
(
void
)
{
;
}
protected:
uint8_t
_bpp
;
// bits per pixel (1, 8 or 16)
...
...
Processors/TFT_eSPI_ESP32.h
View file @
b6db90ad
...
...
@@ -426,6 +426,10 @@ SPI3_HOST = 2
#define RD_L
#define RD_H
#endif
#else
#define TFT_RD -1
#define RD_L
#define RD_H
#endif
////////////////////////////////////////////////////////////////////////////////////////
...
...
Processors/TFT_eSPI_RP2040.h
View file @
b6db90ad
...
...
@@ -160,8 +160,20 @@
// Make sure TFT_RD is defined if not used to avoid an error message
////////////////////////////////////////////////////////////////////////////////////////
// At the moment read is not supported for parallel mode, tie TFT signal high
#ifndef TFT_RD
#ifdef TFT_RD
#if (TFT_RD >= 0)
#define RD_L sio_hw->gpio_clr = (1ul << TFT_RD)
//#define RD_L digitalWrite(TFT_WR, LOW)
#define RD_H sio_hw->gpio_set = (1ul << TFT_RD)
//#define RD_H digitalWrite(TFT_WR, HIGH)
#else
#define RD_L
#define RD_H
#endif
#else
#define TFT_RD -1
#define RD_L
#define RD_H
#endif
////////////////////////////////////////////////////////////////////////////////////////
...
...
TFT_eSPI.cpp
View file @
b6db90ad
This diff is collapsed.
Click to expand it.
TFT_eSPI.h
View file @
b6db90ad
...
...
@@ -16,7 +16,7 @@
#ifndef _TFT_eSPIH_
#define _TFT_eSPIH_
#define TFT_ESPI_VERSION "2.4.3
2
"
#define TFT_ESPI_VERSION "2.4.3
3
"
// Bit level feature flags
// Bit 0 set: viewport capability
...
...
@@ -407,6 +407,18 @@ class TFT_eSPI : public Print { friend class TFT_eSprite; // Sprite class has ac
height
(
void
),
width
(
void
);
// Read the colour of a pixel at x,y and return value in 565 format
virtual
uint16_t
readPixel
(
int32_t
x
,
int32_t
y
);
virtual
void
setWindow
(
int32_t
xs
,
int32_t
ys
,
int32_t
xe
,
int32_t
ye
);
// Note: start + end coordinates
// Push (aka write pixel) colours to the set window
virtual
void
pushColor
(
uint16_t
color
);
// These are non-inlined to enable override
virtual
void
begin_nin_write
();
virtual
void
end_nin_write
();
void
setRotation
(
uint8_t
r
);
// Set the display image orientation to 0, 1, 2 or 3
uint8_t
getRotation
(
void
);
// Read the current rotation
...
...
@@ -414,8 +426,7 @@ class TFT_eSPI : public Print { friend class TFT_eSprite; // Sprite class has ac
// The TFT_eSprite class inherits the following functions (not all are useful to Sprite class
void
setAddrWindow
(
int32_t
xs
,
int32_t
ys
,
int32_t
w
,
int32_t
h
),
// Note: start coordinates + width and height
setWindow
(
int32_t
xs
,
int32_t
ys
,
int32_t
xe
,
int32_t
ye
);
// Note: start + end coordinates
void
setAddrWindow
(
int32_t
xs
,
int32_t
ys
,
int32_t
w
,
int32_t
h
);
// Note: start coordinates + width and height
// Viewport commands, see "Viewport_Demo" sketch
void
setViewport
(
int32_t
x
,
int32_t
y
,
int32_t
w
,
int32_t
h
,
bool
vpDatum
=
true
);
...
...
@@ -428,9 +439,13 @@ class TFT_eSPI : public Print { friend class TFT_eSprite; // Sprite class has ac
void
frameViewport
(
uint16_t
color
,
int32_t
w
);
void
resetViewport
(
void
);
// Clip input window to viewport bounds, return false if whole area is out of bounds
bool
clipAddrWindow
(
int32_t
*
x
,
int32_t
*
y
,
int32_t
*
w
,
int32_t
*
h
);
// Clip input window area to viewport bounds, return false if whole area is out of bounds
bool
clipWindow
(
int32_t
*
xs
,
int32_t
*
ys
,
int32_t
*
xe
,
int32_t
*
ye
);
// Push (aka write pixel) colours to the TFT (use setAddrWindow() first)
void
pushColor
(
uint16_t
color
),
pushColor
(
uint16_t
color
,
uint32_t
len
),
// Deprecated, use pushBlock()
void
pushColor
(
uint16_t
color
,
uint32_t
len
),
// Deprecated, use pushBlock()
pushColors
(
uint16_t
*
data
,
uint32_t
len
,
bool
swap
=
true
),
// With byte swap option
pushColors
(
uint8_t
*
data
,
uint32_t
len
);
// Deprecated, use pushPixels()
...
...
@@ -440,9 +455,6 @@ class TFT_eSPI : public Print { friend class TFT_eSprite; // Sprite class has ac
// Write a set of pixels stored in memory, use setSwapBytes(true/false) function to correct endianess
void
pushPixels
(
const
void
*
data_in
,
uint32_t
len
);
// Read the colour of a pixel at x,y and return value in 565 format
uint16_t
readPixel
(
int32_t
x
,
int32_t
y
);
// Support for half duplex (bi-directional SDA) SPI bus where MOSI must be switched to input
#ifdef TFT_SDA_READ
#if defined (TFT_eSPI_ENABLE_8_BIT_READ)
...
...
@@ -461,6 +473,28 @@ class TFT_eSPI : public Print { friend class TFT_eSprite; // Sprite class has ac
void
fillRectVGradient
(
int16_t
x
,
int16_t
y
,
int16_t
w
,
int16_t
h
,
uint32_t
color1
,
uint32_t
color2
);
void
fillRectHGradient
(
int16_t
x
,
int16_t
y
,
int16_t
w
,
int16_t
h
,
uint32_t
color1
,
uint32_t
color2
);
// Draw a pixel blended with the pixel colour on the TFT or sprite, return blended colour
// If bg_color is not included the background pixel colour will be read from TFT or sprite
uint16_t
drawPixel
(
int32_t
x
,
int32_t
y
,
uint32_t
color
,
uint8_t
alpha
,
uint32_t
bg_color
=
0x00FFFFFF
);
// Draw a small anti-aliased filled circle at ax,ay with radius r (uses drawWideLine)
// If bg_color is not included the background pixel colour will be read from TFT or sprite
void
drawSpot
(
float
ax
,
float
ay
,
float
r
,
uint32_t
fg_color
,
uint32_t
bg_color
=
0x00FFFFFF
);
// Draw an anti-aliased filled circle at x, y with radius r
// If bg_color is not included the background pixel colour will be read from TFT or sprite
void
fillSmoothCircle
(
int32_t
x
,
int32_t
y
,
int32_t
r
,
uint32_t
color
,
uint32_t
bg_color
=
0x00FFFFFF
);
void
fillSmoothRoundRect
(
int32_t
x
,
int32_t
y
,
int32_t
w
,
int32_t
h
,
int32_t
radius
,
uint32_t
color
,
uint32_t
bg_color
=
0x00FFFFFF
);
// Draw an anti-aliased wide line from ax,ay to bx,by width wd with radiused ends (radius is wd/2)
// If bg_color is not included the background pixel colour will be read from TFT or sprite
void
drawWideLine
(
float
ax
,
float
ay
,
float
bx
,
float
by
,
float
wd
,
uint32_t
fg_color
,
uint32_t
bg_color
=
0x00FFFFFF
);
// Draw an anti-aliased wide line from ax,ay to bx,by with different width at each end aw, bw and with radiused ends
// If bg_color is not included the background pixel colour will be read from TFT or sprite
void
drawWedgeLine
(
float
ax
,
float
ay
,
float
bx
,
float
by
,
float
aw
,
float
bw
,
uint32_t
fg_color
,
uint32_t
bg_color
=
0x00FFFFFF
);
void
drawCircle
(
int32_t
x
,
int32_t
y
,
int32_t
r
,
uint32_t
color
),
drawCircleHelper
(
int32_t
x
,
int32_t
y
,
int32_t
r
,
uint8_t
cornername
,
uint32_t
color
),
fillCircle
(
int32_t
x
,
int32_t
y
,
int32_t
r
,
uint32_t
color
),
...
...
@@ -577,6 +611,7 @@ class TFT_eSPI : public Print { friend class TFT_eSprite; // Sprite class has ac
// Support function to UTF8 decode and draw characters piped through print stream
size_t
write
(
uint8_t
);
size_t
write
(
const
uint8_t
*
buf
,
size_t
len
);
// Used by Smooth font class to fetch a pixel colour for the anti-aliasing
void
setCallback
(
getColorCallback
getCol
);
...
...
@@ -744,6 +779,9 @@ class TFT_eSPI : public Print { friend class TFT_eSprite; // Sprite class has ac
// Single GPIO input/output direction control
void
gpioMode
(
uint8_t
gpio
,
uint8_t
mode
);
// Helper function: calculate distance of a point from a finite length line between two points
float
wedgeLineDistance
(
float
pax
,
float
pay
,
float
bax
,
float
bay
,
float
dr
);
// Display variant settings
uint8_t
tabcolor
,
// ST7735 screen protector "tab" colour (now invalid)
colstart
=
0
,
rowstart
=
0
;
// Screen display area to CGRAM area coordinate offsets
...
...
keywords.txt
View file @
b6db90ad
...
...
@@ -27,6 +27,15 @@ getViewportHeight KEYWORD2
getViewportDatum KEYWORD2
frameViewport KEYWORD2
# Smooth (anti-aliased) graphics functions
fillRectHGradient KEYWORD2
fillRectVGradient KEYWORD2
fillSmoothCircle KEYWORD2
fillSmoothRoundRect KEYWORD2
drawSpot KEYWORD2
drawWideLine KEYWORD2
drawWedgeLine KEYWORD2
pushColor KEYWORD2
pushColors KEYWORD2
pushBlock KEYWORD2
...
...
library.json
View file @
b6db90ad
{
"name"
:
"TFT_eSPI"
,
"version"
:
"2.4.3
2
"
,
"version"
:
"2.4.3
3
"
,
"keywords"
:
"Arduino, tft, ePaper, display, Pico, RP2040, STM32, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9481, ILI9486, ILI9488, ST7789, RM68140, SSD1351, SSD1963, ILI9225, HX8357D"
,
"description"
:
"A TFT and ePaper SPI graphics library with optimisation for Raspberry Pi Pico, ESP8266, ESP32 and STM32"
,
"repository"
:
...
...
library.properties
View file @
b6db90ad
name
=
TFT_eSPI
version
=
2.4.3
2
version
=
2.4.3
3
author
=
Bodmer
maintainer
=
Bodmer
sentence
=
TFT graphics library for Arduino processors with performance optimisation for RP2040, STM32, ESP8266 and ESP32
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment