初级会员
- 积分
- 80
- 金钱
- 80
- 注册时间
- 2022-6-29
- 在线时间
- 33 小时
|
发表于 2022-11-28 18:03:59
|
显示全部楼层
main函数主要内容
yearset = calendar.w_year;
monthset = calendar.w_month;
dateset = calendar.w_date;
hourset = calendar.hour;
minset = calendar.min;
secset = calendar.sec;
while (1)
{
key = KEY_Scan(0);
if(key)
{
if(key==KEY1_PRES)
{
if(Key1_STA<6) Key4_STA++;
else Key1_STA=1;
switch(Key1_STA)
{
case 1:
printf("Year Set\r\n");
break;
case 2:
printf("Month Set\r\n");
break;
case 3:
printf("Date Set\r\n");
break;
case 4:
printf("Hour Set\r\n");
break;
case 5:
printf("Minute Set\r\n");
break;
case 6:
printf("Second Set\r\n");
break;
default:
break;
}
}else if(key==KEY2_PRES)
{
switch(Key1_STA)
{
case 1:
if(yearset<2099) yearset++;
else yearset = 1970;
break;
case 2:
if(monthset<12) monthset++;
else monthset = 1;
break;
case 3:
if(Is_Leap_Year(yearset))
{
if(monthset==2)
{
if(dateset<(mon_table[monthset-1]+1)) dateset++;
else dateset = 1;
}else
{
if(dateset<mon_table[monthset-1]) dateset++;
else dateset = 1;
}
}
else
{
if(dateset<mon_table[monthset-1]) dateset++;
else dateset = 1;
}
break;
case 4:
if(hourset<23) hourset++;
else hourset = 0;
break;
case 5:
if(minset<59) minset++;
else minset = 0;
break;
case 6:
secset = 0;
break;
case 0:
printf("Please press Key1 to select time quantum set!\r\n");
break;
default:
break;
}
RTC_Set(yearset,monthset,dateset,hourset,minset,secset);
}
}else delay_ms(100);
} |
|