From: Caisking <3449750381@qq.com> Date: Wed, 26 Jun 2024 08:59:47 +0000 (+0800) Subject: 心率血氧卡片优化 X-Git-Tag: release_V1.2.70_20241020_135402~948^2~2^2~1^2~4 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=0ae1063358c7f6223d31064c37b2d6a771e6fc8d;p=mirrors%2FFD230.git 心率血氧卡片优化 --- diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index 33ca91d7b..d07b47e96 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -285,8 +285,7 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/key/src/KeyInputListener.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/screennotify/src/ui_screennotify.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/heart_blood/src/BloodCardView.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/heart_blood/src/HeartCardView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/heart_blood/BloodCardView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/heart_blood/health_service/health_service.cpp diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h index d46d2980d..3ef50537c 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h @@ -82,6 +82,7 @@ typedef enum : uint16_t VIEW_SET_CARD, // 卡片管理 VIEW_ADD_CARD, // 添加卡片 VIEW_SET_DIAL, // 切换表盘 + VIEW_SET_HEART, // 设置心率周期检测 /* ----------------------------------- 训练 ----------------------------------- */ VIEW_TRAINING, // 训练 VIEW_TRAININGNOMAL, // 正常训练开始界面(除骑行,健走,跑步外) diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h index 6e9fc2fdc..cb8cd11c3 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h @@ -75,6 +75,7 @@ namespace OHOS void InitMessageShowSlice(void); void InitTakePhotosSlice(void); void InitSleepSlice(void); + void InitSetHeartSlice(void); /* ----------------------------------- 训练 ----------------------------------- */ void InitTraingSlice(void); void InitTraingNomalSlice(void); diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenView.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenView.cpp index 6ee4c6ed9..d75edf6c0 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenView.cpp @@ -88,7 +88,7 @@ namespace OHOS // 更新数据 std::string bloodoxygenStr = std::to_string(spo2); percent->SetText(bloodoxygenStr.c_str()); - + // 获取时间差 uint32_t time = BloodOxygenPresenter::GetInstance()->GetCurrentTime(); uint32_t check_time = BloodOxygenModel::GetInstance()->GetCheckTime(); @@ -100,7 +100,7 @@ namespace OHOS } else if (time_diff <= 60) { - UpdateLabel(timeLabel, time_diff,STR_CHECKNO); + UpdateLabel(timeLabel, time_diff, STR_CHECKTIME); } else { diff --git a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/BloodCardView.cpp b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/BloodCardView.cpp index 843989e31..5e78deca0 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/BloodCardView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/BloodCardView.cpp @@ -39,22 +39,35 @@ namespace OHOS void BloodCardView::UpSPO2Text() { // 更新血氧数据 - uint16_t spo2_ = BloodOxygenModel::GetInstance()->GetSPO2data(); - if (spo2_ != 0) // 判断是否为默认数据 + uint16_t spo2 = BloodOxygenModel::GetInstance()->GetSPO2data(); + if (spo2 != 0) // 判断是否为默认数据 { // 更新数据 - std::string bloodoxygenStr = std::to_string(spo2_); + std::string bloodoxygenStr = std::to_string(spo2); bloodLabel->SetText(bloodoxygenStr.c_str()); - // 更新时间 + + // 获取时间差 uint32_t time = BloodOxygenPresenter::GetInstance()->GetCurrentTime(); uint32_t check_time = BloodOxygenModel::GetInstance()->GetCheckTime(); - std::string TimeStr = BloodOxygenPresenter::GetInstance()->GetTDOA(time, check_time) + "检测"; - timeLabel->SetText(TimeStr.c_str()); + int time_diff = BloodOxygenPresenter::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 { bloodLabel->SetText("--"); - timeLabel->SetText("暂无检测结果"); + timeLabel->SetTextId(STR_CHECKNO); } } @@ -104,7 +117,7 @@ namespace OHOS Add(bloodLabel); /* -------------------------------------------------------------------------- */ - timeLabel = new UILabel(); + timeLabel = new UILabelExt(); if (timeLabel == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::new timeLabel fail"); @@ -114,19 +127,6 @@ namespace OHOS timeLabel->Resize(280, 100); // widget's width and height timeLabel->SetViewId("label1"); // Set style timeLabel->SetStyle(STYLE_TEXT_FONT, 30); - if (bloodoxygen != 0) - { - // 更新时间 - uint32_t time = BloodOxygenPresenter::GetInstance()->GetCurrentTime(); - uint32_t check_time = BloodOxygenModel::GetInstance()->GetCheckTime(); - std::string TimeStr = BloodOxygenPresenter::GetInstance()->GetTDOA(time, check_time) + "检测"; - timeLabel->SetText(TimeStr.c_str()); - } - else - { - timeLabel->SetText("暂无测量记录"); - } - /* -------------------------------------------------------------------------- */ timeLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); timeLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); timeLabel->SetRollSpeed(0); @@ -135,6 +135,8 @@ namespace OHOS // Add to rootView Add(timeLabel); + UpSPO2Text(); + // Add Label to App if (titleLabel == nullptr) { diff --git a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/BloodCardView.h b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/BloodCardView.h index 68841c390..6751d5556 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/BloodCardView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/BloodCardView.h @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-06-26 16:13:19 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-06-26 16:52:01 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/heart_blood/BloodCardView.h + */ #ifndef _Blood_CARD_VIEW_H #define _Blood_CARD_VIEW_H @@ -50,7 +56,7 @@ namespace OHOS UILabelButton *monitorButton = nullptr; UILabel *titleLabel = nullptr; UILabel *bloodLabel = nullptr; - UILabel *timeLabel = nullptr; + UILabelExt *timeLabel = nullptr; bool viewiInitStatus{false}; bool resLoadStatus{false}; diff --git a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartRateView.cpp b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartRateView.cpp index 4cf64b21a..422e5243e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartRateView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartRateView.cpp @@ -612,7 +612,6 @@ namespace OHOS viewiInitStatus = true; } } - if (!resLoadStatus) { ScreenModels::GetInstance()->LoadAppImages(HEART_IAMGES, imageViewTop, HEART_HEARTRATE_TOP); @@ -865,4 +864,110 @@ namespace OHOS } } } +#if 0 +#ifdef __cplusplus + extern "C" + { +#endif + /* 定时器回调函数 */ + void HeartTimerCallback() + { + g_motionTimes++; + HeartCardPresenter *gHeartCardPresenter = HeartPresenter::GetInstance(); + if (gHeartCardPresenter == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartTimerCallback::gHeartCardPresenter new fail"); + return; + } + // gHeartCardPresenter->ModifiesTime(); + PRINT("HeartTimerCallback\r\n"); + } + + /* 开启定时器 */ + void InitTimer(void) + { + if (g_startCounting != NULL) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HeartModel::HeartTimer already exists!!"); + return; + } + g_startCounting = osTimerNew((osTimerFunc_t)HeartTimerCallback, osTimerPeriodic, NULL, NULL); + if (g_startCounting == NULL) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartModel::HeartTimer osTimerNew failed!!"); + return; + } + int tick = osMs2Tick(MS_ONE_SECONDS); + osStatus_t retTimer = osTimerStart(g_startCounting, tick); + if (retTimer != osOK) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartModel::HeartTimer osTimerStart failed, ret = %lx!!", retTimer); + if (g_startCounting != NULL) + { + retTimer = osTimerDelete(g_startCounting); + if (retTimer != osOK) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartModel::osTimerDelete failed, ret = %lx!!", retTimer); + return; + } + g_startCounting = NULL; + } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitTimer!"); + return; + } + } + /* 关闭定时器 */ + void DisableTimer(void) + { + if (g_startCounting != NULL) + { + osStatus_t ret = osTimerDelete(g_startCounting); + if (ret != osOK) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ScanTimerCallback osTimerDelete failed, ret = %lx!!", ret); + return; + } + g_startCounting = NULL; + PRINT("g_motionTimes:%d\r\n", sportdata->duration); + g_motionTimes = 0; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DisableTimer!"); + } + } + /* 暂停定时器 */ + void PauseTimer(void) + { + // 检查定时器是否存在 + if (g_startCounting != NULL) + { + // 暂停定时器,但不删除它 + osStatus_t ret = osTimerStop(g_startCounting); + if (ret != osOK) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StopWatch_PauseTimer osTimerStop failed, ret = %lx!!", ret); + } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PauseTimer!"); + } + } + + /*恢复定时器*/ + void ResumeTimer(void) + { + // 检查定时器是否存在 + if (g_startCounting != NULL) + { + int tick = osMs2Tick(MS_ONE_SECONDS); + // 恢复定时器 + osStatus_t ret = osTimerStart(g_startCounting, tick); + if (ret != osOK) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ResumeTimer osTimerStart failed, ret = %lx!!", ret); + } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ResumeTimer!"); + } + } + +#ifdef __cplusplus + } +#endif +#endif } // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartView.cpp b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartView.cpp index 40eda2915..d0398a93b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartView.cpp @@ -115,7 +115,7 @@ namespace OHOS } else if (time_diff <= 60) { - UpdateLabel(timeLabel, time_diff, STR_CHECKNO); + UpdateLabel(timeLabel, time_diff, STR_CHECKTIME); } else { diff --git a/code/sdk/application/wearable/fd230app/nativeui/set_card/src/SetMainView.cpp b/code/sdk/application/wearable/fd230app/nativeui/set_card/src/SetMainView.cpp index 63bfdb3f6..3e5b12ef0 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/set_card/src/SetMainView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/set_card/src/SetMainView.cpp @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-06-11 20:17:37 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-06-26 11:25:56 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/set_card/src/SetMainView.cpp + */ /*** * @Date: 2024-06-11 20:17:37 * @LastEditors: Caisking 3449750381@qq.com @@ -31,7 +37,6 @@ namespace OHOS SetMainView::~SetMainView() { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetMainView::~SetMainView"); - RemoveAll(); DeInit(); g_pSetMainView = nullptr; } @@ -87,15 +92,6 @@ namespace OHOS } void SetMainView::UnLoad(void) { -#if 0 - if (resLoadStatus) - { - ImageInfo *img = nullptr; - background->SetSrc(img); - ImageCacheManager::GetInstance().UnloadOneInMultiRes(BLOODOXYGEN_BACKGOUND, BLOOD_IAMGES); - resLoadStatus = false; - } -#endif } /* -------------------------------------------------------------------------- */ } diff --git a/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepCardView.cpp b/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepCardView.cpp index 780c41cf6..62bb9a11e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepCardView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepCardView.cpp @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-06-25 10:41:40 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-06-26 11:27:04 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepCardView.cpp + */ #include "sleep/include/SleepCardView.h" #include "sleep/include/SleepControlView.h" #include "sleep/include/SleepControlPresenter.h" @@ -27,7 +33,7 @@ namespace OHOS delete sleepOnSwipeListener; sleepOnSwipeListener = nullptr; } - + if (sleepcontrolView != nullptr) { delete sleepcontrolView; @@ -62,7 +68,7 @@ namespace OHOS } SleepSwipView->SetOnSwipeListener(sleepOnSwipeListener); Add(SleepSwipView); - + return true; } @@ -78,7 +84,6 @@ namespace OHOS void SleepCardView::UnLoad(void) { - // Weather's usage scenes is complicated, so we do not release it's resources inner slice. } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/Training_CardView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/Training_CardView.cpp index d4cd21c29..ad3d6e50c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/Training_CardView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/Training_CardView.cpp @@ -220,21 +220,19 @@ namespace OHOS { if (!viewiInitStatus) { + // 加载组件 ,加载imagecache InitView(); viewiInitStatus = true; } - // if (!resLoadStatus) - // { - // resLoadStatus = true; - // } } void Training_CardView::UnLoad(void) { - // if (resLoadStatus) - // { - // //ImageCacheManager::GetInstance().UnloadAllInMultiRes(TRAINING_IAMGES); - // resLoadStatus = false; - // } +#if 0 + if (viewiInitStatus) + { + ImageCacheManager::GetInstance().UnloadAllInMultiRes(TRAINING_IAMGES); + } +#endif } }