|
本帖最后由 Clagrens 于 2015-6-3 00:13 编辑
今天某宝入手了一个2.4TFT触摸屏……
宝贝地址:
http://item.taobao.com/item.htm?spm=a230r.1.14.36.YAipfw&id=39834819734&ns=1&abbucket=3#detail
不科学的竟然店家给的驱动没办法驱动(非病句也)……
于是此刻我就只能求助万能的google……然后终于找到解决办法了!!
首先,我是先搜索关于这个屏幕的信息,关键词“2.4 tft arduino”
找到这个网站,是卖这个屏幕的
http://www.banggood.com/2_4-Inch-TFT-LCD-Shield-Touch-Board-Display-Module-For-Arduino-UNO-p-940735.html
第一版就有一个高人提供了一个解决办法!
I got Touch and Screen working thanks to the links here and some some my own figuring out for the touchscreen!
My combination that worked is as follows:
“谢谢这些库文件的开放者,和一些为我的触摸屏指出型号的人,我终于使这个触摸屏可以触摸和显示了!以下是我的整理:”
Install 3 adafruit libraries)
(https://github.com/adafruit/Adafruit-GFX-Library)
(https://github.com/adafruit/TFTLCD-Library)
(https://github.com/adafruit/Touch-Screen-Library)
1.安装上面三个adafruit的库
(注,打开上面的页面之后页面右边有个downloadzip,下载就好了。不会用github的话可以百度找找。)
(注意,不同版本的arduino导入库的方法不一样,可以查找相关的版本导入方法,本教程基于arduino 1.6.4)
Open Examples > TFTLCD-Library-master > tftpaint
Change this to force the sample to use this display type
"uint16_t identifier = tft.readID();" to "uint16_t identifier = 0x9341;"
2.打开“文件->示例-> TFTLCD-Library-master > graphicstest”
3.修改
"uint16_t identifier = tft.readID();"
为
"uint16_t identifier = 0x9341;"
(为什么呢!因为国产山寨触摸屏没有给芯片写ID,所以导致adafruit库没办法识别,修改这一句后就能强制地调用9341的驱动!)
将上面几句改好之后液晶就能驱动了
对于触摸屏的话,有几种解决方案:
1.adafruit的标准定义
#define YP A2 // must be an analog pin, use "An" notation!
#define XM A3 // must be an analog pin, use "An" notation!
#define YM 8 // can be a digital pin
#define XP 9 // can be a digital pin
2.上面那个网址的定义
#define YP A2 // must be an analog pin, use "An" notation!
#define XM A1 // must be an analog pin, use "An" notation!
#define YM 7 // can be a digital pin
#define XP 6 // can be a digital pin
3.对某宝的国产屏定义
#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
注意!!某宝给的国产屏按着上面定义给出的x轴点坐标是反转的
如果要跑示例中的tftpaint
需要将
p.x = map(p.x, TS_MINX, TS_MAXX, tft.width(), 0);
p.y = map(p.y, TS_MINY, TS_MAXY, tft.height(), 0);
改为
p.x = map(p.x, TS_MAXX, TS_MINX, tft.width(), 0);
p.y = map(p.y, TS_MINY, TS_MAXY, tft.height(), 0);
这样才是真正能跑了
附上一张我的painttest
第一次发帖,请轻喷~谢谢 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|