方言を話すおしゃべり猫型ロボット『ミーア』をリリースしました(こちらをクリック)

[ST7735] Guide to solving drawing problems on TFT LCDs: how to set Green Tab.

This article can be read in about 11 minutes.

Introduction

We are currently developing a talking cat robot called “Mia”.

Mia
The talking cat-shaped robot Mia shares sadness and joy with more than 100 different rich expressions. It also speaks in...

Mia’s Characteristics Various Dialects and Personalities Mia speaks in various dialects and personalities. Personality Standard Sarcasm Meddlesome Romantic Natural Dialect Osaka dialect Hakata dialect Kagoshima dialect Hiroshima dialect Tsugaru dialect: coming soon Kyoto dialect: coming soon More than 100 types.

I am using the ST7735s LCD to draw the eyes, but an error has occurred where some pixels at the bottom right of the screen are not drawn, so I am trying to resolve it. This article describes the drawing problems encountered with the ST7735 TFT LCD display and their solutions.

In addition, we are using ST7735s 1.44 inch, and Bodmer’s TFT_eSPI library is being used as the eye drawing code. I am connecting an SP32-based self-made board and an ST7735.

GitHub - 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
Arduino and PlatformIO IDE compatible TFT library optimised for the Raspberry Pi Pico (RP2040), STM32, ESP8266 and ESP32...

Is it a software issue?

At first, I thought it was a problem with the software that draws the eyes, so I checked the relevant code.

In platformio.ini, the TFT_eSPI library is set for ST7735, and HEIGHT and WIDTH are also set to 128px.

C++
// platformio.ini
; TFT_eSPI library configured for ST7735
build_flags =
  -DUSER_SETUP_LOADED=1
  -DST7735_DRIVER=1
  -DTFT_WIDTH=128
  -DTFT_HEIGHT=128

Also, in the eye drawing code, we use tft.pushImage and specify that IMG_HEIGHT and IMG_WIDTH use 128px to fill the display, so there seems to be no problem.

C++
// src/eye.cpp
<strong>#</strong>define IMG_WIDTH 128
<strong>#</strong>define IMG_HEIGHT 128

//  静止画
void displayStaticEyeImage(const uint8_t *eyeImage, const uint8_t *eyeImage2) {
  Serial.println("Static Image");
  for (uint8_t e = 0; e < NUM_EYES; e++) {
    digitalWrite(eye[e].tft_cs, LOW);
    tft.startWrite();
    if (e == 0 || eyeImage2 == nullptr) {
      tft.pushImage(eye[e].xposition, 0, IMG_WIDTH, IMG_HEIGHT, eyeImage, true, NULL);
    } else {
      tft.pushImage(eye[e].xposition, 0, IMG_WIDTH, IMG_HEIGHT, eyeImage2, true, NULL);
    }
    tft.endWrite();
    digitalWrite(eye[e].tft_cs, HIGH);
  }
}

Complete the screen redraw test using tft.fillScreen function

In order to determine if it’s a software or hardware problem, I use a tft.fillScreen function to fill the entire screen with a single color and see if all pixels are drawn properly.

Insert test code inside the loop() function.

C++
// src/main.cpp
void loop() {
	TFT_eSPI tft;
  // Test code to show test colours on the display.
  tft.fillScreen(TFT_BLUE); 
  delay(5000); // Keep the screen in that colour for 5 seconds.
  // Original code thereafter.
  ...
}

When I built it, the error was not resolved. So I guess it’s a hardware (ST7735) issue.

Set green tab on ST7735?

While googling, I found someone who had a similar problem.

ST7735 1.44" 128x128 weird results · Issue #507 · Bodmer/TFT_eSPI
I got this ST7735 working nicely with Adafruit's library. Using TFT_eSPI produces weird results using the examples with ...

What is Green Tab? Model number? I looked at the AliExpress site where I purchased it, but there was nothing specifically mentioned about it.

Tft-カラースクリーン付きLCDモジュール,0.96/1.3/1.44/1.8/2.4インチ,2.8/3.5インチ,防水 - AliExpress 502
Smarter Shopping, Better Living! Aliexpress.com

When I checked the delivered product, I found something that looked like a green sticky note next to the protective cover of the display. This seems to be what Tab refers to.

Although ST7735 displays use the same basic chip, there are many variations due to small differences in specifications depending on different manufacturers and production batches. These differences are due to differences in internal settings such as the actual displayable area, pixel arrangement, and offset during the manufacturing of the display module. Tabs such as “Green Tab,” “Red Tab,” and “Black Tab” are colored tabs on the edge of a display’s flexible printed circuit (FPC) that identify different models and versions.

For example, there are multiple versions of “Green Tab” (e.g. GREENTAB, GREENTAB2, GREENTAB3), each with a different name for the following reasons:

  • Manufacture date: Tabs of the same color may have small differences because they were manufactured at different times or come from different production lines.
  • Display settings: Even if the tab colors are the same, the initialization code burned into the internal ROM, active pixel area, offset, color order (RGB or BGR), display orientation, etc. may be different.
  • Compatibility: Some displays are specifically optimized with certain main chips or libraries and require separate settings accordingly.

I see, the Green tab is further subdivided into multiple versions, so it is necessary to configure it.

Bodmer’s TFT_eSPI library recommends that user-specific settings, such as the type of LCD display being used, be written in the User_Setup.h file, but this time the User_Setup.h file itself has been deleted, and the unique settings is consolidated in platformio.ini, so add “-DST7735_GREENTAB” to build_flags in platformio.ini and build.

TFT_eSPI/User_Setup.h at master · Bodmer/TFT_eSPI
Arduino and PlatformIO IDE compatible TFT library optimised for the Raspberry Pi Pico (RP2040), STM32, ESP8266 and ESP32...
C++
// platformio.ini
build_flags =
  -DUSER_SETUP_LOADED=1
  -DST7735_DRIVER=1
  -DTFT_WIDTH=128
  -DTFT_HEIGHT=128
  -DST7735_GREENTAB

oh!? Only the horizontal display was fixed and it became full screen.

Only the vertical display remains.

-No change even if DST7735_GREENTAB2 is set.

When it didn’t work, I set -DST7735_GREENTAB3…

C++
// platformio.ini
build_flags =
  -DUSER_SETUP_LOADED=1
  -DST7735_DRIVER=1
  -DTFT_WIDTH=128
  -DTFT_HEIGHT=128
  -DST7735_GREENTAB3

oh!! Eyes are now displayed on the entire ST7735s screen!

Stop saying that even though it’s the same LCD display module, the pixel arrangement and offset differ depending on the manufacturer! That’s what it feels like, but I’m glad I was able to resolve it.

The TFT library I use is Bodmer, so I wrote about Bodmer this time, but I think it could be done similarly for Adafruit. Someone encountered a similar error with Adafruit.

https://forum.arduino.cc/t/problem-with-1-8-128×160-tft-display/468416/3

コメント

Copied title and URL