${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodpressure/src/BPModel.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodpressure/src/BPDetectionView.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodpressure/src/BPDetectionPresenter.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodpressure/src/BPDetectFirstView.cpp
+
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bluetooth/src/BluetoothDeviceCaseListAdapter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bluetooth/src/BluetoothDeviceListView.cpp
{VIEW_BLOOD_RESULT, PNG_APPLIST_SPO2_IMAGE_BIG, PNG_APPLIST_SPO2_IMAGE, PNG_APPLIST_DEFAULT_IMG, "血氧", STR_BLOOD_OXYGEN, nullptr},
#if defined(BOARD_W9) || defined(BOARD_N9)
/*W9与N9的Slice写宏里面*/
- // {VIEW_BLOOD_PRESSURE_CALIBRATION, PNG_APPLIST_SPO2_IMAGE_BIG, PNG_APPLIST_SPO2_IMAGE, PNG_APPLIST_DEFAULT_IMG, "血压", STR_BP_CHECK, nullptr},
- {VIEW_BLOOD_PRESSURE_CHECK, PNG_APPLIST_SPO2_IMAGE_BIG, PNG_APPLIST_SPO2_IMAGE, PNG_APPLIST_DEFAULT_IMG, "血压", STR_BLOOD_OXYGEN, nullptr},
+ {VIEW_BLOOD_PRESSURE_CHECK, PNG_APPLIST_SPO2_IMAGE_BIG, PNG_APPLIST_SPO2_IMAGE, PNG_APPLIST_DEFAULT_IMG, "血压", STR_BP_CHECK, nullptr},
#endif
{VIEW_SLEEP, PNG_APPLIST_SLEEP_IMAGE_BIG, PNG_APPLIST_SLEEP_IMAGE, PNG_APPLIST_DEFAULT_IMG, "睡眠", STR_SLEEP, nullptr},
{VIEW_TRAINING, PNG_APPLIST_TRAINING_IMAGE_BIG, PNG_APPLIST_TRAINING_IMAGE, PNG_APPLIST_DEFAULT_IMG, "运动", STR_TRAINING, nullptr},
#include "heart_blood/health_service/health_service.h"
#include "custom_utils.h"
-extern "C" errcode_t uapi_get_timestamp_ms(uint32_t *tm);
+
#include "custom_utils.h"
#include "ppg_service.h"
--- /dev/null
+
+#ifndef BP_DetectFirst_VIEW_H
+#define BP_DetectFirst_VIEW_H
+
+#include "components/ui_button.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"
+namespace OHOS {
+
+class BPDetectFirstView {
+public:
+ BPDetectFirstView();
+ ~BPDetectFirstView();
+ static BPDetectFirstView *GetInstance();
+ UIViewGroup *BPDetectFirstInit();
+ void UpdateText(); //更新文本数据
+
+private:
+ UILabelExt *DBPTitleLabel{nullptr};
+ UILabelExt *SBPTitleText{nullptr};
+ UILabel *DBPText{nullptr};
+ UILabel *SBPText{nullptr};
+ UILabel *timeLabel{nullptr};
+
+ UIImageView *BPImageView{nullptr};
+ UIImageView *BgWImageView{nullptr};
+ UIImageView *BgQImageView{nullptr};
+
+ UILabelButtonExt *CheckButton{nullptr};
+
+ UIViewGroup *group{nullptr};
+
+ uint16_t m_dbp_{0};
+ uint16_t m_sbp_{0};
+};
+} // namespace OHOS
+
+#endif // 血压主界面
\ No newline at end of file
#include "wearable_log.h"
#include "bloodpressure/include/BPDetectionPresenter.h"
+#include "bloodpressure/include/BPDetectFirstView.h"
#define CLICK_BLOOD_PRESSURE "click_bloodpressure"
namespace OHOS {
-
+
+typedef enum : uint8_t {
+ //检测主界面
+ MAIN_BPVIEW,
+ //测量中界面
+ CALIBRATION_BPVIEW,
+ //输入对比值界面
+ UNDER_CALIBRATION_BPVIEW,
+ //结果界面
+ RESULT_BPVIEW,
+ MAX_BPDECETVIEW,
+} BPDETECTVIEWID;
+
class BPDetectionPresenter;
class BPDetectionView : public View<BPDetectionPresenter> {
public:
void OnStart() override;
static BPDetectionView *GetInstance(void);
- bool BPDetectionViewInit();
- void UpdataText(); //更新文本数据
-
-private:
- // UIImageAnimatorView *imageAnimator{nullptr};
+ bool ChangeBPCalibrationView(int16_t);
+ bool ChangeBPUnderCalibrationView(int16_t);
+ bool ChangeBPValueView(int16_t);
- UILabelExt *DBPTitleLabel{nullptr};
- UILabelExt *SBPTitleText{nullptr};
- UILabel *DBPText{nullptr};
- UILabel *SBPText{nullptr};
- UILabel *timeLabel{nullptr};
-
- UIImageView *BPImageView{nullptr};
- UIImageView *BgWImageView{nullptr};
- UIImageView *BgQImageView{nullptr};
-
- UILabelButtonExt *CheckButton{nullptr};
+ bool ClickFunc(int16_t interface);
+ void ChangeView(int16_t hideView, int16_t showView);
+
+ bool ChangeBPDetectFirstView(int16_t thisView);
- uint16_t m_dbp_{0};
- uint16_t m_sbp_{0};
+private:
+ UIViewGroup *group[MAX_BPDECETVIEW]{nullptr};
+ BPDetectFirstView *g_pBPDetectFirstView = nullptr;
};
} // namespace OHOS
--- /dev/null
+/***
+ * @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/BPDetectFirstView.cpp
+ */
+
+#include "ui_resource_image.h"
+#include "UiConfig.h"
+#include "wearable_log.h"
+#include "uicomponents/UIComponents.h"
+#include "bloodpressure/include/BPDetectionPresenter.h"
+#include "bloodpressure/include/BPDetectFirstView.h"
+#include "bloodpressure/include/BPModel.h"
+namespace OHOS
+{
+ static BPDetectFirstView *g_pBPDetectFirstView{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";
+
+ BPDetectFirstView::BPDetectFirstView()
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BPDetectFirstView::BPDetectFirstView");
+ g_pBPDetectFirstView = this;
+ }
+ BPDetectFirstView::~BPDetectFirstView()
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BPDetectFirstView::~BPDetectFirstView");
+ if(group)
+ {
+ group->RemoveAll();
+ if(DBPTitleLabel)
+ {
+ delete DBPTitleLabel;
+ DBPTitleLabel = nullptr;
+ }
+ if(SBPTitleText)
+ {
+ delete SBPTitleText;
+ SBPTitleText = nullptr;
+ }
+ if(DBPText)
+ {
+ delete DBPText;
+ DBPText = nullptr;
+ }
+ if(SBPText)
+ {
+ delete SBPText;
+ SBPText = nullptr;
+ }
+ if(timeLabel)
+ {
+ 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;
+ }
+ }
+ delete group;
+ group = nullptr;
+ g_pBPDetectFirstView = nullptr;
+ }
+
+ BPDetectFirstView *BPDetectFirstView::GetInstance()
+ {
+ return g_pBPDetectFirstView;
+ }
+
+ void BPDetectFirstView::UpdateText()
+ {
+ 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());
+ //获取上一次检测数据 ? 待定
+
+ }
+
+ /***
+ * @description:
+ * @return 是否初始化成功
+ */
+ UIViewGroup *BPDetectFirstView::BPDetectFirstInit()
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bool BPDetectFirstView::InitView()");
+ group = new UIViewGroup();
+ group->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BPDetectionViewInit is begin");
+ /*初始化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, 360, 230, 80, CLICK_BLOOD_PRESSURE,STR_CHECK, 30);
+ CheckButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffFF8A36); // 设置按键颜色
+ UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::BPDetectionPresenter::GetInstance();
+ CheckButton->SetOnClickListener(clickListener);//设置按键监听
+
+ DBPText->SetTextColor(Color::GetColorFromRGBA(0xFF, 0x35, 0x00, 0xFF));
+ SBPText->SetTextColor(Color::GetColorFromRGBA(0xFF, 0x35, 0x00, 0xFF));
+
+ group->Add(DBPTitleLabel);
+ group->Add(SBPTitleText);
+ group->Add(DBPText);
+ group->Add(SBPText);
+ group->Add(timeLabel);
+ group->Add(BPImageView);
+ group->Add(BgWImageView);
+ group->Add(BgQImageView);
+ group->Add(CheckButton);
+
+ UpdateText();
+
+ return group;
+ }
+
+
+
+}
{
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()
{
if(container_)
container_->RemoveAll();
- if(DBPTitleLabel)
- {
- delete DBPTitleLabel;
- DBPTitleLabel = nullptr;
- }
- if(SBPTitleText)
- {
- delete SBPTitleText;
- SBPTitleText = nullptr;
- }
- if(DBPText)
- {
- delete DBPText;
- DBPText = nullptr;
- }
- if(SBPText)
- {
- delete SBPText;
- SBPText = nullptr;
- }
- if(timeLabel)
- {
- delete timeLabel;
- timeLabel = nullptr;
- }
- if(BPImageView)
- {
- delete BPImageView;
- BPImageView = nullptr;
- }
- if(BgWImageView)
- {
- delete BgWImageView;
- BgWImageView = nullptr;
- }
- if(BgQImageView)
- {
- delete BgQImageView;
- BgQImageView = nullptr;
- }
- if(CheckButton)
+ if(g_pBPDetectFirstView)
+ {
+ delete g_pBPDetectFirstView;
+ g_pBPDetectFirstView = nullptr;
+ }
+
+
+ for(int i = 0; i < MAX_BPDECETVIEW; ++i)
{
- delete CheckButton;
- CheckButton = nullptr;
+ if(group[i])
+ {
+ group[i] = nullptr;
+ }
}
-
+
+
g_pBPCheckView = nullptr;
}
BPDetectionView *BPDetectionView::GetInstance(void)
{
return g_pBPCheckView;
}
- /*初始化检测界面*/
- bool BPDetectionView::BPDetectionViewInit()
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BPDetectionViewInit is begin");
- /*初始化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);
-
- 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()
{
SetContainerView(new UIViewGroup());
container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
- if (!BPDetectionViewInit())
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BPDetectionView::InitBPView fail");
- return;
- }
-
container_->SetDraggable(true);
container_->SetTouchable(true);
container_->SetOnDragListener(presenter_);
+ // 切换到第一个界面
+ ChangeView(MAX_BPDECETVIEW, MAIN_BPVIEW);
+
// 增加按键监听
RootView::GetInstance()->SetOnKeyActListener(presenter_);
}
}
return;
}
+
+ ///////////////////////////////////////////////////////////
+ bool BPDetectionView::ChangeBPDetectFirstView(int16_t thisView)
+ {
+ // 检查视图是否已初始化,避免重复创建
+ if (group[thisView] == nullptr)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodPressureView::ChangeInitialCalibrationView");
+ // 创建首次校准视图实例
+ g_pBPDetectFirstView = new BPDetectFirstView();
+ if (g_pBPDetectFirstView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodPressureView:: new scrollView[%d] fail", thisView);
+ return false;
+ }
+ // 初始化视图并添加到视图组
+ group[thisView] = g_pBPDetectFirstView->BPDetectFirstInit();
+ container_->Add(group[thisView]);
+ }
+ return true;
+ }
+
+
+ /**
+ * 视图映射结构体 - 将视图ID映射到对应的视图切换函数
+ */
+ struct BPViewMapper
+ {
+ const int16_t viewId; // 视图ID
+ bool (BPDetectionView::*func)(int16_t); // 对应的视图切换函数指针
+ };
+
+ static const BPViewMapper ViewMapper[] = {
+ {MAIN_BPVIEW, &BPDetectionView::ChangeBPDetectFirstView},
+ };
+
+ bool BPDetectionView::ClickFunc(int16_t interface)
+ {
+ int funcSize = sizeof(ViewMapper) / sizeof(ViewMapper[0]);
+
+ for (int i = 0; i < funcSize; i++)
+ {
+ if (interface == ViewMapper[i].viewId)
+ {
+ bool jug = (this->*(ViewMapper[i].func))(interface);
+ if (jug == false)
+ {
+ return false;
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+
+ void BPDetectionView::ChangeView(int16_t hideView, int16_t showView)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BPDetectionView::ChangeView");
+ if (hideView > MAX_BPDECETVIEW)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BPDetectionView:: SystemViewId Overstep ones bounds");
+ return;
+ }
+ if (hideView != MAX_BPDECETVIEW)
+ {
+ if (group[hideView] == nullptr)
+ {
+ return;
+ }
+ group[hideView]->SetVisible(false);
+ }
+ ClickFunc(showView);
+ group[showView]->SetVisible(true);
+ container_->Invalidate();
+ }
+
}
#include <cmsis_os2.h>
#include <service/graphic_service.h>
-extern "C" errcode_t uapi_get_timestamp_ms(uint32_t *tm);
+
#include "AppViewIDs.h"
#include "ConfigModel.h"
std::string BPModel::GetCurrentTimeStr() {
uint32_t timeStamp = 0;
- if (uapi_get_timestamp_ms(&timeStamp) != ERRCODE_SUCC) {
+ if (uapi_get_timestampe_ss(&timeStamp) != ERRCODE_SUCC) {
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to get timestamp");
return "----/--/-- \n --/--";
}