From: Caisking <3449750381@qq.com> Date: Mon, 1 Jul 2024 08:25:43 +0000 (+0800) Subject: 增加睡眠数据 X-Git-Tag: release_V1.2.70_20241020_135402~908 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=fafef225749139ab9f32df60b654ddcf8834afc2;p=mirrors%2FFD230.git 增加睡眠数据 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepModel.h b/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepModel.h index a596d09b1..00735930c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepModel.h @@ -4,9 +4,9 @@ * @LastEditors: penglei 1624952103@qq.com * @LastEditTime: 2024-06-28 15:51:01 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepModel.h - * @Description: - * - * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. + * @Description: + * + * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. */ /*** * @Date: 2024-06-25 10:34:10 @@ -20,72 +20,69 @@ #include #include -//#include "AppViewIDs.h" -//#include "UiConfig.h" -//#include "sleep/include/SleepView.h" -//#include "sleep/include/SleepControlPresenter.h" +// #include "AppViewIDs.h" +// #include "UiConfig.h" +// #include "sleep/include/SleepView.h" +// #include "sleep/include/SleepControlPresenter.h" #include "string" - #define SLEEP_PATH "user/userdata/sleep/%s/sleep_%d.bin" #define SLEEP_DIR_PATH "user/userdata/sleep/%s" - namespace OHOS { - #pragma pack(1) +#pragma pack(1) typedef struct { - uint32_t fall_asleep_timestamp; //入睡 - uint32_t wake_up_timestamp; //出睡 - uint16_t total_time; //总时长 + uint32_t fall_asleep_timestamp; // 入睡 + uint32_t wake_up_timestamp; // 出睡 + uint16_t total_time; // 总时长 } NAP_T; typedef struct { uint32_t timestamp; // - uint8_t stat; //状态 - + uint8_t stat; // 状态 + } SLEEP_STATE_T; typedef struct { SLEEP_STATE_T sleep_status[20]; uint8_t status_num; - uint32_t fall_asleep_timestamp; //入睡 - uint32_t wake_up_timestamp; //出睡 - uint16_t total_time; //总时长 - uint16_t total_deep_sleep_time;//深睡 - uint16_t total_mild_sleep_time;//浅睡 - uint16_t total_rem_sleep_time;//清醒 - uint16_t total_wake_time;//动眼 + uint32_t fall_asleep_timestamp; // 入睡 + uint32_t wake_up_timestamp; // 出睡 + uint16_t total_time; // 总时长 + uint16_t total_deep_sleep_time; // 深睡 + uint16_t total_mild_sleep_time; // 浅睡 + uint16_t total_rem_sleep_time; // 清醒 + uint16_t total_wake_time; // 动眼 } SLEEP_T; - - #pragma pack() - bool save_nap_data(NAP_T *data); +#pragma pack() - uint32_t read_sleep_nap_data(char *data,uint32_t size,FILE *fp); - + bool save_nap_data(NAP_T *data); + uint32_t read_sleep_nap_data(char *data, uint32_t size, FILE *fp); void set_nap_data(NAP_T *data); - void set_sleep_data(SLEEP_T *data); - bool save_sleep_data(SLEEP_T *data); class SleepModel { public: static SleepModel &GetInstance(void); - void GetSleepTime(); // 获取睡眠时间 - std::string GetSleepStr(); // 解析睡眠时间 - void GetRestTime(); // 获取入睡时间 - std::string GetRestStr(); // 解析入睡时间 - void GetWalkTime(); // 获取醒来时间 - std::string GetWalkStr(); // 解析醒来时间 - void GetGoalTime(); // 获取目标休息时间(xx-xx) - std::string GetGoalStr(); // 解析目标休息时间 + void update_time_info(uint32_t timestamp, std::string &timeStr); + void update_sleep(SLEEP_T *data); + void set_sleep_goal(); + + int get_sleep_hour(); + int get_sleep_min(); + int get_sleep_goal(); + int get_sleep_total(); + std::string get_rest_str(); // 解析入睡时间 + std::string get_walk_str(); // 解析醒来时间 + std::string get_goal_str(); // 解析目标休息时间 private: SleepModel(); @@ -93,11 +90,12 @@ namespace OHOS SleepModel &operator=(const SleepModel &); virtual ~SleepModel(); - std::string sleepStr; - std::string restStr; - std::string walkStr; - std::string goalsleepStr; - std::string goalwalkStr; + std::string sleepStr{"--"}; + std::string walkStr{"--"}; + std::string goalStr{"--"}; + + uint8_t sleep_total_time = 0; + uint8_t goal_total_time = 0; }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepTimeView.h b/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepTimeView.h index 254087266..867cd550f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepTimeView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepTimeView.h @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-06-25 14:50:26 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-07-01 15:10:12 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepTimeView.h + */ /*** * @Date: 2024-06-25 14:50:26 * @LastEditors: Caisking 3449750381@qq.com @@ -54,7 +60,7 @@ namespace OHOS UILabelExt *sleeptitle{nullptr}; // 入睡时间标题 UILabelExt *walktitle{nullptr}; // 醒来标题 UILabelExt *apptitle{nullptr}; // 详情 - UILabelExt *rest{nullptr}; // 作息时间 + UILabelExt *goal{nullptr}; // 作息时间 UILabelExt *sleep{nullptr}; // 入睡时间 UILabelExt *walk{nullptr}; // 醒来时间 UIImageView *transverseline_1{nullptr}; // 横线1 diff --git a/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp index 2a430e086..255dbcedf 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp @@ -4,9 +4,9 @@ * @LastEditors: penglei 1624952103@qq.com * @LastEditTime: 2024-06-28 16:52:58 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp - * @Description: - * - * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. + * @Description: + * + * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. */ #include "sleep/include/SleepModel.h" @@ -15,23 +15,37 @@ #include "sleep/include/SleepControlPresenter.h" #include "custom_utils.h" #include - - - +#include "UiConfig.h" +#include "ui_resource_image.h" +#include "samgr_lite.h" +#include +#include +#include +#include +#include +#include +#include "wearable_log.h" +#include "ConfigModel.h" + +extern "C" errcode_t uapi_get_TIME_STR(uint32_t time, char *p_time, char separator, bool include_seconds, bool include_year); +extern "C" int get_sleep_time_from_config_model(void); +extern "C" int get_wake_up_time_from_config_model(); namespace OHOS { - static NAP_T nap_data = {0}; - static SLEEP_T sleep_data = {0}; - static SLEEP_STATE_T sleep_status = {0}; + + static NAP_T nap_data = {0}; + static SLEEP_T sleep_data = {0}; + static SLEEP_STATE_T sleep_status = {0}; + bool save_nap_data(NAP_T *data) { struct stat info; - char dir_path[64]={0}; - char file_path[64]={0}; - char day[12]={0}; - uapi_get_YYMMDD_Time(day,'\0'); + char dir_path[64] = {0}; + char file_path[64] = {0}; + char day[12] = {0}; + uapi_get_YYMMDD_Time(day, '\0'); - sprintf_s(dir_path,64,SLEEP_DIR_PATH,day); + sprintf_s(dir_path, 64, SLEEP_DIR_PATH, day); if (stat("user/userdata/sleep", &info) != 0) { if (mkdir("user/userdata/sleep", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) @@ -44,64 +58,62 @@ namespace OHOS { if (mkdir(dir_path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mkdir fail %s",dir_path); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mkdir fail %s", dir_path); return false; // Failed to create folder } } uint32_t creationTime; - int ret =uapi_get_timestampe_ss(&creationTime); + int ret = uapi_get_timestampe_ss(&creationTime); - sprintf_s(file_path,64,SLEEP_PATH,day,creationTime); + sprintf_s(file_path, 64, SLEEP_PATH, day, creationTime); FILE *fp; - fp=fopen(file_path,"wb+"); - if(fp==NULL) + fp = fopen(file_path, "wb+"); + if (fp == NULL) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "save_nap_sleep_data fopen fail"); return false; } - uint8_t sleep_type=0; - fwrite(&sleep_type,1,1,fp); + uint8_t sleep_type = 0; + fwrite(&sleep_type, 1, 1, fp); uint32_t fall_asleep_timestamp = data->fall_asleep_timestamp; - fwrite(&fall_asleep_timestamp,1,4,fp); + fwrite(&fall_asleep_timestamp, 1, 4, fp); uint32_t wake_up_timestamp = data->wake_up_timestamp; - fwrite(&wake_up_timestamp,1,4,fp); - - uint16_t total_time=data->total_time; - fwrite(&total_time,1,2,fp); + fwrite(&wake_up_timestamp, 1, 4, fp); + uint16_t total_time = data->total_time; + fwrite(&total_time, 1, 2, fp); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "save_nap_sleep_data succ"); fclose(fp); return true; - } void set_nap_data(NAP_T *data) - { - memset(&nap_data,0,sizeof(NAP_T)); - memcpy_s(&nap_data,sizeof(NAP_T),data,sizeof(NAP_T)); + { + memset(&nap_data, 0, sizeof(NAP_T)); + memcpy_s(&nap_data, sizeof(NAP_T), data, sizeof(NAP_T)); save_nap_data(&nap_data); } - uint32_t read_sleep_nap_data(char *data,uint32_t size,FILE *fp) + uint32_t read_sleep_nap_data(char *data, uint32_t size, FILE *fp) { - return fread(data,1,size,fp); + return fread(data, 1, size, fp); } - + bool save_sleep_data(SLEEP_T *data) { struct stat info; - char dir_path[64]={0}; - char file_path[64]={0}; - char day[12]={0}; - uapi_get_YYMMDD_Time(day,'\0'); + char dir_path[64] = {0}; + char file_path[64] = {0}; + char day[12] = {0}; + uapi_get_YYMMDD_Time(day, '\0'); - sprintf_s(dir_path,64,SLEEP_DIR_PATH,day); + sprintf_s(dir_path, 64, SLEEP_DIR_PATH, day); if (stat("user/userdata/sleep", &info) != 0) { if (mkdir("user/userdata/sleep", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) @@ -114,66 +126,177 @@ namespace OHOS { if (mkdir(dir_path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mkdir fail %s",dir_path); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mkdir fail %s", dir_path); return false; // Failed to create folder } } - + uint32_t creationTime; - int ret =uapi_get_timestampe_ss(&creationTime); + int ret = uapi_get_timestampe_ss(&creationTime); - sprintf_s(file_path,64,SLEEP_PATH,day,creationTime); + sprintf_s(file_path, 64, SLEEP_PATH, day, creationTime); FILE *fp; - fp=fopen(file_path,"wb+"); - if(fp==NULL) + fp = fopen(file_path, "wb+"); + if (fp == NULL) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "save_nap_sleep_data fopen fail"); return false; } uint8_t sleep_type = 1; - fwrite(&sleep_type,1,1,fp); + fwrite(&sleep_type, 1, 1, fp); uint32_t fall_asleep_timestamp = data->fall_asleep_timestamp; - fwrite(&fall_asleep_timestamp,1,4,fp); + fwrite(&fall_asleep_timestamp, 1, 4, fp); uint32_t wake_up_timestamp = data->wake_up_timestamp; - fwrite(&wake_up_timestamp,1,4,fp); + fwrite(&wake_up_timestamp, 1, 4, fp); - uint16_t total_time=data->total_time; - fwrite(&total_time,1,2,fp); + uint16_t total_time = data->total_time; + fwrite(&total_time, 1, 2, fp); - uint16_t total_deep_sleep_time=data->total_deep_sleep_time; - fwrite(&total_deep_sleep_time,1,2,fp); + uint16_t total_deep_sleep_time = data->total_deep_sleep_time; + fwrite(&total_deep_sleep_time, 1, 2, fp); - uint16_t total_mild_sleep_time=data->total_mild_sleep_time; - fwrite(&total_mild_sleep_time,1,2,fp); + uint16_t total_mild_sleep_time = data->total_mild_sleep_time; + fwrite(&total_mild_sleep_time, 1, 2, fp); - uint16_t total_rem_sleep_time=data->total_rem_sleep_time; - fwrite(&total_rem_sleep_time,1,2,fp); + uint16_t total_rem_sleep_time = data->total_rem_sleep_time; + fwrite(&total_rem_sleep_time, 1, 2, fp); - uint16_t total_wake_time=data->total_wake_time; - fwrite(&total_wake_time,1,2,fp); + uint16_t total_wake_time = data->total_wake_time; + fwrite(&total_wake_time, 1, 2, fp); - fwrite(data->sleep_status,sizeof(SLEEP_STATE_T),data->status_num,fp); + fwrite(data->sleep_status, sizeof(SLEEP_STATE_T), data->status_num, fp); fclose(fp); return true; } void set_sleep_data(SLEEP_T *data) - { - memset(&sleep_data,0,sizeof(SLEEP_T)); - memcpy_s(&sleep_data,sizeof(SLEEP_T),data,sizeof(SLEEP_T)); + { + memset(&sleep_data, 0, sizeof(SLEEP_T)); + memcpy_s(&sleep_data, sizeof(SLEEP_T), data, sizeof(SLEEP_T)); save_sleep_data(&sleep_data); + // 刷新model里面的数据 + SleepModel::GetInstance().update_sleep(&sleep_data); + } + SleepModel::SleepModel() + { + set_sleep_goal(); } - - SleepModel::SleepModel() {} SleepModel::~SleepModel() {} SleepModel &SleepModel::GetInstance() { static SleepModel instance; return instance; } + + void SleepModel::update_sleep(SLEEP_T *data) + { + if (data == NULL) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Invalid input data"); + return; + } + + // 打印数据 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "fall_asleep_timestamp:%d wake_up_timestamp:%d total_time:%d", + data->fall_asleep_timestamp, data->wake_up_timestamp, data->total_time); + + update_time_info(data->fall_asleep_timestamp, sleepStr); + update_time_info(data->wake_up_timestamp, walkStr); + + // 更新睡眠总时间 + sleep_total_time = data->total_time; + + // 更新一下配置 + set_sleep_goal(); + } + + void SleepModel::update_time_info(uint32_t timestamp, std::string &timeStr) + { + char labelTime[20]; + if (uapi_get_TIME_STR(timestamp, labelTime, '.', false, false) == ERRCODE_SUCC) + { + timeStr = std::string(labelTime); + } + else + { + timeStr = "--"; + } + } + + /* + 设置睡眠目标 + 前2个字节是显示睡眠小时 + 后2个字节显示睡眠分钟 + 需要单独解析出来。 + */ + void SleepModel::set_sleep_goal() + { + int goal_sleep = get_sleep_time_from_config_model(); + int goal_walk = get_wake_up_time_from_config_model(); + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "goal_sleep:%d goal_walk:%d", goal_sleep, goal_walk); + + // 提取小时部分(前2字节) + int goal_sleep_hour = goal_sleep >> 16; + // 提取分钟部分(后2字节) + int goal_sleep_min = goal_sleep & 0x00FF; + + std::ostringstream sleeposs; + sleeposs << std::setfill('0') << std::setw(2) << goal_sleep_hour << ":" << std::setw(2) << goal_sleep_min; + + std::string goalsleepStr = sleeposs.str(); + + // 提取小时部分(前2字节) + int goal_walk_hour = goal_walk >> 16; + // 提取分钟部分(后2字节) + int goal_walk_min = goal_walk & 0x00FF; + + std::ostringstream walkoss; + walkoss << std::setfill('0') << std::setw(2) << goal_walk_hour << ":" << std::setw(2) << goal_walk_min; + + std::string goalwalkStr = walkoss.str(); + + goalStr = goalsleepStr + "-" + goalwalkStr; + goal_total_time = goal_walk_hour * 60 + goal_walk_min; + } + // 获取睡眠总时长(小时) + int SleepModel::get_sleep_hour() + { + return sleep_total_time / 60; + } + // 获取睡眠总时长(分钟) + int SleepModel::get_sleep_min() + { + return sleep_total_time % 60; + } + // 获取睡眠总时长(目标) + int SleepModel::get_sleep_goal() + { + return goal_total_time; + } + // 获取睡眠总时长(实际) + int SleepModel::get_sleep_total() + { + return sleep_total_time; + } + // 解析入睡时间 + std::string SleepModel::get_rest_str() + { + return sleepStr; + } + // 解析醒来时间 + std::string SleepModel::get_walk_str() + { + return walkStr; + } + // 解析目标休息时间 + std::string SleepModel::get_goal_str() + { + return goalStr; + } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepTimeView.cpp b/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepTimeView.cpp index 7f234e0e1..24765744a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepTimeView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepTimeView.cpp @@ -29,11 +29,9 @@ namespace OHOS void SleepTimeView::SleepDataRefresh() { -#if 0 - rest->SetText(); - sleep->SetText(); - walk->SetText(); -#endif + sleep->SetText((SleepModel::GetInstance().get_rest_str()).c_str()); + walk->SetText((SleepModel::GetInstance().get_walk_str()).c_str()); + goal->SetText((SleepModel::GetInstance().get_goal_str()).c_str()); } void SleepTimeView::ClearAll() @@ -59,10 +57,10 @@ namespace OHOS delete apptitle; apptitle = nullptr; } - if (rest != nullptr) + if (goal != nullptr) { - delete rest; - rest = nullptr; + delete goal; + goal = nullptr; } if (sleep != nullptr) @@ -141,8 +139,9 @@ namespace OHOS apptitle->SetTextColor(Color::Gray()); /* ------------------------------- 数据label初始化 ------------------------------- */ restStr = "--"; - InitLabelAdapt(rest, 211, 95, 230, 47, "restlabel", restStr.c_str(), DEFAULT_VECTOR_FONT_FILENAME, 30); - rest->SetTextColor(Color::Gray()); + InitLabelAdapt(goal, 117, 95, 300, 50, "restlabel", restStr.c_str(), DEFAULT_VECTOR_FONT_FILENAME, 40); + // goal->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); + goal->SetTextColor(Color::Gray()); sleepStr = "--"; InitLabelAdapt(sleep, 99, 238, 230, 47, "sleeplabel", sleepStr.c_str(), DEFAULT_VECTOR_FONT_FILENAME, 30); sleep->SetTextColor(Color::Purple()); @@ -154,7 +153,7 @@ namespace OHOS Add(sleeptitle); Add(walktitle); Add(apptitle); - Add(rest); + Add(goal); Add(sleep); Add(walk); Add(transverseline_1); @@ -173,6 +172,7 @@ namespace OHOS } SetDraggable(true); SetTouchable(true); + SleepDataRefresh(); return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepView.cpp b/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepView.cpp index b959a4441..d0541a906 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepView.cpp @@ -26,16 +26,23 @@ namespace OHOS g_pSleepView = nullptr; } + // 刷新UI数据 void SleepView::SleepDataRefresh() { -#if 0 - time_minute->SetText(SleepModel::GetInstance().getstepnew()); - time_hour->SetText(SleepModel::GetInstance().getstepSleep()); - circleProgress_->SetValue(SleepModel::GetInstance().getstepvalue()); -#endif - Invalidate(); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Updata SleppTime!"); - RootView::GetInstance()->Invalidate(); + int sleep_hour = SleepModel::GetInstance().get_sleep_hour(); + int sleep_min = SleepModel::GetInstance().get_sleep_min(); + // 有数据则刷新 + if (sleep_hour != 0 || sleep_min != 0) + { + time_hour->SetText(std::to_string(sleep_hour).c_str()); + time_minute->SetText(std::to_string(sleep_min).c_str()); + + int value = (float(SleepModel::GetInstance().get_sleep_total()) / float(SleepModel::GetInstance().get_sleep_goal())) * 100; + circleProgress_->SetValue(value); + Invalidate(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Updata SleppTime!"); + RootView::GetInstance()->Invalidate(); + } } void SleepView::ClearAll() @@ -145,7 +152,7 @@ namespace OHOS circleProgress_->SetRadius(205); circleProgress_->SetStartAngle(320); circleProgress_->SetEndAngle(40); - circleProgress_->SetValue(50); + circleProgress_->SetValue(0); circleProgress_->SetBackgroundImagePosition(36, 26); /* -------------------------------- 将组件添加到根视图 ------------------------------- */ Add(progress_image); @@ -171,6 +178,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SleepView::InitPage fail"); return false; } + SleepDataRefresh(); // 刷新数据 SetDraggable(true); SetTouchable(true); return true; diff --git a/code/sdk/application/wearable/service/ble_service/blemoder/CMakeLists.txt b/code/sdk/application/wearable/service/ble_service/blemoder/CMakeLists.txt index 8636427bb..5e12163b5 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/CMakeLists.txt +++ b/code/sdk/application/wearable/service/ble_service/blemoder/CMakeLists.txt @@ -14,6 +14,7 @@ ${ROOT_DIR}/middleware/services/gui/uikit/utils/interfaces/kits ${ROOT_DIR}/application/wearable/nativeapp/nativeui/heartrate/include ${ROOT_DIR}/application/wearable/fd230app/nativeui/weather/include ${ROOT_DIR}/application/wearable/fd230app/nativeui/heart_blood/health_service +${ROOT_DIR}/application/wearable/fd230app/nativeui/sleep/include/ ${ROOT_DIR}/application/wearable/fd230app/nativeui/phone/include ${ROOT_DIR}/application/wearable/fd230app/nativeui/language/include ${ROOT_DIR}/application/wearable/fd230app/nativeui/language 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 930eef597..ac646ef41 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp @@ -28,6 +28,7 @@ #ifdef FD230 #include "TraingModel.h" #include "WeatherModel.h" +#include "SleepModel.h" #endif #include "AlmmgrAlarmClockManage.h" @@ -390,6 +391,9 @@ void ble_set_sleep_remind(msg_get_sleep_param_info_t data) printf("睡前提醒 %d\r\n",data.bedtime_alarm); p_ConfigModel->set_condigData_Int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SLEEP_REMIND,data.bedtime_alarm); + + //更新睡眠配置 + OHOS:: SleepModel::GetInstance().set_sleep_goal(); } return; } diff --git a/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp b/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp index 7caecfba0..407f9187f 100644 --- a/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp +++ b/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp @@ -1445,12 +1445,15 @@ void get_user_info_from_config_model(int user_info[5]) user_info[3] = OHOS::ConfigModel::GetInstance()->get_configData_int(OHOS::ConfigModel::CONFIGMODEL_ITEM_CUSTOM_DATA_HEIGHT); user_info[4] = OHOS::ConfigModel::GetInstance()->get_configData_int(OHOS::ConfigModel::CONFIGMODEL_ITEM_CUSTOM_DATA_WEARING_MODE); } + +//获取睡眠目标[入睡时间] int get_sleep_time_from_config_model(void) { int sleep_time = 0; sleep_time = OHOS::ConfigModel::GetInstance()->get_configData_int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SLEEP_BEDTIME); return sleep_time; } +//获取睡眠目标[醒来时间] int get_wake_up_time_from_config_model(void) { int wake_up_time = 0;