main.c

来自「89c51与ds1302代码显示时间的源程序」· C语言 代码 · 共 36 行

C
36
字号
#include <at89X52.h>
#include "ds1302new.h"
#include "LCD1602.h"

TDateTime CurrectValue; //定义一个结构体,用于存储日期时间信息
unsigned char *WeekStr[]={"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};

void main(void)
{	
	LCD_init();
	init_ds1302();
	P2_1=0;
	GetCurrentDateTime(&CurrectValue);
	CurrectValue.Year=7;
	CurrectValue.Month=10;
	CurrectValue.MonthDay=27;
	CurrectValue.WeekDay=7;
	CurrectValue.Hour=15;
	CurrectValue.Min=42;
	CurrectValue.Sec=0;
	SetDateTime(&CurrectValue);
	p=LCD_PutStr(" DS1302RealTimer \n",-1);
	p=LCD_PutStr("WWW.BQMCU.COM.CN \n",p);
	delay_nms(300);
	p=LCD_PutStr("",-1);
	while(1){
		GetCurrentDateTime(&CurrectValue);
		p=0;
		p=LCD_PutStr(CurrectValue.DateStr,p);
		p=LCD_PutStr(" ",p);
		p=LCD_PutStr(WeekStr[CurrectValue.WeekDay-1],p);
		p=LCD_PutStr("\n",p);
		p=LCD_PutStr(CurrectValue.TimeStr,p);
		}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?