📄 datesetup.cpp
字号:
#include "ClockApp.h"
#include "DateSetup.h"
#include "Calendar.h"
CDateSetup::CDateSetup() :CXSetup(4)
{
#ifdef WIN32
m_year = m_month = m_day = 0;
#endif
}
CDateSetup::~CDateSetup()
{
}
//时钟跳动了16分之一秒
void CDateSetup::OnTick()
{
if(CClockApp::clockApp->GetCurrentFunc() == this){
memset(&led, 0, sizeof(led));
if(!m_updated) LoadOldValue();
//年
led.mon1 = DataLed[2];
led.mon2 = DataLed[0];
led.day1 = DataLed[m_year / 10];
led.day2 = DataLed[m_year % 10];
//月
if(m_month > 9)led.hour1 = DataLed[1];
led.hour2 = DataLed[m_month % 10];
//日
if(m_day > 9) led.min1 = DataLed[m_day / 10];
led.min2 = DataLed[m_day % 10];
led.f_date = 1;
CClockApp::clockApp->Display(led);
}
}
void CDateSetup::SetFlash()
{
memset(&led, 0, sizeof(led));
switch(m_current_setup){
case 1:
led.day1 = 0x7f;
break;
case 2:
led.day2 = 0x7f;
break;
case 3:
led.hour1 = 0x7f;
led.hour2 = 0x7f;
break;
case 4:
led.min1 = 0x7f;
led.min2 = 0x7f;
break;
}
CClockApp::clockApp->Flash(&led);
}
void CDateSetup::LoadOldValue()
{
UCHAR temp;
CClockApp::clockApp->m_clock.GetTime(
m_year, m_month, m_day, temp, temp, temp
);
}
void CDateSetup::SaveSetup()
{
UCHAR hour, min, sec, temp;
CClockApp::clockApp->m_clock.GetTime(temp, temp, temp, hour, min, sec);
temp = CCalendar::GetMonthDays(m_year, m_month);
if(m_day > temp) m_day = temp;
CClockApp::clockApp->m_clock.SetTime(m_year, m_month, m_day, hour, min, sec);
}
UCHAR CDateSetup::OnSet(UCHAR add)
{
UCHAR temp;
switch(m_current_setup){
case 1: //年的十位
temp = m_year / 10;
m_year %= 10;
if(add){
if(temp >= ((LAST_LUNAT_YEAR - 2000)/10)-1 ) temp = 0;
else temp++;
}else{
if(!temp) temp = ((LAST_LUNAT_YEAR - 2000)/10)-1;
else temp--;
}
m_year += temp * 10;
break;
case 2: //年的个位
temp = m_year % 10;
m_year -= temp;
if(add){
if(temp >= 9) temp = 0;
else temp++;
}else{
if(!temp) temp = 9;
else temp--;
}
m_year += temp;
break;
case 3: //月
if(add){
if(m_month >= 12) m_month = 1;
else m_month++;
}else{
if(m_month == 1) m_month = 12;
else m_month--;
}
break;
case 4: //日
temp = CCalendar::GetMonthDays(m_year, m_month);
if(add){
if(m_day >= temp) m_day = 1;
else m_day++;
}else{
if(m_day == 1 || m_day > temp) m_day = temp;
else m_day--;
}
break;
}
return 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -