请教“Mega 2560+TFT3.2寸屏的演示实验”问题
本帖最后由 yuqingshan 于 2014-7-8 19:52 编辑近来在发现玩Arduino比较热,网上淘了一块Mega 2560,玩了一段时间,近日又淘了一块HY-TFT320彩屏,控制IC是SSD1289,参照《arduino学习笔记33 - Mega 2560+TFT3.2寸屏的演示实验 》资料连线演示实验。连线见图1
连接方法是这样的:
(LEDK -> GND) only 3.2″ TFT LCD
LEDA -> 5V
VCC -> 5V
RD -> 3.3V
GND -> GND
DB0->DB7 to pin D37->D30
DB8->DB15 to pin D22->D29
RS -> D38
WR -> D39
CS(pin6) -> D40
RSET-> D41
但是TFT规格书说明:背光电源(LED_A 引脚):背光电源最高3.2V,难道连接:LEDA -> 5V 有问题吗?
1.系统XP+Arduino-1.5.6-r2,出现情况见图2
参考弘毅网上‘参考使老版本库文件支持Arduino 1.0 IDE的方法’一文(
http://www.geek-workshop.com/forum.php?mod=viewthread&tid=1030)
将“#include "WProgram.h"”字段和把两个文件的“#include "WProgram.h""字段替换为:
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
这样编译能同过,上传代码,但通电后没有啥显示的,一遍白光,情况见图3.
2.改用系统Xin7+Arduino1.05-r2,情况基本一样:能顺利通过编译,就是屏幕没反应,没有什么显示,白光。运行库内带的示例情况也一样,屏幕没反应。
询问店家,是不太懂的一类,无Arduino应用资料,只提供51的资料,
请教高手是Arduino还是HY-TFT320引线有问题?弄不出显示的。
附代码:
#include <ITDB02_Graph16.h>
// Declare which fonts we will be using
extern uint8_t SmallFont[];
// Uncomment the next line for the ITDB02 Shield
//ITDB02 myGLCD(19,18,17,16);
// Uncomment the next line for the ITDB02 Mega Shield
ITDB02 myGLCD(38,39,40,41);
void setup()
{
randomSeed(analogRead(0));
// Setup the LCD
myGLCD.InitLCD();
myGLCD.setFont(SmallFont);
}
void loop()
{
int buf;
int x, x2;
int y, y2;
int r;
// Clear the screen and draw the frame
myGLCD.clrScr();
myGLCD.setColor(255, 0, 0);
myGLCD.fillRect(0, 0, 239, 13);
myGLCD.setColor(64, 64, 64);
myGLCD.fillRect(0, 306, 239, 319);
myGLCD.setColor(255, 255, 255);
myGLCD.setBackColor(255, 0, 0);
myGLCD.print("ITDB02 - 240x320 Color Display", CENTER, 1);
myGLCD.setColor(255, 128, 128);
myGLCD.setBackColor(64, 64, 64);
myGLCD.print("H.Karlsen", LEFT, 307);
myGLCD.print("(C)2010", RIGHT, 307);
myGLCD.setColor(255,255,0);
myGLCD.print("Portrait", CENTER, 307);
myGLCD.setColor(0, 0, 255);
myGLCD.drawLine(0, 14, 239, 14);
myGLCD.drawLine(0, 14, 0, 305);
myGLCD.drawLine(239, 14, 239, 305);
myGLCD.drawLine(0, 305, 239, 305);
// Draw crosshairs
myGLCD.setColor(0, 0, 255);
myGLCD.setBackColor(0, 0, 0);
myGLCD.drawLine(119, 15, 119, 304);
myGLCD.drawLine(1, 159, 238, 159);
for (int i=9; i<240; i+=10)
myGLCD.drawLine(i, 157, i, 161);
for (int i=19; i<300; i+=10)
myGLCD.drawLine(117, i, 121, i);
// Draw sin-, cos- and tan-lines
myGLCD.setColor(0,255,255);
myGLCD.print("Sin", 5, 15);
for (int i=1; i<238; i++)
{
myGLCD.drawPixel(i,159+(sin(((i*1.51)*3.14)/180)*100));
}
myGLCD.setColor(255,0,0);
myGLCD.print("Cos", 5, 27);
for (int i=1; i<238; i++)
{
myGLCD.drawPixel(i,159+(cos(((i*1.51)*3.14)/180)*100));
}
myGLCD.setColor(255,255,0);
myGLCD.print("Tan", 5, 39);
for (int i=1; i<238; i++)
{
myGLCD.drawPixel(i,159+(tan(((i*1.51)*3.14)/180)));
}
delay(2000);
myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,238,304);
myGLCD.setColor(0, 0, 255);
myGLCD.setBackColor(0, 0, 0);
myGLCD.drawLine(119, 15, 119, 304);
myGLCD.drawLine(1, 159, 238, 159);
// Draw a moving sinewave
x=1;
for (int i=1; i<6902; i++)
{
x++;
if (x==239)
x=1;
if (i>239)
{
if ((x==119)||(buf==159))
myGLCD.setColor(0,0,255);
else
myGLCD.setColor(0,0,0);
myGLCD.drawPixel(x,buf);
}
myGLCD.setColor(0,255,255);
y=159+(sin(((i*1.4)*3.14)/180)*(100-(i / 100)));
myGLCD.drawPixel(x,y);
buf=y;
}
delay(2000);
myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,238,304);
// Draw some filled rectangles
for (int i=1; i<6; i++)
{
switch (i)
{
case 1:
myGLCD.setColor(255,0,255);
break;
case 2:
myGLCD.setColor(255,0,0);
break;
case 3:
myGLCD.setColor(0,255,0);
break;
case 4:
myGLCD.setColor(0,0,255);
break;
case 5:
myGLCD.setColor(255,255,0);
break;
}
myGLCD.fillRect(30+(i*20), 70+(i*20), 90+(i*20), 130+(i*20));
}
delay(2000);
myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,238,304);
// Draw some filled, rounded rectangles
for (int i=1; i<6; i++)
{
switch (i)
{
case 1:
myGLCD.setColor(255,0,255);
break;
case 2:
myGLCD.setColor(255,0,0);
break;
case 3:
myGLCD.setColor(0,255,0);
break;
case 4:
myGLCD.setColor(0,0,255);
break;
case 5:
myGLCD.setColor(255,255,0);
break;
}
myGLCD.fillRoundRect(150-(i*20),70+(i*20), 210-(i*20), 130+(i*20));
}
delay(2000);
myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,238,304);
// Draw some filled circles
for (int i=1; i<6; i++)
{
switch (i)
{
case 1:
myGLCD.setColor(255,0,255);
break;
case 2:
myGLCD.setColor(255,0,0);
break;
case 3:
myGLCD.setColor(0,255,0);
break;
case 4:
myGLCD.setColor(0,0,255);
break;
case 5:
myGLCD.setColor(255,255,0);
break;
}
myGLCD.fillCircle(60+(i*20),100+(i*20), 30);
}
delay(2000);
myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,238,304);
// Draw some lines in a pattern
myGLCD.setColor (255,0,0);
for (int i=15; i<304; i+=5)
{
myGLCD.drawLine(1, i, (i/1.22)-10, 304);
}
myGLCD.setColor (255,0,0);
for (int i=304; i>15; i-=5)
{
myGLCD.drawLine(238, i, (i/1.22)-11, 15);
}
myGLCD.setColor (0,255,255);
for (int i=304; i>15; i-=5)
{
myGLCD.drawLine(1, i, 251-(i/1.22), 15);
}
myGLCD.setColor (0,255,255);
for (int i=15; i<304; i+=5)
{
myGLCD.drawLine(238, i, 250-(i/1.22), 304);
}
delay(2000);
myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,238,304);
// Draw some random circles
for (int i=0; i<100; i++)
{
myGLCD.setColor(random(255), random(255), random(255));
x=32+random(175);
y=45+random(212);
r=random(30);
myGLCD.drawCircle(x, y, r);
}
delay(2000);
myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,238,304);
// Draw some random rectangles
for (int i=0; i<100; i++)
{
myGLCD.setColor(random(255), random(255), random(255));
x=2+random(236);
y=16+random(287);
x2=2+random(236);
y2=16+random(287);
myGLCD.drawRect(x, y, x2, y2);
}
delay(2000);
myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,238,304);
// Draw some random rounded rectangles
for (int i=0; i<100; i++)
{
myGLCD.setColor(random(255), random(255), random(255));
x=2+random(236);
y=16+random(287);
x2=2+random(236);
y2=16+random(287);
myGLCD.drawRoundRect(x, y, x2, y2);
}
delay(2000);
myGLCD.setColor(0,0,0);
myGLCD.fillRect(2,16,238,304);
for (int i=0; i<100; i++)
{
myGLCD.setColor(random(255), random(255), random(255));
x=2+random(236);
y=16+random(289);
x2=2+random(236);
y2=16+random(289);
myGLCD.drawLine(x, y, x2, y2);
}
delay(2000);
myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,238,304);
for (int i=0; i<10000; i++)
{
myGLCD.setColor(random(255), random(255), random(255));
myGLCD.drawPixel(2+random(236), 16+random(289));
}
delay(2000);
myGLCD.fillScr(0, 0, 255);
myGLCD.setColor(255, 0, 0);
myGLCD.fillRoundRect(30, 100, 209, 219);
myGLCD.setColor(255, 255, 255);
myGLCD.setBackColor(255, 0, 0);
myGLCD.print("That's it!", CENTER, 133);
myGLCD.print("Restarting in a", CENTER, 159);
myGLCD.print("few seconds...", CENTER, 172);
myGLCD.setColor(0, 0, 0);
myGLCD.setBackColor(0, 0, 255);
myGLCD.print("Runtime: (msecs)", CENTER, 290);
myGLCD.printNumI(millis(), CENTER, 305);
delay (10000);
}
本帖最后由 yuqingshan 于 2014-7-17 18:02 编辑
折腾2个星期,终于可以出图像了,之前老是出不了图,见图2-1,图2-2,图2-3,估计是那根线接错了,具体原因不清楚。
但问题来了,现在只能显示字符、图片类可以,显线一类的就出现花屏,具体分别加如下语句:
myGLCD.drawLine(100,100, 200,200);
见图2-4,
或:myGLCD.fillCircle(119,159,80);
图2-5,
或:myGLCD.fillRect(119,0,239,159);
图2-6
搞不清楚是TFT3.2本身有问题还是使用的库不对,那位高手帮帮忙,
谢谢。
使用库:ITDB02_Graph16.h 我还是遇到了相同问题。。。花屏,我的是TFT_320..我以为是TFT有问题,就要求卖家换一片,换的还没发回来。。。。 可以看看这个帖子【教程】ITead TFT-LCD触摸显示屏现成驱动库使用方法
http://www.geek-workshop.com/thread-10541-1-1.html
感谢ITEAD创易工作室帮助,认识又进一步了,谢谢。不过问题还是未能解决:
补充材料:
3.2寸TFT彩色LCD液晶屏模块带触摸屏
自选驱动IC:SSD1289
,
图01,02-外型
估计程序中的model参数修改应也正确吧:
图02-运行程例也是没有问题
问题就是运行其他一些代码,如:myGLCD.drawRoundRect(x, y, x2, y2)等就花屏。
触屏功能暂时还未使用。 估计是屏和库不兼容。换了一片回来还是花屏。。。 请问大大找到可用的库, 或可用的屏了吗?
我正在找给 arduino 用约3吋的屏, 不知你的是否可用了.
本帖最后由 yuqingshan 于 2014-9-25 15:47 编辑
花屏的问题终于解决了,现在发现应是电源的问题,估计不是库的问题。
原来Mega 2560采用USB或者外部供电6.5-9.0v时,就出现花屏,尤其是绘图等功能演示,但数字显示又正常,非常困惑,后来无意间采用一节3.7V锂电供电,结果全部程例演示正常,后来再用5.0V稳压电源(电池连接电源连接器的GND和VIN引脚,即和前面锂电供电一样接口孔),结果也是正常,这样看来是Mega 2560供电系统有些BUG或者电源干扰TFT屏,最坏是我买的Mega 2560太过山寨货?(TB上80大洋淘的),帖出这问题情况,希望各位朋友有点参考价值。
库采用:ITDB02_Graph16,或者:UTFT.h,UTouch.h 都可以正常的。
不过还有一问题,还想请硬件高手解答一下,就是TFT3.2屏的扩展板,其中板上的R5电阻,无意发现如果USB或外部供电,花屏(但是仅绘图等时花屏,数字、文字时正常),电阻R5发热较大50~60℃;如果电池端口供电5V时,屏幕所有功能正常,发热约30℃。感觉可像该连接板设计是否也有些问题?
我用的4.3的屏ITDB02-4.3,库选的ITDB43,和你开始一样,程序烧进去没问题,屏幕白的没图像,例子也不行,线都检查过,不知道是什么原因? yuqingshan 发表于 2014-7-17 08:53 static/image/common/back.gif
折腾2个星期,终于可以出图像了,之前老是出不了图,见图2-1,图2-2,图2-3,估计是那根线接错了,具体原因 ...
楼主用的不是ili9341的驱动芯片吗? yuqingshan 发表于 2014-7-17 08:53 static/image/common/back.gif
折腾2个星期,终于可以出图像了,之前老是出不了图,见图2-1,图2-2,图2-3,估计是那根线接错了,具体原因 ...
请问为什么我编译出错呢?? lx872000 发表于 2015-3-8 22:22 static/image/common/back.gif
我用的4.3的屏ITDB02-4.3,库选的ITDB43,和你开始一样,程序烧进去没问题,屏幕白的没图像,例子也不行,线 ...
我也是这样的,我是3.2 的屏,可是就是白屏 电平的原因,arduino IO电平5V,TFT3.3V,买电平转换芯片吧
页:
[1]