📄 dgl.bak
字号:
#include <reg52.h>
sbit CS=P1^0;
sbit RES=P1^1;
sbit A0=P1^2;
sbit SCL=P1^3;
sbit SI=P1^4;
void Delay(unsigned int i)
{
unsigned int c;
while(i--)
{
c=1000 ;
while(c--);
}
}
void SpisendData(char c)
{
unsigned char i;
CS=0;
A0=1;
for(i=0x80;i>0;i=i>>1)
{
SCL=0;
SI=(i&c);
SCL=1;
}
CS=1;
}
void SpisendCode(char c)
{
unsigned char i;
CS=0;
A0=0;
for(i=0x80;i>0;i=i>>1)
{
SCL=0;
SI=(i&c);
SCL=1;
}
CS=1;
}
void LcdInitial()
{
RES=0;
Delay(30);
RES=1;
SpisendCode(0xae);Delay(1); //display off也是reset后默认的
SpisendCode(0xa6);Delay(1); //display normal也是reset后默认的
SpisendCode(0xa4);Delay(1); //full display 也是reset后默认的
SpisendCode(0xc4);Delay(1); //Common Output Status Select,default:normal
SpisendCode(0xa0);Delay(1); //Column Address Set Direction:default:normal
SpisendCode(0x66);Delay(1); //mode and dummy perial select:00,also default
SpisendData(0x00);Delay(1);
SpisendCode(0x39);Delay(1); //Gray-scale Pattern Set
SpisendData(0x01);Delay(1); //选白色
SpisendCode(0x6d);Delay(1); //Display Line Number Set
SpisendData(0x13);Delay(1); //total 81 lines,also default,xxxxxxxxxxxxxxx
SpisendData(0x00);Delay(1); //start line
SpisendCode(0xe7);Delay(1); // MLS drive selection
SpisendData(0x0b);Delay(1); //
SpisendCode(0x36);Delay(1); //nline inverted:n=4,also default;
SpisendData(0x00);Delay(1);
SpisendCode(0xe5);Delay(1);//n-line Inverting Drive ON/OFF,default is off,now is on
SpisendCode(0x5f);Delay(1); //frequence select
SpisendData(0x08);Delay(1); //not the defalut,fcl=171khz,ffr=81hz
SpisendCode(0xab);Delay(1); //os on
SpisendCode(0x2b);Delay(1); //adjust v3
SpisendData(0x07);Delay(1); //v3:9~16
SpisendCode(0x81);Delay(1); //v3 volume
SpisendCode(0x4e);Delay(1); //Temperature Gradient Set :use default
SpisendData(0x00);Delay(1);
SpisendCode(0x28);Delay(1); //Thermal sensor ON/OFF:is off
SpisendData(0x7f);Delay(1); //alfa=128?127
SpisendCode(0xa2);Delay(1); //lcd bias
SpisendData(0x00);Delay(1); // 1/8
SpisendCode(0x25);Delay(1); //power control,mode set
SpisendData(0x04);Delay(1);
SpisendData(0x06);Delay(1);
SpisendData(0x07);Delay(1);
}
void main()
{
char i=255,a=2;
LcdInitial();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -