From f97e4ba36713235e294009d702e052523a711525 Mon Sep 17 00:00:00 2001 From: Caisking Date: Sat, 28 Feb 2026 14:32:22 +0800 Subject: [PATCH] =?utf8?q?=E4=BC=98=E5=8C=96=E8=BF=90=E5=8A=A8=E5=BF=83?= =?utf8?q?=E7=8E=87=E9=9C=87=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../src/MotionRecognitionView.cpp | 2 +- .../nativeui/traing/include/TraingModel.h | 2 ++ .../nativeui/traing/src/TraingModel.cpp | 25 +++++++++++++------ .../training_card/include/TraingCardView.h | 4 +++ .../training_card/src/TraingCardView.cpp | 23 ++++++++++++----- 5 files changed, 42 insertions(+), 14 deletions(-) diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/motionrecognition/src/MotionRecognitionView.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/motionrecognition/src/MotionRecognitionView.cpp index 11d24694d..0fcb52427 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/motionrecognition/src/MotionRecognitionView.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/motionrecognition/src/MotionRecognitionView.cpp @@ -156,7 +156,7 @@ namespace OHOS note->SetStyle(STYLE_TEXT_FONT, 20); note->SetStyle(STYLE_LINE_HEIGHT, 40); note->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); - // note->SetTextId(STR_MOTION_RECOGNITION_NOTE);//开启后,手表会在检测到你处于运动状态时发出提醒。支持的运动包括:走路、跑步、划船机、椭圆机。 + // note->SetTextId(STR_MOTION_RECOGNITION_NOTE);//开启后,手表会在检测到你处于运动状态时发出提醒。支持的运动包括:走路、跑步 、划船机、椭圆机。 if(ConfigModel::GetInstance()->GetLanguage() == 0) { note->SetText("开启后,手表会在检测到你处于运动状态时发出提醒。支持的运动包括:走路、跑步、划船机、椭圆机。"); diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/include/TraingModel.h b/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/include/TraingModel.h index 8cc0af507..30349ee85 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/include/TraingModel.h +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/include/TraingModel.h @@ -464,6 +464,8 @@ private: std::vector gpsData; // GPS数据集 bool gpsconnect{false}; bool gpsopen{false};// GPS是否开启 + int shock_count{0}; //震动次数 + int restshock_count{0}; //震动休息次数 }; } // namespace OHOS diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/src/TraingModel.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/src/TraingModel.cpp index 296f7ebaa..42111224b 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/src/TraingModel.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/src/TraingModel.cpp @@ -495,6 +495,7 @@ return sum / sortedHeartRates.size(); // 返回平均值 } + #ifdef SUPPORT_CYWEE_SERVICE /*分析数据*/ void TraingModel::AnalysisData(act_result_t *cyweeInfo) { @@ -551,11 +552,18 @@ // 心率提醒 目前取值有问题,暂时关闭 if (sportdata->heart >= user_maxHeart && user_maxHeart != 0) { uapi_set_screen_on_api(); // 亮屏检测 - if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && - (!uapi_sleep_mode_flag_get())) { - custom_VibratorFunc_int(0); - custom_VibratorFunc_int(0); - custom_VibratorFunc_int(0); + if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get())) { + if (shock_count < 10 && restshock_count < 5) { + custom_VibratorFunc_int(0); + shock_count++; + restshock_count = 0; + } else { + restshock_count++; + shock_count = 0; + if (restshock_count >= 5) { + restshock_count = 0; /* 休息满 5 次,下一轮可再震 */ + } + } } if (TraingCardView::GetInstance()) { GraphicService::GetInstance()->PostGraphicEvent( @@ -594,7 +602,7 @@ if (isspecialsport_ == false) { return; } - + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[apc:%d fpc:%d cdc:%d std:%d]", cyweeInfo->avg_pace, cyweeInfo->max_pace, cyweeInfo->avg_step_freq, cyweeInfo->avg_step_len); @@ -637,7 +645,7 @@ /*分析运动心率数据*/ void TraingModel::AnalysisHeartData(uint8_t hrs) { sportdata->heart = hrs; - // 计算平均心率 + // 计算平均心率 if (sportdata->heart > 50) { sportdata->avgheart = Averageheartrate(sportdata->heart); SetIntensity(sportdata->avgheart); // 设置训练强度 @@ -730,6 +738,9 @@ void TraingModel::SetSportdata(SportData *data) { gpsData.clear(); // 清空gps数据 canvasData.clear(); // 清空画布数据 + + restshock_count = 0; //重置震动休息计数 + shock_count = 0; //重置震动计数 } uint32_t TraingModel::get_current_time() { diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/training_card/include/TraingCardView.h b/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/training_card/include/TraingCardView.h index e77aa403e..a1284f7c6 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/training_card/include/TraingCardView.h +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/training_card/include/TraingCardView.h @@ -51,6 +51,7 @@ namespace OHOS { enum Control_Card { CONTROL = 0, DATA, MUSIC }; enum PopupType { + None, // 无弹窗 EndPopup, // 结束训练弹窗 GetTagPopup, // 达到训练目标弹窗 HeartPopup, // 达到最高心率弹窗 @@ -134,6 +135,9 @@ private: std::string winbasePath = "/user/res/Training/training_GIF/win/"; const ImageInfo **winimageInfos; ImageAnimatorInfo *winimageAnimatorInfo{nullptr}; + + PopupType currentPopupType = PopupType::None; + bool currentPopupStatus = false; }; } // namespace OHOS #endif // TraingCard_PRESENTER_H diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/training_card/src/TraingCardView.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/training_card/src/TraingCardView.cpp index f2b78335f..75293892b 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/training_card/src/TraingCardView.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/training_card/src/TraingCardView.cpp @@ -785,16 +785,27 @@ void TraingCardView::OnStart() { ////////////////////////////////////////////// #endif } -/*设置弹窗状态*/ +/* +设置弹窗状态 +增加 如果当前已经是这个弹窗状态 不需要设置 + +*/ void TraingCardView::SetPopupViewStatus(PopupType type, bool status) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetPopupViewStatus %d", type); + if (currentPopupType == type && currentPopupStatus == status) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetPopupViewStatus %d already set status %d", type, status); + return; + } + currentPopupType = type; + currentPopupStatus = status; + UIView *popupView = nullptr; - if (type == EndPopup) { + if (currentPopupType == EndPopup) { popupView = endView; - } else if (type == GetTagPopup) { + } else if (currentPopupType == GetTagPopup) { popupView = getView; - } else if (type == HeartPopup) { + } else if (currentPopupType == HeartPopup) { popupView = heartView; } if (popupView == nullptr) { @@ -803,9 +814,9 @@ void TraingCardView::SetPopupViewStatus(PopupType type, bool status) { } UIView *cardview = TraingCardView::GetInstance()->GetTraingCrad(); if (cardview != nullptr) { - cardview->SetVisible(!status); + cardview->SetVisible(!currentPopupStatus); } - popupView->SetVisible(status); + popupView->SetVisible(currentPopupStatus); //刷新 RootView::GetInstance()->Invalidate(); } -- 2.17.1