dicklaw795 发表于 2013-10-2 17:35:39

arduino tftlcd Point p = ts.getPoint();

本帖最后由 dicklaw795 于 2013-10-21 08:10 编辑

想不用delay( )情況下每秒更新 tftlcd,但發現屏幕每兩秒才更新一次,死不瞑目,搞了兩天,發現與觸屏有關,刪除了觸屏的" Point p = ts.getPoint();"后便更新正常,請問有什麼方法可用到觸屏又可每秒更新屏幕


http://v.youku.com/v_show/id_XNjE2MzA4NjYw.html

#define LCD_CS A3   
#define LCD_CD A2   
#define LCD_WR A1   
#define LCD_RD A0   
// you can also just connect RESET to the arduino RESET pin
#define LCD_RESET -1
//Duemilanove/Diecimila/UNO/etc ('168 and '328 chips) microcontoller:
// Color definitions
#define        BLACK         0x0000
#define        BLUE            0x001F
#define        RED             0xF800
#define        GREEN         0x07E0
#define CYAN            0x07FF
#define MAGENTA         0xF81F
#define YELLOW          0xFFE0
#define WHITE         0xFFFF
#define        DS1307COLOR   0x07E0
#define        BACKCOLOR       0x0000
#define BMP085COLOR   0x07FF
#define FRAMECOLOR      0x07FF

#include "TFTLCD.h"
TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
///////////////////////////////////////////////////////////////
#include <Wire.h>
#include <RTClib.h>
RTC_DS1307 RTC; // Tiny RTC Modul
const char *DOW = {
"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT","SUN"};
/////////////////////////////////////////////////////////////

#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 YM7 // can be a digital pin
#define XP6// can be a digital pin

#define TS_MINX 150
#define TS_MINY 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);
#define MINPRESSURE 10
#define MAXPRESSURE 1000

//////////////////////////////////
char temp_str;
int temp_sec=0;



void setup(void) {
Wire.begin();
RTC.begin();

Serial.begin(9600);
//Serial.println("8 Bit LCD test!");
tft.reset();
tft.initDisplay();
tft.fillScreen(BLUE);
tft.setTextColor(DS1307COLOR);
tft.setTextSize(3);
tft.setCursor(5, 15);
DateTime now=RTC.now();
temp_sec=now.second();

}

void loop(void) {
digitalWrite(13, HIGH);
//Point p = ts.getPoint();
digitalWrite(13, LOW);
pinMode(XM, OUTPUT);
pinMode(YP, OUTPUT);
//p.x = map(p.x, TS_MAXX, TS_MINX, tft.width(), 0);
//p.y = map(p.y, TS_MAXY, TS_MINY, tft.height(), 0);
DateTime now=RTC.now();

if (now.second()!=temp_sec){
    temp_sec=now.second();
    tft.setCursor(0,0);
    tft.fillRect(0,0,40,30,BLACK);
    tft.print(now.second());
}
}



dicklaw795 发表于 2013-10-4 16:19:35

:'(:dizzy:

dicklaw795 发表于 2013-10-9 05:13:01

:(:'(:Q............................

dicklaw795 发表于 2013-10-21 08:07:55

已解決:lol

雨轩 发表于 2015-5-27 21:56:34

可以给个库文件我吗,谢谢啦!

雨轩 发表于 2015-5-31 01:27:43

编译出错了,楼主代码有问题啊
页: [1]
查看完整版本: arduino tftlcd Point p = ts.getPoint();