#1233 手表,室外跑步,APP运动数据中目标显示0公里,手表设置的是1公里目标提醒
authorCaisking <3449750381@qq.com>
Mon, 9 Dec 2024 02:44:06 +0000 (10:44 +0800)
committerCaisking <3449750381@qq.com>
Mon, 9 Dec 2024 02:44:06 +0000 (10:44 +0800)
code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp

index 10326b1..8b7db00 100644 (file)
@@ -1242,7 +1242,10 @@ bool TraingModel::SaveSportData() {
   data.st = static_cast<uint32_t>(sportdata->starttime);
   data.sp = static_cast<uint32_t>(sportdata->endtime);
   data.tgt = static_cast<uint32_t>(sportdata->sportTagType);
-  data.tg = static_cast<uint32_t>(sportdata->tag);
+  if (sportdata->sportTagType == ExerciseTag::Duration)
+    data.tg = static_cast<uint32_t>((sportdata->tag) * 1000);
+  else
+    data.tg = static_cast<uint32_t>(sportdata->tag);
   data.pg = static_cast<uint32_t>(sportdata->goaldegree);
   data.du = static_cast<uint32_t>(sportdata->duration);
   data.ca = static_cast<uint32_t>(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 被执行。");
 }