From: luozheng <1732036298@qq.com> Date: Fri, 13 Mar 2026 02:38:07 +0000 (+0800) Subject: 修复活动界面里程错误计算问题 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=8d1ba9c0d664a21a592655b2060160d2903f3124;p=mirrors%2FFD230.git 修复活动界面里程错误计算问题 --- diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/goal/include/goalmodel.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/goal/include/goalmodel.h index bbe14dfa7..c22fc73b9 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/goal/include/goalmodel.h +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/goal/include/goalmodel.h @@ -92,7 +92,6 @@ namespace OHOS GoalModel(const GoalModel &) = delete; GoalModel &operator=(const GoalModel &) = delete; virtual ~GoalModel(); - bool WEATHER_DATA_VALID{false}; // 天气数据是否有效 }; } diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/goal/src/goalmodel.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/goal/src/goalmodel.cpp index b4a09ea64..f06a28386 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/goal/src/goalmodel.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/goal/src/goalmodel.cpp @@ -413,7 +413,7 @@ namespace OHOS // return 0; } - float GoalModel::goal_parse_distance_data(void) + float GoalModel::goal_parse_distance_data(void) { char path_[64]={0}; char timeday[12] = {0}; @@ -456,8 +456,8 @@ namespace OHOS // uint8_t memcpy(&timetemp,date+i*8,4); memcpy(&sing_date,date+i*8+4,4); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "time: %d", timetemp); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "data: %f", sing_date); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "time: %d", timetemp); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "data: %f", sing_date); struct tm *timeinfo; timeinfo = localtime((time_t *) &timetemp); diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/sleep/src/SleepModel.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/sleep/src/SleepModel.cpp index 22db1f507..0a6a0ee55 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/sleep/src/SleepModel.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/sleep/src/SleepModel.cpp @@ -390,7 +390,7 @@ namespace OHOS OHOS::SleepModel::GetInstance().set_sleep_total(sleep_total); OHOS::SleepModel::GetInstance().set_nap_total(nap_total); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ReadSleepData sleepStr %u wakeStr %u sleep_total_time %d", sleep_fall_asleep_timestamp, sleep_wake_up_timestamp, sleep_total_time); @@ -417,7 +417,7 @@ namespace OHOS napwakeStr = "--"; } - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ReadSleepData sleepStr %s wakeStr %s sleep_total_time %d nap_total_time %d napsleepStr %s napwakeStr %s", sleepStr.c_str(), wakeStr.c_str(), sleep_total_time, nap_total_time, napsleepStr.c_str(), napwakeStr.c_str()); } @@ -657,7 +657,7 @@ namespace OHOS int goal_sleep = get_sleep_time_from_config_model(); int goal_wake = get_wake_up_time_from_config_model(); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "goal_sleep:%d goal_wake:%d", + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "goal_sleep:%d goal_wake:%d", goal_sleep, goal_wake); /* -------------------------------------------------------------------------- */ diff --git a/code/sdk/zhihui/drivers/cywee/dml/cywee_data.c b/code/sdk/zhihui/drivers/cywee/dml/cywee_data.c index 094a7de9b..8a89aadb2 100644 --- a/code/sdk/zhihui/drivers/cywee/dml/cywee_data.c +++ b/code/sdk/zhihui/drivers/cywee/dml/cywee_data.c @@ -264,12 +264,12 @@ void cywee_save_data(void) int step = cywee_get_sport_data(STEP) + cywee_get_sport_data(HISTORY_STEP); int calories = cywee_get_sport_data(NEW_CALORIES) + cywee_get_sport_data(HISTORY_CALORIES); - int distances = cywee_get_sport_data(NEW_DISTANCE) + cywee_get_sport_data(HISTORY_DISTANCE); + float distances = cywee_get_sport_data_float(NEW_DISTANCE) + cywee_get_sport_data_float(HISTORY_DISTANCE); int fat = cywee_get_sport_data(NEW_FAT) + cywee_get_sport_data(HISTORY_FAT); int history_step_ = cywee_get_sport_data(HISTORY_STEP_); int history_calories_ = cywee_get_sport_data(HISTORY_CALORIES_); - int history_distances_ = cywee_get_sport_data(HISTORY_DISTANCE_); + float history_distances_ = cywee_get_sport_data_float(HISTORY_DISTANCE_); int history_fat_ = cywee_get_sport_data(HISTORY_FAT_); CWM_OS_saveData(&step,sizeof(int),STEP); @@ -291,12 +291,12 @@ void cywee_restoreData(void) { int history_step = 0; int history_calories = 0; - int history_distances = 0; + float history_distances = 0; int history_fat = 0; int history_step_ = 0; int history_calories_ = 0; - int history_distances_ = 0; + float history_distances_ = 0; int history_fat_ = 0; CWM_OS_restoreData(&history_step,sizeof(int),STEP); @@ -312,8 +312,8 @@ void cywee_restoreData(void) CWM_OS_restoreData(&history_distances,sizeof(int),DISTANCE); CWM_OS_OneHourAgo_restoreData(&history_distances_,sizeof(float),DISTANCE); - cywee_set_sport_data(history_distances,HISTORY_DISTANCE); - cywee_set_sport_data(history_distances_,HISTORY_DISTANCE_); + cywee_set_sport_data_float(history_distances,HISTORY_DISTANCE); + cywee_set_sport_data_float(history_distances_,HISTORY_DISTANCE_); CWM_OS_restoreData(&history_fat,sizeof(int),FAT); CWM_OS_OneHourAgo_restoreData(&history_fat_,sizeof(uint16_t),FAT); @@ -631,6 +631,7 @@ static void CWM_OS_saveData_history(void* new_data,void *history ,uint32_t len,u else if(f_data) *(float*)history=*(float*)new_data; + // printf("CWM_OS_saveData_history %d %d\n",*(int*)history,*(int*)new_data); } static void CWM_OS_saveData_STAND_history(uint8_t *falg,uint32_t len,uint32_t time) @@ -767,8 +768,9 @@ int32_t cywee_get_now_hour_data(void*value, uint8_t type) return 1; case DISTANCE: - data= cywee_get_sport_data(HISTORY_DISTANCE) + cywee_get_sport_data(NEW_DISTANCE); - f_data=(float)data/1000.0-cywee_get_sport_data(HISTORY_DISTANCE_); + f_data= cywee_get_sport_data_float(HISTORY_DISTANCE) + cywee_get_sport_data_float(NEW_DISTANCE); + printf("cywee_get_now_hour_data DISTANCE %f %f %f %f\n",cywee_get_sport_data_float(HISTORY_DISTANCE),cywee_get_sport_data_float(NEW_DISTANCE),cywee_get_sport_data_float(HISTORY_DISTANCE_),f_data); + f_data=f_data/1000.0-cywee_get_sport_data_float(HISTORY_DISTANCE_); if(f_data<0) return 0; memcpy_s(value,4,&f_data,4); @@ -800,12 +802,13 @@ void cywee_calories_history_save(uint32_t time) void cywee_distances_history_save(uint32_t time) { - int data= cywee_get_sport_data(HISTORY_DISTANCE) + cywee_get_sport_data(NEW_DISTANCE); - float history_distances_now = (float)data / 1000.0; - float history_distances_ = cywee_get_sport_data(HISTORY_DISTANCE_); + float data= cywee_get_sport_data_float(HISTORY_DISTANCE) + cywee_get_sport_data_float(NEW_DISTANCE); + float history_distances_now = data / 1000.0; + float history_distances_ = cywee_get_sport_data_float(HISTORY_DISTANCE_); // CWM_OS_dbgPrintf("history_distances is saving\n"); CWM_OS_saveData_history(&history_distances_now,&history_distances_,sizeof(float),DISTANCE,time); - cywee_set_sport_data(history_distances_,HISTORY_DISTANCE_); + // printf("cywee_distances_history_save %f %f\n",history_distances_now,history_distances_); + cywee_set_sport_data_float(history_distances_,HISTORY_DISTANCE_); } void cywee_fat_history_save(uint32_t time) diff --git a/code/sdk/zhihui/drivers/cywee/dml/cywee_dml.c b/code/sdk/zhihui/drivers/cywee/dml/cywee_dml.c index e20c5c58d..55ad7b450 100644 --- a/code/sdk/zhihui/drivers/cywee/dml/cywee_dml.c +++ b/code/sdk/zhihui/drivers/cywee/dml/cywee_dml.c @@ -61,8 +61,8 @@ static int new_calories = 0; //存卡路里数据 static int history_calories = 0; // static float history_calories_ = 0;//一小时前卡路里数据 -static int new_distance=0; //存距离数据 -static int history_distances=0; //历史数据 +static float new_distance=0; //存距离数据 +static float history_distances=0; //历史数据 static float history_distances_=0; //一小时前距离数据 static int new_fat=0; //存燃脂数据 @@ -907,9 +907,6 @@ uint32_t cywee_get_sport_data(uint8_t type) case HISTORY_STEP: data = history_step; break; - case HISTORY_DISTANCE: - data = history_distances; - break; case HISTORY_CALORIES: data = history_calories; break; @@ -919,18 +916,12 @@ uint32_t cywee_get_sport_data(uint8_t type) case HISTORY_STEP_: data = history_step_; break; - case HISTORY_DISTANCE_: - data = history_distances_; - break; case HISTORY_CALORIES_: data = history_calories_; break; case HISTORY_FAT_: data = history_fat_; break; - case NEW_DISTANCE: - data = new_distance; - break; case NEW_CALORIES: data = new_calories; break; @@ -943,6 +934,50 @@ uint32_t cywee_get_sport_data(uint8_t type) return data; } +float cywee_get_sport_data_float(uint8_t type) +{ + float data = 0.0; + switch (type) + { + case HISTORY_DISTANCE: + data = history_distances; //历史数据 + printf("history_distances : %f \n",data); + break; + case NEW_DISTANCE: + data = new_distance; //新距离数据 + printf("new_distance : %f \n",data); + break; + case HISTORY_DISTANCE_: + data = history_distances_; //一小时前距离数据 + printf("history_distances_ : %f \n",data); + break; + default: + break; + } + return data; +} + +void cywee_set_sport_data_float(float data,uint8_t type) +{ + switch (type) + { + case HISTORY_DISTANCE: + history_distances = data;//历史数据 + printf("history_distances : %f \n",data); + break; + case NEW_DISTANCE: + new_distance = data; //新距离数据 + printf("new_distance : %f \n",data); + break; + case HISTORY_DISTANCE_: + history_distances_ = data;//一小时前距离数据 + printf("history_distances_ : %f \n",data); + break; + default: + break; + } +} + void cywee_set_sport_data(uint32_t data,uint8_t type) { switch (type) @@ -953,9 +988,6 @@ void cywee_set_sport_data(uint32_t data,uint8_t type) case HISTORY_STEP: history_step = data; break; - case HISTORY_DISTANCE: - history_distances = data; - break; case HISTORY_CALORIES: history_calories = data; break; @@ -965,18 +997,12 @@ void cywee_set_sport_data(uint32_t data,uint8_t type) case HISTORY_STEP_: history_step_ = data; break; - case HISTORY_DISTANCE_: - history_distances_ = data; - break; case HISTORY_CALORIES_: history_calories_ = data; break; case HISTORY_FAT_: history_fat_ = data; break; - case NEW_DISTANCE: - new_distance = data; - break; case NEW_CALORIES: new_calories = data; break; @@ -1750,6 +1776,7 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) { new_calories = c_act_result_t.calories; new_distance = c_act_result_t.distance; + // printf("stepcount %d new_calories %d new_distance %d\n",stepcount,new_calories,new_distance); // c_act_result_t.hrs = hrs; // hrs = 0; //每次上报完 清除心率值 diff --git a/code/sdk/zhihui/drivers/cywee/dml/cywee_hal.h b/code/sdk/zhihui/drivers/cywee/dml/cywee_hal.h index fdca7a711..bcea68079 100644 --- a/code/sdk/zhihui/drivers/cywee/dml/cywee_hal.h +++ b/code/sdk/zhihui/drivers/cywee/dml/cywee_hal.h @@ -196,6 +196,8 @@ void cywee_custom_save_wear_data(void); uint32_t cywee_get_sport_data(uint8_t type); void cywee_set_sport_data(uint32_t data,uint8_t type); +float cywee_get_sport_data_float(uint8_t type); +void cywee_set_sport_data_float(float data,uint8_t type); int cywee_start(void); void cywee_sensor_stop(void);