leona 发表于 2013-12-20 10:05:08

在pcDuino上使用Touch LCD Shield

这是一个多功能pcduino 兼容的电阻触摸屏。它可以用作显示装置或速写本。而且集成了一个SD卡模块。



                                                                                硬件特性:

Resolution320×240
LCD color65k
LCD driver ICILI9341
Interface TypeSPI
Touch Screen4-Wire resistive touch screen
功能特性:
/*有类库的支持,可以直接通过调用API接口实现控制*/

各个管脚使用方法:

                                                                                用于 TFT Screen控制:
D4: TF_CS, SD card select input pin
TF_CS,和SD设置为输入模式
D5:TFT_CS, TFT chip select input pin
TFT_CS, TFT设置为输入模式
D6:TFT_D/C, TFT Data/Command control pin
TFT_D/C, TFT Data/Command 控制管脚
D7:BACKLIGHT, TFT backlight control pin
BACKLIGHT, TFT 背光控制管脚
用于SPI 接口:
D10: SPI chip select使能
D11: SPI MOSI(主机输出从机输入)pin
D12: SPI MISO (从机输出主机输入)pin
D13: SPI serial clock pin(SPI时钟管脚)
用于 Touch 功能:
A0 – Touch Screen Y- input pin.
A1 – Touch Screen X- input pin.
A2 – Touch Screen Y+ input pin.
A3 – Touch Screen X+ input pin.
               
       
                       
调试:
                                                                               
[*]工具:一个pcduino和一个Touch LCD Shield
[*]示例代码:
#include <stdint.h>
#include “TFTv2.h”
#include <SPI.h>
void setup()
{
TFT_BL_ON; // turn on the background light
Tft.TFTinit(); // init TFT library
Tft.drawChar(‘S’,0,0,1,RED); // draw char: ‘S’, (0, 0), size: 1, color: RED
Tft.drawChar(‘E’,10,10,2,BLUE); // draw char: ‘E’, (10, 10), size: 2, color: BLUE
Tft.drawChar(‘E’,20,40,3,GREEN); // draw char: ‘E’, (20, 40), size: 3, color: GREEN
Tft.drawChar(‘E’,30,80,4,YELLOW); // draw char: ‘E’, (30, 80), size: 4, color: YELLOW
Tft.drawChar(‘D’,40,120,4,YELLOW); // draw char: ‘D’, (40, 120), size: 4, color: YELLOW
Tft.drawString(“Hello”,0,180,3,CYAN); // draw string: “hello”, (0, 180), size: 3, color: CYAN
Tft.drawString(“World!!”,60,220,4,WHITE); // draw string: “world!!”, (80, 230), size: 4, color: WHITE
}
void loop()
{
}
               
       
                       


                                                                                运行库可以在这里下载。
注明:以下是要在有c_enviroment的情况下进行的
(1)编译前截图
http://cnlearn.linksprite.com/wp-content/uploads/2013/11/%E7%BC%96%E8%AF%91%E5%89%8D_%E5%89%AF%E6%9C%AC.jpg(2)编译库文件,也就是操作shield的函数库ubuntu@ubuntu:~/Arduino/TFTtouch$ gcc -c TFTv2.cpp(3)编译调试文件test.cppubuntu@ubuntu:~/Arduino/TFTtouch$ gcc -c test.cpp(4)链接目标文件和库ubuntu@ubuntu:~/Arduino/TFTtouch$ gcc test.o TFTv2.o -o test -larduino(5)编译后的文件截图http://cnlearn.linksprite.com/wp-content/uploads/2013/11/%E7%BC%96%E8%AF%91%E5%90%8E_%E5%89%AF%E6%9C%AC.jpg(6)运行截图ubuntu@ubuntu:~/Arduino/TFTtouch$ ./testhttp://cnlearn.linksprite.com/wp-content/uploads/2013/11/%E8%BF%90%E8%A1%8C_%E5%89%AF%E6%9C%AC.jpg               
       
                       
               
       
                       

页: [1]
查看完整版本: 在pcDuino上使用Touch LCD Shield