Hi Guys.
Hardware: ESP32 with 4.0" TFT (with touch but not used). ST7796
Using TFT_eSPI Library
My setting:
// For ST7796 Setting_Matt//
#define TFT_MISO 16
#define TFT_MOSI 23
#define TFT_SCLK 18
#define TFT_CS 15 // Chip select control pin
#define TFT_DC 2 // Data Command control pin
#define TFT_RST 4 // Reset pin (could connect to RST pin)
#define SPI_FREQUENCY 40000000
#define SPI_READ_FREQUENCY 15000000
I'm just trying to read a pixel and then put a filled rectangle on the display.
I came to the #define SPI_READ_FREQUENCY 15000000
by just messing about with frequency until the serial output had constant 0x07E0 output.
However, I need a delay(2);
after the tft.readPixel();
Anything smaller than 2ms delay and I just get a green screen. It appears to run through the code as a get an output on the serial monitor, but never changes to a black screen with my filled rectangle.
Could it be my display not capable? I don't really understand.
If I use a read frequency higher than 15MHz then the colour is wrong.
This is not the real code that I want, but I'm just trying to understand how to use the function.
Having delays in the code is not an option, so I can't implement it like this.
Any assistance more than welcome.
Here's the code I'm using for test:
#include <SPI.h>
#include <TFT_eSPI.h>
uint16_t x;
TFT_eSPI tft = TFT_eSPI();
void setup() {
Serial.begin(115200);
tft.init();
}
void loop() {
tft.fillScreen(TFT_GREEN);
x = tft.readPixel(100, 100);
// delay(1); // This delay of 1ms does not work. If I remove delay completely it doesn't work. I just get a green screen
delay(2); // This works.
tft.fillScreen(TFT_BLACK);
tft.fillRect(100, 100, 100, 100, x);
delay(1000);
}
Thanks in advance for any help.
Cheers,
Matt