diff --git a/stm32components b/stm32components index 3b82b7a..92ed794 160000 --- a/stm32components +++ b/stm32components @@ -1 +1 @@ -Subproject commit 3b82b7adf76a40c6931d8578725a72c8c7886bd9 +Subproject commit 92ed79403f40852dc6a44347d10355cfe9bb90b8 diff --git a/uappbase/apphal/apphal.cpp b/uappbase/apphal/apphal.cpp index d1c0c13..8e42c80 100644 --- a/uappbase/apphal/apphal.cpp +++ b/uappbase/apphal/apphal.cpp @@ -291,8 +291,8 @@ void AppHal::MX_I2C1_Init(void) { __HAL_RCC_GPIOB_CLK_ENABLE(); __HAL_RCC_I2C1_CLK_ENABLE(); - hi2c1.Instance = I2C1; - hi2c1.Init.ClockSpeed = 400000; + hi2c1.Instance = I2C1; + hi2c1.Init.ClockSpeed = 400000; // hi2c1.Init.ClockSpeed = 1000000; hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2; hi2c1.Init.OwnAddress1 = 0; @@ -408,13 +408,35 @@ void AppHal::rtc_init() { sDate.WeekDay = 0x01; sDate.Month = 0x1; sDate.Date = 0x1; - sDate.Year = 0x24; + sDate.Year = 24; if (HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BIN) != HAL_OK) { Error_Handler(); } } +void AppHal::rtc_get(zdate_t* date) { + RTC_DateTypeDef GetData; + RTC_TimeTypeDef GetTime; + /* Get the RTC current Time */ + HAL_RTC_GetTime(&hrtc, &GetTime, RTC_FORMAT_BIN); + /* Get the RTC current Date */ + HAL_RTC_GetDate(&hrtc, &GetData, RTC_FORMAT_BIN); + + date->year = 2000 + GetData.Year; + date->month = GetData.Month; + date->day = GetData.Date; + + date->hours = GetTime.Hours; + date->minutes = GetTime.Minutes; + date->seconds = GetTime.Seconds; + + // /* Display date Format : yy/mm/dd */ + // ZLOGI("", "%02d/%02d/%02d\r\n", 2000 + GetData.Year, GetData.Month, GetData.Date); + // /* Display time Format : hh:mm:ss */ + // ZLOGI("", "%02d:%02d:%02d\r\n", GetTime.Hours, GetTime.Minutes, GetTime.Seconds); +} + void AppHal::usb_init() { GPIO_InitTypeDef GPIO_InitStruct = {0}; diff --git a/uappbase/apphal/apphal.hpp b/uappbase/apphal/apphal.hpp index 3800e29..6bda47c 100644 --- a/uappbase/apphal/apphal.hpp +++ b/uappbase/apphal/apphal.hpp @@ -18,6 +18,8 @@ class AppHal { static void tmc_spi_init(); static void rtc_init(); + static void rtc_get(zdate_t* date); + static void usb_init(); }; diff --git a/uappbase/bean/event.hpp b/uappbase/bean/event.hpp index a1f65dd..1e8410f 100644 --- a/uappbase/bean/event.hpp +++ b/uappbase/bean/event.hpp @@ -9,15 +9,19 @@ namespace iflytop { using namespace std; typedef enum { - kAppEvent_RunModeChangeEvent, - kAppEvent_RemoterConnectStateChangeEvent, + kAE_RunModeChangeEvent, // 运行模式改变 + kAppEvent_StateDisplayInfo, - kAppEvent_BleConnectEvent, kAppEvent_AcidChCfgChangeEvent, // UI_EVENT KAE_UIEvent, kAE_LoginEvent, + kAE_unLoginEvent, + + kAE_AcidStatChangeEvent, // 统计数据变化事件 + kAE_RemoterConnectedEvent, // 遥控器连接成功 + kAE_RemoterDisConnectedEvent, // 遥控器断开连接 } AppEventType_t; @@ -29,6 +33,7 @@ typedef enum { * @注意 * 下面这个结构不易定义过大,否则容易造成栈溢出 */ + typedef struct { AppEventType_t type; union event { diff --git a/uappbase/service/app_event_bus.cpp b/uappbase/service/app_event_bus.cpp index e254063..97dd7cc 100644 --- a/uappbase/service/app_event_bus.cpp +++ b/uappbase/service/app_event_bus.cpp @@ -14,10 +14,12 @@ void AppEventBus::initialize() { AppEvent_t event; while (1) { if (xQueueReceive(xQueue, &event, portMAX_DELAY) == pdTRUE) { + // ZLOGI(TAG, "pop event type %d", event.type); for (int i = 0; i < cbNum; i++) { m_cbs[i](&event); } } + } }); } @@ -27,8 +29,7 @@ void AppEventBus::regOnEvent(onAppEventCB_t onEvent) { cbNum++; } void AppEventBus::pushEvent(const AppEvent_t& event) { - xQueueSend(xQueue, &event, 0); - + // ZLOGI(TAG, "pushEvent %d", event.type); if (xQueueSend(xQueue, &event, 100) != pdPASS) { ZLOGE(TAG, "xQueueSend failed"); } diff --git a/uappbase/service/gstate_mgr.cpp b/uappbase/service/gstate_mgr.cpp index 5ef7808..2c08f89 100644 --- a/uappbase/service/gstate_mgr.cpp +++ b/uappbase/service/gstate_mgr.cpp @@ -4,6 +4,7 @@ using namespace std; using namespace iflytop; +#define TAG "GSM" #define GSM GStateMgr::ins() void GStateMgr::initialize() { m_mutex.init(); } @@ -49,16 +50,28 @@ void GStateMgr::setAcidState(int32_t state) { m_AcidState = state; } -void GStateMgr::setRemoterS(int32_t state) { +void GStateMgr::setRemoterS(int32_t state, const char* name) { zlock_guard l(m_mutex); + AppEvent_t appevent; + m_RemoterS = state; - AppEventBus::ins()->pushEvent(createAppEvent(kAppEvent_RemoterConnectStateChangeEvent)); + if (state) { + ZLOGI(TAG, "on ble connect -> client name:%s", name); + strncpy(m_RemoterName, name, sizeof(m_RemoterName)); + strncpy(appevent.d.bleName, name, sizeof(appevent.d.bleName)); + appevent.type = kAE_RemoterConnectedEvent; + + } else { + ZLOGI(TAG, "on ble disconnect"); + appevent.type = kAE_RemoterDisConnectedEvent; + } + AppEventBus::ins()->pushEvent(appevent); } void GStateMgr::setRunMode(hand_acid_mode_t mode) { zlock_guard l(m_mutex); if (m_RunMode != mode) { m_RunMode = mode; - AppEventBus::ins()->pushEvent(createAppEvent(kAppEvent_RunModeChangeEvent)); + AppEventBus::ins()->pushEvent(createAppEvent(kAE_RunModeChangeEvent)); } } void GStateMgr::changeToNextRunMode() { @@ -92,6 +105,35 @@ bool GStateMgr::getPumpSelectState(int32_t index) { zlock_guard l(m_mutex); return pumpSelectState[index]; } + +void GStateMgr::resetAcidUsed() { + zlock_guard l(m_mutex); + for (int i = 0; i < 4; i++) { + acidUsed[i] = 0.0; + } +} +float GStateMgr::getAcidUsed(int32_t index) { + zlock_guard l(m_mutex); + return acidUsed[index]; // add 0.5 for force change to int +} +void GStateMgr::appendAcidUsed(int32_t index, float val) { + zlock_guard l(m_mutex); + acidUsed[index] += val; +} + +void GStateMgr::setAcidRemain(int32_t index, float val) { + zlock_guard l(m_mutex); + acidRemain[index] = val; +} +float GStateMgr::getAcidRemain(int32_t index) { + zlock_guard l(m_mutex); + return acidRemain[index]; // add 0.5 for force change to int +} +void GStateMgr::decreaseAcidRemain(int32_t index, float val) { + zlock_guard l(m_mutex); + acidRemain[index] -= val; +} + bool GStateMgr::isHasPumpSelect() { zlock_guard l(m_mutex); for (int i = 0; i < 4; i++) { diff --git a/uappbase/service/gstate_mgr.hpp b/uappbase/service/gstate_mgr.hpp index 50bfabb..9d6901d 100644 --- a/uappbase/service/gstate_mgr.hpp +++ b/uappbase/service/gstate_mgr.hpp @@ -9,6 +9,8 @@ namespace iflytop { using namespace std; #define GSM GStateMgr::ins() +#define CH_NUM 4 + class GStateMgr { private: /* data */ @@ -17,12 +19,17 @@ class GStateMgr { bool m_isLogin; char m_loginUsr[MAX_USR_NAME_SIZE + 1]; + int32_t m_RemoterS; // 遥控器状态 1:在线,0:离线 + char m_RemoterName[20]; + int32_t m_AcidState; // 酸液桶状态 1:在线,0:离线 - int32_t m_RemoterS; // 遥控器状态 1:在线,0:离线 hand_acid_mode_t m_RunMode = khand_acid_m_jog_mode; // 运行模式 int32_t m_menuPage = 0; - bool pumpSelectState[4] = {false}; + bool pumpSelectState[CH_NUM] = {false}; + + float acidUsed[CH_NUM] = {0.0}; + float acidRemain[CH_NUM] = {0.0}; zmutex m_mutex = {"GStateMgr"}; @@ -43,7 +50,7 @@ class GStateMgr { const char* getLoginUsr(); void setAcidState(int32_t state); - void setRemoterS(int32_t state); + void setRemoterS(int32_t state, const char* name); void setRunMode(hand_acid_mode_t mode); void changeToNextRunMode(); @@ -54,10 +61,18 @@ class GStateMgr { hand_acid_mode_t getRunMode(); int32_t getMenuPage(); + bool isHasPumpSelect(); + void setPumpSelectState(int32_t index, bool state); bool getPumpSelectState(int32_t index); - bool isHasPumpSelect(); + void resetAcidUsed(); + float getAcidUsed(int32_t index); + void appendAcidUsed(int32_t index, float val); + + void setAcidRemain(int32_t index, float val); + float getAcidRemain(int32_t index); + void decreaseAcidRemain(int32_t index, float val); }; } // namespace iflytop \ No newline at end of file diff --git a/ui/hand_acid_mainboard_ui.HMI b/ui/hand_acid_mainboard_ui.HMI index 2d967da..21ad954 100644 Binary files a/ui/hand_acid_mainboard_ui.HMI and b/ui/hand_acid_mainboard_ui.HMI differ diff --git a/ui/hand_acid_mainboard_ui_v1.HMI b/ui/hand_acid_mainboard_ui_v1.HMI deleted file mode 100644 index 104c6e9..0000000 Binary files a/ui/hand_acid_mainboard_ui_v1.HMI and /dev/null differ diff --git a/ui/hand_acid_mainboard_zhaohe_edit.HMI b/ui/hand_acid_mainboard_zhaohe_edit.HMI deleted file mode 100644 index 0dbad61..0000000 Binary files a/ui/hand_acid_mainboard_zhaohe_edit.HMI and /dev/null differ diff --git a/ui/ui.h b/ui/ui.h index 44f9742..1e772f8 100644 --- a/ui/ui.h +++ b/ui/ui.h @@ -2,7 +2,7 @@ #define pg_gvar 0 #define pg_pStart 1 #define pg_login 2 -#define pg_main 3 +#define pg_home 3 #define pg_navi 4 #define pg_muInterval 5 #define pg_muUsrMgr 6 @@ -32,54 +32,54 @@ #define ob_login_uName 3 #define ob_login_uNameEMsg 4 #define ob_login_pwdEMsg 5 -//main.objs -#define ob_main_main 0 -#define ob_main_AcidCH0S 1 -#define ob_main_AcidCH1S 2 -#define ob_main_AcidCH2S 3 -#define ob_main_AcidCH3S 4 -#define ob_main_sysInfoPic 5 -#define ob_main_MenuButton 6 -#define ob_main_acidname0 7 -#define ob_main_acideval0 8 -#define ob_main_sysInfo 9 -#define ob_main_clock 10 -#define ob_main_acidname1 11 -#define ob_main_acideval1 12 -#define ob_main_acidname2 13 -#define ob_main_acideval2 14 -#define ob_main_acidname3 15 -#define ob_main_acideval3 16 -#define ob_main_p0 17 -#define ob_main_RemoterS 18 -#define ob_main_AcidState 19 -#define ob_main_RemoterS0 20 -#define ob_main_RemoterS1 21 -#define ob_main_AcidState0 22 -#define ob_main_AcidState1 23 -#define ob_main_AcidState2 24 -#define ob_main_RunMode 25 -#define ob_main_RunMode0 26 -#define ob_main_RunMode1 27 -#define ob_main_RunModeVal 28 -#define ob_main_StatUsedCH0 29 -#define ob_main_StatUsedCH1 30 -#define ob_main_StatUsedCH2 31 -#define ob_main_StatUsedCH3 32 -#define ob_main_StatRmidCH0 33 -#define ob_main_StatRmidCH1 34 -#define ob_main_StatRmidCH2 35 -#define ob_main_StatRmidCH3 36 -#define ob_main_SelCH0 37 -#define ob_main_SelCH1 38 -#define ob_main_SelCH2 39 -#define ob_main_SelCH3 40 -#define ob_main_CHState0 41 -#define ob_main_CHState1 42 -#define ob_main_tm0 43 -#define ob_main_str 44 -#define ob_main_weekArr 45 -#define ob_main_m0 46 +//home.objs +#define ob_home_home 0 +#define ob_home_AcidCH0S 1 +#define ob_home_AcidCH1S 2 +#define ob_home_AcidCH2S 3 +#define ob_home_AcidCH3S 4 +#define ob_home_sysInfoPic 5 +#define ob_home_MenuButton 6 +#define ob_home_acidname0 7 +#define ob_home_acideval0 8 +#define ob_home_sysInfo 9 +#define ob_home_clock 10 +#define ob_home_acidname1 11 +#define ob_home_acideval1 12 +#define ob_home_acidname2 13 +#define ob_home_acideval2 14 +#define ob_home_acidname3 15 +#define ob_home_acideval3 16 +#define ob_home_p0 17 +#define ob_home_RemoterS 18 +#define ob_home_AcidState 19 +#define ob_home_RemoterS0 20 +#define ob_home_RemoterS1 21 +#define ob_home_AcidState0 22 +#define ob_home_AcidState1 23 +#define ob_home_AcidState2 24 +#define ob_home_RunMode 25 +#define ob_home_RunMode0 26 +#define ob_home_RunMode1 27 +#define ob_home_RunModeVal 28 +#define ob_home_StatUsedCH0 29 +#define ob_home_StatUsedCH1 30 +#define ob_home_StatUsedCH2 31 +#define ob_home_StatUsedCH3 32 +#define ob_home_StatRmidCH0 33 +#define ob_home_StatRmidCH1 34 +#define ob_home_StatRmidCH2 35 +#define ob_home_StatRmidCH3 36 +#define ob_home_SelCH0 37 +#define ob_home_SelCH1 38 +#define ob_home_SelCH2 39 +#define ob_home_SelCH3 40 +#define ob_home_CHState0 41 +#define ob_home_CHState1 42 +#define ob_home_tm0 43 +#define ob_home_str 44 +#define ob_home_weekArr 45 +#define ob_home_m0 46 //navi.objs #define ob_navi_navi 0 #define ob_navi_bak 1 diff --git a/usrc/apphardware/apphardware.cpp b/usrc/apphardware/apphardware.cpp index 7659768..55ef589 100644 --- a/usrc/apphardware/apphardware.cpp +++ b/usrc/apphardware/apphardware.cpp @@ -11,8 +11,9 @@ void AppHardware::setTJCScreenInDownloadMode() { } void AppHardware::initialize() { - ZCAN1::ins()->zcaninit(CAN1_TX_PIN, CAN1_RX_PIN); + AppHal::rtc_init(); + ZCAN1::ins()->zcaninit(CAN1_TX_PIN, CAN1_RX_PIN); AppHal::tmc_spi_init(); // TJC SCREEN UART INIT diff --git a/usrc/db/type/acid_channel_cfg.hpp b/usrc/db/type/acid_channel_cfg.hpp index 5a6503c..fce260c 100644 --- a/usrc/db/type/acid_channel_cfg.hpp +++ b/usrc/db/type/acid_channel_cfg.hpp @@ -4,14 +4,17 @@ namespace iflytop { typedef struct { - uint8_t id; // 酸液通道id (0->3) + uint8_t id; // 酸液通道id (0->3) + + // 基础参数 char acidChooseName[MAX_ACID_NAME_LENGTH]; // 酸液0 选择的名字 float acidEachDistriVal; // 酸液0 distribution - float mLPR; // 电机0 uint16_t pumpDefVel; // 泵机默认速度r/min RPM float pipeLengthML; // 酸液管路长度 float chAppendMl; // 通道每次小回流的液体长度 + // 电机参数 + float mLPR; // 电机0 uint8_t irun; // 电机0 irun } AcidChannelCfg_t; diff --git a/usrc/service/app_core.cpp b/usrc/service/app_core.cpp index 0a77535..8707894 100644 --- a/usrc/service/app_core.cpp +++ b/usrc/service/app_core.cpp @@ -104,7 +104,13 @@ void AppCore::initialize() { UI::ins()->initialize(); UI::ins()->startSchedule(); UI::ins()->pageInit(); - UI::ins()->chpage(pg_login); + // UI::ins()->chpage(pg_login); + UI::ins()->chpage(pg_home); + + + + + while (true) osDelay(30); } diff --git a/usrc/service/remote_controler_event_processer.cpp b/usrc/service/remote_controler_event_processer.cpp index 6dd054d..7be744e 100644 --- a/usrc/service/remote_controler_event_processer.cpp +++ b/usrc/service/remote_controler_event_processer.cpp @@ -1,5 +1,6 @@ #include "remote_controler_event_processer.hpp" +#include "db/dao/device_setting_dao.hpp" #include "pump_ctrl_service.hpp" #include "service/remote_controler.hpp" @@ -20,7 +21,7 @@ static const char* zhex2str(uint8_t* data, size_t len) { void RemoteControlerEventProcesser::initialize() { m_thread.init(TAG); - GSM->setRemoterS(RemoteControlerUpper::ins()->isConnected()); + GSM->setRemoterS(RemoteControlerUpper::ins()->isConnected(), DeviceSettingDao::get()->bleClientName); RCTRL->regOnReport([this](uint8_t* rx, int32_t len) { // ZLOGI(TAG, "TRACE process ble report start"); @@ -36,15 +37,10 @@ void RemoteControlerEventProcesser::initialize() { if (packet->cmd == kzble_report_connected_event) { zble_connected_event_t* event = (zble_connected_event_t*)packet->data; - GSM->setRemoterS(true); - AppEvent_t appevent; - appevent.type = kAppEvent_BleConnectEvent; - strncpy(appevent.d.bleName, event->blename, sizeof(appevent.d.bleName)); + GSM->setRemoterS(true, event->blename); - ZLOGI(TAG, "on ble connect -> client name:%s", event->blename); - AppEventBus::ins()->pushEvent(appevent); } else if (packet->cmd == kzble_report_disconnect_event) { - GSM->setRemoterS(false); + GSM->setRemoterS(false, NULL); PUMPCS->stop(); } // ZLOGI(TAG, "TRACE process ble report end"); @@ -105,14 +101,14 @@ void RemoteControlerEventProcesser::processKeyEventFromRemoter(hand_acid_remoter /** * @brief 下面几个页面蓝牙手柄按下,不做任何反应,TODO */ -// if (UIS->getNowPage() == pg_login || UIS->getNowPage() == pg_pStart || UIS->getNowPage() == pg_muBleHandSett || UIS->getNowPage() == pg_muPumpTest) { -// return; -// } + // if (UIS->getNowPage() == pg_login || UIS->getNowPage() == pg_pStart || UIS->getNowPage() == pg_muBleHandSett || UIS->getNowPage() == pg_muPumpTest) { + // return; + // } /** * @brief 如果不在首页,则报警 */ - if (UIS->getNowPage() != pg_main) { + if (UIS->getNowPage() != pg_home) { UIS->alert("请先切换到首页,在控制设备"); return; } diff --git a/usrc/uicontroler/base/page_processer.cpp b/usrc/uicontroler/base/page_processer.cpp index bb3b2c8..379f450 100644 --- a/usrc/uicontroler/base/page_processer.cpp +++ b/usrc/uicontroler/base/page_processer.cpp @@ -20,8 +20,11 @@ IPageProcesser::IPageProcesser(const char* name, uint32_t pageId) { } void IPageProcesser::initialize() { + ZLOGI(TAG, "initialize page %s %d", pageName, pageId); AppEventBus::ins()->regOnEvent([this](AppEvent_t* event) { + // ZLOGI(TAG, "event type %s %d", pageName, event->type); + if (event->type == KAE_UIEvent) { if (pageId != event->d.uiEvent.pid) { return; @@ -37,6 +40,8 @@ void IPageProcesser::initialize() { } else if (event->d.uiEvent.eventId == tjc::kpt_inputfield_content_change_event1) { OnInputFieldContentChange(event->d.uiEvent.bid, event->d.uiEvent.d.inputfield_content.text); } + + // } else { OnAppEvent(event); } @@ -46,7 +51,7 @@ void IPageProcesser::initialize() { namespace iflytop { void UIPageInit() { for (size_t i = 0; i < m_pageNum; i++) { - ZLOGI(TAG, "initialize page %s %d", m_pages[i]->pageName, m_pages[i]->pageId); + // ZLOGI(TAG, "initialize page %s %d", m_pages[i]->pageName, m_pages[i]->pageId); m_pages[i]->initialize(); } } diff --git a/usrc/uicontroler/front_end_controler.cpp b/usrc/uicontroler/front_end_controler.cpp index 2bed284..4b16da4 100644 --- a/usrc/uicontroler/front_end_controler.cpp +++ b/usrc/uicontroler/front_end_controler.cpp @@ -351,6 +351,17 @@ bool UI::setTxt(uint8_t pid, uint8_t bid, const char* txt, ...) { sendcmd("p[%d].b[%d].txt=\"%s\"", pid, bid, buf); return true; } + +void UI::setPicturePicNum(uint8_t pid, uint8_t bid, uint8_t fromBid) { + zlock_guard lg(m_cmdlock); + sendcmd("p[%d].b[%d].pic=p[%d].b[%d].pic", pid, bid, pid, fromBid); +} +void UI::setButtonPicNum(uint8_t pid, uint8_t bid, uint8_t fromBid) { + zlock_guard lg(m_cmdlock); + sendcmd("p[%d].b[%d].pic=p[%d].b[%d].pic", pid, bid, pid, fromBid); + sendcmd("p[%d].b[%d].pic2=p[%d].b[%d].pic2", pid, bid, pid, fromBid); +} + bool UI::setVal(uint8_t pid, uint8_t cid, int32_t val) { zlock_guard lg(m_cmdlock); sendcmd("p[%d].b[%d].val=%d", pid, cid, val); @@ -362,6 +373,16 @@ bool UI::vis(uint16_t buuid, int32_t val) { return true; } +void UI::setrtc(zdate_t* date) { + zlock_guard lg(m_cmdlock); + sendcmd("rtc0=%d", date->year); + sendcmd("rtc1=%d", date->month); + sendcmd("rtc2=%d", date->day); + sendcmd("rtc3=%d", date->hours); + sendcmd("rtc4=%d", date->minutes); + sendcmd("rtc5=%d", date->seconds); +} + void UI::alert(const char* info, function onConfirm) { zlock_guard lg(m_cmdlock); // if (m_isInPopWin) { diff --git a/usrc/uicontroler/front_end_controler.hpp b/usrc/uicontroler/front_end_controler.hpp index 1e0ba09..8d220e9 100644 --- a/usrc/uicontroler/front_end_controler.hpp +++ b/usrc/uicontroler/front_end_controler.hpp @@ -12,7 +12,6 @@ typedef struct { uint16_t datalen; } tjc_rx_packet_t; - #define UIS UI::ins() class UI { ZThread m_thread; @@ -22,11 +21,9 @@ class UI { tjc::UIEvent event_cache; - int32_t m_nowPage = 0; int32_t m_lastPage = 0; - public: UI() {}; ~UI() {}; @@ -48,16 +45,15 @@ class UI { bool echo(uint8_t tx, uint8_t* rx); bool setTxt(uint8_t pid, uint8_t bid, const char* txt, ...); - // bool setTxt(uint8_t bid, const char* txt) { return setTxt(m_nowPage, bid, txt); } - bool setVal(uint8_t pid, uint8_t bid, int32_t val); - // bool setVal(uint8_t bid, int32_t val) { return setVal(m_nowPage, bid, val); } + void setPicturePicNum(uint8_t pid, uint8_t bid, uint8_t fromBid); + void setButtonPicNum(uint8_t pid, uint8_t bid, uint8_t fromBid); + + bool setVal(uint8_t pid, uint8_t bid, int32_t val); bool vis(uint16_t bid, int32_t val); // 不支持跨页面隐藏 // vis b0,0 - // bool readTxt(uint16_t buuid, char* txt, int32_t txtbuflen) { return readTxt(buuid >> 8, buuid & 0xff, txt, txtbuflen); } - // bool readInt(uint16_t buuid, int32_t* val) { return readInt(buuid >> 8, buuid & 0xff, val); } void alert(const char* info) { alert(info, nullptr); } void alertNoConfirm(const char* info); @@ -67,6 +63,8 @@ class UI { void confirm(const char* info, function onConfirm); void chpage(uint8_t page); + void setrtc(zdate_t* date); + // void bakpage(); void virtualClick(uint8_t pid, uint8_t bid, uint8_t event); void setTouchEnableState(uint8_t bid, uint8_t enable); diff --git a/usrc/uicontroler/page.bak/Page_login.cpp b/usrc/uicontroler/page.bak/Page_login.cpp deleted file mode 100644 index 69e291a..0000000 --- a/usrc/uicontroler/page.bak/Page_login.cpp +++ /dev/null @@ -1,97 +0,0 @@ -#include "Page_login.hpp" - -#include - -#include "db/dao/user_dao.hpp" - -using namespace iflytop; -#define TAG "Page_login" - -#define PAGE pg_login -#define OBJ(name) ob_login_##name - -static int usrNum; -static char usrName[10][20]; - -// UIS->sendcmd("p[%d].b[%d].picc=%d", PAGE, OBJ(txtUser##i), 2); -#define EN_USR(i, enable) \ - if (enable) { \ - UIS->setTxt(PAGE, OBJ(txtUser##i), usrName[i]); \ - UIS->setVal(PAGE, OBJ(uen##i), 1); \ - } else { \ - UIS->setTxt(PAGE, OBJ(txtUser##i), ""); \ - UIS->setVal(PAGE, OBJ(uen##i), (int32_t)0); \ - } - -bool Page_login::isBelongThisPage(int page) { return page == PAGE; } - -void Page_login::OnPageLoad(OnPageLoadContext* cxt) { - // - - user_t* users = nullptr; - UserDao::getUsers(&users, &usrNum); - for (int i = 0; i < usrNum; i++) { - strcpy(usrName[i], users[i].name); - } - - /** - * @brief 加载用户信息 - */ - - // EN_USR(0, enusrNum >= 1); - // EN_USR(1, enusrNum >= 2); - // EN_USR(2, enusrNum >= 3); - // EN_USR(3, enusrNum >= 4); - // EN_USR(4, enusrNum >= 5); - // EN_USR(5, enusrNum >= 6); - - // if (!cxt->isFromPopWin) { - // UIS->setVal(PAGE, OBJ(chooseUsr), (int32_t)0); - // UIS->setTxt(PAGE, OBJ(cUsrName), getCfgStr((config_index_t)(kusr_name0))); - // UIS->setTxt(PAGE, OBJ(txtPasswd), ""); - // } - - // UIS->sendcmd("click m0,0"); -} -void Page_login::OnInputFieldContentChange(uint8_t bid, const char* text) { - if (bid == OBJ(txtPasswd)) { - UIS->setTxt(PAGE, bid, text); - UIS->virtualClick(PAGE, OBJ(blogin), 0); // 触发一次登录按钮虚拟点击事件 - } -} - -void Page_login::OnLoginButtonClick(uint8_t bid, const char* userName, const char* passwd) { - - // // - // ZLOGI(TAG, "try login %s %s", userName, passwd); - // const char* curUsrPasswd = getPasswd(userName, &passwdcfgcache); - // if (!curUsrPasswd) { - // UIS->setTxt(PAGE, OBJ(txtPasswd), ""); - // UIS->alert("用户不存在"); - // return; - // } - // if (strlen(curUsrPasswd) == 0) { - // UIS->setTxt(PAGE, OBJ(txtPasswd), ""); - // UIS->alert("密码为空"); - // return; - // } - - // if (strcmp(curUsrPasswd, passwd) != 0) { - // UIS->setTxt(PAGE, OBJ(txtPasswd), ""); - // UIS->alert("密码错误"); - // return; - // } - - // if (strcmp(userName, getCfgStr(kusr_name0)) == 0) { - // ZLOGI(TAG, "%s(admin) login success ", userName); - // GSM->setLogin(true, false, userName); - // } else { - // ZLOGI(TAG, "%s login success ", userName); - // GSM->setLogin(false, false, userName); - // } - - // UIS->chpage(pg_main); - // GSM->setMenuPage(GSM->isAdmin() ? pg_menuAdmin2 : pg_menuUsr); - - return; -} diff --git a/usrc/uicontroler/page.bak/Page_login.hpp b/usrc/uicontroler/page.bak/Page_login.hpp deleted file mode 100644 index 0d7b9c3..0000000 --- a/usrc/uicontroler/page.bak/Page_login.hpp +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once -#include "uicontroler/base/page_processer.hpp" -namespace iflytop { -using namespace std; - -class Page_login : public IPageProcesser { - private: - /* data */ - - - public: - static Page_login* ins() { - static Page_login instance; - return &instance; - } - - private: - bool isBelongThisPage(int page); - - virtual void OnPageLoad(OnPageLoadContext*cxt) override; - virtual void OnLoginButtonClick(uint8_t bid, const char* userName, const char* passwd) override; - virtual void OnInputFieldContentChange(uint8_t bid, const char* text) override; -}; - -} // namespace iflytop - -// kpt_sys_event_page_id \ No newline at end of file diff --git a/usrc/uicontroler/page.bak/Page_main.cpp b/usrc/uicontroler/page.bak/Page_main.cpp deleted file mode 100644 index f26ac29..0000000 --- a/usrc/uicontroler/page.bak/Page_main.cpp +++ /dev/null @@ -1,244 +0,0 @@ -#include "Page_main.hpp" - -#include "db/dao/acid_ch_cfg_dao.hpp" -#include "db/dao/device_setting_dao.hpp" -#include "service\pump_ctrl_service.hpp" -#include "ui/usrui.h" -using namespace iflytop; - -#define PAGE pg_main -#define TAG "Page_main" - -#define ADMIN_MENU_ID pg_menuAdmin2 -#define USR_MENU_ID pg_menuUsr - -static const char* fmt(const char* fmt, ...) { - static char buf[128]; - va_list args; - va_start(args, fmt); - vsnprintf(buf, sizeof(buf), fmt, args); - va_end(args); - return buf; -} - -/** - * @brief - * - * 1.对接遥控器状态 - * 2.对接阀门控制板的状态(直接隐藏掉) - * - */ -void Page_main::updateRunModeState() { - // 更新底部状态栏 - if ((int32_t)GSM->getRunMode() == khand_acid_m_jog_mode) { - UIS->setPic(PAGE, ob_main_RunMode, pic_jog_mode); - } else { - UIS->setPic(PAGE, ob_main_RunMode, pic_continuous_mode); - } - - UIS->setEnumComponentState(PAGE, ob_main_RunMode, (int32_t)GSM->getRunMode()); // 运行模式 - if (GSM->getRunMode() == khand_acid_m_jog_mode) { - UIS->vis(ob_main_RunModeVal, 0); - UIS->vis(ob_main_RunModeValUint, 0); - } else { - UIS->vis(ob_main_RunModeVal, 1); - UIS->vis(ob_main_RunModeValUint, 1); - UIS->setTxt(PAGE, ob_main_RunModeVal, "%.1f", DeviceSettingDao::get()->distrIntervalS); // 加酸间隔状态更新 - } -} - -bool Page_main::isBelongThisPage(int page) { return page == PAGE; } - -void Page_main::OnPageLoad(OnPageLoadContext* cxt) { - // 只有管理员能够修改,酸液通道名称 - if (GSM->isAdmin()) { - UIS->setTouchEnableState(ob_main_acidname0, 1); - UIS->setTouchEnableState(ob_main_acidname1, 1); - UIS->setTouchEnableState(ob_main_acidname2, 1); - UIS->setTouchEnableState(ob_main_acidname3, 1); - } else { - UIS->setTouchEnableState(ob_main_acidname0, 0); - UIS->setTouchEnableState(ob_main_acidname1, 0); - UIS->setTouchEnableState(ob_main_acidname2, 0); - UIS->setTouchEnableState(ob_main_acidname3, 0); - } - // 更新底部 - updateRunModeState(); - - // 更新酸液种类 - UIS->setTxt(PAGE, ob_main_acidname0, AcidChCfgDao::getCfg(0)->acidChooseName); - UIS->setTxt(PAGE, ob_main_acidname1, AcidChCfgDao::getCfg(1)->acidChooseName); - UIS->setTxt(PAGE, ob_main_acidname2, AcidChCfgDao::getCfg(2)->acidChooseName); - UIS->setTxt(PAGE, ob_main_acidname3, AcidChCfgDao::getCfg(3)->acidChooseName); - // 更新加液体积 - UIS->setTxt(PAGE, ob_main_acideval0, "%.2f", AcidChCfgDao::getCfg(0)->acidEachDistriVal); - UIS->setTxt(PAGE, ob_main_acideval1, "%.2f", AcidChCfgDao::getCfg(1)->acidEachDistriVal); - UIS->setTxt(PAGE, ob_main_acideval2, "%.2f", AcidChCfgDao::getCfg(2)->acidEachDistriVal); - UIS->setTxt(PAGE, ob_main_acideval3, "%.2f", AcidChCfgDao::getCfg(3)->acidEachDistriVal); - // 更新顶部状态栏 - UIS->setEnumComponentState(PAGE, ob_main_AcidState, GSM->getAcidState()); // 酸液锁是否在线 - UIS->setAph(PAGE, ob_main_AcidState, 0); // 暂时隐藏掉Aph - UIS->setEnumComponentState(PAGE, ob_main_RemoterS, GSM->getRemoterS()); // 遥控器是否在线 - - UIS->setVal(PAGE, ob_main_acidch0, GSM->getPumpSelectState(0)); - UIS->setVal(PAGE, ob_main_acidch1, GSM->getPumpSelectState(1)); - UIS->setVal(PAGE, ob_main_acidch2, GSM->getPumpSelectState(2)); - UIS->setVal(PAGE, ob_main_acidch3, GSM->getPumpSelectState(3)); - - // 时间位置暂时显示版本号 - UIS->setTxt(PAGE, ob_main_clock, ""); - // UIS->setTxt(PAGE, ob_main_clock, "版本:%s", APP_VERSION); - - // 根据当前登录用户设置菜单页面 -} - -void Page_main::OnAppEvent(AppEvent_t* event) { - if (event->type == kAppEvent_RunModeChangeEvent) { - updateRunModeState(); - UIS->setTxt(PAGE, ob_main_sysInfo, "切换模式"); - } - - if (event->type == kAppEvent_RemoterConnectStateChangeEvent) { - UIS->setEnumComponentState(PAGE, ob_main_RemoterS, GSM->getRemoterS()); - if (GSM->getRemoterS()) { - UIS->setTxt(PAGE, ob_main_sysInfo, "连接上手柄"); - } else { - UIS->setTxt(PAGE, ob_main_sysInfo, "断开手柄连接"); - } - } - - if (event->type == kAppEvent_StateDisplayInfo) { - UIS->setTxt(PAGE, ob_main_sysInfo, event->d.stateDisplayInfo); - } - - return; -}; - -void Page_main::OnInputFieldContentChange(uint8_t bid, const char* text) { - /*********************************************************************************************************************** - * 事件过滤 * - ***********************************************************************************************************************/ - if (PumpCtrlService::ins()->isWorking()) { - UIS->alert("工作中,请稍后再操作"); - return; - } - - // 运行间隔设定值 - if (bid == ob_main_RunModeVal) { - float distrIntervalSSecond = atof(text); - if (distrIntervalSSecond <= 0) { - UIS->alert("酸液间隔时间不能小于0"); - return; - } - if (distrIntervalSSecond > 30) { - UIS->alert("酸液间隔时间不能大于30"); - return; - } - } - - // 加酸设定值过滤 - if (bid == ob_main_acideval0 || // - bid == ob_main_acideval1 || // - bid == ob_main_acideval2 || // - bid == ob_main_acideval3) { - float add_ml = atof(text); - if (add_ml < 0.009) { - UIS->alert("设定值不能小于0"); - return; - } else if (add_ml > DeviceSettingDao::get()->echDitrUpLimit) { - UIS->alert(fmt("设定值不能大于%d", DeviceSettingDao::get()->echDitrUpLimit)); - return; - } - } - - /*********************************************************************************************************************** - * 业务逻辑 * - ***********************************************************************************************************************/ - // 更新酸液每次分配设定值 - if (bid == ob_main_acideval0) { - processAcidevalUpdateEvent(bid, text, 0); - } else if (bid == ob_main_acideval1) { - processAcidevalUpdateEvent(bid, text, 1); - } else if (bid == ob_main_acideval2) { - processAcidevalUpdateEvent(bid, text, 2); - } else if (bid == ob_main_acideval3) { - processAcidevalUpdateEvent(bid, text, 3); - } - - // 修改酸液名称 - else if (bid == ob_main_acidname0) { - ZLOGI(TAG, "acidname0:%s", text); - AcidChCfgDao::updatekCfgAcidChooseName(0, text); - UIS->setTxt(PAGE, bid, text); - } else if (bid == ob_main_acidname1) { - ZLOGI(TAG, "acidname1:%s", text); - AcidChCfgDao::updatekCfgAcidChooseName(1, text); - UIS->setTxt(PAGE, bid, text); - } else if (bid == ob_main_acidname2) { - ZLOGI(TAG, "acidname2:%s", text); - AcidChCfgDao::updatekCfgAcidChooseName(2, text); - UIS->setTxt(PAGE, bid, text); - } else if (bid == ob_main_acidname3) { - ZLOGI(TAG, "acidname3:%s", text); - AcidChCfgDao::updatekCfgAcidChooseName(3, text); - UIS->setTxt(PAGE, bid, text); - } - - // 设置加酸间隔 - if (bid == ob_main_RunModeVal) { - float distrIntervalSSecond = atof(text); - UIS->setTxt(PAGE, bid, zfmt("%.1f", distrIntervalSSecond)); - // CS->setcfgAndFlush(kcfg_distrIntervalS, zfmt("%.1f", distrIntervalSSecond)); - DeviceSettingDao::updatedistrIntervalS(distrIntervalSSecond); - } -} - -void Page_main::OnButton(uint8_t bid, uint8_t val) { - /*********************************************************************************************************************** - * 事件过滤 * - ***********************************************************************************************************************/ - if (bid == ob_main_RunMode || // - bid == ob_main_acidch0 || // - bid == ob_main_acidch1 || // - bid == ob_main_acidch2 || // - bid == ob_main_acidch3 || // - bid == ob_main_MenuButton // - ) { - if (PumpCtrlService::ins()->isWorking()) { - UIS->alert("工作中,请稍后再操作"); - return; - } - } - - /*********************************************************************************************************************** - * 业务逻辑 * - ***********************************************************************************************************************/ - if (bid == ob_main_RunMode) { - // 切换模式 - GSM->changeToNextRunMode(); - } else if (bid == ob_main_acidch0) { - // 选中(取消选中)加酸泵0 - ZLOGI(TAG, "choose acid ch%d,%d", 0, val); - GSM->setPumpSelectState(0, val); - } else if (bid == ob_main_acidch1) { - // 选中(取消选中)加酸泵1 - ZLOGI(TAG, "choose acid ch%d,%d", 1, val); - GSM->setPumpSelectState(1, val); - } else if (bid == ob_main_acidch2) { - // 选中(取消选中)加酸泵2 - ZLOGI(TAG, "choose acid ch%d,%d", 2, val); - GSM->setPumpSelectState(2, val); - } else if (bid == ob_main_acidch3) { - // 选中(取消选中)加酸泵3 - ZLOGI(TAG, "choose acid ch%d,%d", 3, val); - GSM->setPumpSelectState(3, val); - } else if (bid == ob_main_MenuButton) { - UIS->chpage(GSM->getMenuPage()); - } -} - -void Page_main::processAcidevalUpdateEvent(uint8_t bid, const char* text, int ch) { - ZLOGI(TAG, "set acid ch%d:%s", ch, text); - UIS->setTxt(PAGE, bid, refmt("%.1f", text)); - AcidChCfgDao::updateAcidEachDistriVal(ch, atof(text)); -} diff --git a/usrc/uicontroler/page.bak/Page_main.hpp b/usrc/uicontroler/page.bak/Page_main.hpp deleted file mode 100644 index f154e15..0000000 --- a/usrc/uicontroler/page.bak/Page_main.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once -#include "uicontroler/base/page_processer.hpp" - -namespace iflytop { -using namespace std; - -class Page_main : public IPageProcesser { - private: - /* data */ - - public: - static Page_main* ins() { - static Page_main instance; - return &instance; - } - - private: - virtual bool isBelongThisPage(int page)override; - - virtual void OnPageLoad(OnPageLoadContext*cxt) override; - virtual void OnButton(uint8_t bid, uint8_t val) override; - virtual void OnInputFieldContentChange(uint8_t bid, const char* text) override; - virtual void OnAppEvent(AppEvent_t* event) override; - - private: - void processAcidevalUpdateEvent(uint8_t bid, const char* text, int ch); - void updateRunModeState(); -}; - -} // namespace iflytop diff --git a/usrc/uicontroler/page.bak/Page_menu.cpp b/usrc/uicontroler/page.bak/Page_menu.cpp deleted file mode 100644 index 2dd128f..0000000 --- a/usrc/uicontroler/page.bak/Page_menu.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "Page_menu.hpp" -using namespace iflytop; - -#define PAGE pg_main -#define TAG "Page_menu" - -/** - * @brief - * - * 1.对接遥控器状态 - * 2.对接阀门控制板的状态(直接隐藏掉) - * - */ - -bool Page_menu::isBelongThisPage(int page) { - if (page == pg_menuAdmin) return true; - if (page == pg_menuAdmin2) return true; - if (page == pg_menuUsr) return true; - if (page == pg_muneWarehouse) return true; - return false; -} - -void Page_menu::OnUnLoginButtonClick(uint8_t bid) { - ZLOGI(TAG, "OnUnLoginButtonClick"); - GSM->setUnLogin(); - UIS->chpage(pg_login); - return; -}; diff --git a/usrc/uicontroler/page.bak/Page_menu.hpp b/usrc/uicontroler/page.bak/Page_menu.hpp deleted file mode 100644 index afe443b..0000000 --- a/usrc/uicontroler/page.bak/Page_menu.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once -#include "uicontroler/base/page_processer.hpp" - -namespace iflytop { -using namespace std; - -class Page_menu : public IPageProcesser { - private: - /* data */ - - public: - static Page_menu* ins() { - static Page_menu instance; - return &instance; - } - - private: - virtual bool isBelongThisPage(int page)override; - - - - virtual void OnUnLoginButtonClick(uint8_t bid); -}; - -} // namespace iflytop diff --git a/usrc/uicontroler/page.bak/keyboard/Page_keybAcidCh.cpp b/usrc/uicontroler/page.bak/keyboard/Page_keybAcidCh.cpp deleted file mode 100644 index 5a1a5b4..0000000 --- a/usrc/uicontroler/page.bak/keyboard/Page_keybAcidCh.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "Page_keybAcidCh.hpp" - -#include "db/dao/acid_name_dao.hpp" -using namespace iflytop; - -#define TAG "Page_keybAcidCh" -#define PAGE pg_keybAcidCh -#define OBJ(name) ob_keybAcidCh_##name - -bool Page_keybAcidCh::isBelongThisPage(int page) { return page == PAGE; } - -void Page_keybAcidCh::OnKeyboardPageLoad() { - ZLOGI(TAG, "Page_keybAcidCh::OnKeyboardPageLoad"); - UIS->setTxt(PAGE, OBJ(b0), AcidNameDao::getAcidName(0)); - UIS->setTxt(PAGE, OBJ(b1), AcidNameDao::getAcidName(1)); - UIS->setTxt(PAGE, OBJ(b2), AcidNameDao::getAcidName(2)); - UIS->setTxt(PAGE, OBJ(b3), AcidNameDao::getAcidName(3)); - UIS->setTxt(PAGE, OBJ(b4), AcidNameDao::getAcidName(4)); - UIS->setTxt(PAGE, OBJ(b5), AcidNameDao::getAcidName(5)); - UIS->setTxt(PAGE, OBJ(b6), AcidNameDao::getAcidName(6)); - UIS->setTxt(PAGE, OBJ(b7), AcidNameDao::getAcidName(7)); - UIS->setTxt(PAGE, OBJ(b8), AcidNameDao::getAcidName(8)); - UIS->setTxt(PAGE, OBJ(b9), AcidNameDao::getAcidName(9)); - UIS->setTxt(PAGE, OBJ(b10), AcidNameDao::getAcidName(10)); - UIS->setTxt(PAGE, OBJ(b11), AcidNameDao::getAcidName(11)); - UIS->setTxt(PAGE, OBJ(b12), AcidNameDao::getAcidName(12)); - UIS->setTxt(PAGE, OBJ(b13), AcidNameDao::getAcidName(13)); - UIS->setTxt(PAGE, OBJ(b14), AcidNameDao::getAcidName(14)); - return; -}; - -// muAcidType \ No newline at end of file diff --git a/usrc/uicontroler/page.bak/keyboard/Page_keybAcidCh.hpp b/usrc/uicontroler/page.bak/keyboard/Page_keybAcidCh.hpp deleted file mode 100644 index ec161e8..0000000 --- a/usrc/uicontroler/page.bak/keyboard/Page_keybAcidCh.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once -// -#include "uicontroler/base/page_processer.hpp" - -namespace iflytop { -using namespace std; -// page: keybAcidCh -class Page_keybAcidCh : public IPageProcesser { - public: - static Page_keybAcidCh* ins() { - static Page_keybAcidCh instance; - return &instance; - } - - private: - virtual bool isBelongThisPage(int page) override; - virtual void OnKeyboardPageLoad() override; -}; - -} // namespace iflytop diff --git a/usrc/uicontroler/page.bak/page.hpp b/usrc/uicontroler/page.bak/page.hpp deleted file mode 100644 index 73aaaf6..0000000 --- a/usrc/uicontroler/page.bak/page.hpp +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -// #include "Page_login.hpp" -// #include "Page_main.hpp" -// #include "Page_menu.hpp" -// #include "keyboard/Page_keybAcidCh.hpp" -// #include "submenu/Page_changePasswd.hpp" -// #include "submenu/Page_muAcidType.hpp" -// #include "submenu/Page_muAudit.hpp" -// #include "submenu/Page_muDeviceInfo.hpp" -// #include "submenu/Page_muInterval.hpp" -// #include "submenu/Page_muPumpTest.hpp" -// #include "submenu/Page_muSettings.hpp" -// #include "submenu/Page_muUsrMgr.hpp" - -// // -// #include "submenu/Page_muBleHandSett.hpp" -// #include "submenu/Page_muMotorSett.hpp" -// #include "submenu/Page_muPumpSett.hpp" \ No newline at end of file diff --git a/usrc/uicontroler/page.bak/submenu/Page_changePasswd.cpp b/usrc/uicontroler/page.bak/submenu/Page_changePasswd.cpp deleted file mode 100644 index ace73fc..0000000 --- a/usrc/uicontroler/page.bak/submenu/Page_changePasswd.cpp +++ /dev/null @@ -1,79 +0,0 @@ -#include "Page_changePasswd.hpp" - -#include "db/dao/user_dao.hpp" -using namespace iflytop; - -/** - * @brief - * 酸类修改页面 - */ - -#define PAGE pg_changePasswd -#define TAG "Page_changePasswd" - -bool Page_changePasswd::isBelongThisPage(int page) { return page == PAGE; } - -void Page_changePasswd::OnPageLoad(OnPageLoadContext* cxt) { - if (!cxt->isFromPopWin) { - memset(oldpasswdBuf, 0, sizeof(oldpasswdBuf)); - memset(newpasswdBuf, 0, sizeof(newpasswdBuf)); - memset(confirmPasswdBuf, 0, sizeof(confirmPasswdBuf)); - } - - UIS->setTxt(PAGE, ob_changePasswd_oldPwd, oldpasswdBuf); - UIS->setTxt(PAGE, ob_changePasswd_newPwd, newpasswdBuf); - UIS->setTxt(PAGE, ob_changePasswd_newPwdCfm, confirmPasswdBuf); -}; - -void Page_changePasswd::OnInputFieldContentChange(uint8_t bid, const char* text) { - user_t* user = UserDao::getUserByName(GSM->getLoginUsr()); - - if (user == nullptr) { - UIS->alert("用户不存在"); - return; - } - - if (bid == ob_changePasswd_oldPwd) { // 旧密码 - if (strcmp(user->passwd, text) != 0) { - UIS->alert("旧密码错误"); - return; - } - UIS->setTxt(PAGE, bid, text); - strcpy(oldpasswdBuf, text); - - } else if (bid == ob_changePasswd_newPwd) { // 新密码 - strcpy(newpasswdBuf, text); - UIS->setTxt(PAGE, bid, text); - } else if (bid == ob_changePasswd_newPwdCfm) { // 新密码确认 - strcpy(confirmPasswdBuf, text); - UIS->setTxt(PAGE, bid, text); - } -} -void Page_changePasswd::OnButton(uint8_t bid, uint8_t val) { - - // - if (bid == ob_changePasswd_confirm) { - user_t* user = UserDao::getUserByName(GSM->getLoginUsr()); - - if (user == nullptr) { - UIS->alert("用户不存在"); - return; - } - - if (strcmp(user->passwd, oldpasswdBuf) != 0) { - UIS->alert("旧密码错误"); - return; - } - if (strcmp(newpasswdBuf, confirmPasswdBuf) != 0) { - UIS->alert("两次密码不一致"); - return; - } - UserDao::updateUserPasswd(GSM->getLoginUsr(), newpasswdBuf); - - UIS->confirmNoCancle("密码修改成功"); - } else if (bid == ob_changePasswd_bak) { - UIS->chpage(GSM->getMenuPage()); - } -}; - -// muAcidType \ No newline at end of file diff --git a/usrc/uicontroler/page.bak/submenu/Page_changePasswd.hpp b/usrc/uicontroler/page.bak/submenu/Page_changePasswd.hpp deleted file mode 100644 index ce096e3..0000000 --- a/usrc/uicontroler/page.bak/submenu/Page_changePasswd.hpp +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once -// -#include "uicontroler/base/page_processer.hpp" -namespace iflytop { -using namespace std; -// page: keybAcidCh -class Page_changePasswd : public IPageProcesser { - private: - /* data */ - - char oldpasswdBuf[30]; - char newpasswdBuf[30]; - char confirmPasswdBuf[30]; - - public: - static Page_changePasswd* ins() { - static Page_changePasswd instance; - return &instance; - } - - private: - virtual bool isBelongThisPage(int page) override; - - virtual void OnPageLoad(OnPageLoadContext*cxt) override; - virtual void OnInputFieldContentChange(uint8_t bid, const char* text) override; - virtual void OnButton(uint8_t bid, uint8_t val) override; - - private: -}; - -} // namespace iflytop diff --git a/usrc/uicontroler/page.bak/submenu/Page_muAcidType.cpp b/usrc/uicontroler/page.bak/submenu/Page_muAcidType.cpp deleted file mode 100644 index 12414da..0000000 --- a/usrc/uicontroler/page.bak/submenu/Page_muAcidType.cpp +++ /dev/null @@ -1,105 +0,0 @@ -#include "Page_muAcidType.hpp" - -#include "db/dao/acid_name_dao.hpp" -using namespace iflytop; - -/** - * @brief - * 酸类修改页面 - */ - -#define PAGE pg_muAcidType -#define OBJ(name) ob_muAcidType_##name -#define TAG "Page_muAcidType" -bool Page_muAcidType::isBelongThisPage(int page) { return page == PAGE; } - -static int getAcidOff(int bid) { - switch (bid) { - case OBJ(t1): - return 0; - case OBJ(t2): - return 1; - case OBJ(t3): - return 2; - case OBJ(t4): - return 3; - case OBJ(t5): - return 4; - case OBJ(t6): - return 5; - case OBJ(t7): - return 6; - case OBJ(t8): - return 7; - case OBJ(t9): - return 8; - case OBJ(t10): - return 9; - case OBJ(t11): - return 10; - case OBJ(t12): - return 11; - case OBJ(t13): - return 12; - case OBJ(t14): - return 13; - case OBJ(t15): - return 14; - default: - return 0; - } -} - -void Page_muAcidType::OnPageLoad(OnPageLoadContext* cxt) { // - UIS->setTxt(PAGE, OBJ(t1), AcidNameDao::getAcidName(0)); - UIS->setTxt(PAGE, OBJ(t2), AcidNameDao::getAcidName(1)); - UIS->setTxt(PAGE, OBJ(t3), AcidNameDao::getAcidName(2)); - UIS->setTxt(PAGE, OBJ(t4), AcidNameDao::getAcidName(3)); - UIS->setTxt(PAGE, OBJ(t5), AcidNameDao::getAcidName(4)); - UIS->setTxt(PAGE, OBJ(t6), AcidNameDao::getAcidName(5)); - UIS->setTxt(PAGE, OBJ(t7), AcidNameDao::getAcidName(6)); - UIS->setTxt(PAGE, OBJ(t8), AcidNameDao::getAcidName(7)); - UIS->setTxt(PAGE, OBJ(t9), AcidNameDao::getAcidName(8)); - UIS->setTxt(PAGE, OBJ(t10), AcidNameDao::getAcidName(9)); - UIS->setTxt(PAGE, OBJ(t11), AcidNameDao::getAcidName(10)); - UIS->setTxt(PAGE, OBJ(t12), AcidNameDao::getAcidName(11)); - UIS->setTxt(PAGE, OBJ(t13), AcidNameDao::getAcidName(12)); - UIS->setTxt(PAGE, OBJ(t14), AcidNameDao::getAcidName(13)); - UIS->setTxt(PAGE, OBJ(t15), AcidNameDao::getAcidName(14)); -}; -void Page_muAcidType::updateAcidName(uint8_t bid, const char* txt) { - ZLOGI(TAG, "updateAcidName: cindex %d : %s", getAcidOff(bid), txt); - UIS->setTxt(PAGE, bid, txt); - AcidNameDao::updateAcidName(getAcidOff(bid), txt); -} - -void Page_muAcidType::OnInputFieldContentChange(uint8_t bid, const char* text) { // - switch (bid) { - case OBJ(t1): - case OBJ(t2): - case OBJ(t3): - case OBJ(t4): - case OBJ(t5): - case OBJ(t6): - case OBJ(t7): - case OBJ(t8): - case OBJ(t9): - case OBJ(t10): - case OBJ(t11): - case OBJ(t12): - case OBJ(t13): - case OBJ(t14): - case OBJ(t15): - updateAcidName(bid, text); - break; - default: - break; - } -}; -void Page_muAcidType::OnButton(uint8_t bid, uint8_t val) { // - if (bid == OBJ(bak)) { - UIS->chpage(GSM->getMenuPage()); - } -}; - -// muAcidType \ No newline at end of file diff --git a/usrc/uicontroler/page.bak/submenu/Page_muAcidType.hpp b/usrc/uicontroler/page.bak/submenu/Page_muAcidType.hpp deleted file mode 100644 index 1ff33b1..0000000 --- a/usrc/uicontroler/page.bak/submenu/Page_muAcidType.hpp +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once -// -#include "uicontroler/base/page_processer.hpp" -namespace iflytop { -using namespace std; -// page: keybAcidCh -class Page_muAcidType : public IPageProcesser { - private: - /* data */ - - public: - static Page_muAcidType* ins() { - static Page_muAcidType instance; - return &instance; - } - - private: - virtual bool isBelongThisPage(int page) override; - - virtual void OnPageLoad(OnPageLoadContext*cxt) override; - virtual void OnInputFieldContentChange(uint8_t bid, const char* text) override; - virtual void OnButton(uint8_t bid, uint8_t val) override; - - private: - void updateAcidName(uint8_t bid, const char* txt); -}; - -} // namespace iflytop diff --git a/usrc/uicontroler/page.bak/submenu/Page_muAudit.cpp b/usrc/uicontroler/page.bak/submenu/Page_muAudit.cpp deleted file mode 100644 index 8d41637..0000000 --- a/usrc/uicontroler/page.bak/submenu/Page_muAudit.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "Page_muAudit.hpp" -using namespace iflytop; - -#define PAGE pg_muAudit -#define OBJ(name) ob_muAudit_##name -#define TAG "Page_muAudit" -bool Page_muAudit::isBelongThisPage(int page) { return page == PAGE; } - -void Page_muAudit::OnPageLoad(OnPageLoadContext* cxt) { // -}; - -void Page_muAudit::OnInputFieldContentChange(uint8_t bid, const char* text) { // -}; -void Page_muAudit::OnButton(uint8_t bid, uint8_t val) { // - if (bid == OBJ(bak)) { - UIS->chpage(GSM->getMenuPage()); - } -}; - -// muAcidType \ No newline at end of file diff --git a/usrc/uicontroler/page.bak/submenu/Page_muAudit.hpp b/usrc/uicontroler/page.bak/submenu/Page_muAudit.hpp deleted file mode 100644 index 6df6153..0000000 --- a/usrc/uicontroler/page.bak/submenu/Page_muAudit.hpp +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once -// -#include "uicontroler/base/page_processer.hpp" - -namespace iflytop { -using namespace std; -// page: keybAcidCh -class Page_muAudit : public IPageProcesser { - private: - /* data */ - - public: - static Page_muAudit* ins() { - static Page_muAudit instance; - return &instance; - } - - private: - virtual bool isBelongThisPage(int page) override; - - virtual void OnPageLoad(OnPageLoadContext*cxt) override; - virtual void OnInputFieldContentChange(uint8_t bid, const char* text) override; - virtual void OnButton(uint8_t bid, uint8_t val) override; - -}; -} diff --git a/usrc/uicontroler/page.bak/submenu/Page_muBleHandSett.cpp b/usrc/uicontroler/page.bak/submenu/Page_muBleHandSett.cpp deleted file mode 100644 index 74d09d5..0000000 --- a/usrc/uicontroler/page.bak/submenu/Page_muBleHandSett.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include "Page_muBleHandSett.hpp" - -#include "db/dao/device_setting_dao.hpp" -#include "service/remote_controler.hpp" - -using namespace iflytop; - -/** - * @brief - * 酸类修改页面 - */ - -#define PAGE pg_muBleHandSett -#define TAG "Page_muBleHandSett" - -static bool m_scaning; -void Page_muBleHandSett::initialize() { // - IPageProcesser::initialize(); - RCTRL->regOnReport([this](uint8_t* rx, int32_t len) { - zble_proto_packet_t* packet = (zble_proto_packet_t*)rx; - if (UIS->getNowPage() != PAGE) { - return; - } - if (packet->cmd == kzble_app_report_key_event) { - int32_t keyEvent = *(int32_t*)packet->data; - if (keyEvent == hand_acid_remoter_kevent_add_liquid) { - UIS->setTxt(PAGE, ob_muBleHandSett_bleCliName, "加液"); - } - if (keyEvent == hand_acid_remoter_kevent_change_next_mode) { - UIS->setTxt(PAGE, ob_muBleHandSett_bleCliName, "模式切换"); - } - if (keyEvent == hand_acid_remoter_kevent_reflux) { - UIS->setTxt(PAGE, ob_muBleHandSett_bleCliName, "液路回流"); - } - if (keyEvent == hand_acid_remoter_kevent_preFilling) { - UIS->setTxt(PAGE, ob_muBleHandSett_bleCliName, "液路预充"); - } - return; - } - }); -} -bool Page_muBleHandSett::isBelongThisPage(int page) { return page == PAGE; } -void Page_muBleHandSett::updatePage() { UIS->setTxt(PAGE, ob_muBleHandSett_bleCliName, DeviceSettingDao::get()->bleClientName); } -void Page_muBleHandSett::OnPageLoad(OnPageLoadContext* cxt) { // - updatePage(); -}; -void Page_muBleHandSett::OnAppEvent(AppEvent_t* event) { - if (event->type == kAppEvent_BleConnectEvent) { - ZLOGI(TAG, "ble connect success"); - UIS->setTxt(PAGE, ob_muBleHandSett_bleCliName, "绑定成功"); - DeviceSettingDao::updateBleClientName(event->d.bleName); - m_scaning = false; - } -} -void Page_muBleHandSett::OnInputFieldContentChange(uint8_t bid, const char* text) { updatePage(); } -void Page_muBleHandSett::OnButton(uint8_t bid, uint8_t val) { - ZLOGI(TAG, "bid:%d", bid); - if (bid == ob_muBleHandSett_bak) { - if (m_scaning) { - RCTRL->startScan("XXXXXXXXX", false); // 相当于停止扫描 - } - UIS->chpage(getBakPage(PAGE)); - } else if (bid == ob_muBleHandSett_bleScan) { - ZLOGI(TAG, "bleScan"); - bool suc = RCTRL->startScan(BLENAME, true); - if (suc) UIS->setTxt(PAGE, ob_muBleHandSett_bleCliName, "扫描中..."); - m_scaning = true; - } -}; - -// muAcidType \ No newline at end of file diff --git a/usrc/uicontroler/page.bak/submenu/Page_muBleHandSett.hpp b/usrc/uicontroler/page.bak/submenu/Page_muBleHandSett.hpp deleted file mode 100644 index 9dd86ef..0000000 --- a/usrc/uicontroler/page.bak/submenu/Page_muBleHandSett.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once -// -#include "uicontroler/base/page_processer.hpp" -namespace iflytop { -using namespace std; -// page: keybAcidCh -class Page_muBleHandSett : public IPageProcesser { - private: - /* data */ - - public: - static Page_muBleHandSett* ins() { - static Page_muBleHandSett instance; - return &instance; - } - virtual void initialize() override; - - private: - virtual bool isBelongThisPage(int page) override; - - virtual void OnPageLoad(OnPageLoadContext* cxt) override; - virtual void OnInputFieldContentChange(uint8_t bid, const char* text) override; - virtual void OnButton(uint8_t bid, uint8_t val) override; - virtual void OnAppEvent(AppEvent_t* event) override; - - private: - void updatePage(); -}; - -} // namespace iflytop diff --git a/usrc/uicontroler/page.bak/submenu/Page_muDeviceInfo.cpp b/usrc/uicontroler/page.bak/submenu/Page_muDeviceInfo.cpp deleted file mode 100644 index d558232..0000000 --- a/usrc/uicontroler/page.bak/submenu/Page_muDeviceInfo.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "Page_muDeviceInfo.hpp" - -using namespace iflytop; - -#define PAGE pg_muDeviceInfo -#define TAG "Page_muDeviceInfo" -bool Page_muDeviceInfo::isBelongThisPage(int page) { return page == PAGE; } - -void Page_muDeviceInfo::OnPageLoad(OnPageLoadContext* cxt) { - UIS->setTxt(PAGE, ob_muDeviceInfo_deviceId, "SN000001"); - UIS->setTxt(PAGE, ob_muDeviceInfo_manufa, "中国黄金"); - UIS->setTxt(PAGE, ob_muDeviceInfo_softVers, APP_VERSION); -} -void Page_muDeviceInfo::OnInputFieldContentChange(uint8_t bid, const char* text) {} -void Page_muDeviceInfo::OnButton(uint8_t bid, uint8_t val) { - if (bid == ob_muDeviceInfo_bak) { - UIS->chpage(GSM->getMenuPage()); - } -} \ No newline at end of file diff --git a/usrc/uicontroler/page.bak/submenu/Page_muDeviceInfo.hpp b/usrc/uicontroler/page.bak/submenu/Page_muDeviceInfo.hpp deleted file mode 100644 index 94695dc..0000000 --- a/usrc/uicontroler/page.bak/submenu/Page_muDeviceInfo.hpp +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once -// -#include "uicontroler/base/page_processer.hpp" -namespace iflytop { -using namespace std; -// page: keybAcidCh -class Page_muDeviceInfo : public IPageProcesser { - private: - /* data */ - - public: - static Page_muDeviceInfo* ins() { - static Page_muDeviceInfo instance; - return &instance; - } - - private: - virtual bool isBelongThisPage(int page) override; - - virtual void OnPageLoad(OnPageLoadContext*cxt) override; - virtual void OnInputFieldContentChange(uint8_t bid, const char* text) override; - virtual void OnButton(uint8_t bid, uint8_t val) override; - - private: -}; - -} // namespace iflytop diff --git a/usrc/uicontroler/page.bak/submenu/Page_muInterval.cpp b/usrc/uicontroler/page.bak/submenu/Page_muInterval.cpp deleted file mode 100644 index d9a0cbb..0000000 --- a/usrc/uicontroler/page.bak/submenu/Page_muInterval.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include "Page_muInterval.hpp" - -#include "db/dao/device_setting_dao.hpp" -using namespace iflytop; - -/** - * @brief - * 酸类修改页面 - */ - -#define PAGE pg_muInterval -#define TAG "Page_muInterval" - -bool Page_muInterval::isBelongThisPage(int page) { return page == PAGE; } - -void Page_muInterval::OnPageLoad(OnPageLoadContext* cxt) { - // 设置加酸间隔时间 - UIS->setTxt(PAGE, ob_muInterval_stAcidInte, "%.1f", DeviceSettingDao::get()->distrIntervalS); -}; - -void Page_muInterval::OnInputFieldContentChange(uint8_t bid, const char* text) { - if (bid == ob_muInterval_stAcidInte) { - float distrIntervalSSecond = atof(text); - if (distrIntervalSSecond <= 0) { - UIS->alert("酸液间隔时间不能小于0"); - UIS->setTxt(PAGE, ob_muInterval_stAcidInte,"%.1f", DeviceSettingDao::get()->distrIntervalS); - return; - } - - if (distrIntervalSSecond > 30) { - UIS->alert("酸液间隔时间不能大于30"); - UIS->setTxt(PAGE, ob_muInterval_stAcidInte,"%.1f", DeviceSettingDao::get()->distrIntervalS); - return; - } - UIS->setTxt(PAGE, bid, zfmt("%.1f", distrIntervalSSecond)); - DeviceSettingDao::updatedistrIntervalS(distrIntervalSSecond); - } -}; -void Page_muInterval::OnButton(uint8_t bid, uint8_t val) { - // - if (bid == ob_muInterval_bak) { - UIS->chpage(GSM->getMenuPage()); - } -}; - -// muAcidType \ No newline at end of file diff --git a/usrc/uicontroler/page.bak/submenu/Page_muInterval.hpp b/usrc/uicontroler/page.bak/submenu/Page_muInterval.hpp deleted file mode 100644 index 7e18b02..0000000 --- a/usrc/uicontroler/page.bak/submenu/Page_muInterval.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once -// -#include "uicontroler/base/page_processer.hpp" -namespace iflytop { -using namespace std; -// page: keybAcidCh -class Page_muInterval : public IPageProcesser { - private: - /* data */ - - public: - static Page_muInterval* ins() { - static Page_muInterval instance; - return &instance; - } - - private: - virtual bool isBelongThisPage(int page) override; - - virtual void OnPageLoad(OnPageLoadContext*cxt) override; - virtual void OnInputFieldContentChange(uint8_t bid, const char* text) override; - virtual void OnButton(uint8_t bid, uint8_t val) override; -}; - -} // namespace iflytop diff --git a/usrc/uicontroler/page.bak/submenu/Page_muMotorSett.cpp b/usrc/uicontroler/page.bak/submenu/Page_muMotorSett.cpp deleted file mode 100644 index e80c651..0000000 --- a/usrc/uicontroler/page.bak/submenu/Page_muMotorSett.cpp +++ /dev/null @@ -1,83 +0,0 @@ -#include "Page_muMotorSett.hpp" - -#include "db/dao/acid_ch_cfg_dao.hpp" -#include "service/remote_controler.hpp" - -using namespace iflytop; - -/** - * @brief - * 酸类修改页面 - */ - -#define PAGE pg_muMotorSett -#define TAG "Page_muMotorSett" - -static bool m_scaning; -void Page_muMotorSett::initialize() { // - IPageProcesser::initialize(); -} - -static int32_t getMxIRun(int32_t index) { - if (index < 0 || index > 3) return 0; - return AcidChCfgDao::getCfg(index)->irun; -} -static int32_t setMxIRun(int32_t index, int32_t irun) { - if (index < 0 || index > 3) return 0; - AcidChCfgDao::updateIRUN(index, irun); - return 0; -} - -bool Page_muMotorSett::isBelongThisPage(int page) { return page == PAGE; } - -void Page_muMotorSett::updatePage() { - UIS->setTxt(PAGE, ob_muMotorSett_irun0, zitoa(getMxIRun(0))); - UIS->setTxt(PAGE, ob_muMotorSett_irun1, zitoa(getMxIRun(1))); - UIS->setTxt(PAGE, ob_muMotorSett_irun2, zitoa(getMxIRun(2))); - UIS->setTxt(PAGE, ob_muMotorSett_irun3, zitoa(getMxIRun(3))); -} - -void Page_muMotorSett::OnPageLoad(OnPageLoadContext* cxt) { // - updatePage(); -}; -void Page_muMotorSett::OnAppEvent(AppEvent_t* event) {} -void Page_muMotorSett::OnInputFieldContentChange(uint8_t bid, const char* text) { - /*********************************************************************************************************************** - * irunx * - ***********************************************************************************************************************/ - - if (bid == ob_muMotorSett_irun0 || bid == ob_muMotorSett_irun1 || bid == ob_muMotorSett_irun2 || bid == ob_muMotorSett_irun3) { - int irun = atoi(text); - if (irun < 1 || irun > 31) { - UIS->alert("IRUN需要限制在1..31"); - return; - } - } - - if (bid == ob_muMotorSett_irun0) { - setMxIRun(0, atoi(text)); - UIS->setTxt(bid, zfmt("%d", getMxIRun(0))); - } else if (bid == ob_muMotorSett_irun1) { - setMxIRun(1, atoi(text)); - UIS->setTxt(bid, zfmt("%d", getMxIRun(1))); - } else if (bid == ob_muMotorSett_irun2) { - setMxIRun(2, atoi(text)); - UIS->setTxt(bid, zfmt("%d", getMxIRun(2))); - } else if (bid == ob_muMotorSett_irun3) { - setMxIRun(3, atoi(text)); - UIS->setTxt(bid, zfmt("%d", getMxIRun(3))); - } - - /*********************************************************************************************************************** - * addAcidVel * - ***********************************************************************************************************************/ - - updatePage(); -} -void Page_muMotorSett::OnButton(uint8_t bid, uint8_t val) { - if (bid == ob_muMotorSett_bak) { - UIS->chpage(getBakPage(PAGE)); - } -}; - -// muAcidType \ No newline at end of file diff --git a/usrc/uicontroler/page.bak/submenu/Page_muMotorSett.hpp b/usrc/uicontroler/page.bak/submenu/Page_muMotorSett.hpp deleted file mode 100644 index a8dae0d..0000000 --- a/usrc/uicontroler/page.bak/submenu/Page_muMotorSett.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once -// -#include "uicontroler/base/page_processer.hpp" -namespace iflytop { -using namespace std; -// page: keybAcidCh -class Page_muMotorSett : public IPageProcesser { - private: - /* data */ - - public: - static Page_muMotorSett* ins() { - static Page_muMotorSett instance; - return &instance; - } - virtual void initialize() override; - - private: - virtual bool isBelongThisPage(int page) override; - - virtual void OnPageLoad(OnPageLoadContext* cxt) override; - virtual void OnInputFieldContentChange(uint8_t bid, const char* text) override; - virtual void OnButton(uint8_t bid, uint8_t val) override; - virtual void OnAppEvent(AppEvent_t* event) override; - - private: - void updatePage(); -}; - -} // namespace iflytop diff --git a/usrc/uicontroler/page.bak/submenu/Page_muPumpSett.cpp b/usrc/uicontroler/page.bak/submenu/Page_muPumpSett.cpp deleted file mode 100644 index 58e1d5a..0000000 --- a/usrc/uicontroler/page.bak/submenu/Page_muPumpSett.cpp +++ /dev/null @@ -1,163 +0,0 @@ -#include "Page_muPumpSett.hpp" - -#include "db/dao/acid_ch_cfg_dao.hpp" -#include "service/remote_controler.hpp" - -using namespace iflytop; - -/** - * @brief - * 酸类修改页面 - */ - -#define PAGE pg_muPumpSett -#define TAG "Page_muPumpSett" - -static float getMotorMLPR(int32_t index) { - if (index < 0 || index > 3) return 0; - return AcidChCfgDao::getCfg(index)->mLPR; -} - -static float setMotorMLPR(int32_t index, float mlpr) { - if (index < 0 || index > 3) return 0; - // AcidChCfgDao::updateMLPR(index, mlpr); - return 0; -} - -static bool m_scaning; -void Page_muPumpSett::initialize() { // - IPageProcesser::initialize(); - - RCTRL->regOnReport([this](uint8_t* rx, int32_t len) { - zble_proto_packet_t* packet = (zble_proto_packet_t*)rx; - if (UIS->getNowPage() != PAGE) { - return; - } - - if (packet->cmd == kzble_app_report_key_event) { - int32_t keyEvent = *(int32_t*)packet->data; - - return; - } - }); -} -bool Page_muPumpSett::isBelongThisPage(int page) { return page == PAGE; } - -void Page_muPumpSett::updatePage() { - UIS->setTxt(PAGE, ob_muPumpSett_pumpCoef0, zfmt("%.4f", getMotorMLPR(0))); - UIS->setTxt(PAGE, ob_muPumpSett_pumpCoef1, zfmt("%.4f", getMotorMLPR(1))); - UIS->setTxt(PAGE, ob_muPumpSett_pumpCoef2, zfmt("%.4f", getMotorMLPR(2))); - UIS->setTxt(PAGE, ob_muPumpSett_pumpCoef3, zfmt("%.4f", getMotorMLPR(3))); - // UIS->setTxt(PAGE, ob_muPumpSett_pipeLen0, zfmt("%.2f", getCfgPipeLengthML(0))); - // UIS->setTxt(PAGE, ob_muPumpSett_pipeLen1, zfmt("%.2f", getCfgPipeLengthML(1))); - // UIS->setTxt(PAGE, ob_muPumpSett_pipeLen2, zfmt("%.2f", getCfgPipeLengthML(2))); - // UIS->setTxt(PAGE, ob_muPumpSett_pipeLen3, zfmt("%.2f", getCfgPipeLengthML(3))); - // TODO:改成4个输入框 - // UIS->setTxt(PAGE, ob_muPumpSett_addAcidVel0, zitoa(getMxRunRPM(0))); - // UIS->setTxt(PAGE, ob_muPumpSett_addAcidVel1, zitoa(getMxRunRPM(1))); - // UIS->setTxt(PAGE, ob_muPumpSett_addAcidVel2, zitoa(getMxRunRPM(2))); - // UIS->setTxt(PAGE, ob_muPumpSett_addAcidVel3, zitoa(getMxRunRPM(3))); -} - -void Page_muPumpSett::OnPageLoad(OnPageLoadContext* cxt) { // - updatePage(); -}; -void Page_muPumpSett::OnAppEvent(AppEvent_t* event) {} - -void Page_muPumpSett::OnInputFieldContentChange(uint8_t bid, const char* text) { - /*********************************************************************************************************************** - * irunx * - ***********************************************************************************************************************/ - - /*********************************************************************************************************************** - * pumpCoef * - ***********************************************************************************************************************/ - - if (bid == ob_muPumpSett_pumpCoef0) { - setMotorMLPR(0, atof(text)); - UIS->setTxt(bid, zfmt("%.4f", getMotorMLPR(0))); - } else if (bid == ob_muPumpSett_pumpCoef1) { - setMotorMLPR(1, atof(text)); - UIS->setTxt(bid, zfmt("%.4f", getMotorMLPR(1))); - } else if (bid == ob_muPumpSett_pumpCoef2) { - setMotorMLPR(2, atof(text)); - UIS->setTxt(bid, zfmt("%.4f", getMotorMLPR(2))); - } else if (bid == ob_muPumpSett_pumpCoef3) { - setMotorMLPR(3, atof(text)); - UIS->setTxt(bid, zfmt("%.4f", getMotorMLPR(3))); - } - - /*********************************************************************************************************************** - * pipeLen * - ***********************************************************************************************************************/ - - if (bid == ob_muPumpSett_pipeLen0 || bid == ob_muPumpSett_pipeLen1 || bid == ob_muPumpSett_pipeLen2 || bid == ob_muPumpSett_pipeLen3) { - float len = atof(text); - if (len < 0.1) { - UIS->alert("管道长度不能小于0.1"); - return; - } - } - - // if (bid == ob_muPumpSett_pipeLen0) { - // setCfgPipeLengthML(0, atof(text)); - // UIS->setTxt(bid, zfmt("%.2f", getCfgPipeLengthML(0))); - // } - - // if (bid == ob_muPumpSett_pipeLen1) { - // setCfgPipeLengthML(1, atof(text)); - // UIS->setTxt(bid, zfmt("%.2f", getCfgPipeLengthML(1))); - // } - - // if (bid == ob_muPumpSett_pipeLen2) { - // setCfgPipeLengthML(2, atof(text)); - // UIS->setTxt(bid, zfmt("%.2f", getCfgPipeLengthML(2))); - // } - - // if (bid == ob_muPumpSett_pipeLen3) { - // setCfgPipeLengthML(3, atof(text)); - // UIS->setTxt(bid, zfmt("%.2f", getCfgPipeLengthML(3))); - // } - - /*********************************************************************************************************************** - * addAcidVel * - ***********************************************************************************************************************/ - // TODO改成4个输入框 - if (bid == ob_muPumpSett_addAcidVel0 || bid == ob_muPumpSett_addAcidVel1 || bid == ob_muPumpSett_addAcidVel2 || bid == ob_muPumpSett_addAcidVel3) { - int rpm = atoi(text); - if (rpm < 10) { - UIS->alert("转速不能小于10"); - return; - } - - if (rpm > 2000) { - UIS->alert("转速不能大于2000"); - return; - } - - // switch (bid) { - // case ob_muPumpSett_addAcidVel0: - // setMxRunRPM(0, rpm); - // break; - // case ob_muPumpSett_addAcidVel1: - // setMxRunRPM(1, rpm); - // break; - // case ob_muPumpSett_addAcidVel2: - // setMxRunRPM(2, rpm); - // break; - // case ob_muPumpSett_addAcidVel3: - // setMxRunRPM(3, rpm); - // break; - // } - UIS->setTxt(bid, zitoa(rpm)); - } - - updatePage(); -} -void Page_muPumpSett::OnButton(uint8_t bid, uint8_t val) { - if (bid == ob_muPumpSett_bak) { - UIS->chpage(getBakPage(PAGE)); - } -}; - -// muAcidType \ No newline at end of file diff --git a/usrc/uicontroler/page.bak/submenu/Page_muPumpSett.hpp b/usrc/uicontroler/page.bak/submenu/Page_muPumpSett.hpp deleted file mode 100644 index 0d5e47a..0000000 --- a/usrc/uicontroler/page.bak/submenu/Page_muPumpSett.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once -// -#include "uicontroler/base/page_processer.hpp" -namespace iflytop { -using namespace std; -// page: keybAcidCh -class Page_muPumpSett : public IPageProcesser { - private: - /* data */ - - public: - static Page_muPumpSett* ins() { - static Page_muPumpSett instance; - return &instance; - } - virtual void initialize() override; - - private: - virtual bool isBelongThisPage(int page) override; - - virtual void OnPageLoad(OnPageLoadContext* cxt) override; - virtual void OnInputFieldContentChange(uint8_t bid, const char* text) override; - virtual void OnButton(uint8_t bid, uint8_t val) override; - virtual void OnAppEvent(AppEvent_t* event) override; - - private: - void updatePage(); -}; - -} // namespace iflytop diff --git a/usrc/uicontroler/page.bak/submenu/Page_muPumpTest.cpp b/usrc/uicontroler/page.bak/submenu/Page_muPumpTest.cpp deleted file mode 100644 index ae97ac6..0000000 --- a/usrc/uicontroler/page.bak/submenu/Page_muPumpTest.cpp +++ /dev/null @@ -1,128 +0,0 @@ -#include "Page_muPumpTest.hpp" - -#include "service/pump_ctrl_service.hpp" -#include "service/remote_controler.hpp" -using namespace iflytop; - -#define PAGE pg_muPumpTest -#define TAG "Page_muPumpTest" - -static void Page_muPumpTest_onTimer(const void* tid) { - Page_muPumpTest* thisClass = (Page_muPumpTest*)pvTimerGetTimerID((TimerHandle_t)tid); - thisClass->onTimer(); -} - -void Page_muPumpTest::initialize() { // - IPageProcesser::initialize(); - - osTimerDef(statiUpdateTimer, Page_muPumpTest_onTimer); - statiUpdateTimerId = osTimerCreate(osTimer(statiUpdateTimer), osTimerPeriodic, this); - - RCTRL->regOnReport([this](uint8_t* rx, int32_t len) { - zble_proto_packet_t* packet = (zble_proto_packet_t*)rx; - // ZLOGI(TAG, "TRACE process ble report start"); - if (UIS->getNowPage() != PAGE) { - // ZLOGI(TAG, "TRACE process ble report end...."); - return; - } - - if (packet->cmd == kzble_app_report_key_event) { - int32_t keyEvent = *(int32_t*)packet->data; - if (keyEvent == hand_acid_remoter_kevent_add_liquid) { - if (m_workFlag) { - pumpStart(1); - } else { - pumpStop(); - } - } - } - // ZLOGI(TAG, "TRACE process ble report end...."); - }); -} - -bool Page_muPumpTest::isBelongThisPage(int page) { return page == PAGE; } - -void Page_muPumpTest::OnPageLoad(OnPageLoadContext* cxt) { - // motorTrunsBegin - if (!cxt->isFromPopWin) { - updateStatiInfo(0, 0); - m_pumpId = 0; - m_workFlag = false; - } - ZLOGI(TAG, "m_pumpId:%d %d", m_pumpId, cxt->isFromPopWin); - UIS->setTxt(ob_muPumpTest_pumpId, zfmt("%d", m_pumpId + 1)); -} - -void Page_muPumpTest::OnInputFieldContentChange(uint8_t bid, const char* text) { // - ZLOGI(TAG, "bid:%d %s", bid, text); - // ob_muPumpTest_frompage - if (bid == ob_muPumpTest_pumpId) { - pumpChangeSelectId(atoi(text) - 1); - } -} -void Page_muPumpTest::OnButton(uint8_t bid, uint8_t val) { - ZLOGI(TAG, "bid:%d", bid); - if (bid == ob_muPumpTest_bak) { - pumpStop(); - UIS->chpage(pg_muSettings); - } else if (bid == ob_muPumpTest_clearStati) { - ZLOGI(TAG, "clearStati"); - clearStatisInfo(); - } else if (bid == ob_muPumpTest_forward) { - ZLOGI(TAG, "forward"); - pumpStart(1); - } else if (bid == ob_muPumpTest_bakward) { - ZLOGI(TAG, "bakward"); - pumpStart(-1); - } else if (bid == ob_muPumpTest_stop) { - ZLOGI(TAG, "stop"); - pumpStop(); - } -} -/*********************************************************************************************************************** - * LOGIC * - ***********************************************************************************************************************/ -void Page_muPumpTest::pumpStop() { - PUMPCS->stopRotate(); - osTimerStop(statiUpdateTimerId); - updateStatiInfo(); - m_workFlag = false; -} -void Page_muPumpTest::pumpStart(int32_t direction) { - ZLOGI(TAG, "pumpStart %d %d", m_pumpId, direction); - PUMPCS->rotate(m_pumpId, direction); - osTimerStop(statiUpdateTimerId); - osTimerStart(statiUpdateTimerId, 300); - m_workFlag = true; -} -void Page_muPumpTest::pumpChangeSelectId(int id) { - if (id < 0 || id > 3) { - ZLOGW(TAG, "pumpId out of range"); - return; - } - if ((id) != m_pumpId) { - ZLOGI(TAG, "pumpId change to %d", id); - m_pumpId = id; - PUMPCS->stopRotate(); - clearStatisInfo(); - } -} -void Page_muPumpTest::updateStatiInfo(float statiTruns, float statiVolum) { - m_statiTruns = statiTruns; - m_statiVolum = statiVolum; - UIS->setTxt(ob_muPumpTest_statiTrun, zfmt("%.2f", m_statiTruns)); - UIS->setTxt(ob_muPumpTest_statiVolum, zfmt("%.1f", m_statiVolum)); -} -void Page_muPumpTest::clearStatisInfo() { - updateStatiInfo(0, 0); - PUMPCS->setCurrentPosAsZero(m_pumpId); -} - -void Page_muPumpTest::updateStatiInfo() { - double nowPos = PUMPCS->getMotorNowPosR(m_pumpId); - double truns = (nowPos); - // float motorX_mLPR = getMotorMLPR(m_pumpId); - // double volum = truns * motorX_mLPR; - // updateStatiInfo(truns, volum); -} -void Page_muPumpTest::onTimer() { updateStatiInfo(); } diff --git a/usrc/uicontroler/page.bak/submenu/Page_muPumpTest.hpp b/usrc/uicontroler/page.bak/submenu/Page_muPumpTest.hpp deleted file mode 100644 index 14e6df5..0000000 --- a/usrc/uicontroler/page.bak/submenu/Page_muPumpTest.hpp +++ /dev/null @@ -1,46 +0,0 @@ -#pragma once -// -#include "uicontroler/base/page_processer.hpp" -namespace iflytop { -using namespace std; -// page: keybAcidCh -class Page_muPumpTest : public IPageProcesser { - private: - /* data */ - - int m_pumpId = 0; - float m_statiTruns = 0; - float m_statiVolum = 0; - bool m_workFlag = false; - - osTimerId statiUpdateTimerId; // - - public: - static Page_muPumpTest* ins() { - static Page_muPumpTest instance; - return &instance; - } - - virtual void initialize(); - - private: - virtual bool isBelongThisPage(int page) override; - - virtual void OnPageLoad(OnPageLoadContext* cxt) override; - virtual void OnInputFieldContentChange(uint8_t bid, const char* text) override; - virtual void OnButton(uint8_t bid, uint8_t val) override; - - private: - void updateStatiInfo(float statiTruns, float statiVolum); - void clearStatisInfo(); - void updateStatiInfo(); - - void pumpStop(); - void pumpStart(int32_t direction); - void pumpChangeSelectId(int id); - - public: - void onTimer(); -}; - -} // namespace iflytop diff --git a/usrc/uicontroler/page.bak/submenu/Page_muSettings.cpp b/usrc/uicontroler/page.bak/submenu/Page_muSettings.cpp deleted file mode 100644 index d781741..0000000 --- a/usrc/uicontroler/page.bak/submenu/Page_muSettings.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "Page_muSettings.hpp" - -#include "service/remote_controler.hpp" - -using namespace iflytop; - -/** - * @brief - * 酸类修改页面 - */ - -#define PAGE pg_muSettings -#define TAG "Page_muSettings" - -static bool m_scaning; - -void Page_muSettings::initialize() { // - IPageProcesser::initialize(); -} -bool Page_muSettings::isBelongThisPage(int page) { return page == PAGE; } -void Page_muSettings::updatePage() {} -void Page_muSettings::OnPageLoad(OnPageLoadContext* cxt) { // -}; -void Page_muSettings::OnAppEvent(AppEvent_t* event) {} -void Page_muSettings::OnInputFieldContentChange(uint8_t bid, const char* text) {} -void Page_muSettings::OnButton(uint8_t bid, uint8_t val) { - if (bid == ob_muSettings_bak) { - UIS->chpage(GSM->getMenuPage()); - } -}; - -// muAcidType \ No newline at end of file diff --git a/usrc/uicontroler/page.bak/submenu/Page_muSettings.hpp b/usrc/uicontroler/page.bak/submenu/Page_muSettings.hpp deleted file mode 100644 index af004c4..0000000 --- a/usrc/uicontroler/page.bak/submenu/Page_muSettings.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once -// -#include "uicontroler/base/page_processer.hpp" -namespace iflytop { -using namespace std; -// page: keybAcidCh -class Page_muSettings : public IPageProcesser { - private: - /* data */ - - public: - static Page_muSettings* ins() { - static Page_muSettings instance; - return &instance; - } - virtual void initialize() override; - - private: - virtual bool isBelongThisPage(int page) override; - - virtual void OnPageLoad(OnPageLoadContext* cxt) override; - virtual void OnInputFieldContentChange(uint8_t bid, const char* text) override; - virtual void OnButton(uint8_t bid, uint8_t val) override; - virtual void OnAppEvent(AppEvent_t* event) override; - - private: - void updatePage(); -}; - -} // namespace iflytop diff --git a/usrc/uicontroler/page.bak/submenu/Page_muUsrMgr.cpp b/usrc/uicontroler/page.bak/submenu/Page_muUsrMgr.cpp deleted file mode 100644 index e5cd98c..0000000 --- a/usrc/uicontroler/page.bak/submenu/Page_muUsrMgr.cpp +++ /dev/null @@ -1,117 +0,0 @@ -#include "Page_muUsrMgr.hpp" -using namespace iflytop; - -/** - * @brief - * 酸类修改页面 - */ - -#define PAGE pg_muUsrMgr -#define TAG "Page_muUsrMgr" - -bool Page_muUsrMgr::isBelongThisPage(int page) { return page == PAGE; } - -void Page_muUsrMgr::OnPageLoad(OnPageLoadContext* cxt) { // - ZLOGI(TAG, "OnPageLoad"); - updatePage(); -}; -void Page_muUsrMgr::updatePage() { - // UIS->setTxt(PAGE, ob_muUsrMgr_usr0name, getCfgStr(kusr_name0)); - // UIS->setTxt(PAGE, ob_muUsrMgr_usr1name, getCfgStr(kusr_name1)); - // UIS->setTxt(PAGE, ob_muUsrMgr_usr2name, getCfgStr(kusr_name2)); - // UIS->setTxt(PAGE, ob_muUsrMgr_usr3name, getCfgStr(kusr_name3)); - // UIS->setTxt(PAGE, ob_muUsrMgr_usr4name, getCfgStr(kusr_name4)); - // UIS->setTxt(PAGE, ob_muUsrMgr_usr5name, getCfgStr(kusr_name5)); - - // // UIS->setVal(PAGE, ob_muUsrMgr_usr1en, (int)getCfgBool(kusr_enable1)); - // UIS->setVal(PAGE, ob_muUsrMgr_usr2en, (int)getCfgBool(kusr_enable2)); - // UIS->setVal(PAGE, ob_muUsrMgr_usr3en, (int)getCfgBool(kusr_enable3)); - // UIS->setVal(PAGE, ob_muUsrMgr_usr4en, (int)getCfgBool(kusr_enable4)); - // UIS->setVal(PAGE, ob_muUsrMgr_usr5en, (int)getCfgBool(kusr_enable5)); -} - -void Page_muUsrMgr::OnInputFieldContentChange(uint8_t bid, const char* text) { - // if (bid == ob_muUsrMgr_usr1ReName) { - // ZLOGI(TAG, "rename usr1:%s", text); - // CS->setcfgAndFlush(kusr_name1, text); - // updatePage(); - // } // - // else if (bid == ob_muUsrMgr_usr2ReName) { - // ZLOGI(TAG, "rename usr2:%s", text); - // CS->setcfgAndFlush(kusr_name2, text); - // updatePage(); - // } // - // else if (bid == ob_muUsrMgr_usr3ReName) { - // ZLOGI(TAG, "rename usr3:%s", text); - // CS->setcfgAndFlush(kusr_name3, text); - // updatePage(); - // } // - // else if (bid == ob_muUsrMgr_usr4ReName) { - // ZLOGI(TAG, "rename usr4:%s", text); - // CS->setcfgAndFlush(kusr_name4, text); - // updatePage(); - // } // - // else if (bid == ob_muUsrMgr_usr5ReName) { - // ZLOGI(TAG, "rename usr5:%s", text); - // CS->setcfgAndFlush(kusr_name5, text); - // updatePage(); - // } -} - -void Page_muUsrMgr::OnButton(uint8_t bid, uint8_t val) { - ZLOGI(TAG, "bid:%d", bid); - - // if (bid == ob_muUsrMgr_bak) { - // UIS->chpage(GSM->getMenuPage()); - // } else if (bid == ob_muUsrMgr_usr1Rest) { - // ZLOGI(TAG, "reset usr1 "); - // CS->setcfgAndFlush(kusr_name1, USER1_DEFAULT_NAME); - // CS->setcfgAndFlush(kusr_passwd1, USER_DEFAULT_PWD); - // updatePage(); - // } else if (bid == ob_muUsrMgr_usr2Rest) { - // ZLOGI(TAG, "reset usr2 "); - // CS->setcfgAndFlush(kusr_name2, USER2_DEFAULT_NAME); - // CS->setcfgAndFlush(kusr_passwd2, USER_DEFAULT_PWD); - // updatePage(); - // } else if (bid == ob_muUsrMgr_usr3Rest) { - // ZLOGI(TAG, "reset usr3 "); - // CS->setcfgAndFlush(kusr_name3, USER3_DEFAULT_NAME); - // CS->setcfgAndFlush(kusr_passwd3, USER_DEFAULT_PWD); - // updatePage(); - // } else if (bid == ob_muUsrMgr_usr4Rest) { - // ZLOGI(TAG, "reset usr4 "); - // CS->setcfgAndFlush(kusr_name4, USER4_DEFAULT_NAME); - // CS->setcfgAndFlush(kusr_passwd4, USER_DEFAULT_PWD); - // updatePage(); - // } else if (bid == ob_muUsrMgr_usr5Rest) { - // ZLOGI(TAG, "reset usr5 "); - // CS->setcfgAndFlush(kusr_name5, USER5_DEFAULT_NAME); - // CS->setcfgAndFlush(kusr_passwd5, USER_DEFAULT_PWD); - // updatePage(); - // } - // // } - // // else if (bid == ob_muUsrMgr_usr1en) { - // // ZLOGI(TAG, "enable usr1 %d", val); - // // CS->setcfgAndFlush(kusr_enable1, (bool)val); - // // updatePage(); - // // } - // else if (bid == ob_muUsrMgr_usr2en) { - // ZLOGI(TAG, "enable usr2 %d", val); - // CS->setcfgAndFlush(kusr_enable2, (bool)val); - // updatePage(); - // } else if (bid == ob_muUsrMgr_usr3en) { - // ZLOGI(TAG, "enable usr3 %d", val); - // CS->setcfgAndFlush(kusr_enable3, (bool)val); - // updatePage(); - // } else if (bid == ob_muUsrMgr_usr4en) { - // ZLOGI(TAG, "enable usr4 %d", val); - // CS->setcfgAndFlush(kusr_enable4, (bool)val); - // updatePage(); - // } else if (bid == ob_muUsrMgr_usr5en) { - // ZLOGI(TAG, "enable usr5 %d", val); - // CS->setcfgAndFlush(kusr_enable5, (bool)val); - // updatePage(); - // } -}; - -// muAcidType \ No newline at end of file diff --git a/usrc/uicontroler/page.bak/submenu/Page_muUsrMgr.hpp b/usrc/uicontroler/page.bak/submenu/Page_muUsrMgr.hpp deleted file mode 100644 index 2cf5802..0000000 --- a/usrc/uicontroler/page.bak/submenu/Page_muUsrMgr.hpp +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once -// -#include "uicontroler/base/page_processer.hpp" -namespace iflytop { -using namespace std; -// page: keybAcidCh -class Page_muUsrMgr : public IPageProcesser { - private: - /* data */ - - public: - static Page_muUsrMgr* ins() { - static Page_muUsrMgr instance; - return &instance; - } - - private: - virtual bool isBelongThisPage(int page) override; - - virtual void OnPageLoad(OnPageLoadContext*cxt) override; - virtual void OnInputFieldContentChange(uint8_t bid, const char* text) override; - virtual void OnButton(uint8_t bid, uint8_t val) override; - - private: - void updatePage(); -}; - -} // namespace iflytop diff --git a/usrc/uicontroler/page/home/home_page.cpp b/usrc/uicontroler/page/home/home_page.cpp new file mode 100644 index 0000000..bf6d39d --- /dev/null +++ b/usrc/uicontroler/page/home/home_page.cpp @@ -0,0 +1,173 @@ + +#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" + +namespace iflytop { +using namespace std; +#define TAG "HomePage" + +class HomePage : public IPageProcesser { + private: + char userName[20] = {0}; + char passwd[20] = {0}; + + public: + HomePage() : IPageProcesser(TAG, pg_home) {} + + virtual void initialize() override { + IPageProcesser::initialize(); + syncState(); + } + + private: + virtual void OnPageLoad(OnPageLoadContext* cxt) override { + ZLOGI(TAG, "OnPageLoad"); + UI::ins()->vis(ob_home_AcidState, 0); // 隐藏酸液桶状态 + UIS->setTouchEnableState(ob_home_acidname0, 0); + UIS->setTouchEnableState(ob_home_acidname1, 0); + UIS->setTouchEnableState(ob_home_acidname2, 0); + UIS->setTouchEnableState(ob_home_acidname3, 0); + UIS->setTouchEnableState(ob_home_RunModeVal, 0); + syncState(); + } + virtual void OnBackKey(OnPageLoadContext* cxt) override {} + virtual void OnInputFieldContentChange(uint8_t bid, const char* text) override { + if (bid == ob_home_acideval0) { + AcidChCfgDao::updateAcidEachDistriVal(0, atof(text)); + } else if (bid == ob_home_acideval1) { + AcidChCfgDao::updateAcidEachDistriVal(1, atof(text)); + } else if (bid == ob_home_acideval2) { + AcidChCfgDao::updateAcidEachDistriVal(2, atof(text)); + } else if (bid == ob_home_acideval3) { + AcidChCfgDao::updateAcidEachDistriVal(3, atof(text)); + } else if (bid == ob_home_RunModeVal) { + DeviceSettingDao::updatedistrIntervalS(atof(text)); + } + } + virtual void OnButton(uint8_t bid, uint8_t val) override { + ZLOGI(TAG, "OnButton bid:%d val:%d", bid, val); + if (bid == ob_home_SelCH0) { + setPumpSelectState(0, !GStateMgr::ins()->getPumpSelectState(0)); + } else if (bid == ob_home_SelCH1) { + setPumpSelectState(1, !GStateMgr::ins()->getPumpSelectState(1)); + } else if (bid == ob_home_SelCH2) { + setPumpSelectState(2, !GStateMgr::ins()->getPumpSelectState(2)); + } else if (bid == ob_home_SelCH3) { + setPumpSelectState(3, !GStateMgr::ins()->getPumpSelectState(3)); + } + } + virtual void OnDoubleStateButton(uint8_t bid, uint8_t val) override {} + virtual void OnAppEvent(AppEvent_t* event) override { + if (event->type == kAE_RemoterConnectedEvent) { + syncBleState(); // 同步蓝牙状态 + UIS->setTxt(pageId, ob_home_sysInfo, "连接上手柄"); + } else if (event->type == kAE_RemoterDisConnectedEvent) { + syncBleState(); // 同步蓝牙状态 + UIS->setTxt(pageId, ob_home_sysInfo, "断开手柄连接"); + + } else if (event->type == kAE_RunModeChangeEvent) { + syncMode(); // 初始化设备模式 + UIS->setTxt(pageId, ob_home_sysInfo, "切换模式"); + + } else if (event->type == kAE_AcidStatChangeEvent) { + syncStat(); // 初始化统计数据 + } else if (event->type == kAppEvent_StateDisplayInfo) { + UIS->setTxt(pageId, ob_home_sysInfo, event->d.stateDisplayInfo); + } + } + + private: + void syncState() { + syncdate(); // 初始化时间 + syncPumpSelectState(); // 初始化选中状态 + syncAcidName(); // 初始化通道名字 + syncAcidEachDistriVal(); // 初始化每次加液体体积 + syncStat(); // 初始化统计数据 + syncMode(); // 初始化设备模式 + syncBleState(); // 同步蓝牙状态 + } + + private: + void syncdate() { + static zdate_t date; + AppHal::rtc_get(&date); + UI::ins()->setrtc(&date); + } + + void setPumpSelectState(uint8_t chIndex, bool state) { + GStateMgr::ins()->setPumpSelectState(chIndex, state); + if (chIndex == 0) { + UI::ins()->setPicturePicNum(pageId, ob_home_AcidCH0S, state ? ob_home_CHState1 : ob_home_CHState0); + } else if (chIndex == 1) { + UI::ins()->setPicturePicNum(pageId, ob_home_AcidCH1S, state ? ob_home_CHState1 : ob_home_CHState0); + } else if (chIndex == 2) { + UI::ins()->setPicturePicNum(pageId, ob_home_AcidCH2S, state ? ob_home_CHState1 : ob_home_CHState0); + } else if (chIndex == 3) { + UI::ins()->setPicturePicNum(pageId, ob_home_AcidCH3S, state ? ob_home_CHState1 : ob_home_CHState0); + } + } + + void syncPumpSelectState() { + UI::ins()->setPicturePicNum(pageId, ob_home_AcidCH0S, GStateMgr::ins()->getPumpSelectState(0) ? ob_home_CHState1 : ob_home_CHState0); + UI::ins()->setPicturePicNum(pageId, ob_home_AcidCH1S, GStateMgr::ins()->getPumpSelectState(1) ? ob_home_CHState1 : ob_home_CHState0); + UI::ins()->setPicturePicNum(pageId, ob_home_AcidCH2S, GStateMgr::ins()->getPumpSelectState(2) ? ob_home_CHState1 : ob_home_CHState0); + UI::ins()->setPicturePicNum(pageId, ob_home_AcidCH3S, GStateMgr::ins()->getPumpSelectState(3) ? ob_home_CHState1 : ob_home_CHState0); + } + + void syncAcidName() { + UI::ins()->setTxt(pageId, ob_home_acidname0, AcidChCfgDao::getCfg(0)->acidChooseName); + UI::ins()->setTxt(pageId, ob_home_acidname1, AcidChCfgDao::getCfg(1)->acidChooseName); + UI::ins()->setTxt(pageId, ob_home_acidname2, AcidChCfgDao::getCfg(2)->acidChooseName); + UI::ins()->setTxt(pageId, ob_home_acidname3, AcidChCfgDao::getCfg(3)->acidChooseName); + } + + void syncAcidEachDistriVal() { + UI::ins()->setTxt(pageId, ob_home_acideval0, "%.1f", AcidChCfgDao::getCfg(0)->acidEachDistriVal); + UI::ins()->setTxt(pageId, ob_home_acideval1, "%.1f", AcidChCfgDao::getCfg(1)->acidEachDistriVal); + UI::ins()->setTxt(pageId, ob_home_acideval2, "%.1f", AcidChCfgDao::getCfg(2)->acidEachDistriVal); + UI::ins()->setTxt(pageId, ob_home_acideval3, "%.1f", AcidChCfgDao::getCfg(3)->acidEachDistriVal); + } + + void syncStat() { + // StatUsedC + UI::ins()->setTxt(pageId, ob_home_StatRmidCH0, "%.1f", GStateMgr::ins()->getAcidRemain(0)); + UI::ins()->setTxt(pageId, ob_home_StatRmidCH1, "%.1f", GStateMgr::ins()->getAcidRemain(1)); + UI::ins()->setTxt(pageId, ob_home_StatRmidCH2, "%.1f", GStateMgr::ins()->getAcidRemain(2)); + UI::ins()->setTxt(pageId, ob_home_StatRmidCH3, "%.1f", GStateMgr::ins()->getAcidRemain(3)); + UI::ins()->setTxt(pageId, ob_home_StatUsedCH0, "%.1f", GStateMgr::ins()->getAcidUsed(0)); + UI::ins()->setTxt(pageId, ob_home_StatUsedCH1, "%.1f", GStateMgr::ins()->getAcidUsed(1)); + UI::ins()->setTxt(pageId, ob_home_StatUsedCH2, "%.1f", GStateMgr::ins()->getAcidUsed(2)); + UI::ins()->setTxt(pageId, ob_home_StatUsedCH3, "%.1f", GStateMgr::ins()->getAcidUsed(3)); + } + + void syncMode() { + auto nowMode = GStateMgr::ins()->getRunMode(); + if (nowMode == khand_acid_m_jog_mode) { + UI::ins()->setPicturePicNum(pageId, ob_home_RunMode, ob_home_RunMode1); + UI::ins()->setTxt(pageId, ob_home_RunModeVal, "", DeviceSettingDao::get()->distrIntervalS); + } else if (nowMode == khand_acid_m_continuous_mode) { + UI::ins()->setPicturePicNum(pageId, ob_home_RunMode, ob_home_RunMode0); + UI::ins()->setTxt(pageId, ob_home_RunModeVal, "%.1f", DeviceSettingDao::get()->distrIntervalS); + } + } + + void syncBleState() { + bool bleIsConnected = GStateMgr::ins()->getRemoterS(); + if (bleIsConnected) { + UI::ins()->setPicturePicNum(pageId, ob_home_RemoterS, ob_home_RemoterS1); + } else { + UI::ins()->setPicturePicNum(pageId, ob_home_RemoterS, ob_home_RemoterS0); + } + } +}; + +// 实例化LoginPage, 使其自动注册 +static HomePage instance; +} // namespace iflytop + +// kpt_sys_event_page_id diff --git a/usrc/uicontroler/page/login/login_page.cpp b/usrc/uicontroler/page/login/login_page.cpp index 08a67f0..679aff2 100644 --- a/usrc/uicontroler/page/login/login_page.cpp +++ b/usrc/uicontroler/page/login/login_page.cpp @@ -16,11 +16,7 @@ class LoginPage : public IPageProcesser { virtual void initialize() override { IPageProcesser::initialize(); - - UIS->setTxt(pageId, ob_login_uName, ""); // 用户名 - UIS->setTxt(pageId, ob_login_uNameEMsg, ""); // 用户名错误信息 - UIS->setTxt(pageId, ob_login_pwd, ""); // 密码 - UIS->setTxt(pageId, ob_login_pwdEMsg, ""); // 密码错误信息 + resetPage(); } private: @@ -55,13 +51,20 @@ class LoginPage : public IPageProcesser { ZLOGI(TAG, "login %s success", userName); AppEventBus::ins()->pushSimpleEvent(kAE_LoginEvent); - UI::ins()->chpage(pg_main); + UI::ins()->chpage(pg_home); + resetPage(); } } virtual void OnDoubleStateButton(uint8_t bid, uint8_t val) override {} virtual void OnAppEvent(AppEvent_t* event) override {} private: + void resetPage() { + UIS->setTxt(pageId, ob_login_uName, ""); // 用户名 + UIS->setTxt(pageId, ob_login_uNameEMsg, ""); // 用户名错误信息 + UIS->setTxt(pageId, ob_login_pwd, ""); // 密码 + UIS->setTxt(pageId, ob_login_pwdEMsg, ""); // 密码错误信息 + } }; // 实例化LoginPage, 使其自动注册 diff --git a/usrc/uicontroler/pagerouter/page_bak_router.cpp b/usrc/uicontroler/pagerouter/page_bak_router.cpp index 4a0df07..d4424cc 100644 --- a/usrc/uicontroler/pagerouter/page_bak_router.cpp +++ b/usrc/uicontroler/pagerouter/page_bak_router.cpp @@ -23,7 +23,7 @@ int getBakPage(int nowPage) { // ) { // return pg_muSettings; // } - return pg_main; + return pg_home; } } // namespace iflytop