From aa2d1284fae73338d9b46784d4bf48dfd76ddd17 Mon Sep 17 00:00:00 2001 From: Caisking <3449750381@qq.com> Date: Tue, 19 Nov 2024 20:55:57 +0800 Subject: [PATCH] =?utf8?q?=E8=AE=AD=E7=BB=83=EF=BC=9A=E4=BC=98=E5=8C=96?= =?utf8?q?=E8=AE=AD=E7=BB=83=E9=85=8D=E9=80=9F=E8=A1=A8=E5=BF=83=E7=8E=87?= =?utf8?q?=E8=A1=A8=E6=95=B0=E6=8D=AE=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/traing/src/TraingModel.cpp | 44 ++++++++++++------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp index 042ad84ca..9aba0afd4 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp @@ -48,6 +48,8 @@ #include #include +#include "bleService.h" + extern "C" errcode_t uapi_get_timestampe_ms(uint32_t *tm); #ifdef __cplusplus @@ -591,6 +593,9 @@ void TraingModel::SetTimestamp() { if (currentState == ExerciseState::Start && !Startstate) { // 设置训练 runtime 为 1 训练中 uapi_dev_runtime_set_train_status(1); + if (Openingway) { + uapi_ble_connect_param_update(10); + } // 更新用户数据 SetUserSportdata(); @@ -630,6 +635,9 @@ void TraingModel::SetTimestamp() { } else if (currentState == ExerciseState::End && !Endstate) { // 设置训练 runtime 为 0 训练结束 uapi_dev_runtime_set_train_status(0); + if (Openingway) { + uapi_ble_connect_param_update(50); + } sportdata->endtime = time; @@ -640,7 +648,7 @@ void TraingModel::SetTimestamp() { // 记录运动数据 // RecordSportData(); - + //配置最后的训练强度(平均心率为标准) SetIntensity(sportdata->avgheart); @@ -1259,7 +1267,7 @@ bool TraingModel::SaveSportData() { // 保存心率表 if (!SaveHeartTable()) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SaveHeartRateData is error!"); - // uapi_dev_runtime_set_train_storage_status(0); // 恢复状态 + // uapi_dev_runtime_set_train_storage_status(0); // 恢复状态 // return false; } // 保存速度表 @@ -1421,7 +1429,7 @@ void TraingModel::PrintPaceTable() { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Pace Table:"); for (const auto &entry : paceTable) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "时间戳: %u, 配速: %.2f", + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "时间戳: %u, 配速: %d", entry.timestamp, entry.pace); } } @@ -1618,25 +1626,25 @@ std::string TraingModel::DisplayMotionDuration() { motionDuration = oss.str(); - // 获取当前时间(以微秒为单位) - uint32_t currentTime = static_cast( - std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch()) - .count()); + // // 获取当前时间(以微秒为单位) + // uint32_t currentTime = static_cast( + // std::chrono::duration_cast( + // std::chrono::system_clock::now().time_since_epoch()) + // .count()); - // 记录和检查上一次调用的时间 - static uint32_t lastCallTime = 0; - if (currentTime - lastCallTime < 1000000) { // 小于1秒 - return motionDuration; - } - lastCallTime = currentTime; // 更新最后调用时间 + // // 记录和检查上一次调用的时间 + // static uint32_t lastCallTime = 0; + // if (currentTime - lastCallTime < 1000000) { // 小于1秒 + // return motionDuration; + // } + // lastCallTime = currentTime; // 更新最后调用时间 // 如果 g_motionTimes 不为零,进行计算和数据存储 if (g_motionTimes > 0) { sportdata->duration = g_motionTimes; // 设置训练时长 // 每分钟进行配速和心率数据存储 - StoreDataIfMinutePassed(); + // StoreDataIfMinutePassed(); } return motionDuration; // 返回格式化的运动时长 @@ -1656,7 +1664,7 @@ void TraingModel::SendLiveDataIfNecessary() { // 每10秒进行配速和心率数据存储 void TraingModel::StoreDataIfMinutePassed() { - if (sportdata->duration % 10 == 0) { + if (sportdata->duration % 5 == 0) { uint32_t timestamp; //进行数据的筛选 if (uapi_get_timestampe_ss(×tamp) == ERRCODE_SUCC) { @@ -1683,6 +1691,10 @@ void TraingTimerCallback() { OHOS::TraingModel::GetInstance()->SendLiveDataIfNecessary(); // 更新时间目标完成度 OHOS::TraingModel::GetInstance()->CheckTimeTag(); + // 特殊运动才存储心率配速表 + if (OHOS::TraingModel::GetInstance()->GetIsSpecial()) + OHOS::TraingModel::GetInstance() + ->StoreDataIfMinutePassed(); //存储心率配速表 if ((sportdata->goaldegree >= 100) && (shock_count < 4)) { shock_count++; -- 2.17.1