下方是我的程序:
#include "led.h"
#include "delay.h"
#include "key.h"
#include "sys.h"
#include "lcd.h"
#include "usart.h"
#include "usmart.h"
#include "rtc.h"
int main(void)
{
int show_year = 2019;
int show_mouth = 7;
int show_date = 1;
int si_key1 = 0;
u8 t=0;
vu8 key=0;
delay_init();
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
uart_init(115200);
LED_Init();
LCD_Init();
KEY_Init();
usmart_dev.init(SystemCoreClock/1000000); //3õê¼»ˉUSMART
RTC_Init();
POINT_COLOR=BLACK;
LCD_ShowString(170,400,300,16,16,"Only days left");
POINT_COLOR=BLUE;
LCD_ShowString(60,130,200,16,16," - - ");
LCD_ShowString(60,162,200,16,16," : : ");
while(1)
{
key=KEY_Scan(0);
if(key)
{
switch(key)
{
case KEY0_PRES:
if(si_key1==0)
show_year++;
else if(si_key1==1)
show_mouth++;
else
show_date++;
break;
case KEY2_PRES:
if(si_key1==0)
show_year--;
else if(si_key1==1)
show_mouth--;
else
show_date--;
break;
case KEY1_PRES:
si_key1++;
if(si_key1>2)
si_key1=0;
break;
}
if (show_mouth>12||show_mouth<1)
show_mouth=1;
if (show_date<1||show_date>30)
show_date=1;
}else delay_ms(1);
if(t!=calendar.sec)
{
t=calendar.sec;
LCD_ShowNum(60,130,calendar.w_year,4,16);
LCD_ShowNum(100,130,calendar.w_month,2,16);
LCD_ShowNum(124,130,calendar.w_date,2,16);
switch(calendar.week)
{
case 0:
LCD_ShowString(60,148,200,16,16,"Sunday ");
break;
case 1:
LCD_ShowString(60,148,200,16,16,"Monday ");
break;
case 2:
LCD_ShowString(60,148,200,16,16,"Tuesday ");
break;
case 3:
LCD_ShowString(60,148,200,16,16,"Wednesday");
break;
case 4:
LCD_ShowString(60,148,200,16,16,"Thursday ");
break;
case 5:
LCD_ShowString(60,148,200,16,16,"Friday ");
break;
case 6:
LCD_ShowString(60,148,200,16,16,"Saturday ");
break;
}
LCD_ShowNum(60,162,calendar.hour,2,16);
LCD_ShowNum(84,162,calendar.min,2,16);
LCD_ShowNum(108,162,calendar.sec,2,16);
LCD_ShowNum(206,400,(show_mouth-calendar.w_month)*30+show_date-calendar.w_date,2,16);
LCD_ShowNum(60,110,show_year,4,16);
LCD_ShowNum(100,110,show_mouth,2,16);
LCD_ShowNum(140,110,show_date,2,16);
LED0=!LED0;
}
delay_ms(10);
};
}
|