c51实现万年历、温度与闹钟功能程序
sbit Bell_Out = P1 ^ 7;//闹钟管脚输出
sbit DQ = P2 ^ 1;//ds1820data
sbit clock_clk = P1 ^ 0;//ds1302_clk
sbit clock_dat = P1 ^ 1;//ds1302_dat
sbit clock_Rst = P1 ^ 2;//ds1302_Rst
#define Disp_On 0x3f //定义管脚的指令值
#define Disp_Off 0x3e
#define Col_Add 0x40
#define Page_Add 0xb8
#define Start_Line 0xc0
#define Lcd_Bus P0 //定义数据口
sbit Mcs = P3 ^ 5; //
sbit Scs = P3 ^ 6; //
sbit Enable = P1 ^ 5; //
sbit Di = P1 ^ 4; //
sbit RW = P1 ^ 3; //
sbit Lcd_Rst= P3 ^ 7; //
//键盘扫描
sbit Add_Key = P2 ^ 1;//加1键
sbit Dec_Key = P2 ^ 2;//减1键
sbit OK_Key = P2^ 3;//确定键
//24存储器
sbit SCL = P3 ^ 3;
sbit SDA = P3 ^ 4;
sbit WP = P3 ^ 2;
#define TRUE 1
#define FALSE 0
#define Delay2408_TIME 60 //经实验,不要小于50!否则可能造成时序混乱
//为了编程方便定义的位变量
sbit a0 = ACC ^ 0;
sbit a1 = ACC ^ 1;
sbit a2 = ACC ^ 2;
sbit a3 = ACC ^ 3;
sbit a4 = ACC ^ 4;
sbit a5 = ACC ^ 5;
sbit a6 = ACC ^ 6;
sbit a7 = ACC ^ 7;
bit flag, Bell_Swh,Hourb,Minb,Secb,Kgb;//闪烁标志位
bit sec=0,min=0,hour=0,year=0,mon=0,day=0,weekk=0; //闪烁标志位
unsigned char id,id2,d,e,S_1302,H_1302,H_2402,S_2402; //
//Function Definition 函数声明
void Delay(int num);
void Init_DS18B20(void);
unsigned char ReadOneChar(void);
void WriteOneChar(unsigned char dat);
unsigned int ReadTemperature(void);
void clock_out(unsigned char dd);
unsigned char clock_in(void);
unsigned char read_clock(unsigned char ord);
void write_clock(unsigned char ord, unsigned char dd);
void Disp(void);
void id_case1_key(void);
void id_case2_key(void);
void Set_time(unsigned char sel,bit sel_1);
void Timer0_Init(void);
void Init_1302(void);
void Set_Bell(unsigned char sel, bit sel_1);
//24系列
void Delay2408(unsigned int t);
void I2C_Start(void);
void I2C_Stop(void);
void SEND_0(void);
void SEND_1(void);
bit Check_Acknowledge(void);
void WriteI2CByte(unsigned char b)reentrant;
unsigned char ReadI2CByte(void)reentrant;
void Write_One_Byte(unsigned char addr,unsigned char thedata);
char Read_One_Byte(unsigned char addr);
//12864
void Delay12864(unsigned int t);
void write_com(unsigned char cmdcode);
void write_data(unsigned char Dispdata);
void frame(void);
void Clr_Scr(void);
void Disp_Img(unsigned char code *img);
void Disp_Digit(unsigned char pag,unsigned char col, unsigned char code *hzk);
void Disp_Chinese(unsigned char pag,unsigned char col, unsigned char code *hzk);
void Init_lcd(void);
//汉字库及数字符号库
unsigned char code nao[32]={0x00,0x00,0xF9,0x12,0x90,0x92,0x96,0xFA,0x92,0x92,0x92,0x12,0x02,0xFE,0x00,0x00,
0x00,0x00,0xFF,0x00,0x1F,0x00,0x00,0x7F,0x00,0x08,0x1F,0x40,0x80,0x7F,0x00,0x00};/*-- 文字: 闹 --*/
unsigned char code zhong[32]={0x40,0x30,0x2C,0xEB,0x28,0x28,0x00,0xF8,0x08,0x08,0xFF,0x08,0x08,0xF8,0x00,0x00,
0x01,0x01,0x01,0xFF,0x41,0x21,0x00,0x01,0x01,0x01,0xFF,0x01,0x01,0x01,0x00,0x00};/*-- 文字: 钟 --*/
unsigned char code she[32]={0x40,0x41,0xCE,0x04,0x00,0x80,0x40,0xBE,0x82,0x82,0x82,0xBE,0xC0,0x40,0x40,0x00,
0x00,0x00,0x7F,0x20,0x90,0x80,0x40,0x43,0x2C,0x10,0x10,0x2C,0x43,0xC0,0x40,0x00};/*-- 文字: 设 --*/
unsigned char code ding[32]={0x00,0x10,0x0C,0xA4,0x24,0x24,0x25,0xE6,0x24,0x24,0x24,0x24,0x14,0x0C,0x04,0x00,
0x40,0x20,0x18,0x07,0x08,0x10,0x20,0x7F,0x42,0x42,0x42,0x42,0x40,0x40,0x00,0x00};/*-- 文字: 定 --*/
unsigned char code kai[32]={0x40,0x42,0x42,0x42,0x42,0xFE,0x42,0x42,0x42,0x42,0xFE,0x42,0x42,0x42,0x42,0x00,
0x00,0x40,0x20,0x10,0x0C,0x03,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00};/*-- 文字: 开 --*/
unsigned char code guan[32]={0x00,0x10,0x10,0x10,0x11,0x1E,0x14,0xF0,0x10,0x18,0x17,0x12,0x18,0x10,0x00,0x00,
0x01,0x81,0x41,0x21,0x11,0x09,0x05,0x03,0x05,0x09,0x31,0x61,0xC1,0x41,0x01,0x00};/*-- 文字: 关 --*/
unsigned char code shit[32
c51万年历温度与闹 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)