From: Caisking Date: Mon, 16 Jun 2025 07:54:42 +0000 (+0800) Subject: 增加血压测量Slice以及主UI X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=5d241b65bc41eac38aa1acc3de5ab76653b243e6;p=mirrors%2FFD230.git 增加血压测量Slice以及主UI --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPDetectionPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPDetectionPresenter.h index 79281efc6..7d74b72f2 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPDetectionPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPDetectionPresenter.h @@ -1,9 +1,4 @@ -/*** - * @Date: 2024-07-29 15:33:59 - * @LastEditors: Caisking 3449750381@qq.com - * @LastEditTime: 2024-07-29 16:28:08 - * @FilePath: /FD230/code/sdk/application/wearable/fd230/nativeapp/nativeui/bloodpressure/include/BPDetectionPresenter.h - */ + #ifndef BP_DETECTION_PRESENTER_H #define BP_DETECTION_PRESENTER_H @@ -16,18 +11,15 @@ #include "bloodpressure/include/BPDetectionView.h" #include "power_display_service.h" -#define BP_KEEP_TIME 60000 // 60s namespace OHOS { class BPDetectionView; class BPDetectionPresenter : public Presenter, - public ModelListenerSample, public UIView::OnClickListener, public UIView::OnDragListener, - public RootView::OnKeyActListener, - public ListScrollListener + public RootView::OnKeyActListener { public: BPDetectionPresenter(); @@ -35,10 +27,10 @@ namespace OHOS static BPDetectionPresenter *GetInstance(void); void OnStart() override; + void OnPause() override; void OnResume() override; void OnStop() override; - void OnTickEvent() override; - void Notify() override {} + bool OnClick(UIView &view, const ClickEvent &event) override; bool OnDrag(UIView &view, const DragEvent &event) override; bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 @@ -46,13 +38,7 @@ namespace OHOS void NavigateBack(void); private: - void ResetTickTimer(void); - uint64_t startTime{0}; - bool BPCountEvent{false}; - bool BPCheckState{false}; - - const power_display_svr_api_t *display_api = power_display_svr_get_api(); - uint32_t display_time; + bool BPCheckState = false; }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPDetectionView.h b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPDetectionView.h index 0b0fd66f9..df9863b51 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPDetectionView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPDetectionView.h @@ -2,7 +2,8 @@ * @Date: 2024-07-29 15:38:56 * @LastEditors: Caisking 3449750381@qq.com * @LastEditTime: 2024-07-29 15:42:12 - * @FilePath: /FD230/code/sdk/application/wearable/fd230/nativeapp/nativeui/bloodpressure/include/BPDetectionView.cpp + * @FilePath: + * /FD230/code/sdk/application/wearable/fd230/nativeapp/nativeui/bloodpressure/include/BPDetectionView.cpp */ /* * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. @@ -14,53 +15,57 @@ #ifndef BP_Detection_VIEW_H #define BP_Detection_VIEW_H -#include "View.h" #include "BaseView.h" -#include "wearable_log.h" #include "UiConfig.h" -#include "components/ui_label.h" -#include "components/ui_label_ext.h" +#include "View.h" #include "components/ui_button.h" -#include "components/ui_label_button.h" -#include "components/ui_image_animator.h" #include "components/ui_circle_progress.h" +#include "components/ui_image_animator.h" +#include "components/ui_label.h" +#include "components/ui_label_button.h" +#include "components/ui_label_button_ext.h" +#include "components/ui_label_ext.h" +#include "components/ui_scroll_view.h" #include "components/ui_view_group.h" - +#include "wearable_log.h" #include "bloodpressure/include/BPDetectionPresenter.h" -#include "components/ui_scroll_view.h" -#include "components/ui_label_button_ext.h" +#define CLICK_BLOOD_PRESSURE "click_bloodpressure" +namespace OHOS { + +class BPDetectionPresenter; +class BPDetectionView : public View { +public: + BPDetectionView(); + virtual ~BPDetectionView(); + void OnStop() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStart() override; + static BPDetectionView *GetInstance(void); + + bool BPDetectionViewInit(); + void UpdataText(); //更新文本数据 -#include "power_display_service.h" +private: + // UIImageAnimatorView *imageAnimator{nullptr}; -#define STOPCHECK "stop_check" -namespace OHOS -{ - class BPDetectionPresenter; - class BPDetectionView : public View - { - public: - BPDetectionView(); - virtual ~BPDetectionView(); - void OnStop() override; - void OnSetUpView() override; - void OnTearDownView() override; - void OnStart() override; - static BPDetectionView *GetInstance(void); + UILabelExt *DBPTitleLabel{nullptr}; + UILabelExt *SBPTitleText{nullptr}; + UILabel *DBPText{nullptr}; + UILabel *SBPText{nullptr}; + UILabel *timeLabel{nullptr}; - bool BPDetectionViewInit(); - UIImageAnimatorView *GetImageAnimator(void); - void UpShowBPText(void); + UIImageView *BPImageView{nullptr}; + UIImageView *BgWImageView{nullptr}; + UIImageView *BgQImageView{nullptr}; - private: - UIImageAnimatorView *imageAnimator{nullptr}; - UILabelExt *titleLabel{nullptr}; - UILabel *Spo2Text{nullptr}; - UILabelButtonExt *testButton{nullptr}; + UILabelButtonExt *CheckButton{nullptr}; - uint32_t spo2_; - }; -} + uint16_t m_dbp_{0}; + uint16_t m_sbp_{0}; +}; +} // namespace OHOS #endif // 血氧主界面 \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPDetectionPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPDetectionPresenter.cpp index 1dcca0026..da8030678 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPDetectionPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPDetectionPresenter.cpp @@ -20,6 +20,7 @@ namespace OHOS { + // 当前Presenter属性实例化的内存指针 static BPDetectionPresenter *g_pBPDetectionPresenter = nullptr; @@ -27,17 +28,11 @@ namespace OHOS { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BPDetectionPresenter::BPDetectionPresenter"); g_pBPDetectionPresenter = this; - - // display_api->set_screen_set_keepon_timeout(-1); // 设置常亮 - ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); - ResetTickTimer(); } BPDetectionPresenter::~BPDetectionPresenter() { - // display_api->set_screen_set_keepon_timeout(0); // 恢复 - ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON); - g_pBPDetectionPresenter = nullptr; + } BPDetectionPresenter *BPDetectionPresenter::GetInstance() { @@ -52,19 +47,19 @@ namespace OHOS Presenter::OnStart(); if (!BPCheckState) { - BPModel::GetInstance()->BP_Start(); + // BPModel::GetInstance()->BP_Start(); BPCheckState = true; } } - void BPDetectionPresenter::OnResume(void) - { - } + void BPDetectionPresenter::OnPause(void) {} + + void BPDetectionPresenter::OnResume(void) {} void BPDetectionPresenter::OnStop(void) { if (BPCheckState) { - BPModel::GetInstance()->BP_Stop(); + // BPModel::GetInstance()->BP_Stop(); BPCheckState = false; } } @@ -83,30 +78,13 @@ namespace OHOS bool BPDetectionPresenter::OnClick(UIView &view, const ClickEvent &event) { - if (strcmp(view.GetViewId(), STOPCHECK) == 0) + if (strcmp(view.GetViewId(), CLICK_BLOOD_PRESSURE) == 0) { NavigateBack(); } return true; } - void BPDetectionPresenter::OnTickEvent() - { - // 更新显示血氧数据 - // BPDetectionView::GetInstance()->UpShowBPText(); 屏蔽动态显示实时数据 - uint64_t current_time = osKernelGetTick2ms(); - if ((startTime != 0) && (current_time - startTime >= BP_KEEP_TIME)) - { - // 超时处理 - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "检测结果: 超时处理 BP_KEEP_TIME: %lld", current_time - startTime); - BPModel::GetInstance()->SetMain(BPMain::TIMEOUT); - BPModel::GetInstance()->BP_Stop(); - } - } - void BPDetectionPresenter::ResetTickTimer(void) - { - startTime = osKernelGetTick2ms(); - } // 增加按键事件 bool BPDetectionPresenter::OnKeyAct(UIView &view, const KeyEvent &event) { diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPDetectionView.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPDetectionView.cpp index 8696302ff..11dfe6b61 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPDetectionView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPDetectionView.cpp @@ -6,56 +6,26 @@ */ #include "UiConfig.h" #include "wearable_log.h" -#include "BPDetectionView.h" -#include "BPModel.h" + +#include "bloodpressure/include/BPDetectionView.h" +#include "bloodpressure/include/BPModel.h" +#include "bloodpressure/include/BPDetectionPresenter.h" + #include "ui_image_animator.h" #include "BPDetectionView.h" #include "ui_resource_string.h" #include "power_display_service.h" #include "uicomponents/UIComponents.h" + namespace OHOS { - // 动态刷新设置 - static constexpr uint16_t IMAGE_SIZE = 180; - static constexpr uint16_t IMAGE_POSITION_Y = 143; - static constexpr uint16_t IMAGE_POSITION_X = 143; - static constexpr uint16_t DETECTION_IMAGE_ANIMATORVIEW_SIZE = 30; - static constexpr uint16_t DETECTION_IMAGE_ANIMATORVIEW_SPEED = 40; - - static ImageAnimatorInfo g_imageAnimatorInfo_blood[30] = { - {PNG_CHECK_TIME_IMAGE_0, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_CHECK_TIME_IMAGE_1, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_CHECK_TIME_IMAGE_2, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_CHECK_TIME_IMAGE_3, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_CHECK_TIME_IMAGE_4, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_CHECK_TIME_IMAGE_5, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_CHECK_TIME_IMAGE_6, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_CHECK_TIME_IMAGE_7, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_CHECK_TIME_IMAGE_8, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_CHECK_TIME_IMAGE_9, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_CHECK_TIME_IMAGE_10, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_CHECK_TIME_IMAGE_11, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_CHECK_TIME_IMAGE_12, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_CHECK_TIME_IMAGE_13, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_CHECK_TIME_IMAGE_14, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_CHECK_TIME_IMAGE_15, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_CHECK_TIME_IMAGE_16, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_CHECK_TIME_IMAGE_17, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_CHECK_TIME_IMAGE_18, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_CHECK_TIME_IMAGE_19, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_CHECK_TIME_IMAGE_20, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_CHECK_TIME_IMAGE_21, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_CHECK_TIME_IMAGE_22, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_CHECK_TIME_IMAGE_23, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_CHECK_TIME_IMAGE_24, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_CHECK_TIME_IMAGE_25, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_CHECK_TIME_IMAGE_26, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_CHECK_TIME_IMAGE_27, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_CHECK_TIME_IMAGE_28, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - {PNG_CHECK_TIME_IMAGE_29, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH}, - }; - + static BPDetectionView *g_pBPCheckView = nullptr; + static const char* image_bp = "/user/res/BPCalibration/measuring.bin"; + static const char* image_bg_w = "/user/res/BPCalibration/W.bin"; + static const char* image_bg_q = "/user/res/BPCalibration/Q.bin"; + + BPDetectionView::BPDetectionView() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BPBandoffView::BPBandoffView"); @@ -66,86 +36,109 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BPDetectionView::~BPDetectionView"); if(container_) container_->RemoveAll(); - if(titleLabel) + + if(DBPTitleLabel) + { + delete DBPTitleLabel; + DBPTitleLabel = nullptr; + } + if(SBPTitleText) { - delete titleLabel; - titleLabel = nullptr; + delete SBPTitleText; + SBPTitleText = nullptr; } - if(testButton) + if(DBPText) { - delete testButton; - testButton = nullptr; + delete DBPText; + DBPText = nullptr; } - if(imageAnimator) + if(SBPText) { - imageAnimator->Stop(); - delete imageAnimator; - imageAnimator = nullptr; + delete SBPText; + SBPText = nullptr; } - if(Spo2Text) + if(timeLabel) { - delete Spo2Text; - Spo2Text = nullptr; + delete timeLabel; + timeLabel = nullptr; } + if(BPImageView) + { + delete BPImageView; + BPImageView = nullptr; + } + if(BgWImageView) + { + delete BgWImageView; + BgWImageView = nullptr; + } + if(BgQImageView) + { + delete BgQImageView; + BgQImageView = nullptr; + } + if(CheckButton) + { + delete CheckButton; + CheckButton = nullptr; + } + g_pBPCheckView = nullptr; } BPDetectionView *BPDetectionView::GetInstance(void) { return g_pBPCheckView; } - UIImageAnimatorView *BPDetectionView::GetImageAnimator() - { - return imageAnimator; - } - - /*更新显示数据*/ - void BPDetectionView::UpShowBPText() - { - uint16_t spo2_ = BPModel::GetInstance()->GetShowSPO2data(); - std::string bloodpressureStr = std::to_string(spo2_); - if (Spo2Text != nullptr) - Spo2Text->SetText(bloodpressureStr.c_str()); - } /*初始化检测界面*/ bool BPDetectionView::BPDetectionViewInit() { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BPDetectionViewInit is begin"); - /*初始化title*/ - InitLabelExt(titleLabel, 83, 50, 300, 35, "title", STR_CHECKON, DEFAULT_VECTOR_FONT_FILENAME, 30); - container_->Add(titleLabel); + /*初始化label*/ + InitLabel(DBPTitleLabel, 20, 66, 200, 60, "calibration", "收缩压", DEFAULT_VECTOR_FONT_FILENAME, 30); + InitLabel(SBPTitleText, 240, 66, 200, 60, "calibration", "舒张压", DEFAULT_VECTOR_FONT_FILENAME, 30); + InitUILabel(DBPText, 20, 120, 200, 60, "calibration", "---", DEFAULT_VECTOR_FONT_FILENAME, 50); + InitUILabel(SBPText, 240, 120, 200, 60, "calibration", "---", DEFAULT_VECTOR_FONT_FILENAME, 50); + InitUILabel(timeLabel, 133, 115, 200, 60, "calibration", "----/--/-- \n --:--", DEFAULT_VECTOR_FONT_FILENAME, 20); + + InitImageView(BPImageView, 208, 10, 100, 100, "image_bp", image_bp); + InitImageView(BgWImageView, 0, -75, 100, 100, "image_bg_w", image_bg_w); + InitImageView(BgQImageView, 55, 196, 100, 100, "image_bg_q", image_bg_q); + + InitButtonExt(CheckButton, 118, 336, 230, 80, CLICK_BLOOD_PRESSURE,STR_CHECK, 30); + CheckButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffFF8A36); // 设置按键颜色 + CheckButton->SetOnClickListener(presenter_); + + DBPText->SetTextColor(Color::GetColorFromRGBA(0xFF, 0x35, 0x00, 0xFF)); + SBPText->SetTextColor(Color::GetColorFromRGBA(0xFF, 0x35, 0x00, 0xFF)); + + container_->Add(DBPTitleLabel); + container_->Add(SBPTitleText); + container_->Add(DBPText); + container_->Add(SBPText); + container_->Add(timeLabel); + container_->Add(BPImageView); + container_->Add(BgWImageView); + container_->Add(BgQImageView); + container_->Add(CheckButton); - /* -------------------------------------------------------------------------- */ - imageAnimator = new UIImageAnimatorView(); - if (imageAnimator == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BPBandoffView::new UIImageAnimatorView fail"); - return false; - } - imageAnimator->SetImageAnimatorSrc(g_imageAnimatorInfo_blood, DETECTION_IMAGE_ANIMATORVIEW_SIZE, DETECTION_IMAGE_ANIMATORVIEW_SPEED); - imageAnimator->SetRepeat(true); - container_->Add(imageAnimator); - - /* -------------------------------------------------------------------------- */ - /*初始化血氧值label*/ - // InitUILabel(Spo2Text, 83, 83, 300, 300, "bloodtext", "--", GILROY_BOLD_FONT, 140); - // container_->Add(Spo2Text); - - /* -------------------------------------------------------------------------- */ - InitButtonExt(testButton, 93, 330, 280, 90, STOPCHECK, STR_CHECKSTOP, 30); - container_->Add(testButton); - - /* -------------------------------------------------------------------------- */ - UIView::OnClickListener *clickLeftListener = (UIView::OnClickListener *)OHOS::BPDetectionPresenter::GetInstance(); - if (clickLeftListener == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BPDetectionView::new clickLeftListener fail"); - return false; - } - testButton->SetOnClickListener(clickLeftListener); - /* -------------------------------------------------------------------------- */ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BPDetectionViewInit is ok"); return true; } + + void BPDetectionView::UpdataText() + { + if(DBPText == nullptr || SBPText == nullptr || timeLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DBPText or SBPText or timeLabel is null"); + return; + } + //获取时间更新时间 + std::string timeStr = BPModel::GetInstance()->GetCurrentTimeStr(); + timeLabel->SetText(timeStr.c_str()); + //获取上一次检测数据 ? 待定 + + } + void BPDetectionView::OnStart() { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BPDetectionView::OnStart"); @@ -157,26 +150,21 @@ namespace OHOS if (!BPDetectionViewInit()) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BPDetectionView::InitBPView fail"); + return; } - SetContainerView(container_); container_->SetDraggable(true); container_->SetTouchable(true); container_->SetOnDragListener(presenter_); // 增加按键监听 - RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::BPDetectionPresenter::GetInstance(); - RootView::GetInstance()->SetOnKeyActListener(keyactListener); + RootView::GetInstance()->SetOnKeyActListener(presenter_); } void BPDetectionView::OnSetUpView() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BPDetectionView::OnSetUpView"); View::OnSetUpView(); - if (imageAnimator != nullptr) - { - imageAnimator->Start(); - } Draw(); } void BPDetectionView::OnTearDownView() 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 523ee684b..7c995d9bb 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPModel.cpp @@ -21,7 +21,9 @@ extern "C" errcode_t uapi_get_timestamp_ms(uint32_t *tm); #define MAX_UNWARE_COUNT 10 #define MAX_VALID_SPO2_COUNT 30 #define MAX_DISVALID_SPO2_COUNT 100 - +// 声明定时器变量 +static osTimerId_t g_timer = nullptr; +static int Time = 30; /* ---------------------------- 收缩压:DBP @@ -53,7 +55,7 @@ std::string BPModel::GetCurrentTimeStr() { if (uapi_get_timestamp_ms(&timeStamp) != ERRCODE_SUCC) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to get timestamp"); - return "----/--/-- /n --/--"; + return "----/--/-- \n --/--"; } // 将时间戳转换为 time_t 类型 @@ -62,17 +64,16 @@ std::string BPModel::GetCurrentTimeStr() { if (timeinfo == NULL) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to convert time"); - return "----/--/-- /n --/--"; + return "----/--/-- \n --/--"; } // 格式化时间为字符串 char buffer[20]; // 格式: YYYY-MM-DD HH:MM - std::strftime(buffer, sizeof(buffer), "%Y-%m-%d /n %H:%M", timeinfo); + std::strftime(buffer, sizeof(buffer), "%Y-%m-%d \n %H:%M", timeinfo); return std::string(buffer); } - /////////////////////////////////////////////////////////////////////////////////////// /*定时器到期时的处理*/ @@ -83,6 +84,7 @@ static void BP_TimerCallbackProc(int data) { if (Time < 0) // 如果校准超时30s,进入完成界面 { BPModel::GetInstance()->BP_StopTimer(); + //TODO:加判断?界面没有存在 直接就挂了 BPMainView::GetInstance()->ChangeView(BPUNDERCALIBRATIONVIEW, BPVALUEVIEW); } return;