⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nokia3310lcd.txt

📁 诺基亚3310LCD屏8051单片机源代码
💻 TXT
字号:
诺基亚 3310 LCD屏 基本资料:
 Nokia 3310 LCD, 84x48 pixels
The Nokia 3310 LCD is a nice small graphical LCD, suitable for a lot of various projects. 
The display is 38*35 mm, with an active display surface of 30*22 mm, and a 84*48 pixel resolution. 
The display is easy to interface, using standard SPI communication. A 1-10 uF electrolytic capacitor from VOUT to GND, is the only external component needed. 

* Logic supply voltage range VDD to VSS : 2.7 to 3.3 V 
* Low power consumption, suitable for battery operated systems 

#define uchar unsigned char 
#define uint unsigned int 
//可以改动端口 
sbit sclk=P2^0;//时钟 
sbit sdin=P2^1; //数据 
sbit dc=P2^2;//1写数据,0写指令 
sbit sce=P2^3;//片选 
sbit res=P2^4;//复位,0复位 

void write_byte(uchar datatemp,bit mod)//写一字节 mod=0,命令模式 通用 
{ 
uchar i=8; 
sce=0; 
dc=mod; 
while (i--) 
{ 
if (datatemp&0x80){sdin=1;} 
else {sdin=0;} 
sclk=0; 
sclk=1; 
datatemp<<=1; 
} 
dc=1; 
sce=1; 
sdin=1; 
} 

void init(void) //初始化 通用 
{ 
res=0; 
Adelay(10); 
res=1; 
sce=1; 
sdin=1; 
sclk=1; 
write_byte(0x21,0);//初始化Lcd,功能设定使用扩充指令 
write_byte(0xd5,0);//设定液晶偏置电压(高--低) 
write_byte(0x20,0);//使用基本指令 
write_byte(0x0C,0);//设定显示模式,正常显示 
} 

void setadd(uchar a,uchar d)//设定地址 
{ 
write_byte((a|0x80),0);//设定x坐标 
write_byte((d|0x40),0);//设定y坐标 
} 

void clr()//清屏 
{ 
uchar t,k; 
uint d; 
d=0; 
// setdd(0,0); 
for(t=0;t<6;t++) 
{ 
for(k=0;k<84;k++) 
{ 
setadd(k,t); 
write_byte(0,1); 
d=d+1; 
if(d>504)d=d-504; 
} 
} 
} 

//写汉字 
void WriteCh(uchar *p,char x0,char x1,char y0,char y1,char z0) 
//*p是数组字模,x0是横向初始坐标,x1横向结束坐标,x(0~84) 
//y0是纵向初始坐标,y1纵向结束坐标,y(0~5) z0数组长度 
{ 
unsigned char z,x,y; 
for(x=x0;x<x1;x++) 
{ 
for(y=y0;y<y1;y++) 
{ 
setadd(x,y); ///定位 
write_byte(*p,1); 
Adelay(4); 
p++; //写下一位 
z++; //数组长度 
if(z==z0) 
{ 
y0+=2; 
//n+=2; 
z=0; 
} 
} 
} 
} 

//写数字 
void WriteDa(uchar num,char x0,char x1,char y0,char y1,char z0) 
{ 
unsigned char z=0,x,y; 
for(x=x0;x<x1;x++) 
{ 
for(y=y0;y<y1;y++) 
{ 
setadd(x,y); ///定位 
write_byte(dal3[num][z],1); 
Adelay(4); 
z++; 
if(z==z0) 
{ 
y0+=2; 
z=0; 
} 
} 
} 
} 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -