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
c8c63172
Commit
c8c63172
authored
Oct 25, 2020
by
Bodmer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add off-screen support to readRect()
See #803
parent
1c1ec8cf
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
49 deletions
+55
-49
TFT_eSPI.cpp
TFT_eSPI.cpp
+52
-46
TFT_eSPI.h
TFT_eSPI.h
+1
-1
library.json
library.json
+1
-1
library.properties
library.properties
+1
-1
No files found.
TFT_eSPI.cpp
View file @
c8c63172
...
...
@@ -1023,57 +1023,52 @@ void TFT_eSPI::setCallback(getColorCallback getCol)
***************************************************************************************/
void
TFT_eSPI
::
readRect
(
int32_t
x
,
int32_t
y
,
int32_t
w
,
int32_t
h
,
uint16_t
*
data
)
{
if
(
_vpOoB
)
return
;
x
+=
_xDatum
;
y
+=
_yDatum
;
// Clipping
if
((
x
>=
_vpW
)
||
(
y
>=
_vpH
))
return
;
if
(
x
<
_vpX
)
{
w
+=
x
-
_vpX
;
x
=
_vpX
;
}
if
(
y
<
_vpY
)
{
h
+=
y
-
_vpY
;
y
=
_vpY
;
}
if
((
x
+
w
)
>
_vpW
)
w
=
_vpW
-
x
;
if
((
y
+
h
)
>
_vpH
)
h
=
_vpH
-
y
;
if
((
w
<
1
)
||
(
h
<
1
))
return
;
PI_CLIP
;
#if defined(TFT_PARALLEL_8_BIT)
CS_L
;
readAddrWindow
(
x
,
y
,
w
,
h
);
readAddrWindow
(
x
,
y
,
dw
,
dh
);
data
+=
dx
+
dy
*
w
;
// Set masked pins D0- D7 to input
busDir
(
dir_mask
,
INPUT
);
// Total pixel count
uint32_t
len
=
w
*
h
;
#if defined (ILI9341_DRIVER) | defined (ILI9488_DRIVER) // Read 3 bytes
// Dummy read to throw away don't care value
readByte
();
// Fetch the 24 bit RGB value
while
(
len
--
)
{
// Assemble the RGB 16 bit colour
uint16_t
rgb
=
((
readByte
()
&
0xF8
)
<<
8
)
|
((
readByte
()
&
0xFC
)
<<
3
)
|
(
readByte
()
>>
3
);
while
(
dh
--
)
{
int32_t
lw
=
dw
;
uint16_t
*
line
=
data
;
while
(
lw
--
)
{
// Assemble the RGB 16 bit colour
uint16_t
rgb
=
((
readByte
()
&
0xF8
)
<<
8
)
|
((
readByte
()
&
0xFC
)
<<
3
)
|
(
readByte
()
>>
3
);
// Swapped byte order for compatibility with pushRect()
*
data
++
=
(
rgb
<<
8
)
|
(
rgb
>>
8
);
// Swapped byte order for compatibility with pushRect()
*
line
++
=
(
rgb
<<
8
)
|
(
rgb
>>
8
);
}
data
+=
w
;
}
#elif defined (SSD1963_DRIVER)
// Fetch the 18 bit BRG pixels
while
(
len
--
)
{
uint16_t
bgr
=
((
readByte
()
&
0xF8
)
>>
3
);;
// CS_L adds a small delay
bgr
|=
((
readByte
()
&
0xFC
)
<<
3
);
bgr
|=
(
readByte
()
<<
8
);
// Swap Red and Blue (could check MADCTL setting to see if this is needed)
uint16_t
rgb
=
(
bgr
>>
11
)
|
(
bgr
<<
11
)
|
(
bgr
&
0x7E0
);
// Swapped byte order for compatibility with pushRect()
*
data
++
=
(
rgb
<<
8
)
|
(
rgb
>>
8
);
while
(
dh
--
)
{
int32_t
lw
=
dw
;
uint16_t
*
line
=
data
;
while
(
lw
--
)
{
uint16_t
bgr
=
((
readByte
()
&
0xF8
)
>>
3
);;
// CS_L adds a small delay
bgr
|=
((
readByte
()
&
0xFC
)
<<
3
);
bgr
|=
(
readByte
()
<<
8
);
// Swap Red and Blue (could check MADCTL setting to see if this is needed)
uint16_t
rgb
=
(
bgr
>>
11
)
|
(
bgr
<<
11
)
|
(
bgr
&
0x7E0
);
// Swapped byte order for compatibility with pushRect()
*
line
++
=
(
rgb
<<
8
)
|
(
rgb
>>
8
);
}
data
+=
w
;
}
#else // ILI9481 reads as 16 bits
...
...
@@ -1081,18 +1076,23 @@ void TFT_eSPI::readRect(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t *da
readByte
();
// Fetch the 16 bit BRG pixels
while
(
len
--
)
{
while
(
dh
--
)
{
int32_t
lw
=
dw
;
uint16_t
*
line
=
data
;
while
(
lw
--
)
{
#ifdef ILI9486_DRIVER
// Read the RGB 16 bit colour
*
data
++
=
readByte
()
|
(
readByte
()
<<
8
);
*
line
++
=
readByte
()
|
(
readByte
()
<<
8
);
#else
// Read the BRG 16 bit colour
uint16_t
bgr
=
(
readByte
()
<<
8
)
|
readByte
();
// Swap Red and Blue (could check MADCTL setting to see if this is needed)
uint16_t
rgb
=
(
bgr
>>
11
)
|
(
bgr
<<
11
)
|
(
bgr
&
0x7E0
);
// Swapped byte order for compatibility with pushRect()
*
data
++
=
(
rgb
<<
8
)
|
(
rgb
>>
8
);
*
line
++
=
(
rgb
<<
8
)
|
(
rgb
>>
8
);
#endif
}
data
+=
w
;
}
#endif
...
...
@@ -1107,7 +1107,9 @@ void TFT_eSPI::readRect(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t *da
begin_tft_read
();
readAddrWindow
(
x
,
y
,
w
,
h
);
readAddrWindow
(
x
,
y
,
dw
,
dh
);
data
+=
dx
+
dy
*
w
;
#ifdef TFT_SDA_READ
begin_SDA_Read
();
...
...
@@ -1117,8 +1119,10 @@ void TFT_eSPI::readRect(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t *da
tft_Read_8
();
// Read window pixel 24 bit RGB values
uint32_t
len
=
w
*
h
;
while
(
len
--
)
{
while
(
dh
--
)
{
int32_t
lw
=
dw
;
uint16_t
*
line
=
data
;
while
(
lw
--
)
{
#if !defined (ILI9488_DRIVER)
...
...
@@ -1136,16 +1140,18 @@ void TFT_eSPI::readRect(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t *da
#else
// The 6 colour bits are in MS 6 bits of each byte but we do not include the extra clock pulse
// so we use a trick and mask the middle 6 bits of the byte, then only shift 1 place left
uint8_t
r
=
(
tft_Read_8
()
&
0x7E
)
<<
1
;
uint8_t
g
=
(
tft_Read_8
()
&
0x7E
)
<<
1
;
uint8_t
b
=
(
tft_Read_8
()
&
0x7E
)
<<
1
;
color
=
color565
(
r
,
g
,
b
);
// The 6 colour bits are in MS 6 bits of each byte but we do not include the extra clock pulse
// so we use a trick and mask the middle 6 bits of the byte, then only shift 1 place left
uint8_t
r
=
(
tft_Read_8
()
&
0x7E
)
<<
1
;
uint8_t
g
=
(
tft_Read_8
()
&
0x7E
)
<<
1
;
uint8_t
b
=
(
tft_Read_8
()
&
0x7E
)
<<
1
;
color
=
color565
(
r
,
g
,
b
);
#endif
// Swapped colour byte order for compatibility with pushRect()
*
data
++
=
color
<<
8
|
color
>>
8
;
// Swapped colour byte order for compatibility with pushRect()
*
line
++
=
color
<<
8
|
color
>>
8
;
}
data
+=
w
;
}
//CS_H;
...
...
TFT_eSPI.h
View file @
c8c63172
...
...
@@ -16,7 +16,7 @@
#ifndef _TFT_eSPIH_
#define _TFT_eSPIH_
#define TFT_ESPI_VERSION "2.3.
2
"
#define TFT_ESPI_VERSION "2.3.
3
"
// Bit level feature flags
// Bit 0 set: viewport capability
...
...
library.json
View file @
c8c63172
{
"name"
:
"TFT_eSPI"
,
"version"
:
"2.3.
2
"
,
"version"
:
"2.3.
3
"
,
"keywords"
:
"Arduino, tft, ePaper, display, STM32, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9486, ST7789, RM68140"
,
"description"
:
"A TFT and ePaper SPI graphics library with optimisation for ESP8266, ESP32 and STM32"
,
"repository"
:
...
...
library.properties
View file @
c8c63172
name
=
TFT_eSPI
version
=
2.3.
2
version
=
2.3.
3
author
=
Bodmer
maintainer
=
Bodmer
sentence
=
TFT graphics library for Arduino processors with performance optimisation for 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