From 8104d24d660ffda059293bf9f32a99243d78ad4d Mon Sep 17 00:00:00 2001 From: Caisking Date: Wed, 18 Mar 2026 16:45:01 +0800 Subject: [PATCH] =?utf8?q?=E4=BF=AE=E6=94=B9=E9=85=8D=E9=80=9F=E4=B8=BA?= =?utf8?q?=E5=AE=9E=E6=97=B6=E9=85=8D=E9=80=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/traing/src/TraingModel.cpp | 134 ++++++++++-------- 1 file changed, 75 insertions(+), 59 deletions(-) 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 9d083f598..ba610bd2b 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 @@ -500,6 +500,39 @@ } #ifdef SUPPORT_CYWEE_SERVICE +/* +//基本运动数据结构体 + typedef struct +{ + int activity_mode;//模式 + int steps;//步数 + int distance;//距离 + int calories;//卡路里 + int step_frequency;//步频 + float step_length;//步幅 + int pace;//配速 + int BMR_calories;//基础卡路里 + // int hrs;//心率 + int duration;//持续时间 + int MHR_zone;//心率区间 +}act_result_t; + +//运动额外数据结构体 +typedef struct +{ + int avg_step_freq;//平均步频 + float avg_step_len;//平均步长 + int avg_pace;//平均配速 + int max_step_freq;//最大步频 + int max_pace;//最大配速 + int activity_zone;//活动程度区间 0低度 1中度 2高度 + int ativity_zone_moderate_duration;//中度活动时间 + int ativity_zone_high_duration;//高度活动时间 + int MHR_zone;//心率区间 + int distance_motion;//体感距离 +}act_ext_result_t; +*/ + /*分析数据*/ void TraingModel::AnalysisData(act_result_t *cyweeInfo) { if (cyweeInfo == NULL) @@ -516,70 +549,53 @@ sportdata->steps = cyweeInfo->steps; sportdata->distance = cyweeInfo->distance; sportdata->calories = cyweeInfo->calories; - // 骑行等距离不在实时补算,结束时在 SaveSportData 里用 GPS 轨迹一次性计算 - - // sportdata->cdc = cyweeInfo->step_frequency; - // sportdata->std = cyweeInfo->step_length; - - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, " pace %d", sportdata->pc); - // 通过距离和时间自己计算配速,而不是使用CYWEE提供的配速 - // 配速单位:秒/公里 - // 计算公式:配速 = 时间(秒) * 1000 / 距离(米) - int calculatedPace = 0; +#if 0 + // 通过距离和时间自己计算配速 + // 配速 = 总时间(秒) * 1000 / 总距离(米) if (sportdata->distance > 0 && sportdata->duration > 0) { - // 距离单位是米,需要转换为公里:距离(公里) = 距离(米) / 1000 - // 配速(秒/公里) = 时间(秒) / 距离(公里) = 时间(秒) * 1000 / 距离(米) - calculatedPace = (sportdata->duration * 1000) / sportdata->distance; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, - "CalculatePace: distance=%d米, duration=%d秒, calculatedPace=%d秒/公里", - sportdata->distance, sportdata->duration, calculatedPace); - } else { - // 如果距离或时间为0,使用CYWEE提供的配速作为后备 - calculatedPace = cyweeInfo->pace; + int calculatedPace = (sportdata->duration * 1000) / sportdata->distance; + sportdata->pc = calculatedPace; WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, - "CalculatePace: 距离或时间为0,使用CYWEE配速=%d", calculatedPace); + "CalculatePace: distance=%d米, duration=%d秒, pace=%d秒/公里", + sportdata->distance, sportdata->duration, calculatedAvgPace); + } else if (cyweeInfo->avg_pace != 0) { + // 如果距离或时间为0,使用CYWEE提供的平均配速作为后备 + sportdata->pc = cyweeInfo->pace; } - - sportdata->pc = calculatedPace; +#else + sportdata->pc = cyweeInfo->pace; +#endif - // 更新最慢配速 - if (sportdata->spc < sportdata->pc && sportdata->pc != 0) { - sportdata->spc = sportdata->pc; - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "spc %d", sportdata->spc); - - -#if 1 - // 心率提醒 目前取值有问题,暂时关闭 - if (sportdata->heart >= user_maxHeart && user_maxHeart != 0) { - uapi_set_screen_on_api(); // 亮屏检测 - 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 (sportdata->heart >= user_maxHeart && user_maxHeart != 0) { + uapi_set_screen_on_api(); // 亮屏检测 + 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( - std::bind(&TraingCardView::SetPopupViewStatus, - TraingCardView::GetInstance(), HeartPopup, true)); - if (TraingCardView::GetInstance()->GetHeartMaxLabel()) { - GraphicService::GetInstance()->PostGraphicEvent( - std::bind(&TraingCardView::SetHeartMaxLabel, - TraingCardView::GetInstance(), user_maxHeart)); - } - } - } - #endif + } + } + if (TraingCardView::GetInstance()) { + GraphicService::GetInstance()->PostGraphicEvent( + std::bind(&TraingCardView::SetPopupViewStatus, + TraingCardView::GetInstance(), HeartPopup, true)); + if (TraingCardView::GetInstance()->GetHeartMaxLabel()) { + GraphicService::GetInstance()->PostGraphicEvent( + std::bind(&TraingCardView::SetHeartMaxLabel, + TraingCardView::GetInstance(), user_maxHeart)); + } + } + } + } #endif @@ -1952,8 +1968,8 @@ bool TraingModel::GetMomentum() { AddHeartRateData(timestamp, sportdata->heart); //特殊运动才存储配速数据 if (OHOS::TraingModel::GetInstance()->GetIsSpecial()) { - if (sportdata->apc != 0) - AddPaceData(timestamp, sportdata->apc); + if (sportdata->pc != 0) + AddPaceData(timestamp, sportdata->pc); } } } -- 2.17.1