Commit 18e03db0 authored by hu's avatar hu

调整时间日期设置,显示,调整星期算法

parent da37d8ec
No preview for this file type
This diff is collapsed.
project .intvect 1536
project .text 314828
project .text 314684
project .rodata 410775
project .secinfo 120
project .syscall 6
project .romdata 9037
project .romdata 9029
project .ROM.ramfunc 208
project .ramfunc 208
......@@ -295,7 +295,7 @@ void GUI_Data_Dispaly(uint8_t Mode)
GUI_General_Digit_Display(Calendar_Sprite, Year, Nb_14_0, 4u, 0u, GUI_DISP_Year, 48, GUI_BLENDMODE_SRC_OVER); /*显示年*/
GUI_General_Digit_Display(Calendar_Sprite, Month, Nb_14_0, 2u, 0u, GUI_DISP_Month, 48, GUI_BLENDMODE_SRC_OVER); /*显示月*/
GUI_General_Digit_Display(Calendar_Sprite, Date, Nb_14_0, 2u, 0u, GUI_DISP_Date, 48, GUI_BLENDMODE_SRC_OVER); /*显示日*/
GUI_General_Display(Calendar_Sprite, GUIWedk[Week - 1u], GUI_BLENDMODE_SRC_OVER);
GUI_General_Display(Calendar_Sprite, GUIWedk[Week], GUI_BLENDMODE_SRC_OVER);
}
else
{
......
......@@ -134,8 +134,8 @@ typedef struct
} _TPMS;
extern _TPMS TPMS_Matching;
static const uint32_t GUIWedk[7u] = {CN_xingqiyi, CN_xingqier, CN_xingqisan, CN_xingqisi, CN_xingqiwu, CN_xingqiliu, CN_xingqiri};
static const uint32_t GUIMenuWedk[7u] = {CN_Mon, CN_Tue, CN_Wed, CN_Thu, CN_Fri, CN_Sat, CN_ri};
static const uint32_t GUIWedk[7u] = {CN_xingqiri, CN_xingqiyi, CN_xingqier, CN_xingqisan, CN_xingqisi, CN_xingqiwu, CN_xingqiliu};
static const uint32_t GUIMenuWedk[7u] = {CN_ri, CN_Mon, CN_Tue, CN_Wed, CN_Thu, CN_Fri, CN_Sat};
static const uint32_t GUIGear[12u] = {CN_dangwei_1, CN_dangwei_2, CN_dangwei_3, CN_dangwei_4, CN_dangwei_5, CN_dangwei_6, CN_dangwei_7, CN_dangwei_8, CN_dangwei_9, CN_dangwei_10, CN_dangwei_11, CN_dangwei_12};
static const uint16_t GUI_DISP_AC_TEMP[2] = {229u, 216u}; /*室外温度数字显示*/
......
......@@ -843,9 +843,9 @@ void Level3_3Menu_7Exit(void)
/*日期设定 ----- 年*/
void Level3_4Menu_1Enter_1(void)
{
User_set_Num.Year = Get_RTC_YEAR();
User_set_Num.Year = Get_RTC_YEAR();
User_set_Num.Month = Get_RTC_MONTH();
User_set_Num.Date = Get_RTC_DATE();
User_set_Num.Date = Get_RTC_DATE();
}
void Level3_4Menu_1Do_1(void)
{
......@@ -881,9 +881,12 @@ void Level3_4Menu_1Exit_3(void)
{
if (MenuFlag.Menu_Return)
{
RTE_RTC_Set_Year(User_set_Num.Year + 2000u);
RTE_RTC_Set_Year (User_set_Num.Year + 2000u);
RTE_RTC_Set_Month(User_set_Num.Month);
RTE_RTC_Set_Date(User_set_Num.Date);
RTE_RTC_Set_Date (User_set_Num.Date);
RTE_RTC_Set_Hour(Get_RTC_HOUR());
RTE_RTC_Set_Minute(Get_RTC_MINUTE());
MenuFlag.Menu_Return = 0;
......@@ -919,6 +922,10 @@ void Level3_4Menu_2Exit_2(void)
{
if (MenuFlag.Menu_Return)
{
RTE_RTC_Set_Year ( Get_RTC_YEAR() + 2000u );
RTE_RTC_Set_Month( Get_RTC_MONTH() );
RTE_RTC_Set_Date ( Get_RTC_DATE() );
RTE_RTC_Set_Hour(User_set_Num.Hour);
RTE_RTC_Set_Minute(User_set_Num.Minute);
......
......@@ -103,4 +103,4 @@ uint8_t Get_RTC_SECOND(void)
uint8_t Get_RTC_WEEK(void)
{
return RTC_WEEK ;
}
}
\ No newline at end of file
......@@ -61,7 +61,7 @@ void RTC_Pre_Init(void)
RTC_Stop(); /* Stop RTCA*/
#if (RTC_MODE_SELECT == RTC_MODE_MAIN)
RTCA0SLSB = 1U; /*Frequency selection mode*/
RTCA0SLSB = 1U; /*Frequency selection mode*/
RTCA0SCMP = 4000000U - 1U; /*4M*/
#else
RTCA0SLSB = 0U; /*32.768 kHz mode*/
......@@ -94,7 +94,7 @@ void RTC_Set_Time(RTC_Information_st_t *pstRTCTime)
{
;
}
RTCA0WAIT = 1U; /*Stop all clock counters*/
RTCA0WAIT = 1U; /*Stop all clock counters*/
while (RTCA0WST != 1U) /*Wait all clock counters stop*/
{
;
......@@ -126,7 +126,7 @@ void RTC_Timing_Service(void)
{
;
}
RTCA0WAIT = 1U; /*Stop all clock counters*/
RTCA0WAIT = 1U; /*Stop all clock counters*/
while (RTCA0WST != 1U) /*Wait all clock counters stop*/
{
;
......@@ -142,11 +142,7 @@ void RTC_Timing_Service(void)
Week = Cal_RTC_Week(g_stRTCInformation.u8RTCYear, g_stRTCInformation.u8RTCMonth, g_stRTCInformation.u8RTCDayOfMonth);
if (Week)
{
g_stRTCInformation.u8RTCWeek = Week ;
}
g_stRTCInformation.u8RTCWeek = Week ;
g_RTCLeapYear = RTC_Determine_Leap_Year(g_stRTCInformation.u8RTCYear);
......@@ -166,86 +162,15 @@ void RTC_Init(void)
/*计算 星期几*/
static uint8_t Cal_RTC_Week(uint16_t Year, uint8_t Month, uint8_t Day)
{
static uint8_t DefaultWeek = 6 ; //2000.1.1
static uint16_t OldYear = 0 ;
static uint8_t OldMonth = 0 ;
static uint8_t OldDay = 0 ;
uint8_t u8Result = 0 ;
uint32_t DiffDay = 0 ;
uint16_t DiffYear = 0 ;
uint16_t DiffMouth = 0 ;
if ((Year != OldYear) || (Month != OldMonth) || (Day != OldDay))
if (Month < 3)
{
OldYear = Year ;
OldMonth = Month ;
OldDay = Day ;
DiffYear = Year - 0 ;
DiffMouth = Month - 1 ;
while (DiffYear)
{
if (RTC_Determine_Leap_Year((DiffYear - 1)))
{
DiffDay += 366 ;
}
else
{
DiffDay += 365 ;
}
DiffYear -- ;
}
while (DiffMouth)
{
switch (DiffMouth + 1)
{
case 1 :
case 3 :
case 5 :
case 7 :
case 8 :
case 10:
case 12:
DiffDay += 31 ;
break ;
case 4 :
case 6 :
case 9 :
case 11 :
DiffDay += 30 ;
break ;
case 2 :
if (RTC_Determine_Leap_Year(Year))
{
DiffDay += 29 ;
}
else
{
DiffDay += 28 ;
}
break ;
}
DiffMouth -- ;
}
DiffDay += (Day - 1) ;
DiffDay %= 7 ;
DiffDay += DefaultWeek ;
if (DiffDay > 7)
{
DiffDay -= 7 ;
}
u8Result = (uint8_t)DiffDay ;
Month += 12;
Year--;
}
return u8Result ;
uint8_t tmp_0 = (uint8_t)(Year % 100);
uint8_t tmp_1 = (uint8_t)(Year / 100);
uint8_t week = (uint8_t)((tmp_0 + (tmp_0 >> 2) + (tmp_1 >> 2) + 13 * (Month + 1) / 5 + Day - 1 - (tmp_1 << 1)) % 7);
return week;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment