Hello !
My items are : (sory for the bad englisch...i am dutch)
display =
http://produk-inovatif.com/shop/arduino/2-4-tft-lcd-shield-touch-panel-display-with-tf-wtf-reader-for-arduino-uno/
pcf = selfmade pcb and its using onley 5v, gnd,scl and sda from the uno board and taht part is testen and works fine. (schematic..see attach.
and my code is :
// pcf8583
#include <Wire.h>
#include <stdio.h>
#include <PCF8583.h>
/*****************************************************************************
- read/write serial interface to PCF8583 RTC via I2C interface
-
- Arduino analog input 5 - I2C SCL (PCF8583 pin 6)
- Arduino analog input 4 - I2C SDA (PCF8583 pin 5)
-
- You can set the type by sending it YYMMddhhmmss;
- the semicolon on the end tells it you're done...
-
******************************************************************************/
// display
#include <Adafruit_GFX.h> // Core graphics library
#include <SWTFT.h> // Hardware-specific library
#include <TouchScreen.h>
#define YP A1 // must be an analog pin, use "An" notation!
#define XM A2 // must be an analog pin, use "An" notation!
#define YM 7 // can be a digital pin
#define XP 6 // can be a digital pin
#define TS_MINX 100//150
#define TS_MINY 100//120
#define TS_MAXX 920
#define TS_MAXY 940
// For better pressure precision, we need to know the resistance
// between X+ and X- Use any multimeter to read it
// For the one we're using, its 300 ohms across the X plate
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);
int toetswaarde=20;
int temptoetswaarde=0;
int waardebit=0;
int tijd=0;
// Assign human-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;
// pcf8583
int correct_address = 0;
PCF8583 p (0xA0);
void setup(void) {
Serial.begin(9600);
tft.reset();
uint16_t identifier = tft.readID();
tft.begin(identifier);
delay(100);
toetsveld();
}
#define MINPRESSURE 10
#define MAXPRESSURE 1000
void loop(){
// pcf8583
if(Serial.available() > 0){
p.year= (byte) ((Serial.read() - 48) *10 + (Serial.read() - 48)) + 2000;
p.month = (byte) ((Serial.read() - 48) *10 + (Serial.read() - 48));
p.day = (byte) ((Serial.read() - 48) *10 + (Serial.read() - 48));
p.hour = (byte) ((Serial.read() - 48) *10 + (Serial.read() - 48));
p.minute = (byte) ((Serial.read() - 48) *10 + (Serial.read() - 48));
p.second = (byte) ((Serial.read() - 48) * 10 + (Serial.read() - 48)); // Use of (byte) type casting and ascii math to achieve result.
if(Serial.read() == ';'){
Serial.println("setting date");
p.set_time();
}
}
p.get_time();
char time[50];
sprintf(time, "%02d/%02d/%02d %02d:%02d:%02d",
p.year, p.month, p.day, p.hour, p.minute, p.second);
Serial.println(time);
// 2.4 inch display
TSPoint p = ts.getPoint();
pinMode(XM, OUTPUT);
pinMode(YP, OUTPUT);
int temp1=0;
if (p.z > MINPRESSURE && p.z < MAXPRESSURE) {
if(p.x<350&&p.y<280){toetswaarde=1;}
if(p.x>350&&p.x<650&&p.y<280){toetswaarde=2;}
if(p.x>650&&p.x<950&&p.y<280){toetswaarde=3;}
if(p.x<350&&p.y>280&&p.y<480){toetswaarde=4;}
if(p.x>350&&p.x<650&&p.y>280&&p.y<480){toetswaarde=5;}
if(p.x>650&&p.x<950&&p.y>280&&p.y<480){toetswaarde=6;}
if(p.x<350&&p.y>480&&p.y<680){toetswaarde=7;}
if(p.x>350&&p.x<650&&p.y>480&&p.y<680){toetswaarde=8;}
if(p.x>650&&p.x<950&&p.y>480&&p.y<680){toetswaarde=9;}
if(p.x<350&&p.y>680&&p.y<880){Serial.println("*");}
if(p.x>350&&p.x<650&&p.y>680&&p.y<880){toetswaarde=0;}
if(p.x>650&&p.x<950&&p.y>680&&p.y<880){toetswaarde=11;}
if (toetswaarde<temptoetswaarde||toetswaarde>temptoetswaarde){waardebit=1;temp1=temptoetswaarde;temptoetswaarde=toetswaarde;}
}
++tijd;
if (tijd>2000){
byte a=32;
if (toetswaarde>9){a=20;}
tft.setTextColor(BLACK); tft.setTextSize(4);
tft.setCursor(a, 263);tft.println(toetswaarde);
temptoetswaarde=20;
a=32;}
if(waardebit==1){
tijd=0;
byte a=32;
if (temp1>9){a=20;}
tft.setTextColor(BLACK); tft.setTextSize(4);
tft.setCursor(a, 263);tft.println(temp1);
a=32;
if(toetswaarde>9){a=20;}
tft.setTextColor(YELLOW); tft.setTextSize(4);
tft.setCursor(a, 263);tft.println(toetswaarde);
//Serial.println("ik heb de toets gezien !!!!!!");
//Serial.println(toetswaarde);
waardebit=0;}
}
int toetsveld() {
byte a,b,c,d,e;
a=3;b=3;c=75;d=75;e=6;
tft.fillScreen(BLACK);
vierkant(a,b,c,d,e);
vierkant(a+1,b+1,c-2,d-2,e-1);
a=82;
vierkant(a,b,c,d,e);
vierkant(a+1,b+1,c-2,d-2,e-1);
a=161;
vierkant(a,b,c,d,e);
vierkant(a+1,b+1,c-2,d-2,e-1);
a=3;b=82;
vierkant(a,b,c,d,e);
vierkant(a+1,b+1,c-2,d-2,e-1);
a=82;
vierkant(a,b,c,d,e);
vierkant(a+1,b+1,c-2,d-2,e-1);
a=161;
vierkant(a,b,c,d,e);
vierkant(a+1,b+1,c-2,d-2,e-1);
a=3;b=161;
vierkant(a,b,c,d,e);
vierkant(a+1,b+1,c-2,d-2,e-1);
a=82;
vierkant(a,b,c,d,e);
vierkant(a+1,b+1,c-2,d-2,e-1);
a=161;
vierkant(a,b,c,d,e);
vierkant(a+1,b+1,c-2,d-2,e-1);
a=3;b=240;
vierkant(a,b,c,d,e);
vierkant(a+1,b+1,c-2,d-2,e-1);
a=82;
vierkant(a,b,c,d,e);
vierkant(a+1,b+1,c-2,d-2,e-1);
a=161;
vierkant(a,b,c,d,e);
vierkant(a+1,b+1,c-2,d-2,e-1);
tft.setTextColor(WHITE); tft.setTextSize(4);
tft.setCursor(32, 27);tft.println("1");
tft.setCursor(110, 27);tft.println("2");
tft.setCursor(189, 27);tft.println("3");
tft.setCursor(32, 105);tft.println("4");
tft.setCursor(110, 105);tft.println("5");
tft.setCursor(189, 105);tft.println("6");
tft.setCursor(32, 184);tft.println("7");
tft.setCursor(110, 184);tft.println("8");
tft.setCursor(189, 184);tft.println("9");
tft.setCursor(110, 263);tft.println("0");
//tft.setTextColor(YELLOW); tft.setTextSize(4);
//tft.setCursor(32, 263);tft.println(a);
//tft.setCursor(189, 263);tft.println("#");
}
unsigned long vierkant(int a,int b,int c,int d,int e) {
int kleur=MAGENTA;
tft.drawLine(a+e, b, (a+c)-e, b, kleur);
tft.drawLine((a+c)-e, b, a+c, b+e, kleur);
tft.drawLine(a+c, b+e, a+c, (b+d)-e, kleur);
tft.drawLine(a+c, (b+d)-e, (a+c)-e, b+d, kleur);
tft.drawLine((a+c)-e, b+d, a+e, b+d, kleur);
tft.drawLine(a+e, b+d, a, (b+d)-e, kleur);
tft.drawLine(a, (b+d)-e, a, b+e, kleur);
tft.drawLine(a, b+e, a+e, b, kleur);
a=0;b=0;c=0;d=0;e=0;}
A_TFTLCD.pdf (24 KB)