Pages: [1] 2   Go Down
Author Topic: Clear Screen and 2.8TFT  (Read 1871 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 616
Posts: 49447
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Links to the library are going to be necessary.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley
Logged

NE PA
Offline Offline
Full Member
***
Karma: 5
Posts: 156
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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


Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 627
Posts: 34243
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I use:-
Code:
display.clearDisplay();   // clears the screen and buffer
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 627
Posts: 34243
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Have you tried running the examples in the library?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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()
{


}
 
 
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 627
Posts: 34243
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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:-
Code:
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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:-
Code:
#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?
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 627
Posts: 34243
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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
« Last Edit: February 11, 2013, 01:32:11 pm by grindsoul » Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 616
Posts: 49447
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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()"? 
Logged

Pages: [1] 2   Go Up
Jump to: