Skip to content

Commit e52a016

Browse files
committed
Fix #1760, fix #1763, fix #1764
1 parent e4accc0 commit e52a016

File tree

10 files changed

+226
-21
lines changed

10 files changed

+226
-21
lines changed

Processors/TFT_eSPI_RP2040.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
// Processor ID reported by getSetup()
2323
#define PROCESSOR_ID 0x2040
2424

25+
// Transactions always supported
26+
#ifndef SUPPORT_TRANSACTIONS
27+
#define SUPPORT_TRANSACTIONS
28+
#endif
29+
2530
// Include processor specific header
2631
// None
2732

@@ -285,6 +290,25 @@
285290
spi.transfer(0); spi.transfer((C)>>8); \
286291
spi.transfer(0); spi.transfer((C)>>0)
287292

293+
#elif defined (ILI9225_DRIVER) // Needs gaps between commands + data bytes, so use slower transfer functions
294+
295+
// These all end in 8 bit mode
296+
#define tft_Write_8(C) spi.transfer(C);
297+
298+
// Note: the following macros do not wait for the end of transmission
299+
300+
#define tft_Write_16(C) spi.transfer16(C)
301+
302+
#define tft_Write_16N(C) spi.transfer16(C)
303+
304+
#define tft_Write_16S(C) spi.transfer16((C)<<8 | (C)>>8)
305+
306+
#define tft_Write_32(C) spi.transfer16((C)>>16); spi.transfer16(C)
307+
308+
#define tft_Write_32C(C,D) spi.transfer16(C); spi.transfer16(D)
309+
310+
#define tft_Write_32D(C) spi.transfer16(C); spi.transfer16(C)
311+
288312
#else
289313

290314
// This swaps to 8 bit mode, then back to 16 bit mode

Processors/pio_SPI_18bit.pio

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
// Raspberry Pi Pico PIO program to output 18 bit data to a TFT
2+
// controller via a SPI output data path.
3+
4+
//"Set" set: 1 output pin, TFT_DC
5+
// Side set: 1 output pin, TFT_SCLK
6+
// Data set: 1 output pin, TFT_MOSI
7+
8+
.program tft_io
9+
.side_set 1 opt ; The TFT_SCLK output.
10+
11+
// The C++ code switches between the 8 bits and 16 bits loops
12+
// by waiting for the SM to be idle and setting its PC.
13+
//
14+
15+
// 8 bit transfer
16+
public start_8:
17+
// Pull the next 32 bit value from the TX FIFO.
18+
pull side 0
19+
// Lose the top 24 bits, send 1st bit
20+
out pins, 25
21+
// Now send remaining bits
22+
jmp spi_out side 1
23+
24+
public set_addr_window:
25+
// Loop count in x for caset, paset and ramwr
26+
set x, 2 side 0
27+
pull_cmd:
28+
// Set DC low
29+
set pins, 0
30+
// Fetch and output LS byte (caset, paset or ramwr), discarding top 24 bits, set WR low
31+
pull side 0
32+
out pins, 25
33+
nop side 1
34+
next_cmd_bit:
35+
out pins, 1 side 0
36+
jmp !osre, next_cmd_bit side 1
37+
// Set DC high
38+
set pins, 1 side 0
39+
// Finish if 3rd cmd byte ramwr sent (x == 0)
40+
jmp !x, start_tx
41+
pull
42+
next_xy:
43+
// send 32 bit start and end coordinates
44+
out pins, 1 side 0
45+
jmp !osre, next_xy side 1
46+
// Loop back for next command
47+
jmp x--, pull_cmd side 0
48+
// End
49+
jmp start_tx
50+
51+
public block_fill:
52+
// Fetch colour value
53+
pull side 0
54+
// Move colour to x
55+
mov x, osr
56+
// Fetch pixel count
57+
pull
58+
// Move pixel count to y
59+
mov y, osr
60+
next_16:
61+
// Copy colour value back into osr
62+
mov osr, x side 0
63+
// Lose the top 8 bits, send 1st bit
64+
out pins, 9 side 0
65+
nop side 1
66+
next_bit:
67+
// Output next remaining bits
68+
out pins, 1 side 0
69+
// Set TFT_SCLK high and jump for next bit
70+
jmp !osre, next_bit side 1
71+
// Decrement count and loop
72+
jmp y--, next_16 side 0
73+
// Now drop back to 16 bit output
74+
75+
.wrap_target
76+
public start_tx:
77+
// Pull the next 32 bit value from the TX FIFO.
78+
// Send the bottom 24 bits
79+
pull side 0
80+
// Drop the first 8 bits, write first bit
81+
out pins, 9 side 0
82+
nop side 1
83+
spi_out:
84+
// Output the remaining bits
85+
out pins, 1 side 0
86+
// Set TFT_SCLK high and jump for next bit
87+
jmp !osre, spi_out side 1
88+
// Return to start
89+
.wrap

