From 3c085281b63e22101f4b46f54ffe4074e7319e92 Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Thu, 12 Dec 2024 19:02:17 +0800 Subject: [PATCH] =?utf8?q?=E6=AD=A5=E6=95=B0=E7=AD=89=E6=95=B0=E6=8D=AE?= =?utf8?q?=E6=98=BE=E7=A4=BA=E4=BF=AE=E6=94=B9=EF=BC=8C=E4=BF=AE=E5=A4=8D?= =?utf8?q?=E6=89=8B=E8=A1=A8=E6=95=B0=E6=8D=AE=E4=B8=8D=E4=B8=8EAPP?= =?utf8?q?=E4=B8=80=E8=87=B4=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/activity/src/ActivityModel.cpp | 9 +- .../nativeui/goal/include/goalmodel.h | 18 +- .../fd230app/nativeui/goal/src/goalmodel.cpp | 245 +++++++++++++++++- .../fd230app/nativeui/goal/src/goalother.cpp | 2 +- .../fd230app/nativeui/goal/src/goalview.cpp | 2 +- .../main/include/dial/DialModelDistance.h | 2 +- .../main/src/dial/DialModelDistance.cpp | 8 +- .../msg_center/src/msg_center_customer.cpp | 27 +- .../msg_center/src/notify/transmitting.cpp | 6 +- 9 files changed, 283 insertions(+), 36 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/activity/src/ActivityModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/activity/src/ActivityModel.cpp index d4f9c8147..3054a4d88 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/activity/src/ActivityModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/activity/src/ActivityModel.cpp @@ -188,12 +188,15 @@ void ActivityModel::Init() { // StepSubscribeTopic(TOPIC_EVENT_STEPDATA_UPDATE); // StepSubscribeTopic(TOPIC_EVENT_NEXTDAY_UPDATE); InitStepData(); - uint16_t counter = get_step_data(); + uint32_t counter = OHOS::GoalModel::GetInstance().show_data_step_refresh(); + uint32_t calories= OHOS::GoalModel::GetInstance().show_data_calories_refresh(); + float distance= OHOS::GoalModel::GetInstance().show_data_distance_refresh(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ActivityModel::ActivityModel,%d",counter); DialModelSteps::GetInstance()->UpdateSteps(counter); //更新表盘步数 DialModelStepgoal::GetInstance()->UpdateStepgoal(counter); //更新表盘目标 - DialModelDistance::GetInstance()->UpdateDistance(get_distance_data()); //更新表盘距离 - DialModelCalorie::GetInstance()->UpdateCalorie(get_calories_data()); //更新表盘卡路里 + DialModelDistance::GetInstance()->UpdateDistance(distance); //更新表盘距离 + DialModelCalorie::GetInstance()->UpdateCalorie(calories); //更新表盘卡路里 } uint32 ActivityModel::GetStepCounter(void) { return stepCounter; } 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 7758b33ca..c31d672cc 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/goal/include/goalmodel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/goal/include/goalmodel.h @@ -58,16 +58,30 @@ namespace OHOS return other_goal_show; } - + uint32_t goal_parse_step_data(void); + float goal_parse_calories_data(void); + float goal_parse_distance_data(void); + uint32_t goal_parse_fat_data(void); + + uint32_t show_data_step_refresh(void); + float show_data_calories_refresh(void); + float show_data_distance_refresh(void); + 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 show_step=0; + float show_distance=0; + uint32_t show_fat=0; + float show_calories=0; + uint32_t show_stand=0; + uint32_t standdata_now=0; uint8_t step_goal_show=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 ed18d1343..ee6e55577 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalmodel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalmodel.cpp @@ -12,6 +12,8 @@ #include "ConfigModel.h" #include "cywee_hal.h" #include "goal_notification.h" +#include "custom_utils.h" +#include "cywee_ble_Service.h" namespace OHOS { @@ -42,6 +44,12 @@ namespace OHOS stand=ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_STANDUP_TIMES); standdata_now=get_now_stand_count(); + + show_step=goal_parse_step_data(); + show_calories=goal_parse_calories_data(); + show_distance=goal_parse_distance_data(); + show_fat=goal_parse_fat_data(); + } @@ -52,7 +60,7 @@ namespace OHOS uint8_t GoalModel::getstepvalue() { int stepgoal = step; - int stepdata = get_step_data();//OHOS::ActivityModel::GetInstance()->GetStepCounter(); + 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; @@ -79,7 +87,7 @@ namespace OHOS char stepnewstr[20]; char *GoalModel::getstepnew() { - int stepdata = get_step_data(); + int stepdata = show_data_step_refresh(); memset((void *)stepnewstr, 0, 20); sprintf_s(stepnewstr, 20, "%d", stepdata); return stepnewstr; @@ -97,7 +105,7 @@ namespace OHOS char caloriesnewstr[20]; char *GoalModel::getcaloriespnew() { - int caloriesdata = get_calories_data(); + int caloriesdata = show_data_calories_refresh(); memset((void *)caloriesnewstr, 0, 20); sprintf_s(caloriesnewstr, 20, "%d", caloriesdata); @@ -116,7 +124,7 @@ namespace OHOS char distancenewstr[20]; char *GoalModel::getdistancenew() { - float distancedata = (float)get_distance_data() / 1000.0; + float distancedata = show_data_distance_refresh(); memset((void *)distancenewstr, 0, 20); sprintf_s(distancenewstr, 20, "%0.1f", distancedata); @@ -135,7 +143,7 @@ namespace OHOS bool GoalModel::is_goal_DISTANCE_done() { - float distancedata_now = (float)get_distance_data() / 1000.0; + float distancedata_now = show_data_distance_refresh(); int distancedata_goal = distance; if(distancedata_now>=distancedata_goal) @@ -147,7 +155,7 @@ namespace OHOS bool GoalModel::is_goal_fatburning_done() { - int fatburningdata_now = get_fat_time_data()/60; + int fatburningdata_now =show_data_fat_refresh(); int fatburningdata_goal = fat; @@ -173,7 +181,7 @@ namespace OHOS bool GoalModel::is_goal_calories_done() { - int calories_now = get_calories_data(); + int calories_now = show_data_calories_refresh(); int calories_goal = calories; @@ -188,7 +196,7 @@ namespace OHOS char *GoalModel::getfatburningnew() { - int fatburningdata = get_fat_time_data()/60; + int fatburningdata = show_data_fat_refresh(); memset((void *)fatburningnewstr, 0, 20); sprintf_s(fatburningnewstr, 20, "%d", fatburningdata); @@ -234,4 +242,225 @@ namespace OHOS } } + uint32_t GoalModel::goal_parse_step_data(void) + { + char path_[64]={0}; + char timeday[12] = {0}; + uapi_get_YYMMDD_Time_extend(timeday, '_',0); + sprintf_s(path_,64,"%s%s.bin",CWM_HISTORY_DATA_PATH,timeday); + FILE * fp = fopen(path_,"rb+"); + uint32_t size=0; + uint32_t toal_data=0; + + if (fp != NULL) + { + fseek(fp, 0, SEEK_END); // 将文件指针移动到文件末尾 + size = ftell(fp); // 获取当前文件指针位置,即文件大小 + fseek(fp, 0, SEEK_SET); // 将文件指针移回文件开头 + } + else + { + return 0; + } + uint8_t *date=(uint8_t *)malloc(size); + if(date==NULL) return 0; + + fread(date,sizeof(uint8_t),size,fp); + fclose(fp); + int32_t sing_date=0; + int32_t timetemp=0; + + for(int i=0;i0) + toal_data+=sing_date; + } + return toal_data; + } + + float GoalModel::goal_parse_calories_data(void) + { + char path_[64]={0}; + char timeday[12] = {0}; + uapi_get_YYMMDD_Time_extend(timeday, '_',0); + sprintf_s(path_,64,"%s%s.bin",CWM_HISTORY_DATA_CALORIES_PATH,timeday); + FILE * fp = fopen(path_,"rb+"); + uint32_t size=0; + float toal_data=0; + + if (fp != NULL) + { + fseek(fp, 0, SEEK_END); // 将文件指针移动到文件末尾 + size = ftell(fp); // 获取当前文件指针位置,即文件大小 + fseek(fp, 0, SEEK_SET); // 将文件指针移回文件开头 + } + else + { + return 0; + } + uint8_t *date=(uint8_t *)malloc(size); + if(date==NULL) return 0; + + fread(date,sizeof(uint8_t),size,fp); + fclose(fp); + float sing_date=0; + int32_t timetemp=0; + + for(int i=0;i0) + toal_data+=sing_date; + } + return toal_data; + } + + float GoalModel::goal_parse_distance_data(void) + { + char path_[64]={0}; + char timeday[12] = {0}; + uapi_get_YYMMDD_Time_extend(timeday, '_',0); + sprintf_s(path_,64,"%s%s.bin",CWM_HISTORY_DATA_DISTANCE_PATH,timeday); + FILE * fp = fopen(path_,"rb+"); + uint32_t size=0; + float toal_data=0; + + if (fp != NULL) + { + fseek(fp, 0, SEEK_END); // 将文件指针移动到文件末尾 + size = ftell(fp); // 获取当前文件指针位置,即文件大小 + fseek(fp, 0, SEEK_SET); // 将文件指针移回文件开头 + } + else + { + return 0; + } + uint8_t *date=(uint8_t *)malloc(size); + if(date==NULL) return 0; + + fread(date,sizeof(uint8_t),size,fp); + fclose(fp); + float sing_date=0; + int32_t timetemp=0; + + for(int i=0;i0) + toal_data+=sing_date; + } + return toal_data; + } + + + uint32_t GoalModel::goal_parse_fat_data(void) + { + char path_[64]={0}; + char timeday[12] = {0}; + uapi_get_YYMMDD_Time_extend(timeday, '_',0); + sprintf_s(path_,64,"%s%s.bin",CWM_HISTORY_DATA_FAT_PATH,timeday); + FILE * fp = fopen(path_,"rb+"); + uint32_t size=0; + float toal_data=0; + + if (fp != NULL) + { + fseek(fp, 0, SEEK_END); // 将文件指针移动到文件末尾 + size = ftell(fp); // 获取当前文件指针位置,即文件大小 + fseek(fp, 0, SEEK_SET); // 将文件指针移回文件开头 + } + else + { + return 0; + } + uint8_t *date=(uint8_t *)malloc(size); + if(date==NULL) return 0; + + fread(date,sizeof(uint8_t),size,fp); + fclose(fp); + uint16 sing_date=0; + int32_t timetemp=0; + + for(int i=0;i0) + toal_data+=sing_date; + } + return toal_data; + } + + + + + uint32_t GoalModel::show_data_step_refresh(void) + { + int32_t value=0; + uint32_t toal_date; + + toal_date=show_step; + get_now_hour_data(&value,CYWEE_SAVE_DATA_STEP); + if(value>0) + toal_date+=value; + return toal_date; + } + + float GoalModel::show_data_calories_refresh(void) + { + + float _f_value=0; + float toal_date; + toal_date=show_calories; + get_now_hour_data(&_f_value,CYWEE_SAVE_DATA_CALORIES); + if(_f_value>0) + toal_date+=_f_value; + + return toal_date; + } + + float GoalModel::show_data_distance_refresh(void) + { + + float _f_value=0; + float toal_date; + toal_date=show_distance; + get_now_hour_data(&_f_value,CYWEE_SAVE_DATA_DISTANCE); + if(_f_value>0) + toal_date+=_f_value; + + return toal_date; + } + + uint32_t GoalModel::show_data_fat_refresh(void) + { + + uint16_t _16_value=0; + uint32_t toal_date; + toal_date=show_fat; + get_now_hour_data(&_16_value,CYWEE_SAVE_DATA_FAT); + if(_16_value>0) + toal_date+=_16_value; + + return toal_date; + } + + } \ No newline at end of file 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 f83204fba..ed5a83a86 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalother.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalother.cpp @@ -65,7 +65,7 @@ namespace OHOS Invalidate(); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GoalViewrefresh Invalidat "); - RootView::GetInstance()->Invalidate(); + // RootView::GetInstance()->Invalidate(); } 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 5c7b978e9..f26b49f55 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalview.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalview.cpp @@ -55,7 +55,7 @@ namespace OHOS Invalidate(); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GoalViewrefresh Invalidat "); - RootView::GetInstance()->Invalidate(); + // RootView::GetInstance()->Invalidate(); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelDistance.h b/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelDistance.h index 1498d820f..325cb8bd4 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelDistance.h +++ b/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelDistance.h @@ -29,7 +29,7 @@ namespace OHOS return &instance; } bool GetDialFloatData(DialDataType &type, float &out) override; - void UpdateDistance(uint32_t Distance); + void UpdateDistance(float Distance); int GetDistanceData(void); private: diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelDistance.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelDistance.cpp index 07a12ed5b..ddaaf8f86 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelDistance.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelDistance.cpp @@ -3,7 +3,7 @@ #include "DialModelDistance.h" #include "wearable_log.h" REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_DISTANCE, OHOS::DialModelDistance::GetInstance()); - +#include "goal/include/goalmodel.h" #include "cywee_hal.h" extern "C" int get_distance_data(); @@ -12,14 +12,14 @@ namespace OHOS bool DialModelDistance::GetDialFloatData(DialDataType &type, float &out) { (void)type; - distance_ = static_cast(get_distance_data()) / 1000.0f; + distance_ = static_cast( OHOS::GoalModel::GetInstance().show_data_distance_refresh()); out = distance_; return true; } - void DialModelDistance::UpdateDistance(uint32_t distance) { + void DialModelDistance::UpdateDistance(float distance) { // 将距离从米(m)转换为公里(km)并保留一位小数 - distance_ = static_cast(distance) / 1000.0f; // distance 米 + distance_ = static_cast(distance); // distance 米 if (onChangeListener_ != nullptr) { // 通知改变监听器更新距离数据 diff --git a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp index 866aa2fff..bcde17478 100644 --- a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp @@ -385,23 +385,19 @@ void MsgCenterNotifyONtimeProc(const Topic topic, Request* req) // The alarm notification is not displayed if the incoming call notification is already being processed cywee_save_data(); -// do_cywee_service_check_msg(CYWEE_SERVICE_CMD_SAVE_DATA,NULL); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "保存每小时步数"); step_history_save(); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "保存每小时站立数据"); if(get_stand_falg()) - { - stand_history_save(); - SendMsgToUIService(UI_UPDATE_GOAL, 0, nullptr, 0); - } - - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "保存每小时卡路里数据"); + stand_history_save(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "保存每小时卡路里数据"); calories_history_save(); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "保存每小时距离数据"); distances_history_save(); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "保存每小时燃脂数据"); fat_history_save(); +//保存完增加一次读取数据 + SendMsgToUIService(UI_UPDATE_GOAL, 0, nullptr, 0); } @@ -450,11 +446,13 @@ void MsgCenterNotifystepProc(const Topic topic, Request* req) 0; // OHOS::ActivityModel::GetInstance()->GetStepCounter(); counter = *(uint32_t *)req->data; set_step_data(counter); - counter=get_step_data(); + counter=OHOS::GoalModel::GetInstance().show_data_step_refresh(); + uint32_t calories= OHOS::GoalModel::GetInstance().show_data_calories_refresh(); + float distance= OHOS::GoalModel::GetInstance().show_data_distance_refresh(); OHOS::DialModelSteps::GetInstance() ->UpdateSteps(counter);//更新表盘步数 OHOS::DialModelStepgoal::GetInstance() ->UpdateStepgoal(counter);//更新表盘目标 - OHOS::DialModelDistance::GetInstance() ->UpdateDistance(get_distance_data());//更新表盘距离 - OHOS::DialModelCalorie::GetInstance() ->UpdateCalorie(get_calories_data());//更新表盘卡路里 + OHOS::DialModelDistance::GetInstance() ->UpdateDistance(distance);//更新表盘距离 + OHOS::DialModelCalorie::GetInstance() ->UpdateCalorie(calories);//更新表盘卡路里 if(OHOS::GoalView::GetInstance()) @@ -1498,7 +1496,9 @@ void MsgCenterNotifyActivityProc(const Topic topic, Request* req) { set_calories_data(c_activity_result_t->calories); #if DIALDATASET - DialModelCalorie::GetInstance()->UpdateCalorie(get_calories_data()); + uint32_t calories= OHOS::GoalModel::GetInstance().show_data_calories_refresh(); + + DialModelCalorie::GetInstance()->UpdateCalorie(calories); #endif } /*更新距离数据*/ @@ -1506,7 +1506,8 @@ void MsgCenterNotifyActivityProc(const Topic topic, Request* req) { set_distance_data(c_activity_result_t->distance); #if DIALDATASET - DialModelDistance::GetInstance()->UpdateDistance(get_distance_data()); + float distance= OHOS::GoalModel::GetInstance().show_data_distance_refresh(); + DialModelDistance::GetInstance()->UpdateDistance(distance); #endif } } diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/transmitting.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/transmitting.cpp index 1b2a9c560..dd439540f 100644 --- a/code/sdk/application/wearable/service/msg_center/src/notify/transmitting.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/transmitting.cpp @@ -195,8 +195,8 @@ namespace OHOS if (Title == nullptr) { Title = new UILabelExt(); } - Title->SetPosition(158, 51); // widget's left position and top position - Title->Resize(800, 88); // widget's width and height + Title->SetPosition(83, 50); // widget's left position and top position + Title->Resize(300, 35); // widget's width and height Title->SetViewId("label1");// Set style Title->SetStyle(STYLE_TEXT_FONT, 30); @@ -204,7 +204,7 @@ namespace OHOS Title->SetText("OTA下载中"); Title->SetTextId (STR_OTA_DOWNLOAD); - Title->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + Title->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); Title->SetRollSpeed(0); Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); -- 2.17.1