|
#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相關(guān)管腳
sbit rs=P1^4;
sbit en=P1^0;
//鍵盤定義
sbit K1=P3^4; //設(shè)置時間
sbit K3=P3^6; //減按鍵
sbit K2=P3^5; //加按鍵
sbit K4=P3^7; //設(shè)置半徑安全距離
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負跳變觸發(fā)
TMOD=0x01;//定時器工作于方式1
TH0=0x3c; //50ms
TL0=0xb0;
EA=1; //CPU開中斷總允許
ET0=1;//開定時中斷
EX0=1;//開外部INTO中斷
TR0=1;//啟動定時
}
/********液晶寫入指令函數(shù)與寫入數(shù)據(jù)函數(shù),以后可調(diào)用**************/
void write_1602com(uchar com)//****液晶寫入指令函數(shù)****
{
rs=0;//數(shù)據(jù)/指令選擇置為指令
P0=com;//送入數(shù)據(jù)
delay(1);
en=1;//拉高使能端,為制造有效的下降沿做準(zhǔn)備
delay(1);
en=0;//en由高變低,產(chǎn)生下降沿,液晶執(zhí)行命令
}
void write_1602dat(uchar dat)//***液晶寫入數(shù)據(jù)函數(shù)****
{
rs=1;//數(shù)據(jù)/指令選擇置為數(shù)據(jù)
P0=dat;//送入數(shù)據(jù)
delay(1);
en=1; //en置高電平,為制造下降沿做準(zhǔn)備
delay(1);
en=0; //en由高變低,產(chǎn)生下降沿,液晶執(zhí)行命令
}
//自定義字符集
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()//***液晶初始化函數(shù)****
{
Lcd_ram();
write_1602com(0x38);//設(shè)置液晶工作模式,意思:16*2行顯示,5*7點陣,8位數(shù)據(jù)
write_1602com(0x0c);//開顯示不顯示光標(biāo)
write_1602com(0x06);//整屏不移動,光標(biāo)自動右移
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需要用到的嗎
|
|