From: Caisking <3449750381@qq.com> Date: Mon, 9 Dec 2024 02:44:06 +0000 (+0800) Subject: #1233 手表,室外跑步,APP运动数据中目标显示0公里,手表设置的是1公里目标提醒 X-Git-Tag: v1.3.113-repair_tp~141^2~25 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=f69a083dcd7b0c766e2820d8bf5568c953218011;p=mirrors%2FFD230.git #1233 手表,室外跑步,APP运动数据中目标显示0公里,手表设置的是1公里目标提醒 --- 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 10326b15d..8b7db0028 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp @@ -1242,7 +1242,10 @@ bool TraingModel::SaveSportData() { data.st = static_cast(sportdata->starttime); data.sp = static_cast(sportdata->endtime); data.tgt = static_cast(sportdata->sportTagType); - data.tg = static_cast(sportdata->tag); + if (sportdata->sportTagType == ExerciseTag::Duration) + data.tg = static_cast((sportdata->tag) * 1000); + else + data.tg = static_cast(sportdata->tag); data.pg = static_cast(sportdata->goaldegree); data.du = static_cast(sportdata->duration); data.ca = static_cast(sportdata->calories * 10); @@ -1713,38 +1716,37 @@ void LogError(const char *msg, osStatus_t ret) { void TraingTimerCallback(void) { // 只在活动状态下进行更新 - if (pauseStartTimestamp == 0) { - //开始时将该值设置为运动开始值 - pauseStartTimestamp = sportdata->starttime; - } + if (pauseStartTimestamp == 0) { + //开始时将该值设置为运动开始值 + pauseStartTimestamp = sportdata->starttime; + } - uint32_t currentTimestamp = - OHOS::TraingModel::GetInstance()->get_current_time(); // 获取当前时间戳 - g_motionTimes = (currentTimestamp - pauseStartTimestamp) + - totalPausedDuration; // 更新运动时间 - sportdata->duration = g_motionTimes; // 更新持续时间 + uint32_t currentTimestamp = + OHOS::TraingModel::GetInstance()->get_current_time(); // 获取当前时间戳 + g_motionTimes = (currentTimestamp - pauseStartTimestamp) + + totalPausedDuration; // 更新运动时间 + sportdata->duration = g_motionTimes; // 更新持续时间 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, - "更新运动时间。当前运动时间: %d %d %d %d", currentTimestamp, - pauseStartTimestamp, totalPausedDuration, g_motionTimes); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, + "更新运动时间。当前运动时间: %d %d %d %d", currentTimestamp, + pauseStartTimestamp, totalPausedDuration, g_motionTimes); - // 检查并发送实时数据 - OHOS::TraingModel::GetInstance()->SendLiveDataIfNecessary(); - OHOS::TraingModel::GetInstance()->CheckTimeTag(); + // 检查并发送实时数据 + OHOS::TraingModel::GetInstance()->SendLiveDataIfNecessary(); + OHOS::TraingModel::GetInstance()->CheckTimeTag(); - // 记录特殊活动的心率/配速数据 - if (OHOS::TraingModel::GetInstance()->GetIsSpecial()) { - OHOS::TraingModel::GetInstance()->StoreDataIfMinutePassed(); - } + // 记录特殊活动的心率/配速数据 + if (OHOS::TraingModel::GetInstance()->GetIsSpecial()) { + OHOS::TraingModel::GetInstance()->StoreDataIfMinutePassed(); + } - // 振动反馈 - if ((sportdata->goaldegree >= 100) && (shock_count < 4)) { - shock_count++; - ui_api_vibrate_once_func(); // 触发振动反馈 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "触发了振动。振动计数: %d", - shock_count); - } - + // 振动反馈 + if ((sportdata->goaldegree >= 100) && (shock_count < 4)) { + shock_count++; + ui_api_vibrate_once_func(); // 触发振动反馈 + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "触发了振动。振动计数: %d", + shock_count); + } WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingTimerCallback 被执行。"); }