From 65ccbf01393c51e99df0023839c3db337ef32ce6 Mon Sep 17 00:00:00 2001 From: Bodmer Date: Mon, 2 Mar 2020 22:25:39 +0000 Subject: [PATCH] STM32 update Boost performance for ILI9488 display with STM32 processors. Enable smooth fonts in setup files (smooth fonts for STM32 processors is now supported with fonts in program memory) --- Processors/TFT_eSPI_STM32.c | 35 +++++++++++--- TFT_eSPI.h | 2 +- User_Setups/Setup29_ILI9341_STM32.h | 5 +- User_Setups/Setup30_ILI9341_Parallel_STM32.h | 3 +- User_Setups/Setup31_ST7796_Parallel_STM32.h | 5 +- User_Setups/Setup32_ILI9341_STM32F103.h | 9 ++-- User_Setups/Setup33_RPi_ILI9486_STM32.h | 7 ++- User_Setups/Setup34_ILI9481_Parallel_STM32.h | 51 ++++++++++++++++++++ library.json | 2 +- library.properties | 2 +- 10 files changed, 94 insertions(+), 27 deletions(-) create mode 100644 User_Setups/Setup34_ILI9481_Parallel_STM32.h diff --git a/Processors/TFT_eSPI_STM32.c b/Processors/TFT_eSPI_STM32.c index 3923f93..80a9a82 100644 --- a/Processors/TFT_eSPI_STM32.c +++ b/Processors/TFT_eSPI_STM32.c @@ -221,17 +221,38 @@ void TFT_eSPI::pushPixels(const void* data_in, uint32_t len) ** Function name: pushBlock - for STM32 and 3 byte RGB display ** Description: Write a block of pixels of the same colour ***************************************************************************************/ +#define BUF_SIZE 240*3 void TFT_eSPI::pushBlock(uint16_t color, uint32_t len) { - // Split out the colours - spiBuffer[0] = (color & 0xF800)>>8; // Red - spiBuffer[1] = (color & 0x07E0)>>3; // Green - spiBuffer[2] = (color & 0x001F)<<3; // Blue + uint8_t col[BUF_SIZE]; + // Always using swapped bytes is a peculiarity of this function... + //color = color>>8 | color<<8; + uint8_t r = (color & 0xF800)>>8; // Red + uint8_t g = (color & 0x07E0)>>3; // Green + uint8_t b = (color & 0x001F)<<3; // Blue - while (len--) HAL_SPI_Transmit(&spiHal, spiBuffer, 3, HAL_MAX_DELAY); + if (len=BUF_SIZE/3 ) ; + // Send remaining pixels + if (len) HAL_SPI_Transmit(&spiHal, col, len*3, HAL_MAX_DELAY); //*/ } - - /*************************************************************************************** ** Function name: pushPixels - for STM32 and 3 byte RGB display ** Description: Write a sequence of pixels diff --git a/TFT_eSPI.h b/TFT_eSPI.h index 6fc7e9b..3d54ddc 100644 --- a/TFT_eSPI.h +++ b/TFT_eSPI.h @@ -16,7 +16,7 @@ #ifndef _TFT_eSPIH_ #define _TFT_eSPIH_ -#define TFT_ESPI_VERSION "2.1.4" +#define TFT_ESPI_VERSION "2.1.5" /*************************************************************************************** ** Section 1: Load required header files diff --git a/User_Setups/Setup29_ILI9341_STM32.h b/User_Setups/Setup29_ILI9341_STM32.h index c2bfcfd..0a8dc82 100644 --- a/User_Setups/Setup29_ILI9341_STM32.h +++ b/User_Setups/Setup29_ILI9341_STM32.h @@ -49,9 +49,8 @@ #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts -// At the moment SMOOTH fonts must be disabled for STM32 processors (due to lack of SPIFFS) -// Support for smooth fonts via SD cards is planned. -//#define SMOOTH_FONT // Must be commented out for STM32 +// STM32 support for smooth fonts via program memory (FLASH) arrays +#define SMOOTH_FONT // Nucleo-F767ZI has a ~216MHZ CPU clock, this is divided by 4, 8, 16 etc diff --git a/User_Setups/Setup30_ILI9341_Parallel_STM32.h b/User_Setups/Setup30_ILI9341_Parallel_STM32.h index bff3a31..fbf2847 100644 --- a/User_Setups/Setup30_ILI9341_Parallel_STM32.h +++ b/User_Setups/Setup30_ILI9341_Parallel_STM32.h @@ -47,6 +47,5 @@ #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts -// At the moment SMOOTH fonts must be disabled for STM32 processors (due to lack of SPIFFS) -// Support for smooth fonts via SD cards is planned. +// STM32 support for smooth fonts via program memory (FLASH) arrays #define SMOOTH_FONT diff --git a/User_Setups/Setup31_ST7796_Parallel_STM32.h b/User_Setups/Setup31_ST7796_Parallel_STM32.h index 7a8fc56..25675d4 100644 --- a/User_Setups/Setup31_ST7796_Parallel_STM32.h +++ b/User_Setups/Setup31_ST7796_Parallel_STM32.h @@ -48,6 +48,5 @@ #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts -// At the moment SMOOTH fonts must be disabled for STM32 processors (due to lack of SPIFFS) -// Support for smooth fonts via SD cards is planned. -//#define SMOOTH_FONT +// STM32 support for smooth fonts via program memory (FLASH) arrays +#define SMOOTH_FONT diff --git a/User_Setups/Setup32_ILI9341_STM32F103.h b/User_Setups/Setup32_ILI9341_STM32F103.h index c5f71e7..0be32f7 100644 --- a/User_Setups/Setup32_ILI9341_STM32F103.h +++ b/User_Setups/Setup32_ILI9341_STM32F103.h @@ -36,7 +36,7 @@ // T_DIN - connect to processor MOSI // T_CS - connect to processor pin specified by TOUCH_CS above // T_SCK - connect to processor SCK -//* + #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters @@ -44,10 +44,9 @@ #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:-. #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts -//*/ -// At the moment SMOOTH fonts MUST be disabled for STM32 processors (due to lack of SPIFFS) -// Support for smooth fonts via SD cards is planned. -//#define SMOOTH_FONT // Must be commented out for STM32 + +// STM32 support for smooth fonts via program memory (FLASH) arrays +#define SMOOTH_FONT // Assuming the processor clock is 72MHz: #define SPI_FREQUENCY 36000000 // 36MHz SPI clock diff --git a/User_Setups/Setup33_RPi_ILI9486_STM32.h b/User_Setups/Setup33_RPi_ILI9486_STM32.h index 7c69261..f7a7038 100644 --- a/User_Setups/Setup33_RPi_ILI9486_STM32.h +++ b/User_Setups/Setup33_RPi_ILI9486_STM32.h @@ -50,11 +50,10 @@ #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts -// At the moment SMOOTH fonts must be disabled for STM32 processors (due to lack of SPIFFS) -// Support for smooth fonts via SD cards is planned. -//#define SMOOTH_FONT // Must be commented out for STM32 +// STM32 support for smooth fonts via program memory (FLASH) arrays +#define SMOOTH_FONT + - // Nucleo-F767ZI has a ~216MHZ CPU clock, this is divided by 4, 8, 16 etc #define SPI_FREQUENCY 20000000 // 27MHz SPI clock diff --git a/User_Setups/Setup34_ILI9481_Parallel_STM32.h b/User_Setups/Setup34_ILI9481_Parallel_STM32.h new file mode 100644 index 0000000..74e4e19 --- /dev/null +++ b/User_Setups/Setup34_ILI9481_Parallel_STM32.h @@ -0,0 +1,51 @@ + //////////////////////////////////////////////////// + // Setup for Nucleo 64 or 144 and ILI9341 display // + //////////////////////////////////////////////////// + +// See SetupX_Template.h for all options available + +// Define STM32 to invoke optimised processor support +#define STM32 + +// Defining the board allows the library to optimise the performance +// for UNO compatible "MCUfriend" style shields +#define NUCLEO_64_TFT +//#define NUCLEO_144_TFT + +// Tell the library to use 8 bit parallel mode (otherwise SPI is assumed) +#define TFT_PARALLEL_8_BIT + +// Define the display driver chip type +//#define ILI9341_DRIVER +#define ILI9481_DRIVER + +// Define the Nucleo 64/144 pins used for the parallel interface TFT +// The pins can be changed here but these are the ones used by the +// common "MCUfriend" shields +#define TFT_CS A3 // Chip select control pin +#define TFT_DC A2 // Data Command control pin +#define TFT_RST A4 // Reset pin + +#define TFT_WR A1 // Write strobe control pin +#define TFT_RD A0 // Read pin + +#define TFT_D0 D8 // 8 bit parallel bus to TFT +#define TFT_D1 D9 +#define TFT_D2 D2 +#define TFT_D3 D3 +#define TFT_D4 D4 +#define TFT_D5 D5 +#define TFT_D6 D6 +#define TFT_D7 D7 + +// Fonts to be available +#define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH +#define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters +#define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters +#define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm +#define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:. +#define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. +#define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts + +// STM32 support for smooth fonts via program memory (FLASH) arrays +#define SMOOTH_FONT diff --git a/library.json b/library.json index 9525e30..a866c9e 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "TFT_eSPI", - "version": "2.1.4", + "version": "2.1.5", "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": diff --git a/library.properties b/library.properties index 49bf9c5..4bbe860 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=TFT_eSPI -version=2.1.4 +version=2.1.5 author=Bodmer maintainer=Bodmer sentence=TFT graphics library for Arduino processors with performance optimisation for STM32, ESP8266 and ESP32