Are these the pins you are trying to use on Teensy 4.1?
View attachment 37108
Pins 21 and 22 are not SPI pins,
SPI pins are 11-13
SPI1 pins are by default: 26, 27, 1, but there are a few alternative pins for some of the functions like pin 39
The change to correct default pins surely helped, thank you!
BUT...
- Only the right 1/4 of the display gets updated, the rest is pixel noise
- its difficult to get any text visible on the display at all. When it once succeeded me, it was vertical instead of horisontal - but the change of orientation, i tried all from 0- to even 4, didnt solve anything, onlymaybe maiking it wors with several divided areas on the screen and black/white pixel stribes at the right.
- When I briefly saw a small part of the text vertical, it was with white color! - Even my command was setting it to BLACK color
- I have tried some setAddrWindow() settings, which seemed like nothing changed anything.
- I have tried change 76 x 280 and opposite, but nothing changed.
- I once had some blue right side part on tft1 and yellow right side part on tft2, but now its like the displays are reset several like 3 times and removing the colors again
- so I have now build in 10 secs pauses between all important commands to try follow whats going on, when & why.
- But it feels like a mess and like the displays are updated or getting white at complete wrong commands.
- I have tried SPI_FREQUENCY settings form 10...-40... but it didnt seem to change anything.
Code:
#include <SPI.h>
#include <TFT_eSPI.h> // Correct library for ST7789P3
// TFT Setup with Correct CS Pins
#define TFT_CS1 24 // Chip Select for TFT 1
#define TFT_CS2 25 // Chip Select for TFT 2
#define TFT_RST 7 // Reset pin
#define TFT_DC 23 // Data/Command pin
#define TFT_MOSI 11 // Data pin
#define TFT_SCLK 13 // Clock pin
TFT_eSPI tft1 = TFT_eSPI(); // First TrackChannel TFT
TFT_eSPI tft2 = TFT_eSPI(); // Second TrackChannel TFT
void setup() {
Serial.begin(115200);
while (!Serial);
Serial.println("🔍 Before SPI.begin()");
SPI.begin();
Serial.println("🔍 After SPI.begin() - now 2 sec pause");
delay(10000);
Serial.println("🔍 Before pinMode(TFT_CS1, OUTPUT)");
pinMode(TFT_CS1, OUTPUT);
Serial.println("🔍 After pinMode");
Serial.println("🔍 Before init");
tft1.init();
Serial.println("🔍 After init - now 2 sec pause");
delay(10000);
Serial.println("🔍 Before digitalWrite(TFT_CS1, HIGH)");
digitalWrite(TFT_CS1, HIGH);
Serial.println("🔍 After digitalWrite(TFT_CS1, HIGH) - now 2 sec pause");
delay(10000);
Serial.println("🔍 Before startWrite()");
tft1.startWrite();
Serial.println("🔍 After startWrite() - no2 2 sec pause");
delay(10000);
Serial.println("🔍 Before tft1.writecommand(TFT_SWRST)");
tft1.writecommand(TFT_SWRST); // Send Software Reset Command
Serial.println("🔍 After tft1.writecommand(TFT_SWRST)");
tft1.setCursor(0, 0); // Restore previous text position
tft1.setTextColor(TFT_BLACK, TFT_WHITE);
tft1.setTextSize(2);
tft1.setRotation(0); // Restored previous rotation
Serial.println("🔍 Now 2 sec pause");
delay(10000);
Serial.println("🔍 Before tft1.fillScreen(TFT_BLUE)");
tft1.fillScreen(TFT_BLUE); // Restore whole screen yellow
Serial.println("🔍 After tft1.fillScreen(TFT_BLUE) - now 2 sec pause");
delay(10000);
Serial.println("🔍 Before print(1234567890)");
tft1.print("1234567890");
Serial.println("🔍 After print(1234567890) - now 2 sec pause");
delay(10000);
Serial.println("🔍 Before endWrite()");
tft1.endWrite();
Serial.println("🔍 After endWrite() - now 2 sec pause");
delay(10000);
Serial.println("🔍 Before digitalWrite(TFT_CS1, LOW)");
digitalWrite(TFT_CS1, LOW);
Serial.println("🔍 After digitalWrite(TFT_CS1, LOW) - now 2 sec pause");
delay(10000);
Serial.println("🔍 Before SPI.begin()");
SPI.begin();
Serial.println("🔍 After SPI.begin() - now 2 sec pause");
delay(10000);
Serial.println("🔍 Before pinMode(TFT_CS2, OUTPUT)");
pinMode(TFT_CS2, OUTPUT);
Serial.println("🔍 After pinMode");
Serial.println("🔍 Before tft2.init()");
tft2.init();
Serial.println("🔍 After init - now 2 sec pause");
delay(10000);
Serial.println("🔍 Before digitalWrite(TFT_CS2, HIGH)");
digitalWrite(TFT_CS2, HIGH);
Serial.println("🔍 After digitalWrite(TFT_CS2, HIGH) - now 2 sec pause");
delay(10000);
Serial.println("🔍 Before startWrite()");
tft2.startWrite();
Serial.println("🔍 After startWrite() - no2 2 sec pause");
delay(10000);
Serial.println("🔍 Before tft2.writecommand(TFT_SWRST)");
tft2.writecommand(TFT_SWRST); // Send Software Reset Command
Serial.println("🔍 After tft2.writecommand(TFT_SWRST)");
tft2.setCursor(0, 0); // Restore previous text position
tft2.setTextColor(TFT_BLACK, TFT_WHITE);
tft2.setTextSize(2);
tft2.setRotation(0); // Restored previous rotation
Serial.println("🔍 Now 2 sec pause");
delay(10000);
Serial.println("🔍 Before tft2.fillScreen(TFT_YELLOW)");
tft2.fillScreen(TFT_YELLOW); // Restore whole screen yellow
Serial.println("🔍 Before tft2.fillScreen(TFT_BLUE) - now 2 sec pause");
delay(10000);
Serial.println("🔍 Before print(1234567890)");
tft2.print("1234567890");
Serial.println("🔍 After print(1234567890) - now 2 sec pause");
delay(10000);
Serial.println("🔍 Before endWrite()");
tft2.endWrite();
Serial.println("🔍 Before endWrite() - now 2 sec pause");
delay(10000);
Serial.println("🔍 Before digitalWrite(TFT_CS2, LOW)");
digitalWrite(TFT_CS2, LOW);
Serial.println("🔍 After digitalWrite(TFT_CS2, LOW) - now 2 sec pause");
delay(10000);
//tft1.setAddrWindow(0-10, 0-10, 280, 76);
}
void loop() {
}
What I have in the User_setup.h:
Code:
#define USER_SETUP_INFO "User_Setup"
//MY CODE
#define ST7789_DRIVER
//MY CODE
#define TFT_WIDTH 76
#define TFT_HEIGHT 280
//MY CODE
// SPI Pins - Match Our Wiring
#define TFT_CS 24
#define TFT_RST 7
#define TFT_DC 23
#define TFT_MOSI 11
#define TFT_SCLK 13
#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_FONT8N // Font 8. Alternative to Font 8 above, slightly narrower, so 3 digits fit a 160 pixel TFT
#define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts
// Comment out the #define below to stop the SPIFFS filing system and smooth font code being loaded
// this will save ~20kbytes of FLASH
#define SMOOTH_FONT
// #define SPI_FREQUENCY 1000000
// #define SPI_FREQUENCY 5000000
// #define SPI_FREQUENCY 10000000
#define SPI_FREQUENCY 20000000
// #define SPI_FREQUENCY 27000000
// #define SPI_FREQUENCY 40000000
// #define SPI_FREQUENCY 55000000 // STM32 SPI1 only (SPI2 maximum is 27MHz)
// #define SPI_FREQUENCY 80000000
// Optional reduced SPI frequency for reading TFT
#define SPI_READ_FREQUENCY 20000000
// The XPT2046 requires a lower SPI clock rate of 2.5MHz so we define that here:
#define SPI_TOUCH_FREQUENCY 2500000
//MY CODE
#define TOUCH_CS -1 // No touch support
#define CGRAM_OFFSET
What I have experienced this if I tried other orientations than 1, e.g. 0,2,3 and 4: The color got splitted up and right side got filled with stribes:
and only right side color and the other display white, if I have orientation 1:
The code I uploaded now is actually resulting in this, where tft1 is white and tft2 is mess pixels and only right side has yellow:
(but with the many 10 secs pauses in the code I could see that both displays gets correct color, it just disappears again for tft1!)
I dont have snapshot of the testcase where I got partial vertical text inside the yellow area.
So...
A) How do I get the color to fill the whole display?
B) How do I get correct orientation (when it seems like the orientation params doesnt change anything!?
C) How do I get black text, when it supposed to!?
D) How do I get rid of the 3 updates of the displays which color, clears, colors, clears only one screen? I actually put the writecommand(TFT_SWRST) in to SOLVE the problem with old dirt & updates on the screen from each time till next time, so I clean up old garbage content, so I want to keep that one! as none of the other commands seemed to do that.
E) What is the correct order of all these TFT commands?
F) Is it the driver which are not working with this display? If yes, can You recommend another where I can get better result?