TFT Display code not compiling

Here is my code:


/*
      This tests the TfT display
*/

#include <Elegoo_GFX.h>
#include <Elegoo_TFTLCD.h>
#include <TouchScreen.h>


#define TS_MINX 920
#define TS_MINY 120
#define TS_MAXX 150
#define TS_MAXY 940
#define YP A3                             // must be an analog pin, use "An" notation!
#define XM A2                             // must be an analog pin, use "An" notation!
#define YM 9                              // can be a digital pin
#define XP 8                              // can be a digital pin

TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);

// macros for color (16 bit)
#define BLACK   0x0000
#define BLUE    0x001F
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF

#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#define LCD_RESET A4

Elegoo_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_WR, LCD_RD, LCD_RESET);

void setup() {
  
  tft.reset();
  tft.begin(0x9341);
  tft.fillScreen(BLACK);
  tft.fillRect(0,0,240,160,GREEN);
  tft.fillRect(0,160,240,160,WHITE);
  tft.drewRect(0,0,240,160,WHITE);
  tft.drewRect(0,160,240,160,WHITE);
  tft.setTextColor(WHITE);
  tft.setTextSize(2);
  tft.setCursor(80, 80);
  tft.println("Turn ON");
  tft.setCursor(80, 240);
  tft.println("Turn OFF");
}

void loop() {
    
}

And here is the error message:

Arduino: 1.8.19 (Linux), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

Tft_Test:38:68: error: no matching function for call to 'Elegoo_TFTLCD::Elegoo_TFTLCD(const uint8_t&, const uint8_t&, const uint8_t&, const uint8_t&, const uint8_t&, const uint8_t&)'
Elegoo_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_WR, LCD_RD, LCD_RESET);
^
And here is the error message:

Arduino: 1.8.19 (Linux), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

Tft_Test:38:68: error: no matching function for call to 'Elegoo_TFTLCD::Elegoo_TFTLCD(const uint8_t&, const uint8_t&, const uint8_t&, const uint8_t&, const uint8_t&, const uint8_t&)'
Elegoo_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_WR, LCD_RD, LCD_RESET);
^
In file included from /home/fanele24/Arduino/Tft_Test/Tft_Test.ino:7:0:
/home/fanele24/Arduino/libraries/Elegoo_TFTLCD/Elegoo_TFTLCD.h:27:3: note: candidate: Elegoo_TFTLCD::Elegoo_TFTLCD()
Elegoo_TFTLCD(void);
^~~~~~~~~~~~~
/home/fanele24/Arduino/libraries/Elegoo_TFTLCD/Elegoo_TFTLCD.h:27:3: note: candidate expects 0 arguments, 6 provided
/home/fanele24/Arduino/libraries/Elegoo_TFTLCD/Elegoo_TFTLCD.h:26:3: note: candidate: Elegoo_TFTLCD::Elegoo_TFTLCD(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)
Elegoo_TFTLCD(uint8_t cs, uint8_t cd, uint8_t wr, uint8_t rd, uint8_t rst);
Multiple libraries were found for "TouchScreen.h"
^~~~~~~~~~~~~
Used: /home/fanele24/Arduino/libraries/TouchScreen
Not used: /home/fanele24/Arduino/libraries/Adafruit_TouchScreen
/home/fanele24/Arduino/libraries/Elegoo_TFTLCD/Elegoo_TFTLCD.h:26:3: note: candidate expects 5 arguments, 6 provided
/home/fanele24/Arduino/libraries/Elegoo_TFTLCD/Elegoo_TFTLCD.h:22:7: note: candidate: constexpr Elegoo_TFTLCD::Elegoo_TFTLCD(const Elegoo_TFTLCD&)
class Elegoo_TFTLCD : public Elegoo_GFX {
^~~~~~~~~~~~~
/home/fanele24/Arduino/libraries/Elegoo_TFTLCD/Elegoo_TFTLCD.h:22:7: note: candidate expects 1 argument, 6 provided
/home/fanele24/Arduino/libraries/Elegoo_TFTLCD/Elegoo_TFTLCD.h:22:7: note: candidate: constexpr Elegoo_TFTLCD::Elegoo_TFTLCD(Elegoo_TFTLCD&&)
/home/fanele24/Arduino/libraries/Elegoo_TFTLCD/Elegoo_TFTLCD.h:22:7: note: candidate expects 1 argument, 6 provided
/home/fanele24/Arduino/Tft_Test/Tft_Test.ino: In function 'void setup()':
Tft_Test:47:7: error: 'class Elegoo_TFTLCD' has no member named 'drewRect'; did you mean 'drawRect'?
tft.drewRect(0,0,240,160,WHITE);
^~~~~~~~
drawRect
Tft_Test:48:7: error: 'class Elegoo_TFTLCD' has no member named 'drewRect'; did you mean 'drawRect'?
tft.drewRect(0,160,240,160,WHITE);
^~~~~~~~
drawRect
exit status 1
no matching function for call to 'Elegoo_TFTLCD::Elegoo_TFTLCD(const uint8_t&, const uint8_t&, const uint8_t&, const uint8_t&, const uint8_t&, const uint8_t&)'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

I don't know why it keeps saying "no matching function for call to 'Elegoo_TFTLCD::Elegoo_TFTLCD(const uint8_t&, const uint8_t&, const uint8_t&, const uint8_t&, const uint8_t&, const uint8_t&)'"Preformatted text

That is a bit of a list, some are self explanatory

Tft_Test:47:7: error: 'class Elegoo_TFTLCD' has no member named 'drewRect'; did you mean 'drawRect'?

You have made a typo it should be 'drawRect'

about the other one, it expects 5 arguments (or 0 but let's say 5) and you have provided 6 of which 1 twice.
try :

Elegoo_TFTLCD tft(LCD_CS,  LCD_CD,  LCD_WR,  LCD_RD,  LCD_RESET);

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.