#include "public.h"
#include "lcd12864.h"
#include "ds1302.h"
#include "string.h"
char num=0;
u8 DisplayData[8];
u8 DisData[6];
void delay(u16 i)
{
while(i--);
}
void datapros()
{
Ds1302ReadTime();
DisplayData[0] = TIME[2]/16+0x30;
DisplayData[1] = (TIME[2]&0x0f)+0X30;
DisplayData[2] = 0x2D;
DisplayData[3] = TIME[1]/16+0X30;
DisplayData[4] = (TIME[1]&0x0f)+0X30;
DisplayData[5] = 0x2D;
DisplayData[6] = TIME[0]/16+0X30;
DisplayData[7] = (TIME[0]&0x0f)+0X30;
}
void datapros2()
{
Ds1302ReadTime();
DisData[0] = TIME[6]/16+0x30; //年
DisData[1] = (TIME[6]&0x0f)+0X30;
DisData[2] = TIME[4]/16+0X30;
DisData[3] = (TIME[4]&0x0f)+0X30;
DisData[4] = TIME[3]/16+0X30;
DisData[5] = (TIME[3]&0x0f)+0X30;
}
void main()
{
Ds1302Init();
lcd12864_init();//LCD12864初始化
lcd12864_show_string(0,0,"万年历");//第1行字符串显示
//lcd12864_show_string(0,1,"2021年12月10日");//第2行字符串显示
lcd12864_show_string(0,2,"时间:");//第3行字符串显示
while(1)
{
datapros();
datapros2();
lcd12864_show_string(0,1,DisData);
lcd12864_show_string(1,1,"年");
lcd12864_show_string(2,1,&DisData[2]);
lcd12864_show_string(3,1,"月");
lcd12864_show_string(4,1,&DisData[4]);
lcd12864_show_string(5,1,"日");
lcd12864_show_string(0,3,DisplayData);//第4行字符串显示
lcd12864_show_string(4,3," ");//第4行字符串显示
}
}
|