📄 3310.c
字号:
#include <reg52.h>
#include <intrins.h>
#include <dat.h>
#include <ad.h> //水平寻址下高位
#define uchar unsigned char
#define uint unsigned int
sbit sclk=P0^7;
sbit sdin=P0^6;
sbit dc =P0^5;
sbit sce =P0^4;
sbit res =P0^0;
/*往LCD3310写指令,或写数据*/
void lcd3310_wr(uchar com,bit k)
{
uchar i;
sce=0;
dc=k;
for(i=0;i<7;i++)
{
sclk=0;
if(com&0x80)
sdin=1;
else
sdin=0;
com<<=1;
sclk=1;
}
sclk=0;
if(com&0x80)
sdin=1;
else
sdin=0;
dc=k;
sclk=1;
sce=1;
}
/*LCD3310清屏*/
void lcd_clc()
{
uint i;
lcd3310_wr(0x40,0);
lcd3310_wr(0x80,0);
for (i=0; i<504; i++)
lcd3310_wr(0,1); //即往ram中每个单位都写入0
}
/*LCD3310初始化*/
void lcd_init()
{
// res=0;
// _nop_();
res=1;
sce=0;
lcd3310_wr(0x20,0); /*功能设置:芯片活动,水平寻址,使用基本指令集*/
lcd3310_wr(0x0c,0); /*显示配置:0x00空白,0x0a普通模式,0x09开所有显示段,0x0b反转映像模式*/
lcd3310_wr(0xcf,0); /*温度控制:0x04 V_lcd温度系数0,0x05 系数1,0x06 系数2,0x07 系数3*/
lcd3310_wr(0xb7,0);
lcd_clc();
}
/*设置坐标*/
void setxy(uchar x,uchar y) //输入范围:0<=x<=5; 0<=y<=83
{
lcd3310_wr(0x40|x,0);
lcd3310_wr(0x80|y,0);
}
/*在指定位置写入一个字符*/
void wr_char(uchar x,uchar y,uchar ch)
{
uchar i;
setxy(x,y);
ch-=32;
for(i=0;i<6;i++)
lcd3310_wr(tbl[ch][i],1);
}
/*从指定位置开始写入一个字符串*/
void wr_string(uchar x,uchar y,uchar *str)
{
uchar i,temp;
setxy(x,y);
while(*str)
{
temp=(*str)-32;
for(i=0;i<6;i++)
lcd3310_wr(tbl[temp][i],1);
str++;
}
}
/*在指定位置写入一个汉字(12点阵)*/
void wr_chinese(uchar x,uchar y,const uchar *chinese) //参数chinese[]为汉字摸
{
uchar i;
setxy(x,y); //写汉字的上半部
for(i=0;i<12;i++)
{
lcd3310_wr(*chinese,1);
chinese++;
}
setxy(x+1,y);
for(i=0;i<12;i++) //写汉字的下半部
{
lcd3310_wr(*chinese,1);
chinese++;
}
}
/*写一组汉字*/
void wr_mulchinese(uchar x,uchar y,const uchar *chinese,uchar count) //count为汉字个数
{
uchar i;
for(i=0;i<count;i++)
{
wr_chinese(x,y,chinese);
y+=12;
// x--;
chinese+=24;
}
}
/*在指定位置开始写入图片 */
void draw_map(uchar x,uchar y,uchar *map,
uchar kuan,uchar gao)
{
uchar i,n,row;
if(gao%8==0)
row=gao/8;
else
row=gao/8+1;
for(n=0;n<row;n++)
{
setxy(x,y);
for(i=0;i<kuan;i++)
{
lcd3310_wr(*map,1);
map++;
}
x++;
}
}
/*用于延时n毫秒*/
void delay(uint n)
{
uchar m;
uint i;
for(i=0;i<n;i++)
for(m=0;m<200;m++);
}
void drawline()
{
uchar i;
wr_string(0,0,"35^C");
for(i=24;i<84;i++)
lcd3310_wr(0x10,1);
wr_string(2,0,"15^C") ;
for(i=24;i<84;i++)
lcd3310_wr(0x08,1);
}
void main()
{
//{0x00,0x00,0x0f,0x09,0x09,0x0f}, //度(温度)
uchar i='0';
uchar k[6]={0x00,0x00,0x0f,0x09,0x09,0x0f};
lcd_init();
drawline();
// wr_mulchinese(3,0,wendu[0],5);
// wr_mulchinese(5,0,zhuansu[0],5);
wr_string(3,0,"CurTemp:");
wr_string(4,0,"CurRev:1000rad/min");
while(1)
{
wr_char(3,54,i);
wr_string(3,72,"^C");
delay(1000);
i++;
if(i>=10)
i=0;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -