Skip to content

Commit

Permalink
Various updates - raise to version 2.4.43
Browse files Browse the repository at this point in the history
Sprite class uses TFT_eSPI setBitmapColor - fn deleted
Small performance improvement to RP2040 SPI PIO
Typo corrections
Correct (unused) tft_Write_32 for STM32
Update HX8357D rotation code
Enable software reset for ILI9486
Add preliminary RM68120 support
  • Loading branch information
Bodmer committed Mar 17, 2022
1 parent 3b63aa9 commit 8480f39
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 40 deletions.
12 changes: 0 additions & 12 deletions Extensions/Sprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,18 +335,6 @@ int8_t TFT_eSprite::getColorDepth(void)
}


/***************************************************************************************
** Function name: setBitmapColor
** Description: Set the 1bpp foreground foreground and background colour
***************************************************************************************/
void TFT_eSprite::setBitmapColor(uint16_t c, uint16_t b)
{
if (c == b) b = ~c;
_tft->bitmap_fg = c;
_tft->bitmap_bg = b;
}


/***************************************************************************************
** Function name: setPaletteColor
** Description: Set the 4bpp palette color at the given index
Expand Down
3 changes: 0 additions & 3 deletions Extensions/Sprite.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ class TFT_eSprite : public TFT_eSPI {
// Get the color at the given palette index
uint16_t getPaletteColor(uint8_t index);

// Set foreground and background colours for 1 bit per pixel Sprite
void setBitmapColor(uint16_t fg, uint16_t bg);

void drawPixel(int32_t x, int32_t y, uint32_t color);

void drawChar(int32_t x, int32_t y, uint16_t c, uint32_t color, uint32_t bg, uint8_t font),
Expand Down
6 changes: 3 additions & 3 deletions Processors/TFT_eSPI_ESP32.h
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ SPI3_HOST = 2
// Write 8 bits
#define tft_Write_8(C) TFT_WRITE_BITS((C)<<8, 16)

// Write 16 bits with corrected endianess for 16 bit colours
// Write 16 bits with corrected endianness for 16 bit colours
#define tft_Write_16(C) TFT_WRITE_BITS((C)<<8 | (C)>>8, 16)

// Future option for transfer without wait
Expand Down Expand Up @@ -513,7 +513,7 @@ SPI3_HOST = 2
// Write 8 bits
#define tft_Write_8(C) TFT_WRITE_BITS(C, 8)
// Write 16 bits with corrected endianess for 16 bit colours
// Write 16 bits with corrected endianness for 16 bit colours
#define tft_Write_16(C) TFT_WRITE_BITS((C)<<8 | (C)>>8, 16)
// Write 16 bits
Expand All @@ -537,7 +537,7 @@ SPI3_HOST = 2
// Write 8 bits
#define tft_Write_8(C) TFT_WRITE_BITS(C, 8)

// Write 16 bits with corrected endianess for 16 bit colours
// Write 16 bits with corrected endianness for 16 bit colours
#define tft_Write_16(C) TFT_WRITE_BITS((C)<<8 | (C)>>8, 16)

// Future option for transfer without wait
Expand Down
4 changes: 2 additions & 2 deletions Processors/TFT_eSPI_STM32.h
Original file line number Diff line number Diff line change
Expand Up @@ -1010,8 +1010,8 @@
HAL_SPI_Transmit(&spiHal, spiBuffer, 2, 10); }

#define tft_Write_32(C) \
{ spiBuffer[1] = ((C)>>24); spiBuffer[3] = ((C)>>16); spiBuffer[5] = ((C)>>8); spiBuffer[7] = C; \
HAL_SPI_Transmit(&spiHal, spiBuffer, 8, 10); }
{ spiBuffer[0] = (C)>>24; spiBuffer[1] = (C)>>16; spiBuffer[2] = (C)>>8; spiBuffer[3] = C; \
HAL_SPI_Transmit(&spiHal, spiBuffer, 4, 10); }

#define tft_Write_32C(C,D) \
{ spiBuffer[1] = ((C)>>8); spiBuffer[3] = (C); spiBuffer[5] = ((D)>>8); spiBuffer[7] = D; \
Expand Down
6 changes: 3 additions & 3 deletions Processors/pio_SPI.pio
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
public start_8:
// Pull the next 32 bit value from the TX FIFO.
pull side 0
// Lose the top 24 bits
out null, 24
// Lose the top 24 bits, send 1st bit
out pins, 25
// Now send remaining bits
jmp spi_out side 0
jmp spi_out side 1

public set_addr_window:
// Loop count in x for caset, paset and ramwr
Expand Down
4 changes: 2 additions & 2 deletions Processors/pio_SPI.pio.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

static const uint16_t tft_io_program_instructions[] = {
0x90a0, // 0: pull block side 0
0x6078, // 1: out null, 24
0x101e, // 2: jmp 30 side 0
0x6019, // 1: out pins, 25
0x181e, // 2: jmp 30 side 1
0xf022, // 3: set x, 2 side 0
0xe000, // 4: set pins, 0
0x90a0, // 5: pull block side 0
Expand Down
16 changes: 8 additions & 8 deletions TFT_Drivers/HX8357D_Rotation.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
switch (rotation) {
case 0: // Portrait
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
_width = TFT_WIDTH;
_height = TFT_HEIGHT;
_width = _init_width;
_height = _init_height;
break;
case 1: // Landscape (Portrait + 90)
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
_width = TFT_HEIGHT;
_height = TFT_WIDTH;
_width = _init_height;
_height = _init_width;
break;
case 2: // Inverter portrait
writedata(TFT_MAD_COLOR_ORDER);
_width = TFT_WIDTH;
_height = TFT_HEIGHT;
_width = _init_width;
_height = _init_height;
break;
case 3: // Inverted landscape
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
_width = TFT_HEIGHT;
_height = TFT_WIDTH;
_width = _init_height;
_height = _init_width;
break;
}
2 changes: 1 addition & 1 deletion TFT_Drivers/ILI9486_Init.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

writecommand(0x01); // SW reset
delay(120);

writecommand(0x11); // Sleep out, also SW reset
delay(120);

Expand Down
36 changes: 36 additions & 0 deletions TFT_eSPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,9 @@ void TFT_eSPI::init(uint8_t tc)
#elif defined (ILI9225_DRIVER)
#include "TFT_Drivers/ILI9225_Init.h"

#elif defined (RM68120_DRIVER)
#include "TFT_Drivers/RM68120_Init.h"

#endif

#ifdef TFT_INVERSION_ON
Expand Down Expand Up @@ -825,6 +828,9 @@ void TFT_eSPI::setRotation(uint8_t m)
#elif defined (ILI9225_DRIVER)
#include "TFT_Drivers/ILI9225_Rotation.h"

#elif defined (RM68120_DRIVER)
#include "TFT_Drivers/RM68120_Rotation.h"

#endif

delayMicroseconds(10);
Expand Down Expand Up @@ -889,6 +895,7 @@ void TFT_eSPI::spiwrite(uint8_t c)
** Function name: writecommand
** Description: Send an 8 bit command to the TFT
***************************************************************************************/
#ifndef RM68120_DRIVER
void TFT_eSPI::writecommand(uint8_t c)
{
begin_tft_write();
Expand All @@ -902,7 +909,36 @@ void TFT_eSPI::writecommand(uint8_t c)
end_tft_write();

}
#else
void TFT_eSPI::writecommand(uint16_t c)
{
begin_tft_write();

DC_C;

tft_Write_16(c);

DC_D;

end_tft_write();

}
void TFT_eSPI::writeRegister(uint16_t c, uint8_t d)
{
begin_tft_write();

DC_C;

tft_Write_16(c);

DC_D;

tft_Write_8(d);

end_tft_write();

}
#endif

