From: luozheng <1732036298@qq.com> Date: Tue, 3 Feb 2026 10:51:04 +0000 (+0800) Subject: 修复活动界面里程错误计算问题 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=5823a6a5e206e41f8ed7f35ad1e7a9a9c184c84e;p=mirrors%2FFD230.git 修复活动界面里程错误计算问题 --- diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/goal/include/goalmodel.h b/code/sdk/application/wearable/fd272/nativeapp/nativeui/goal/include/goalmodel.h index bbe14dfa7..c22fc73b9 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/goal/include/goalmodel.h +++ b/code/sdk/application/wearable/fd272/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/fd272/nativeapp/nativeui/goal/src/goalmodel.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/goal/src/goalmodel.cpp index c414efb9a..5415189fb 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/goal/src/goalmodel.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/goal/src/goalmodel.cpp @@ -412,7 +412,9 @@ 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}; @@ -455,8 +457,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); @@ -534,6 +536,7 @@ namespace OHOS + //步数 uint32_t GoalModel::show_data_step_refresh(void) { int32_t value=0; 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 0caf087ac..3d80cd940 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; //存燃脂数据 @@ -914,9 +914,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; @@ -926,18 +923,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; @@ -950,6 +941,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) @@ -960,9 +995,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; @@ -972,18 +1004,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; @@ -1775,6 +1801,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 c9bdfff9b..0c19369c0 100644 --- a/code/sdk/zhihui/drivers/cywee/dml/cywee_hal.h +++ b/code/sdk/zhihui/drivers/cywee/dml/cywee_hal.h @@ -197,6 +197,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);