Clear Screen and 2.8TFT

Hello.

I have been searching around the internet for code to clear my screen inside a simple text sketch on my TFT 2.8 display.

I have searched high and low and only found ways to clear a LCD which is obviously completely different from the TFT… lcd.clear(); did not work even with the library loaded. ClearScreen(); has not worked at all for me even though I read different ways to type it out so it actually complies but when I run it the text from the screen does not clear.

I guess what I am asking is if there is a “command” within the TFT. library that I can use to clear the screen so I can write again? I was going to just re DigitalWrite all the text in black with no delay to cover it back up to black which would be like a fake clear screen but I said to myself there has to be an easier way.

I start my sketch with

#include <stdint.h>
#include <TouchScreen.h>
#include <TFT.h>
#include <TFT_Graphics.h>

void setup()
{

Tft.init();

after a bunch of digitalwrite code I want to clear it to write all over again
thank you

Links to the library are going to be necessary.

Im so sorry I should have known better.

http://www.seeedstudio.com/wiki/images/5/53/TFT_Touch_Shield_libraries.zip

thank you for your response :slight_smile:

Have you tried tft.ClearScreen(WHITE) or tft.ClearScreen(BLACK)?

I use:-

display.clearDisplay();   // clears the screen and buffer

error "'class TFT' has no member named 'ClearScreen'" when I try Tft.ClearScreen(BLACK)

display.clearDisplay(); // clears the screen and buffer gives me display is not declared in this scope... so this is probably my error now instead of the library error.... display.clearDisplay(); seems to be doing something but not yet

Have you tried running the examples in the library?

all the examples in the TFT run fine if you mean the "draw circles " "paint" etc they all work just fine.

I am trying to write a text sketch that runs from line 0 to 250 but then I need a wipe to start to write again on line 0.

I am guessing that within TFT library there is a "member" called display or clearDisplay but maybe I am not putting it in the rigth place? is this in void setup or loop because I tried both

I am also very new to this..

should I #include anything other than TFT.h, TFT_graphics.h, etc?

my sketch is very simple to give you an idea. I just want to clear it after it runs so I can go back to line 0 and write more

void setup()
{

Tft.init(); //init TFT library
Tft.drawString("SCAN INITAITED",0,0,2,RED);
delay(3000);
Tft.drawString("----------7657566470808106647",0,20,1,WHITE);
delay(2000);
Tft.drawString("==============476445070416616" ,0,30,1,WHITE);
delay(2000);
Tft.drawString("Possible Match " ,0,40,2, RED);
delay (4000);
Tft.drawString("----------------76466013131",0,60,1,WHITE);
delay(2000);
Tft.drawString("------------------267790997",0,70,1,WHITE);
delay (2000);
Tft.drawString("----------------------90997",0,80,1,WHITE);
delay (2000);
Tft.drawString("-------------------------97",0,90,1,WHITE);
Tft.drawString("WARNING",10,100,2,RED);
Tft.drawString("!!!DETECTED!!!",10,120,2,RED);
delay (3000);

Tft.drawString("PROX SENSOR",0,140,2,RED);
Tft.drawString("VER 2.2 !ON!" ,0,155,2,RED);
delay(500);

}

void loop()
{

}

all the examples in the TFT run fine

So they have the clear the display call in them don’t they?
You have to include:-

#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

Grumpy_Mike:

all the examples in the TFT run fine

So they have the clear the display call in them don’t they?
You have to include:-

#include <Adafruit_GFX.h>

#include <Adafruit_SSD1306.h>

I searched through the code in the sketches of all the TFT examples and none use any clear screen command.

I added the adafruit lines but dont I need one of his libraries like

https://github.com/adafruit/Touch-Screen-Library ?? first?

I searched through the code in the sketches of all the TFT examples and none use any clear screen command.

Get the Adafruit_SSD1306 library and run the ssd1306_128x64_spi or the ssd1306_128x64_i2c example sketch, I think that is what you are missing.

Grumpy_Mike:

I searched through the code in the sketches of all the TFT examples and none use any clear screen command.

Get the Adafruit_SSD1306 library and run the ssd1306_128x64_spi or the ssd1306_128x64_i2c example sketch, I think that is what you are missing.

So I got the Adafruit_SSD1306 library and installed it, made sure to #include the two ( #include <Adafruit_GFX.h>, #include <Adafruit_SSD1306.h>)

I loaded the ssd1306_128x64_spi example up and saw the "display.clearDisplay(); " command in there so i figured since I have the library installed and its included now I should have access to that command?
But I still get… error: ‘display’ was not declared in this scope

And whats funny on top of it when I open up the ssd1306_128x64_spi amd try to just verify it I get an error “ssd1306_128x64_spi:335: error: ‘class Adafruit_SSD1306’ has no member named ‘println’” even though its their example.

So after installing it my sketch is as follows.

"#include <stdint.h>
#include <TouchScreen.h>
#include <TFT.h>
#include <TFT_Graphics.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#ifdef SEEEDUINO
#define YP A2 // must be an analog pin, use “An” notation!
#define XM A1 // must be an analog pin, use “An” notation!
#define YM 14 // can be a digital pin, this is A0
#define XP 17 // can be a digital pin, this is A3
#endif

#ifdef MEGA
#define YP A2 // must be an analog pin, use “An” notation!
#define XM A1 // must be an analog pin, use “An” notation!
#define YM 54 // can be a digital pin, this is A0
#define XP 57 // can be a digital pin, this is A3
#endif

void setup()
{

Tft.init(); //init TFT library
Tft.drawString(“SCAN INITAITED”,0,0,2,RED);
delay(3000);
Tft.drawString("----------7657566470808106647",0,20,1,WHITE);
delay(2000);
Tft.drawString("==============476445070416616" ,0,30,1,WHITE);
delay(2000);
Tft.drawString(“Possible Match " ,0,40,2, RED);
delay (4000);
Tft.drawString(”----------------76466013131",0,60,1,WHITE);
delay(2000);
Tft.drawString("------------------267790997",0,70,1,WHITE);
delay (2000);
Tft.drawString("----------------------90997",0,80,1,WHITE);
delay (2000);
Tft.drawString("-------------------------97",0,90,1,WHITE);
Tft.drawString(“WARNING”,0,100,2,RED);
Tft.drawString("!!!10,120,2,RED);
delay (3000);

Tft.drawString(“PROX SENSOR”,0,140,2,RED);
Tft.drawString(“VER 2.2 !ON!” ,0,155,2,RED);
delay(500);

display.clearDisplay();
}

void loop()
{

}

"

am I using the command wrong? or in the wrong spot?

thanks so much mike for all your help

Your instance of the TFT class is called Tft. Why are you calling clearDisplay() on some non-existent instance?

PaulS:
Your instance of the TFT class is called Tft. Why are you calling clearDisplay() on some non-existent instance?

you mean use "Tft.clearDisplay()" instead of using the "display.clearDisplay()"?

you mean use "Tft.clearDisplay()" instead of using the "display.clearDisplay()"?

wELL, THAT'S WHAT i'D DO.

PaulS:

you mean use "Tft.clearDisplay()" instead of using the "display.clearDisplay()"?

wELL, THAT'S WHAT i'D DO.

wont that negate the whole fact of including the adafruit?

I tried and apparently "class TFT' has no member named 'clearDisplay' ".

im about to just digital write everything over in black with no delay to get over this..I just figured it would have been a bit easier somehow i dont understand what i am doing wrong.

You are the one with the random collection of libraries. You need to go through them and the examples, to see what you can do.

use

Tft.fillRectangle(0,0,400,400,BLACK);

Hi,
in 2.8" tft from adafruit, for clear screen, you can use this instruction....

tft.fillScreen(ILI9341_WHITE);

you can use this instruction tft.clear(WHITE); but you need change the code in file Adafruit_ILI9341.cpp and Adafruit_ILI9341.h, Adafruit_GFX.cpp and Adafruit_GFX
This files are in libraries form adafruit, you need to download that libraries and put then in libraries from software arduino.

Link for the libraries for 2.8" tft from adafruit : Arduino Graphics Test | Adafruit 2.8" TFT Touch Shield v2 - Capacitive or Resistive | Adafruit Learning System.

or you can use the original instruction without change the respective files.