完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
``有没有德飞莱用3.5寸彩屏的?我的程序下上去没反应,是屏坏了呢?还是程序有问题?求大神指点啊 #include"reg52.h" #include"tft.h" /*------------------------------------------------ 主函数 ------------------------------------------------*/ void main(void) { TFT_Initial();//³õʼ»¯ while(1) { show_colour_bar(); //ÏÔʾ²ÊÌõ ClearScreen(0xff00); Show_RGB (0,240,0,320,0xf800);//Ë¢³ö320x240µÄСÇøÓò ClearScreen(0xff00); LCD_PutString(0,0,"朗逸电子科技",0x0000,0x00f8); LCD_PutString(0,32,"朗逸电子科技",0xffff,0xf800); LCD_PutString(0,64,"朗逸电子科技",0x2334,0x0045); LCD_PutString(0,96,"朗逸电子科技",0x0560,0x0a80); LCD_PutString(0,128,"朗逸电子科技",0x0000,0x0f80); LCD_PutString(0,160,"朗逸电子科技",0x0000,0x0f80); LCD_PutString(0,192,"朗逸电子科技",0x0000,0x0f80); LCD_PutString(0,224,"朗逸电子科技",0x0000,0x0f80); LCD_PutString(0,256,"朗逸电子科技",0x0000,0x0f80); LCD_PutString(0,288,"朗逸电子科技",0x0000,0x0f80); LCD_PutString(0,320,"朗逸电子科技",0x0000,0x0f80); LCD_PutString(0,352,"朗逸电子科技",0x0000,0x0f80); while(1); } } /* tft */ #include"reg52.h" #include"tft.h" ***it CS=P2^2; ***it RES=P2^1; ***it RS=P2^4; ***it RW=P2^5; #define DataPort P0 //unsigned char code pic[]; #define X_MAX 240 #define Y_MAX 320 void ClearScreen(unsigned int bColor) { unsigned int i,j; LCD_SetPos(0,X_MAX-1,0,Y_MAX-1);// for (i=0;i<Y_MAX;i++) { for (j=0;j<X_MAX;j++) Write_Data_U16(bColor); } } #include "8X16.h" void LCD_PutChar8x16(unsigned short x, unsigned short y, char c, unsigned int fColor, unsigned int bColor) { unsigned int i,j; LCD_SetPos(x,x+8-1,y,y+16-1); for(i=0; i<16;i++) { unsigned char m=Font8x16[c*16+i]; for(j=0;j<8;j++) { if((m&0x80)==0x80) { Write_Data_U16(fColor); } else { Write_Data_U16(bColor); } m<<=1; } } } /*------------------------------------------------ д×Ö·û´®º¯Êý ------------------------------------------------*/ void LCD_PutChar(unsigned short x, unsigned short y, char c, unsigned int fColor, unsigned int bColor) { LCD_PutChar8x16( x, y, c, fColor, bColor ); } /*------------------------------------------------ д32x31ºº×Öº¯Êý ------------------------------------------------*/ #include "GB3231.h" // void PutGB1616(unsigned short x, unsigned short y, unsigned char c[2], unsigned int fColor,unsigned int bColor){ unsigned int i,j,k; LCD_SetPos(x, x+32-1,y, y+31-1); for (k=0;k<64;k++) { //64±êʾ×Ô½¨ºº×Ö¿âÖеĸöÊý£¬Ñ»·²éѯÄÚÂë if ((codeGB_16[k].Index[0]==c[0])&&(codeGB_16[k].Index[1]==c[1])){ for(i=0;i<124;i++) { unsigned short m=codeGB_16[k].Msk[i]; for(j=0;j<8;j++) { if((m&0x80)==0x80) { Write_Data_U16(fColor); } else { Write_Data_U16(bColor); } m<<=1; } } } } } /*------------------------------------------------ д×Ö·û´®º¯Êý ------------------------------------------------*/ void LCD_PutString(unsigned short x, unsigned short y, unsigned char *s, unsigned int fColor, unsigned int bColor) { unsigned char l=0; while(*s) { if( *s < 0x80) { LCD_PutChar(x+l*8,y,*s,fColor,bColor); s++;l++; } else { PutGB1616(x+l*8,y,(unsigned char*)s,fColor,bColor); s+=2;l+=4; } } } /*------------------------------------------------ Ö¸¶¨ÇøÓòÏÔʾָ¶¨RGBÑÕÉ« ------------------------------------------------*/ void Show_RGB (unsigned int x0,unsigned int x1,unsigned int y0,unsigned int y1,unsigned int Color) { unsigned int i,j; LCD_SetPos(x0,x1,y0,y1); for (i=y0;i<=y1;i++) { for (j=x0;j<=x1;j++) Write_Data_U16(Color); } } /*------------------------------------------------ ÏÔʾ²ÊÌõ ------------------------------------------------*/ void show_colour_bar (void) { unsigned char GAP=50; int V,H; LCD_SetPos(0,X_MAX-1,0,Y_MAX-1); for(H=0;H<X_MAX;H++) { for(V=0;V<GAP*1;V++) Write_Data_U16(0xf800); } for(H=0;H<X_MAX;H++) { for(V=GAP*1;V<GAP*2;V++) Write_Data_U16(0x07e0); } for(H=0;H<X_MAX;H++) { for(V=GAP*2;V<GAP*3;V++) Write_Data_U16(0x001f); } for(H=0;H<X_MAX;H++) { for(V=GAP*3;V<GAP*4;V++) Write_Data_U16(0xffe0); } for(H=0;H<X_MAX;H++) { for(V=GAP*4;V<GAP*5;V++) Write_Data_U16(0xf81f); } for(H=0;H<X_MAX;H++) { for(V=GAP*5;V<GAP*6;V++) Write_Data_U16(0x07ff); } for(H=0;H<X_MAX;H++) { for(V=GAP*6;V<GAP*7;V++) Write_Data_U16(0xffff); } for(H=0;H<X_MAX;H++) { for(V=GAP*7;V<GAP*8;V++) Write_Data_U16(0x0000); } } /*------------------------------------------------ д16λÊý¾Ýº¯Êý ------------------------------------------------*/ void Write_Data_U16(unsigned int y) { unsigned char m,n; m=y>>8; n=y; LCD_Write_Data(m); LCD_Write_Data(n); } /*------------------------------------------------ дָÁÊý ------------------------------------------------*/ void LCD_Write_Command(unsigned char u) { CS=0; RS=0; DataPort=u; RW=0; RW=1; CS=1; } /*------------------------------------------------ дÊý¾Ýº¯Êý ------------------------------------------------*/ void LCD_Write_Data(unsigned char u) { CS=0; RS=1; DataPort=u; RW=0; RW=1; CS=1; } WriteCom(a,b) { LCD_Write_Command(a); LCD_Write_Command(b); } WriteData(a,b) { LCD_Write_Data(a); LCD_Write_Data(b); } /*------------------------------------------------ ÑÓʱº¯Êý ------------------------------------------------*/ void delayms(unsigned int count) { int i,j; for(i=0;i<count;i++) { for(j=0;j<260;j++); } } /*------------------------------------------------ Òº¾§³õʼ»¯´úÂë ------------------------------------------------*/ void TFT_Initial(void) { // VCI=2.80V //************* Reset LCD Driver ****************// RES = 1; delayms(1); // delaymsms 1ms RES = 0; delayms(10); // delaymsms 10ms // This delaymsms time is necessary RES = 1; delayms(50); // delaymsms 50 ms // Synchronization after reset////////// //////////////////////////////////////////// LCD_Write_Command(0x11); //Exit Sleep delayms(100); LCD_Write_Command(0xD1); LCD_Write_Data (0x00); LCD_Write_Data (0x71); LCD_Write_Data (0x19); LCD_Write_Command(0xD0); LCD_Write_Data (0x07); LCD_Write_Data (0x01); LCD_Write_Data (0x08); LCD_Write_Command(0x36); LCD_Write_Data (0x48); LCD_Write_Command(0x3A); LCD_Write_Data (0x05); LCD_Write_Command(0xC1); LCD_Write_Data (0x10); LCD_Write_Data (0x10); LCD_Write_Data (0x02); LCD_Write_Data (0x02); LCD_Write_Command(0xC0); //Set Default Gamma LCD_Write_Data (0x00); LCD_Write_Data (0x35); LCD_Write_Data (0x00); LCD_Write_Data (0x00); LCD_Write_Data (0x01); LCD_Write_Data (0x02); LCD_Write_Command(0xC5); //Set frame rate LCD_Write_Data (0x04); LCD_Write_Command(0xD2); //power setting LCD_Write_Data (0x01); LCD_Write_Data (0x44); LCD_Write_Command(0xC8); //Set Gamma LCD_Write_Data (0x04); LCD_Write_Data (0x67); LCD_Write_Data (0x35); LCD_Write_Data (0x04); LCD_Write_Data (0x08); LCD_Write_Data (0x06); LCD_Write_Data (0x24); LCD_Write_Data (0x01); LCD_Write_Data (0x37); LCD_Write_Data (0x40); LCD_Write_Data (0x03); LCD_Write_Data (0x10); LCD_Write_Data (0x08); LCD_Write_Data (0x80); LCD_Write_Data (0x00); LCD_Write_Command(0x2A); LCD_Write_Data (0x00); LCD_Write_Data (0x00); LCD_Write_Data (X_MAX>>8); LCD_Write_Data (X_MAX); LCD_Write_Command(0x2B); LCD_Write_Data (0x00); LCD_Write_Data (0x00); LCD_Write_Data (Y_MAX>>8); LCD_Write_Data (Y_MAX); LCD_Write_Command(0x29); //display on LCD_Write_Command(0x2C); //display on delayms(100); } /*------------------------------------------------ º¯ÊýÃû³Æ:LCD_DefineDispWindow ¹¦ ÄÜ:¶¨ÒåÏÔʾ´°Ìå ²Î Êý:x0: ´°ÌåÖÐX×ø±êÖнÏСÕß x1: ´°ÌåÖÐX×ø±êÖнϴóÕß y0: ´°ÌåÖÐY×ø±êÖнÏСÕß y1: ´°ÌåÖÐY×ø±êÖнϴóÕß ·µ »Ø Öµ:ÎÞ ------------------------------------------------*/ static void LCD_SetPos(unsigned int x0,unsigned int x1,unsigned int y0,unsigned int y1) { WriteCom(0x00,0x2A); WriteData(x0>>8,x0); WriteData(x1>>8,x1); WriteCom(0x00,0x2B); WriteData(y0>>8,y0); WriteData(y1>>8,y1); WriteCom(0x00,0x2C); } `` |
|
相关推荐
6个回答
|
|
一般这种情况都是由于线路问题造成的,或是rs.rw.en设置错误,具体应该拿屏参来看
|
|
|
|
不是屏坏?我只有这些资料,程序时佩戴的。感觉是程序有问题, |
|
|
|
|
|
|
|
都不行,3.0;3.5;2.4;都试过了,初步估计是屏坏了,卸开后排线上有层嘿嘿的东西,不知道是不是里面的液体。找同学借了个2.2的先研究下。谢谢啦
|
|
|
|
摘星揽月111 发表于 2015-11-11 20:25 你好,我的也是这款屏幕,把例程下进去也是没反应,你现在搞定了吗 |
|
|
|
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
嵌入式学习-飞凌嵌入式ElfBoard ELF 1板卡-使用AHT20进行环境监测之AHT20传感器介绍
203 浏览 0 评论
761 浏览 0 评论
806 浏览 1 评论
基于瑞萨FPB-RA4E2智能床头灯项目——1编译环境搭建与点亮驱动ws2812全彩LED
743 浏览 0 评论
嵌入式学习-飞凌嵌入式ElfBoard ELF 1板卡-LCD显示图片编程示例之介绍mmap
1195 浏览 0 评论
【youyeetoo X1 windows 开发板体验】少儿AI智能STEAM积木平台
11807 浏览 31 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-27 21:55 , Processed in 0.579840 second(s), Total 51, Slave 44 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号