// return 0;
}
- float GoalModel::goal_parse_distance_data(void)
+
+ //里程
+ float GoalModel::goal_parse_distance_data(void)
{
char path_[64]={0};
char timeday[12] = {0};
// 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);
+ //步数
uint32_t GoalModel::show_data_step_refresh(void)
{
int32_t value=0;
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);
{
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);
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);
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)
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);
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)
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; //存燃脂数据
case HISTORY_STEP:
data = history_step;
break;
- case HISTORY_DISTANCE:
- data = history_distances;
- break;
case HISTORY_CALORIES:
data = history_calories;
break;
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;
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)
case HISTORY_STEP:
history_step = data;
break;
- case HISTORY_DISTANCE:
- history_distances = data;
- break;
case HISTORY_CALORIES:
history_calories = data;
break;
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;
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; //每次上报完 清除心率值