Can't get TFT LCD Arduino Shield to work.

I have a 2.4 inch TFT LCD Arduino Shield with SD port from www.mcufriend.com. I have put it on an Arduino Uno clone. I use a iMac desktop with macOS v. 10.12.6. I have tried several sketches on it, and all of them will come back with the same error message; see below.

Arduino: 1.8.3 (Mac OS X), Board: "Arduino/Genuino Uno"

WARNING: Spurious .mystools folder in 'MySensors' library
WARNING: Category '' in library ST7775 Display Driver is not valid. Setting to 'Uncategorized'
/Users/danurbauer/Documents/Arduino/libraries/SWTFT/.cpp: In member function 'void SWTFT::drawLine3Byte(int16_t, int16_t, int16_t, int16_t, uint8_t, uint8_t, uint8_t)':
/Users/danurbauer/Documents/Arduino/libraries/SWTFT/.cpp:629:16: error: 'swap' was not declared in this scope
swap(x0, y0);
^
/Users/danurbauer/Documents/Arduino/libraries/SWTFT/.cpp:634:16: error: 'swap' was not declared in this scope
swap(x0, x1);
^
exit status 1
Error compiling for board Arduino/Genuino Uno.

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

And this is the sketch I was trying to run:

#include <Adafruit_GFX.h>    // Core graphics library 
#include <SWTFT.h> // Hardware-specific library 
char dataRx;
// Assign readable names to some common 16-bit color values:
#define    BLACK   0x0000
#define    BLUE    0x001F
#define    RED     0xF800
#define    GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF
SWTFT tft;
void setup(void) {
  Serial.begin(9600);
  Serial.println(F("Type character in Arduino Serial port"));
  delay(1000);
  tft.reset();
  uint16_t identifier = tft.readID();

  tft.begin(identifier);
  tft.fillScreen(BLACK);
  Serial.println(F("This is a serial data send Test!"));
  Serial.println(F("Type character in Arduino serial port & press <SEND> "));
}
void loop(void) {

  while (!Serial.available());
  dataRx = Serial.read();
  tft.setTextColor(YELLOW);
  tft.setTextSize(2);
  tft.print(dataRx);

}

I’m a newbie to Arduino and C++, so I don’t have the skills yet to understand the error or how to fix it if it can be fixed. I need your help. Any help would be most appreciated.

Hi,
Shouldn't your while statement have its own { } brackets?

Also if you look in the library folder of the "Adafruit_GFX.h", you will find instructions on how to setup the library for your display.

The library is for many different TFT displays and it may need to be configured for yours.

Tom.. :slight_smile:

Shouldn't your while statement have its own { } brackets?

It looks like the code is waiting for serial input in that while so the trailing semicolon is the only code required to be executed until serial input becomes available.

It might make the program easier to understand if it was written using an if instead of a while and would be non blocking if/when that matters in a larger program.

void loop(void)
{
  if (Serial.available())
  {
    dataRx = Serial.read();
    tft.setTextColor(YELLOW);
    tft.setTextSize(2);
    tft.print(dataRx);
  }