Bodmer / TFT_eSPI

Arduino and PlatformIO IDE compatible TFT library optimised for the Raspberry Pi Pico (RP2040), STM32, ESP8266 and ESP32 that supports different driver chips
Other
3.8k stars 1.09k forks source link

Doesn't work STM32F103 + ST7735 #3125

Open petrd opened 10 months ago

petrd commented 10 months ago

Display initialization does not work in this configuration. The problem is only in this HW configuration and in the TFT_eSPI library. Everything works when I using the Adafruit_ST7735 library. If I replace the STM32F103 with the RB2040, the display with the TFT_eSPI library also works.

Configuration: BluePill 32F103C8 + ST7735 0.96 SPI1, RST = PA2, DC = PA3, CS = PA4

SW: Arduino 1.8.19 STM32 MCU based board 2.7.1 TFT_eSPI 2.5.34

Setup:

#define STM32
#define ST7735_DRIVER
#define ST7735_GREENTAB160x80
#define TFT_WIDTH  80
#define TFT_HEIGHT 160
#define TFT_INVERSION_ON
#define TFT_SPI_PORT 1
#define TFT_RST       PA2 // PA2 ADC2 12
#define TFT_DC        PA3 // PA3 ADC3 13
#define TFT_CS        PA4 // NC PA4 ADC4 14 NSS1
#define TFT_MOSI      PA7 // PA7 ADC7 17 MOSI1 Data out

#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

// Assuming the processor clock is 72MHz:
//#define SPI_FREQUENCY  36000000   // 36MHz SPI clock
#define SPI_FREQUENCY  18000000   // 18MHz SPI clock
#define SPI_READ_FREQUENCY  12000000 // Reads need a slower SPI clock
#define SPI_TOUCH_FREQUENCY  2500000 // Must be very slow

Code:


#include <TFT_eSPI.h>       // Hardware-specific library

TFT_eSPI tft = TFT_eSPI();  // Invoke custom library

// Include the header files that contain the icons
#include "Alert.h"
#include "Close.h"
#include "Info.h"

long count = 0; // Loop count

void setup()
{
  Serial.begin(9600);
  tft.begin();
  tft.setRotation(1);   // landscape

  tft.fillScreen(TFT_BLUE);

  // Swap the colour byte order when rendering
  tft.setSwapBytes(true);
}

void loop()
{
  // Loop filling and clearing screen
  tft.pushImage(random(tft.width() -  infoWidth), random(tft.height() -  infoHeight),  infoWidth,  infoHeight, info);
  tft.pushImage(random(tft.width() - alertWidth), random(tft.height() - alertHeight), alertWidth, alertHeight, alert);
  tft.pushImage(random(tft.width() - closeWidth), random(tft.height() - closeHeight), alertWidth, closeHeight, closeX);

  // Clear screen after 100 x 3 = 300 icons drawn
  if (1000 == count++) {
    count = 1;
    tft.setRotation(2 * random(2)); // Rotate randomly to clear display left>right or right>left to reduce monotony!
    tft.fillScreen(TFT_BLACK);
    tft.setRotation(1);   delay(1000);
  }
   delay(250); Serial.print("Screen width: "); Serial.print(tft.width()); Serial.print(" height: "); Serial.println(tft.height());
}

Example is not useful none works.

Bodmer commented 9 months ago

Use STM32 MCU based board 2.6.0 or use the githun TFT_eSPI master copy version 2.5.43

It appears that breaking chages have been made to the latest STM32 board packages.

petrd commented 9 months ago

Combination STM32 MCU based board 2.7.1 + TFT_eSPI 2.5.43 nor a combination STM32 MCU based board 2.6.0 + TFT_eSPI 2.5.43 doesn't work. The result is the same. :-(