Hi! i have product id: 1947 and plan to use it as a display for aquarium controller.
When i try to display my RTC on the screen,the new number get print on top of the old number,superimposed on top... i got no idea on how to resolve this problem, is in the programing..any help? i will post the code as soon i get home form work.
Adafruit TFT 2.8 w. Capacitive not displaying time correctly
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- corderopilot
- Posts: 10
- Joined: Thu Nov 20, 2014 7:56 pm
Adafruit TFT 2.8 w. Capacitive not displaying time correctly
Last edited by corderopilot on Fri Jan 16, 2015 12:27 am, edited 2 times in total.
- corderopilot
- Posts: 10
- Joined: Thu Nov 20, 2014 7:56 pm
Re: Adafruit TFT 2.8 w. Capacitive not dispaying time correc
Code: Select all
#include <Adafruit_GFX.h> // Core graphics library
#include <SPI.h> // this is needed for display
#include <Adafruit_ILI9341.h>
#include <Wire.h> // this is needed for FT6206
#include <Adafruit_FT6206.h> //el touchscreen
#include <ds3231.h>
// The FT6206 uses hardware I2C (SCL/SDA)
Adafruit_FT6206 ctp = Adafruit_FT6206();//ctp=capacitive touch pannel
// The display also uses hardware SPI, plus #9 & #10
#define TFT_CS 10
#define TFT_DC 9
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
int sector(80);
void setup(){
tft.begin();
Wire.begin();
if (! ctp.begin(30))
while (1);
tft.fillScreen(ILI9341_BLACK); //this is the backgroung
Serial.begin(9600);
//just a silly test.uncomment to view..
/* void testdrawrects(uint16_t color); {(ILI9341_BLACK);
for (int16_t x=0; x < tft.width(); x+=6) {
tft.drawRect(tft.width()/2 -x/2, tft.height()/2 -x/2 , x, x, ILI9341_YELLOW);
tft.fillScreen(ILI9341_BLACK);
}}*/
//Draw selection sector
tft.drawRect(0,0,240,80,ILI9341_RED);//dibuja el cuadro del sector 1 (lugar x,lugar y,tamaño x,tamaño y,color);
tft.drawRect(0,sector,240,80,ILI9341_RED);
tft.drawRect(0,sector*2,240,80,ILI9341_RED);
tft.drawRect(0,240,75,80,ILI9341_RED);//theese
tft.drawRect(75,240,75,80,ILI9341_RED);//are the last
tft.drawRect(150,240,90,80,ILI9341_RED);//tree boxes
tft.setCursor(0,115);
tft.setTextSize(2);
tft.println(" TEMP '1' ");
tft.setCursor(0,190);
tft.setTextSize(2);
tft.println(" TEMP '2' ");
tft.setCursor(14,260);
tft.setTextSize(2);
tft.println("leds");
tft.setCursor(2,295);
tft.println("ON/OFF");
tft.setCursor(83,260);
tft.setTextSize(2);
tft.println("PUMPS");
tft.setCursor(77,295);
tft.println("ON/OFF");
tft.setCursor(152,260);
tft.setTextSize(2);
tft.println("CHILLER");
tft.setCursor(160,295);
tft.println("ON/OFF");
}
void loop(){
struct ts t;//this is RTC program
DS3231_get(&t); //Get time
tft.setCursor(0,115);
tft.setTextSize(2);
tft.setTextColor(ILI9341_YELLOW);//any color
tft.setCursor(70,35);
tft.print(t.hour);
tft.print(":");
if(t.min<10)
{
tft.print("0");
}
tft.print(t.min);
tft.print(":");
if(t.sec<10)
{
tft.print("0");
}
tft.print(t.sec);
// Wait for a touch
if (! ctp.touched()) {
return;
}
// Retrieve a point
TS_Point p = ctp.getPoint();
// flip it around to match the screen.
p.x = map(p.x, 0, 240, 240, 0);
p.y = map(p.y, 0, 320, 320, 0);
// Print out the remapped (rotated) coordinates
Serial.print("("); Serial.print(p.x);
Serial.print(", "); Serial.print(p.y);
Serial.println(")");
if(p.x<= 80 && p.y>=240){ tft.drawRect(0,240,75,80,ILI9341_WHITE);}
else{ tft.drawRect(0,240,75,80,ILI9341_RED);}
delay(5);
if(p.x >= 80 && p.x <=160 && p.y >=240){ tft.drawRect(75,240,75,80,ILI9341_WHITE);}
else{ tft.drawRect(75,240,75,80,ILI9341_RED);}
delay(5);
if(p.x >= 160 && p.x <=240 && p.y >=240){ tft.drawRect(150,240,90,80,ILI9341_WHITE);}
else{ tft.drawRect(150,240,90,80,ILI9341_RED);}
delay(5);
}
Last edited by Franklin97355 on Thu Jan 15, 2015 12:15 am, edited 1 time in total.
Reason: Added missing [code] tags
Reason: Added missing [code] tags
- corderopilot
- Posts: 10
- Joined: Thu Nov 20, 2014 7:56 pm
- corderopilot
- Posts: 10
- Joined: Thu Nov 20, 2014 7:56 pm
Re: Adafruit TFT 2.8 w. Capacitive not displaying time corre
perhaps a picture...
[/img] [img]
[/img] [img]
- Franklin97355
- Posts: 23912
- Joined: Mon Apr 21, 2008 2:33 pm
Re: Adafruit TFT 2.8 w. Capacitive not displaying time corre
Are you clearing the display between writes? Post a picture of the whole screen please.
- corderopilot
- Posts: 10
- Joined: Thu Nov 20, 2014 7:56 pm
- corderopilot
- Posts: 10
- Joined: Thu Nov 20, 2014 7:56 pm
Re: Adafruit TFT 2.8 w. Capacitive not displaying time corre
how do i clear the display between writes? sorry but i have a month trying to do what you see on te pics,never have programmed anything before.
- corderopilot
- Posts: 10
- Joined: Thu Nov 20, 2014 7:56 pm
- stratosfear
- Posts: 18
- Joined: Tue Dec 31, 2013 8:21 am
Re: Adafruit TFT 2.8 w. Capacitive not displaying time corre
setTextColor can also specify a background color.
Jon
Code: Select all
tft.setTextColor(ILI9341_CYAN, ILI9341_BLACK); //cyan text and black background to eliminate artifacts
- corderopilot
- Posts: 10
- Joined: Thu Nov 20, 2014 7:56 pm
Re: Adafruit TFT 2.8 w. Capacitive not displaying time corre
That do the trick. thanks a lot for your help!!tft.setTextColor(ILI9341_CYAN, ILI9341_BLACK); //cyan text and black background to eliminate artifacts
- corderopilot
- Posts: 10
- Joined: Thu Nov 20, 2014 7:56 pm
Re: Adafruit TFT 2.8 w. Capacitive not displaying time corre
file https://github.com/adafruit/Adafruit-GF ... ruit_GFX.h GFX.h is where you find the commands of the library. Once again thanks Jon for your help!!
- corderopilot
- Posts: 10
- Joined: Thu Nov 20, 2014 7:56 pm
Re: Adafruit TFT 2.8 w. Capacitive not displaying time corre
I need to make the Switches work...one press "on" press it again "OFF" so far i just can make it turn "on" on a single press but no off..any one have an idea how to do that?
Please be positive and constructive with your questions and comments.