新手入门
- 积分
- 27
- 金钱
- 27
- 注册时间
- 2015-8-31
- 在线时间
- 0 小时
|
5金钱
#include <ADUC824.h>
#include <stdio.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
/****************Serial*************************/
sbit R_S=P1^1;//指令/数据选择信号
sbit RES=P1^2;//复位信号
sbit SCK=P1^0;//时钟信号
sbit SDA=P3^4;//串口输入
sbit C_S=P3^3;//片选
uchar code table[]={"h"};
/**********************************************/
void delay(uint ms) //延时部分
{
uchar j;
while(ms--)
{ for(j=0;j<=110;j++);} //20us=0.02ms//
}
/************Serial*************/
void WrateC(uchar com) //写命令
{
unsigned char data i,j;
C_S=0;
R_S=0;
SCK=0;
for(i=0;i<8;i++)
{
j=com;
SCK=0;
if(com&&0x80) SDA=1;
else SDA=0;
SCK=1;
com=j<<1;
}
R_S=1;
}
void WrateD(uchar dat) //写数据
{
unsigned char data i,j;
C_S=0;
R_S=1;
SCK=0;
for(i=0;i<8;i++)
{
j=dat;
SCK=0;
if(dat&&0x80) SDA=1;
else SDA=0;
SCK=1;
dat=j<<1;
}
R_S=0;
}
void ClearScreen()
{
uchar i, j;
for(i=0; i<8; i++)
{
WrateC(0xB0+i);
WrateC(0x10);
WrateC(0x00);
for(j=0; j<128; j++)
{
WrateD(0x00);
}
}
}
void ClearDisplay() //显示部分
{
C_S=0;
WrateC(0xb0);
WrateC(0x00);
WrateC(0x10);
WrateD(table[0]); //发送数据
delay(1000);
}
void LcdInit() //液晶初始化
{
C_S=0;
RES=1;
delay(10);//最少2um
RES=0;
delay(5);
RES=1;
delay(5);
WrateC(0xe2);//软件复位
WrateC(0xa2);//Bais set 显示偏压1/7
WrateC(0xa0);//ADC seg镜像选择 0xa0正常,0xA1左右镜像
WrateC(0xc8);//com output scan direction,com镜像选择 0xc0正常,0xC8上下镜像
/****Select internal resistor ratio****/
WrateC(0x2c);//内部电源管理
delay(5);
WrateC(0x2e);//三条指令间隔时间2um
delay(5);
WrateC(0x2f);//
delay(5);
/**************************************/
WrateC(0x80);//电压模式选择
WrateC(0x27);//电压调整寄存器高位 范围:0x21-0x27 ,值越大,显示效果越浓(底影越浓)
WrateC(0x1d);//电压调整寄存器低位 范围:0x00-0x3f
WrateC(0xaf);//显示开
WrateC(0x40);//从首行开始显示
// WrateC(0xb0);//从第一页开始显示
}
void main() //主函数
{
delay(50);
LcdInit();
ClearScreen();
while(1)
{
ClearDisplay();
}
}
|
最佳答案
查看完整内容[请看2#楼]
有个显示字符的驱动,你拿去试试。里面的SPI_ReadWriteByte改成你的写位函数就行了。
还有个中英文混合显示的,你要的再说。
|