I am using ESP32 Devkit, Arduino IDE, Arduino GFX library 1.30 and a TFT display with ST7789 driver. I want to achieve this:
#include <Arduino_GFX_Library.h> //this is not adafruit
#define TFT_SCK 18
#define TFT_MOSI 23
#define TFT_MISO 19
#define TFT_CS 22
#define TFT_DC 21
#define TFT_RESET 17
Arduino_ESP32SPI bus;
Arduino_ST7789 tft;
void draw_sth() {
tft.drawLine(0,0,200,200,0x8000);
}
void setup(){
bus = Arduino_ESP32SPI(TFT_DC, TFT_CS, TFT_SCK, TFT_MOSI, TFT_MISO);
tft = Arduino_ST7789(&bus, TFT_RESET);
tft.begin();
tft.fillScreen(BLACK);
draw_sth();
}
void loop() {
draw_sth();
delay(5000);
}
This raises
"sketch_nov05a:4:16: error: no matching function for call to 'Arduino_ST7789::Arduino_ST7789()'
** Arduino_ST7789 tft;"**
Then I can get it to compile by doing this, which is bad, but anyway:
#include <Arduino_GFX_Library.h>
#define TFT_SCK 18
#define TFT_MOSI 23
#define TFT_MISO 19
#define TFT_CS 22
#define TFT_DC 21
#define TFT_RESET 17
Arduino_ESP32SPI bus = Arduino_ESP32SPI(TFT_DC, TFT_CS, TFT_SCK, TFT_MOSI, TFT_MISO);
Arduino_ST7789 tft = Arduino_ST7789(&bus, TFT_RESET);
void draw_sth() {
tft.drawLine(0,0,200,200,0x8000);
}
void setup(){
Arduino_ESP32SPI bus = Arduino_ESP32SPI(TFT_DC, TFT_CS, TFT_SCK, TFT_MOSI, TFT_MISO);
tft = Arduino_ST7789(&bus, TFT_RESET);
tft.begin();
tft.fillScreen(BLACK);
draw_sth();
}
void loop() {
draw_sth();
delay(5000);
}
which then lets the display flicker when entering loop.
Any ideas what's wrong? Thank you.