From 7d873d5b7a3e1d0ff6fdd2934810767b4d9bee92 Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Mon, 16 Dec 2024 10:20:27 +0800 Subject: [PATCH] =?utf8?q?=E4=BF=AE=E5=A4=8D=E6=AF=8F=E6=97=A5=E7=9B=AE?= =?utf8?q?=E6=A0=87=E6=95=B0=E6=8D=AE=E5=90=8C=E6=AD=A5=E9=97=AE=E9=A2=98?= =?utf8?q?=EF=BC=8C=E5=BD=93=E7=B3=BB=E7=BB=9F=E6=97=B6=E9=97=B4=E5=BC=82?= =?utf8?q?=E5=B8=B8=E4=BB=8D=E6=9C=89=E6=A6=82=E7=8E=87=E5=87=BA=E7=8E=B0B?= =?utf8?q?UG?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/goal/include/goalmodel.h | 30 +-- .../fd230app/nativeui/goal/src/goalmodel.cpp | 191 +++++++++++------- .../fd230app/nativeui/goal/src/goalother.cpp | 32 +-- .../fd230app/nativeui/goal/src/goalview.cpp | 8 +- .../nativeui/main/src/MainPresenterSample.cpp | 2 +- .../peripheral/cywee/src/board_yh601s.c | 27 ++- 6 files changed, 178 insertions(+), 112 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/goal/include/goalmodel.h b/code/sdk/application/wearable/fd230app/nativeui/goal/include/goalmodel.h index c31d672cc..cfcbea17d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/goal/include/goalmodel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/goal/include/goalmodel.h @@ -30,20 +30,20 @@ namespace OHOS uint8_t getstepvalue(); - char* getstepGoal(); - char* getstepnew(); + std::string getstepGoal(); + std::string getstepnew(); - char* getcaloriesGoal(); - char* getcaloriespnew(); + std::string getcaloriesGoal(); + std::string getcaloriespnew(); - char* getdistanceGoal(); - char* getdistancenew(); + std::string getdistanceGoal(); + std::string getdistancenew(); - char* getfatburninggoal(); - char* getfatburningnew(); + std::string getfatburninggoal(); + std::string getfatburningnew(); - char* getstandgoal(); - char* getstandnew(); + std::string getstandgoal(); + std::string getstandnew(); void updata(); void GoalModelInitdata(); uint32_t getstepgoaldata(); @@ -69,11 +69,11 @@ namespace OHOS uint32_t show_data_fat_refresh(void); private: //目标数据 - uint32_t step=0; - uint32_t distance=0; - uint32_t fat=0; - uint32_t calories=0; - uint32_t stand=0; + uint32_t step_goal=0; + uint32_t distanc_goal=0; + uint32_t fat_goal=0; + uint32_t calories_goal=0; + uint32_t stand_goal=0; //展示数据 uint32_t show_step=0; diff --git a/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalmodel.cpp b/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalmodel.cpp index 3ea42edb6..3f4f0d213 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalmodel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalmodel.cpp @@ -14,7 +14,7 @@ #include "goal_notification.h" #include "custom_utils.h" #include "cywee_ble_Service.h" - +// #include "goalmodel.h" namespace OHOS { @@ -37,11 +37,11 @@ namespace OHOS step_goal_show=ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_STEP); other_goal_show=ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_OTHER); - step=ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_STEPCOUNT); - distance=ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_DISTANCE); - fat=ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_DURATION); - calories=ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_CALORIES); - stand=ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_STANDUP_TIMES); + step_goal=ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_STEPCOUNT); + distanc_goal=ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_DISTANCE); + fat_goal=ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_DURATION); + calories_goal=ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_CALORIES); + stand_goal=ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_STANDUP_TIMES); standdata_now=get_now_stand_count(); @@ -59,7 +59,7 @@ namespace OHOS } uint8_t GoalModel::getstepvalue() { - int stepgoal = step; + int stepgoal = step_goal; int stepdata = show_data_step_refresh();//get_step_data();//OHOS::ActivityModel::GetInstance()->GetStepCounter(); // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%d %d %f ",stepdata,stepgoal,((float)stepdata/(float)stepgoal) * 100); uint8_t value = ((float)stepdata / (float)stepgoal) * 100; @@ -73,78 +73,147 @@ namespace OHOS } uint32_t GoalModel::getstepgoaldata() { - return step; + return step_goal; } - char stepgoalstr[20]; - char *GoalModel::getstepGoal() + + std::string GoalModel::getstepGoal() { - int stepgoal = step; - memset((void *)stepgoalstr, 0, 20); - sprintf_s(stepgoalstr, 20, "/%d", stepgoal); + // int stepgoal = step; + // memset((void *)stepgoalstr, 0, 20); + char temp_str[20]={0}; + sprintf_s(temp_str, 20, "/%d", step_goal); + std::string stepgoalstr; + stepgoalstr= temp_str; return stepgoalstr; } - char stepnewstr[20]; - char *GoalModel::getstepnew() + + std::string GoalModel::getstepnew() { + int stepdata = show_data_step_refresh(); - memset((void *)stepnewstr, 0, 20); - sprintf_s(stepnewstr, 20, "%d", stepdata); + char temp_str[20]={0}; + sprintf_s(temp_str, 20, "%d", stepdata); + + std::string stepnewstr=temp_str; + return stepnewstr; } - char caloriesgoalstr[20]; - char *GoalModel::getcaloriesGoal() + + std::string GoalModel::getcaloriesGoal() { - int caloriesdata =calories; - memset((void *)caloriesgoalstr, 0, 20); - sprintf_s(caloriesgoalstr, 20, "/%d", caloriesdata); + std::string caloriesgoalstr; + + int caloriesdata =calories_goal; + char temp_str[20]={0}; + sprintf_s(temp_str, 20, "/%d", caloriesdata); + caloriesgoalstr=temp_str; + return caloriesgoalstr; } - char caloriesnewstr[20]; - char *GoalModel::getcaloriespnew() + + std::string GoalModel::getcaloriespnew() { + std::string caloriesnewstr; + int caloriesdata = show_data_calories_refresh(); + char temp_str[20]={0}; + sprintf_s(temp_str, 20, "%d", caloriesdata); - memset((void *)caloriesnewstr, 0, 20); - sprintf_s(caloriesnewstr, 20, "%d", caloriesdata); + caloriesnewstr=temp_str; + return caloriesnewstr; } - char distancegoalstr[20]; - char *GoalModel::getdistanceGoal() + std::string GoalModel::getdistanceGoal() { - int distancedata = distance; - memset((void *)distancegoalstr, 0, 20); - sprintf_s(distancegoalstr, 20, "/%d", distancedata); + std::string distancegoalstr; + + int distancedata = distanc_goal; + char temp_str[20]={0}; + sprintf_s(temp_str, 20, "/%d", distancedata); + + distancegoalstr=temp_str; + return distancegoalstr; } - char distancenewstr[20]; - char *GoalModel::getdistancenew() + + std::string GoalModel::getdistancenew() { + std::string distancenewstr; + float distancedata = show_data_distance_refresh(); + char temp_str[20]={0}; + sprintf_s(temp_str, 20, "%0.1f", distancedata); + + distancenewstr=temp_str; - memset((void *)distancenewstr, 0, 20); - sprintf_s(distancenewstr, 20, "%0.1f", distancedata); return distancenewstr; } - char fatburninggoalstr[20]; - char *GoalModel::getfatburninggoal() + + std::string GoalModel::getfatburninggoal() { - int fatburningdata = fat; - memset((void *)fatburninggoalstr, 0, 20); - sprintf_s(fatburninggoalstr, 20, "/%d", fatburningdata); + std::string fatburninggoalstr; + + int fatburningdata = fat_goal; + + char temp_str[20]={0}; + sprintf_s(temp_str, 20, "/%d", fatburningdata); + fatburninggoalstr=temp_str; + return fatburninggoalstr; } + std::string GoalModel::getfatburningnew() + { + + std::string fatburningnewstr; + + int fatburningdata = show_data_fat_refresh();; + + char temp_str[20]={0}; + sprintf_s(temp_str, 20, "%d", fatburningdata); + fatburningnewstr=temp_str; + + return fatburningnewstr; + } + + + std::string GoalModel::getstandgoal() + { + std::string standstr; + + int standdata =stand_goal; + char temp_str[20]={0}; + sprintf_s(temp_str, 20, "/%d", standdata); + standstr=temp_str; + + return standstr; + } + + + std::string GoalModel::getstandnew() + { + std::string standnewstr; + + int standdata = standdata_now; + char temp_str[20]={0}; + sprintf_s(temp_str, 20, "%d", standdata); + standnewstr=temp_str; + + return standnewstr; + } + + bool GoalModel::is_goal_DISTANCE_done() { float distancedata_now = show_data_distance_refresh(); - int distancedata_goal = distance; + int distancedata_goal = distanc_goal; if(distancedata_now>=distancedata_goal) return true; @@ -157,7 +226,7 @@ namespace OHOS { int fatburningdata_now =show_data_fat_refresh(); - int fatburningdata_goal = fat; + int fatburningdata_goal = fat_goal; if(fatburningdata_now>=fatburningdata_goal) return true; @@ -170,7 +239,7 @@ namespace OHOS { int standdata_now_ = standdata_now; - int standdata_goal = stand; + int standdata_goal = stand_goal; if(standdata_now_>=standdata_goal) return true; @@ -183,44 +252,16 @@ namespace OHOS { int calories_now = show_data_calories_refresh(); - int calories_goal = calories; + int caloriesdata_goal = calories_goal; - if(calories_now>=calories_goal) + if(calories_now>=caloriesdata_goal) return true; else return false; } - char fatburningnewstr[20]; - char *GoalModel::getfatburningnew() - { - int fatburningdata = show_data_fat_refresh(); - - memset((void *)fatburningnewstr, 0, 20); - sprintf_s(fatburningnewstr, 20, "%d", fatburningdata); - return fatburningnewstr; - } - - char standstr[20]; - char *GoalModel::getstandgoal() - { - int standdata =stand; - memset((void *)standstr, 0, 20); - sprintf_s(standstr, 20, "/%d", standdata); - return standstr; - } - - char standnewstr[20]; - char *GoalModel::getstandnew() - { - int standdata = standdata_now; - - memset((void *)standnewstr, 0, 20); - sprintf_s(standnewstr, 20, "%d", standdata); - return standnewstr; - } GoalModel &GoalModel::GetInstance() { @@ -339,7 +380,7 @@ namespace OHOS 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: %d", sing_date); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "data: %f", sing_date); struct tm *timeinfo; @@ -395,7 +436,7 @@ namespace OHOS 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: %d", sing_date); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "data: %f", sing_date); struct tm *timeinfo; timeinfo = localtime((time_t *) &timetemp); diff --git a/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalother.cpp b/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalother.cpp index ed5a83a86..51cae63b6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalother.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalother.cpp @@ -47,21 +47,21 @@ namespace OHOS void GoalotherView::GoalViewrefresh() { if(mileagenowdataLabel) - mileagenowdataLabel->SetText(GoalModel::GetInstance().getdistancenew()); + mileagenowdataLabel->SetText(GoalModel::GetInstance().getdistancenew().c_str()); if(mileagegoaldataLabel) - mileagegoaldataLabel->SetText(GoalModel::GetInstance().getdistanceGoal()); + mileagegoaldataLabel->SetText(GoalModel::GetInstance().getdistanceGoal().c_str()); if(fatburningnowdataLabel) - fatburningnowdataLabel->SetText(GoalModel::GetInstance().getfatburningnew()); + fatburningnowdataLabel->SetText(GoalModel::GetInstance().getfatburningnew().c_str()); if(fatburninggoaldataLabel) - fatburninggoaldataLabel->SetText(GoalModel::GetInstance().getfatburninggoal()); + fatburninggoaldataLabel->SetText(GoalModel::GetInstance().getfatburninggoal().c_str()); if(standnowdataLabel) - standnowdataLabel->SetText(GoalModel::GetInstance().getstandnew()); + standnowdataLabel->SetText(GoalModel::GetInstance().getstandnew().c_str()); if(standgoaldataLabel) - standgoaldataLabel->SetText(GoalModel::GetInstance().getstandgoal()); + standgoaldataLabel->SetText(GoalModel::GetInstance().getstandgoal().c_str()); if(calorienowdataLabel) - calorienowdataLabel->SetText(GoalModel::GetInstance().getcaloriespnew()); + calorienowdataLabel->SetText(GoalModel::GetInstance().getcaloriespnew().c_str()); if(caloriegoaldataLabel) - caloriegoaldataLabel->SetText(GoalModel::GetInstance().getcaloriesGoal()); + caloriegoaldataLabel->SetText(GoalModel::GetInstance().getcaloriesGoal().c_str()); Invalidate(); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GoalViewrefresh Invalidat "); @@ -301,7 +301,7 @@ namespace OHOS mileagenowdataLabel->SetStyle(STYLE_TEXT_FONT, 40); // Set additional property - mileagenowdataLabel->SetText(GoalModel::GetInstance().getdistancenew()); + mileagenowdataLabel->SetText(GoalModel::GetInstance().getdistancenew().c_str()); mileagenowdataLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); mileagenowdataLabel->SetTextColor(Color::GetColorFromRGBA(0x4F, 0xC3, 0x4C, 0xff)); mileagenowdataLabel->SetAlign(TEXT_ALIGNMENT_RIGHT, TEXT_ALIGNMENT_CENTER); @@ -319,7 +319,7 @@ namespace OHOS mileagegoaldataLabel->SetStyle(STYLE_TEXT_FONT, 40); // Set additional property - mileagegoaldataLabel->SetText(GoalModel::GetInstance().getdistanceGoal()); + mileagegoaldataLabel->SetText(GoalModel::GetInstance().getdistanceGoal().c_str()); mileagegoaldataLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); mileagegoaldataLabel->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff)); mileagegoaldataLabel->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER); @@ -337,7 +337,7 @@ namespace OHOS fatburningnowdataLabel->SetStyle(STYLE_TEXT_FONT, 40); // Set additional property - fatburningnowdataLabel->SetText(GoalModel::GetInstance().getfatburningnew()); + fatburningnowdataLabel->SetText(GoalModel::GetInstance().getfatburningnew().c_str()); fatburningnowdataLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); fatburningnowdataLabel->SetTextColor(Color::GetColorFromRGBA(0x4F, 0xC3, 0x4C, 0xff)); fatburningnowdataLabel->SetAlign(TEXT_ALIGNMENT_RIGHT, TEXT_ALIGNMENT_CENTER); @@ -354,7 +354,7 @@ namespace OHOS fatburninggoaldataLabel->SetStyle(STYLE_TEXT_FONT, 40); // Set additional property - fatburninggoaldataLabel->SetText(GoalModel::GetInstance().getfatburninggoal()); + fatburninggoaldataLabel->SetText(GoalModel::GetInstance().getfatburninggoal().c_str()); fatburninggoaldataLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); fatburninggoaldataLabel->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff)); fatburninggoaldataLabel->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER); @@ -372,7 +372,7 @@ namespace OHOS // Set additional property - standnowdataLabel->SetText(GoalModel::GetInstance().getstandnew()); + standnowdataLabel->SetText(GoalModel::GetInstance().getstandnew().c_str()); standnowdataLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); standnowdataLabel->SetTextColor(Color::GetColorFromRGBA(0x4F, 0xC3, 0x4C, 0xff)); standnowdataLabel->SetAlign(TEXT_ALIGNMENT_RIGHT, TEXT_ALIGNMENT_CENTER); @@ -389,7 +389,7 @@ namespace OHOS standgoaldataLabel->SetStyle(STYLE_TEXT_FONT, 40); // Set additional property - standgoaldataLabel->SetText(GoalModel::GetInstance().getstandgoal()); + standgoaldataLabel->SetText(GoalModel::GetInstance().getstandgoal().c_str()); standgoaldataLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); standgoaldataLabel->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff)); standgoaldataLabel->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER); @@ -406,7 +406,7 @@ namespace OHOS calorienowdataLabel->SetStyle(STYLE_TEXT_FONT, 40); // Set additional property - calorienowdataLabel->SetText(GoalModel::GetInstance().getcaloriespnew()); + calorienowdataLabel->SetText(GoalModel::GetInstance().getcaloriespnew().c_str()); calorienowdataLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); calorienowdataLabel->SetTextColor(Color::GetColorFromRGBA(0x4F, 0xC3, 0x4C, 0xff)); calorienowdataLabel->SetAlign(TEXT_ALIGNMENT_RIGHT, TEXT_ALIGNMENT_CENTER); @@ -423,7 +423,7 @@ namespace OHOS caloriegoaldataLabel->SetStyle(STYLE_TEXT_FONT, 40); // Set additional property - caloriegoaldataLabel->SetText(GoalModel::GetInstance().getcaloriesGoal()); + caloriegoaldataLabel->SetText(GoalModel::GetInstance().getcaloriesGoal().c_str()); caloriegoaldataLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); caloriegoaldataLabel->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff)); diff --git a/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalview.cpp b/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalview.cpp index f26b49f55..4d5aac53d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalview.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalview.cpp @@ -45,9 +45,9 @@ namespace OHOS void GoalView::GoalViewrefresh() { if(nowstepLabel) - nowstepLabel->SetText(GoalModel::GetInstance().getstepnew()); + nowstepLabel->SetText(GoalModel::GetInstance().getstepnew().c_str()); if(goalstepLabel) - goalstepLabel->SetText(GoalModel::GetInstance().getstepGoal()); + goalstepLabel->SetText(GoalModel::GetInstance().getstepGoal().c_str()); if(circleProgress1_) circleProgress1_->SetValue(GoalModel::GetInstance().getstepvalue()); @@ -176,7 +176,7 @@ namespace OHOS // Set additional property - nowstepLabel->SetText(GoalModel::GetInstance().getstepnew());//); + nowstepLabel->SetText(GoalModel::GetInstance().getstepnew().c_str());//); nowstepLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); //nowstepLabel->SetTextColor(0x4FC34C); nowstepLabel->SetTextColor(Color::GetColorFromRGBA(0x4F, 0xC3, 0x4C, 0xff)); @@ -195,7 +195,7 @@ namespace OHOS goalstepLabel->SetStyle(STYLE_TEXT_FONT, 40); // Set additional property - goalstepLabel->SetText(GoalModel::GetInstance().getstepGoal()); + goalstepLabel->SetText(GoalModel::GetInstance().getstepGoal().c_str()); goalstepLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); goalstepLabel->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); goalstepLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp index 7a72e3afb..b4d7f44f5 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp @@ -458,7 +458,7 @@ namespace OHOS break; case GOAL: - Updategoal(); + // Updategoal(); break; case SLEEP: diff --git a/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c b/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c index 72703636c..7c36ff970 100644 --- a/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c +++ b/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c @@ -558,6 +558,12 @@ void CWM_OS_saveData_history(void* new_data,void *history ,uint32_t len,uint8_t sprintf_s(path_,64,"%s%s.bin",CWM_HISTORY_DATA_PATH,timeday); i_data= *(int*)new_data-*(int*)history;//新数据减去旧数据,作为这一个小时的值 + // { + // FILE *fp= fopen("/user/userdata/i_data_test.txt","ab+"); + // fwrite("x",1,1,fp); + // fclose(fp); + // } + break; case CYWEE_DATA_DISTANCE: @@ -638,7 +644,26 @@ void CWM_OS_saveData_history(void* new_data,void *history ,uint32_t len,uint8_t if(i_data) ret =fwrite(&i_data,1,sizeof(i_data),fp); fclose(fp); - } + } + else + { + msleep(5); + FILE * fp = fopen(path_,"ab+"); + uint32_t creationTime; + creationTime=time;//当前值计入上小时 + + int ret =fwrite(&creationTime,1,4,fp); + if(ret==0) + { + CWM_OS_dbgPrintf("fwrite failed %d\n",ret); + } + if(i_data) + ret =fwrite(&i_data,1,sizeof(i_data),fp); + fclose(fp); + } + + + } -- 2.17.1