From 912c7c4bc653e203d69c8026ecdd77ba3c308dda Mon Sep 17 00:00:00 2001 From: zhaohe Date: Wed, 20 Nov 2024 20:50:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0popWinPage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .cproject | 30 ----- .settings/language.settings.xml | 4 +- .vscode/c_cpp_properties.json | 52 ++++---- .vscode/c_cpp_properties.json copy 2.bak | 35 ++++++ .vscode/settings.json | 3 +- hello.cpp | 9 ++ uappbase/base.hpp | 4 +- uappbase/bean/appevent.h | 36 ++++++ uappbase/bean/event.hpp | 47 +------- uappbase/service/app_event_bus.cpp | 1 + uappbase/service/gstate_mgr.cpp | 2 +- ui/hand_acid_mainboard_ui.HMI | Bin 19270797 -> 19270797 bytes ui/ui.h | 19 +-- usrc/apphardware/apphardware.hpp | 2 +- usrc/db/type/device_setting.hpp | 4 - usrc/service/app_core.cpp | 14 ++- usrc/service/remote_controler_event_processer.cpp | 30 +++-- usrc/service/remote_controler_event_processer.hpp | 1 - usrc/uicontroler/base/page_processer.cpp | 9 +- usrc/uicontroler/base/page_processer.hpp | 9 +- usrc/uicontroler/base/ui_public_state.cpp | 0 usrc/uicontroler/base/ui_public_state.hpp | 14 --- usrc/uicontroler/base/ui_state.cpp | 42 +++++++ usrc/uicontroler/base/ui_state.hpp | 26 ++++ usrc/uicontroler/page/PageInitializer.cpp | 8 -- usrc/uicontroler/page/home_page.cpp | 2 +- usrc/uicontroler/page/navi_page.cpp | 5 +- usrc/uicontroler/page/popwin_page.cpp | 138 ++++++++++++++++++++++ usrc/uicontroler/pagerouter/page_bak_router.cpp | 2 +- usrc/uicontroler/pagerouter/page_bak_router.hpp | 1 - usrc/uicontroler/tjc/tjc_base_type.h | 109 +++++++++++++++++ usrc/uicontroler/tjc/tjc_constant.hpp | 117 +----------------- usrc/uicontroler/ui_controler.cpp | 94 +++------------ usrc/uicontroler/ui_controler.hpp | 22 ++-- 34 files changed, 524 insertions(+), 367 deletions(-) create mode 100644 .vscode/c_cpp_properties.json copy 2.bak create mode 100644 hello.cpp create mode 100644 uappbase/bean/appevent.h delete mode 100644 usrc/uicontroler/base/ui_public_state.cpp delete mode 100644 usrc/uicontroler/base/ui_public_state.hpp create mode 100644 usrc/uicontroler/base/ui_state.cpp create mode 100644 usrc/uicontroler/base/ui_state.hpp delete mode 100644 usrc/uicontroler/page/PageInitializer.cpp create mode 100644 usrc/uicontroler/page/popwin_page.cpp create mode 100644 usrc/uicontroler/tjc/tjc_base_type.h diff --git a/.cproject b/.cproject index 8f9b407..fcc79fc 100644 --- a/.cproject +++ b/.cproject @@ -134,36 +134,6 @@ - - - - diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml index 1eb30e0..adb54ce 100644 --- a/.settings/language.settings.xml +++ b/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -16,7 +16,7 @@ - + diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 87ff7e7..e3dae62 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -1,34 +1,42 @@ { "configurations": [ { - "name": "app", + "name": "Win32", "includePath": [ - "./Core/Inc", - "./app_protocols", - "./Drivers/STM32F4xx_HAL_Driver/Inc", - "./Drivers/STM32F4xx_HAL_Driver/Inc/Legacy", - "./Middlewares/Third_Party/FreeRTOS/Source/include", - "./Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS", - "./Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F", - "./Middlewares/ST/STM32_USB_Host_Library/Core/Inc/", - "USB_HOST/Target/", - "USB_HOST/App/", - "FATFS/App/", - "FATFS/Target/", - "Middlewares/Third_Party/FatFs/src/", - "Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Inc/", - "./Drivers/CMSIS/Device/ST/STM32F4xx/Include", - "./Drivers/CMSIS/Include", - "./usrc/", - "./" + "${workspaceFolder}/Core/Inc", + "${workspaceFolder}/app_protocols", + "${workspaceFolder}/Drivers/STM32F4xx_HAL_Driver/Inc", + "${workspaceFolder}/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy", + "${workspaceFolder}/Middlewares/Third_Party/FreeRTOS/Source/include", + "${workspaceFolder}/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS", + "${workspaceFolder}/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F", + "${workspaceFolder}/Middlewares/ST/STM32_USB_Host_Library/Core/Inc/", + "${workspaceFolder}/USB_HOST/Target/", + "${workspaceFolder}/USB_HOST/App/", + "${workspaceFolder}/FATFS/App/", + "${workspaceFolder}/FATFS/Target/", + "${workspaceFolder}/Middlewares/Third_Party/FatFs/src/", + "${workspaceFolder}/Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Inc/", + "${workspaceFolder}/Drivers/CMSIS/Device/ST/STM32F4xx/Include", + "${workspaceFolder}/Drivers/CMSIS/Include", + "${workspaceFolder}/usrc/", + "${workspaceFolder}/" + ], "defines": [ "DEBUG", "USE_HAL_DRIVER", - "STM32F407xx" + "STM32F407xx" ], - "compilerPath": "C:/ST/STM32CubeIDE_1.13.0/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.win32_1.1.0.202305231506/tools/bin/arm-none-eabi-g++.exe", - "intelliSenseMode": "${default}" + "compilerPath": "C:/ST/STM32CubeIDE_1.13.0/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.12.3.rel1.win32_1.0.100.202403111256/tools/bin/arm-none-eabi-g++.exe", + "intelliSenseMode": "gcc-x64", + "browse": { + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "", + "path": [ + "${workspaceFolder}" + ] + } } ], "version": 4 diff --git a/.vscode/c_cpp_properties.json copy 2.bak b/.vscode/c_cpp_properties.json copy 2.bak new file mode 100644 index 0000000..c69b89f --- /dev/null +++ b/.vscode/c_cpp_properties.json copy 2.bak @@ -0,0 +1,35 @@ +{ + "configurations": [ + { + "name": "app", + "includePath": [ + "./Core/Inc", + "./app_protocols", + "./Drivers/STM32F4xx_HAL_Driver/Inc", + "./Drivers/STM32F4xx_HAL_Driver/Inc/Legacy", + "./Middlewares/Third_Party/FreeRTOS/Source/include", + "./Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS", + "./Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F", + "./Middlewares/ST/STM32_USB_Host_Library/Core/Inc/", + "USB_HOST/Target/", + "USB_HOST/App/", + "FATFS/App/", + "FATFS/Target/", + "Middlewares/Third_Party/FatFs/src/", + "Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Inc/", + "./Drivers/CMSIS/Device/ST/STM32F4xx/Include", + "./Drivers/CMSIS/Include", + "./usrc/", + "./" + ], + "defines": [ + "DEBUG", + "USE_HAL_DRIVER", + "STM32F407xx" + ], + "compilerPath": "C:/ST/STM32CubeIDE_1.13.0/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.12.3.rel1.win32_1.0.100.202403111256/tools/bin/arm-none-eabi-g++.exe", + "intelliSenseMode": "${default}" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 3b7456f..95b1834 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -99,7 +99,8 @@ "file_operate.h": "c", "fatfs.h": "c", "stm32f4xx.h": "c", - "stm32f407xx.h": "c" + "stm32f407xx.h": "c", + "cstring": "cpp" }, "files.autoGuessEncoding": false, "files.encoding": "gb2312" diff --git a/hello.cpp b/hello.cpp new file mode 100644 index 0000000..a3bb1db --- /dev/null +++ b/hello.cpp @@ -0,0 +1,9 @@ +#include +#include +#include "ui/ui.h" + +int main() { + std::cout << "Hello, World!" << std::endl; + return 0; + +} \ No newline at end of file diff --git a/uappbase/base.hpp b/uappbase/base.hpp index aef4fc9..05b3ca3 100644 --- a/uappbase/base.hpp +++ b/uappbase/base.hpp @@ -2,8 +2,8 @@ #include "appdep.hpp" #include "bean/bean.hpp" #include "appcfg/appcfg.hpp" -// +// // #include "service/app_event_bus.hpp" #include "service/gstate_mgr.hpp" -// +// // #include "apphal/apphal.hpp" diff --git a/uappbase/bean/appevent.h b/uappbase/bean/appevent.h new file mode 100644 index 0000000..34f193d --- /dev/null +++ b/uappbase/bean/appevent.h @@ -0,0 +1,36 @@ +#pragma once +#include +#include "uicontroler/tjc/tjc_base_type.h" + +typedef enum { + kAE_RunModeChangeEvent, // 运行模式改变 + + kAppEvent_StateDisplayInfo, + kAppEvent_AcidChCfgChangeEvent, + + // UI_EVENT + KAE_UIEvent, + kAE_LoginEvent, + kAE_unLoginEvent, + + kAE_AcidStatChangeEvent, // 统计数据变化事件 + kAE_RemoterConnectedEvent, // 遥控器连接成功 + kAE_RemoterDisConnectedEvent, // 遥控器断开连接 + +} AppEventType_t; + +/** + * + * @注意 + * 下面这个结构不易定义过大,否则容易造成栈溢出 + */ + +typedef struct { + AppEventType_t type; + union { + uint32_t placeholder; + char bleName[20]; + char stateDisplayInfo[30]; + UIEvent uiEvent; + } d; +} AppEvent_t; \ No newline at end of file diff --git a/uappbase/bean/event.hpp b/uappbase/bean/event.hpp index 1e8410f..0db0294 100644 --- a/uappbase/bean/event.hpp +++ b/uappbase/bean/event.hpp @@ -3,53 +3,12 @@ #include #include -#include - -#include "uicontroler\tjc\tjc_constant.hpp" +extern "C" { +#include "appevent.h" +} namespace iflytop { using namespace std; -typedef enum { - kAE_RunModeChangeEvent, // 运行模式改变 - - kAppEvent_StateDisplayInfo, - kAppEvent_AcidChCfgChangeEvent, - - // UI_EVENT - KAE_UIEvent, - kAE_LoginEvent, - kAE_unLoginEvent, - - kAE_AcidStatChangeEvent, // 统计数据变化事件 - kAE_RemoterConnectedEvent, // 遥控器连接成功 - kAE_RemoterDisConnectedEvent, // 遥控器断开连接 - -} AppEventType_t; -/** - * - * @brief - * - * - * @注意 - * 下面这个结构不易定义过大,否则容易造成栈溢出 - */ - -typedef struct { - AppEventType_t type; - union event { - uint32_t placeholder; - char bleName[20]; - char stateDisplayInfo[30]; - tjc::UIEvent uiEvent; - } d; - -} AppEvent_t; - -static inline AppEvent_t createAppEvent(AppEventType_t type) { - AppEvent_t event; - event.type = type; - return event; -} static inline AppEvent_t createStateDisplayInfoEvent(const char* info) { AppEvent_t event; diff --git a/uappbase/service/app_event_bus.cpp b/uappbase/service/app_event_bus.cpp index 97dd7cc..ff4d016 100644 --- a/uappbase/service/app_event_bus.cpp +++ b/uappbase/service/app_event_bus.cpp @@ -10,6 +10,7 @@ void AppEventBus::initialize() { thread.init("AppEventBus", 1024); xQueue = xQueueCreate(20, sizeof(AppEvent_t)); + thread.start([this]() { AppEvent_t event; while (1) { diff --git a/uappbase/service/gstate_mgr.cpp b/uappbase/service/gstate_mgr.cpp index 2c08f89..49faa61 100644 --- a/uappbase/service/gstate_mgr.cpp +++ b/uappbase/service/gstate_mgr.cpp @@ -71,7 +71,7 @@ void GStateMgr::setRunMode(hand_acid_mode_t mode) { zlock_guard l(m_mutex); if (m_RunMode != mode) { m_RunMode = mode; - AppEventBus::ins()->pushEvent(createAppEvent(kAE_RunModeChangeEvent)); + AppEventBus::ins()->pushSimpleEvent(kAE_RunModeChangeEvent); } } void GStateMgr::changeToNextRunMode() { diff --git a/ui/hand_acid_mainboard_ui.HMI b/ui/hand_acid_mainboard_ui.HMI index 21ad954cb5e0160965679a153d3651b596af0728..2e84d40d395d3503aa6e9333c13d2cebe1515139 100644 GIT binary patch delta 1746 zcmdVYi&Iop9Ki8&c9-4I1T9lj(#4f&#%Y{!8b|CUWmcwvmS(1fWG~BbT}ac)G=8?3 z;A$vWKzmq8rir-L(qk1&%SzK;_K@nP(UVLwdr8svXUz03ztBd7Y@2+%P?%ExL&m9mhF#oNJ=CB#n%@_-_EoSyM#>}DAf$19u9rPSH z9yWD;o@G^~#G5=pUq5}*q}Et7sL*?2&*hM;@v{dfBgV3~4e2)S3uI^bHm$EOD9;J? zC@Bs_i$fM3c;Q0|{E6aFptR|v_{kDC6m^-xWeS%mT&8fD!et6K6bLr`A6|&Np~-Q{ zmLYPUoG%y1g>sP$l^nTPE|Fn!sSKCPH^D zvN-|)oLJ*BO?Y~E*3?2Lc=no}BgS%br{~{C8D3)|(6yKY*3iDs?O@FO_Whnt#x%C? zmvk|vqnAL(kHytzdKot&1+ zc}}f=yFamNL!>&*8D1MX;^bsR&WX0Qh7)bAGg{W3BtO48%_%LY&Wz?KBPc>K?#4{a z!abOcIk*@1;eO1;1DJ>Tcn~EJEWksE;$bYrBUpq|lwmPqSc0W^6y;ck<*0yz6{tiN zs<9HQ@E9J)6L=D<@f4oMGgyNfJd3q>4(qTU&tn5>u@QCHgg7?i1-ys^>hTg@#w&Og zNo>JZG@udN@EW#b2VTb;*oims7T(4#?8ZCTgS~hc@8NxXfDf?`AK_zsf={s@P52C- z;|sX>5(jV)U!fUa;~RX7@9;f-Kns4vA^e2HID(&X6u;mYe#LM29e?0Y97iku!ry3H zl%KRQXgnIP#-~Zq_%#8|DVkJG2Te!KshUojG)=muv!;vYG|lOnu9`D6-89`bJv3)( hdTM%UGBjstdTaV|#+ur9_c!yDL(eVLY;# z5E03%rCltun}s4x7h4w7E_PGO(juBJbkm~y-R%1m{RjQvob&n4JM+GC&hx`GEM1b; z0DD}MU7xZwx~8$nPTf4)YWD0+`DGQe@+KBevih%<-mul`w=5ghae3jg|2DW!*cG-4 zv)MyicS_J1pih=Q1p@^`oopG=**rFs;{=nVDs)jB3&mq08!1SI10VcuEEK5k-uou1 z^+Iuvkv&HC7};ZFkC8n__CkSR_ug=z%?p*bNr8-%6J?Z~Bqz&g86#um6d5O{%4srQ zCdlbBQ6|Y5a;BUmg;FHNa<)vCDRPcXm2>4hIbSZ2X>y@lBqegOTq4t@RLbO1xlAsX z88TDKZ19%WC@eo$wVLXCI@faS*YCM4_(TX)# zi#Du7JD!4zr|}G)#dBDX=aE1MlIX++ynv0^gctD=UdAifj92j*UdJ1F6I-wqU3d#` zV;kPVyV#B$cn|NR8y}ztAHu^&_!ytyQ}p69e2y>hCBDK=?84Xh27UMz-{E`wfFJP_ ze#S5O6~Ezk{DD8Q8-HQXqPm3L2u+G6RpV%U8owr>8K6ni4AczL4A!J;_R;LC$initialize(); // 基础硬件初始化 + /*********************************************************************************************************************** + * 服务初始化 * + ***********************************************************************************************************************/ + ZLOGI(TAG, "load zhdb"); ZHDB::init(); UserDao::init(); @@ -107,10 +111,10 @@ void AppCore::initialize() { // UIControler::ins()->chpage(pg_login); UIControler::ins()->chpage(pg_navi); - - - - + osDelay(1000); + UIControler::ins()->popWarningWin("警告!!!!!!!"); + UIControler::ins()->popConfirmWin("消息确认!!!!!!!", [](bool val) { ZLOGI(TAG, "confirm val %d", val); }); + UIControler::ins()->popInfoWin("消息确认!!!!!!!"); while (true) osDelay(30); } diff --git a/usrc/service/remote_controler_event_processer.cpp b/usrc/service/remote_controler_event_processer.cpp index 4be7491..6c8c486 100644 --- a/usrc/service/remote_controler_event_processer.cpp +++ b/usrc/service/remote_controler_event_processer.cpp @@ -1,22 +1,19 @@ #include "remote_controler_event_processer.hpp" #include "db/dao/device_setting_dao.hpp" + +// #include "pump_ctrl_service.hpp" #include "service/remote_controler.hpp" +#include "uicontroler/ui_controler.hpp" +#include "ui/ui.h" // -#include "uicontroler/ui_controler.hpp" using namespace iflytop; #define TAG "RemoteControlerEventProcesser" -static const char* zhex2str(uint8_t* data, size_t len) { - static char buf[256]; - memset(buf, 0, sizeof(buf)); - for (size_t i = 0; i < len; i++) { - sprintf(buf + i * 2, "%02X", data[i]); - } - return buf; -} + +static const char* zhex2str(uint8_t* data, size_t len); void RemoteControlerEventProcesser::initialize() { m_thread.init(TAG); @@ -109,7 +106,7 @@ void RemoteControlerEventProcesser::processKeyEventFromRemoter(hand_acid_remoter * @brief 如果不在首页,则报警 */ if (UIS->getNowPage() != pg_home) { - UIS->alert("请先切换到首页,在控制设备"); + UIS->popWarningWin("请先切换到首页,在控制设备"); return; } @@ -119,7 +116,7 @@ void RemoteControlerEventProcesser::processKeyEventFromRemoter(hand_acid_remoter if (keyEvent == hand_acid_remoter_kevent_add_liquid) { // if (!GSM->isHasPumpSelect()) { - UIS->alert("请至少选中一个通道"); + UIS->popWarningWin("请至少选中一个通道"); return; } @@ -141,9 +138,18 @@ void RemoteControlerEventProcesser::processKeyEventFromRemoter(hand_acid_remoter } else if (keyEvent == hand_acid_remoter_kevent_preFilling) { // 管路填充 if (!GSM->isHasPumpSelect()) { - UIS->alert("请至少选中一个通道"); + UIS->popWarningWin("请至少选中一个通道"); return; } PUMPCS->acidPrefilling(); } } + +static const char* zhex2str(uint8_t* data, size_t len) { + static char buf[256]; + memset(buf, 0, sizeof(buf)); + for (size_t i = 0; i < len; i++) { + sprintf(buf + i * 2, "%02X", data[i]); + } + return buf; +} diff --git a/usrc/service/remote_controler_event_processer.hpp b/usrc/service/remote_controler_event_processer.hpp index 12475d2..7a14b47 100644 --- a/usrc/service/remote_controler_event_processer.hpp +++ b/usrc/service/remote_controler_event_processer.hpp @@ -4,7 +4,6 @@ #include "uappbase/base.hpp" #include "config/config.hpp" namespace iflytop { -using namespace std; /** * @brief * diff --git a/usrc/uicontroler/base/page_processer.cpp b/usrc/uicontroler/base/page_processer.cpp index 379f450..4c8ab0e 100644 --- a/usrc/uicontroler/base/page_processer.cpp +++ b/usrc/uicontroler/base/page_processer.cpp @@ -30,17 +30,16 @@ void IPageProcesser::initialize() { return; } - if (event->d.uiEvent.eventId == tjc::kpt_sys_event_page_id) { + if (event->d.uiEvent.eventId == kpt_sys_event_page_id) { OnPageLoadContext cxt = {0}; OnPageLoad(&cxt); - } else if (event->d.uiEvent.eventId == tjc::kpt_double_state_button_event) { + } else if (event->d.uiEvent.eventId == kpt_double_state_button_event) { OnDoubleStateButton(event->d.uiEvent.bid, event->d.uiEvent.d.double_state_button.val); - } else if (event->d.uiEvent.eventId == tjc::kpt_button_event) { + } else if (event->d.uiEvent.eventId == kpt_button_event) { OnButton(event->d.uiEvent.bid, event->d.uiEvent.d.button_event.val); - } else if (event->d.uiEvent.eventId == tjc::kpt_inputfield_content_change_event1) { + } else if (event->d.uiEvent.eventId == kpt_inputfield_content_change_event1) { OnInputFieldContentChange(event->d.uiEvent.bid, event->d.uiEvent.d.inputfield_content.text); } - // } else { OnAppEvent(event); diff --git a/usrc/uicontroler/base/page_processer.hpp b/usrc/uicontroler/base/page_processer.hpp index 7b0d3dd..0de33a8 100644 --- a/usrc/uicontroler/base/page_processer.hpp +++ b/usrc/uicontroler/base/page_processer.hpp @@ -1,11 +1,16 @@ #pragma once +#include -#include "apphardware/apphardware.hpp" #include "config/config.hpp" #include "uappbase/base.hpp" +#include "uappbase\bean\event.hpp" #include "ui/ui.h" + +// + +#include "apphardware/apphardware.hpp" #include "uicontroler/ui_controler.hpp" -#include "uicontroler/pagerouter/page_bak_router.hpp" +// #include "uicontroler/pagerouter/page_bak_router.hpp" namespace iflytop { using namespace std; diff --git a/usrc/uicontroler/base/ui_public_state.cpp b/usrc/uicontroler/base/ui_public_state.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/usrc/uicontroler/base/ui_public_state.hpp b/usrc/uicontroler/base/ui_public_state.hpp deleted file mode 100644 index e138b22..0000000 --- a/usrc/uicontroler/base/ui_public_state.hpp +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "uappbase/base.hpp" -#include "uicontroler/ui_controler.hpp" -namespace iflytop { - -class UIPublicState { - private: - /* data */ - public: - -}; - -} // namespace iflytop \ No newline at end of file diff --git a/usrc/uicontroler/base/ui_state.cpp b/usrc/uicontroler/base/ui_state.cpp new file mode 100644 index 0000000..f723293 --- /dev/null +++ b/usrc/uicontroler/base/ui_state.cpp @@ -0,0 +1,42 @@ +#include "ui_state.hpp" +using namespace iflytop; + +static QueueHandle_t xQueue; +static int popInfoNum; + +static zmutex lock = {"UIPublicState-Lock"}; +#define TAG "UIPublicState" + +void UIPublicState::initialize() { // + xQueue = xQueueCreate(5, sizeof(UIPopInfo_t)); + ZASSERT(xQueue); + lock.init(); +} + +void UIPublicState::pushUIPopInfo(UIPopWinType_t type, const char* info, function onConfirm) { + zlock_guard guard(lock); + static UIPopInfo_t popInfo; + popInfo.type = type; + strncpy(popInfo.info, info, sizeof(popInfo.info)); + popInfo.onConfirm = onConfirm; + BaseType_t suc = xQueueSend(xQueue, &popInfo, 0); + if (suc == 0) { + ZLOGE(TAG, "pushUIPopInfo failed"); + if (onConfirm) onConfirm(false); + } + + popInfoNum++; +} +bool UIPublicState::popUIPopInfoBlock(UIPopInfo_t* info) { + BaseType_t suc = xQueueReceive(xQueue, info, 100); + if (suc != 0) { + { + zlock_guard guard(lock); + popInfoNum--; + } + return true; + } + return false; +} + +int UIPublicState::getPopInfoNum() { return popInfoNum; } diff --git a/usrc/uicontroler/base/ui_state.hpp b/usrc/uicontroler/base/ui_state.hpp new file mode 100644 index 0000000..60077ef --- /dev/null +++ b/usrc/uicontroler/base/ui_state.hpp @@ -0,0 +1,26 @@ +#pragma once + +#include "uappbase/base.hpp" +namespace iflytop { + +typedef enum { + UI_POP_WIN_TYPE_INFO, + UI_POP_WIN_TYPE_WARNING_INFO, + UI_POP_WIN_TYPE_CONFIRM, + UI_POP_WIN_TYPE_FATAL_ERROR, +} UIPopWinType_t; + +typedef struct { + UIPopWinType_t type; + char info[100]; + function onConfirm; +} UIPopInfo_t; + +class UIPublicState { + public: + static void initialize(); + static void pushUIPopInfo(UIPopWinType_t type, const char* info, function onConfirm); + static bool popUIPopInfoBlock(UIPopInfo_t* info); + static int getPopInfoNum(); +}; +} // namespace iflytop \ No newline at end of file diff --git a/usrc/uicontroler/page/PageInitializer.cpp b/usrc/uicontroler/page/PageInitializer.cpp deleted file mode 100644 index fc820a9..0000000 --- a/usrc/uicontroler/page/PageInitializer.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "uicontroler/base/page_processer.hpp" -namespace iflytop { -using namespace std; - - -} // namespace iflytop - -// kpt_sys_event_page_id \ No newline at end of file diff --git a/usrc/uicontroler/page/home_page.cpp b/usrc/uicontroler/page/home_page.cpp index 54ff8cb..b5234e5 100644 --- a/usrc/uicontroler/page/home_page.cpp +++ b/usrc/uicontroler/page/home_page.cpp @@ -54,7 +54,7 @@ class HomePage : public IPageProcesser { virtual void OnButton(uint8_t bid, uint8_t val) override { ZLOGI(TAG, "OnButton bid:%d val:%d", bid, val); if (PumpCtrlService::ins()->isWorking()) { - UIS->alert("工作中,请稍后再操作"); + UIS->popWarningWin("工作中,请稍后再操作"); return; } diff --git a/usrc/uicontroler/page/navi_page.cpp b/usrc/uicontroler/page/navi_page.cpp index a999006..668aec2 100644 --- a/usrc/uicontroler/page/navi_page.cpp +++ b/usrc/uicontroler/page/navi_page.cpp @@ -1,5 +1,5 @@ -#include "db/dao/user_dao.hpp" +// #include "db/dao/user_dao.hpp" #include "ui/ui.h" #include "uicontroler/base/page_processer.hpp" namespace iflytop { @@ -12,11 +12,12 @@ class NaviPage : public IPageProcesser { char passwd[20] = {0}; public: - NaviPage() : IPageProcesser(TAG, pg_login) {} + NaviPage() : IPageProcesser(TAG, pg_navi) {} virtual void initialize() override { IPageProcesser::initialize(); syncState(); + } private: diff --git a/usrc/uicontroler/page/popwin_page.cpp b/usrc/uicontroler/page/popwin_page.cpp new file mode 100644 index 0000000..b499bcd --- /dev/null +++ b/usrc/uicontroler/page/popwin_page.cpp @@ -0,0 +1,138 @@ + +#include "ui/ui.h" +#include "uicontroler/base/page_processer.hpp" +#include "uicontroler/base/ui_state.hpp" +using namespace iflytop; +using namespace std; +#define TAG "PopWinPage" + +static UIPopInfo_t hangupInfo; +static bool handupInfoFlag = false; +static int lastPage = 0; +static int displayNum = 0; + +class PopWinPage : public IPageProcesser { + private: + ZThread thread; + + public: + PopWinPage() : IPageProcesser(TAG, pg_popwin) {} + + virtual void initialize() override { + IPageProcesser::initialize(); + syncState(); + + thread.init("PopWinPage", 512); + thread.start([this]() { + while (true) { + if (handupInfoFlag) { + osDelay(300); + updatePopWindowsInfo(&hangupInfo); + } else { + if (UIPublicState::popUIPopInfoBlock(&hangupInfo)) { + ZLOGI(TAG, "PopWinPage info:%s", hangupInfo.info); + initPopWindowsInfo(&hangupInfo); + } + } + } + }); + } + + private: + virtual void OnPageLoad(OnPageLoadContext* cxt) override {} + virtual void OnBackKey(OnPageLoadContext* cxt) override {} + virtual void OnInputFieldContentChange(uint8_t bid, const char* text) override {} + virtual void OnButton(uint8_t bid, uint8_t val) override { + // + int num = UIPublicState::getPopInfoNum(); + if (bid == ob_popwin_canclekey) { + if (hangupInfo.onConfirm) { + hangupInfo.onConfirm(false); + } + } else if (bid == ob_popwin_confirmkey) { + if (hangupInfo.onConfirm) { + hangupInfo.onConfirm(true); + } + } + + if (num <= 0) { + UIControler::ins()->chpage(lastPage); + } + handupInfoFlag = false; + } + virtual void OnDoubleStateButton(uint8_t bid, uint8_t val) override {} + virtual void OnAppEvent(AppEvent_t* event) override {} + + void updatePopWindowsInfo(UIPopInfo_t* info) { + int num = UIPublicState::getPopInfoNum(); + if (num != displayNum) { + displayNum = num; + if (info->type == UI_POP_WIN_TYPE_INFO) { + UIControler::ins()->setTxt(pageId, ob_popwin_t1, "消息(%d)", displayNum + 1); + } else if (info->type == UI_POP_WIN_TYPE_WARNING_INFO) { + UIControler::ins()->setTxt(pageId, ob_popwin_t1, "警告(%d)", displayNum + 1); + } else if (info->type == UI_POP_WIN_TYPE_CONFIRM) { + UIControler::ins()->setTxt(pageId, ob_popwin_t1, "消息(%d)", displayNum + 1); + } else if (info->type == UI_POP_WIN_TYPE_FATAL_ERROR) { + UIControler::ins()->setTxt(pageId, ob_popwin_t1, "警告(%d)", displayNum + 1); + } + } + } + + void initPopWindowsInfo(UIPopInfo_t* info) { + if (UIControler::ins()->getNowPage() != pageId) { + lastPage = UIControler::ins()->getNowPage(); + } + + handupInfoFlag = true; + displayNum = UIPublicState::getPopInfoNum(); + UIControler::ins()->chpage(pg_popwin); + + if (info->type == UI_POP_WIN_TYPE_INFO) { + // 消息 + UIControler::ins()->setTxt(pageId, ob_popwin_t1, "消息(%d)", displayNum + 1); + UIControler::ins()->sendcmd("p[%d].b[%d].pco=%d", pageId, ob_popwin_t1, 10591 /*蓝色*/); + + UIControler::ins()->setTxt(pageId, ob_popwin_info, info->info); + UIControler::ins()->sendcmd("p[%d].b[%d].pco=%d", pageId, ob_popwin_info, 0 /*黑色*/); + + UIControler::ins()->vis(ob_popwin_canclekey, 0); + + } else if (info->type == UI_POP_WIN_TYPE_WARNING_INFO) { + // 警告消息 + UIControler::ins()->setTxt(pageId, ob_popwin_t1, "警告(%d)", displayNum + 1); + UIControler::ins()->sendcmd("p[%d].b[%d].pco=%d", pageId, ob_popwin_t1, 63488 /*红色*/); + + UIControler::ins()->setTxt(pageId, ob_popwin_info, info->info); + UIControler::ins()->sendcmd("p[%d].b[%d].pco=%d", pageId, ob_popwin_info, 63488 /*红色*/); + + UIControler::ins()->vis(ob_popwin_canclekey, 0); + + } else if (info->type == UI_POP_WIN_TYPE_CONFIRM) { + // 确认(可被取消) + UIControler::ins()->setTxt(pageId, ob_popwin_t1, "消息(%d)", displayNum + 1); + UIControler::ins()->sendcmd("p[%d].b[%d].pco=%d", pageId, ob_popwin_t1, 10591 /*蓝色*/); + + UIControler::ins()->setTxt(pageId, ob_popwin_info, info->info); + UIControler::ins()->sendcmd("p[%d].b[%d].pco=%d", pageId, ob_popwin_info, 0 /*黑色*/); + + UIControler::ins()->vis(ob_popwin_canclekey, 1); + } else if (info->type == UI_POP_WIN_TYPE_FATAL_ERROR) { + // 警告消息 + UIControler::ins()->setTxt(pageId, ob_popwin_t1, "警告(%d)", displayNum + 1); + UIControler::ins()->sendcmd("p[%d].b[%d].pco=%d", pageId, ob_popwin_t1, 63488 /*红色*/); + + UIControler::ins()->setTxt(pageId, ob_popwin_info, info->info); + UIControler::ins()->sendcmd("p[%d].b[%d].pco=%d", pageId, ob_popwin_info, 63488 /*红色*/); + + UIControler::ins()->vis(ob_popwin_canclekey, 0); + UIControler::ins()->vis(ob_popwin_confirmkey, 0); + } + } + + private: + void syncState() {} +}; + +// 实例化LoginPage, 使其自动注册 +static PopWinPage instance; diff --git a/usrc/uicontroler/pagerouter/page_bak_router.cpp b/usrc/uicontroler/pagerouter/page_bak_router.cpp index d4424cc..30c98d3 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_home; + return 0; } } // namespace iflytop diff --git a/usrc/uicontroler/pagerouter/page_bak_router.hpp b/usrc/uicontroler/pagerouter/page_bak_router.hpp index ded6d82..5de62bd 100644 --- a/usrc/uicontroler/pagerouter/page_bak_router.hpp +++ b/usrc/uicontroler/pagerouter/page_bak_router.hpp @@ -1,7 +1,6 @@ #pragma once #include "apphardware/apphardware.hpp" #include "uappbase/base.hpp" -#include "uicontroler/ui_controler.hpp" #include "config/config.hpp" namespace iflytop { int getBakPage(int nowPage); diff --git a/usrc/uicontroler/tjc/tjc_base_type.h b/usrc/uicontroler/tjc/tjc_base_type.h new file mode 100644 index 0000000..f3aeae1 --- /dev/null +++ b/usrc/uicontroler/tjc/tjc_base_type.h @@ -0,0 +1,109 @@ +#pragma once +#include +/** + * @brief + * + * 约定 + * 1.用户名最大长度为15 + * 2.组件名称最大长度为14 + * 3.页面名称最大长度为14 + * 4.密码为纯数字6位数密码 + * + * + * 1. 键盘最终不修改页面内容,页面内容由单片机进行修改 + * 2. 每进入一个页面均要发送sendme指令 + * 2. 可用组件 + * 按键 + * 双态按键 + * 键盘 + * 文本输入框(页面一律使用文本输入框) + * 图片 + * 返回按键 + * 下拉框组件 + * + */ + +#define MAX_USR_PASSWD_LENGTH (6) +#define ELEMENT_ID_MAX_SIZE 14 +#define TJC_MAX_PACKET_SIZE 256 + +typedef enum { + /** + * @brief 错误码 + */ + kpt_sys_ecode_invalid = 0x00, + kpt_sys_ecode_suc = 0x01, + kpt_sys_ecode_invalid_control_id = 0x02, + kpt_sys_ecode_invalid_page_id = 0x03, + kpt_sys_ecode_invalid_image_id = 0x04, + kpt_sys_ecode_invalid_font_id = 0x05, + kpt_sys_ecode_file_op_failed = 0x06, + kpt_sys_ecode_crc_failed = 0x09, + kpt_sys_ecode_invalid_baudrate = 0x11, + kpt_sys_ecode_invalid_curve_id = 0x12, + kpt_sys_ecode_invalid_var_name = 0x1A, + kpt_sys_ecode_invalid_var_op = 0x1B, + kpt_sys_ecode_var_op_failed = 0x1C, + kpt_sys_ecode_flash_op_failed = 0x1D, + kpt_sys_ecode_invalid_param_num = 0x1E, + kpt_sys_ecode_io_op_failed = 0x1F, + kpt_sys_ecode_escape_char_failed = 0x20, + kpt_sys_ecode_var_name_too_long = 0x23, + kpt_sys_ecode_serial_buf_overflow = 0x24, + /** + * @brief 事件 + */ + kpt_button_event = 0x65, // 普通按键 + kpt_sys_event_page_id = 0x66, // 页面变化事件 + kpt_sys_event_touch_data = 0x67, + kpt_sys_event_sleep_touch = 0x68, + kpt_sys_event_string_var = 0x70, + kpt_sys_event_number_var = 0x71, + kpt_sys_event_sleep_mode = 0x86, + kpt_sys_event_auto_wakeup = 0x87, + kpt_sys_event_sys_start = 0x88, + kpt_sys_event_sd_upgrade = 0x89, + kpt_sys_event_passthrough_finish = 0xFD, + kpt_sys_event_passthrough_ready = 0xFE, + + /** + * @brief 用户消息回执 + */ + kpt_ack = 0xAA, + // + kpt_inputfield_content_change_event1 = 0xAC, // 跨页面键盘输入事件 + kpt_double_state_button_event = 0xAD, + kpt_bakup_button_event = 0xB0, // 返回按键 +} tjc_packet_type_t; + +typedef enum { + kbutton_release = 0, + kbutton_press = 1, +} button_event_t; + +typedef enum { + k_button_release_event = 1, + k_input_confirm_event = 2, +} usr_event_type_t; + +typedef struct { + int32_t eventId; + uint8_t pid; + uint8_t bid; + union { + // inputfield_content_event + struct { + char text[TJC_MAX_PACKET_SIZE]; + } inputfield_content; + + // kpt_double_state_button_event + struct { + uint8_t val; + } double_state_button; + + struct { + uint8_t val; // 0 抬起,1按下 + } button_event; + + } d; +} UIEvent; \ No newline at end of file diff --git a/usrc/uicontroler/tjc/tjc_constant.hpp b/usrc/uicontroler/tjc/tjc_constant.hpp index b3272c9..c6aa970 100644 --- a/usrc/uicontroler/tjc/tjc_constant.hpp +++ b/usrc/uicontroler/tjc/tjc_constant.hpp @@ -1,123 +1,12 @@ #pragma once #include - -#include "../ui/ui.h" -#include "uappbase/appcfg/appcfg.hpp" - +extern "C" { +#include "tjc_base_type.h" +} namespace tjc { - -/** - * @brief - * - * 约定 - * 1.用户名最大长度为15 - * 2.组件名称最大长度为14 - * 3.页面名称最大长度为14 - * 4.密码为纯数字6位数密码 - * - * - * 1. 键盘最终不修改页面内容,页面内容由单片机进行修改 - * 2. 每进入一个页面均要发送sendme指令 - * 2. 可用组件 - * 按键 - * 双态按键 - * 键盘 - * 文本输入框(页面一律使用文本输入框) - * 图片 - * 返回按键 - * 下拉框组件 - * - */ - -#define MAX_USR_PASSWD_LENGTH (6) -#define ELEMENT_ID_MAX_SIZE 14 -#define TJC_MAX_PACKET_SIZE 256 - -typedef enum { - /** - * @brief 错误码 - */ - kpt_sys_ecode_invalid = 0x00, - kpt_sys_ecode_suc = 0x01, - kpt_sys_ecode_invalid_control_id = 0x02, - kpt_sys_ecode_invalid_page_id = 0x03, - kpt_sys_ecode_invalid_image_id = 0x04, - kpt_sys_ecode_invalid_font_id = 0x05, - kpt_sys_ecode_file_op_failed = 0x06, - kpt_sys_ecode_crc_failed = 0x09, - kpt_sys_ecode_invalid_baudrate = 0x11, - kpt_sys_ecode_invalid_curve_id = 0x12, - kpt_sys_ecode_invalid_var_name = 0x1A, - kpt_sys_ecode_invalid_var_op = 0x1B, - kpt_sys_ecode_var_op_failed = 0x1C, - kpt_sys_ecode_flash_op_failed = 0x1D, - kpt_sys_ecode_invalid_param_num = 0x1E, - kpt_sys_ecode_io_op_failed = 0x1F, - kpt_sys_ecode_escape_char_failed = 0x20, - kpt_sys_ecode_var_name_too_long = 0x23, - kpt_sys_ecode_serial_buf_overflow = 0x24, - /** - * @brief 事件 - */ - kpt_button_event = 0x65, // 普通按键 - kpt_sys_event_page_id = 0x66, // 页面变化事件 - kpt_sys_event_touch_data = 0x67, - kpt_sys_event_sleep_touch = 0x68, - kpt_sys_event_string_var = 0x70, - kpt_sys_event_number_var = 0x71, - kpt_sys_event_sleep_mode = 0x86, - kpt_sys_event_auto_wakeup = 0x87, - kpt_sys_event_sys_start = 0x88, - kpt_sys_event_sd_upgrade = 0x89, - kpt_sys_event_passthrough_finish = 0xFD, - kpt_sys_event_passthrough_ready = 0xFE, - - /** - * @brief 用户消息回执 - */ - kpt_ack = 0xAA, - // - kpt_inputfield_content_change_event1 = 0xAC, // 跨页面键盘输入事件 - kpt_double_state_button_event = 0xAD, - kpt_bakup_button_event = 0xB0, // 返回按键 -} packet_type_t; - -typedef enum { - kbutton_release = 0, - kbutton_press = 1, -} button_event_t; - -typedef struct { - int32_t eventId; - uint8_t pid; - uint8_t bid; - union { - // inputfield_content_event - struct { - char text[TJC_MAX_PACKET_SIZE]; - } inputfield_content; - - // kpt_double_state_button_event - struct { - uint8_t val; - } double_state_button; - - struct { - uint8_t val; // 0 抬起,1按下 - } button_event; - - } d; -} UIEvent; - -typedef enum { - k_button_release_event = 1, - k_input_confirm_event = 2, -} usr_event_type_t; - const char* pt2str(uint8_t type); const char* uimarco2str(uint8_t pid, uint8_t bid); const char* pageName(uint8_t page); - #define UI_UUID(pgid, obid) ((pg_##pgid << 8) + ob_##pgid##_##obid) } // namespace tjc diff --git a/usrc/uicontroler/ui_controler.cpp b/usrc/uicontroler/ui_controler.cpp index e074a76..f20e2d2 100644 --- a/usrc/uicontroler/ui_controler.cpp +++ b/usrc/uicontroler/ui_controler.cpp @@ -38,8 +38,17 @@ void UIControler::initialize() { // eventProcessThread.init("eventProcessThread", 1024); tjcUart = AppHardware::ins()->tjcUart; + UIPublicState::initialize(); m_cmdlock.init(); } + +void UIControler::callUsrEventCb(UIEvent* event) { + static AppEvent_t appEvent; + appEvent.type = KAE_UIEvent; + memcpy(&appEvent.d.uiEvent, event, sizeof(UIEvent)); + AppEventBus::ins()->pushEvent(appEvent); +} + #define UART_RX_OVERTIME 5 void UIControler::startSchedule() { usartRxThread.start([this]() { @@ -78,17 +87,17 @@ void UIControler::startSchedule() { uint8_t packetType = packet.data[0]; memset(&event_cache, 0, sizeof(event_cache)); - if (packetType == tjc::kpt_inputfield_content_change_event1) { + if (packetType == kpt_inputfield_content_change_event1) { processInputfieldContentChangeEvent1(packet.data, packet.datalen); - } else if (packetType == tjc::kpt_double_state_button_event) { + } else if (packetType == kpt_double_state_button_event) { processUsrDoubleStateButtonEvent(packet.data, packet.datalen); - } else if (tjc::kpt_button_event == packetType) { + } else if (kpt_button_event == packetType) { event_cache.eventId = packet.data[0]; event_cache.pid = packet.data[1]; event_cache.bid = packet.data[2]; event_cache.d.button_event.val = packet.data[3]; callUsrEventCb(&event_cache); - } else if (tjc::kpt_sys_event_page_id == packetType) { + } else if (kpt_sys_event_page_id == packetType) { event_cache.eventId = packet.data[0]; event_cache.pid = packet.data[1]; event_cache.bid = 0; @@ -98,13 +107,12 @@ void UIControler::startSchedule() { } else { m_lastPage = m_nowPage; m_nowPage = packet.data[1]; - } #if MODULE_DEBUG - ZLOGD(TAG, "page change from %d to %d ", m_lastPage, m_nowPage); + ZLOGD(TAG, "page change from %d to %d ", m_lastPage, m_nowPage); #endif + } callUsrEventCb(&event_cache); - } else { event_cache.eventId = packet.data[0]; callUsrEventCb(&event_cache); @@ -136,7 +144,7 @@ void UIControler::processScreenRxPacket(uint8_t* data, size_t len) { static tjc_rx_packet_t packet; packet.datalen = len; memcpy(packet.data, data, len); - if (tjc::kpt_ack == packetType) { + if (kpt_ack == packetType) { if (m_isWaitingForAck) { bool suc = ackQueue.send(&packet, 10); if (!suc) { @@ -210,12 +218,7 @@ void UIControler::processUsrDoubleStateButtonEvent(uint8_t* data, size_t len) { callUsrEventCb(&event_cache); } -void UIControler::callUsrEventCb(tjc::UIEvent* event) { - static AppEvent_t appEvent; - appEvent.type = KAE_UIEvent; - memcpy(&appEvent.d.uiEvent, event, sizeof(tjc::UIEvent)); - AppEventBus::ins()->pushEvent(appEvent); -} + void UIControler::processInputfieldContentChangeEvent0(uint8_t* data, size_t len) { /** @@ -383,71 +386,12 @@ void UIControler::setrtc(zdate_t* date) { sendcmd("rtc5=%d", date->seconds); } -void UIControler::alert(const char* info, function onConfirm) { - zlock_guard lg(m_cmdlock); - // if (m_isInPopWin) { - // ZLOGE(TAG, "isInPopWin,alert failed"); - // return; - // } - - // m_onAlertPageConfirmKey = onConfirm; - // static char buf[128]; - // sprintf(buf, "%s", info); - - // sendcmd("p[%d].b[%d].val=%d", pg_alert, ob_alert_frompage, m_nowPage); - // sendcmd("p[%d].b[%d].txt=\"%s\"", pg_alert, ob_alert_info, buf); - // sendcmd("page alert"); -} -void UIControler::alertNoConfirm(const char* info) { +void UIControler::popWin(UIPopWinType_t type, const char* info, function onConfirm) { zlock_guard lg(m_cmdlock); - // if (m_isInPopWin) { - // ZLOGE(TAG, "isInPopWin,alertNoConfirm failed"); - // return; - // } - - // static char buf[128]; - // sprintf(buf, "%s", info); - - // sendcmd("p[%d].b[%d].val=dp", pg_alert, ob_alert_frompage); - // sendcmd("p[%d].b[%d].txt=\"%s\"", pg_alert, ob_alert_info, buf); - // sendcmd("page alert"); - // vis(ob_alert_confirmkey, 0); + UIPublicState::pushUIPopInfo(type, info, onConfirm); } -void UIControler::confirmNoCancle(const char* info, function onConfirm) { - zlock_guard lg(m_cmdlock); - // if (m_isInPopWin) { - // ZLOGE(TAG, "isInPopWin,confirmNoCancle failed"); - // return; - // } - - // m_onConfirmPageConfirmKey = onConfirm; - // static char buf[128]; - // sprintf(buf, "%s", info); - - // sendcmd("p[%d].b[%d].val=dp", pg_confirm, ob_confirm_frompage); - // sendcmd("p[%d].b[%d].txt=\"%s\"", pg_confirm, ob_confirm_info, buf); - // sendcmd("page confirm"); - // vis(ob_confirm_canclekey, 0); -} - -void UIControler::confirm(const char* info, function onConfirm) { - zlock_guard lg(m_cmdlock); - // if (m_isInPopWin) { - // ZLOGE(TAG, "isInPopWin,confirm failed"); - // return; - // } - - // m_onConfirmPageConfirmKey = onConfirm; - // static char buf[128]; - // sprintf(buf, "%s", info); - - // sendcmd("p[%d].b[%d].val=dp", pg_confirm, ob_confirm_frompage); - // sendcmd("p[%d].b[%d].txt=\"%s\"", pg_confirm, ob_confirm_info, buf); - // sendcmd("page confirm"); - // vis(ob_confirm_canclekey, 1); -} void UIControler::chpage(uint8_t page) { sendcmd("page %d", page); } // void UIControler::bakpage() { sendcmd("page %d", m_lastPage); } diff --git a/usrc/uicontroler/ui_controler.hpp b/usrc/uicontroler/ui_controler.hpp index 55ee63a..0c35637 100644 --- a/usrc/uicontroler/ui_controler.hpp +++ b/usrc/uicontroler/ui_controler.hpp @@ -4,6 +4,7 @@ #include "uappbase/base.hpp" // #include "tjc/tjc.hpp" +#include "uicontroler/base/ui_state.hpp" namespace iflytop { using namespace std; @@ -19,7 +20,7 @@ class UIControler { tjc_rx_packet_t ackcache; zmutex m_cmdlock = {"UI_LOCK"}; - tjc::UIEvent event_cache; + UIEvent event_cache; int32_t m_nowPage = 0; int32_t m_lastPage = 0; @@ -49,18 +50,20 @@ class UIControler { 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 + void popWin(UIPopWinType_t type, const char* info, function onConfirm); + void popWarningWin(const char* info) { popWin(UI_POP_WIN_TYPE_WARNING_INFO, info, nullptr); } + void popConfirmWin(const char* info, function onConfirm) { popWin(UI_POP_WIN_TYPE_CONFIRM, info, onConfirm); } + void popInfoWin(const char* info) { popWin(UI_POP_WIN_TYPE_INFO, info, nullptr); } - void alert(const char* info) { alert(info, nullptr); } - void alertNoConfirm(const char* info); - void alert(const char* info, function onConfirm); - void confirmNoCancle(const char* info) { confirmNoCancle(info, nullptr); } - void confirmNoCancle(const char* info, function onConfirm); - void confirm(const char* info, function onConfirm); + // void alertNoConfirm(const char* info); + // void alert(const char* info, function onConfirm); + // void confirmNoCancle(const char* info) { confirmNoCancle(info, nullptr); } + // void confirmNoCancle(const char* info, function onConfirm); + // void confirm(const char* info, function onConfirm); void chpage(uint8_t page); void setrtc(zdate_t* date); @@ -83,8 +86,7 @@ class UIControler { void processUsrDoubleStateButtonEvent(uint8_t* data, size_t len); void startReceiveAck(); - - void callUsrEventCb(tjc::UIEvent* event); + void callUsrEventCb(UIEvent* event); }; static inline const char* zitoa(int val) {