极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 10275|回复: 5

arduino tftlcd Point p = ts.getPoint();

[复制链接]
发表于 2013-10-2 17:35:39 | 显示全部楼层 |阅读模式
本帖最后由 dicklaw795 于 2013-10-21 08:10 编辑

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




  1. #define LCD_CS A3   
  2. #define LCD_CD A2   
  3. #define LCD_WR A1   
  4. #define LCD_RD A0   
  5. // you can also just connect RESET to the arduino RESET pin
  6. #define LCD_RESET -1
  7. //Duemilanove/Diecimila/UNO/etc ('168 and '328 chips) microcontoller:
  8. // Color definitions
  9. #define        BLACK           0x0000
  10. #define        BLUE            0x001F
  11. #define        RED             0xF800
  12. #define        GREEN           0x07E0
  13. #define CYAN            0x07FF
  14. #define MAGENTA         0xF81F
  15. #define YELLOW          0xFFE0
  16. #define WHITE           0xFFFF
  17. #define        DS1307COLOR     0x07E0
  18. #define        BACKCOLOR       0x0000
  19. #define BMP085COLOR     0x07FF
  20. #define FRAMECOLOR      0x07FF

  21. #include "TFTLCD.h"
  22. TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
  23. ///////////////////////////////////////////////////////////////
  24. #include <Wire.h>
  25. #include <RTClib.h>
  26. RTC_DS1307 RTC; // Tiny RTC Modul
  27. const char *DOW[8] = {
  28.   "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT","SUN"};
  29. /////////////////////////////////////////////////////////////

  30. #include "TouchScreen.h"
  31. #define YP A1  // must be an analog pin, use "An" notation!
  32. #define XM A2  // must be an analog pin, use "An" notation!
  33. #define YM  7 // can be a digital pin
  34. #define XP  6  // can be a digital pin

  35. #define TS_MINX 150
  36. #define TS_MINY 120
  37. #define TS_MAXX 920
  38. #define TS_MAXY 940

  39. // For better pressure precision, we need to know the resistance
  40. // between X+ and X- Use any multimeter to read it
  41. // For the one we're using, its 300 ohms across the X plate
  42. TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);
  43. #define MINPRESSURE 10
  44. #define MAXPRESSURE 1000

  45. //////////////////////////////////
  46. char temp_str[12];
  47. int temp_sec=0;



  48. void setup(void) {
  49.   Wire.begin();
  50.   RTC.begin();

  51.   Serial.begin(9600);
  52.   //Serial.println("8 Bit LCD test!");
  53.   tft.reset();
  54.   tft.initDisplay();
  55.   tft.fillScreen(BLUE);
  56.   tft.setTextColor(DS1307COLOR);
  57.   tft.setTextSize(3);
  58.   tft.setCursor(5, 15);
  59.   DateTime now=RTC.now();
  60.   temp_sec=now.second();

  61. }

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

  71.   if (now.second()!=temp_sec){
  72.     temp_sec=now.second();
  73.     tft.setCursor(0,0);
  74.     tft.fillRect(0,0,40,30,BLACK);
  75.     tft.print(now.second());
  76.   }
  77. }



复制代码
回复

使用道具 举报

 楼主| 发表于 2013-10-4 16:19:35 | 显示全部楼层
回复 支持 反对

使用道具 举报

 楼主| 发表于 2013-10-9 05:13:01 | 显示全部楼层
............................
回复 支持 反对

使用道具 举报

 楼主| 发表于 2013-10-21 08:07:55 | 显示全部楼层
已解決
回复 支持 反对

使用道具 举报

发表于 2015-5-27 21:56:34 | 显示全部楼层
可以给个库文件我吗,谢谢啦!
回复 支持 反对

使用道具 举报

发表于 2015-5-31 01:27:43 | 显示全部楼层
编译出错了,楼主代码有问题啊
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|联系我们|极客工坊

GMT+8, 2026-6-8 01:18 , Processed in 0.052625 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表