杭州清达光电技术有限公司

主营:液晶模块,OLED显示模块,LCM,超低温液晶,军工显示屏,OLED显示屏,串口显示屏,彩屏模组,耐高温高湿显示屏,带字库液晶,RS232显示屏,UART显示屏

  • 黄金会员
  • 8
您现在的位置:杭州清达光电技术有限公司首页 > 7寸彩屏RA8875控制器驱动代码例程
VIP会员 8
  • 经营模式:生产型
  • 所在地区:浙江 - 杭州
  • 企业类别:私营有限责任公司
公司相册
站内搜索
7寸彩屏RA8875控制器驱动代码例程

7寸彩屏RA8875控制器驱动代码例程

杭州佳显科技有限公司生产的7寸TFT模组,带中文字库,触摸屏可选,3.3V,可以直接单片机驱动,采用RA8875控制器,方便单片机用户,8位并口/16位并口可选,SPI串口可选。


测试代码如下:

#include<>
#include<>
#include<>
#include<>
#define uchar unsigned char
#define uint unsigned int
#define ulong unsigned long
sbit x=P3^2;
#define data P1
sbit rs = P3^0;
sbit wr = P3^1;
sbit rd = P3^3;
sbit cs = P3^4;
sbit rest = P3^5;
#define WD 800 /* 显示区宽度 */
#define HD 480 /* 显示区高度 */
#define clear 0x00 /* Clear Display */
#define time 400 /* 1000延时 1.03895500 s */
#define time1 300 /* 1000延时 1.03895500 s */
#define color_brown 0x40c0
#define color_black 0x0000
#define color_white 0xffff
#define color_red 0xf800
#define color_green 0x07e0
#define color_blue 0x001f
#define color_yellow color_red|color_green
#define color_cyan color_green|color_blue
#define color_purple color_red|color_blue
/********* 时间延时程序 *********/
void delay(uint t) /* 1.02500 ms */
{ uint i,j;
for(i=t;i>0;i--)
for(j=125;j>0;j--);
}
void delay2(uint t) /* 1.02500 ms */
{ uint i;
for(i=t;i>0;i--)
_nop_();
}
/******** 读“指令”程序 ********/
uchar read_com(void)
{ uchar temp;
temp=0xff;
cs=0;
rs=1;
wr=1;
rd=0;
temp=data;
rd=1;
cs=1;
return temp;
}
/********判忙程序 ********/
void busy()
{
uchar temp;
do{
temp=read_com();
}while(temp&0x80);
// while(WAIT==0);
}
/******** 写“指令”程序 ********/
void write_com(uchar com)
{ busy();
data=0xff;
cs=0;
rs=1;
rd=1;
data=com;
wr=0;
wr=1;
cs=1;
}
/******** 写“数据”程序 ********/
void write_data(uchar dat)
{ busy();
data=0xff;
cs=0;
rs=0;
rd=1;
data=dat;
wr=0;
wr=1;
cs=1;
}
/******** 写“指令数据”程序 *********/
void write_comdat(uchar com,uchar dat)
{ write_com(com);
write_data(dat);
}
/******* 读“数据”程序 ********/
uchar read_data(void)
{ uchar temp;
busy();
cs=0;
rs=0;
wr=1;
rd=0;
temp=data;
rd=1;
cs=1;
return temp;
} //*/
/******** 工作窗口设置程序 ********/
void active_window(uint row0,uint row1,uint col0,uint col1)
{
write_comdat(0x30,col0); //Horizontal Start Point
write_comdat(0x31,col0>>8);
write_comdat(0x32,row0); //Vertical Start Point
write_comdat(0x33,row0>>8);
write_comdat(0x34,col1); //Horizontal End Point
write_comdat(0x35,col1>>8);
write_comdat(0x36,row1); //Vertical End Point
write_comdat(0x37,row1>>8);
}
/******** 卷动窗口设置程序 ********/
void scroll_window(uint row0,uint row1,uint col0,uint col1)
{
write_comdat(0x38,col0); //Horizontal Start Point
write_comdat(0x39,col0>>8);
write_comdat(0x3a,row0); //Vertical Start Point
write_comdat(0x3b,row0>>8);
write_comdat(0x3c,col1); //Horizontal End Point
write_comdat(0x3d,col1>>8);
write_comdat(0x3e,row1); //Vertical End Point
write_comdat(0x3f,row1>>8);
}
/******** 卷动偏移量设置程序 ********/
void scroll_offset(uint row,uint col)
{
write_comdat(0x24,col); //Horizontal offset
write_comdat(0x25,col>>8);
write_comdat(0x26,row); //Vertical offset
write_comdat(0x27,row>>8);
}
/******** 浮动窗口设置程序 ********/
void floating_window(uint row0,uint col0,uint height,uint width,uint row1,uint col1)
{
write_comdat(0xD0,col0); //Start Address XA:Destination
write_comdat(0xD1,col0>>8);
write_comdat(0xD2,row0); //Start Address YA:Destination
write_comdat(0xD3,row0>>8);
write_comdat(0xD4,width); //Width
write_comdat(0xD5,width>>8);
write_comdat(0xD6,height); //Height
write_comdat(0xD7,height>>8);
write_comdat(0xD8,col1); //Display X Address:Source
write_comdat(0xD9,col1>>8);
write_comdat(0xDA,row1); //Display Y Address:Source
write_comdat(0xDB,row1>>8);
}
/******** 字体(内部)设置程序 ********/
void font_in_set(void)
{
write_comdat(0x40,0x80);
write_comdat(0x44,0x00);
write_comdat(0x21,0x00);
write_comdat(0x22,0x00);
write_comdat(0x29,0x00);
write_comdat(0x2E,0x00);
write_comdat(0x2F,0x00);
}
/******** 字体(外部)设置程序 ********/
void font_ex_set(void)
{
write_comdat(0x44,0x00);
write_comdat(0x20,0x00);
write_comdat(0x21,0x20);
write_comdat(0x22,0x00);
write_comdat(0x22,0x00);
write_comdat(0x29,0x0F);
write_comdat(0x2E,0x00);
write_comdat(0x2F,0x81);
}
/******** 字体地址程序 ********/
void font_position(uint row,uint col)
{
write_comdat(0x2A,(uchar)(col)); //Horizontal Position
write_comdat(0x2B,(uchar)(col>>8));
write_comdat(0x2C,(uchar)(row)); //Vertical Position
write_comdat(0x2D,(uchar)(row>>8));
}
/******** 内存写入地址程序 ********/
void memory_write_position(uint row,uint col)
{
write_comdat(0x46,(uchar)(col)); //Horizontal Position
write_comdat(0x47,(uchar)(col>>8));
write_comdat(0x48,(uchar)(row)); //Vertical Position
write_comdat(0x49,(uchar)(row>>8));
}
/******** 内存读取地址程序 ********/
void memory_read_position(uint row,uint col)
{
write_comdat(0x4A,col); //Horizontal Position
write_comdat(0x4B,col>>8);
write_comdat(0x4C,row); //Vertical Position
write_comdat(0x4D,row>>8);
}
/******** BTE背景色前景色设置程序 ********/
void back_fore_color(uint color_b,uint color_f)
{
write_comdat(0x60,(uchar)(color_b>>11)); //背景色
write_comdat(0x61,(uchar)(color_b>>5));
write_comdat(0x62,(uchar)(color_b));
write_comdat(0x63,(uchar)(color_f>>11)); //前景色
write_comdat(0x64,(uchar)(color_f>>5));
write_comdat(0x65,(uchar)(color_f));
}
/********倍频设置程序********/
void PLL(void)
{ write_comdat(0x88,0x0a);
write_comdat(0x89,0x02);
}
/******** 清屏程序********/
void clr(void)
{
active_window(0,HD-1,0,WD-1); //工作窗口
write_comdat(0x8E,0x80); //清除工作窗口
}
/******** 全屏(文本)显示程序********/
void fill_txt(uchar dat)
{ uint i;
font_position(0,0); //字体地址
write_com(0x02); //写数据
for(i=0;i<WD/8*HD/16;i++)
write_data(dat);
}
/******** 全屏(图形)显示程序********/
void fill_graph(uint x,uint y,uint k,uchar dat)
{ ulong i;
memory_write_position(x,y); //内存地址
write_com(0x02); //写数据
for(i=0;i<WD*k;i++)
write_data(dat);
}
/******** 字符(文本)显示程序 ********/
void chhzes_txt(uint x,uint y,uchar *s)
{
font_position(x,y); //字体地址
write_com(0x02); //写数据
while(*s!='\0')
write_data(*s++);
}
/******** 建立CGRAM自定义字符程序********/
void CGRAM_set(uchar *s,uchar k)
{ uchar i,j;
write_comdat(0x40,0x00); //图形模式
write_comdat(0x21,0x00);
write_comdat(0x41,0x04);
for(j=0;j<k;j++)
{ write_comdat(0x23,0x00+j); //CGRAM No
write_com(0x02); //写数据
for(i=0;i<16;i++)
write_data(*s++);
}
}
/******** 显示CGRAM自定义字符程序********/
void CGRAM_disp(uint x,uint y,uchar k,uchar cod)
{ uchar i;
write_comdat(0x40,0x80); //文本模式
write_comdat(0x21,0xa0);
write_comdat(0x41,0x00);
font_position(x,y); //字体地址
write_com(0x02); //写数据
for(i=0;i<k;i++)
write_data(cod+i);
}
/******** 画直线或矩形程序 ********/
/***** l_s=0:直线; l_s=1:矩形 *****/
void draw_line_square(uint x1,uint x2,uint y1,uint y2,uchar l_s)
{
write_comdat(0x91,(uchar)(y1)); //Horizontal Start Address
write_comdat(0x92,(uchar)(y1>>8));
write_comdat(0x93,(uchar)(x1)); //Vertical Start Address
write_comdat(0x94,(uchar)(x1>>8));
write_comdat(0x95,(uchar)(y2)); //Horizontal End Address
write_comdat(0x96,(uchar)(y2>>8));
write_comdat(0x97,(uchar)(x2)); //Vertical End Address
write_comdat(0x98,(uchar)(x2>>8));
if(l_s==0) //画直线
{ write_comdat(0x90,0x80); //Start
write_comdat(0x90,0x00); //End
}
else //画矩形
{ write_comdat(0x90,0x90); //Start,unfill
write_comdat(0x90,0x10); //End
}
}
void draw_fill_square(uint x1,uint x2,uint y1,uint y2)
{
write_comdat(0x91,(uchar)(y1)); //Horizontal Start Address
write_comdat(0x92,(uchar)(y1>>8));
write_comdat(0x93,(uchar)(x1)); //Vertical Start Address
write_comdat(0x94,(uchar)(x1>>8));
write_comdat(0x95,(uchar)(y2)); //Horizontal End Address
write_comdat(0x96,(uchar)(y2>>8));
write_comdat(0x97,(uchar)(x2)); //Vertical End Address
write_comdat(0x98,(uchar)(x2>>8));
write_comdat(0x90,0xb0); //Start,fill
write_comdat(0x90,0x30); //End
}
/******** 画圆程序 ********/
void draw_circle(uint x,uint y,uint r)
{
write_comdat(0x99,(uchar)(y)); //Horizontal Address
write_comdat(0x9a,(uchar)(y>>8));
write_comdat(0x9b,(uchar)(x)); //Vertical Address
write_comdat(0x9c,(uchar)(x>>8));
write_comdat(0x9d,(uchar)(r)); //Center Address
write_comdat(0x90,0x40); //开始画圆,不填充
write_comdat(0x90,0x00); //结束画圆
delay(time/2);
write_comdat(0x90,0x60); //Start,fill
write_comdat(0x90,0x20); //End
}
/******** 画椭圆或圆角矩形程序 ********/
/**** e_cs=0:椭圆; e_cs=1:圆角方形 ****/
void draw_ellipse_csquare(uint x,uint y,uint l,uint s)
{
write_comdat(0xa1,(uchar)(l)); //Long axis
write_comdat(0xa2,(uchar)(l>>8));
write_comdat(0xa3,(uchar)(s)); //Short axis
write_comdat(0xa4,(uchar)(s>>8));
write_comdat(0xa5,(uchar)(y)); //Center Horizontal Address
write_comdat(0xa6,(uchar)(y>>8));
write_comdat(0xa7,(uchar)(x)); //Center Vertical Address
write_comdat(0xa8,(uchar)(x>>8));
write_comdat(0xa0,0x80); //Start,Unfill
write_comdat(0xa0,0x80); //End
delay(time/2);
write_comdat(0xa0,0xc0); //Start,fill
write_comdat(0xa0,0x40); //End
}
/******** 画圆角方形程序 ********/
void draw_circle_square(uint x1,uint x2,uint y1,uint y2,uint l,uint s)
{
write_comdat(0x91,(uchar)(y1)); //Horizontal Start Address
write_comdat(0x92,(uchar)(y1>>8));
write_comdat(0x93,(uchar)(x1)); //Vertical Start Address
write_comdat(0x94,(uchar)(x1>>8));
write_comdat(0x95,(uchar)(y2)); //Horizontal End Address
write_comdat(0x96,(uchar)(y2>>8));
write_comdat(0x97,(uchar)(x2)); //Vertical End Address
write_comdat(0x98,(uchar)(x2>>8));
write_comdat(0xa1,(uchar)(l)); //Long axis
write_comdat(0xa2,(uchar)(l>>8));
write_comdat(0xa3,(uchar)(s)); //Short axis
write_comdat(0xa4,(uchar)(s>>8));
write_comdat(0xa0,0xa0); //Start,Unfill
write_comdat(0xa0,0x20); //End
delay(time/2);
write_comdat(0xa0,0xe0); //Start,fill
write_comdat(0xa0,0x60); //End
}
/******** 画三角形程序 ********/
void draw_triangle(uint x1,uint y1,uint x2,uint y2,uint x3,uint y3)
{
write_comdat(0x91,(uchar)(y1)); //Point0 Horizontal Address
write_comdat(0x92,(uchar)(y1>>8));
write_comdat(0x93,(uchar)(x1)); //Point0 Vertical Address
write_comdat(0x94,(uchar)(x1>>8));
write_comdat(0x95,(uchar)(y2)); //Point1 Horizontal Address
write_comdat(0x96,(uchar)(y2>>8));
write_comdat(0x97,(uchar)(x2)); //Point1 Vertical Address
write_comdat(0x98,(uchar)(x2>>8));
write_comdat(0xa9,(uchar)(y3)); //Point2 Horizontal Address
write_comdat(0xaa,(uchar)(y3>>8));
write_comdat(0xab,(uchar)(x3)); //Point2 Vertical Address
write_comdat(0xac,(uchar)(x3>>8));
write_comdat(0x90,0x81); //Start,Unfill
write_comdat(0x90,0x01); //End
delay(time/2);
write_comdat(0x90,0xa1); //Start,fill
write_comdat(0x90,0x21); //End
}
void external_int()interrupt 0 //using 1
{
do{x=1;delay(10);}
while(x==1);
delay(10);
}
/******** 初始化程序 ********/
void set()
{
delay(100);
write_comdat(0x01,0x00); //Display OFF
PLL(); //倍频设置
write_comdat(0x04,0x81);
write_comdat(0x05,0x00);
// write_comdat(0x06,0x03); //Serial Flash/ROM CLK Setting
write_comdat(0x10,0x00);
write_comdat(0x14,0x63);
write_comdat(0x15,0x00);
write_comdat(0x16,0x03); //Horizontal Non-Display Period
write_comdat(0x17,0x03); //HSYNC Start Position
write_comdat(0x18,0x0b); //HSYNC Pulse Width
write_comdat(0x19,0xdf); //LCD Vertical Display Height:HD-1=01DFH
write_comdat(0x1A,0x01);
write_comdat(0x1B,0x20); //LCD Vertical Non-Display Period
write_comdat(0x1C,0x00);
write_comdat(0x1D,0x16); //VSYNC Start Position
write_comdat(0x1E,0x00);
write_comdat(0x1F,0x01); //VSYNC Pulse Width
write_comdat(0x20,0x00); //单图层
write_comdat(0x01,0x80); //82H:Display ON 、82H:睡眠模式
clr(); //清屏
}
/********* 主函数 *********/
void main()
{
EA=1; //中断总允许
IT0=0; //设置外部中断INT0为电平触发方式,低电平有效
EX0=1;//外部中断INT0允许(INT0使能)
set();
while(1)
{
write_comdat(0x20,0x00); //单图层
write_comdat(0x41,0x00); //00:写入图层一;01:写入图层二
write_comdat(0x40,0x80); //文本模式
active_window(0,HD-1,0,WD-1); //工作窗口
back_fore_color(color_red,color_white); //背景色、前景色
write_comdat(0x8e,0x80);
write_comdat(0x8A,0x89); //PWM控制
write_comdat(0x8B,0x8f);
clr(); //清屏
write_comdat(0x05,0x08);
write_comdat(0x06,0x03);
font_ex_set(); //外部CGROM、字体16
write_comdat(0x22,0x0f); //字体大小:2倍
chhzes_txt(100,70,'杭州佳显科技有限公司');
chhzes_txt(250,200,'7 INCH TFT ');
delay(10*time);
write_comdat(0x22,0x05); //字体大小:1倍
clr(); //清屏
chhzes_txt(20,32,'7寸TFT彩色液晶模块,内置RA8875控制器,支持文字与绘图模式双图层显示;内置中英文字库和存储FLASH,支持快速存取图片;'
'8-bit或16-bit的8080并口,SPI串口可选择;内建几何图形加速引擎,提供使用者透过简单的设定轻松画出直线、矩形、圆形和椭圆的几何图形。'
'为了贴近终端始用者的应用,整合了强大的功能,如画面卷动功能、显示浮动窗口、图形Pattern 及文字放大等功能,可大量节省使用者软件开'
'发的时间,并提升MCU软件的执行效率。');
delay(10*time);
write_comdat(0x20,0x00); //单图层
write_comdat(0x41,0x00); //00:写入图层一;01:写入图层二
write_comdat(0x40,0x00); //图形模式
//彩色条纹显示///
clr(); //清屏
back_fore_color(color_red,color_red); //背景色、前景色
draw_fill_square(0,479,0,103);
back_fore_color(color_red,color_green); //背景色、前景色
draw_fill_square(0,479,104,207);
back_fore_color(color_red,color_blue); //背景色、前景色
draw_fill_square(0,479,208,311);
back_fore_color(color_red,color_yellow); //背景色、前景色
draw_fill_square(0,479,312,415);
back_fore_color(color_red,color_purple); //背景色、前景色
draw_fill_square(0,479,416,519);
back_fore_color(color_red,color_black); //背景色、前景色
draw_fill_square(0,479,520,623);
back_fore_color(color_red,color_white); //背景色、前景色
draw_fill_square(0,479,624,727);
back_fore_color(color_red,color_cyan); //背景色、前景色
draw_fill_square(0,479,728,799);
delay(10*time);
}
}

需要详细资料或者问题可加微信联系!

免责声明:以上信息由会员自行提供,内容的真实性、准确性和合法性由发布会员负责。一步电子网(www.kuyibu.com)对此不承担任何责任。
友情提醒:为规避购买风险,建议您在购买相关产品时,优先选择一步电子网(www.kuyibu.com)VIP会员

杭州清达光电技术有限公司 电话:86-0571-89902095 传真:86-0571-89902095
地址:浙江 - 杭州 杭州市余杭区良渚街道博园路1号杭州电子市场西区2楼2A001(门市部)
技术支持:一步电子网  管理商铺入口

声明:以上所展示的信息由企业自行提供,内容的真实性、准确性和合法性由发布企业负责。一步电子网对此不承担任何保证责任。

金瓶儿 <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <文本链> <文本链> <文本链> <文本链> <文本链> <文本链>