Processors/pio_SPI_18bit.pio.h

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// -------------------------------------------------- //
2+
// This file is autogenerated by pioasm; do not edit! //
3+
// -------------------------------------------------- //
4+
5+
#pragma once
6+
7+
#if !PICO_NO_HARDWARE
8+
#include "hardware/pio.h"
9+
#endif
10+
11+
// ------ //
12+
// tft_io //
13+
// ------ //
14+
15+
#define tft_io_wrap_target 27
16+
#define tft_io_wrap 31
17+
18+
#define tft_io_offset_start_8 0u
19+
#define tft_io_offset_set_addr_window 3u
20+
#define tft_io_offset_block_fill 17u
21+
#define tft_io_offset_start_tx 27u
22+
23+
static const uint16_t tft_io_program_instructions[] = {
24+
0x90a0, // 0: pull block side 0
25+
0x6019, // 1: out pins, 25
26+
0x181e, // 2: jmp 30 side 1
27+
0xf022, // 3: set x, 2 side 0
28+
0xe000, // 4: set pins, 0
29+
0x90a0, // 5: pull block side 0
30+
0x6019, // 6: out pins, 25
31+
0xb842, // 7: nop side 1
32+
0x7001, // 8: out pins, 1 side 0
33+
0x18e8, // 9: jmp !osre, 8 side 1
34+
0xf001, // 10: set pins, 1 side 0
35+
0x003b, // 11: jmp !x, 27
36+
0x80a0, // 12: pull block
37+
0x7001, // 13: out pins, 1 side 0
38+
0x18ed, // 14: jmp !osre, 13 side 1
39+
0x1044, // 15: jmp x--, 4 side 0
40+
0x001b, // 16: jmp 27
41+
0x90a0, // 17: pull block side 0
42+
0xa027, // 18: mov x, osr
43+
0x80a0, // 19: pull block
44+
0xa047, // 20: mov y, osr
45+
0xb0e1, // 21: mov osr, x side 0
46+
0x7009, // 22: out pins, 9 side 0
47+
0xb842, // 23: nop side 1
48+
0x7001, // 24: out pins, 1 side 0
49+
0x18f8, // 25: jmp !osre, 24 side 1
50+
0x1095, // 26: jmp y--, 21 side 0
51+
// .wrap_target
52+
0x90a0, // 27: pull block side 0
53+
0x7009, // 28: out pins, 9 side 0
54+
0xb842, // 29: nop side 1
55+
0x7001, // 30: out pins, 1 side 0
56+
0x18fe, // 31: jmp !osre, 30 side 1
57+
// .wrap
58+
};
59+
60+
#if !PICO_NO_HARDWARE
61+
static const struct pio_program tft_io_program = {
62+
.instructions = tft_io_program_instructions,
63+
.length = 32,
64+
.origin = -1,
65+
};
66+
67+
static inline pio_sm_config tft_io_program_get_default_config(uint offset) {
68+
pio_sm_config c = pio_get_default_sm_config();
69+
sm_config_set_wrap(&c, offset + tft_io_wrap_target, offset + tft_io_wrap);
70+
sm_config_set_sideset(&c, 2, true, false);
71+
return c;
72+
}
73+
#endif

