diff --git a/uappbase/service/config_index.cpp b/uappbase/service/config_index.cpp index 1973da7..16de9aa 100644 --- a/uappbase/service/config_index.cpp +++ b/uappbase/service/config_index.cpp @@ -13,7 +13,7 @@ static cfg_iterm_info_t cfg_iterm_infos[] = { CFG_ITERM(kusr_passwd0, kcfgt_str, USER_DEFAULT_PWD), // CFG_ITERM(kusr_name1, kcfgt_str, USER1_DEFAULT_NAME), // - CFG_ITERM(kusr_enable1, kcfgt_bool, "true"), // + CFG_ITERM(kusr_enable1, kcfgt_bool, "true"), // CFG_ITERM(kusr_passwd1, kcfgt_str, USER_DEFAULT_PWD), // CFG_ITERM(kusr_name2, kcfgt_str, USER2_DEFAULT_NAME), // @@ -79,9 +79,9 @@ static cfg_iterm_info_t cfg_iterm_infos[] = { * 其他配置 * ***********************************************************************************************************************/ CFG_ITERM(kcfg_lockAcidName, kcfgt_bool, "false"), // - CFG_ITERM(kcfg_echDitrUpLi, kcfgt_int32, "40"), // 每次分配上限设定值 each distri up-limit + CFG_ITERM(kcfg_echDitrUpLi, kcfgt_int32, "99"), // 每次分配上限设定值 each distri up-limit CFG_ITERM(kcfg_distrInterval, kcfgt_float, "1.5"), // 每次分配间隔时间 - CFG_ITERM(kcfg_pumpDefVel, kcfgt_int32, "800"), // + CFG_ITERM(kcfg_pumpDefVel, kcfgt_int32, "300"), // CFG_ITERM(kcfg_m0irun, kcfgt_int32, "20"), // CFG_ITERM(kcfg_m1irun, kcfgt_int32, "20"), // diff --git a/uappbase/service/config_service_utils.cpp b/uappbase/service/config_service_utils.cpp index 135d140..6dfaccf 100644 --- a/uappbase/service/config_service_utils.cpp +++ b/uappbase/service/config_service_utils.cpp @@ -1,21 +1,21 @@ #include "config_service_utils.hpp" namespace iflytop { -int32_t getMotorMLPR(int32_t motorid) { +float getMotorMLPR(int32_t motorid) { switch (motorid) { case 0: - return getCfgInt(kcfg_mLPR0); + return getCfgFloat(kcfg_mLPR0); case 1: - return getCfgInt(kcfg_mLPR1); + return getCfgFloat(kcfg_mLPR1); case 2: - return getCfgInt(kcfg_mLPR2); + return getCfgFloat(kcfg_mLPR2); case 3: - return getCfgInt(kcfg_mLPR3); + return getCfgFloat(kcfg_mLPR3); default: ZASSERT(0); return 0; } } -void setMotorMLPR(int motorid, int32_t val) { +void setMotorMLPR(int32_t motorid, float val) { // switch (motorid) { case 0: @@ -67,7 +67,9 @@ int32_t setMxIRun(int motorid, int32_t val) { break; default: ZASSERT(0); + return 0; } + return 0; } const char* getPasswd(const char* usrname, CfgItermCache* cache) { @@ -128,4 +130,4 @@ const void setPasswd(const char* usrname, const char* passwd) { } } -} // namespace iflytop \ No newline at end of file +} // namespace iflytop diff --git a/uappbase/service/config_service_utils.hpp b/uappbase/service/config_service_utils.hpp index 58b49dd..4ecd6c5 100644 --- a/uappbase/service/config_service_utils.hpp +++ b/uappbase/service/config_service_utils.hpp @@ -1,8 +1,10 @@ #pragma once #include "config_service.hpp" namespace iflytop { -int32_t getMotorMLPR(int32_t motorid); -void setMotorMLPR(int32_t motorid, int32_t val); +float getMotorMLPR(int32_t motorid); +void setMotorMLPR(int32_t motorid, float val); + + int32_t setMxIRun(int motorid, int32_t val); int32_t getMxIRun(int motorid); diff --git a/usrc/service/front_end_controler.hpp b/usrc/service/front_end_controler.hpp index 4d1e2fe..5b10f4a 100644 --- a/usrc/service/front_end_controler.hpp +++ b/usrc/service/front_end_controler.hpp @@ -61,6 +61,9 @@ class FrontEndControler { bool setVal(uint8_t pid, uint8_t bid, const char* txt, ...); bool setVal(uint8_t pid, uint8_t bid, int32_t val); + bool setVal(uint8_t bid, const char* txt) { return setVal(m_nowPage, bid, txt); } + bool setVal(uint8_t bid, int32_t val) { return setVal(m_nowPage, bid, val); } + // bool setVal(uint16_t buuid, const char* txt) { return setVal(buuid >> 8, buuid & 0xff, txt); } // bool setVal(uint16_t buuid, int32_t val) { return setVal(buuid >> 8, buuid & 0xff, val); } diff --git a/usrc/service/page/Page_main.cpp b/usrc/service/page/Page_main.cpp index eea40a4..2da475f 100644 --- a/usrc/service/page/Page_main.cpp +++ b/usrc/service/page/Page_main.cpp @@ -78,7 +78,7 @@ void Page_main::OnPageLoad(OnPageLoadContext*cxt) { UIS->setVal(PAGE, ob_main_acidch3, GSM->getPumpSelectState(3)); // 时间位置暂时显示版本号 - // UIS->setVal(PAGE, ob_main_clock, "", APP_VERSION); + UIS->setVal(PAGE, ob_main_clock, ""); // UIS->setVal(PAGE, ob_main_clock, "版本:%s", APP_VERSION); // 根据当前登录用户设置菜单页面 diff --git a/usrc/service/page/submenu/Page_muSettings.cpp b/usrc/service/page/submenu/Page_muSettings.cpp index 83fcdbe..549a496 100644 --- a/usrc/service/page/submenu/Page_muSettings.cpp +++ b/usrc/service/page/submenu/Page_muSettings.cpp @@ -12,31 +12,105 @@ static CfgItermCache cfgcache; bool Page_muSettings::isBelongThisPage(int page) { return page == PAGE; } -void Page_muSettings::OnPageLoad(OnPageLoadContext*cxt) { // +void Page_muSettings::updatePage() { UIS->setVal(PAGE, ob_muSettings_bleCliName, "testData"); - UIS->setVal(PAGE, ob_muSettings_irun0, "1"); - UIS->setVal(PAGE, ob_muSettings_irun1, "1"); - UIS->setVal(PAGE, ob_muSettings_irun2, "1"); - UIS->setVal(PAGE, ob_muSettings_irun3, "1"); - UIS->setVal(PAGE, ob_muSettings_pumpCoef0, "1"); - UIS->setVal(PAGE, ob_muSettings_pumpCoef1, "1"); - UIS->setVal(PAGE, ob_muSettings_pumpCoef2, "1"); - UIS->setVal(PAGE, ob_muSettings_pumpCoef3, "1"); - UIS->setVal(PAGE, ob_muSettings_pipeLen0, "1"); - UIS->setVal(PAGE, ob_muSettings_pipeLen1, "1"); - UIS->setVal(PAGE, ob_muSettings_pipeLen2, "1"); - UIS->setVal(PAGE, ob_muSettings_pipeLen3, "1"); - UIS->setVal(PAGE, ob_muSettings_addAcidVel, "1"); + UIS->setVal(PAGE, ob_muSettings_irun0, zitoa(getMxIRun(0))); + UIS->setVal(PAGE, ob_muSettings_irun1, zitoa(getMxIRun(1))); + UIS->setVal(PAGE, ob_muSettings_irun2, zitoa(getMxIRun(2))); + UIS->setVal(PAGE, ob_muSettings_irun3, zitoa(getMxIRun(3))); + UIS->setVal(PAGE, ob_muSettings_pumpCoef0, zfmt("%.1f", getMotorMLPR(0))); + UIS->setVal(PAGE, ob_muSettings_pumpCoef1, zfmt("%.1f", getMotorMLPR(1))); + UIS->setVal(PAGE, ob_muSettings_pumpCoef2, zfmt("%.1f", getMotorMLPR(2))); + UIS->setVal(PAGE, ob_muSettings_pumpCoef3, zfmt("%.1f", getMotorMLPR(3))); + UIS->setVal(PAGE, ob_muSettings_pipeLen0, getCfgStr(kcfg_pipeLengthML)); + UIS->setVal(PAGE, ob_muSettings_pipeLen1, getCfgStr(kcfg_pipeLengthML)); + UIS->setVal(PAGE, ob_muSettings_pipeLen2, getCfgStr(kcfg_pipeLengthML)); + UIS->setVal(PAGE, ob_muSettings_pipeLen3, getCfgStr(kcfg_pipeLengthML)); + UIS->setVal(PAGE, ob_muSettings_addAcidVel, getCfgStr(kcfg_pumpDefVel)); +} + +void Page_muSettings::OnPageLoad(OnPageLoadContext* cxt) { // + updatePage(); }; -void Page_muSettings::OnInputFieldContentChange(uint8_t bid, const char* text) { UIS->setVal(PAGE, bid, text); } +void Page_muSettings::OnInputFieldContentChange(uint8_t bid, const char* text) { + /*********************************************************************************************************************** + * irunx * + ***********************************************************************************************************************/ + if (bid == ob_muSettings_irun0) { + setMxIRun(0, atoi(text)); + UIS->setVal(bid, getMxIRun(0)); + } else if (bid == ob_muSettings_irun1) { + setMxIRun(1, atoi(text)); + UIS->setVal(bid, getMxIRun(1)); + } else if (bid == ob_muSettings_irun2) { + setMxIRun(2, atoi(text)); + UIS->setVal(bid, getMxIRun(2)); + } else if (bid == ob_muSettings_irun3) { + setMxIRun(3, atoi(text)); + UIS->setVal(bid, getMxIRun(3)); + } + + /*********************************************************************************************************************** + * pumpCoef * + ***********************************************************************************************************************/ + + else if (bid == ob_muSettings_pumpCoef0) { + setMotorMLPR(0, atof(text)); + UIS->setVal(bid, zfmt("%.1f", getMotorMLPR(0))); + } else if (bid == ob_muSettings_pumpCoef1) { + setMotorMLPR(1, atof(text)); + UIS->setVal(bid, zfmt("%.1f", getMotorMLPR(1))); + } else if (bid == ob_muSettings_pumpCoef2) { + setMotorMLPR(2, atof(text)); + UIS->setVal(bid, zfmt("%.1f", getMotorMLPR(2))); + } else if (bid == ob_muSettings_pumpCoef3) { + setMotorMLPR(3, atof(text)); + UIS->setVal(bid, zfmt("%.1f", getMotorMLPR(3))); + } + + /*********************************************************************************************************************** + * pipeLen * + ***********************************************************************************************************************/ + + else if (bid == ob_muSettings_pipeLen0) { + CS->setcfg(kcfg_pipeLengthML, text); + UIS->setVal(bid, getCfgStr(kcfg_pipeLengthML)); + } + + else if (bid == ob_muSettings_pipeLen1) { + CS->setcfg(kcfg_pipeLengthML, text); + UIS->setVal(bid, getCfgStr(kcfg_pipeLengthML)); + } + + else if (bid == ob_muSettings_pipeLen2) { + CS->setcfg(kcfg_pipeLengthML, text); + UIS->setVal(bid, getCfgStr(kcfg_pipeLengthML)); + } + + else if (bid == ob_muSettings_pipeLen3) { + CS->setcfg(kcfg_pipeLengthML, text); + UIS->setVal(bid, getCfgStr(kcfg_pipeLengthML)); + } + + /*********************************************************************************************************************** + * addAcidVel * + ***********************************************************************************************************************/ + + else if (bid == ob_muSettings_addAcidVel) { + CS->setcfg(kcfg_pumpDefVel, text); + UIS->setVal(bid, getCfgStr(kcfg_pumpDefVel)); + } + + updatePage(); +} void Page_muSettings::OnButton(uint8_t bid, uint8_t val) { static CfgItermCache usrpasswdcache; ZLOGI(TAG, "bid:%d", bid); - if (bid == ob_muSettings_bleScan) { - ZLOGI(TAG, "bleScan"); - } else if (bid == ob_muSettings_bak) { + if (bid == ob_muSettings_bak) { UIS->chpage(GSM->getMenuPage()); + } else if (bid == ob_muSettings_bleScan) { + ZLOGI(TAG, "bleScan"); } }; diff --git a/usrc/service/page/submenu/Page_muSettings.hpp b/usrc/service/page/submenu/Page_muSettings.hpp index bfbc1e1..7e6a286 100644 --- a/usrc/service/page/submenu/Page_muSettings.hpp +++ b/usrc/service/page/submenu/Page_muSettings.hpp @@ -22,6 +22,7 @@ class Page_muSettings : public IPageProcesser { virtual void OnButton(uint8_t bid, uint8_t val) override; private: + void updatePage(); }; } // namespace iflytop diff --git a/usrc/service/pump_ctrl_service.cpp b/usrc/service/pump_ctrl_service.cpp index f3dd79d..26c0134 100644 --- a/usrc/service/pump_ctrl_service.cpp +++ b/usrc/service/pump_ctrl_service.cpp @@ -12,6 +12,14 @@ static TMC51X0* m_motors[4]; static CfgItermCache cfgcache; #define APPEND_ML 1 +static int getMxRunRPM(int32_t mid) { // + float mLPmin = getCfgFloat(kcfg_pumpDefVel); + float motorX_mLPR = getMotorMLPR(mid); + + int rpm = mLPmin / motorX_mLPR; + return rpm; +} + void PumpCtrlService::initialize() { m_motors[0] = AppHardware::ins()->getPump(0); m_motors[1] = AppHardware::ins()->getPump(1); @@ -73,6 +81,8 @@ void PumpCtrlService::stop() { ZLOGI(TAG, "stop finish"); } + + /*********************************************************************************************************************** * EXT * ***********************************************************************************************************************/ @@ -82,31 +92,28 @@ void PumpCtrlService::reflux() { m_thread.start( [this]() { - ValveStateSyncService::ins()->setValveState(1); - int32_t pipeLenML = getCfgInt(kcfg_pipeLengthML); - int32_t vel = getCfgInt(config_index_t(kcfg_pumpDefVel)); - - for (size_t i = 0; i < PUMP_NUM; i++) { - TMC51X0* cur_motor = m_motors[i]; - cur_motor->stop(); - cur_motor->setXACTUAL(0); - ZLOGI(TAG, "pump %d move %f ml", i, -pipeLenML); - cur_motor->moveBy((int32_t)-pipeLenML * 1000, vel); - } - - while (!m_thread.getExitFlag()) { - if (isAllReachTarget()) { - break; - } - osDelay(10); + ValveStateSyncService::ins()->setValveState(1); + int32_t pipeLenML = getCfgInt(kcfg_pipeLengthML); + + for (size_t i = 0; i < PUMP_NUM; i++) { + TMC51X0* cur_motor = m_motors[i]; + cur_motor->stop(); + cur_motor->setXACTUAL(0); + ZLOGI(TAG, "pump %d move %f ml", i, -pipeLenML); + cur_motor->moveBy((int32_t)-pipeLenML * 1000, getMxRunRPM(i)); + } + + while (!m_thread.getExitFlag()) { + if (isAllReachTarget()) { + break; + } + osDelay(10); } stopAll(); ZLOGI(TAG, "reflux end"); }, - []() { - ValveStateSyncService::ins()->setValveState(0); - }); + []() { ValveStateSyncService::ins()->setValveState(0); }); } void PumpCtrlService::acidPrefilling() { ZLOGI(TAG, "acidPrefilling"); @@ -117,14 +124,13 @@ void PumpCtrlService::acidPrefilling() { ValveStateSyncService::ins()->setValveState(1); int32_t pipeLenML = getCfgInt(kcfg_pipeLengthML); - int32_t vel = getCfgInt(config_index_t(kcfg_pumpDefVel)); for (size_t i = 0; i < PUMP_NUM; i++) { TMC51X0* cur_motor = m_motors[i]; cur_motor->stop(); cur_motor->setXACTUAL(0); ZLOGI(TAG, "pump %d move %f ml", i, pipeLenML); - cur_motor->moveBy((int32_t)pipeLenML * 1000, vel); + cur_motor->moveBy((int32_t)pipeLenML * 1000, getMxRunRPM(i)); } while (!m_thread.getExitFlag()) { @@ -136,9 +142,8 @@ void PumpCtrlService::acidPrefilling() { // 短回流 for (size_t i = 0; i < PUMP_NUM; i++) { - int32_t vel = getCfgInt(kcfg_pumpDefVel); TMC51X0* cur_motor = m_motors[i]; - cur_motor->moveBy(-(int32_t)(APPEND_ML) * 1000, vel); + cur_motor->moveBy(-(int32_t)(APPEND_ML) * 1000, getMxRunRPM(i)); } while (!isAllReachTarget()) { @@ -195,14 +200,13 @@ void PumpCtrlService::doMoveOnce() { for (size_t i = 0; i < PUMP_NUM; i++) { bool pumpselect = GSM->getPumpSelectState(i); float distribut_ml = getCfgFloat(config_index_t(kcfg_acideval0 + i)); - int32_t vel = getCfgInt(kcfg_pumpDefVel); TMC51X0* cur_motor = m_motors[i]; cur_motor->stop(); cur_motor->setXACTUAL(0); if (pumpselect) { ZLOGI(TAG, "pump %d move %f ml", i, distribut_ml); - cur_motor->moveBy((int32_t)(distribut_ml + APPEND_ML) * 1000, vel); + cur_motor->moveBy((int32_t)(distribut_ml + APPEND_ML) * 1000, getMxRunRPM(i)); } } @@ -213,13 +217,12 @@ void PumpCtrlService::doMoveOnce() { // 回流 for (size_t i = 0; i < PUMP_NUM; i++) { bool pumpselect = GSM->getPumpSelectState(i); - int32_t vel = getCfgInt(kcfg_pumpDefVel); TMC51X0* cur_motor = m_motors[i]; cur_motor->stop(); cur_motor->setXACTUAL(0); if (pumpselect) { - cur_motor->moveBy(-(int32_t)(APPEND_ML) * 1000, vel); + cur_motor->moveBy(-(int32_t)(APPEND_ML) * 1000, getMxRunRPM(i)); } } diff --git a/usrc/service/remote_controler_event_processer.cpp b/usrc/service/remote_controler_event_processer.cpp index 00f63a1..a5f3936 100644 --- a/usrc/service/remote_controler_event_processer.cpp +++ b/usrc/service/remote_controler_event_processer.cpp @@ -87,9 +87,13 @@ void RemoteControlerEventProcesser::processKeyEventFromRemoter(hand_acid_remoter ZLOGW(TAG, "now page is in pump test, remote key event process by pumpTestPage"); return; } + if (UIS->getNowPage() == pg_login || UIS->getNowPage() == pg_pStart) { + return; + } if (UIS->getNowPage() != pg_main) { - UIS->chpage(pg_main); + UIS->alert("请先切换到首页,在控制泵机"); + return; } if (PUMPCS->isWorking()) {