From 25002248b91a357bdb5489c577780019b26cd68f Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Fri, 6 Sep 2024 16:32:24 +0800 Subject: [PATCH] =?utf8?q?=E4=BF=AE=E6=94=B9=E6=AF=8F=E6=97=A5=E6=B4=BB?= =?utf8?q?=E5=8A=A8=E4=B8=BB=E9=A1=B5=E9=9D=A2=E5=8D=A1=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/goal/include/Maingoalview.h | 4 + .../nativeui/goal/include/goalControlView.h | 2 + .../nativeui/goal/src/Maingoalpresenter.cpp | 13 -- .../nativeui/goal/src/goalControlView.cpp | 19 +- .../main/include/MainPresenterSample.h | 2 + .../nativeui/main/src/MainPresenterSample.cpp | 36 ++++ .../service/ble_service/blemoder/bletest.cpp | 180 ++++++++++++++---- .../msg_center/src/msg_center_customer.cpp | 4 +- 8 files changed, 202 insertions(+), 58 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/goal/include/Maingoalview.h b/code/sdk/application/wearable/fd230app/nativeui/goal/include/Maingoalview.h index 5bd4464a3..31641849f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/goal/include/Maingoalview.h +++ b/code/sdk/application/wearable/fd230app/nativeui/goal/include/Maingoalview.h @@ -45,6 +45,10 @@ namespace OHOS GoalotherView *GetohergoalView(void); UIView *GetGoalPageView(void); + UISwipeView *getSwipeView(void) + { + return goalSwipeViewList; + } public: void OnStart() override; diff --git a/code/sdk/application/wearable/fd230app/nativeui/goal/include/goalControlView.h b/code/sdk/application/wearable/fd230app/nativeui/goal/include/goalControlView.h index f112ca19d..d3d34805d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/goal/include/goalControlView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/goal/include/goalControlView.h @@ -16,6 +16,8 @@ namespace OHOS bool InitView(void); void PreLoad(void) override; void UnLoad(void) override; + UISwipeView *GetGoalControlSwipView(void); + static goalControlView *GetInstance(void); private: void ClearAll(void); diff --git a/code/sdk/application/wearable/fd230app/nativeui/goal/src/Maingoalpresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/goal/src/Maingoalpresenter.cpp index 25151e886..0e9c89970 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/goal/src/Maingoalpresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/goal/src/Maingoalpresenter.cpp @@ -107,24 +107,11 @@ namespace OHOS void MaingoalPresenter::OnSwipe(UISwipeView &view) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainWeatherPresenter::OnSwipe,current tab index = %d", view.GetCurrentPage()); - // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "the view index = %d,dragging direction = %d,current tab index = %d", view.GetViewIndex(), view.GetDirection(), view.GetCurrentPage()); - // if (view.GetCurrentPage() == GOALSTEPVIEW) - // { - - // } } void GoalControlViewOnSwipeListener::OnSwipe(UISwipeView &view) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GoalControlViewOnSwipeListener::OnSwipe,current tab index = %d", view.GetCurrentPage()); - if (view.GetCurrentPage() == MAINGOALVIEW) - { - view.SetIntercept(false); - } - else - { - view.SetIntercept(true); - } return; } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalControlView.cpp b/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalControlView.cpp index 86fad0920..561250473 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalControlView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalControlView.cpp @@ -2,18 +2,28 @@ #include "goal/include/Maingoalpresenter.h" namespace OHOS { + static goalControlView *g_pgoalControlView{nullptr}; + goalControlView::goalControlView() { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "goalControlView::goalControlView"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherControlView::WeatherControlView"); SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + g_pgoalControlView = this; } goalControlView::~goalControlView() { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "goalControlView::~goalControlView"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherControlView::~WeatherControlView"); ClearAll(); + g_pgoalControlView = nullptr; + } + + goalControlView *goalControlView::GetInstance(void) + { + return g_pgoalControlView; } + void goalControlView::ClearAll(void) { if (viewiInitStatus == true) @@ -82,4 +92,9 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "goalControlView::UnLoad"); } + UISwipeView *goalControlView::GetGoalControlSwipView(void) + { + return maingoalView->getSwipeView(); + } + } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/include/MainPresenterSample.h b/code/sdk/application/wearable/fd230app/nativeui/main/include/MainPresenterSample.h index 91cc6fb7f..3837b511d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/include/MainPresenterSample.h +++ b/code/sdk/application/wearable/fd230app/nativeui/main/include/MainPresenterSample.h @@ -94,9 +94,11 @@ namespace OHOS void LogCardTransition(CardId previous, CardId current); void ResetSleepCardView(); void ResetWeatherCardView(); + void ResetgoalCardView(); void StartHeartRateDetection(); void UpdateWatchFace(); void UpdateWeather(); + void Updategoal(); void ProcessDataNotify(void); void SetCircleProgress(void); void SetCompassRotate(void); 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 d053c321c..701dd6cfd 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp @@ -294,6 +294,18 @@ namespace OHOS } } + void MainPresenterSample::ResetgoalCardView() + { + if(goalControlView::GetInstance()) + { + auto goalSwipView = goalControlView::GetInstance()->GetGoalControlSwipView(); + if (goalSwipView->GetCurrentPage() != 0) + { + goalSwipView->SetCurrentPage(0); + } + } + } + void MainPresenterSample::OnSwipe(UISwipeView &view) { // UNUSED(view); @@ -425,7 +437,13 @@ namespace OHOS LogCardTransition(previousCardId, currentCardId); ResetWeatherCardView(); } + if (previousCardId == GOAL && currentCardId != GOAL) + { + LogCardTransition(previousCardId, currentCardId); + ResetgoalCardView(); + } + // 更新上一个卡片的值 previousCardId = currentCardId; @@ -450,6 +468,9 @@ namespace OHOS case WEATHER: UpdateWeather(); break; + case GOAL: + Updategoal(); + break; } } @@ -482,6 +503,8 @@ namespace OHOS } } } + + /*心率卡片*/ void MainPresenterSample::StartHeartRateDetection() { @@ -502,6 +525,19 @@ namespace OHOS dynamic_cast(view_->GetViewById(WATCH_FACE))->UpdateTime(); } } + + void MainPresenterSample::Updategoal() + { + if(GoalView::GetInstance()) + { + GoalView::GetInstance()->GoalViewrefresh(); + } + if(GoalotherView::GetInstance()) + { + GoalotherView::GetInstance()->GoalViewrefresh(); + } + } + /*天气*/ void MainPresenterSample::UpdateWeather() { diff --git a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp index 83708e2f8..a508acaf8 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp @@ -498,37 +498,92 @@ uint8_t ble_get_sleep_data(uint32_t file_size,uint8_t day_,uint8_t *data) if (ent->d_type == DT_REG || ent->d_type == DT_UNKNOWN ) // 普通文件 { - - char file_path[128]={0}; - sprintf_s(file_path,128,"%s/%s",dir_path,ent->d_name); - - FILE * fp = fopen(file_path,"rb+"); - if(fp==NULL) + if(fileName=="sleep_time.bin") { - printf(" fopen fail %s\r\n",file_path); - return 1 ; - } + char file_path[128]={0}; + sprintf_s(file_path,128,"%s/%s",dir_path,ent->d_name); + + FILE * fp = fopen(file_path,"rb+"); + if(fp==NULL) + { + printf(" fopen fail %s\r\n",file_path); + return 1 ; + } + uint16_t sleep_file_size=0; + if (fp != NULL) + { + fseek(fp, 0, SEEK_END); // 将文件指针移动到文件末尾 + sleep_file_size = ftell(fp); // 获取当前文件指针位置,即文件大小 + sleep_file_size++; + fseek(fp, 0, SEEK_SET); // 将文件指针移回文件开头 + memcpy(data+offset,&sleep_file_size,2); + *(data+offset+2)=sleep_count; + sleep_count++; + + uint16_t read_size =fread(data+offset+3,1,sleep_file_size,fp); - uint16_t sleep_file_size=0; - if (fp != NULL) + if((read_size+1)==sleep_file_size) + { + + } + + else + { + printf(" fread fail read_size:%d!= sleep_file_size:%d \r\n",read_size,sleep_file_size); + } + + fclose(fp); + char file_path[128]={0}; + sprintf_s(file_path,128,"%s/%s",dir_path,"sleep_status.bin"); + fp = fopen(file_path,"rb+"); + sleep_file_size=0; + if(fp) + { + fseek(fp, 0, SEEK_END); + sleep_file_size = ftell(fp); + fseek(fp, 0, SEEK_SET); + uint16_t read_size =fread(data+offset+3+read_size,1,sleep_file_size,fp); + offset+=read_size; + } + offset+=read_size; + offset+=3; + + } + } + else if(fileName!="sleep_status.bin") { - fseek(fp, 0, SEEK_END); // 将文件指针移动到文件末尾 - sleep_file_size = ftell(fp); // 获取当前文件指针位置,即文件大小 - sleep_file_size++; - fseek(fp, 0, SEEK_SET); // 将文件指针移回文件开头 - memcpy(data+offset,&sleep_file_size,2); - *(data+offset+2)=sleep_count; - sleep_count++; - offset+=3; - uint16_t read_size =fread(data+offset,1,sleep_file_size,fp); - - if((read_size+1)==sleep_file_size) - offset+=read_size; - else - printf(" fread fail read_size:%d!= sleep_file_size:%d \r\n",read_size,sleep_file_size); - - fclose(fp); + char file_path[128]={0}; + sprintf_s(file_path,128,"%s/%s",dir_path,ent->d_name); + + FILE * fp = fopen(file_path,"rb+"); + if(fp==NULL) + { + printf(" fopen fail %s\r\n",file_path); + return 1 ; + } + + uint16_t sleep_file_size=0; + if (fp != NULL) + { + fseek(fp, 0, SEEK_END); // 将文件指针移动到文件末尾 + sleep_file_size = ftell(fp); // 获取当前文件指针位置,即文件大小 + sleep_file_size++; + fseek(fp, 0, SEEK_SET); // 将文件指针移回文件开头 + memcpy(data+offset,&sleep_file_size,2); + *(data+offset+2)=sleep_count; + sleep_count++; + offset+=3; + uint16_t read_size =fread(data+offset,1,sleep_file_size,fp); + + if((read_size+1)==sleep_file_size) + offset+=read_size; + else + printf(" fread fail read_size:%d!= sleep_file_size:%d \r\n",read_size,sleep_file_size); + + fclose(fp); + } } + } } else if (ent->d_type == DT_DIR) // 目录 @@ -568,25 +623,68 @@ uint8_t ble_get_sleep_data_dir(uint32_t *file_size,uint8_t day_) if (ent->d_type == DT_REG || ent->d_type == DT_UNKNOWN ) // 普通文件 { - - char file_path[128]={0}; - sprintf_s(file_path,128,"%s/%s",dir_path,ent->d_name); - FILE * fp = fopen(file_path,"rb+"); - if(fp==NULL) + if(fileName=="sleep_time.bin") { - printf(" fopen fail %s\r\n",file_path); - return file_count; + char file_path[128]={0}; + sprintf_s(file_path,128,"%s/%s",dir_path,ent->d_name); + + FILE * fp = fopen(file_path,"rb+"); + if(fp==NULL) + { + printf(" fopen fail %s\r\n",file_path); + return file_count; + } + + if (fp != NULL) + { + fseek(fp, 0, SEEK_END); // 将文件指针移动到文件末尾 + *file_size += ftell(fp)+3; // 获取当前文件指针位置,即文件大小 + fseek(fp, 0, SEEK_SET); // 将文件指针移回文件开头 + fclose(fp); + } + file_count++; } - - if (fp != NULL) + else if (fileName=="sleep_status.bin") { - fseek(fp, 0, SEEK_END); // 将文件指针移动到文件末尾 - *file_size += ftell(fp)+3; // 获取当前文件指针位置,即文件大小 - fseek(fp, 0, SEEK_SET); // 将文件指针移回文件开头 - fclose(fp); + char file_path[128]={0}; + sprintf_s(file_path,128,"%s/%s",dir_path,ent->d_name); + FILE * fp = fopen(file_path,"rb+"); + if(fp==NULL) + { + printf(" fopen fail %s\r\n",file_path); + return file_count; + } + if (fp != NULL) + { + fseek(fp, 0, SEEK_END); // 将文件指针移动到文件末尾 + *file_size += ftell(fp); // 获取当前文件指针位置,即文件大小 + fseek(fp, 0, SEEK_SET); // 将文件指针移回文件开头 + fclose(fp); + } } - file_count++; + else + { + char file_path[128]={0}; + sprintf_s(file_path,128,"%s/%s",dir_path,ent->d_name); + + FILE * fp = fopen(file_path,"rb+"); + if(fp==NULL) + { + printf(" fopen fail %s\r\n",file_path); + return file_count; + } + + if (fp != NULL) + { + fseek(fp, 0, SEEK_END); // 将文件指针移动到文件末尾 + *file_size += ftell(fp)+3; // 获取当前文件指针位置,即文件大小 + fseek(fp, 0, SEEK_SET); // 将文件指针移回文件开头 + fclose(fp); + } + file_count++; + } + } } else if (ent->d_type == DT_DIR) // 目录 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 38fc9fb12..3163c01f4 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 @@ -330,8 +330,8 @@ void MsgCenterNotifyONtimeProc(const Topic topic, Request* req) unused(req); // The alarm notification is not displayed if the incoming call notification is already being processed // cywee_save_data(); - 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, "保存每小时站立数据"); -- 2.17.1