TFT_Drivers/ILI9341_Defines.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Change the width and height if required (defined in portrait mode)
22
// or use the constructor to over-ride defaults
33

4-
#if defined (ILI9341_DRIVER) || ILI9341_2_DRIVER
4+
#if defined (ILI9341_DRIVER) || defined (ILI9341_2_DRIVER)
55
#define TFT_WIDTH 240
66
#define TFT_HEIGHT 320
77
#elif defined (ILI9342_DRIVER)

TFT_Drivers/ILI9341_Init.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//
66
// See ST7735_Setup.h file for an alternative format
77

8-
#if defined (ILI9341_DRIVER) | defined (ILI9342_DRIVER)
8+
#if defined (ILI9341_DRIVER) || defined (ILI9342_DRIVER)
99
{
1010
writecommand(0xEF);
1111
writedata(0x03);

TFT_eSPI.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#ifndef _TFT_eSPIH_
1717
#define _TFT_eSPIH_
1818

19-
#define TFT_ESPI_VERSION "2.4.44"
19+
#define TFT_ESPI_VERSION "2.4.45"
2020

2121
// Bit level feature flags
2222
// Bit 0 set: viewport capability

keywords.txt

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,42 +12,41 @@ drawFastHLine KEYWORD2
1212
fillRect KEYWORD2
1313
height KEYWORD2
1414
width KEYWORD2
15+
readPixel KEYWORD2
16+
setWindow KEYWORD2
17+
pushColor KEYWORD2
18+
1519
setRotation KEYWORD2
1620
getRotation KEYWORD2
1721
invertDisplay KEYWORD2
1822
setAddrWindow KEYWORD2
19-
setWindow KEYWORD2
2023

2124
setViewport KEYWORD2
25+
checkViewport KEYWORD2
2226
resetViewport KEYWORD2
2327
getViewportX KEYWORD2
2428
getViewportY KEYWORD2
2529
getViewportWidth KEYWORD2
2630
getViewportHeight KEYWORD2
2731
getViewportDatum KEYWORD2
2832
frameViewport KEYWORD2
29-
30-
# Smooth (anti-aliased) graphics functions
31-
fillRectHGradient KEYWORD2
32-
fillRectVGradient KEYWORD2
33-
fillSmoothCircle KEYWORD2
34-
fillSmoothRoundRect KEYWORD2
35-
drawSpot KEYWORD2
36-
drawWideLine KEYWORD2
37-
drawWedgeLine KEYWORD2
38-
39-
pushColor KEYWORD2
33+
resetViewport KEYWORD2
34+
clipAddrWindow KEYWORD2
35+
clipWindow KEYWORD2
4036
pushColors KEYWORD2
4137
pushBlock KEYWORD2
4238
pushPixels KEYWORD2
43-
readPixel KEYWORD2
39+
4440
tft_Read_8 KEYWORD2
4541
begin_SDA_Read KEYWORD2
4642
end_SDA_Read KEYWORD2
43+
4744
fillScreen KEYWORD2
45+
4846
drawRect KEYWORD2
4947
drawRoundRect KEYWORD2
5048
fillRoundRect KEYWORD2
49+
5150
drawCircle KEYWORD2
5251
drawCircleHelper KEYWORD2
5352
fillCircle KEYWORD2
@@ -56,22 +55,28 @@ drawEllipse KEYWORD2
5655
fillEllipse KEYWORD2
5756
drawTriangle KEYWORD2
5857
fillTriangle KEYWORD2
58+
5959
setSwapBytes KEYWORD2
6060
getSwapBytes KEYWORD2
61+
6162
drawBitmap KEYWORD2
6263
drawXBitmap KEYWORD2
64+
6365
setPivot KEYWORD2
6466
getPivotX KEYWORD2
6567
getPivotY KEYWORD2
68+
6669
readRect KEYWORD2
6770
pushRect KEYWORD2
6871
pushImage KEYWORD2
6972
readRectRGB KEYWORD2
73+
7074
drawNumber KEYWORD2
7175
drawFloat KEYWORD2
7276
drawString KEYWORD2
7377
drawCentreString KEYWORD2
7478
drawRightString KEYWORD2
79+
7580
setCursor KEYWORD2
7681
getCursorX KEYWORD2
7782
getCursorY KEYWORD2
@@ -90,29 +95,35 @@ decodeUTF8 KEYWORD2
9095
write KEYWORD2
9196
setCallback KEYWORD2
9297
fontsLoaded KEYWORD2
98+
9399
spiwrite KEYWORD2
94100
writecommand KEYWORD2
101+
writeRegister KEYWORD2
95102
writedata KEYWORD2
96103
commandList KEYWORD2
97104
readcommand8 KEYWORD2
98105
readcommand16 KEYWORD2
99106
readcommand32 KEYWORD2
107+
100108
color565 KEYWORD2
101109
color8to16 KEYWORD2
102110
color16to8 KEYWORD2
103111
color16to24 KEYWORD2
104112
color24to16 KEYWORD2
105113
alphaBlend KEYWORD2
106114
alphaBlend24 KEYWORD2
115+
107116
initDMA KEYWORD2
108117
deInitDMA KEYWORD2
109118
pushImageDMA KEYWORD2
110119
pushPixelsDMA KEYWORD2
111120
dmaBusy KEYWORD2
112121
dmaWait KEYWORD2
122+
113123
startWrite KEYWORD2
114124
writeColor KEYWORD2
115125
endWrite KEYWORD2
126+
116127
setAttribute KEYWORD2
117128
getAttribute KEYWORD2
118129
getSetup KEYWORD2
@@ -128,6 +139,14 @@ getTouch KEYWORD2
128139
calibrateTouch KEYWORD2
129140
setTouch KEYWORD2
130141

142+
# Smooth (anti-aliased) graphics functions
143+
fillRectHGradient KEYWORD2
144+
fillRectVGradient KEYWORD2
145+
fillSmoothCircle KEYWORD2
146+
fillSmoothRoundRect KEYWORD2
147+
drawSpot KEYWORD2
148+
drawWideLine KEYWORD2
149+
drawWedgeLine KEYWORD2
131150

132151
# Smooth font functions
133152

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "TFT_eSPI",
3-
"version": "2.4.44",
3+
"version": "2.4.45",
44
"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",
55
"description": "A TFT and ePaper SPI graphics library with optimisation for Raspberry Pi Pico, RP2040, ESP8266, ESP32 and STM32",
66
"repository":

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=TFT_eSPI
2-
version=2.4.44
2+
version=2.4.45
33
author=Bodmer
44
maintainer=Bodmer
55
sentence=TFT graphics library for Arduino processors with performance optimisation for RP2040, STM32, ESP8266 and ESP32

license.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,16 @@ sketch.
9696

9797
In 2019 the library was adapted to be able to use it with any 32 bit Arduino
9898
compatible processor. It will run on 8 bit and 16 bit processors but will be
99-
slow due to extensive use of 32 bit varaibles.
99+
slow due to extensive use of 32 bit variables.
100100

101-
Many of the example sketches are original work, that contain code created
101+
Many of the example sketches are original work that contain code created
102102
for my own projects. For all the original code the FreeBSD licence applies
103103
and is compatible with the GNU GPL.
104104

105105
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvStartvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
106106
Software License Agreement (FreeBSD License)
107107

108-
Copyright (c) 2020 Bodmer (https://github.com/Bodmer)
108+
Copyright (c) 2022 Bodmer (https://github.com/Bodmer)
109109

110110
All rights reserved.
111111

0 commit comments

Comments
 (0)