mcu_hi3321_watch/application/wearable/nativeapp/nativeui/heartrate/include/HeartRateView.h
2025-05-26 20:15:20 +08:00

105 lines
3.3 KiB
C++

/*
* Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
* Description: heartRate view
* Author:
* Create: 2021-07-26
*/
#ifndef HEART_RATE_VIEW_H
#define HEART_RATE_VIEW_H
#include "View.h"
#include "components/ui_image_animator.h"
#include "components/ui_chart.h"
#include "wearable_log.h"
#include "ohos_types.h"
#include "components/ui_card_page.h"
#include "HeartModel.h"
namespace OHOS {
#define HEART_AVE_NUM 360
#define HEART_RATE_LIMIT_UPPER 200
#define HEART_RATE_LIMIT_LOWER 0
#define INVALID_HEART_VALUE ((int16)0xFFFF)
#define NUM_1 1
#define NUM_2 2
#define NUM_3 3
#define NUM_4 4
#define NUM_5 5
#define NUM_7 7
#define NUM_16 16
#define NUM_99 99
class HeartRateView : public UICardPage {
public:
HeartRateView();
~HeartRateView() override;
static HeartRateView *GetInstance(void);
bool InitView(void);
void PreLoad(void) override;
void UnLoad(void) override;
int32_t SetHeartRateData(Point *rateData, uint32 rateDataSize); // 设置心率数据,用于画心率曲线
void RefreshElectrocardiogram(void); // 刷新心率曲线
void ClearElectrocardiogram(void); // 清空心率曲线
void RefreshHeartRatePerSec(uint16_t value); // 刷新每秒心率
void RefreshHeartRateMax(uint16_t max); // 刷新心率最大值
void RefreshHeartRateMin(uint16_t min); // 刷新心率最小值
void RefreshRestHeartRate(uint16_t value); // 刷新静息心率
void HeartbeatImageAnimatorStart(void); // 心形动画启动
void HeartbeatImageAnimatorStop(void); // 心形动画停止
void InitRefreshInterface(void);
private:
typedef struct {
uint8_t fontSize;
int16 x;
int16 y;
int16 width;
int16 height;
} LabelInfo;
int32_t InitHeartRateData(void);
void SetLabel(UILabel *label, LabelInfo labelInfo);
void HeartRateLabelDisplay(void);
void HeartRateCoordinate(void);
void HeartRateElectrocardiogram(void);
void InsertTopAndBottomRateImage(void);
void UpdataTopAndBottomRate(void);
void ElectrocardiogramOnePoint(Point *rateData, uint16_t index);
void ElectrocardiogramMultiPoint(Point *rateData, uint16_t rateDataNume);
int32_t HeartRateDataProc(void);
void HeartbeatImageAnimator(void);
private:
Point heartRateData[HEART_AVE_NUM];
Point rateDataTmp[HEART_AVE_NUM];
bool viewiInitStatus{false};
bool resLoadStatus{false};
UIChartPolyline *chart{nullptr};
uint16_t dataNume; // 心率曲线记录数据总个数
uint16_t currIndex; // 当前已显示心率曲线心率个数
UIChartDataSerial *dataSerial[HEART_AVE_NUM]{nullptr};
UIChartDataSerial *dataTopAndbottom{nullptr};
UIImageView *imageViewTop{nullptr};
UIImageView *imageViewBottom{nullptr};
uint16_t serialIndex;
UIImageAnimatorView *imageAnimator{nullptr};
UIImageView *imageViewCoordinate{nullptr};
UILabel *topRate{nullptr};
UILabel *bottomRate{nullptr};
UILabel *ratePerSec{nullptr};
UILabel *ratePerSecText{nullptr};
UILabel *restRate{nullptr};
UILabel *restRateText1{nullptr};
UILabel *restRateText2{nullptr};
uint16_t maxRate;
uint16_t minRate;
};
} // namespace OHOS
#endif // HEART_RATE_VIEW_H