/***************************************************************************************
** Function name: writedata
Expand Down
12 changes: 8 additions & 4 deletions TFT_eSPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#ifndef _TFT_eSPIH_
#define _TFT_eSPIH_

#define TFT_ESPI_VERSION "2.4.42"
#define TFT_ESPI_VERSION "2.4.43"

// Bit level feature flags
// Bit 0 set: viewport capability
Expand Down Expand Up @@ -620,9 +620,13 @@ class TFT_eSPI : public Print { friend class TFT_eSprite; // Sprite class has ac

// Low level read/write
void spiwrite(uint8_t); // legacy support only

void writecommand(uint8_t c), // Send a command, function resets DC/RS high ready for data
writedata(uint8_t d); // Send data with DC/RS set high
#ifndef RM68120_DRIVER
void writecommand(uint8_t c); // Send a command, function resets DC/RS high ready for data
#else
void writecommand(uint16_t c); // Send a command, function resets DC/RS high ready for data
void writeRegister(uint16_t c, uint8_t d); // Write data to 16 bit command register
#endif
void writedata(uint8_t d); // Send data with DC/RS set high

void commandList(const uint8_t *addr); // Send a initialisation sequence to TFT stored in FLASH

Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "TFT_eSPI",
"version": "2.4.42",
"version": "2.4.43",
"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":
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=TFT_eSPI
version=2.4.42
version=2.4.43
author=Bodmer
maintainer=Bodmer
sentence=TFT graphics library for Arduino processors with performance optimisation for RP2040, STM32, ESP8266 and ESP32
Expand Down

0 comments on commit 8480f39

Please sign in to comment.