📄 calendar.c
字号:
Calendar_Search_Invert(tempsituat);
Calendar_Search_Invert(situation);
break;
case 7:
situation=8;
Calendar_Search_Invert(tempsituat);
Calendar_Search_Invert(situation);
break;
}
}
break;
case KEY_UP:
tempsituat=situation;
if(0<situation && situation<5)
{
situation=7;
Calendar_Search_Invert(tempsituat);
Calendar_Search_Invert(situation);
}
else
{
switch(situation)
{
case 6:
case 5:
situation=1;
Calendar_Search_Invert(tempsituat);
Calendar_Search_Invert(situation);
break;
case 8:
case 7:
situation=5;
Calendar_Search_Invert(tempsituat);
Calendar_Search_Invert(situation);
break;
}
}
break;
case KEY_DOWN:
tempsituat=situation;
if(0<situation && situation<5)
{
situation=5;
Calendar_Search_Invert(tempsituat);
Calendar_Search_Invert(situation);
}
else
{
switch(situation)
{
case 6:
case 5:
situation=7;
Calendar_Search_Invert(tempsituat);
Calendar_Search_Invert(situation);
break;
case 8:
case 7:
situation=1;
Calendar_Search_Invert(tempsituat);
Calendar_Search_Invert(situation);
break;
}
}
break;
case KEY_ENTER:
#if 1
if(1900<tempsearch.year && tempsearch.year<2100) /* 1901~2099*/
{
if(0<tempsearch.month && tempsearch.month<13)
{
if(tempsearch.day<=solar_month_total_day(tempsearch.year,tempsearch.month))
{
memcpy(Cal_search,&tempsearch,sizeof(DATE));
tempkey=KEY_EXIT;
}
else
dataerror = TRUE;
}
else
dataerror = TRUE;
}
else
dataerror = TRUE;
if(dataerror)
{
// Sbuf = SaveScreen();
ClearArea(29,27,106,26);
DrawRect(30,28,104,24);
DrawString(33,32," 输入错误!");
SysDeadDelay(1000);
dataerror = FALSE;
// RestoreScreen(Sbuf);
}
#else
itoa(tempsearch.year,buf);
DrawString(0,0,buf) ;
itoa(tempsearch.month,buf);
DrawString(0,16,buf);
itoa(tempsearch.day,buf);
DrawString(0,32,buf);
#endif
break;
case KEY_EXIT:
memcpy(Cal_search,&CalRTCDate,sizeof(DATE));
break;
}
}
}while(tempkey!=KEY_EXIT);
/*ModifyInputMode(oldinputmode);*/
return KEY_NULL;
}
/* *******************************************
【上页】【下页】翻一年的显示
【上】【下】 翻一个月显示
【左】【右】 翻一天显示
【查找】 设置任一天的日期显示阳历
进入日历表的时候是按照普通的系统时间显示日历表,
当进入日历表后,就是不是时实的因为这里面不能设置系统的日期,
也就是说当从23:59跳到00:00的时候显示画面上的日期和星期不会改变
*********************************************/
BYTE Calendar(void)
{
BYTE csTemp_Key;
BYTE solar_month_day;
BYTE tempDay,tempMonth;
BYTE start_week;
BYTE lunar_leap_month;
BYTE secondflag;
BYTE monthtotal;
//BYTE buf[4];
WORD temptotal;
//TIME CalRTCTime,tempRTCTime;
DATE CalRTCDate,lunar_calendar;
// GetDate(&CalRTCDate);
SysReadSetting();
if((g_bSectorBuf[0x10]==0xff&&g_bSectorBuf[0x11]==0xff)||(g_bSectorBuf[0x10]==0&&g_bSectorBuf[0x11]==0))
{
g_bSectorBuf[0x10]=(2006&0xff00)>>8;
g_bSectorBuf[0x11]=2006&0xff;
}
if((g_bSectorBuf[0x12]==0xff&&g_bSectorBuf[0x13]==0xff)||(g_bSectorBuf[0x12]==0&&g_bSectorBuf[0x13]==0))
{
g_bSectorBuf[0x12]=0;
g_bSectorBuf[0x13]=1;
}
if((g_bSectorBuf[0x14]==0xff&&g_bSectorBuf[0x15]==0xff)||(g_bSectorBuf[0x14]==0&&g_bSectorBuf[0x15]==0))
{
g_bSectorBuf[0x14]=0;
g_bSectorBuf[0x15]=1;
}
CalRTCDate.year = *(uint16*)&g_bSectorBuf[0x10];
if(CalRTCDate.year<1900||CalRTCDate.year>2100)
CalRTCDate.year = 2006;
CalRTCDate.month = *(uint16*)&g_bSectorBuf[0x12];
if(CalRTCDate.month<1||CalRTCDate.month>12)
CalRTCDate.month = 1;
CalRTCDate.day = *(uint16*)&g_bSectorBuf[0x14];
if(CalRTCDate.day<1||CalRTCDate.day>31)
CalRTCDate.day = 1;
CalRTCDate.year=CalRTCDate.year-1900;
temptotal=get_solar_day_date(CalRTCDate,&start_week);
get_lunar_day(CalRTCDate,&lunar_calendar,&lunar_leap_month,temptotal);
ClearScreen();
// SetLcdFlag(FLAG_UP|FLAG_DOWN|FLAG_PREV|FLAG_NEXT|FLAG_LEFT|FLAG_RIGHT );
Calendar_Init(); /*固定的星期图标和其它边框*/
Display_solar_lunar_Calendar(CalRTCDate,start_week);
Calendar_Day_Invert(CalRTCDate.day,start_week); /*首显的当天标志 反显*/
Display_lunar_pertain(lunar_calendar,lunar_leap_month,LUNAR_X,LUNAR_LINE);
g_nSelectKey = 0xff;
g_Input.InputTool = 0;
//GetTime(&tempRTCTime);
/*Display_RTC_Time(9,40,tempRTCTime);*/
do{
if(secondflag==0)
{
secondflag=1;
}
//memcpy(&tempRTCTime,&CalRTCTime,sizeof(TIME));
tempDay=CalRTCDate.day;
tempMonth=CalRTCDate.month;
/* 想办法加上一个时间显示的光标 */
//GetTime(&CalRTCTime);/*一下显示实时时钟:十分秒*/
#if 0
if(CalRTCTime.second!=tempRTCTime.second)
{
/*DrawString(25,40,":"); 闪烁的秒表 */
secondflag=0;
if(CalRTCTime.minute!=tempRTCTime.minute)
{
/*Display_RTC_Time(9,40,CalRTCTime); 分钟不同了就要显示整个实时时钟*/
}
}
#endif
csTemp_Key=GetKey();
if (IsFuncKey(csTemp_Key))
return csTemp_Key;
if(csTemp_Key == PEN_DOWN||csTemp_Key == PEN_MOVE||csTemp_Key == PEN_UP)
{
if(PenSelectButton(csTemp_Key,Calendar_Button,6,&g_nSelectKey))
{
if(csTemp_Key==PEN_UP)
{
csTemp_Key = CalendarKey[g_nSelectKey];
g_nSelectKey = 0xff;
}
}
}
if(csTemp_Key!=KEY_NULL)
{
switch(csTemp_Key)
{
case KEY_RIGHT:
case Day_Down:
solar_month_day=solar_month_total_day((BYTE)CalRTCDate.year,(BYTE)CalRTCDate.month); /*当月总共多少天*/
if(CalRTCDate.day<solar_month_day)
{
CalRTCDate.day++;
Calendar_Invert_Day((BYTE)CalRTCDate.day-1,(BYTE)CalRTCDate.day,start_week);
}
else /* 注意到最末的时候切换到1号的时候反色显示 */
{
CalRTCDate.day=1;
Calendar_Invert_Day((BYTE)solar_month_day,(BYTE)CalRTCDate.day,start_week);
}
Display_solar_day(CalRTCDate);
get_lunar_day(CalRTCDate,&lunar_calendar,&lunar_leap_month,temptotal);
Display_lunar_pertain(lunar_calendar,lunar_leap_month,LUNAR_X,LUNAR_LINE);
break;
case KEY_LEFT:
case Day_Up:
solar_month_day=solar_month_total_day((BYTE)CalRTCDate.year,(BYTE)CalRTCDate.month); /*当月总共多少天*/
if(CalRTCDate.day>1)
{
CalRTCDate.day--;
Calendar_Invert_Day((BYTE)CalRTCDate.day+1,(BYTE)CalRTCDate.day,start_week);
}
else
{
CalRTCDate.day=solar_month_day;
Calendar_Invert_Day(1,(BYTE)CalRTCDate.day,start_week);
}
Display_solar_day(CalRTCDate);
get_lunar_day(CalRTCDate,&lunar_calendar,&lunar_leap_month,temptotal);
Display_lunar_pertain(lunar_calendar,lunar_leap_month,LUNAR_X,LUNAR_LINE);
break;
case KEY_UP: /*选择月份*/
case Month_Up:
CalRTCDate.month--;
if(CalRTCDate.month<1)
{
CalRTCDate.month=12;
CalRTCDate.year--;
if(CalRTCDate.year<1)
CalRTCDate.year=199; /* 1900+199=2009 */
}
temptotal=get_solar_day_date(CalRTCDate,&start_week);
monthtotal=solar_month_total_day(CalRTCDate.year,CalRTCDate.month);
if(CalRTCDate.day>monthtotal)
CalRTCDate.day=monthtotal; /* 如果日期大于当前的最大日期则等于最后日期 */
get_lunar_day(CalRTCDate,&lunar_calendar,&lunar_leap_month,temptotal);
Display_solar_lunar_Calendar(CalRTCDate,start_week);
Calendar_Day_Invert(CalRTCDate.day,start_week); /*首显的当天标志 反显*/
Display_lunar_pertain(lunar_calendar,lunar_leap_month,LUNAR_X,LUNAR_LINE);
break;
case KEY_DOWN:
case Month_Down:
CalRTCDate.month++;
if(CalRTCDate.month>12)
{
CalRTCDate.month=1;
CalRTCDate.year++;
if(CalRTCDate.year>199)
CalRTCDate.year=1; /*1+1900=1900*/
}
temptotal=get_solar_day_date(CalRTCDate,&start_week);
monthtotal=solar_month_total_day(CalRTCDate.year,CalRTCDate.month);
if(CalRTCDate.day>monthtotal)
CalRTCDate.day=monthtotal; /* 如果日期大于当前的最大日期则等于最后日期 */
get_lunar_day(CalRTCDate,&lunar_calendar,&lunar_leap_month,temptotal);
Display_solar_lunar_Calendar(CalRTCDate,start_week);
Calendar_Day_Invert(CalRTCDate.day,start_week); /*首显的当天标志 反显*/
Display_lunar_pertain(lunar_calendar,lunar_leap_month,LUNAR_X,LUNAR_LINE);
break;
case KEY_PREV:
case Year_Up:
CalRTCDate.year--;
if(CalRTCDate.year<1)
CalRTCDate.year=199; /* 1900+199=2009 */
temptotal=get_solar_day_date(CalRTCDate,&start_week);
monthtotal=solar_month_total_day(CalRTCDate.year,CalRTCDate.month);
if(CalRTCDate.day>monthtotal)
CalRTCDate.day=monthtotal; /* 如果日期大于当前的最大日期则等于最后日期 */
get_lunar_day(CalRTCDate,&lunar_calendar,&lunar_leap_month,temptotal);
Display_solar_lunar_Calendar(CalRTCDate,start_week);
Calendar_Day_Invert(CalRTCDate.day,start_week); /*首显的当天标志 反显*/
Display_lunar_pertain(lunar_calendar,lunar_leap_month,LUNAR_X,LUNAR_LINE);
break;
case KEY_NEXT:
case Year_Down:
CalRTCDate.year++;
if(CalRTCDate.year>199)
CalRTCDate.year=1; /*1+1900=1900*/
temptotal=get_solar_day_date(CalRTCDate,&start_week);
monthtotal=solar_month_total_day(CalRTCDate.year,CalRTCDate.month);
if(CalRTCDate.day>monthtotal)
CalRTCDate.day=monthtotal; /* 如果日期大于当前的最大日期则等于最后日期 */
get_lunar_day(CalRTCDate,&lunar_calendar,&lunar_leap_month,temptotal);
Display_solar_lunar_Calendar(CalRTCDate,start_week);
Calendar_Day_Invert(CalRTCDate.day,start_week); /*首显的当天标志 反显*/
Display_lunar_pertain(lunar_calendar,lunar_leap_month,LUNAR_X,LUNAR_LINE);
break;
case KEY_SEARCH:
csTemp_Key=Calendar_Search(CalRTCDate,&CalRTCDate);
if (IsFuncKey(csTemp_Key))
return csTemp_Key;
CalRTCDate.year=CalRTCDate.year-1900;
ClearScreen();
// SetLcdFlag(FLAG_UP|FLAG_DOWN|FLAG_PREV|FLAG_NEXT|FLAG_LEFT|FLAG_RIGHT );
Calendar_Init();
temptotal=get_solar_day_date(CalRTCDate,&start_week);
get_lunar_day(CalRTCDate,&lunar_calendar,&lunar_leap_month,temptotal);
//GetTime(&CalRTCTime);
/*Display_RTC_Time(9,40,CalRTCTime);*/
Display_solar_lunar_Calendar(CalRTCDate,start_week);
Calendar_Day_Invert(CalRTCDate.day,start_week); /*首显的当天标志 反显*/
Display_lunar_pertain(lunar_calendar,lunar_leap_month,LUNAR_X,LUNAR_LINE);
break;
case KEY_HELP:
csTemp_Key = Help();
if (IsFuncKey(csTemp_Key))
return csTemp_Key;
csTemp_Key = KEY_NULL;
ClearScreen();
Calendar_Init(); /*固定的星期图标和其它边框*/
Display_solar_lunar_Calendar(CalRTCDate,start_week);
Calendar_Day_Invert(CalRTCDate.day,start_week); /*首显的当天标志 反显*/
Display_lunar_pertain(lunar_calendar,lunar_leap_month,LUNAR_X,LUNAR_LINE);
break;
case KEY_ENTER:
MessageBox(MSGBOX_SAVING);
SysReadSetting();
*(uint16*)&g_bSectorBuf[0x10]=CalRTCDate.year+1900;
*(uint16*)&g_bSectorBuf[0x12]=CalRTCDate.month;
*(uint16*)&g_bSectorBuf[0x14]=CalRTCDate.day;
SysWriteSetting();
ClearScreen();
Calendar_Init(); /*固定的星期图标和其它边框*/
Display_solar_lunar_Calendar(CalRTCDate,start_week);
Calendar_Day_Invert(CalRTCDate.day,start_week); /*首显的当天标志 反显*/
Display_lunar_pertain(lunar_calendar,lunar_leap_month,LUNAR_X,LUNAR_LINE);
break;
}
}
}while(csTemp_Key!=KEY_EXIT && IsFuncKey(csTemp_Key)!=TRUE);
return csTemp_Key;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -