📄 calendar.c
字号:
LCD_SetTextColor(Red);
LCD_DrawRect(dayline, daycolumn, 24, 32);
tmpValue--;
WeekDayNum(date_s.year, date_s.month, tmpValue);
LCD_SetBackColor(Blue2);
LCD_SetTextColor(White);
LCD_DisplayStringLine(Line1, " WEEK DAY N: ");
if(wn/10)
{
LCD_DisplayChar(Line1, 223, ((wn/10)+ 0x30));
LCD_DisplayChar(Line1, 207, ((wn%10)+ 0x30));
}
else
{
LCD_DisplayChar(Line1, 223, ((wn%10)+ 0x30));
}
if(dc/100)
{
LCD_DisplayChar(Line1, 47, ((dc/100)+ 0x30));
LCD_DisplayChar(Line1, 31, (((dc%100)/10)+ 0x30));
LCD_DisplayChar(Line1, 15, (((dc%100)%10)+ 0x30));
}
else if(dc/10)
{
LCD_DisplayChar(Line1, 47, ((dc/10)+ 0x30));
LCD_DisplayChar(Line1, 31, ((dc%10)+ 0x30));
}
else
{
LCD_DisplayChar(Line1, 47, ((dc%10)+ 0x30));
}
LCD_SetBackColor(White);
}
/* If "UP" pushbutton is pressed */
if(MyKey == UP)
{
LCD_SetTextColor(White);
LCD_DrawRect(dayline, daycolumn, 24, 32);
if(tmpValue == 1)
{
dayline = lastdayline;
daycolumn = lastdaycolumn;
tmpValue = ValueMax;
}
else if(tmpValue < 8)
{
tmpValue = 1;
dayline = Line3;
daycolumn = firstdaycolumn;
}
else
{
dayline -= 24;
tmpValue -= 7;
}
LCD_SetTextColor(Red);
LCD_DrawRect(dayline, daycolumn, 24, 32);
WeekDayNum(date_s.year, date_s.month, tmpValue);
LCD_SetBackColor(Blue2);
LCD_SetTextColor(White);
LCD_DisplayStringLine(Line1, " WEEK DAY N: ");
if(wn/10)
{
LCD_DisplayChar(Line1, 223, ((wn/10)+ 0x30));
LCD_DisplayChar(Line1, 207, ((wn%10)+ 0x30));
}
else
{
LCD_DisplayChar(Line1, 223, ((wn%10)+ 0x30));
}
if(dc/100)
{
LCD_DisplayChar(Line1, 47, ((dc/100)+ 0x30));
LCD_DisplayChar(Line1, 31, (((dc%100)/10)+ 0x30));
LCD_DisplayChar(Line1, 15, (((dc%100)%10)+ 0x30));
}
else if(dc/10)
{
LCD_DisplayChar(Line1, 47, ((dc/10)+ 0x30));
LCD_DisplayChar(Line1, 31, ((dc%10)+ 0x30));
}
else
{
LCD_DisplayChar(Line1, 47, ((dc%10)+ 0x30));
}
LCD_SetBackColor(White);
}
/* If "DOWN" pushbutton is pressed */
if(MyKey == DOWN)
{
LCD_SetTextColor(White);
LCD_DrawRect(dayline, daycolumn, 24, 32);
if(tmpValue == ValueMax)
{
dayline = Line3;
daycolumn = firstdaycolumn;
tmpValue = 1;
}
else
{
dayline += 24;
tmpValue += 7;
}
if(tmpValue > ValueMax)
{
tmpValue = ValueMax;
dayline = lastdayline;
daycolumn = lastdaycolumn;
}
LCD_SetTextColor(Red);
LCD_DrawRect(dayline, daycolumn, 24, 32);
WeekDayNum(date_s.year, date_s.month, tmpValue);
LCD_SetBackColor(Blue2);
LCD_SetTextColor(White);
LCD_DisplayStringLine(Line1, " WEEK DAY N: ");
if(wn/10)
{
LCD_DisplayChar(Line1, 223, ((wn/10)+ 0x30));
LCD_DisplayChar(Line1, 207, ((wn%10)+ 0x30));
}
else
{
LCD_DisplayChar(Line1, 223, ((wn%10)+ 0x30));
}
if(dc/100)
{
LCD_DisplayChar(Line1, 47, ((dc/100)+ 0x30));
LCD_DisplayChar(Line1, 31, (((dc%100)/10)+ 0x30));
LCD_DisplayChar(Line1, 15, (((dc%100)%10)+ 0x30));
}
else if(dc/10)
{
LCD_DisplayChar(Line1, 47, ((dc/10)+ 0x30));
LCD_DisplayChar(Line1, 31, ((dc%10)+ 0x30));
}
else
{
LCD_DisplayChar(Line1, 47, ((dc%10)+ 0x30));
}
LCD_SetBackColor(White);
}
/* If "SEL" pushbutton is pressed */
if(MyKey == SEL)
{
/* Clear the LCD */
LCD_Clear(White);
/* Display the menu */
DisplayMenu();
/* Enable the JoyStick interrupts */
IntExtOnOffConfig(ENABLE);
return;
}
}
}
/*******************************************************************************
* Function Name : Date_Update
* Description : Updates date when time is 23:59:59.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void Date_Update(void)
{
if(date_s.month == 1 || date_s.month == 3 || date_s.month == 5 || date_s.month == 7 ||
date_s.month == 8 || date_s.month == 10 || date_s.month == 12)
{
if(date_s.day < 31)
{
date_s.day++;
}
/* Date structure member: date_s.day = 31 */
else
{
if(date_s.month != 12)
{
date_s.month++;
date_s.day = 1;
}
/* Date structure member: date_s.day = 31 & date_s.month =12 */
else
{
date_s.month = 1;
date_s.day = 1;
date_s.year++;
}
}
}
else if(date_s.month == 4 || date_s.month == 6 || date_s.month == 9 ||
date_s.month == 11)
{
if(date_s.day < 30)
{
date_s.day++;
}
/* Date structure member: date_s.day = 30 */
else
{
date_s.month++;
date_s.day = 1;
}
}
else if(date_s.month == 2)
{
if(date_s.day < 28)
{
date_s.day++;
}
else if(date_s.day == 28)
{
/* Leap year */
if(IsLeapYear(date_s.year))
{
date_s.day++;
}
else
{
date_s.month++;
date_s.day = 1;
}
}
else if(date_s.day == 29)
{
date_s.month++;
date_s.day = 1;
}
}
}
/*******************************************************************************
* Function Name : RegulateYear
* Description : Regulates the year.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
static void RegulateYear(void)
{
u32 tmpValue = 0;
u32 MyKey = 0;
/* Initialize tmpValue */
tmpValue = date_s.year;
/* Endless loop */
while(1)
{
/* Check which key is pressed */
MyKey = ReadKey();
/* If "UP" pushbutton is pressed */
if(MyKey == UP)
{
/* Increase the value of the digit */
if(tmpValue == 2099)
{
tmpValue = 1874;
}
LCD_ClearLine(Line3);
LCD_ClearLine(Line7);
LCD_ClearLine(Line8);
Date_Display(++tmpValue, date_s.month, date_s.day);
}
/* If "DOWN" pushbutton is pressed */
if(MyKey == DOWN)
{
/* Decrease the value of the digit */
if(tmpValue == 1875)
{
tmpValue = 2100;
}
LCD_ClearLine(Line3);
LCD_ClearLine(Line7);
LCD_ClearLine(Line8);
/* Display new value */
Date_Display(--tmpValue, date_s.month, date_s.day);
}
/* If "SEL" pushbutton is pressed */
if(MyKey == SEL)
{
LCD_ClearLine(Line3);
LCD_ClearLine(Line7);
LCD_ClearLine(Line8);
/* Display new value */
Date_Display(tmpValue, date_s.month, date_s.day);
/* Return the digit value and exit */
date_s.year = tmpValue;
return;
}
}
}
/*******************************************************************************
* Function Name : RegulateMonth
* Description : Regulates month.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
static void RegulateMonth(void)
{
u32 tmpValue = 0;
u32 MyKey = 0;
/* Initialize tmpValue */
tmpValue = date_s.month;
/* Endless loop */
while(1)
{
/* Check which key is pressed */
MyKey = ReadKey();
/* If "UP" pushbutton is pressed */
if(MyKey == UP)
{
/* Increase the value of the digit */
if(tmpValue == 12)
{
tmpValue = 0;
}
LCD_ClearLine(Line3);
LCD_ClearLine(Line7);
LCD_ClearLine(Line8);
Date_Display(date_s.year, ++tmpValue, date_s.day);
}
/* If "DOWN" pushbutton is pressed */
if(MyKey == DOWN)
{
/* Decrease the value of the digit */
if(tmpValue == 1)
{
tmpValue = 13;
}
LCD_ClearLine(Line3);
LCD_ClearLine(Line7);
LCD_ClearLine(Line8);
/* Display new value */
Date_Display(date_s.year, --tmpValue, date_s.day);
}
/* If "SEL" pushbutton is pressed */
if(MyKey == SEL)
{
LCD_ClearLine(Line3);
LCD_ClearLine(Line7);
LCD_ClearLine(Line8);
/* Display new value */
Date_Display(date_s.year, tmpValue, date_s.day);
/* Return the digit value and exit */
date_s.month = tmpValue;
return;
}
}
}
/*******************************************************************************
* Function Name : RegulateDay
* Description : Regulates day.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
static void RegulateDay(void)
{
u32 tmpValue = 0;
u32 MyKey = 0, ValueMax = 0;
u32 firstdaycolumn = 0, lastdaycolumn = 0, lastdayline = 0;
if(date_s.month == 2)
{
if(IsLeapYear(date_s.year))
ValueMax = 29;
else
ValueMax = (MonLen[date_s.month - 1] - 1);
}
else
{
ValueMax = (MonLen[date_s.month - 1] - 1);
}
firstdaycolumn = 0x13F - (0x30 * dn);
lastdaycolumn = ValueMax - (7 - dn);
lastdayline = lastdaycolumn / 7;
lastdaycolumn %= 7;
if(lastdaycolumn == 0)
{
lastdayline = Line3 + (lastdayline * 24);
lastdaycolumn = 31;
}
else
{
lastdayline = Line4 + (lastdayline * 24);
lastdaycolumn = 0x13F -(0x30 * (lastdaycolumn - 1));
}
/* Initialize tmpValue */
tmpValue = date_s.day;
/* Endless loop */
while(1)
{
/* Check which key is pressed */
MyKey = ReadKey();
/* If "RIGHT" pushbutton is pressed */
if(MyKey == RIGHT)
{
LCD_SetTextColor(White);
LCD_DrawRect(dayline, daycolumn, 24, 32);
/* Increase the value of the digit */
if(tmpValue == ValueMax)
{
tmpValue = 0;
dayline = Line3;
daycolumn = firstdaycolumn + 48;
}
if(daycolumn == 31)
{
daycolumn = 367;
dayline += 24;
}
daycolumn -= 48;
LCD_SetTextColor(Red);
LCD_DrawRect(dayline, daycolumn, 24, 32);
tmpValue++;
}
/* If "LEFT" pushbutton is pressed */
if(MyKey == LEFT)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -