From 7469fcd96ee30bf9220ebf82d1205d61b2e883c5 Mon Sep 17 00:00:00 2001 From: xue <2144439972@qq.com> Date: Mon, 16 Jun 2025 12:24:01 +0800 Subject: [PATCH] =?utf8?q?1.=E6=A0=A1=E5=87=86=E7=95=8C=E9=9D=A2=EF=BC=8C?= =?utf8?q?=E8=BE=93=E5=85=A5=E8=A1=80=E5=8E=8B=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../wearable/fd230app/CMakeLists.txt | 1 + .../nativelauncher/src/NativeLauncher.cpp | 2 +- .../bloodpressure/include/BPMainView.h | 4 + .../nativeui/bloodpressure/include/BPModel.h | 5 + .../include/BPUnderCalibrationView.h | 2 + .../bloodpressure/include/BPValueView.h | 46 ++++ .../bloodpressure/src/BPCalibrationView.cpp | 2 +- .../bloodpressure/src/BPMainPresenter.cpp | 35 +++ .../nativeui/bloodpressure/src/BPMainView.cpp | 30 +++ .../nativeui/bloodpressure/src/BPModel.cpp | 91 +++++++ .../src/BPUnderCalibrationView.cpp | 20 +- .../bloodpressure/src/BPValueView.cpp | 244 ++++++++++++++++++ .../brandy/mk_fs_image/w9/file.bin | 4 +- .../brandy/mk_fs_image/w9/file_tmp.bin | 4 +- .../w9/fs/user/res/BPCalibration/D.bin | 3 - .../w9/fs/user/res/BPCalibration/J1.bin | 3 + .../w9/fs/user/res/BPCalibration/J2.bin | 3 + .../w9/fs/user/res/BPCalibration/J3.bin | 3 + .../w9/fs/user/res/BPCalibration/Q.bin | 3 - .../w9/fs/user/res/BPCalibration/W.bin | 3 - ...beijing.bin => calibration_background.bin} | 0 .../{Y.bin => calibration_remind.bin} | 0 .../{R.bin => decrease_button.bin} | 0 .../res/BPCalibration/{E.bin => error.bin} | 0 .../{R1.bin => increase_button.bin} | 0 .../fs/user/res/BPCalibration/measuring.bin | 3 + .../res/BPCalibration/{B.bin => posture.bin} | 0 .../res/BPCalibration/{E-1.bin => right.bin} | 0 .../res/BPCalibration/{C.bin => warning.bin} | 0 29 files changed, 493 insertions(+), 18 deletions(-) create mode 100644 code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPValueView.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPValueView.cpp delete mode 100644 code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/D.bin create mode 100644 code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/J1.bin create mode 100644 code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/J2.bin create mode 100644 code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/J3.bin delete mode 100644 code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/Q.bin delete mode 100644 code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/W.bin rename code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/{bp_beijing.bin => calibration_background.bin} (100%) rename code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/{Y.bin => calibration_remind.bin} (100%) rename code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/{R.bin => decrease_button.bin} (100%) rename code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/{E.bin => error.bin} (100%) rename code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/{R1.bin => increase_button.bin} (100%) create mode 100644 code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/measuring.bin rename code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/{B.bin => posture.bin} (100%) rename code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/{E-1.bin => right.bin} (100%) rename code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/{C.bin => warning.bin} (100%) diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index a3b1abdf8..fbe7e9b64 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -227,6 +227,7 @@ set(SOURCES #BloodPressure ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodpressure/src/BPCalibrationView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodpressure/src/BPUnderCalibrationView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodpressure/src/BPValueView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodpressure/src/BPMainView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodpressure/src/BPMainPresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodpressure/src/BPModel.cpp diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp index ed405c8a0..84c8c5c5b 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp @@ -111,7 +111,7 @@ /*血压校准*/ #include "bloodpressure/include/BPMainView.h" #include "bloodpressure/include/BPMainPresenter.h" -/*血压校准*/ +/*血压检测*/ #include "bloodpressure/include/BPDetectionPresenter.h" #include "bloodpressure/include/BPDetectionView.h" /*心率监测*/ diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPMainView.h b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPMainView.h index 51bfc1ab4..4e17b0eec 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPMainView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPMainView.h @@ -8,12 +8,14 @@ #include "components/ui_view_group.h" #include "bloodpressure/include/BPCalibrationView.h" #include "bloodpressure/include/BPUnderCalibrationView.h" +#include "bloodpressure/include/BPValueView.h" namespace OHOS { typedef enum : uint8_t { BPCALIBRATIONVIEW = 0, // 主界面 BPUNDERCALIBRATIONVIEW, // BP校准界面 + BPVALUEVIEW, // 血压输入界面 MAX_BPVIEW, } BPVIEWID; @@ -31,6 +33,7 @@ namespace OHOS bool ChangeBPCalibrationView(int16_t); bool ChangeBPUnderCalibrationView(int16_t); + bool ChangeBPValueView(int16_t); bool ClickFunc(int16_t interface); void ChangeView(int16_t hideView, int16_t showView); @@ -38,6 +41,7 @@ namespace OHOS private: BPCalibrationView *p_BPCalibrationView{nullptr}; BPUnderCalibrationView *p_BPUnderCalibrationView{nullptr}; + BPValueView *g_pBPValueView{nullptr}; private: void DeInit(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPModel.h b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPModel.h index 5f0f91033..0e10aab50 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPModel.h @@ -61,6 +61,11 @@ namespace OHOS void ClearDisplayData(); void CleanAllData(); + // 定时器管理 + void BP_StartTimer(uint32_t interval = 1000); + void BP_StopTimer(void); + + private: uint16_t displayspo2; uint16_t currentspo2; diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPUnderCalibrationView.h b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPUnderCalibrationView.h index 1c8478c7b..06142c648 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPUnderCalibrationView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPUnderCalibrationView.h @@ -24,6 +24,8 @@ namespace OHOS bool InitLable(); bool Initbackground(); + + void UpSPO2Text(void); private: diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPValueView.h b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPValueView.h new file mode 100644 index 000000000..7c45eff8b --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPValueView.h @@ -0,0 +1,46 @@ + +#ifndef BP_VALUE_VIEW_H +#define BP_VALUE_VIEW_H + +#include "components/ui_label.h" +#include "components/ui_label_ext.h" +#include "components/ui_button.h" +#include "components/ui_label_button.h" +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label_button_ext.h" +namespace OHOS +{ + + class BPValueView + { + public: + BPValueView(); + ~BPValueView(); + static BPValueView *GetInstance(); + UIViewGroup * BPValueInit(); + void DeInit(); + bool AddButton(); + bool InitLable(); + bool Initbackground(); + static int16_t SBP; + static int16_t DBP; + + void UpSPO2Text(void); + + private: + UIImageView *background = nullptr; + UILabelExt *titleLabel = nullptr; + UILabelExt *SBPLabel = nullptr; + UILabelExt *DBPLabel = nullptr; + UILabelButton *valuecheckButton{nullptr}; + UIImageView *SBPLeft{nullptr}; + UIImageView *SBPRight{nullptr}; + UIImageView *DBPLeft{nullptr}; + UIImageView *DBPRight{nullptr}; + + UIViewGroup *group{nullptr}; + }; +} + +#endif // 血压主界面 \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPCalibrationView.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPCalibrationView.cpp index c8b515662..dfef0246c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPCalibrationView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPCalibrationView.cpp @@ -14,7 +14,7 @@ namespace OHOS { static BPCalibrationView *g_pBPCalibrationView{nullptr}; - static const char *BPBACKPATH = "/user/res/BP/bp_beijing.bin"; + static const char *BPBACKPATH = "/user/res/BPCalibration/calibration_background.bin"; BPCalibrationView::BPCalibrationView() { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BPCalibrationView::BPCalibrationView"); diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPMainPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPMainPresenter.cpp index cdec01d49..219d87d26 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPMainPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPMainPresenter.cpp @@ -10,6 +10,7 @@ #include "BPModel.h" #include "bloodpressure/include/BPDetectionView.h" +#include "bloodpressure/include/BPUnderCalibrationView.h" #include "bloodpressure/include/BPMainView.h" #include "components/ui_label.h" @@ -140,6 +141,40 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CLICK_BP"); BPMainView::GetInstance()->ChangeView(BPCALIBRATIONVIEW,BPUNDERCALIBRATIONVIEW); + } + if (strcmp(view.GetViewId(), "value_check") == 0) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "value_check"); + + + } + if (strcmp(view.GetViewId(), "SBPLeft") == 0) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SBPLeft_BP"); + + BPValueView::SBP--; + + } + if (strcmp(view.GetViewId(),"SBPRight") == 0) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SBPRight"); + + BPValueView::SBP++; + + } + if (strcmp(view.GetViewId(),"DBPLeft") == 0) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DBPLeft"); + + BPValueView::DBP--; + + } + if (strcmp(view.GetViewId(),"DBPRight") == 0) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DBPRight"); + + BPValueView::DBP++; + } WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BPPresenter::OnClick"); return true; diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPMainView.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPMainView.cpp index 8c3948e04..77a2656ee 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPMainView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPMainView.cpp @@ -51,6 +51,16 @@ namespace OHOS delete p_BPCalibrationView; p_BPCalibrationView = nullptr; } + if (p_BPUnderCalibrationView) + { + delete p_BPUnderCalibrationView; + p_BPUnderCalibrationView = nullptr; + } + if (g_pBPValueView) + { + delete g_pBPValueView; + g_pBPValueView = nullptr; + } } void BPMainView::OnStart() @@ -141,6 +151,25 @@ namespace OHOS return true; } + bool BPMainView::ChangeBPValueView(int16_t thisView) + { + // 检查视图是否已初始化 + if (group[thisView] == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodPressureView::BPValueView"); + g_pBPValueView = new BPValueView(); + if (g_pBPValueView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodPressureView:: new scrollView[%d] fail", thisView); + return false; + } + // 初始化视图并添加到视图组 + group[thisView] = g_pBPValueView->BPValueInit(); + container_->Add(group[thisView]); + } + return true; + } + /** * 视图映射结构体 - 将视图ID映射到对应的视图切换函数 */ @@ -153,6 +182,7 @@ namespace OHOS static const BPViewMapper ViewMapper[] = { {BPCALIBRATIONVIEW, &BPMainView::ChangeBPCalibrationView}, {BPUNDERCALIBRATIONVIEW, &BPMainView::ChangeBPUnderCalibrationView}, + {BPVALUEVIEW, &BPMainView::ChangeBPValueView}, }; bool BPMainView::ClickFunc(int16_t interface) diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPModel.cpp index 421c956e7..9381dbc45 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPModel.cpp @@ -6,6 +6,10 @@ #include "heart_blood/health_service/health_service.h" #include "custom_utils.h" +#include +#include +#include + extern "C" errcode_t uapi_get_timestamp_ms(uint32_t *tm); #include "custom_utils.h" @@ -24,6 +28,9 @@ extern "C" errcode_t uapi_get_timestamp_ms(uint32_t *tm); #define MAX_DISVALID_SPO2_COUNT 100 namespace OHOS { + static osTimerId_t g_timer = nullptr; + static int Time = 30; + /** * @brief Constructor for the BPModel class. */ @@ -301,4 +308,88 @@ namespace OHOS // BPMainView::GetInstance()->UpSPO2Text(); } } + /* -------------------------------------------------------------------------- */ + /*定时器到期时的处理*/ + static void BP_TimerCallbackProc(int data) + { + // 等待完成的定时器 + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BP_TimerCallbackProc,Time = %d", Time); + if (Time < 0) // 如果校准超时30s,进入完成界面 + { + BPModel::GetInstance()->BP_StopTimer(); + BPMainView::GetInstance()->ChangeView(BPUNDERCALIBRATIONVIEW,BPVALUEVIEW); + } + return; + } + + /* + * @brief 回调函数 + */ + static void BP_TimerCallback(int data) + { + Time -= 1; + GraphicService::GetInstance()->PostGraphicEvent(std::bind(BP_TimerCallbackProc, data)); + } + + /* + * @brief 开启定时器函数 + * @param interval 时间间隔,单位ms + */ + void BPModel::BP_StartTimer(uint32_t interval) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BPModel::BP_StartTimer"); + /* -------------------------- 1.检查定时器是否已经存在,如果存在则返回 ------------------------- */ + if (g_timer != nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Timer already exists!!"); + return; + } + + /* --------------------------------- 2.创建定时器 -------------------------------- */ + g_timer = osTimerNew((osTimerFunc_t)BP_TimerCallback, osTimerPeriodic, nullptr, nullptr); + // 检查定时器创建是否成功 + if (g_timer == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Timer create failed!!"); + return; + } + + /* ----------------------------- 3.将毫秒转换为系统时钟节拍数 ---------------------------- */ + int tick = osMs2Tick(interval); + + /* --------------------------------- 4.启动定时器 -------------------------------- */ + osStatus_t ret = osTimerStart(g_timer, tick); + /* -------------------- 5.检查定时器启动是否成功,如果启动失败,删除定时器并置为 nullptr -------------------- */ + if (ret != osOK) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "osTimerDelete failed, ret = %lx!!", ret); + if (g_timer != nullptr) + { + ret = osTimerDelete(g_timer); + } + g_timer = nullptr; + return; + } + } + + /* + * @brief 停止定时器 + */ + void BPModel::BP_StopTimer(void) + { + // 检查定时器是否存在 + if (g_timer != nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BPModel::BP_StopTimer"); + osTimerStop(g_timer); + // 删除定时器并置为 nullptr + osStatus_t ret = osTimerDelete(g_timer); + if (ret != osOK) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "osTimerDelete failed, ret = %lx!!", ret); + } + g_timer = nullptr; + Time = 30; + } + } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPUnderCalibrationView.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPUnderCalibrationView.cpp index 5b80ca0c8..38e9c0677 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPUnderCalibrationView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPUnderCalibrationView.cpp @@ -11,10 +11,12 @@ #include "uicomponents/UIComponents.h" #include "bloodpressure/include/BPMainPresenter.h" #include "bloodpressure/include/BPUnderCalibrationView.h" +#include "bloodpressure/include/BPModel.h" + namespace OHOS { static BPUnderCalibrationView *g_pBPUnderCalibrationView{nullptr}; - static const char *BPBACKPATH = "/user/res/BP/bp_beijing.bin"; + static const char *BPBACKPATH = "/user/res/BPCalibration/calibration_background.bin"; BPUnderCalibrationView::BPUnderCalibrationView() { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BPUnderCalibrationView::BPUnderCalibrationView"); @@ -94,10 +96,10 @@ namespace OHOS { InitLabel(calibrationLabel, 83, 32, 300, 40, "calibration", "校准中...", DEFAULT_VECTOR_FONT_FILENAME, 35); - InitLabel(remindLabel, 53, 270, 360, 35, "remind", "首轮校准中,过程中尽量保持静止,呼吸均匀平衡", DEFAULT_VECTOR_FONT_FILENAME, 30); + InitLabel(remindLabel, 63, 278, 360, 35, "remind", "首轮校准中,过程中尽量保持静止,呼吸均匀平衡", DEFAULT_VECTOR_FONT_FILENAME, 30); remindLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); remindLabel->SetTextColor(Color::Red()); - InitLabel(timeLabel, 120, 340, 300, 35, "timeLabel", "秒", DEFAULT_VECTOR_FONT_FILENAME, 30); + InitLabel(timeLabel, 140, 400, 300, 35, "timeLabel", "秒", DEFAULT_VECTOR_FONT_FILENAME, 30); group->Add(calibrationLabel); group->Add(remindLabel); @@ -114,6 +116,17 @@ namespace OHOS background = new UIImageView(); background->SetPosition(0, 0, 466, 466); background->SetSrc(BPBACKPATH); + + background = new UIImageView(); + background->SetPosition(0, 0, 466, 466); + background->SetSrc(BPBACKPATH); + + background = new UIImageView(); + background->SetPosition(0, 0, 466, 466); + background->SetSrc(BPBACKPATH); + + + group->Add(background); return true; } @@ -142,6 +155,7 @@ namespace OHOS return nullptr; }; WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bool BPUnderCalibrationView::InitView()"); + BPModel::GetInstance()-> BP_StartTimer(1000); return group; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPValueView.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPValueView.cpp new file mode 100644 index 000000000..a4ce6b7f0 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPValueView.cpp @@ -0,0 +1,244 @@ +/*** + * @Date: 2024-04-15 10:55:58 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-07-31 14:36:25 + * @FilePath: /FD230/code/sdk/application/wearable/fd230/nativeapp/nativeui/bloodpressure/src/BPValueView.cpp + */ + +#include "ui_resource_image.h" +#include "UiConfig.h" +#include "wearable_log.h" +#include "uicomponents/UIComponents.h" +#include "bloodpressure/include/BPMainPresenter.h" +#include "bloodpressure/include/BPValueView.h" +namespace OHOS +{ + static BPValueView *g_pBPValueView{nullptr}; + static const char *BPBACKPATH = "/user/res/BPCalibration/calibration_background.bin"; + static const char *LEFTPATH = "/user/res/BPCalibration/decrease_button.bin"; + static const char *RIGHTPATH = "/user/res/BPCalibration/increase_button.bin"; + int16_t BPValueView::SBP=120; + int16_t BPValueView::DBP=120; + + + BPValueView::BPValueView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BPValueView::BPValueView"); + g_pBPValueView = this; + } + BPValueView::~BPValueView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BPValueView::~BPValueView"); + DeInit(); + g_pBPValueView = nullptr; + } + BPValueView *BPValueView::GetInstance() + { + return g_pBPValueView; + } + void BPValueView::DeInit() + { + if(group) + { + group->RemoveAll(); + delete group; + group = nullptr; + } + if (background != nullptr) + { + delete background; + background = nullptr; + } + if (titleLabel != nullptr) + { + delete titleLabel; + titleLabel = nullptr; + } + if (SBPLabel != nullptr) + { + delete SBPLabel; + SBPLabel = nullptr; + } + if (DBPLabel != nullptr) + { + delete DBPLabel; + DBPLabel = nullptr; + } + if (valuecheckButton != nullptr) + { + delete valuecheckButton; + valuecheckButton = nullptr; + } + if (SBPLeft != nullptr) + { + delete SBPLeft; + SBPLeft = nullptr; + } + if (SBPRight != nullptr) + { + delete SBPRight; + SBPRight = nullptr; + } + if (DBPLeft != nullptr) + { + delete DBPLeft; + DBPLeft = nullptr; + } + if (DBPRight != nullptr) + { + delete DBPRight; + DBPRight = nullptr; + } + } + /* -------------------------------------------------------------------------- */ + void BPValueView::UpSPO2Text() + { + // // if (bloodLabel == nullptr || timeLabel == nullptr) + // // return; + + // // 更新血氧数据 + // uint16_t spo2 = BPModel::GetInstance()->GetSPO2data(); + // if (spo2 != 0) // 判断是否为默认数据 + // { + // // 更新数据 + // std::string bloodpressureStr = std::to_string(spo2) + "%"; + // // bloodLabel->SetText(bloodpressureStr.c_str()); + + // // 获取时间差 + // uint32_t time = BPMainPresenter::GetInstance()->GetCurrentTime(); + // uint32_t check_time = BPModel::GetInstance()->GetCheckTime(); + // int time_diff = BPMainPresenter::GetInstance()->GetTDOA(time, check_time); + + // if (time_diff == 0) + // { + // timeLabel->SetTextId(STR_CHECKNEW); + // } + // else if (time_diff <= 60) + // { + // UpdateLabel(timeLabel, time_diff, STR_CHECKTIME); + // } + // else + // { + // timeLabel->SetTextId(STR_CHECKLONG); + // } + // } + // else + // { + // } + } + /* -------------------------------------------------------------------------- */ + /*** + * @description: + * @return 添加按键是否成功 + */ + bool BPValueView::AddButton() + { + InitLabelButton(valuecheckButton, 125, 365, 217, 63, "checkButton", "确认", 35); + valuecheckButton->SetViewId("value_check"); + valuecheckButton->SetStyle(STYLE_BACKGROUND_COLOR, 0x19191919); // 设置按键颜色 + valuecheckButton->SetTextColor(Color::Red()); + // 设置按键监听 + UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::BPMainPresenter::GetInstance(); + valuecheckButton->SetOnClickListener(clickListener); + + group->Add(valuecheckButton); + return true; + } + /*** + * @description: + * @return 初始化标签是否成功 + */ + bool BPValueView::InitLable() + { + + InitLabel(titleLabel, 109, 38, 239, 35, "title", "血压校准", DEFAULT_VECTOR_FONT_FILENAME, 35); + InitLabel(SBPLabel, 63, 163, 85, 29, "SBP", "收缩压", DEFAULT_VECTOR_FONT_FILENAME, 30); + InitLabel(DBPLabel, 63, 282, 85, 29, "DBP", "舒张压", DEFAULT_VECTOR_FONT_FILENAME, 30); + /*初始化检测时间*/ + group->Add(titleLabel); + group->Add(SBPLabel); + group->Add(DBPLabel); + + return true; + } + /*** + * @description: + * @return 初始化背景是否成功 + */ + bool BPValueView::Initbackground() + { + background = new UIImageView(); + background->SetPosition(0, 0, 466, 466); + background->SetSrc(BPBACKPATH); + + SBPLeft = new UIImageView(); + SBPLeft->SetPosition(199, 160, 31, 35); + SBPLeft->SetSrc(LEFTPATH); + SBPLeft->SetViewId("SBPLeft"); + UIView::OnClickListener *clickListener_SBPLeft = (UIView::OnClickListener *)OHOS::BPMainPresenter::GetInstance(); + SBPLeft->SetOnClickListener(clickListener_SBPLeft); + + SBPRight = new UIImageView(); + SBPRight->SetPosition(385, 160, 31, 35); + SBPRight->SetSrc(RIGHTPATH); + SBPRight->SetViewId("SBPRight"); + UIView::OnClickListener *clickListener_SBPRight = (UIView::OnClickListener *)OHOS::BPMainPresenter::GetInstance(); + SBPRight->SetOnClickListener(clickListener_SBPRight); + + DBPLeft = new UIImageView(); + DBPLeft->SetPosition(199, 278, 31, 35); + DBPLeft->SetSrc(LEFTPATH); + DBPLeft->SetViewId("DBPLeft"); + UIView::OnClickListener *clickListener_DBPLeft = (UIView::OnClickListener *)OHOS::BPMainPresenter::GetInstance(); + DBPLeft->SetOnClickListener(clickListener_DBPLeft); + + DBPRight = new UIImageView(); + DBPRight->SetPosition(385, 278, 31, 35); + DBPRight->SetSrc(RIGHTPATH); + DBPRight->SetViewId("DBPRight"); + UIView::OnClickListener *clickListener_DBPRight = (UIView::OnClickListener *)OHOS::BPMainPresenter::GetInstance(); + DBPRight->SetOnClickListener(clickListener_DBPRight); + + group->Add(background); + group->Add(SBPLeft); + group->Add(SBPRight); + group->Add(DBPLeft); + group->Add(DBPRight); + return true; + } + /*** + * @description: + * @return 是否初始化成功 + */ + UIViewGroup *BPValueView::BPValueInit() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bool BPValueView::InitView()"); + group = new UIViewGroup(); + if (group == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmPopUpView::group null!"); + return nullptr; + } + group->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + if (!Initbackground()) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Initbackground error!"); + return nullptr; + }; + if (!InitLable()) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLable error!"); + return nullptr; + }; + if (!AddButton()) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AddButton error!"); + return nullptr; + }; + SBP=120; + DBP=120; + + return group; + } + +} diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/file.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/file.bin index de65c4249..3c4b1da87 100644 --- a/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/file.bin +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/file.bin @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a317e355903aa113ed57ca69838e97c5e6edf1f9cbe9b22b0f7e91de60c9ad53 -size 43963392 +oid sha256:b4b062f8fda932bc3f2211903f4cc764d1067eabe272a4e69955fa53cedcb94d +size 44569536 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/file_tmp.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/file_tmp.bin index 2ab92f1da..7e8b67d51 100644 --- a/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/file_tmp.bin +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/file_tmp.bin @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7e383c66b84c89fb165eba71148fec946526964e9469ed0c4b7d679d057480dc -size 43963392 +oid sha256:f5b822a85dd37d84637b1a3990a6d46f9a6fbd9d0159bde988f4e2498b3e70c2 +size 44569536 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/D.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/D.bin deleted file mode 100644 index ee876940a..000000000 --- a/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/D.bin +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2ad95b790da87a16e8f1af72aa90e3a404b84dc302fadb8e87c78f2c9771d875 -size 51192 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/J1.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/J1.bin new file mode 100644 index 000000000..1bd74700f --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/J1.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b30fdc9e6e15f7576ca7b20be8513c95773d5db7573c2330619dd7353446cec2 +size 24600 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/J2.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/J2.bin new file mode 100644 index 000000000..8f3eacd05 --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/J2.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:92a26bd84905cd3ce0c91f0513f79da62c3642c0cc6d8339f9500411968cccd5 +size 24600 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/J3.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/J3.bin new file mode 100644 index 000000000..1b9759e4e --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/J3.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b881d6aa34320b620f4a3c2f723ee6d0fd571db50b357f300f649c81a3e5d3cc +size 24600 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/Q.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/Q.bin deleted file mode 100644 index 056a7faed..000000000 --- a/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/Q.bin +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ec564dfdc5fd5780f259ecd5def9de4afdde2e640303a534722f3b28730f9e3d -size 37464 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/W.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/W.bin deleted file mode 100644 index 5b1cd603c..000000000 --- a/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/W.bin +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5c371066564c59695cf2bd253af59a0be1d59edd0c723c690cb5948198dc7ac2 -size 107352 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/bp_beijing.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/calibration_background.bin similarity index 100% rename from code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/bp_beijing.bin rename to code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/calibration_background.bin diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/Y.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/calibration_remind.bin similarity index 100% rename from code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/Y.bin rename to code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/calibration_remind.bin diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/R.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/decrease_button.bin similarity index 100% rename from code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/R.bin rename to code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/decrease_button.bin diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/E.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/error.bin similarity index 100% rename from code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/E.bin rename to code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/error.bin diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/R1.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/increase_button.bin similarity index 100% rename from code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/R1.bin rename to code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/increase_button.bin diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/measuring.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/measuring.bin new file mode 100644 index 000000000..f7656de9d --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/measuring.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b8f4f54f48eca0b415961c9fe13cfbda8133d63521efdbb9799d28c5b1d967f2 +size 3384 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/B.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/posture.bin similarity index 100% rename from code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/B.bin rename to code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/posture.bin diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/E-1.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/right.bin similarity index 100% rename from code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/E-1.bin rename to code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/right.bin diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/C.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/warning.bin similarity index 100% rename from code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/C.bin rename to code/sdk/build/config/target_config/brandy/mk_fs_image/w9/fs/user/res/BPCalibration/warning.bin -- 2.17.1