打印

ra8835驱动,有兴趣的可以看看

[复制链接]
1952|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
csf860032|  楼主 | 2009-8-12 18:25 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
#include <mega16.h>  
#include <delay.h>
#include <spi.h>
  
#define LCD_BUS  PORTC      
#define _WR      PORTB.0     
#define _RD      PORTB.1     
#define _CS      PORTB.2     
#define AO       PORTB.3     
#define _RES     PORTB.4     
unsigned char CTAB1[25]={
0x53,0x75,0x50,0x50,0x6f,0x72,0x74,0x20,0x54,0x45,0x4c,0x3a,
0x30,0x35,0x37,0x31,0x2d,0x38,0x35,0x31,0x32,0x31,0x37,0x34,0x32};
//--------------写指令代码------------------------------
void Cmdwrite(unsigned char cmdcode)
{
_CS=0;
AO =1;
LCD_BUS=cmdcode;
_RD=1;
_WR=0;
_WR=1;
_CS=0;  
}
//--------------写数据或参数-----------------------------
void Datawrite(unsigned char wrdata)
{
_CS=0;
AO =0;
LCD_BUS=wrdata;
_RD=1;
_WR=0;
_WR=1;
_CS=0;
}  
//---------------写入数据-------------------------------
void Printstr(void)
{
unsigned char i;
Cmdwrite(0x42);
for(i=0;i<25;i++)
{
Datawrite(CTAB1[i]);  //写入数据  
}
}
//-------------写入字符串--------------------------------
/*void Printstr( unsigned char  *pstr)
{
Cmdwrite(0x42);
while(*pstr>0)
  {
  Datawrite(*pstr);
  pstr++;
  }
}*/  
//--------------整屏幕写入数据---------------------------
void Fullscreenfill(unsigned char low,unsigned char high, unsigned char fill_data)
{
unsigned char i,j;
Cmdwrite(0x46);
Datawrite(low);
Datawrite(high);
Cmdwrite(0x42);
for(i=0;i<240;i++)
   for(j=0;j<40;j++)
      Datawrite(fill_data);
}
//--------------模块初始化-------------------------------
void LCD_Initial()
{
_RES=0;
delay_ms(100);
_RES=1;
delay_ms(100);
Cmdwrite(0x40);
Datawrite(0x32);
Datawrite(0x87);
Datawrite(0x07);
Datawrite(0x27);
Datawrite(0x2b);
Datawrite(0xef);
Datawrite(0x28);
Datawrite(0x00);
Cmdwrite(0x44);
Datawrite(0x00);
Datawrite(0x00);
Datawrite(0x77);
Datawrite(0x00);
Datawrite(0x28);
Datawrite(0xef);
Datawrite(0x00);
Datawrite(0x50);
Cmdwrite(0x58);
Datawrite(0x55);
Cmdwrite(0x5b);
Datawrite(0x00);
Cmdwrite(0x5c);
Datawrite(0x00);
Datawrite(0x78);
Cmdwrite(0x5d);
Datawrite(0x07);
Datawrite(0x07);
Cmdwrite(0x4c);
Fullscreenfill(0x00,0x00,0x00);
Fullscreenfill(0x00,0x28,0x00);
Fullscreenfill(0x00,0x50,0x00);
Cmdwrite(0x59);
}
//================================================================
void main()
{
DDRB  =0xff;
PORTB = 0xff;
DDRC  =0xff;
PORTC = 0x00;
   
_RD=1;
_WR=1;
_CS=1;
AO =1;
LCD_BUS=0xff;
LCD_Initial();
Cmdwrite(0x46);
Datawrite(0x3d);
Datawrite(0x02);  
Printstr();  
Cmdwrite(0x46);
Datawrite(0x0a);
Datawrite(0x50);  
Printstr();
delay_ms(200);
while(1)
{}
}

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

8

主题

7

帖子

1

粉丝