diff --git a/ui/ui.h b/ui/ui.h index 1aef458..eab727c 100644 --- a/ui/ui.h +++ b/ui/ui.h @@ -140,49 +140,50 @@ #define ob_muInterval_bak 5 //muUsrMgr.objs #define ob_muUsrMgr_muUsrMgr 0 -#define ob_muUsrMgr_uName0 1 -#define ob_muUsrMgr_uName1 2 -#define ob_muUsrMgr_uName2 3 -#define ob_muUsrMgr_uName3 4 -#define ob_muUsrMgr_uName4 5 -#define ob_muUsrMgr_uName5 6 -#define ob_muUsrMgr_OperaCol 7 -#define ob_muUsrMgr_cfg0 8 -#define ob_muUsrMgr_cfg1 9 -#define ob_muUsrMgr_cfg2 10 -#define ob_muUsrMgr_cfg3 11 -#define ob_muUsrMgr_cfg4 12 -#define ob_muUsrMgr_title 13 -#define ob_muUsrMgr_bak 14 -#define ob_muUsrMgr_t1 15 -#define ob_muUsrMgr_t0 16 -#define ob_muUsrMgr_index0 17 -#define ob_muUsrMgr_index1 18 -#define ob_muUsrMgr_index2 19 -#define ob_muUsrMgr_index3 20 -#define ob_muUsrMgr_index4 21 -#define ob_muUsrMgr_index5 22 -#define ob_muUsrMgr_cfg5 23 -#define ob_muUsrMgr_uName6 24 -#define ob_muUsrMgr_uName7 25 -#define ob_muUsrMgr_cfg6 26 -#define ob_muUsrMgr_index6 27 -#define ob_muUsrMgr_index7 28 -#define ob_muUsrMgr_cfg7 29 -#define ob_muUsrMgr_new 30 -#define ob_muUsrMgr_index 31 -#define ob_muUsrMgr_usrName 32 -#define ob_muUsrMgr_role 33 -#define ob_muUsrMgr_passwd 34 -#define ob_muUsrMgr_indexVal 35 -#define ob_muUsrMgr_usrNameVal 36 -#define ob_muUsrMgr_roleVal 37 -#define ob_muUsrMgr_del 38 -#define ob_muUsrMgr_save 39 -#define ob_muUsrMgr_isEdited 40 -#define ob_muUsrMgr_passwdRest 41 +#define ob_muUsrMgr_passwdRest 1 +#define ob_muUsrMgr_uName0 2 +#define ob_muUsrMgr_uName1 3 +#define ob_muUsrMgr_uName2 4 +#define ob_muUsrMgr_uName3 5 +#define ob_muUsrMgr_uName4 6 +#define ob_muUsrMgr_uName5 7 +#define ob_muUsrMgr_OperaCol 8 +#define ob_muUsrMgr_cfg0 9 +#define ob_muUsrMgr_cfg1 10 +#define ob_muUsrMgr_cfg2 11 +#define ob_muUsrMgr_cfg3 12 +#define ob_muUsrMgr_cfg4 13 +#define ob_muUsrMgr_title 14 +#define ob_muUsrMgr_bak 15 +#define ob_muUsrMgr_t1 16 +#define ob_muUsrMgr_t0 17 +#define ob_muUsrMgr_index0 18 +#define ob_muUsrMgr_index1 19 +#define ob_muUsrMgr_index2 20 +#define ob_muUsrMgr_index3 21 +#define ob_muUsrMgr_index4 22 +#define ob_muUsrMgr_index5 23 +#define ob_muUsrMgr_cfg5 24 +#define ob_muUsrMgr_uName6 25 +#define ob_muUsrMgr_uName7 26 +#define ob_muUsrMgr_cfg6 27 +#define ob_muUsrMgr_index6 28 +#define ob_muUsrMgr_index7 29 +#define ob_muUsrMgr_cfg7 30 +#define ob_muUsrMgr_new 31 +#define ob_muUsrMgr_index 32 +#define ob_muUsrMgr_usrName 33 +#define ob_muUsrMgr_role 34 +#define ob_muUsrMgr_passwd 35 +#define ob_muUsrMgr_indexVal 36 +#define ob_muUsrMgr_usrNameVal 37 +#define ob_muUsrMgr_roleVal 38 +#define ob_muUsrMgr_del 39 +#define ob_muUsrMgr_save 40 +#define ob_muUsrMgr_isEdited 41 #define ob_muUsrMgr_editAreaMask 42 #define ob_muUsrMgr_editAreaLable 43 +#define ob_muUsrMgr_passwdInfo 44 //muDateMgr.objs #define ob_muDateMgr_muDateMgr 0 #define ob_muDateMgr_year 1 diff --git a/usrc/service/app_core.cpp b/usrc/service/app_core.cpp index 6f85b7d..3fa8c94 100644 --- a/usrc/service/app_core.cpp +++ b/usrc/service/app_core.cpp @@ -108,12 +108,12 @@ void AppCore::initialize() { UIControler::ins()->initialize(); - UIControler::ins()->chpage(pg_navi); + UIControler::ins()->chpage(pg_muUsrMgr); osDelay(1000); - UIControler::ins()->popWarningWin("警告!!!!!!!"); - UIControler::ins()->popConfirmWin("消息确认!!!!!!!", [](bool val) { ZLOGI(TAG, "confirm val %d", val); }); - UIControler::ins()->popInfoWin("消息确认!!!!!!!"); + // 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/uicontroler/base/page_processer.cpp b/usrc/uicontroler/base/page_processer.cpp index b7fa19a..f0975eb 100644 --- a/usrc/uicontroler/base/page_processer.cpp +++ b/usrc/uicontroler/base/page_processer.cpp @@ -49,9 +49,24 @@ void IPageProcesser::initialize() { namespace iflytop { void UIControlerHock_PageInit() { + // onlyInitThis + bool hasOnlyInitThis = false; + for (size_t i = 0; i < m_pageNum; i++) { + if (m_pages[i]->onlyInitThis) { + hasOnlyInitThis = true; + break; + } + } + for (size_t i = 0; i < m_pageNum; i++) { // ZLOGI(TAG, "initialize page %s %d", m_pages[i]->pageName, m_pages[i]->pageId); - m_pages[i]->initialize(); + if (hasOnlyInitThis) { + if (m_pages[i]->onlyInitThis) { + m_pages[i]->initialize(); + } + } else { + m_pages[i]->initialize(); + } } } } // namespace iflytop diff --git a/usrc/uicontroler/base/page_processer.hpp b/usrc/uicontroler/base/page_processer.hpp index 3f54bdc..4a01587 100644 --- a/usrc/uicontroler/base/page_processer.hpp +++ b/usrc/uicontroler/base/page_processer.hpp @@ -22,8 +22,9 @@ class OnPageLoadContext { class IPageProcesser { public: - uint32_t pageId = 0; - const char* pageName = "Not Set"; + uint32_t pageId = 0; + const char* pageName = "Not Set"; + bool onlyInitThis = false; // for debug public: IPageProcesser(const char* name, uint32_t pageId); diff --git a/usrc/uicontroler/page/mupage/muUsrMgr_page.cpp b/usrc/uicontroler/page/mupage/muUsrMgr_page.cpp index 019fb35..b0e8393 100644 --- a/usrc/uicontroler/page/mupage/muUsrMgr_page.cpp +++ b/usrc/uicontroler/page/mupage/muUsrMgr_page.cpp @@ -55,22 +55,27 @@ static EditContext_t m_editContext = {false, -1, "", UserRole::user, false, fals class MuUsrMgr : public IPageProcesser { private: public: - MuUsrMgr() : IPageProcesser(TAG, pg_muUsrMgr) {} + MuUsrMgr() : IPageProcesser(TAG, pg_muUsrMgr) { onlyInitThis = true; } virtual void initialize() override { IPageProcesser::initialize(); + + // visEx(ob_muUsrMgr_save, false); + // 初始化状态信息 fillUsrStateUICache(); + syncUIUsrTableState(); + fillEditContext(-1); + syncEditContext(); - // 填充部分UI组件内容 + // // 填充部分UI组件内容 UIControler::ins()->sendcmd("p[%d].b[%d].path=%s/%s/%s", pageId, ob_muUsrMgr_roleVal, // UserRole::admin.chName, // UserRole::storekeeper.chName, // UserRole::user.chName); // 同步UI状态 syncUIUsrTableState(); - syncEditContext(); } private: @@ -248,6 +253,7 @@ class MuUsrMgr : public IPageProcesser { for (int i = 0; i < MAX_USR_NUM; i++) { if (i >= numUser) { m_uiUsrTable[i].enable = false; + continue; } user_t* user = &users[i]; @@ -255,26 +261,10 @@ class MuUsrMgr : public IPageProcesser { m_uiUsrTable[i].role = UserRole::of(user->role); m_uiUsrTable[i].enable = true; m_uiUsrTable[i].usrId = user->id; + m_uiUsrTable[i].index = i; } } - void fillEditContext(int index) { - if (index >= MAX_USR_NUM) { - return; - } - if (index < -1) { - m_editContext.enable = false; - return; - } - - m_editContext.index = index; - strcpy(m_editContext.name, m_uiUsrTable[index].userName); - m_editContext.role = m_uiUsrTable[index].role; - m_editContext.resetPasswd = false; - m_editContext.editDirty = false; - m_editContext.enable = true; - } - /** * @brief 同步用户表状态 * @@ -296,11 +286,29 @@ class MuUsrMgr : public IPageProcesser { } setText(item->userNameBid, "%s", item->userName); - setVal(item->indexBid, item->index); + setText(item->indexBid, "%d", item->index); + visEx(item->userNameBid, true); - visEx(item->cfgButtonBid, true); - visEx(item->indexBid, i != 0 ? true : false); // 用户0为内置管理员用户,不允许修改 + visEx(item->indexBid, true); + visEx(item->cfgButtonBid, i != 0 ? true : false); // 用户0为内置管理员用户,不允许修改 + } + } + + void fillEditContext(int index) { + if (index >= MAX_USR_NUM) { + return; + } + if (index < 0) { + m_editContext.enable = false; + return; } + + m_editContext.index = index; + strcpy(m_editContext.name, m_uiUsrTable[index].userName); + m_editContext.role = m_uiUsrTable[index].role; + m_editContext.resetPasswd = false; + m_editContext.editDirty = false; + m_editContext.enable = true; } /** @@ -312,17 +320,18 @@ class MuUsrMgr : public IPageProcesser { setText(ob_muUsrMgr_usrNameVal, "%s", m_editContext.name); setVal(ob_muUsrMgr_roleVal, m_editContext.role.val); setPicturePicNumFG(ob_muUsrMgr_passwdRest, m_editContext.resetPasswd ? ob_gvar_stateSwitch1 : ob_gvar_stateSwitch0); + setPicturePicNumFG(ob_muUsrMgr_isEdited, m_editContext.editDirty ? ob_gvar_editDirty : ob_gvar_edit); + visEx(ob_muUsrMgr_save, true); visEx(ob_muUsrMgr_del, true); - setPicturePicNumFG(ob_muUsrMgr_isEdited, m_editContext.editDirty ? ob_gvar_editDirty : ob_gvar_edit); } else { setText(ob_muUsrMgr_indexVal, ""); setText(ob_muUsrMgr_usrNameVal, ""); setText(ob_muUsrMgr_roleVal, ""); - visEx(ob_muUsrMgr_passwdRest, false); + setPicturePicNumFG(ob_muUsrMgr_isEdited, ob_gvar_edit); + visEx(ob_muUsrMgr_save, false); visEx(ob_muUsrMgr_del, false); - visEx(ob_muUsrMgr_isEdited, false); } } }; diff --git a/usrc/uicontroler/tjc_event_processer_mgr.cpp b/usrc/uicontroler/tjc_event_processer_mgr.cpp index b425e31..804ab93 100644 --- a/usrc/uicontroler/tjc_event_processer_mgr.cpp +++ b/usrc/uicontroler/tjc_event_processer_mgr.cpp @@ -1,7 +1,9 @@ #include "tjc_event_processer_mgr.hpp" // +#include "event_proceesser/button_event_processer.hpp" #include "event_proceesser/inputfield_content_change_event_processer.hpp" #include "event_proceesser/page_back_event_processer.hpp" +#include "event_proceesser/sys_event_page_id_processer.hpp" #include "event_proceesser/usr_def_clik_release_with_val_event_processer.hpp" using namespace iflytop; @@ -12,11 +14,15 @@ using namespace iflytop; static UsrDefClikReleaseWithValEventProcesser usrDefClikReleaseWithValEventProcesser; static InputFieldContentChangeEventProcesser inputFieldContentChangeEventProcesser; static PageBackEventProcesser pageBackEventProcesser; +static SysEventPageIdProcesser sysEventPageIdProcesser; +static ButtonEventProcesser buttonEventProcesser; static iTjcUiEventProcesser* m_eventProcessers[] = { - &usrDefClikReleaseWithValEventProcesser, - &inputFieldContentChangeEventProcesser, - &pageBackEventProcesser, + &usrDefClikReleaseWithValEventProcesser, // + &inputFieldContentChangeEventProcesser, // + &pageBackEventProcesser, // + &sysEventPageIdProcesser, // + &buttonEventProcesser, // }; /*********************************************************************************************************************** diff --git a/usrc/uicontroler/ui_controler.cpp b/usrc/uicontroler/ui_controler.cpp index b462c45..e8cf2e4 100644 --- a/usrc/uicontroler/ui_controler.cpp +++ b/usrc/uicontroler/ui_controler.cpp @@ -55,7 +55,7 @@ void UIControler::initialize() { // UIPublicState::initialize(); m_cmdlock.init(); -startSchedule(); + startSchedule(); UIControlerHock_PageInit(); } @@ -195,7 +195,7 @@ bool UIControler::_readFiledAsInt(uint8_t pid, uint8_t bid, const char* filedNam startReceiveAck(); sendcmd("com_stop"); sendcmd("printh AA"); - sendcmd("prints p[%d].b[%d].%s,4", pid, filedName, bid); + sendcmd("prints p[%d].b[%d].%s,4", pid, bid, filedName); sendcmd("printh FF FF FF"); sendcmd("com_start"); @@ -315,6 +315,8 @@ void UIControler::sendcmd(const char* format, va_list args) { static char buf[128]; vsprintf(buf, format, args); + ZLOGI(TAG, "tx:%s", buf); + uint8_t len = strlen(buf); if (len > (128 - 3)) { ZLOGI(TAG, "sendcmd too long"); diff --git a/usrc/uicontroler/ui_state_mgr.cpp b/usrc/uicontroler/ui_state_mgr.cpp index c1b348d..170f972 100644 --- a/usrc/uicontroler/ui_state_mgr.cpp +++ b/usrc/uicontroler/ui_state_mgr.cpp @@ -3,7 +3,7 @@ using namespace iflytop; static component_info_t component_info[100] = {0}; -component_info_t* UIStateMgr::findComponent(uint8_t pid, uint16_t bid) { +component_info_t* UIStateMgr::findComponent(uint8_t pid, uint16_t bid) { for (int i = 0; i < 100; i++) { if (component_info[i].isUsed && component_info[i].pid == pid && component_info[i].bid == bid) { return &component_info[i]; @@ -16,6 +16,7 @@ component_info_t* UIStateMgr::allocComponent(uint8_t pid, uint16_t bid) { for (int i = 0; i < 100; i++) { if (!component_info[i].isUsed) { component_info[i].isUsed = true; + component_info[i].isVis = true; component_info[i].pid = pid; component_info[i].bid = bid; return &component_info[i];