这是一款TFT262万彩色液晶,控制器是9325,屏幕2.4寸,比他妈的12864爽多了,这叫一个色彩斑斓啊!想要什么颜色,只要写入相应的数字就在屏幕上显现出来,那还有什么比这个更令人高兴那?对于我来说,可喜可贺了,下一步就是SD卡配合TFT彩屏共同完成彩色图像的显示了,加油啊! 12月21日19:34分天津第四项目部!额,今天晚上还要去看工地!
- #include <reg52.h>
- #define uchar unsigned char
- #define uint unsigned int
- #define DATE P0
- sbit RS=P3^7;
- sbit RW=P3^6;
- sbit RES=P3^5;
- sbit CS=P3^4;
- sbit DB0=P0^0;
- sbit DB1=P0^1;
- sbit DB3=P0^3;
- sbit DB2=P0^2;
- sbit DB4=P0^4;
- sbit DB5=P0^5;
- sbit DB6=P0^6;
- sbit DB7=P0^7;
- void delay1ms(uint x) //延时程序
- { unsigned char a,b,c;
- uint z;
- for(z=x;z;z--)
- {
- for(c=8;c>0;c--)
- for(b=197;b>0;b--)
- for(a=2;a>0;a--);
- }
- }
- void write_date(uchar hight,uchar low) //定义搞八位字节和低八位字节写然后写入数据
- {
- CS=0;
- RS=1;
- DATE=hight;
- RW=0;
- RW=1;
- DATE=low;
- RW=0;
- RW=1;
- CS=1;
- }
- void write_cmd(uchar hight,uchar low )//定义搞八位字节和低八位字节写然后写入指令
- {
- CS=0;
- RS=0;
- DATE=hight;
- RW=0;
- RW=1;
- DATE=low;
- RW=0;
- RW=1;
- CS=1;
- }
- void wr_cmd_date(uint cmmd,uint datesh) //写入指令和相应的数据;
- {
- uchar g,d,g1,d1; /* 2010年12月21日与天津第四项目部终于做完了9325的TFT262万色彩色液晶,感觉比他妈的12864爽多了,
- 毕竟一个是黑白的一个是彩色的,呵呵,加油啊,下一步是组合SD卡和TFT液晶,让液晶显示彩色图片,加油吧!*/
-
-
- d=datesh;
- d=(d&0x00ff);
- g=(datesh>>8)&0x0ff;
-
-
- d1=cmmd;
- d1=(d1&0x00ff);
- g1=(cmmd>>8)&0x0ff;
-
- write_cmd(g1,d1 );
- write_date(g,d ) ;
- }
- void initTFT()//注意:这里是用的设置库,网络上多的很,感谢网络啊。
- {
- wr_cmd_date(0x0001,0x0100);
- wr_cmd_date(0x0002,0x0700);
- wr_cmd_date(0x0003,0x1030);
- wr_cmd_date(0x0004,0x0000);
- wr_cmd_date(0x0008,0x0207);
- wr_cmd_date(0x0009,0x0000);
- wr_cmd_date(0x000A,0x0000);
- wr_cmd_date(0x000C,0x0000);
- wr_cmd_date(0x000D,0x0000);
- wr_cmd_date(0x000F,0x0000);
- //power on sequence VGHVGL
- wr_cmd_date(0x0010,0x0000);
- wr_cmd_date(0x0011,0x0007);
- wr_cmd_date(0x0012,0x0000);
- wr_cmd_date(0x0013,0x0000);
- //vgh
- wr_cmd_date(0x0010,0x1290);
- wr_cmd_date(0x0011,0x0227);
- delay1ms(100);
- //vregiout
- wr_cmd_date(0x0012,0x001d); //0x001b
- delay1ms(100);
- //vom amplitude
- wr_cmd_date(0x0013,0x1500);
- delay1ms(100);
- //vom H
- wr_cmd_date(0x0029,0x0018);
- wr_cmd_date(0x002B,0x000D);
- //gamma
- wr_cmd_date(0x0030,0x0004);
- wr_cmd_date(0x0031,0x0307);
- wr_cmd_date(0x0032,0x0002);// 0006
- wr_cmd_date(0x0035,0x0206);
- wr_cmd_date(0x0036,0x0408);
- wr_cmd_date(0x0037,0x0507);
- wr_cmd_date(0x0038,0x0204);//0200
- wr_cmd_date(0x0039,0x0707);
- wr_cmd_date(0x003C,0x0405);// 0504
- wr_cmd_date(0x003D,0x0F02);
- //ram
- wr_cmd_date(0x0050,0x0000);
- wr_cmd_date(0x0051,0x00EF);
- wr_cmd_date(0x0052,0x0000);
- wr_cmd_date(0x0053,0x013F);
- wr_cmd_date(0x0060,0xA700);
- wr_cmd_date(0x0061,0x0001);
- wr_cmd_date(0x006A,0x0000);
- //
- wr_cmd_date(0x0080,0x0000);
- wr_cmd_date(0x0081,0x0000);
- wr_cmd_date(0x0082,0x0000);
- wr_cmd_date(0x0083,0x0000);
- wr_cmd_date(0x0084,0x0000);
- wr_cmd_date(0x0085,0x0000);
- //
- wr_cmd_date(0x0090,0x0010);
- wr_cmd_date(0x0093,0x0003);
- wr_cmd_date(0x0095,0x0110);
- wr_cmd_date(0x0097,0x0000);
- wr_cmd_date(0x0098,0x0000);
- wr_cmd_date(0x0007,0x0133);
- }
- void main ()
- {unsigned long a;
- delay1ms(30);
- CS=1;
- RES=0;
- delay1ms(150);
- RES=1;
- delay1ms(50);
- initTFT();
- for(a=76800;a;a--)
- {
-
- wr_cmd_date(0x0022,0x0000); //运行刷屏程序,经验证,刷屏时间大约在2S间,没法子,CPU毕竟是8位的!你让他?呵呵
-
-
-
- }
- while(1);
- }
复制代码
|