#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
#include "Data.h"
#include "DS1302.h"
#include "AT24C02.h"
sbit COUNT_IN=P3^2;
//定义1602相关管脚
sbit rs=P1^4;
sbit en=P1^0;
//键盘定义
sbit K1=P3^4; //设置时间
sbit K3=P3^6; //减按键
sbit K2=P3^5; //加按键
sbit K4=P3^7; //设置半径安全距离
sbit BEEP=P3^0;
uint count;
unsigned long Velocity,Mileage;
uchar code tab1[]={" / / : "}; //14/09/10 16:34 3
uchar code tab2[]={" 0.000km 00km/h"}; //000.000km 00km/h
uchar code tab3[]={"Wheel Radius cm"};
uchar code tab4[]={"Safe Speed km/h"};
uchar code tab5[]={"Sec : "};
uchar Mode=0;
uchar bike_set=0;
uchar a;
char RADIUS,SAFE_SPEED;
bit LED_SEC;
uchar before_sec;
//自定义字符
uchar code num[]={
0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,//1
0x1f,0x01,0x01,0x1f,0x10,0x10,0x1f,0x00,//2
0x1f,0x01,0x01,0x1f,0x01,0x01,0x1f,0x00,//3
0x11,0x11,0x11,0x1f,0x01,0x01,0x01,0x00,//4
0x1f,0x10,0x10,0x1f,0x01,0x01,0x1f,0x00,//5
0x1f,0x10,0x10,0x1f,0x11,0x11,0x1f,0x00,//6
0x1f,0x01,0x01,0x01,0x01,0x01,0x01,0x00,//7
};
void READS();
void SETS();
void delay(uint x)
{
uint i,j;
for(i=0;i<x;i++)
for(j=0;j<110;j++);
}
void init()
{
IT0=1; //INT0负跳变触发
TMOD=0x01;//定时器工作于方式1
TH0=0x3c; //50ms
TL0=0xb0;
EA=1; //CPU开中断总允许
ET0=1;//开定时中断
EX0=1;//开外部INTO中断
TR0=1;//启动定时
}
/********液晶写入指令函数与写入数据函数,以后可调用**************/
void write_1602com(uchar com)//****液晶写入指令函数****
{
rs=0;//数据/指令选择置为指令
P0=com;//送入数据
delay(1);
en=1;//拉高使能端,为制造有效的下降沿做准备
delay(1);
en=0;//en由高变低,产生下降沿,液晶执行命令
}
void write_1602dat(uchar dat)//***液晶写入数据函数****
{
rs=1;//数据/指令选择置为数据
P0=dat;//送入数据
delay(1);
en=1; //en置高电平,为制造下降沿做准备
delay(1);
en=0; //en由高变低,产生下降沿,液晶执行命令
}
//自定义字符集
void Lcd_ram()
{
uint i,j,k=0,temp=0x40;
for(i=0;i<7;i++)
{
for(j=0;j<8;j++)
{
write_1602com(temp+j);
write_1602dat(num[k]);
k++;
}
temp=temp+8;
}
}
void lcd_init()//***液晶初始化函数****
{
Lcd_ram();
write_1602com(0x38);//设置液晶工作模式,意思:16*2行显示,5*7点阵,8位数据
write_1602com(0x0c);//开显示不显示光标
write_1602com(0x06);//整屏不移动,光标自动右移
write_1602com(0x01);//清显示
write_1602com(0x80);//显示固定符号从第一行第1个位置之后开始显示
for(a=0;a<16;a++)
{
write_1602dat(tab1[a]);//向液晶屏写固定符号部分
}
write_1602com(0x80+0x40);//显示固定符号写入位置,从第2个位置后开始显示
for(a=0;a<16;a++)
{
write_1602dat(tab2[a]);//写显示固定符号
}
}
上面是前部分代码 想请教自定义字符里的
uchar code num[]={
0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,//1
0x1f,0x01,0x01,0x1f,0x10,0x10,0x1f,0x00,//2
0x1f,0x01,0x01,0x1f,0x01,0x01,0x1f,0x00,//3
0x11,0x11,0x11,0x1f,0x01,0x01,0x01,0x00,//4
0x1f,0x10,0x10,0x1f,0x01,0x01,0x1f,0x00,//5
0x1f,0x10,0x10,0x1f,0x11,0x11,0x1f,0x00,//6
0x1f,0x01,0x01,0x01,0x01,0x01,0x01,0x00,//7
};
和
void Lcd_ram()
{
uint i,j,k=0,temp=0x40;
for(i=0;i<7;i++)
{
for(j=0;j<8;j++)
{
write_1602com(temp+j);
write_1602dat(num[k]);
k++;
}
temp=temp+8;
}
}
是什么功能 那个备注1234567的是ds1302需要用到的吗
|