21 changed files with 258 additions and 60 deletions
-
61uappbase/apphal/apphal.cpp
-
1uappbase/apphal/apphal.hpp
-
3uappbase/bean/appevent.h
-
12uappbase/service/app_event_bus.cpp
-
2uappbase/service/app_event_bus.hpp
-
BINui/hand_acid_mainboard_ui.HMI
-
6usrc/service/app_core.cpp
-
5usrc/uicontroler/base/page_processer.cpp
-
11usrc/uicontroler/base/page_processer.hpp
-
4usrc/uicontroler/event_proceesser/inputfield_content_selected_change_event_processer.cpp
-
7usrc/uicontroler/event_proceesser/usr_def_clik_release_with_val_event_processer.cpp
-
2usrc/uicontroler/page/home_page.cpp
-
2usrc/uicontroler/page/login_page.cpp
-
146usrc/uicontroler/page/mupage/muDateMgr_page.cpp
-
5usrc/uicontroler/page/mupage/muInterval_page.cpp
-
4usrc/uicontroler/page/mupage/muUsrMgr_page.cpp
-
8usrc/uicontroler/page/navi_page.cpp
-
4usrc/uicontroler/page/popwin_page.cpp
-
2usrc/uicontroler/tjc/ui_event.h
-
19usrc/uicontroler/ui_controler.cpp
-
14usrc/uicontroler/ui_controler.hpp
@ -0,0 +1,146 @@ |
|||
|
|||
#include "db/dao/user_dao.hpp"
|
|||
#include "uappbase/apphal/apphal.hpp"
|
|||
#include "ui/ui.h"
|
|||
#include "uicontroler/base/page_processer.hpp"
|
|||
//
|
|||
#include "db/dao/acid_ch_cfg_dao.hpp"
|
|||
#include "db/dao/device_setting_dao.hpp"
|
|||
//
|
|||
#include "service/pump_ctrl_service.hpp"
|
|||
|
|||
namespace iflytop { |
|||
using namespace std; |
|||
#define TAG "MuDateMgrPage"
|
|||
|
|||
static zdate_t date; |
|||
static int m_oneMonthDay = 0; |
|||
|
|||
static int getOneMonthDay(int year, int month) { |
|||
if (month == 2) { |
|||
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) { |
|||
return 29; |
|||
} else { |
|||
return 28; |
|||
} |
|||
} else if (month == 4 || month == 6 || month == 9 || month == 11) { |
|||
return 30; |
|||
} else { |
|||
return 31; |
|||
} |
|||
} |
|||
|
|||
class MuDateMgrPage : public IPageProcesser { |
|||
private: |
|||
public: |
|||
MuDateMgrPage() : IPageProcesser(TAG, pg_muDateMgr) {} |
|||
|
|||
virtual void initialize() override { IPageProcesser::initialize(); } |
|||
|
|||
private: |
|||
virtual void onPageLoad(OnPageLoadContext* cxt) override { return; }; |
|||
/**
|
|||
* @brief 返回上一页 |
|||
*/ |
|||
virtual void onBackKey() override { UIControler::ins()->chpage(pg_navi, true); }; |
|||
|
|||
virtual void onChangePageEvent() override { |
|||
AppHal::rtc_get(&date); |
|||
ZLOGI(TAG, "get rtc %d-%d-%d %d:%d", date.year, date.month, date.day, date.hours, date.minutes); |
|||
if (date.year < 2020) { |
|||
date.year = 2020; |
|||
date.month = 1; |
|||
date.day = 1; |
|||
date.hours = 0; |
|||
date.minutes = 0; |
|||
AppHal::rtc_set(&date); |
|||
} |
|||
|
|||
m_oneMonthDay = getOneMonthDay(date.year, date.month); |
|||
tryUpdateMonthDay(); |
|||
|
|||
setVal(ob_muDateMgr_year, date.year - 2020); |
|||
setVal(ob_muDateMgr_month, date.month - 1); |
|||
setVal(ob_muDateMgr_day, date.day - 1); |
|||
setVal(ob_muDateMgr_hour, date.hours); |
|||
setVal(ob_muDateMgr_min, date.minutes); |
|||
UIControler::ins()->setrtc(&date); |
|||
return; |
|||
}; |
|||
|
|||
virtual void tryUpdateMonthDay() { |
|||
if (m_oneMonthDay == 28) { |
|||
if (date.day > 28) { |
|||
date.day = 28; |
|||
} |
|||
UIControler::ins()->setPath( //
|
|||
thisPage, ob_muDateMgr_day, //
|
|||
"1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10\r\n11\r\n12\r\n13\r\n14\r\n15\r\n16\r\n17\r\n18\r\n19\r\n20\r\n21\r\n22\r\n23\r\n24\r\n25\r\n26\r\n27\r\n28"); |
|||
} else if (m_oneMonthDay == 29) { |
|||
if (date.day > 29) { |
|||
date.day = 29; |
|||
} |
|||
UIControler::ins()->setPath( //
|
|||
thisPage, ob_muDateMgr_day, //
|
|||
"1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10\r\n11\r\n12\r\n13\r\n14\r\n15\r\n16\r\n17\r\n18\r\n19\r\n20\r\n21\r\n22\r\n23\r\n24\r\n25\r\n26\r\n27\r\n28\r\n29"); |
|||
} else if (m_oneMonthDay == 30) { |
|||
if (date.day > 30) { |
|||
date.day = 30; |
|||
} |
|||
UIControler::ins()->setPath( //
|
|||
thisPage, ob_muDateMgr_day, //
|
|||
"1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10\r\n11\r\n12\r\n13\r\n14\r\n15\r\n16\r\n17\r\n18\r\n19\r\n20\r\n21\r\n22\r\n23\r\n24\r\n25\r\n26\r\n27\r\n28\r\n29\r\n30"); |
|||
} else if (m_oneMonthDay == 31) { |
|||
if (date.day > 31) { |
|||
date.day = 31; |
|||
} |
|||
UIControler::ins()->setPath( //
|
|||
thisPage, ob_muDateMgr_day, //
|
|||
"1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10\r\n11\r\n12\r\n13\r\n14\r\n15\r\n16\r\n17\r\n18\r\n19\r\n20\r\n21\r\n22\r\n23\r\n24\r\n25\r\n26\r\n27\r\n28\r\n29\r\n30\r\n31"); |
|||
} |
|||
} |
|||
|
|||
virtual void OnInputFieldContentChange(uint8_t bid, uint8_t slecId, const char* text) {}; |
|||
virtual void onClickRelease(uint8_t bid, uint8_t val, const char* text) override { |
|||
if (bid == ob_muDateMgr_year) { |
|||
ZLOGI(TAG, "set year %s(%d)", text, val); |
|||
date.year = atoi(text); |
|||
|
|||
int32_t oneMonthDay = getOneMonthDay(date.year, date.month); |
|||
if (m_oneMonthDay != oneMonthDay) { |
|||
m_oneMonthDay = oneMonthDay; |
|||
tryUpdateMonthDay(); |
|||
setVal(ob_muDateMgr_day, date.day - 1); |
|||
} |
|||
|
|||
} else if (bid == ob_muDateMgr_month) { |
|||
ZLOGI(TAG, "set month %s(%d)", text, val); |
|||
date.month = atoi(text); |
|||
|
|||
int32_t oneMonthDay = getOneMonthDay(date.year, date.month); |
|||
if (m_oneMonthDay != oneMonthDay) { |
|||
m_oneMonthDay = oneMonthDay; |
|||
tryUpdateMonthDay(); |
|||
setVal(ob_muDateMgr_day, date.day - 1); |
|||
} |
|||
|
|||
} else if (bid == ob_muDateMgr_day) { |
|||
ZLOGI(TAG, "set day %s(%d)", text, val); |
|||
date.day = atoi(text); |
|||
} else if (bid == ob_muDateMgr_hour) { |
|||
ZLOGI(TAG, "set hour %s(%d)", text, val); |
|||
date.hours = atoi(text); |
|||
} else if (bid == ob_muDateMgr_min) { |
|||
ZLOGI(TAG, "set min %s(%d)", text, val); |
|||
date.minutes = atoi(text); |
|||
} |
|||
if (bid == ob_muDateMgr_save) { |
|||
ZLOGI(TAG, "set rtc %d-%d-%d %d:%d", date.year, date.month, date.day, date.hours, date.minutes); |
|||
AppHal::rtc_set(&date); |
|||
} |
|||
} |
|||
}; |
|||
|
|||
// 实例化Page, 使其自动注册
|
|||
static MuDateMgrPage instance; |
|||
} // namespace iflytop
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue