From: snickersun@163.com Date: Tue, 2 Jul 2024 12:37:39 +0000 (+0000) Subject: Merge #434 into sdk602patch0626 from sdk602patch0521 X-Git-Tag: release_V1.2.70_20241020_135402~889^2 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=53a2dab63aeed5d3db5a7b5feb99971b785da5ae;p=mirrors%2FFD230.git Merge #434 into sdk602patch0626 from sdk602patch0521 0521分支截止7月2日 代码合并到本分支 * sdk602patch0521: (77 commits squashed) - 修复表盘协议BUG - Merge branch 'sdk602patch0521' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0521 - 闹钟添加切换睡眠与小睡模式 - Merge branch 'sdk602patch0521' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into remotes/origin/sdk602patch0521 - 重构心率血氧存储内容 - 低电量修改 - Merge branch 'sdk602patch0521' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0521 - Merge branch 'sdk602patch0521' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0521 - 优化低电量关机 - 重构心率血氧存储 - Merge branch 'sdk602patch0521' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into remotes/origin/sdk602patch0521 - Merge branch 'sdk602patch0521' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into remotes/origin/sdk602patch0521 - 补交 - Merge branch 'sdk602patch0521' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0521 - 更改低电量报警 - 卡片设置增加按键监控 - Merge branch 'sdk602patch0521' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0521 - 下拉试图修改,图片采用直接读取内存取消采用Imagecach - Merge branch 'sdk602patch0521' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0521 - 同步表盘资源 - 勿扰模式视图修改,注释开机加载CLOCK_IAMGES - 血氧增加按键控制 - 增加心率按键控制 - ble扫描过滤去除,ble read属性更新 - Merge #416 into sdk602patch0521 from refs/changes/416/head Code review from 胡传军 * refs/changes/416/head: (8 commits squashed) - 修复表盘协议BUG - Merge branch &#39;sdk602patch0521&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0521 - 低电量修改 - Merge branch &#39;sdk602patch0521&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0521 - 优化低电量关机 - Merge branch &#39;sdk602patch0521&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0521 - 更改低电量报警 - ble扫描过滤去除,ble read属性更新 Signed-off-by: aliyun8003852482 <1224667075@qq.com> Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/416 - Merge branches 'sdk602patch0521' and 'sdk602patch0521' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0521 - 部分训练界面增加按键 - 其他卡片取消进入卡片设置 - 回退设置 - 支持res_only,ota_all flag制作 ota包 - update to V1.0.9 - Merge branch 'sdk602patch0521' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0521 - 修改步数等数据存储,从记录一小时内的增值,改为记录当前时间点总值 - 修改下拉图片显示错误问题 - Merge branch 'sdk602patch0521' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0521 - 补交 - 筛选表盘数据刷新 - LCD - LCD补交 - Merge #420 into sdk602patch0521 from refs/changes/420/head Code review from 胡传军 * refs/changes/420/head: (13 commits squashed) - 修复表盘协议BUG - Merge branch &#39;sdk602patch0521&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0521 - 低电量修改 - Merge branch &#39;sdk602patch0521&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0521 - 优化低电量关机 - Merge branch &#39;sdk602patch0521&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0521 - 更改低电量报警 - ble扫描过滤去除,ble read属性更新 - Merge branch &#39;sdk602patch0521&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0521 - 修改步数等数据存储,从记录一小时内的增值,改为记录当前时间点总值 - 补交 - LCD - LCD补交 Signed-off-by: aliyun8003852482 <1224667075@qq.com> Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/420 - Merge #422 into sdk602patch0521 from refs/changes/422/head 筛选表盘数据刷新 * refs/changes/422/head: (1 commits squashed) - 筛选表盘数据刷新 Signed-off-by: Caisking <3449750381@qq.com> Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/422 - Merge branch 'sdk602patch0521' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0521 - Merge branch 'sdk602patch0521' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0521 - 表盘BUG修复 - 优化时间戳获取时间字符串函数 - 增加睡眠数据 - AI语音ble协议更新,协议已测试,UI还需要修改 - 优化蓝牙产测lcd测试 - 表盘map增加误判断,避免错误id因为不当操作注册进来 - 增加设置心率周期检测AT - 设置心率检测优先级控制 - 增加心率检测 睡眠提醒 - Merge #423 into sdk602patch0521 from refs/changes/423/head Code review from 胡传军 * refs/changes/423/head: (17 commits squashed) - 修复表盘协议BUG - Merge branch &#39;sdk602patch0521&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0521 - 低电量修改 - Merge branch &#39;sdk602patch0521&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0521 - 优化低电量关机 - Merge branch &#39;sdk602patch0521&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0521 - 更改低电量报警 - ble扫描过滤去除,ble read属性更新 - Merge branch &#39;sdk602patch0521&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0521 - 修改步数等数据存储,从记录一小时内的增值,改为记录当前时间点总值 - 补交 - LCD - LCD补交 - Merge branch &#39;sdk602patch0521&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0521 - 表盘BUG修复 - AI语音ble协议更新,协议已测试,UI还需要修改 - 表盘map增加误判断,避免错误id因为不当操作注册进来 Signed-off-by: aliyun8003852482 <1224667075@qq.com> Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/423 - Merge #425 into sdk602patch0521 from refs/changes/425/head Code review from 袁清梦 * refs/changes/425/head: (7 commits squashed) - 筛选表盘数据刷新 - Merge branch &#39;sdk602patch0521&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0521 - 优化时间戳获取时间字符串函数 - 增加睡眠数据 - 增加设置心率周期检测AT - 设置心率检测优先级控制 - 增加心率检测 睡眠提醒 Signed-off-by: Caisking <3449750381@qq.com> Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/425 - 补交 - Merge branch 'sdk602patch0521' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0521 - Merge branch 'sdk602patch0521' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0521 - 修复睡眠闹钟bug - bt测试修改 - 修复视频表盘电量配置 - 增加睡眠前20分钟弹窗提醒 - 增加睡眠弹窗 睡眠开启勿扰模式 - 兼容PY25Q128LA NORFLASH - Merge #428 into sdk602patch0521 from refs/changes/428/head bt测试修改 * refs/changes/428/head: (1 commits squashed) - bt测试修改 Signed-off-by: aliyun8003852482 <1224667075@qq.com> Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/428 - 增加资源文件 - 同步原文件更新 - 协议bug修复,增加MP3目录获取(解析MP3还有问题) - Merge branch 'sdk602patch0521' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0521 - 放大设置卡片下方按键为400宽 - 增加早起弹窗 - Merge branch 'sdk602patch0521' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0521 - Merge branch 'sdk602patch0521' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0521 - 时间戳打印测试接口 - Merge #430 into sdk602patch0521 from refs/changes/430/head 优化蓝牙产测LCD测试,TP测试 * refs/changes/430/head: (1 commits squashed) - 优化蓝牙产测LCD测试,TP测试 Signed-off-by: aliyun6865282430 <1624952103@qq.com> Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/430 - 优化早安弹窗 - Merge branch 'sdk602patch0521' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0521 - 心率周期检测 Signed-off-by: snickersun@163.com Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/434 --- diff --git a/autobuild.sh b/autobuild.sh index c4813733a..6aef2a623 100755 --- a/autobuild.sh +++ b/autobuild.sh @@ -5,7 +5,7 @@ DATE=$(date +%Y%m%d_%H%M%S) HOMEDIR=$PWD DEFAULT_BUILD_TYPE=release DEFAULT_TARGET_PACK_NAME=pack_brandy_native_js -DEFAULT_CUSTOM_FW_VERSION=1.0.8 +DEFAULT_CUSTOM_FW_VERSION=1.0.9 TARGET_PACK_NAME=$DEFAULT_TARGET_PACK_NAME RELEASE_BUILD=$DEFAULT_BUILD_TYPE diff --git a/code/sdk/application/battery/service/battery_driver.cpp b/code/sdk/application/battery/service/battery_driver.cpp index cd83fd74b..25b050acf 100644 --- a/code/sdk/application/battery/service/battery_driver.cpp +++ b/code/sdk/application/battery/service/battery_driver.cpp @@ -450,6 +450,8 @@ static int battery_get_power_percentage(float voltage) static void get_avg_voltage(float *vol) { uint32_t current_time = 0; + float max_vol = 0; + float min_vol = 0; uapi_get_timestampe_ss(¤t_time); if(history_time == 0) history_time = current_time; @@ -459,24 +461,39 @@ static void get_avg_voltage(float *vol) if(sample_time >= 10) { sample_time = 0; - if(vol_num == 5) + if(vol_num == 7) { sum_vol -= history_data[left]; history_data[left] = 0; left++; - left = left % 5; + left = left % 7; vol_num--; } vol_num++; right++; - right = right % 5; + right = right % 7; history_data[right] = *vol; sum_vol += history_data[right]; } - if(vol_num != 0) - *vol = sum_vol / vol_num; - + if(vol_num > 0) + { + if(vol_num > 2) + { + min_vol = history_data[0]; + max_vol = history_data[0]; + for (int i = 0;i < vol_num; i++) + { + if (history_data[i] < min_vol) + min_vol = history_data[i]; + if (history_data[i] > max_vol) + max_vol = history_data[i]; + } + *vol = (sum_vol - max_vol - min_vol) / (vol_num - 2); + } + else + *vol = sum_vol / vol_num; + } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/add_card/include/AddCardPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/add_card/include/AddCardPresenter.h index ffaebdf7c..09ce84860 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/add_card/include/AddCardPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/add_card/include/AddCardPresenter.h @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-05-30 15:59:37 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-06-29 14:46:02 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/add_card/include/AddCardPresenter.h + */ /* * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. * Description: AddCardPresenter.h @@ -14,36 +20,38 @@ #include "KeyInputListener.h" #include "ModelListenerSample.h" -#define TOAST_KEEP_TIME 1000 - -namespace OHOS { -static const char *ADD_CARD_ADD = "addcardadd"; - -class AddCardView; -class AddCardModel; -class AddCardPresenter : public Presenter, public ModelListenerSample, - public UIView::OnClickListener, public UIView::OnDragListener, - public ListScrollListener { -public: - AddCardPresenter(); - ~AddCardPresenter() override; - - void OnStart() override; - void OnResume() override; - void OnStop() override; - void OnTickEvent() override; - void Notify() override {} - bool OnClick(UIView &view, const ClickEvent &event) override; - void OnScrollStart(int16_t index, UIView *view) override; - void OnScrollEnd(int16_t index, UIView *view) override; - void OnItemSelected(int16_t index, UIView* view) override; - bool OnDrag(UIView& view, const DragEvent& event) override; -private: - void ResetTickTimer(void); - AddCardModel *model{nullptr}; - uint64_t startTime{0}; - bool cardCountEvent{false}; -}; +#define TOAST_KEEP_TIME 1000 + +namespace OHOS +{ + static const char *ADD_CARD_ADD = "addcardadd"; + + class AddCardView; + class AddCardModel; + class AddCardPresenter : public Presenter, public ModelListenerSample, public UIView::OnClickListener, public UIView::OnDragListener, public ListScrollListener + { + public: + AddCardPresenter(); + ~AddCardPresenter() override; + + void OnStart() override; + void OnResume() override; + void OnStop() override; + void OnTickEvent() override; + void Notify() override {} + bool OnClick(UIView &view, const ClickEvent &event) override; + void OnScrollStart(int16_t index, UIView *view) override; + void OnScrollEnd(int16_t index, UIView *view) override; + void OnItemSelected(int16_t index, UIView *view) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + + private: + void ResetTickTimer(void); + AddCardModel *model{nullptr}; + uint64_t startTime{0}; + bool cardCountEvent{false}; + KeyInputListener *keyActListenr{nullptr}; + }; } #endif // ADD_CARD_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/add_card/src/AddCardItem.cpp b/code/sdk/application/wearable/fd230app/nativeui/add_card/src/AddCardItem.cpp index 5da769a44..2a2864bed 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/add_card/src/AddCardItem.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/add_card/src/AddCardItem.cpp @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-04-15 10:55:58 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-07-02 16:12:03 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/add_card/src/AddCardItem.cpp + */ /*** * @Date: 2024-04-15 10:55:58 * @LastEditors: Caisking 3449750381@qq.com @@ -35,8 +41,8 @@ namespace OHOS cardImg_.SetResizeMode(UIImageView::FILL); cardImg_.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE); - cardToggleButton_.SetPosition(133, 366); - cardToggleButton_.Resize(200, 100); + cardToggleButton_.SetPosition(33, 366); + cardToggleButton_.Resize(400, 100); cardToggleButton_.SetViewId("toggleButton1"); cardToggleButton_.SetStyle(STYLE_BACKGROUND_OPA, 0x00); diff --git a/code/sdk/application/wearable/fd230app/nativeui/add_card/src/AddCardPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/add_card/src/AddCardPresenter.cpp index b92ffb584..a803d3560 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/add_card/src/AddCardPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/add_card/src/AddCardPresenter.cpp @@ -19,11 +19,28 @@ namespace OHOS AddCardPresenter::~AddCardPresenter() { + if (keyActListenr != nullptr) + { + delete keyActListenr; + keyActListenr = nullptr; + } } void AddCardPresenter::OnStart() { Presenter::OnStart(); + if (keyActListenr == nullptr) + { + keyActListenr = new KeyInputListener(); + if (keyActListenr != nullptr) + { + RootView::GetInstance()->SetOnKeyActListener(keyActListenr); + } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ApplistPresenter::OnStart: new KeyInputListener fail"); + } + } } void AddCardPresenter::OnResume(void) diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/include/AlarmClockTimerConfig.h b/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/include/AlarmClockTimerConfig.h index 5c6376744..978755cbc 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/include/AlarmClockTimerConfig.h +++ b/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/include/AlarmClockTimerConfig.h @@ -1,3 +1,13 @@ +/* + * @Author: penglei 1624952103@qq.com + * @Date: 2024-06-07 11:18:25 + * @LastEditors: penglei 1624952103@qq.com + * @LastEditTime: 2024-06-29 14:34:23 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/include/AlarmClockTimerConfig.h + * @Description: + * + * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. + */ /* * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. * Description: AlarmClockTimer @@ -56,7 +66,8 @@ int32_t AlarmTimerInit(void); int32_t SetZeroAlarm(void); int32_t SetAlarm(AlarmType type, uint8_t week, uint8_t hour, uint8_t minute); int32_t AlarmGetCurrentTimeInfo(struct tm *timeInfo); - +void set_sleep_and_wake_time(void); +void get_sleep_time_notify(void); #ifdef __cplusplus } #endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp b/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp index 0b2fd5c7d..9e3af5bac 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-06-29 15:06:13 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-07-01 17:31:58 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp + */ /* * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. * Description: AlarmClockTimer @@ -17,197 +23,362 @@ #include "graphic_service.h" #include "AlarmClockTimerConfig.h" +#include "cywee_service.h" +#include "ConfigModelC.h" +#include "ConfigModel.h" +#include "heartrate/include/HeartModel.h" +#include "sleep/include/SleepModel.h" +#include "cat1_server_hal.h" #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif -static AlarmCtrl g_alarmCtrA; -static AlarmCtrl g_alarmCtrB; -static osTimerId_t g_AlarmHandle = nullptr; + static AlarmCtrl g_alarmCtrA; + static AlarmCtrl g_alarmCtrB; + static osTimerId_t g_AlarmHandle = nullptr; -void AlarmTimerEventPublish(uint16 topic, AlarmClockEventData data) -{ - int32 ret; - uint32 size = sizeof(AlarmClockEventData); - Request *request = nullptr; - BroadcastApi *broadcastApi = nullptr; - IUnknown *api = nullptr; - - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmTimerEventPublish topic=%u!!", topic); - - /* alloc request */ - request = SAMGR_AllocRequestMsg(0, PLATFORM_CORE, BROADCAST_SVR_ID, size); - if (request == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SAMGR_AllocRequestMsg failed"); - return; - } - request->msgId = topic; - ret = memcpy_s(request->data, size, (const void *)&data, size); - if (ret != EOK) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmTimerEventPublish memcpy_s rateDataTmp fail! ret = %d", ret); - return; - } - request->len = size; - request->msgValue = 0; - - /* public request */ - api = SAMGR_GetInstance()->GetFeatureApi(BROADCAST_SERVICE_NAME, BROADCAST_FEATURE_NAME); - if (api == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetFeatureApi failed"); - SAMGR_FreeRequestMsg(request); - return; - } - ret = api->QueryInterface(api, DEFAULT_VERSION, (void **)&broadcastApi); - if (ret != 0 || broadcastApi == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "QueryInterface failed"); - SAMGR_FreeRequestMsg(request); - return; +#define SLEPPNOTIFY 20 + + static int sleep_time = 0; + static int wake_up_time = 0; + static int sleep_notify_time = 0; + static int sleep_time_hour = 0; + static int sleep_time_min = 0; + + // 设置目标睡眠时间 + void set_sleep_and_wake_time(void) + { + sleep_time = get_sleep_time_from_config_model(); + wake_up_time = get_wake_up_time_from_config_model(); } - broadcastApi->PublishTopic((IUnknown *)broadcastApi, request); - broadcastApi->Release((IUnknown *)broadcastApi); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmTimerEventPublish end!!"); + // 设置睡眠提醒时间 + void get_sleep_time_notify(void) + { + int goal_hour = sleep_time >> 16; + int goal_min = (sleep_time & 0X00FF); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "goal_hour:%d goal_min:%d", goal_hour, goal_min); - return; -} + sleep_time_min = (goal_min >= SLEPPNOTIFY) ? goal_min - SLEPPNOTIFY : ((goal_min + 60) - SLEPPNOTIFY); // 避免分钟数为负 + sleep_time_hour = goal_hour; + if (goal_min < SLEPPNOTIFY) + { // 如果需要借位 + sleep_time_hour -= 1; // 小时减1 + } + // 确保小时数正确 + sleep_time_hour = (sleep_time_hour < 0) ? 23 : sleep_time_hour; // 处理从0点前20分钟的情况,变为前一天的23点40分 -static void AlarmCallBackProcA(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmCallBackProcA"); - AlarmClockEventData unuse; - GraphicService::GetInstance()->PostGraphicEvent( - std::bind(AlarmTimerEventPublish, TOPIC_EVENT_ALARM_RING, unuse)); -} + sleep_notify_time = (sleep_time_hour << 16) | sleep_time_min; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sleep_time_hour:%d sleep_time_min:%d sleep_notify_time:%d", sleep_time_hour, sleep_time_min, sleep_notify_time); + } + void AlarmEventPublish(uint16_t topic, uint8_t *data, uint32_t size) + { + int32 ret; -static void AlarmCallBackProcB(void) -{ - AlarmClockEventData unuse; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmCallBackProcB"); - GraphicService::GetInstance()->PostGraphicEvent( - std::bind(AlarmTimerEventPublish, TOPIC_EVENT_NEXTDAY_UPDATE, unuse)); - GraphicService::GetInstance()->PostGraphicEvent(SetZeroAlarm); -} + Request *request = NULL; + BroadcastApi *broadcastApi = NULL; + IUnknown *api = NULL; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChargerEventPublish topic=%u!!", topic); -static void on_time_CallBackProc(void) -{ - AlarmClockEventData unuse; - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "on_time_CallBackProc"); - GraphicService::GetInstance()->PostGraphicEvent( - std::bind(AlarmTimerEventPublish, TOPIC_EVENT_ON_TIME, unuse)); -} + /* alloc request */ + request = SAMGR_AllocRequestMsg(0, PLATFORM_CORE, BROADCAST_SVR_ID, size); + if (request == NULL) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SAMGR_AllocRequestMsg failed"); + return; + } + request->msgId = topic; + if (size > 0) + { + ret = memcpy_s(request->data, size, (const void *)data, size); + if (ret != EOK) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ChargerEventPublish memcpy_s rateDataTmp fail! ret = %d", ret); + return; + } + } + request->len = size; + request->msgValue = 0; + + /* public request */ + api = SAMGR_GetInstance()->GetFeatureApi(BROADCAST_SERVICE_NAME, BROADCAST_FEATURE_NAME); + if (api == NULL) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetFeatureApi failed"); + SAMGR_FreeRequestMsg(request); + return; + } + ret = api->QueryInterface(api, DEFAULT_VERSION, (void **)&broadcastApi); + if (ret != 0 || broadcastApi == NULL) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "QueryInterface failed"); + SAMGR_FreeRequestMsg(request); + return; + } + broadcastApi->PublishTopic((IUnknown *)broadcastApi, request); + broadcastApi->Release((IUnknown *)broadcastApi); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChargerEventPublish end!!"); -void AlarmScan(void *arg) -{ - struct tm curTime; - int32_t ret = AlarmGetCurrentTimeInfo(&curTime); - if (ret != ERRCODE_SUCC) { return; } + void AlarmTimerEventPublish(uint16 topic, AlarmClockEventData data) + { + int32 ret; + uint32 size = sizeof(AlarmClockEventData); + Request *request = nullptr; + BroadcastApi *broadcastApi = nullptr; + IUnknown *api = nullptr; - if (g_alarmCtrA.state == ALARM_STATUS_RUNNING) { - if ((g_alarmCtrA.callback != nullptr) && - (g_alarmCtrA.info.hour == curTime.tm_hour) && - (g_alarmCtrA.info.minute == curTime.tm_min)) { - g_alarmCtrA.callback(); - g_alarmCtrA.state = ALARM_STATUS_CREATED; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmTimerEventPublish topic=%u!!", topic); + + /* alloc request */ + request = SAMGR_AllocRequestMsg(0, PLATFORM_CORE, BROADCAST_SVR_ID, size); + if (request == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SAMGR_AllocRequestMsg failed"); + return; } - } + request->msgId = topic; + ret = memcpy_s(request->data, size, (const void *)&data, size); + if (ret != EOK) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmTimerEventPublish memcpy_s rateDataTmp fail! ret = %d", ret); + return; + } + request->len = size; + request->msgValue = 0; - if (g_alarmCtrB.state == ALARM_STATUS_RUNNING) { - if ((g_alarmCtrB.callback != NULL) && - //(g_alarmCtrB.info.week == curTime.tm_wday) && - (g_alarmCtrB.info.hour == curTime.tm_hour) && - (g_alarmCtrB.info.minute == curTime.tm_min) && - (g_alarmCtrB.info.second == curTime.tm_sec)) { - g_alarmCtrB.callback(); - g_alarmCtrB.state = ALARM_STATUS_CREATED; + /* public request */ + api = SAMGR_GetInstance()->GetFeatureApi(BROADCAST_SERVICE_NAME, BROADCAST_FEATURE_NAME); + if (api == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetFeatureApi failed"); + SAMGR_FreeRequestMsg(request); + return; } + ret = api->QueryInterface(api, DEFAULT_VERSION, (void **)&broadcastApi); + if (ret != 0 || broadcastApi == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "QueryInterface failed"); + SAMGR_FreeRequestMsg(request); + return; + } + broadcastApi->PublishTopic((IUnknown *)broadcastApi, request); + broadcastApi->Release((IUnknown *)broadcastApi); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmTimerEventPublish end!!"); + + return; } - if(curTime.tm_min==0 && curTime.tm_sec==0) + /*闹钟*/ + static void AlarmCallBackProcA(void) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "time: %d : %d",curTime.tm_hour,curTime.tm_min); - on_time_CallBackProc(); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmCallBackProcA"); + AlarmClockEventData unuse; + GraphicService::GetInstance()->PostGraphicEvent( + std::bind(AlarmTimerEventPublish, TOPIC_EVENT_ALARM_RING, unuse)); } -} -static int32_t AlarmCreate(AlarmCtrl *alarmCtrl, AlarmCallBack callback) -{ - if (alarmCtrl == nullptr) { - return ERRCODE_FAIL; - } - if (alarmCtrl->state == ALARM_STATUS_UNUSED) { - alarmCtrl->state = ALARM_STATUS_CREATED; - alarmCtrl->callback = callback; + /*NextDay*/ + static void AlarmCallBackProcB(void) + { + AlarmClockEventData unuse; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmCallBackProcB"); + GraphicService::GetInstance()->PostGraphicEvent( + std::bind(AlarmTimerEventPublish, TOPIC_EVENT_NEXTDAY_UPDATE, unuse)); + GraphicService::GetInstance()->PostGraphicEvent(SetZeroAlarm); } - return ERRCODE_SUCC; -} -int32_t AlarmTimerInit(void) -{ - int32_t timerStatus; - int32_t ret; - - g_alarmCtrA.state = ALARM_STATUS_UNUSED; - g_alarmCtrB.state = ALARM_STATUS_UNUSED; - g_AlarmHandle = osTimerNew(AlarmScan, osTimerPeriodic, nullptr, nullptr); - if (g_AlarmHandle == nullptr) { - return ERRCODE_FAIL; + static void on_time_CallBackProc(void) + { + AlarmClockEventData unuse; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "on_time_CallBackProc"); + GraphicService::GetInstance()->PostGraphicEvent( + std::bind(AlarmTimerEventPublish, TOPIC_EVENT_ON_TIME, unuse)); } - timerStatus = osTimerStart(g_AlarmHandle, ALARM_INTERVAL_MS); - if (timerStatus != osOK) { - return ERRCODE_FAIL; + + void AlarmScan(void *arg) + { + struct tm curTime; + int32_t ret = AlarmGetCurrentTimeInfo(&curTime); + if (ret != ERRCODE_SUCC) + { + return; + } + + if (g_alarmCtrA.state == ALARM_STATUS_RUNNING) + { + if ((g_alarmCtrA.callback != nullptr) && + (g_alarmCtrA.info.hour == curTime.tm_hour) && + (g_alarmCtrA.info.minute == curTime.tm_min)) + { + g_alarmCtrA.callback(); + g_alarmCtrA.state = ALARM_STATUS_CREATED; + } + } + + if (g_alarmCtrB.state == ALARM_STATUS_RUNNING) + { + if ((g_alarmCtrB.callback != NULL) && + //(g_alarmCtrB.info.week == curTime.tm_wday) && + (g_alarmCtrB.info.hour == curTime.tm_hour) && + (g_alarmCtrB.info.minute == curTime.tm_min) && + (g_alarmCtrB.info.second == curTime.tm_sec)) + { + g_alarmCtrB.callback(); + g_alarmCtrB.state = ALARM_STATUS_CREATED; + } + } + // 整点回调 + if (curTime.tm_min == 0 && curTime.tm_sec == 0) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "time: %d : %d", curTime.tm_hour, curTime.tm_min); + on_time_CallBackProc(); + } + // 睡眠总开关 + if (OHOS::ConfigModel::GetInstance()->get_configData_int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SLEEP)) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CONFIGMODEL_ITEM_SLEEP is OK"); + // 睡眠提醒[前提开启睡眠提醒] + if (OHOS::ConfigModel::GetInstance()->get_configData_int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SLEEP_REMIND)) + { + // 提醒一次 + if ((curTime.tm_hour == sleep_time_hour) && (curTime.tm_min == sleep_time_min) && (curTime.tm_sec == 0)) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "It's bedtime in 20 minutes"); + printf("20分钟后要睡觉啦!\r\n"); + AlarmEventPublish(TOPIC_EVENT_SLEEPNOTE, (uint8_t *)sleep_notify_time, 4); + // 设置状态为睡眠提醒 + OHOS::SleepModel::GetInstance().set_sleep_state(OHOS::SLEEPSTATE::SLEEPNOTIFY); + } + } + // 进入睡眠模式 + if ((curTime.tm_hour == (sleep_time >> 16)) && (curTime.tm_min == (sleep_time & 0X00FF)) && (curTime.tm_sec == 0)) + { + do_cywee_service_check_msg(CYWEE_SERVICE_CMD_SLEEPING_MODE, NULL); + // 睡眠弹窗 + printf("要睡觉啦!\r\n"); + AlarmEventPublish(TOPIC_EVENT_SLEEPNOTE, (uint8_t *)sleep_notify_time, 4); + // 设置状态为睡眠 + OHOS::SleepModel::GetInstance().set_sleep_state(OHOS::SLEEPSTATE::SLEPP); + } + // 退出睡眠模式 + if ((curTime.tm_hour == (wake_up_time >> 16)) && (curTime.tm_min == (wake_up_time & 0X00FF)) && (curTime.tm_sec == 0)) + { + printf("起床啦!\r\n"); + do_cywee_service_check_msg(CYWEE_SERVICE_CMD_NAP_SEDENTARY_MODE, NULL); + // 早安提醒 + AlarmEventPublish(TOPIC_EVENT_SLEEPNOTE, (uint8_t *)sleep_notify_time, 4); + // 设置状态为睡眠 + OHOS::SleepModel::GetInstance().set_sleep_state(OHOS::SLEEPSTATE::WALK); + } + } + + // 心率周期检测 [0 1 5 10] + if (OHOS::ConfigModel::GetInstance()->get_configData_int(OHOS::ConfigModel::CONFIGMODEL_ITEM_HEARTRATE_DETECTED)) + { + if (curTime.tm_min % (OHOS::ConfigModel::GetInstance()->get_configData_int(OHOS::ConfigModel::CONFIGMODEL_ITEM_HEARTRATE_DETECTED)) == 0 && curTime.tm_sec == 0) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Automatic heart rate detection starts"); + // 开启心率检测 如果有其他心率检测在进行,则不会进行检测[低优先级] + OHOS::HeartModel::GetInstance()->Heart_Control(OHOS::HeartState::Start, OHOS::HeartCheck::PASSIVITY); + } + } } - ret = AlarmCreate(&g_alarmCtrA, AlarmCallBackProcA); - if (ret != ERRCODE_SUCC) { - return ERRCODE_FAIL; + + static int32_t AlarmCreate(AlarmCtrl *alarmCtrl, AlarmCallBack callback) + { + if (alarmCtrl == nullptr) + { + return ERRCODE_FAIL; + } + if (alarmCtrl->state == ALARM_STATUS_UNUSED) + { + alarmCtrl->state = ALARM_STATUS_CREATED; + alarmCtrl->callback = callback; + } + return ERRCODE_SUCC; } - ret = AlarmCreate(&g_alarmCtrB, AlarmCallBackProcB); - if (ret != ERRCODE_SUCC) { - return ERRCODE_FAIL; + + int32_t AlarmTimerInit(void) + { + int32_t timerStatus; + int32_t ret; + + g_alarmCtrA.state = ALARM_STATUS_UNUSED; + g_alarmCtrB.state = ALARM_STATUS_UNUSED; + g_AlarmHandle = osTimerNew(AlarmScan, osTimerPeriodic, nullptr, nullptr); + if (g_AlarmHandle == nullptr) + { + return ERRCODE_FAIL; + } + timerStatus = osTimerStart(g_AlarmHandle, ALARM_INTERVAL_MS); + if (timerStatus != osOK) + { + return ERRCODE_FAIL; + } + ret = AlarmCreate(&g_alarmCtrA, AlarmCallBackProcA); + if (ret != ERRCODE_SUCC) + { + return ERRCODE_FAIL; + } + ret = AlarmCreate(&g_alarmCtrB, AlarmCallBackProcB); + if (ret != ERRCODE_SUCC) + { + return ERRCODE_FAIL; + } + set_sleep_and_wake_time(); + get_sleep_time_notify(); + return ERRCODE_SUCC; } - return ERRCODE_SUCC; -} -int32_t SetAlarm(AlarmType type, uint8_t week, uint8_t hour, uint8_t minute) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetAlarm %d %d %d %d", type, week, hour, minute); - if (type == ALARM_A) { - g_alarmCtrA.state = ALARM_STATUS_RUNNING; - g_alarmCtrA.info.hour = hour; - g_alarmCtrA.info.minute = minute; - } else if (type == ALARM_B) { - g_alarmCtrB.state = ALARM_STATUS_RUNNING; - g_alarmCtrB.info.week = week; - g_alarmCtrB.info.hour = hour; - g_alarmCtrB.info.minute = minute; - g_alarmCtrB.info.second = 1; - } else { - return ERRCODE_FAIL; + int32_t SetAlarm(AlarmType type, uint8_t week, uint8_t hour, uint8_t minute) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetAlarm %d %d %d %d", type, week, hour, minute); + if (type == ALARM_A) + { + g_alarmCtrA.state = ALARM_STATUS_RUNNING; + g_alarmCtrA.info.hour = hour; + g_alarmCtrA.info.minute = minute; + } + else if (type == ALARM_B) + { + g_alarmCtrB.state = ALARM_STATUS_RUNNING; + g_alarmCtrB.info.week = week; + g_alarmCtrB.info.hour = hour; + g_alarmCtrB.info.minute = minute; + g_alarmCtrB.info.second = 1; + } + else + { + return ERRCODE_FAIL; + } + return ERRCODE_SUCC; } - return ERRCODE_SUCC; -} -int32_t SetZeroAlarm(void) -{ - struct tm curTime; - int32_t ret = AlarmGetCurrentTimeInfo(&curTime); - if (ret != ERRCODE_SUCC) { - return ERRCODE_FAIL; + int32_t SetZeroAlarm(void) + { + struct tm curTime; + int32_t ret = AlarmGetCurrentTimeInfo(&curTime); + if (ret != ERRCODE_SUCC) + { + return ERRCODE_FAIL; + } + int32_t weekday = (++curTime.tm_wday) % 7; + return SetAlarm(ALARM_B, weekday, 0, 0); } - int32_t weekday = (++curTime.tm_wday) % 7; - return SetAlarm(ALARM_B, weekday, 0, 0); -} -int32_t AlarmGetCurrentTimeInfo(struct tm *timeInfo) -{ - if (timeInfo == nullptr) { - return ERRCODE_FAIL; + int32_t AlarmGetCurrentTimeInfo(struct tm *timeInfo) + { + if (timeInfo == nullptr) + { + return ERRCODE_FAIL; + } + time_t sec = time(nullptr); + localtime_r(&sec, timeInfo); + return ERRCODE_SUCC; } - time_t sec = time(nullptr); - localtime_r(&sec, timeInfo); - return ERRCODE_SUCC; -} #ifdef __cplusplus } diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenModel.h b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenModel.h index 10522899e..01228ae73 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenModel.h @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-04-15 10:55:58 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-06-29 16:47:41 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenModel.h + */ #ifndef BLOOD_OXYGEN_MODEL_H #define BLOOD_OXYGEN_MODEL_H @@ -6,6 +12,12 @@ namespace OHOS { + // 血氧检测状态 + enum class BloodState + { + End = 0, + Start, + }; class BloodOxygenModel { public: @@ -43,6 +55,8 @@ namespace OHOS void Blood_Stop(); void Blood_Start(); + void Blood_Control(BloodState state); + private: bool OxygenView; bool BandoffView; @@ -54,6 +68,7 @@ namespace OHOS uint16_t SPO2_; uint64_t timestamp_ms; int32_t wear_; + bool startspo2{false}; uint8_t unwear_counter_; uint8_t valid_counter_; diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenModel.cpp index 1dcf25f05..f02ca0f2e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenModel.cpp @@ -6,6 +6,8 @@ #include "heart_blood/health_service/health_service.h" #include "custom_utils.h" extern "C" errcode_t uapi_get_timestamp_ms(uint64_t *tm); +#include "custom_utils.h" +#include "ppg_service.h" #define MAX_UNWARE_COUNT 30 #define MAX_VALID_HRS_COUNT 30 @@ -38,6 +40,24 @@ namespace OHOS } /* ---------------------------------- 状态检测 ---------------------------------- */ + // 血氧监控 + void BloodOxygenModel::Blood_Control(BloodState state) + { + if (state == BloodState::End && startspo2 == true) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "startspo2 End"); + uint8_t md = PPG_SERVICE_CMD_TYPE_STOP_SPO2_TEST; + send_ppg_cmd_msg(md); + startspo2 = false; + } + else if (state == BloodState::Start && startspo2 == false) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "startspo2 Start"); + uint8_t md = PPG_SERVICE_CMD_TYPE_DO_SPO2_TEST; + send_ppg_cmd_msg(md); + startspo2 = true; + } + } void BloodOxygenModel::Blood_Start() { // 进行初始化操作 @@ -175,9 +195,10 @@ namespace OHOS data->timestamp = BloodOxygenPresenter::GetInstance()->GetCurrentTime(); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%d %d", spo2, data->timestamp); SetCheckTime(data->timestamp); - HealthService::GetInstance()->UpdateBloodOxygenData(*data); + HealthService::GetInstance()->UpdateHealthData(*data); delete data; /* -------------------------------------------------------------------------- */ } } + } diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp index 8847d7653..ad78066ad 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp @@ -36,7 +36,7 @@ #include "custom_utils.h" #include "cywee_service.h" -#define BLOODKEYABLE 0 +#define BLOODKEYABLE 1 namespace OHOS { static constexpr uint16_t PROGRESS_VALUE_MIN = 0; @@ -77,13 +77,6 @@ namespace OHOS BloodOxygenPresenter::~BloodOxygenPresenter() { -#if BLOODKEYABLE - if (keyActListenr != nullptr) - { - delete keyActListenr; - keyActListenr = nullptr; - } -#endif g_pMainView = nullptr; } BloodOxygenPresenter *BloodOxygenPresenter::GetInstance() @@ -95,20 +88,6 @@ namespace OHOS { Presenter::OnStart(); WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodOxygenPresenter::On Start "); -#if BLOODKEYABLE - if (keyActListenr == nullptr) - { - keyActListenr = new KeyInputListener(); - if (keyActListenr != nullptr) - { - RootView::GetInstance()->SetOnKeyActListener(keyActListenr); - } - else - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenPresenter::OnStart: new KeyInputListener fail"); - } - } -#endif } void BloodOxygenPresenter::OnPause(void) {} @@ -151,17 +130,18 @@ namespace OHOS bool BloodOxygenPresenter::OnKeyAct(UIView &view, const KeyEvent &event) { #if BLOODKEYABLE - WEARABLE_LOGD("", "into the view is: %s\n", typeid(view).name()); - uint16 keyID = event.GetKeyId(); - WEARABLE_LOGD("", "into key! keyID %u\n", keyID); - // 如果是power键就返回上一级 - if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER)) + unsigned short keyID = event.GetKeyId(); + unsigned short keyState = event.GetState(); + // 如果是power键,且是亮屏状态,按键释放就返回上一级 + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0) { - // uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); + // 关闭血氧检测 + BloodOxygenModel::GetInstance()->Blood_Control(BloodState::End); + // 回退 + NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST, TransitionType::TRANSITION_ZOOM); } -#endif return true; +#endif } /* ---------------------------------- 状态监听 ---------------------------------- */ bool BloodOxygenPresenter::OnClick(UIView &view, const ClickEvent &event) @@ -219,8 +199,9 @@ namespace OHOS { BloodCheckView::GetInstance()->GetImageAnimator()->Stop(); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetCheckStatus : false"); - uint8_t md = PPG_SERVICE_CMD_TYPE_STOP_SPO2_TEST; - send_ppg_cmd_msg(md); + // 关闭血氧检测 + BloodOxygenModel::GetInstance()->Blood_Control(BloodState::End); + startspo2 = true; } } @@ -236,8 +217,9 @@ namespace OHOS if (startspo2 == true) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetCheckStatus : true"); - uint8_t md = PPG_SERVICE_CMD_TYPE_DO_SPO2_TEST; - send_ppg_cmd_msg(md); + // 开启血氧检测 + BloodOxygenModel::GetInstance()->Blood_Control(BloodState::Start); + startspo2 = false; } } @@ -300,6 +282,7 @@ namespace OHOS BloodOxygenModel::GetInstance()->Blood_Stop(); } } + void BloodOxygenPresenter::Notify(void) { ProgressNotify(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenView.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenView.cpp index d75edf6c0..5e8b9f4c0 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenView.cpp @@ -397,11 +397,15 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::OnStart"); display_time = DisplayBrightnessModel::GetInstance()->GetScreenDurationTime(); display_api->set_screen_auto_off_timeout(300 * 1000); // 设置常亮 + View::OnStart(); if (!InitBloodView()) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::InitBloodView fail"); } + // 增加按键监听 + RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::BloodOxygenPresenter::GetInstance(); + RootView::GetInstance()->SetOnKeyActListener(keyactListener); } void BloodOxygenView::OnSetUpView() diff --git a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothModel.cpp index 2dd3fc9d7..df0c44139 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothModel.cpp @@ -601,8 +601,8 @@ void BtGapPairConfirmedCallback(const bd_addr_t *bdAddr, int req_type, int numbe void BtGapDiscoveryResultCallback(const bd_addr_t *bdAddr) { if ((gap_get_device_class(bdAddr) & 0x200) != 0) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BtGapDiscoveryResultCallback: Mobile Phone Device"); - return; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BtGapDiscoveryResultCallback: Mobile Phone Device"); + //return; } if (bdAddr == nullptr) { @@ -795,12 +795,12 @@ void BluetoothModel::BtGapAclStateChangedHandle(gap_acl_state_t state, unsigned // 回调:ACL连接状态上报 void GapAclStateChangedCallback(const bd_addr_t *bdAddr, gap_acl_state_t state, unsigned int reason) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "bt GapAclStateChangedCallback state %d, reason %x succ or err", state, reason); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "addr: %02x%02x%02x%02x%02x%02x", + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bt GapAclStateChangedCallback state %d, reason %x succ or err", state, reason); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "addr: %02x%02x%02x%02x%02x%02x", bdAddr->addr[5], bdAddr->addr[4], bdAddr->addr[3], /* mac下标 0 1 2 3 4 5 */ bdAddr->addr[2], bdAddr->addr[1], bdAddr->addr[0]); /* mac下标 0 1 2 3 4 5 */ if ((gap_get_device_class(bdAddr) & 0x200) != 0) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GapAclStateChangedCallback: Mobile Phone Device"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GapAclStateChangedCallback: Mobile Phone Device"); return; } GraphicService::GetInstance()->PostGraphicEvent( @@ -971,6 +971,22 @@ static void BtGattsRequestWriteCallback(uint8_t serverId, uint16_t connId, gatts WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "BtGattsRequestWriteCallback"); } +/* 与设备建立A2DP连接 */ +static int wstp_a2dp_snk_connect(const bd_addr_t *bd_addr) +{ + int ret = a2dp_snk_connect(bd_addr); + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP,"a2dp_snk_connect ret(int): %x\n", ret); + return ret; +} + +/* 与设备断开A2DP连接 */ +static int wstp_a2dp_snk_disconnect(const bd_addr_t *bd_addr) +{ + int ret = a2dp_snk_disconnect(bd_addr); + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP,"a2dp_snk_disconnect ret(int): %x\n", ret); + return ret; +} + static void BtA2dpSnkAcceptTimerStop(void) { WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "stop timer\n"); @@ -1045,6 +1061,7 @@ static void BtA2dpSnkConnectStateChangedCb(bd_addr_t *bd_addr, int conn_state) { WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "addr: ****%02x%02x%02x%02x conn_state: %x\n", bd_addr->addr[3], bd_addr->addr[2], bd_addr->addr[1], bd_addr->addr[0], conn_state); /* 3 2 1 0 idx */ + } static void BtA2dpSnkStartStreamReqCb(bd_addr_t *bd_addr) @@ -1129,9 +1146,6 @@ void BtA2dpInit(void) void BtA2dpDeInit(void) { - - - a2dp_src_deregister_callbacks(&g_a2dpSrcCallbacks); a2dp_snk_deregister_callbacks(&g_a2dp_snk_callbacks); diff --git a/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/include/DnotDisturbView.h b/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/include/DnotDisturbView.h index 2fdaf4be4..80db09b20 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/include/DnotDisturbView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/include/DnotDisturbView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-10 11:58:15 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-06-07 18:46:54 + * @LastEditTime: 2024-06-29 16:04:53 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/include/DnotDisturbView.h */ #ifndef DNOTDISTURB_VIEW_H @@ -41,9 +41,8 @@ namespace OHOS void ClearAll(void); UIScrollView *scrollView = nullptr; UILabelExt *showTitleLabel{nullptr}; - UIImageView *background{nullptr}; UIImageView *DnotDisturbImage{nullptr}; - UILabel *AttentionLabel{nullptr}; + UILabelExt *AttentionLabel{nullptr}; UILabelButtonExt *ButtonOn; UILabelButtonExt *ButtonOff; }; diff --git a/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbView.cpp b/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbView.cpp index 0599c1525..03ce7a72b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-10 11:58:21 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-06-07 18:51:22 + * @LastEditTime: 2024-06-29 16:30:35 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbView.cpp */ #include "dnotdisturb/include/DnotDisturbView.h" @@ -16,6 +16,7 @@ namespace OHOS { + static constexpr const char *DROPDOWN_DNOTDISTURB_IMAGE = "/user/res/dropdown/DROPDOWN_DNOTDISTURB.bin"; static DnotDisturbView *g_pDnotDisturbView{nullptr}; DnotDisturbView::DnotDisturbView() @@ -27,7 +28,6 @@ namespace OHOS DnotDisturbView::~DnotDisturbView() { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DnotDisturbView::~DnotDisturbView"); - ClearAll(); g_pDnotDisturbView = nullptr; } @@ -48,12 +48,6 @@ namespace OHOS showTitleLabel = nullptr; } - if (background != nullptr) - { - delete background; - background = nullptr; - } - if (DnotDisturbImage != nullptr) { delete DnotDisturbImage; @@ -82,7 +76,7 @@ namespace OHOS void DnotDisturbView::DnotDisturbViewInit(void) { - + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DnotDisturbView::DnotDisturbViewInit"); if (scrollView == nullptr) { scrollView = new UIScrollView(); @@ -117,27 +111,22 @@ namespace OHOS showTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); showTitleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); /* -------------------------------------------------------------------------- */ - background = new UIImageView(); - if (background == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DnotDisturbView::background new fail!!"); - return; - } - background->SetPosition(186, 116); - ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, background, DROPDOWN_ICONELLIPSEPURPLE); - /* -------------------------------------------------------------------------- */ DnotDisturbImage = new UIImageView(); if (DnotDisturbImage == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DnotDisturbView::DnotDisturbImage new fail!!"); return; } - DnotDisturbImage->SetPosition(186, 116, 94, 94); + DnotDisturbImage->SetPosition(186, 110); + DnotDisturbImage->Resize(94, 94); + DnotDisturbImage->SetStyle(STYLE_BACKGROUND_COLOR, 0xff8120e2); + DnotDisturbImage->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + DnotDisturbImage->SetStyle(STYLE_BORDER_RADIUS, 100); DnotDisturbImage->SetAutoEnable(false); DnotDisturbImage->SetResizeMode(UIImageView::CENTER); - ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, DnotDisturbImage, DROPDOWN_DNOTDISTURB); + DnotDisturbImage->SetSrc(DROPDOWN_DNOTDISTURB_IMAGE); /* -------------------------------------------------------------------------- */ - AttentionLabel = new UILabel(); + AttentionLabel = new UILabelExt(); if (AttentionLabel == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DnotDisturbView::AttentionLabel new fail!!"); @@ -146,8 +135,7 @@ namespace OHOS AttentionLabel->SetPosition(33, 228, 400, 70); AttentionLabel->SetStyle(STYLE_TEXT_FONT, 30); AttentionLabel->SetStyle(STYLE_LINE_HEIGHT, 35); - // AttentionLabel->SetText("开启勿扰模式,手表将不会发出震动与铃声,是否开启"); - SetLabelId(AttentionLabel, STR_DO_NOT_DISTURB_MODE); + AttentionLabel->SetTextId(STR_DO_NOT_DISTURB_MODE); // 开启勿扰模式,手表将不会发出震动与铃声,是否开启 AttentionLabel->SetLineBreakMode(UILabelExt::LINE_BREAK_WRAP); AttentionLabel->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); AttentionLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); @@ -233,7 +221,6 @@ namespace OHOS { View::OnSetUpView(); scrollView->Add(showTitleLabel); - scrollView->Add(background); scrollView->Add(DnotDisturbImage); scrollView->Add(AttentionLabel); scrollView->Add(ButtonOn); @@ -256,6 +243,7 @@ namespace OHOS View::OnStop(); RootView::GetInstance()->RemoveAll(); RootView::GetInstance()->ClearOnKeyActListener(); + ClearAll(); return; } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/health_service.cpp b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/health_service.cpp index 6e8abc5c9..4b09d1c5e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/health_service.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/health_service.cpp @@ -29,8 +29,7 @@ namespace OHOS #endif } // static char *JSON_F_buf=NULL; - cJSON *heart_root = NULL; - cJSON *oxygen_root = NULL; + HealthService::HealthService() { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HealthService::HealthService"); @@ -67,7 +66,7 @@ namespace OHOS if (mkdir(HEALTH_JSON_PATH, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mkdir HEALTH_JSON_PATH is error"); - return false; // Failed to create folder + return false; } } if (stat(HEALTH_JSON_PATH_HEART, &info) != 0) @@ -75,7 +74,7 @@ namespace OHOS if (mkdir(HEALTH_JSON_PATH_HEART, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mkdir HEALTH_JSON_PATH_HEART is error"); - return false; // Failed to create folder + return false; } } if (stat(HEALTH_JSON_PATH_OXYGEN, &info) != 0) @@ -83,20 +82,13 @@ namespace OHOS if (mkdir(HEALTH_JSON_PATH_OXYGEN, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mkdir HEALTH_JSON_PATH_OXYGEN is error"); - return false; // Failed to create folder + return false; } } return true; } - /*生成文件*/ - std::string GetJsonFilePath(uint8_t type) - { - std::string currentDate = GetCurrentDate(); - const char *healthTypePath = (type == HEALTH_TYPE_HEART) ? HEALTH_JSON_PATH_HEART : HEALTH_JSON_PATH_OXYGEN; - return healthTypePath + currentDate + ".json"; - } /*生成bin*/ std::string GetBinFilePath(uint8_t type) { @@ -105,22 +97,27 @@ namespace OHOS return healthTypePath + currentDate + ".bin"; } - // 加载 JSON 数据 - bool HealthService::LoadJsonData(uint8_t type) + + /* --------------------------------- json操作 --------------------------------- */ + static constexpr const char *HEART_JSON_PATH = "/user/userdata/health/heart.json"; + static constexpr const char *BLOOD_JSON_PATH = "/user/userdata/health/blood.json"; + + // 读取血氧数据 + BloodOxygenData *HealthService::ReadBloodOxygenData() { + // 判断文件夹是否存在 if (!CreateHealthFolder()) { - return false; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateHealthFolder file"); + return nullptr; } - std::string jsonFilePath = GetJsonFilePath(type); - printf("GetJsonFilePath:%s\r\n", jsonFilePath.c_str()); - - std::ifstream inFile(jsonFilePath); + // 读取文件 + std::ifstream inFile(BLOOD_JSON_PATH); if (!inFile.is_open()) { - printf("Failed to open JSON file.\r\n"); - return false; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to open JSON file"); + return nullptr; } // 读取文件内容到字符串 @@ -128,316 +125,229 @@ namespace OHOS buffer << inFile.rdbuf(); std::string jsonDataString = buffer.str(); const char *jsonData = jsonDataString.c_str(); - printf("jsonData:%s\r\n", jsonData); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "jsonData: %s", jsonData); + + // 关闭文件 + inFile.close(); if (jsonDataString.empty()) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "jsonDataString is empty"); - inFile.close(); - return false; + return nullptr; } - cJSON *root = cJSON_Parse(jsonData); - if (root == NULL) + cJSON *oxygen_root = cJSON_Parse(jsonData); + if (oxygen_root == NULL) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to parse JSON data"); - inFile.close(); - return false; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "oxygen_root is empty"); + return nullptr; } - if (type == HEALTH_TYPE_HEART) - { - heart_root = root; - } - else if (type == HEALTH_TYPE_OXYGEN) - { - oxygen_root = root; - } + BloodOxygenData *data = new BloodOxygenData(); - // 释放 cJSON 对象内存 - cJSON_Delete(root); - // 关闭文件 - inFile.close(); - return true; - } - // 释放 JSON 数据 - void HealthService::ReleaseJsonData(uint8_t type) - { - if (type == HEALTH_TYPE_HEART) + cJSON *value_item = cJSON_GetObjectItem(oxygen_root, "value"); + cJSON *timestamp_item = cJSON_GetObjectItem(oxygen_root, "timestamp"); + + if (value_item && timestamp_item) { - cJSON_Delete(heart_root); + data->SPO2 = value_item->valueint; + data->timestamp = timestamp_item->valuedouble; } - if (type == HEALTH_TYPE_OXYGEN) + else { + // 读取的数据异常 cJSON_Delete(oxygen_root); - } - } - - // 读取血氧数据 - BloodOxygenData *HealthService::ReadBloodOxygenData() - { - if (!LoadJsonData(HEALTH_TYPE_OXYGEN)) - { + delete data; return nullptr; } - - BloodOxygenData *data = new BloodOxygenData(); - cJSON *latestData = cJSON_GetObjectItem(oxygen_root, "spo2_latest_data"); - if (latestData != NULL) - { - data->SPO2 = cJSON_GetObjectItem(latestData, "value")->valueint; - data->timestamp = cJSON_GetObjectItem(latestData, "timestamp")->valuedouble; - } - - ReleaseJsonData(HEALTH_TYPE_OXYGEN); + cJSON_Delete(oxygen_root); return data; } + // 读取心率数据 HeartRateData *HealthService::ReadHeartRateData() { - if (!LoadJsonData(HEALTH_TYPE_HEART)) + // 判断文件夹是否存在 + if (!CreateHealthFolder()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LoadJsonData is error "); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateHealthFolder file"); return nullptr; } - HeartRateData *data = new HeartRateData(); - cJSON *latestData = cJSON_GetObjectItem(heart_root, "heart_latest_data"); - if (latestData != NULL) + // 读取文件 + std::ifstream inFile(HEART_JSON_PATH); + if (!inFile.is_open()) { - // 读取心率值 - data->Heart = cJSON_GetObjectItem(latestData, "value")->valueint; - data->timestamp = static_cast(cJSON_GetObjectItem(latestData, "timestamp")->valueint); - - char *jsonStr = cJSON_Print(heart_root); - if (jsonStr != NULL) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartRootJSONData: %s", jsonStr); - cJSON_free(jsonStr); - } - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ReadHeartRateData: value %d timestamp %d", data->Heart, data->timestamp); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to open JSON file"); + // 创建一个默认值为 0的数据 存储到json里面 ? + return nullptr; } - ReleaseJsonData(HEALTH_TYPE_HEART); - return data; - } + // 读取文件内容到字符串 + std::stringstream buffer; + buffer << inFile.rdbuf(); + std::string jsonDataString = buffer.str(); + const char *jsonData = jsonDataString.c_str(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "jsonData: %s", jsonData); - bool HealthService::UpdateBloodOxygenData(const BloodOxygenData &data) - { - if (!LoadJsonData(HEALTH_TYPE_OXYGEN)) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LoadJsonData is error"); - // return false; - } + // 关闭文件 + inFile.close(); - if (oxygen_root == nullptr) + if (jsonDataString.empty()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "oxygen_root is first"); - oxygen_root = cJSON_CreateObject(); - if (oxygen_root == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to create cJSON object for oxygen_root"); - return false; - } - cJSON_AddItemToObject(oxygen_root, "spo2_latest_data", cJSON_CreateObject()); - cJSON_AddItemToObject(oxygen_root, "spo2_data_list", cJSON_CreateArray()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "jsonDataString is empty"); + return nullptr; } - cJSON *latestData = cJSON_GetObjectItemCaseSensitive(oxygen_root, "spo2_latest_data"); - if (latestData == NULL || !cJSON_IsObject(latestData)) + cJSON *heart_root = cJSON_Parse(jsonData); + if (heart_root == NULL) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to get spo2_latest_data object"); - cJSON_Delete(oxygen_root); - oxygen_root = nullptr; - return false; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "heart_root is empty"); + return nullptr; } - cJSON *SPO2 = cJSON_GetObjectItemCaseSensitive(latestData, "value"); - if (SPO2 == nullptr && !cJSON_IsNumber(SPO2)) - { - // Add spo2_latest_data - cJSON_AddItemToObject(latestData, "value", cJSON_CreateNumber(data.SPO2)); - cJSON_AddItemToObject(latestData, "timestamp", cJSON_CreateNumber(data.timestamp)); - } - else - { - cJSON_ReplaceItemInObject(latestData, "value", cJSON_CreateNumber(data.SPO2)); - cJSON_ReplaceItemInObject(latestData, "timestamp", cJSON_CreateNumber(data.timestamp)); - } + HeartRateData *data = new HeartRateData(); - // Update or add to spo2_data_list - cJSON *dataList = cJSON_GetObjectItem(oxygen_root, "spo2_data_list"); - if (dataList != NULL && cJSON_IsArray(dataList)) - { - // Check if data already exists in the list - bool dataExists = false; - cJSON *dataItem = NULL; - cJSON_ArrayForEach(dataItem, dataList) - { - cJSON *timestampItem = cJSON_GetObjectItemCaseSensitive(dataItem, "timestamp"); - if (timestampItem != NULL && cJSON_IsNumber(timestampItem) && timestampItem->valuedouble == data.timestamp) - { - cJSON_ReplaceItemInObject(dataItem, "value", cJSON_CreateNumber(data.SPO2)); - dataExists = true; - break; - } - } + cJSON *value_item = cJSON_GetObjectItem(heart_root, "value"); + cJSON *timestamp_item = cJSON_GetObjectItem(heart_root, "timestamp"); - if (!dataExists) - { - cJSON *newData = cJSON_CreateObject(); - cJSON_AddItemToObject(newData, "value", cJSON_CreateNumber(data.SPO2)); - cJSON_AddItemToObject(newData, "timestamp", cJSON_CreateNumber(data.timestamp)); - cJSON_AddItemToArray(dataList, newData); - } + if (value_item && timestamp_item) + { + data->Heart = value_item->valueint; + data->timestamp = timestamp_item->valuedouble; } - - if (!UpdateJsonData(HEALTH_TYPE_OXYGEN)) + else { - printf("UpdateJsonData failed.\r\n"); - ReleaseJsonData(HEALTH_TYPE_OXYGEN); - return false; + // 读取的数据异常 + cJSON_Delete(heart_root); + delete data; + return nullptr; } - /*存储bin*/ - std::string binFilePath = GetBinFilePath(HEALTH_TYPE_HEART); - FILE *fp = fopen(binFilePath.c_str(), "ab+"); - if (fp == NULL) - return false; - fwrite(&data.timestamp, 1, 4, fp); - fwrite(&data.SPO2, 1, 1, fp); - fclose(fp); - - ReleaseJsonData(HEALTH_TYPE_OXYGEN); - - return true; + cJSON_Delete(heart_root); + return data; } - - bool HealthService::UpdateHeartRateData(const HeartRateData &data) + // 保存血氧数据 + bool HealthService::UpdateHealthData(const BloodOxygenData &data) { - if (!LoadJsonData(HEALTH_TYPE_HEART)) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LoadJsonData is error"); - // return false; - } - - if (heart_root == nullptr) + // 判断文件夹是否存在 + if (!CreateHealthFolder()) { - heart_root = cJSON_CreateObject(); - if (heart_root == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to create cJSON object for heart_root"); - return false; - } - - cJSON_AddItemToObject(heart_root, "heart_latest_data", cJSON_CreateObject()); - cJSON_AddItemToObject(heart_root, "heart_data_list", cJSON_CreateArray()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateHealthFolder file"); + return false; } - cJSON *latestData = cJSON_GetObjectItemCaseSensitive(heart_root, "heart_latest_data"); - if (latestData == NULL || !cJSON_IsObject(latestData)) + // 判断文件是否存在 不存在即创建 并打开以输出模式 + std::ofstream outFile(BLOOD_JSON_PATH, std::ios::app); + if (!outFile.is_open()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to get heart_latest_data object"); - cJSON_Delete(heart_root); - heart_root = nullptr; + // 文件创建失败 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to create or open JSON file for writing"); return false; } - cJSON *Heart = cJSON_GetObjectItemCaseSensitive(latestData, "value"); - if (Heart == nullptr && !cJSON_IsNumber(Heart)) - { - // Add heart_latest_data - cJSON_AddItemToObject(latestData, "value", cJSON_CreateNumber(data.Heart)); - cJSON_AddItemToObject(latestData, "timestamp", cJSON_CreateNumber(data.timestamp)); - } - else + // 创建一个 JSON 对象 + cJSON *oxygen_root = cJSON_CreateObject(); + if (oxygen_root == NULL) { - cJSON_ReplaceItemInObject(latestData, "value", cJSON_CreateNumber(data.Heart)); - cJSON_ReplaceItemInObject(latestData, "timestamp", cJSON_CreateNumber(data.timestamp)); + outFile.close(); + return false; } - // // 更新heart_latest_data中的value和timestamp值 - // cJSON_AddItemToObject(latestData, "value", cJSON_CreateNumber(data.Heart)); - // cJSON_AddItemToObject(latestData, "timestamp", cJSON_CreateNumber(data.timestamp)); + cJSON_AddItemToObject(oxygen_root, "value", cJSON_CreateNumber(data.SPO2)); + cJSON_AddItemToObject(oxygen_root, "timestamp", cJSON_CreateNumber(data.timestamp)); - cJSON *dataList = cJSON_GetObjectItem(heart_root, "heart_data_list"); - if (dataList == NULL || !cJSON_IsArray(dataList)) + char *jsonData = cJSON_Print(oxygen_root); + if (jsonData == NULL) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "heart_data_list is null or not an array"); - cJSON_Delete(heart_root); - heart_root = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to generate JSON data"); + cJSON_free(oxygen_root); + outFile.close(); return false; } - int numData = cJSON_GetArraySize(dataList); - if (numData >= 360) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Data list is full (360 items)"); - return false; - } + // 写入 JSON 数据到文件 + outFile << jsonData; - // 添加新数据到dataList中 - cJSON *newData = cJSON_CreateObject(); - cJSON_AddItemToObject(newData, "value", cJSON_CreateNumber(data.Heart)); - cJSON_AddItemToObject(newData, "timestamp", cJSON_CreateNumber(data.timestamp)); - cJSON_AddItemToArray(dataList, newData); + cJSON_free(oxygen_root); + free(jsonData); + outFile.close(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UpdateHealthData JSON is ok"); - if (UpdateJsonData(HEALTH_TYPE_HEART) == false) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to update JSON data for heart rate"); - cJSON_Delete(heart_root); - heart_root = nullptr; - return false; - } - /*存储bin*/ - std::string binFilePath = GetBinFilePath(HEALTH_TYPE_HEART); + /* 存储bin文件[协议使用] */ + std::string binFilePath = GetBinFilePath(HEALTH_TYPE_OXYGEN); FILE *fp = fopen(binFilePath.c_str(), "ab+"); if (fp == NULL) + { return false; - fwrite(&data.timestamp, 1, 4, fp); - fwrite(&data.Heart, 1, 1, fp); + } + + fwrite(&data.timestamp, 4, 1, fp); + fwrite(&data.SPO2, 1, 1, fp); + fclose(fp); return true; } - bool HealthService::UpdateJsonData(uint8_t type) + // 存储心率 + bool HealthService::UpdateHealthData(const HeartRateData &data) { - std::string jsonFilePath = GetJsonFilePath(type); - std::ofstream outFile(jsonFilePath); + // 判断文件夹是否存在 + if (!CreateHealthFolder()) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateHealthFolder file"); + return false; + } + // 判断文件是否存在 不存在即创建 并打开以输出模式 + std::ofstream outFile(HEART_JSON_PATH, std::ios::app); if (!outFile.is_open()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to open file %s", jsonFilePath.c_str()); - // 创建新文件 - outFile.open(jsonFilePath); - if (!outFile.is_open()) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to create file %s", jsonFilePath.c_str()); - return false; - } + // 文件创建失败 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to create or open JSON file for writing"); + return false; } - char *jsonData = NULL; - cJSON *root = (type == HEALTH_TYPE_HEART) ? heart_root : oxygen_root; - if (root == NULL) + // 创建一个 JSON 对象 + cJSON *heart_root = cJSON_CreateObject(); + if (heart_root == NULL) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "JSON root is NULL"); outFile.close(); return false; } - jsonData = cJSON_Print(root); - printf("jsonData:%s\r\n", jsonData); + cJSON_AddItemToObject(heart_root, "value", cJSON_CreateNumber(data.Heart)); + cJSON_AddItemToObject(heart_root, "timestamp", cJSON_CreateNumber(data.timestamp)); + + char *jsonData = cJSON_Print(heart_root); if (jsonData == NULL) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to generate JSON data"); + cJSON_free(heart_root); outFile.close(); return false; } + // 写入 JSON 数据到文件 outFile << jsonData; + + cJSON_free(heart_root); + free(jsonData); outFile.close(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UpdateHealthData JSON is ok"); + + /* 存储bin文件[协议使用] */ + std::string binFilePath = GetBinFilePath(HEALTH_TYPE_HEART); + FILE *fp = fopen(binFilePath.c_str(), "ab+"); + if (fp == NULL) + { + return false; + } + + fwrite(&data.timestamp, 4, 1, fp); + fwrite(&data.Heart, 1, 1, fp); + + fclose(fp); - cJSON_free(jsonData); return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/health_service.h b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/health_service.h index a83c82ad4..5d1b797b8 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/health_service.h +++ b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/health_service.h @@ -1,4 +1,10 @@ -/*** +/*** + * @Date: 2024-06-14 11:34:19 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-06-28 19:49:27 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/health_service.h + */ +/*** * @Date: 2024-06-14 11:34:19 * @LastEditors: Caisking 3449750381@qq.com * @LastEditTime: 2024-06-24 16:08:36 @@ -59,14 +65,13 @@ namespace OHOS ~HealthService(); static HealthService *GetInstance(void); bool CreateHealthFolder(); - bool LoadJsonData(uint8_t type); // 加载json - BloodOxygenData *ReadBloodOxygenData(); // 读取血氧数据 - bool UpdateBloodOxygenData(const BloodOxygenData &data); // 更新血氧数据 - HeartRateData *ReadHeartRateData(); // 读取心率数据 - HeartPoints *ReadHeartRateDataList(); // 读取心率列表 - bool UpdateHeartRateData(const HeartRateData &data); // 更新心率数据 - void ReleaseJsonData(uint8_t type); // 释放json - bool UpdateJsonData(uint8_t type); // 更新json + bool LoadJsonData(uint8_t type); // 加载json + BloodOxygenData *ReadBloodOxygenData(); // 读取血氧数据 + HeartRateData *ReadHeartRateData(); // 读取心率数据 + bool UpdateHealthData(const HeartRateData &data); // 更新心率数据 + bool UpdateHealthData(const BloodOxygenData &data); + void ReleaseJsonData(uint8_t type); // 释放json + bool UpdateJsonData(uint8_t type); // 更新json }; } #endif // HEALTH_MODEL_H \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartModel.h b/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartModel.h index 028337283..91cf57ae7 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartModel.h @@ -81,6 +81,14 @@ extern "C" End = 0, Start, }; + enum class HeartCheck + { + RESTSTSTE = 0, // 未检测状态 + PASSIVITY, // 被动检测心率 + INITIATIVE, // 主动检测心率 + EXERCISE, // 运动心率 + }; + // 控制心率检测 typedef struct { uint32_t heartRatePerSec; @@ -137,7 +145,7 @@ extern "C" void SetCheckTime(uint64_t time); // 设置本次测试完的时间 uint16_t GetIndex(); // 测试点位 void SetIndex(uint16_t index); - void Heart_Control(HeartState state); + void Heart_Control(HeartState state, HeartCheck check); private: HealthAllDatas healthDatas; @@ -168,6 +176,8 @@ extern "C" uint8_t valid_counter_ = 0; // 有效数计数器 uint8_t disvalid_counter_ = 0; // 无效数计数器 uint8_t unwear_counter_ = 0; // 佩戴错误计数器 + + HeartCheck checkstate = HeartCheck::RESTSTSTE; // 目前检测状态 }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp index a19f7a4f3..13976a20a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp @@ -474,14 +474,21 @@ namespace OHOS /* ---------------------------------- 状态检测 ---------------------------------- */ // 控制心率检测 - void HeartModel::Heart_Control(HeartState state) + void HeartModel::Heart_Control(HeartState state, HeartCheck check) { + if (check < checkstate) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Higher execution instruction exists"); + return; + } if (state == HeartState::End && heartstate == true) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartState End"); uint8_t md = PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST; send_ppg_cmd_msg(md); heartstate = false; + // 复原检测状态 + checkstate = HeartCheck::RESTSTSTE; } else if (state == HeartState::Start && heartstate == false) { @@ -626,6 +633,8 @@ namespace OHOS // 结束本次测试 PRINT("MAX_DISVALID_HRS_COUNT\r\n"); Heart_Stop(); + // 关闭自动检测心率 如果有其他高级心率检测在进行,则不会进行关闭[低优先级] + HeartModel::GetInstance()->Heart_Control(HeartState::End, HeartCheck::PASSIVITY); return; } #if HEARTTEST @@ -639,9 +648,9 @@ namespace OHOS data->timestamp = HeartPresenter::GetInstance()->GetCurrentTime(); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " Save %d %d", data->Heart, data->timestamp); SetCheckTime(data->timestamp); - HealthService::GetInstance()->UpdateHeartRateData(*data); - // 更新卡片心率值 - // SetHeartRatePerSec(heart); + HealthService::GetInstance()->UpdateHealthData(*data); + // 关闭自动检测心率 如果有其他高级心率检测在进行,则不会进行关闭[低优先级] + HeartModel::GetInstance()->Heart_Control(HeartState::End, HeartCheck::PASSIVITY); } #endif } diff --git a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartPresenter.cpp index 0239388a6..180bc2550 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartPresenter.cpp @@ -35,7 +35,7 @@ #include "cywee_service.h" #include "custom_utils.h" -#define HEARTKEYABLE 0 +#define HEARTKEYABLE 1 namespace OHOS { @@ -63,7 +63,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to get timestamp"); return 0; } - + return time; } @@ -77,7 +77,7 @@ namespace OHOS // 秒级时间戳的差 int time_diff_seconds = new_time - old_time; // 转换为分钟的差值 - int time_diff_minutes = time_diff_seconds / 60; + int time_diff_minutes = time_diff_seconds / 60; WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "time_diff_seconds is %d time_diff_minute is %d", time_diff_seconds, time_diff_minutes); return time_diff_minutes; } @@ -90,13 +90,6 @@ namespace OHOS HeartPresenter::~HeartPresenter() { -#if HEARTKEYABLE - if (keyActListenr != nullptr) - { - delete keyActListenr; - keyActListenr = nullptr; - } -#endif g_pMainView = nullptr; } @@ -109,20 +102,6 @@ namespace OHOS { Presenter::OnStart(); WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HeartPresenter::On Start "); -#if HEARTKEYABLE - if (keyActListenr == nullptr) - { - keyActListenr = new KeyInputListener(); - if (keyActListenr != nullptr) - { - RootView::GetInstance()->SetOnKeyActListener(keyActListenr); - } - else - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartPresenter::OnStart: new KeyInputListener fail"); - } - } -#endif } void HeartPresenter::OnPause(void) {} @@ -158,17 +137,18 @@ namespace OHOS bool HeartPresenter::OnKeyAct(UIView &view, const KeyEvent &event) { #if HEARTKEYABLE - WEARABLE_LOGD("", "into the view is: %s\n", typeid(view).name()); - uint16 keyID = event.GetKeyId(); - WEARABLE_LOGD("", "into key! keyID %u\n", keyID); - // 如果是power键就返回上一级 - if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER)) + unsigned short keyID = event.GetKeyId(); + unsigned short keyState = event.GetState(); + // 如果是power键,且是亮屏状态,按键释放就返回上一级 + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0) { - // uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); + // 关闭心率检测 + HeartModel::GetInstance()->Heart_Control(HeartState::End,HeartCheck::INITIATIVE); + // 回退 + NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST, TransitionType::TRANSITION_ZOOM); } -#endif return true; +#endif } bool HeartPresenter::OnClick(UIView &view, const ClickEvent &event) @@ -226,9 +206,9 @@ namespace OHOS if (startheart == false) { HeartCheckView::GetInstance()->GetImageAnimator()->Stop(); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetCheckStatus : false"); - uint8_t md = PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST; - send_ppg_cmd_msg(md); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetCheckStatus false"); + // 关闭心率检测 + HeartModel::GetInstance()->Heart_Control(HeartState::End,HeartCheck::INITIATIVE); startheart = true; } } @@ -244,9 +224,10 @@ namespace OHOS HeartCheckView::GetInstance()->UpShowHeartText(); // 更新检测界面 if (startheart == true) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetCheckStatus : true"); - uint8_t md = PPG_SERVICE_CMD_TYPE_DO_PPG_TEST; - send_ppg_cmd_msg(md); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetCheckStatus true"); + // 开启心率检测 [UI优先级最高直接打断正在检测 重新检测] + HeartModel::GetInstance()->Heart_Control(HeartState::End,HeartCheck::INITIATIVE); + HeartModel::GetInstance()->Heart_Control(HeartState::Start,HeartCheck::INITIATIVE); startheart = false; } } @@ -256,7 +237,7 @@ namespace OHOS { if (HeartModel::GetInstance()->GetHeartCheckViewStatus() == true) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetWearStatus : false"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetWearStatus false"); HeartCheckView::GetInstance()->GetImageAnimator()->Stop(); // 跳转到异常检测界面 HeartView::GetInstance()->ChangeView(HEARTCHECKVIEW, HEARTRESULT); diff --git a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartView.cpp b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartView.cpp index d0398a93b..a94b2753b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartView.cpp @@ -417,6 +417,9 @@ namespace OHOS { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartView::InitHeartView fail"); } + // 增加按键监听 + RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::HeartPresenter::GetInstance(); + RootView::GetInstance()->SetOnKeyActListener(keyactListener); } void HeartView::OnSetUpView() 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 e71f14310..7f3bb11d2 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/include/MainPresenterSample.h +++ b/code/sdk/application/wearable/fd230app/nativeui/main/include/MainPresenterSample.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-01 15:10:34 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-05-09 10:00:40 + * @LastEditTime: 2024-06-29 11:19:40 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/include/MainPresenterSample.h */ @@ -35,7 +35,7 @@ namespace OHOS static constexpr const char *DROPDOWN_CLICK_BRIGHTENSCREEN = "dropdownclickbrightscreen"; static constexpr const char *DROPDOWN_CLICK_SETTING = "dropdownclicksetting"; // 设置 - static constexpr const char *DROPDOWN_CLICK_LIGHTING = "dropdownclicklighting"; // 手电筒 + static constexpr const char *DROPDOWN_CLICK_BLUETOOTH = "dropdownclickbluetooth"; // 蓝牙 static constexpr const char *DROPDOWN_CLICK_DNOTDISTURB = "dropdownclickdnotdisturb"; // 勿扰 static constexpr const char *DROPDOWN_CLICK_SAVEELE = "dropdownclicksaveele"; // 省电 static constexpr const char *DROPDOWN_CLICK_FINDMYPHONE = "dropdownclickfindmyphone"; // 找手机 diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/include/PullUpDownView.h b/code/sdk/application/wearable/fd230app/nativeui/main/include/PullUpDownView.h index 905d4e8d3..378d4450b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/include/PullUpDownView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/main/include/PullUpDownView.h @@ -1,3 +1,139 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-04-17 15:26:49 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-06-29 15:08:34 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/include/PullUpDownView.h + */ + +#if 1 +#ifndef PULL_UP_DOWN_VIEW_H +#define PULL_UP_DOWN_VIEW_H + +#include "graphic_types.h" +#include "wearable_log.h" +#include "components/ui_card_page.h" +#include "components/ui_view_group.h" +#include "components/ui_image_view.h" +#include "components/ui_label.h" +#include "components/ui_label_ext.h" +#include "components/ui_label_button.h" +#include "components/ui_box_progress.h" +#include "components/ui_image_animator.h" +#include "battery_hal.h" +#include "main/include/ConnectedStatusView.h" + +extern uint8_t battery_get_voltage(float *voltage); + +namespace OHOS +{ + static constexpr int16_t SETTING_INDEX = 0; + static constexpr int16_t LIGHTING_INDEX = 1; + static constexpr int16_t DNOTDISTURB_INDEX = 2; + static constexpr int16_t SAVEPOWER_INDEX = 3; + static constexpr int16_t FINDPHONE_INDEX = 4; + static constexpr int16_t MAX_INDEX = 5; + + typedef enum : uint8_t + { + DROPDOWNVIEW = 0, + CONNECTEDSTATUSVIEW, + MAX_DROPDOWNVIEWID, + } DROPDOWNVIEWID; + + class PullUpDownView : public UICardPage + { + public: + PullUpDownView(); + ~PullUpDownView() override; + static PullUpDownView *GetInstance(void); + void PreLoad(void) override; + void UnLoad(void) override; + void UpdatePhoneStatus(int status); + void UpdateEarPhoneStatus(int status); + void UpdateBlueToothStatus(int status); + void UpdateDnotDisturbStatus(int status); + void UpdateSignalStrengthStatusAndBatteryPosition(); + bool ChangeDropDownView(int16_t thisView); // 切换到"下拉控制中心"视图 + bool ChangeConnectedStatusView(int16_t thisView); // 切换到"连接状态"视图 + bool ClickFunc(int16_t interface); + void ChangeView(int16_t hideView, int16_t showView); + ConnectedStatusView *GetConnectedStatusView(void); + + UILabel *GetTimeLabel(); + UILabel *GetDateLabel(); + UILabel *GetWeekLabel(); + UIBoxProgress *GetProgress(); + + bool GetPhoneConnectedStatus(void); + bool GetEarPhoneConnectedStatus(void); + bool GetBlueToothConnectedStatus(void); + struct ImageConfig + { + int16_t x; + int16_t y; + int16_t w; + int16_t h; + const char *viewid; + const char *src; + UIView::OnClickListener *clicklistener; + }; + + private: + bool PullUpDownViewInit(); + bool InitBaseData(); // 初始化基础数据组件 + UIImageView *dropDownIconImageViweInit(ImageConfig &imageconfig); + void createDropDownIconImageViwe(void); + UIImageView *dropDownConnectedStatusImageViweInit(int16_t x, int16_t y, int16_t w, int16_t h); + void createDropDownConnectedStatusImageViwe(void); + + bool InitSingalComponentsView(); + void ClearAllConnectedStatusComponentsView(); + void ClearAllSingalComponentsView(); + void ClearAll(); + + int GetSignalStrength(void); + int CalculateSignalBars(int signalStrength); + void UpdateSignalBarDisplay(int signalBars, bool state); + void UpdateBatteryPosition(int signalBars); + void updateSignalDisplay(); + void UpdateCat1NoSignalisplay(bool state); + void UpdateCat14GDisplay(bool state); + + void PreLoadPullUpDownImageRes(void); + void UnLoadPullUpDownImageRes(void); + + private: + ConnectedStatusView *connectedStatusView{nullptr}; + + private: + UIViewGroup *group[MAX_DROPDOWNVIEWID]{nullptr}; + UIImageView *dropSetting{nullptr}; // 设置 + UIImageView *dropBluetooth{nullptr}; // 蓝牙 + UIImageView *dropDnotDisturb{nullptr}; // 勿扰模式 + UIImageView *dropSavePower{nullptr}; // 省电 + UIImageView *drofindPhone{nullptr}; // 找手机 + UIImageView *dropLine{nullptr}; // 线 + UIButton *connectedStatusBackgroundButton{nullptr}; // 放置连接状态icon的背景按钮 + UIImageView *showPhoneConnectedStatus{nullptr}; // 显示手机连接状态 + UIImageView *showEarPhoneConnectedStatus{nullptr}; // 显示耳机连接状态 + UIImageView *showBluetoothConnectedStatus{nullptr}; // 显示蓝牙连接状态 + UILabel *showTimeLabel{nullptr}; // 显示时间 + UILabel *showDateLabel{nullptr}; // 显示日期 + UILabel *showWeekLabel{nullptr}; // 显示星期 + UIImageView *showSignalStrength[4]{nullptr}; // 信号强度 + UILabel *Singal_4{nullptr}; // 4G图标 + UIImageView *NoSignal{nullptr}; // 无信号 + + UIImageView *batteryimage = nullptr; + UIBoxProgress *progress = nullptr; + + bool viewiInitStatus{false}; + }; +} +#endif + +#else /* * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-17 15:26:49 @@ -129,3 +265,4 @@ namespace OHOS }; } #endif +#endif \ No newline at end of file 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 1d62bc5b7..993177c91 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp @@ -38,11 +38,11 @@ namespace OHOS { std::map g_jumpView = { - {DROPDOWN_CLICK_SETTING, VIEW_SETTING}, // 设置 - {DROPDOWN_CLICK_LIGHTING, VIEW_CLASSIC_BLUETOOTH}, // 蓝牙 - {DROPDOWN_CLICK_DNOTDISTURB, VIEW_DNOTDISTURB}, // 勿扰 - {DROPDOWN_CLICK_SAVEELE, VIEW_SAVEELE}, // 省电模式 - {DROPDOWN_CLICK_FINDMYPHONE, VIEW_FIND_PHONE}, // 查找手机 + {DROPDOWN_CLICK_SETTING, VIEW_SETTING}, // 设置 + {DROPDOWN_CLICK_BLUETOOTH, VIEW_CLASSIC_BLUETOOTH}, // 蓝牙 + {DROPDOWN_CLICK_DNOTDISTURB, VIEW_DNOTDISTURB}, // 勿扰 + {DROPDOWN_CLICK_SAVEELE, VIEW_SAVEELE}, // 省电模式 + {DROPDOWN_CLICK_FINDMYPHONE, VIEW_FIND_PHONE}, // 查找手机 }; static MainPresenterSample *g_pMainPresenterSample = nullptr; @@ -144,13 +144,13 @@ namespace OHOS if (curViewId == CONNECTEDSTATUSBACKGROUNDBUTTON) { PullUpDownView::GetInstance()->ChangeView(DROPDOWNVIEW, CONNECTEDSTATUSVIEW); - PullUpDown_StopTimer(); //切换到连接状态视图时停止定时器 + PullUpDown_StopTimer(); // 切换到连接状态视图时停止定时器 return true; } else if (curViewId == CONNECTEDSTATUSVIEWCLOSEBUTTON) { PullUpDownView::GetInstance()->ChangeView(CONNECTEDSTATUSVIEW, DROPDOWNVIEW); - PullUpDown_StartTimer(1000);//切回下拉控制中心视图开启定时器 + PullUpDown_StartTimer(1000); // 切回下拉控制中心视图开启定时器 return true; } // if(&view == PullUpDownView::GetInstance()->GetConnectedStatusView()->GetCloseButton()) @@ -184,7 +184,7 @@ namespace OHOS if (cardId != WATCH_FACE) { SetCardModel::GetInstance().SetSelectedCard(cardId); - NativeAbility::GetInstance().ChangeSlice(VIEW_SET_CARD); + // NativeAbility::GetInstance().ChangeSlice(VIEW_ADD_CARD); } else { @@ -352,7 +352,7 @@ namespace OHOS if (previousCardId == HEART_RATE && cardId != HEART_RATE) { // 从心率卡片变为其他卡片时调用关闭心率检测的函数 - HeartModel::GetInstance()->Heart_Control(HeartState::End); + HeartModel::GetInstance()->Heart_Control(HeartState::End, HeartCheck::INITIATIVE); } // 更新上一个卡片的值 @@ -361,8 +361,9 @@ namespace OHOS switch (cardId) { case HEART_RATE: - // 开启心率检测 - HeartModel::GetInstance()->Heart_Control(HeartState::Start); + // 开启心率检测 [UI优先级最高直接打断正在检测 重新检测] + HeartModel::GetInstance()->Heart_Control(HeartState::End, HeartCheck::INITIATIVE); + HeartModel::GetInstance()->Heart_Control(HeartState::Start, HeartCheck::INITIATIVE); break; case COMPASS: diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp index b9bb68b9d..92d983fe3 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp @@ -1,3 +1,1083 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-06-26 18:14:24 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-07-01 09:30:03 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp + */ + +#if 1 +#include "PullUpDownView.h" +#include "wearable_log.h" +#include "UiConfig.h" +#include "common/screen.h" +#include "main/include/MainPresenterSample.h" +#include "screensetting/include/ScreenModels.h" +#include "settings/include/SettingModel.h" +#include "ui_resource_image.h" +#include "dnotdisturb/include/DnotDisturbModel.h" +#include "custom_utils.h" +#include "custom_runtime.h" +namespace OHOS +{ + + /* ---------------------------------- 坐标位置 ---------------------------------- */ + // 设置 + static constexpr uint16_t SETTING_IMG_X = 30; + static constexpr uint16_t SETTING_IMG_Y = 186; + static constexpr const char *DROPDOWN_SETTING_IMAGE = "/user/res/dropdown/DROPDOWN_SETTING.bin"; + + // 蓝牙 + static constexpr uint16_t BLUETOOTH_IMG_X = 76; + static constexpr uint16_t BLUETOOTH_IMG_Y = 76; + static constexpr const char *DROPDOWN_BLUETOOTH_IMAGE = "/user/res/dropdown/DROPDOWN_BLUETOOTH.bin"; + + // 勿扰 + static constexpr uint16_t DNOTDISTURB_IMG_X = 186; + static constexpr uint16_t DNOTDISTURB_IMG_Y = 30; + static constexpr const char *DROPDOWN_DNOTDISTURB_IMAGE = "/user/res/dropdown/DROPDOWN_DNOTDISTURB.bin"; + + // 省电 + static constexpr uint16_t SAVEPOWER_IMG_X = 296; + static constexpr uint16_t SAVEPOWER_IMG_Y = 76; + static constexpr const char *DROPDOWN_SAVEPOWER_IMAGE = "/user/res/dropdown/DROPDOWN_SAVEPOWER.bin"; + + // 找手机 + static constexpr uint16_t FINDPHONE_IMG_X = 342; + static constexpr uint16_t FINDPHONE_IMG_Y = 186; + static constexpr const char *DROPDOWN_FINDPHONE_IMAGE = "/user/res/dropdown/DROPDOWN_FINDPHONE.bin"; + + // line + static constexpr uint16_t LINE_IMG_X = 193; + static constexpr uint16_t LINE_IMG_Y = 430; + static constexpr const char *DROPDOWN_LINE_IMAGE = "/user/res/dropdown/DROPDOWN_LINE.bin"; + + // icon图片大小 + static constexpr uint16_t ICON_IMG_SIZE_W = 94; + static constexpr uint16_t ICON_IMG_SIZE_H = 94; + + // 电池 + static constexpr uint16_t BATTERY_X = 209; + static constexpr uint16_t BATTERY_Y = 180; + + // 时间 + static constexpr uint16_t TIME_LABEL_X = 172; + static constexpr uint16_t TIME_LABEL_Y = 230; + + // 日期 + static constexpr uint16_t DATE_LABEL_X = 110; + static constexpr uint16_t DATE_LABEL_Y = 300; + + // 星期 + static constexpr uint16_t WEEK_LABEL_X = 295; + static constexpr uint16_t WEEK_LABEL_Y = 300; + + // 手机连接状态 + static constexpr uint16_t PHONECONNECTSTATUS_IMG_X = 123; + static constexpr uint16_t PHONECONNECTSTATUS_IMG_Y = 350; + static constexpr const char *DROPDOWN_PHONECONNECTED_IMAGE = "/user/res/dropdown/DROPDOWN_PHONECONNECTED.bin"; + static constexpr const char *DROPDOWN_PHONEDISCONNECTED_IMAGE = "/user/res/dropdown/DROPDOWN_PHONEDISCONNECTED.bin"; + + // 耳机连接状态 + static constexpr uint16_t EARPHONESCONNECTSTATUS_IMG_X = 203; + static constexpr uint16_t EARPHONESCONNECTSTATUS_IMG_Y = 350; + static constexpr const char *DROPDOWN_EARPHONESCONNECTED_IMAGE = "/user/res/dropdown/DROPDOWN_EARPHONESCONNECTED.bin"; + static constexpr const char *DROPDOWN_EARPHONESDISCONNECTED_IMAGE = "/user/res/dropdown/DROPDOWN_EARPHONESDISCONNECTED.bin"; + + // 蓝牙连接状态 + static constexpr uint16_t BLUETOOTHCONNECTSTATUS_IMG_X = 283; + static constexpr uint16_t BLUETOOTHCONNECTSTATUS_IMG_Y = 350; + static constexpr const char *DROPDOWN_BLUETOOTHCONNECTED_IMAGE = "/user/res/dropdown/DROPDOWN_BLUETOOTHCONNECTED.bin"; + static constexpr const char *DROPDOWN_BLUETOOTHDISCONNECTED_IMAGE = "/user/res/dropdown/DROPDOWN_BLUETOOTHDISCONNECTED.bin"; + + static constexpr uint16_t CONNECTSTATUS_IMG_W = 60; + static constexpr uint16_t CONNECTSTATUS_IMG_H = 60; + + static constexpr const char *DROPDOWN_NOSIGNAL_IMAGE = "/user/res/dropdown/DROPDOWN_NOSIGNAL.bin"; + static const int64_t COLOR_SIGNAL_ON = 0xffffffff; + static const int64_t COLOR_SIGNAL_OFF = 0xff383838; + static const int BATTERY_IMAGE_WIDTH = 48; + static const int BATTERY_IMAGE_HEIGHT = 30; + static const int PROGRESS_WIDTH = 30; + static const int PROGRESS_HEIGHT = 18; + /* -------------------------------------------------------------------------- */ + std::string getWeekString(int wday) + { + std::string weekDays[] = {"星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"}; + return weekDays[wday]; + } + /* -------------------------------------------------------------------------- */ + static PullUpDownView *g_pPullUpDownView = nullptr; + PullUpDownView::PullUpDownView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::PullUpDownView"); + g_pPullUpDownView = this; + } + + PullUpDownView::~PullUpDownView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::~PullUpDownView"); + ClearAll(); + g_pPullUpDownView = nullptr; + } + + PullUpDownView *PullUpDownView::GetInstance(void) + { + return g_pPullUpDownView; + } + + // 清除信号强度相关组件 + void PullUpDownView::ClearAllSingalComponentsView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::ClearAllSingalComponentsView"); + if (NoSignal != nullptr) + { + delete NoSignal; + NoSignal = nullptr; + } + + for (int i = 0; i < 4; i++) + { + if (showSignalStrength[i] != nullptr) + { + delete showSignalStrength[i]; + showSignalStrength[i] = nullptr; + } + } + + if (Singal_4 != nullptr) + { + delete Singal_4; + Singal_4 = nullptr; + } + } + + // 清除所有与连接状态相关的视图组件 + void PullUpDownView::ClearAllConnectedStatusComponentsView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::ClearAllConnectedStatusComponentsView"); + if (connectedStatusBackgroundButton != nullptr) + { + delete connectedStatusBackgroundButton; + connectedStatusBackgroundButton = nullptr; + } + + if (showPhoneConnectedStatus != nullptr) + { + delete showPhoneConnectedStatus; + showPhoneConnectedStatus = nullptr; + } + + if (showEarPhoneConnectedStatus != nullptr) + { + delete showEarPhoneConnectedStatus; + showEarPhoneConnectedStatus = nullptr; + } + + if (showBluetoothConnectedStatus != nullptr) + { + delete showBluetoothConnectedStatus; + showBluetoothConnectedStatus = nullptr; + } + } + + void PullUpDownView::ClearAll() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::ClearAll"); + RemoveAll(); + if (group[DROPDOWNVIEW] != nullptr) + { + group[DROPDOWNVIEW]->RemoveAll(); + group[DROPDOWNVIEW]->ClearBackgroundBlur(); + delete group[DROPDOWNVIEW]; + group[DROPDOWNVIEW] = nullptr; + } + + if (dropSetting != nullptr) + { + delete dropSetting; + dropSetting = nullptr; + } + + if (dropBluetooth != nullptr) + { + delete dropBluetooth; + dropBluetooth = nullptr; + } + + if (dropDnotDisturb != nullptr) + { + delete dropDnotDisturb; + dropDnotDisturb = nullptr; + } + + if (dropSavePower != nullptr) + { + delete dropSavePower; + dropSavePower = nullptr; + } + + if (drofindPhone != nullptr) + { + delete drofindPhone; + drofindPhone = nullptr; + } + + if (dropLine != nullptr) + { + delete dropLine; + dropLine = nullptr; + } + + if (showTimeLabel != nullptr) + { + delete showTimeLabel; + showTimeLabel = nullptr; + } + + if (showDateLabel != nullptr) + { + delete showDateLabel; + showDateLabel = nullptr; + } + + if (showWeekLabel != nullptr) + { + delete showWeekLabel; + showWeekLabel = nullptr; + } + /* -------------------------------------------------------------------------- */ + ClearAllSingalComponentsView(); + ClearAllConnectedStatusComponentsView(); + /* -------------------------------------------------------------------------- */ + if (batteryimage != nullptr) + { + delete batteryimage; + batteryimage = nullptr; + } + + if (progress != nullptr) + { + delete progress; + progress = nullptr; + } + + if (connectedStatusView != nullptr) + { + delete connectedStatusView; + connectedStatusView = nullptr; + group[CONNECTEDSTATUSVIEW] = nullptr; + } + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::ClearAll end!!"); + } + + UIImageView *PullUpDownView::dropDownIconImageViweInit(ImageConfig &imageconfig) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::dropDownIconImageViweInit"); + UIImageView *Image = new UIImageView(); + if (Image == nullptr) + { + return nullptr; + } + Image->SetPosition(imageconfig.x, imageconfig.y, imageconfig.w, imageconfig.h); + Image->SetViewId(imageconfig.viewid); + Image->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + Image->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + Image->SetStyle(STYLE_BORDER_RADIUS, 100); + Image->SetAutoEnable(false); + Image->SetResizeMode(UIImageView::CENTER); + Image->SetSrc(imageconfig.src); + Image->SetTouchable(true); + Image->SetOnClickListener(imageconfig.clicklistener); + + return Image; + } + + /// @brief 创建icon图标 + void PullUpDownView::createDropDownIconImageViwe(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::InitViewImg"); + UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::MainPresenterSample::GetInstance(); + if (clickListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPresenterSample::GetInstance fail!!"); + return; + } + /* ---------------------------------- 下拉设置图片 ---------------------------------- */ + ImageConfig imageconfig = { + .x = SETTING_IMG_X, + .y = SETTING_IMG_Y, + .w = ICON_IMG_SIZE_W, + .h = ICON_IMG_SIZE_H, + .viewid = DROPDOWN_CLICK_SETTING, + .src = DROPDOWN_SETTING_IMAGE, + .clicklistener = clickListener, + }; + dropSetting = dropDownIconImageViweInit(imageconfig); + if (dropSetting == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PullUpDownView::dropSetting new fail"); + return; + } + /* ----------------------------------- 蓝牙 ----------------------------------- */ + imageconfig = { + .x = BLUETOOTH_IMG_X, + .y = BLUETOOTH_IMG_Y, + .w = ICON_IMG_SIZE_W, + .h = ICON_IMG_SIZE_H, + .viewid = DROPDOWN_CLICK_BLUETOOTH, + .src = DROPDOWN_BLUETOOTH_IMAGE, + .clicklistener = clickListener, + }; + dropBluetooth = dropDownIconImageViweInit(imageconfig); + if (dropBluetooth == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PullUpDownView::dropBluetooth new fail"); + return; + } + /* ----------------------------------- 勿扰模式 ----------------------------------- */ + imageconfig = { + .x = DNOTDISTURB_IMG_X, + .y = DNOTDISTURB_IMG_Y, + .w = ICON_IMG_SIZE_W, + .h = ICON_IMG_SIZE_H, + .viewid = DROPDOWN_CLICK_DNOTDISTURB, + .src = DROPDOWN_DNOTDISTURB_IMAGE, + .clicklistener = clickListener, + }; + dropDnotDisturb = dropDownIconImageViweInit(imageconfig); + if (dropDnotDisturb == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PullUpDownView::dropDnotDisturb new fail"); + return; + } + UpdateDnotDisturbStatus(DnotDisturbModel::GetInstance().GetDoNotDisturbModeEnabled()); + /* ----------------------------------- 省电 ----------------------------------- */ + imageconfig = { + .x = SAVEPOWER_IMG_X, + .y = SAVEPOWER_IMG_Y, + .w = ICON_IMG_SIZE_W, + .h = ICON_IMG_SIZE_H, + .viewid = DROPDOWN_CLICK_SAVEELE, + .src = DROPDOWN_SAVEPOWER_IMAGE, + .clicklistener = clickListener, + }; + dropSavePower = dropDownIconImageViweInit(imageconfig); + if (dropSavePower == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PullUpDownView::dropSavePower new fail"); + return; + } + /* ----------------------------------- 找手机 ---------------------------------- */ + imageconfig = { + .x = FINDPHONE_IMG_X, + .y = FINDPHONE_IMG_Y, + .w = ICON_IMG_SIZE_W, + .h = ICON_IMG_SIZE_H, + .viewid = DROPDOWN_CLICK_FINDMYPHONE, + .src = DROPDOWN_FINDPHONE_IMAGE, + .clicklistener = clickListener, + }; + drofindPhone = dropDownIconImageViweInit(imageconfig); + if (drofindPhone == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PullUpDownView::drofindPhone new fail"); + return; + } + /* -------------------------------- dropLine -------------------------------- */ + dropLine = new UIImageView(); + if (dropLine == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dropLine new fail"); + return; + } + dropLine->SetPosition(LINE_IMG_X, LINE_IMG_Y, ICON_IMG_SIZE_W, ICON_IMG_SIZE_H); + dropLine->SetSrc(DROPDOWN_LINE_IMAGE); + /* -------------------------------- 添加组件到视图上 -------------------------------- */ + group[DROPDOWNVIEW]->Add(dropSetting); + group[DROPDOWNVIEW]->Add(dropBluetooth); + group[DROPDOWNVIEW]->Add(dropDnotDisturb); + group[DROPDOWNVIEW]->Add(dropSavePower); + group[DROPDOWNVIEW]->Add(drofindPhone); + group[DROPDOWNVIEW]->Add(dropLine); + } + + // 获取手机连接状态 + bool PullUpDownView::GetPhoneConnectedStatus(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::GetPhoneConnectedStatus"); + // uint8_t ret = uapi_dev_runtime_get_ble_connect_stat(); + // WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "ble phone connect stat = %d", ret); + // if (ret == 1) + // return true; + // else + // return false; + + return SettingModel::GetInstance().GetPhoneConnectStatus(); + } + + // 获取蓝牙耳机连接状态 + bool PullUpDownView::GetEarPhoneConnectedStatus(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::GetEarPhoneConnectedStatus"); + // uint8_t ret = uapi_dev_runtime_get_earphone_connect_stat(); + // WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "earphone connect stat = %d", ret); + // if (ret == 1) + // return true; + // else + // return false; + + return SettingModel::GetInstance().GetEarPhoneConnectStatus(); + } + + // 获取蓝牙连接状态 + bool PullUpDownView::GetBlueToothConnectedStatus(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::GetBlueToothConnectedStatus"); + // uint8_t ret = uapi_dev_runtime_get_br_connect_stat(); + // WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "br connect stat = %d [0 no connect, 1 a2dp, 2 hfp, 3 both]", ret); + // if (ret != 0) + // return true; + // else + // return false; + + return SettingModel::GetInstance().GetBlueToothConnectStatus(); + } + + UIImageView *PullUpDownView::dropDownConnectedStatusImageViweInit(int16_t x, int16_t y, int16_t w, int16_t h) + { + UIImageView *img = new UIImageView(); + if (img == nullptr) + { + return nullptr; + } + img->SetPosition(x, y, w, h); + img->SetAutoEnable(false); + img->SetResizeMode(UIImageView::CENTER); + img->SetStyle(STYLE_BORDER_RADIUS, 100); + + return img; + } + + /// @brief 创建与连接状态相关组件 + void PullUpDownView::createDropDownConnectedStatusImageViwe(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::InitConnectedStatusImage"); + connectedStatusBackgroundButton = new UIButton(); + if (connectedStatusBackgroundButton == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "connectedStatusBackgroundButton new fail"); + return; + } + connectedStatusBackgroundButton->SetPosition(113, 348, 240, 64); + connectedStatusBackgroundButton->SetViewId(CONNECTEDSTATUSBACKGROUNDBUTTON); + connectedStatusBackgroundButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + connectedStatusBackgroundButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + connectedStatusBackgroundButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffffff, UIButton::PRESSED); + connectedStatusBackgroundButton->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + connectedStatusBackgroundButton->SetStyleForState(STYLE_BORDER_COLOR, 0xffffffff, UIButton::PRESSED); + connectedStatusBackgroundButton->SetStyleForState(STYLE_BORDER_OPA, 0x00, UIButton::PRESSED); + UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::MainPresenterSample::GetInstance(); + if (clickListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPresenterSample::GetInstance fail!!"); + return; + } + connectedStatusBackgroundButton->SetOnClickListener(clickListener); + /* -------------------------------- 显示手机连接状态 -------------------------------- */ + + showPhoneConnectedStatus = dropDownConnectedStatusImageViweInit(PHONECONNECTSTATUS_IMG_X, PHONECONNECTSTATUS_IMG_Y, CONNECTSTATUS_IMG_W, CONNECTSTATUS_IMG_H); + if (showPhoneConnectedStatus == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "showPhoneConnectedStatus new fail"); + return; + } + /* -------------------------------- 显示耳机连接状态 -------------------------------- */ + showEarPhoneConnectedStatus = dropDownConnectedStatusImageViweInit(EARPHONESCONNECTSTATUS_IMG_X, EARPHONESCONNECTSTATUS_IMG_Y, CONNECTSTATUS_IMG_W, CONNECTSTATUS_IMG_H); + if (showEarPhoneConnectedStatus == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "showEarPhoneConnectedStatus new fail"); + return; + } + /* -------------------------------- 显示蓝牙连接状态 -------------------------------- */ + showBluetoothConnectedStatus = dropDownConnectedStatusImageViweInit(BLUETOOTHCONNECTSTATUS_IMG_X, BLUETOOTHCONNECTSTATUS_IMG_Y, CONNECTSTATUS_IMG_W, CONNECTSTATUS_IMG_H); + if (showBluetoothConnectedStatus == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "showBluetoothConnectedStatus new fail"); + return; + } + /* -------------------------------------------------------------------------- */ + UpdatePhoneStatus(GetPhoneConnectedStatus()); + UpdateEarPhoneStatus(GetEarPhoneConnectedStatus()); + UpdateBlueToothStatus(GetBlueToothConnectedStatus()); + /* -------------------------------------------------------------------------- */ + group[DROPDOWNVIEW]->Add(connectedStatusBackgroundButton); + group[DROPDOWNVIEW]->Add(showPhoneConnectedStatus); + group[DROPDOWNVIEW]->Add(showEarPhoneConnectedStatus); + group[DROPDOWNVIEW]->Add(showBluetoothConnectedStatus); + } + + /*** + * @brief 初始化时间,日期,星期,电池,信号强度 + */ + bool PullUpDownView::InitBaseData() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::InitBaseData"); + if (!InitSingalComponentsView()) + { + return false; + } + + /* ---------------------------------- 时间显示 ---------------------------------- */ + showTimeLabel = new UILabel(); + if (showTimeLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "showTimeLabel new fail"); + return false; + } + showTimeLabel->SetPosition(TIME_LABEL_X, TIME_LABEL_Y); + showTimeLabel->SetStyle(STYLE_TEXT_FONT, 50); + showTimeLabel->SetStyle(STYLE_LINE_HEIGHT, 59); + showTimeLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + showTimeLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + showTimeLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 50); + /* ---------------------------------- 日期显示 ---------------------------------- */ + showDateLabel = new UILabel(); + if (showDateLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "showDateLabel new fail"); + return false; + } + showDateLabel->SetPosition(DATE_LABEL_X, DATE_LABEL_Y); + showDateLabel->SetStyle(STYLE_TEXT_FONT, 30); + showDateLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + showDateLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + showDateLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + showDateLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + /* ---------------------------------- 星期显示 ---------------------------------- */ + showWeekLabel = new UILabel(); + if (showWeekLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "showWeekLabel new fail"); + return false; + } + showWeekLabel->SetPosition(WEEK_LABEL_X, WEEK_LABEL_Y); + showWeekLabel->SetStyle(STYLE_TEXT_FONT, 30); + showWeekLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + showWeekLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + showWeekLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + showWeekLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 28); + /* ----------------------------------- 电池 ----------------------------------- */ + batteryimage = new UIImageView(); + if (batteryimage == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "batteryimage new fail"); + return false; + } + batteryimage->SetPosition(258, 180, BATTERY_IMAGE_WIDTH, BATTERY_IMAGE_HEIGHT); + std::string batteryimagesPath = "/user/res/Battery/Battery-E.bin"; + batteryimage->SetSrc(batteryimagesPath.c_str()); + /* -------------------------------------------------------------------------- */ + progress = new UIBoxProgress(); + if (progress == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "progress new fail"); + return false; + } + progress->SetPosition(206, 180, PROGRESS_WIDTH, PROGRESS_HEIGHT); + progress->SetValidHeight(PROGRESS_HEIGHT); + progress->SetValidWidth(PROGRESS_WIDTH); + + // progress->SetValue(value); + const char *progressImageSrc = "/user/res/Battery/Battery_Normal.bin"; + progress->SetImage(progressImageSrc, nullptr); + progress->SetBackgroundStyle(STYLE_BACKGROUND_OPA, 0x00); + progress->SetBackgroundStyle(STYLE_TEXT_COLOR, 0xff000000); + progress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + progress->SetForegroundStyle(STYLE_TEXT_COLOR, 0xff000000); + progress->SetForegroundStyle(STYLE_LINE_COLOR, 0xff45A5FF); + + group[DROPDOWNVIEW]->Add(progress); + group[DROPDOWNVIEW]->Add(batteryimage); + group[DROPDOWNVIEW]->Add(showTimeLabel); + group[DROPDOWNVIEW]->Add(showDateLabel); + group[DROPDOWNVIEW]->Add(showWeekLabel); + + /* -------------------------------------------------------------------------- */ + UpdateSignalStrengthStatusAndBatteryPosition(); + /* -------------------------------------------------------------------------- */ + + return true; + } + + // 初始化信号强度相关组件 + bool PullUpDownView::InitSingalComponentsView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::InitSingalComponentsView"); + /* -------------------------------------------------------------------------- */ + NoSignal = new UIImageView(); + if (NoSignal == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "NoSignal new fail"); + return false; + } + NoSignal->SetPosition(160, 176, 36, 38); + NoSignal->SetAutoEnable(false); + NoSignal->SetResizeMode(UIImageView::CENTER); + NoSignal->SetSrc(DROPDOWN_NOSIGNAL_IMAGE); + NoSignal->SetVisible(false); + group[DROPDOWNVIEW]->Add(NoSignal); + /* -------------------------------------------------------------------------- */ + // 定义一个结构体,用于存储 ImageView 的信息 + struct ImageViewInfo + { + int posX; + int posY; + int width; + int height; + }; + // 待添加的 ImageView 信息列表 + std::vector imageViewList = { + {160, 204, 6, 6}, + {170, 196, 6, 14}, + {180, 188, 6, 22}, + {190, 180, 6, 30}, + }; + + // 循环添加 ImageView 到相应的容器中 + for (int i = 0; i < 4; i++) + { + if (showSignalStrength[i] == nullptr) + { + showSignalStrength[i] = new UIImageView(); + if (showSignalStrength[i] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "showSignalStrength[%d] new fail", i); + return false; + } + } + showSignalStrength[i]->SetPosition(imageViewList[i].posX, imageViewList[i].posY, imageViewList[i].width, imageViewList[i].height); + showSignalStrength[i]->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + showSignalStrength[i]->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + showSignalStrength[i]->SetStyle(STYLE_BORDER_RADIUS, 10); + group[DROPDOWNVIEW]->Add(showSignalStrength[i]); + showSignalStrength[i]->SetVisible(false); + } + /* -------------------------------------------------------------------------- */ + if (Singal_4 == nullptr) + { + Singal_4 = new UILabel(); + } + Singal_4->SetPosition(201, 176, 40, 47); + Singal_4->SetStyle(STYLE_TEXT_FONT, 34); + Singal_4->SetStyle(STYLE_LINE_HEIGHT, 40); + Singal_4->SetText("4G"); + Singal_4->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + Singal_4->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Singal_4->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 34); + Singal_4->SetVisible(false); + group[DROPDOWNVIEW]->Add(Singal_4); + + return true; + } + + // 获取信号强度 + int PullUpDownView::GetSignalStrength(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::GetSignalStrength"); + int SignalStrength = uapi_dev_runtime_get_cat1_signal(); // 信号强度 + return CalculateSignalBars(SignalStrength); + } + + // 计算信号格 + int PullUpDownView::CalculateSignalBars(int signalStrength) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::CalculateSignalBars"); + if (signalStrength < 0 || signalStrength > 32 || signalStrength == 0) + return 99; // 无信号 or Invalid signal strength + + // if (signalStrength == 32) + // return 4; // Edge case where signalStrength is exactly at the upper boundary + + return (signalStrength / 8) + 1; + } + +#if 0 + // 函数用于更新信号显示的UI + void PullUpDownView::updateSignalDisplay() + { + int sim = uapi_dev_runtime_get_cat1_simstat(); + int cat1_powerOn = uapi_dev_runtime_get_cat1_powerstat(); + int signal = uapi_dev_runtime_get_cat1_signal(); + int network_on = uapi_dev_runtime_get_cat1_networkstat(); + int cat1_network_type = uapi_dev_runtime_get_cat1_networtype(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sim = %d", sim); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "cat1_powerOn = %d", cat1_powerOn); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "signal = %d", signal); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "network_on = %d", network_on); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "cat1_network_type = %d", cat1_network_type); + + const int SIGNAL_NO_SIGNAL = 99; + const int NETWORK_TYPE_NO_NETWORK = 0; + const int NETWORK_TYPE_4G = 4; + + if (sim == 0 || cat1_powerOn == 0) + { + // 无信号,无4G图标 + UpdateCat1NoSignalisplay(true); + UpdateCat14GDisplay(false); + UpdateSignalBarDisplay(CalculateSignalBars(signal), false); + } + else if (cat1_powerOn == 1 && sim == 1) + { + if (signal == SIGNAL_NO_SIGNAL) + { + // 无信号UI显示 + UpdateCat1NoSignalisplay(true); + UpdateCat14GDisplay(false); + UpdateSignalBarDisplay(CalculateSignalBars(signal), false); + } + else + { + // 信号强度显示 + UpdateCat1NoSignalisplay(false); + UpdateCat14GDisplay(true); + UpdateSignalBarDisplay(CalculateSignalBars(signal), true); + } + if (network_on == 0) + { + // 无信号,无4G图标 显示 + UpdateCat1NoSignalisplay(true); + UpdateCat14GDisplay(false); + UpdateSignalBarDisplay(CalculateSignalBars(signal), false); + } + else + { + if (cat1_network_type == NETWORK_TYPE_NO_NETWORK) + { + // 无信号,无4G图标 显示 + UpdateCat1NoSignalisplay(true); + UpdateCat14GDisplay(false); + UpdateSignalBarDisplay(CalculateSignalBars(signal), false); + } + else if (cat1_network_type == NETWORK_TYPE_4G) + { + // 有4G图标,正常显示信号 + UpdateCat1NoSignalisplay(false); + UpdateCat14GDisplay(true); + UpdateSignalBarDisplay(CalculateSignalBars(signal), true); + } + else + { + // 无4G图标,正常显示信号 + UpdateCat1NoSignalisplay(false); + UpdateCat14GDisplay(false); + UpdateSignalBarDisplay(CalculateSignalBars(signal), true); + } + } + } + } +#else + // 函数用于更新信号显示的UI + void PullUpDownView::updateSignalDisplay() + { + int sim = uapi_dev_runtime_get_cat1_simstat(); + int cat1_powerOn = uapi_dev_runtime_get_cat1_powerstat(); + int signal = uapi_dev_runtime_get_cat1_signal(); + int network_on = uapi_dev_runtime_get_cat1_networkstat(); + int cat1_network_type = uapi_dev_runtime_get_cat1_networtype(); + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sim = %d", sim); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "cat1_powerOn = %d", cat1_powerOn); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "signal = %d", signal); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "network_on = %d", network_on); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "cat1_network_type = %d", cat1_network_type); + + const int SIGNAL_NO_SIGNAL = 99; + const int NETWORK_TYPE_NO_NETWORK = 0; + const int NETWORK_TYPE_4G = 4; + + bool showNoSignalUI = (sim == 0 || cat1_powerOn == 0 || signal == SIGNAL_NO_SIGNAL); + bool showNoNetworkUI = (network_on == 0 || cat1_network_type == NETWORK_TYPE_NO_NETWORK); + + bool show4GIcon = (cat1_network_type == NETWORK_TYPE_4G); + + UpdateCat1NoSignalisplay(showNoSignalUI); + UpdateCat14GDisplay(show4GIcon); + UpdateSignalBarDisplay(CalculateSignalBars(signal), !(showNoSignalUI || showNoNetworkUI)); + } +#endif + + // 更新信号强度显示 + void PullUpDownView::UpdateSignalBarDisplay(int signalBars, bool state) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::UpdateSignalBarDisplay"); + for (int i = 0; i < 4; i++) + { + showSignalStrength[i]->SetStyle(STYLE_BACKGROUND_COLOR, (i < signalBars) ? COLOR_SIGNAL_ON : COLOR_SIGNAL_OFF); + showSignalStrength[i]->Invalidate(); + showSignalStrength[i]->SetVisible(state); + } + } + + // 更新无信号图标显示 + void PullUpDownView::UpdateCat1NoSignalisplay(bool state) + { + if (NoSignal != nullptr) + { + NoSignal->SetVisible(state); + } + } + + // 更新4G图标显示 + void PullUpDownView::UpdateCat14GDisplay(bool state) + { + if (Singal_4 != nullptr) + { + Singal_4->SetVisible(state); + } + } + + // 更新电池位置 + void PullUpDownView::UpdateBatteryPosition(int signalBars) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::UpdateBatteryPosition"); + if (signalBars == 99) + { + batteryimage->SetPosition(209, 180, BATTERY_IMAGE_WIDTH, BATTERY_IMAGE_HEIGHT); + progress->SetPosition(215, 186, PROGRESS_WIDTH, PROGRESS_HEIGHT); + } + else + { + batteryimage->SetPosition(258, 180, BATTERY_IMAGE_WIDTH, BATTERY_IMAGE_HEIGHT); + progress->SetPosition(264, 186, PROGRESS_WIDTH, PROGRESS_HEIGHT); + } + batteryimage->Invalidate(); + progress->Invalidate(); + } + + // 更新信号强度和电池位置 + void PullUpDownView::UpdateSignalStrengthStatusAndBatteryPosition() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::UpdateSignalStrengthStatusAndBatteryPosition"); + updateSignalDisplay(); + UpdateBatteryPosition(GetSignalStrength()); + } + + // 下拉视图初始化 + bool PullUpDownView::PullUpDownViewInit() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::InitView"); + + group[DROPDOWNVIEW] = new UIViewGroup(); + if (group[DROPDOWNVIEW] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group[DROPDOWNVIEW] new fail!!"); + return false; + } + group[DROPDOWNVIEW]->SetPosition(0, 0, 466, 466); + group[DROPDOWNVIEW]->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); + group[DROPDOWNVIEW]->SetViewIndex(0); + group[DROPDOWNVIEW]->SetFullScreenBlur(true); + createDropDownIconImageViwe(); + createDropDownConnectedStatusImageViwe(); + + if (InitBaseData()) + { + MainPresenterSample::GetInstance()->UpdataBaseData(); + } + else + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::InitBaseData Error!"); + return false; + } + SetTouchable(true); + SetIntercept(true); + Add(group[DROPDOWNVIEW]); + return true; + } + + void PullUpDownView::PreLoad(void) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PullUpDownView::PreLoad"); + if (!viewiInitStatus) + { + PullUpDownViewInit(); + viewiInitStatus = true; + } + } + + void PullUpDownView::UnLoad(void) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PullUpDownView::UnLoad"); + } + + // 更新手机连接状态 + void PullUpDownView::UpdatePhoneStatus(int status) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::UpdatePhoneStatus"); + if (showPhoneConnectedStatus == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "showPhoneConnectedStatus nullptr"); + return; + } + showPhoneConnectedStatus->SetSrc(status ? DROPDOWN_PHONECONNECTED_IMAGE : DROPDOWN_PHONEDISCONNECTED_IMAGE); + showPhoneConnectedStatus->Invalidate(); + + if (GetConnectedStatusView() != nullptr) + GetConnectedStatusView()->UpdatePhoneConnectedStatus(status); + + return; + } + + // 更新蓝牙耳机连接状态 + void PullUpDownView::UpdateEarPhoneStatus(int status) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::UpdateEarPhoneStatus"); + if (showEarPhoneConnectedStatus == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "showEarPhoneConnectedStatus nullptr"); + return; + } + showEarPhoneConnectedStatus->SetSrc(status ? DROPDOWN_EARPHONESCONNECTED_IMAGE : DROPDOWN_EARPHONESDISCONNECTED_IMAGE); + showEarPhoneConnectedStatus->Invalidate(); + + if (GetConnectedStatusView() != nullptr) + GetConnectedStatusView()->UpdateEarPhoneConnectedStatus(status); + + return; + } + + // 更新蓝牙连接状态 + void PullUpDownView::UpdateBlueToothStatus(int status) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::UpdateBlueToothStatus"); + if (showBluetoothConnectedStatus == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "showBluetoothConnectedStatus nullptr"); + return; + } + showBluetoothConnectedStatus->SetSrc(status ? DROPDOWN_BLUETOOTHCONNECTED_IMAGE : DROPDOWN_BLUETOOTHDISCONNECTED_IMAGE); + showBluetoothConnectedStatus->Invalidate(); + + if (GetConnectedStatusView() != nullptr) + GetConnectedStatusView()->UpdateBlueToothConnectedStatus(status); + + return; + } + + /*更新勿扰模式状态*/ + void PullUpDownView::UpdateDnotDisturbStatus(int status) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::UpdateDnotDisturbStatus"); + if (dropDnotDisturb != nullptr) + { + dropDnotDisturb->SetStyle(STYLE_BACKGROUND_COLOR, status ? 0xff8e20e2 : 0xff191919); + dropDnotDisturb->Invalidate(); + } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dropIconBackground[DNOTDISTURB_INDEX] is nullptr"); + return; + } + } + + UILabel *PullUpDownView::GetTimeLabel() + { + return showTimeLabel; + } + UILabel *PullUpDownView::GetDateLabel() + { + return showDateLabel; + } + UILabel *PullUpDownView::GetWeekLabel() + { + return showWeekLabel; + } + UIBoxProgress *PullUpDownView::GetProgress() + { + return progress; + } + /* ------------------------------ 下拉界面切换到连接状态视图 ----------------------------- */ + // 切换到"下拉控制中心"视图 + bool PullUpDownView::ChangeDropDownView(int16_t thisView) + { + if (group[thisView] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PullUpDownView::ChangeDropDownView"); + Add(group[thisView]); + } + return true; + } + + // 切换到"连接状态"视图 + bool PullUpDownView::ChangeConnectedStatusView(int16_t thisView) + { + if (group[thisView] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PullUpDownView::ChangeConnectedStatusView"); + connectedStatusView = new ConnectedStatusView(); + if (connectedStatusView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PullUpDownView:: new scrollView[%d] fail", thisView); + return false; + } + group[thisView] = connectedStatusView->ConnectedStatusViewInit(); + Add(group[thisView]); + } + return true; + } + + struct PullUpDownViewMapper + { + const int16_t viewId; + bool (PullUpDownView::*func)(int16_t thisView); + }; + + static const PullUpDownViewMapper ViewMapper[] = { + {DROPDOWNVIEW, &PullUpDownView::ChangeDropDownView}, + {CONNECTEDSTATUSVIEW, &PullUpDownView::ChangeConnectedStatusView}, + }; + + bool PullUpDownView::ClickFunc(int16_t interface) + { + int funcSize = sizeof(ViewMapper) / sizeof(ViewMapper[0]); + for (int i = 0; i < funcSize; i++) + { + if (interface == ViewMapper[i].viewId) + { + bool jug = (this->*(ViewMapper[i].func))(interface); + if (jug == false) + { + return false; + } + return true; + } + } + return false; + } + + void PullUpDownView::ChangeView(int16_t hideView, int16_t showView) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PullUpDownView::ChangeView"); + if (hideView > MAX_DROPDOWNVIEWID) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PullUpDownView:: SystemViewId Overstep ones bounds"); + return; + } + group[hideView]->SetVisible(false); + ClickFunc(showView); + group[showView]->SetVisible(true); + Invalidate(); + } + + ConnectedStatusView *PullUpDownView::GetConnectedStatusView(void) + { + return connectedStatusView; + } + /* -------------------------------------------------------------------------- */ +} +#else /* * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. * Description: WeekStep @@ -173,7 +1253,7 @@ namespace OHOS { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::ClearAll"); RemoveAll(); - UnLoadPullUpDownImageRes(); //切换slice的时候也要卸载资源放在ImageCach空间不够 + UnLoadPullUpDownImageRes(); // 切换slice的时候也要卸载资源放在ImageCach空间不够 if (group[DROPDOWNVIEW] != nullptr) { group[DROPDOWNVIEW]->RemoveAll(); @@ -348,7 +1428,7 @@ namespace OHOS dropLighting->SetAutoEnable(false); dropLighting->SetResizeMode(UIImageView::CENTER); // ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, dropLighting, DROPDOWN_BLUETOOTH); - dropLighting->SetViewId(DROPDOWN_CLICK_LIGHTING); // 进入亮屏界面 + dropLighting->SetViewId(DROPDOWN_CLICK_BLUETOOTH); // 进入亮屏界面 dropLighting->SetTouchable(true); dropLighting->SetOnClickListener(clickListener); /* ----------------------------------- 勿扰模式 ----------------------------------- */ @@ -1206,3 +2286,4 @@ namespace OHOS } /* -------------------------------------------------------------------------- */ } +#endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelHeartRate.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelHeartRate.cpp index 184cd2c8d..89fed7267 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelHeartRate.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelHeartRate.cpp @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-04-15 10:55:58 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-07-01 09:48:06 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelHeartRate.cpp + */ /* * Copyright (c) CompanyNameMagicTag 2023. All rights reserved. * Description: DialModelHeartRate @@ -23,6 +29,9 @@ namespace OHOS void DialModelHeartRate::UpdateHeartRate(int16_t heartRate) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UpdateHeartRate = %d", heartRate); + // 筛选表盘心率数据 + if (heartRate == 0) + return; heartRate_ = static_cast(heartRate); if (onChangeListener_ != nullptr) { diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageModel.cpp index 0e6db03e1..7e8eff98f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageModel.cpp @@ -31,7 +31,7 @@ #define MESSAGE_JSON_FILE "user/userdata/message/ancs.json" #define PRINTFDATA 1 -extern "C" errcode_t uapi_get_TIME_STR(uint32_t time, char *p_time, char separator, bool include_seconds); +extern "C" errcode_t uapi_get_TIME_STR(uint32_t time, char *p_time, char separator, bool include_seconds, bool include_year); namespace OHOS { MessageData message_; @@ -120,7 +120,7 @@ namespace OHOS uint32 timestamp = cJSON_GetObjectItem(item, "time")->valueint; messagedata.timestamp = timestamp; char labelTime[20]; - if (uapi_get_TIME_STR(timestamp, labelTime, '.', false) != ERRCODE_SUCC) + if (uapi_get_TIME_STR(timestamp, labelTime, '.', false, false) != ERRCODE_SUCC) { messagedata.labelTime = std::string("2024.1.1 00:00"); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirView.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirView.cpp index 454b38ee8..5ab5893cb 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirView.cpp @@ -106,7 +106,7 @@ namespace OHOS label1_phone_name = new UILabel(); } label1_phone_name->SetPosition(173, 53); // widget's left position and top position - label1_phone_name->Resize(120, 35); // widget's width and height + label1_phone_name->Resize(120, 55); // widget's width and height label1_phone_name->SetViewId("label1");// Set style label1_phone_name->SetStyle(STYLE_TEXT_FONT, 50); @@ -185,8 +185,8 @@ namespace OHOS { if(strcmp("container_one_page",idstr)==0) { - // container_->SetVisible(true); - // container_one_page->SetVisible(false); + container_->SetVisible(true); + container_one_page->SetVisible(false); return; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testLCD.h b/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testLCD.h index 3c9024ae9..79114e1f0 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testLCD.h +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testLCD.h @@ -23,7 +23,8 @@ namespace OHOS UIScrollView *testLCDInitIView(void); void ClearAll(void); - void set_LCD_color(); + void set_LCD_color(int); + void LCDHideNextButton(void); private: bool testLCDScrollViewcrollViewinit(void); UIScrollView *testLCDScrollView{nullptr}; diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testLCDC.h b/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testLCDC.h new file mode 100644 index 000000000..5f3a1d52d --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testLCDC.h @@ -0,0 +1,28 @@ +/* + * @Author: penglei 1624952103@qq.com + * @Date: 2024-06-07 11:18:25 + * @LastEditors: penglei 1624952103@qq.com + * @LastEditTime: 2024-07-02 18:04:42 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testLCDC.h + * @Description: + * + * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. + */ +#ifndef TEST_LCD_H +#define TEST_LCD_H + +#ifdef __cplusplus +#if __cplusplus +extern "C" +{ +#endif +#endif + void factorytest_set_LCD_color(int color); + void factorytest_hide_test_lcd_button(void); + +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif +#endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testPresenterC.h b/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testPresenterC.h new file mode 100644 index 000000000..a68360d76 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testPresenterC.h @@ -0,0 +1,28 @@ +/* + * @Author: penglei 1624952103@qq.com + * @Date: 2024-06-07 11:18:25 + * @LastEditors: penglei 1624952103@qq.com + * @LastEditTime: 2024-07-02 18:04:51 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testPresenterC.h + * @Description: + * + * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. + */ +#ifndef TEST_PRESENTER_H +#define TEST_PRESENTER_H + +#ifdef __cplusplus +#if __cplusplus +extern "C" +{ +#endif +#endif + void factorytest_enter_test_tp_view(void); + void factorytest_enter_test_lcd_view(void); + +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif +#endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testTP.h b/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testTP.h index dd71274f0..ea7d1c464 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testTP.h +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testTP.h @@ -35,6 +35,7 @@ namespace OHOS UIScrollView *testTPInitIView(void); void ClearAll(void); + void TPHideNextButton(void); private: UIButton *SetTheButton_ext(ButtonConfig_ext_t &buttonconfig, UIView::OnTouchListener *clickListener); bool testTPScrollViewcrollViewinit(void); diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testTPC.h b/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testTPC.h new file mode 100644 index 000000000..f043693dc --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testTPC.h @@ -0,0 +1,28 @@ +/* + * @Author: penglei 1624952103@qq.com + * @Date: 2024-06-07 11:18:25 + * @LastEditors: penglei 1624952103@qq.com + * @LastEditTime: 2024-07-02 18:05:11 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testTPC.h + * @Description: + * + * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. + */ +#ifndef TEST_TP_H +#define TEST_TP_H + +#ifdef __cplusplus +#if __cplusplus +extern "C" +{ +#endif +#endif + + void factorytest_hide_test_tp_button(void); + +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif +#endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testLCD.cpp b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testLCD.cpp index f6b885d97..753eced0d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testLCD.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testLCD.cpp @@ -76,17 +76,18 @@ namespace OHOS testLCDScrollView=nullptr; } } - - void colorTimerCallBack(int data) + uint8_t LCD_TEST_FALG=0; + void colorTimerCallBack(int data) { testLCDView* t= testLCDView::GetInstance(); if(t!=NULL) - t->set_LCD_color(); + t->set_LCD_color(LCD_TEST_FALG); + LCD_TEST_FALG++; } - uint8_t LCD_TEST_FALG=0; - void testLCDView :: set_LCD_color(void) + + void testLCDView :: set_LCD_color(int color) { - switch (LCD_TEST_FALG) + switch (color) { case 0: testLCDScrollView->SetStyle(STYLE_BACKGROUND_COLOR, Color::Green().full); @@ -97,11 +98,20 @@ namespace OHOS case 2: testLCDScrollView->SetStyle(STYLE_BACKGROUND_COLOR, Color::Yellow().full); break; + case 3: + testLCDScrollView->SetStyle(STYLE_BACKGROUND_COLOR, Color::Red().full); + break; + case 4: + testLCDScrollView->SetStyle(STYLE_BACKGROUND_COLOR, Color::White().full); + break; + case 5: + testLCDScrollView->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); + break; default: break; } RootView::GetInstance()->Invalidate(); - LCD_TEST_FALG++; + //LCD_TEST_FALG++; } @@ -147,7 +157,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::draglistener can not be nullptr!"); return false; } - testLCDScrollView->SetOnDragListener(draglistener); + testLCDScrollView->SetOnDragListener(draglistener); testLCDScrollView->SetTouchable(true); testLCDScrollView->SetDraggable(true); @@ -174,4 +184,37 @@ namespace OHOS } return testLCDScrollView; } + + void testLCDView::LCDHideNextButton(void) + { + labelButton_next->SetVisible(false); + testLCDScrollView->Remove(Title); + } + +#ifdef __cplusplus +#if __cplusplus +extern "C" +{ +#endif /* __cplusplus */ +#endif /* __cplusplus */ + + void factorytest_set_LCD_color(int color) + { + testLCDView* t= testLCDView::GetInstance(); + + if(t!=NULL) + t->set_LCD_color(color); + } + + void factorytest_hide_test_lcd_button(void) + { + testLCDView::GetInstance()->LCDHideNextButton(); + osTimerStop(MG_TEST_timer); + } + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cplusplus */ +#endif /* __cplusplus */ } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testPresenter.cpp index 109707d6f..561fb714d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testPresenter.cpp @@ -358,5 +358,27 @@ namespace OHOS //language *g_planguage = new language; /* -------------------------------------------------------------------------- */ // 用来监听语言切换 - + +#ifdef __cplusplus +#if __cplusplus +extern "C" +{ +#endif /* __cplusplus */ +#endif /* __cplusplus */ + + void factorytest_enter_test_tp_view(void) + { + testView::GetInstance()->ChangeView(TESTVIEW,TP); + } + + void factorytest_enter_test_lcd_view(void) + { + testView::GetInstance()->ChangeView(TESTVIEW,LCD); + } + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cplusplus */ +#endif /* __cplusplus */ } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testTP.cpp b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testTP.cpp index f3beb206f..5c57c070d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testTP.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testTP.cpp @@ -203,4 +203,29 @@ namespace OHOS } return testTPScrollView; } + + void testTPView::TPHideNextButton(void) + { + labelButton_next->SetVisible(false); + testTPScrollView->Remove(Title); + } + +#ifdef __cplusplus +#if __cplusplus +extern "C" +{ +#endif /* __cplusplus */ +#endif /* __cplusplus */ + + void factorytest_hide_test_tp_button(void) + { + testTPView::GetInstance()->TPHideNextButton(); + } + + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cplusplus */ +#endif /* __cplusplus */ } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testbt.cpp b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testbt.cpp index da73e93f7..478c164f0 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testbt.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testbt.cpp @@ -277,7 +277,7 @@ namespace OHOS char buf[128]={0}; WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rssi %d",rssi); - sprintf_s(buf,128,"addr:%02X%02X%02X%02X%02X%02X\nRssi:%d",name,addr[0],addr[1],addr[2],addr[3],addr[4],addr[5],rssi); + sprintf_s(buf,128,"addr:%02X %02X %02X %02X %02X %02X\nRssi:%d",addr[0],addr[1],addr[2],addr[3],addr[4],addr[5],rssi); label_BR_SCAN[i]->SetText(buf); RootView::GetInstance()->Invalidate(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/respiratorytraining/src/RespiratoryTrainingModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/respiratorytraining/src/RespiratoryTrainingModel.cpp index 6d67e862c..0b30109f0 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/respiratorytraining/src/RespiratoryTrainingModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/respiratorytraining/src/RespiratoryTrainingModel.cpp @@ -57,7 +57,7 @@ namespace OHOS { Time = 5; START_FLAG = false; - HeartModel::GetInstance()->Heart_Control(HeartState::End); // 关闭心率检测 + HeartModel::GetInstance()->Heart_Control(HeartState::End,HeartCheck::INITIATIVE); // 关闭心率检测 } /* -------------------------------------------------------------------------- */ /*定时器到期时的处理*/ @@ -78,7 +78,7 @@ namespace OHOS RespiratoryTrainingModel::GetInstance().RT_StopTimer(); // 停止定时器 RespiratoryTrainingModel::GetInstance().AddRespiratoryTrainingTimes(); // 呼吸训练次数加1 p_RespiratoryTrainingView->GetRespiratoryTrainingAnimator_()->Stop(); // 关闭呼吸动画 - HeartModel::GetInstance()->Heart_Control(HeartState::End); // 关闭心率检测 + HeartModel::GetInstance()->Heart_Control(HeartState::End,HeartCheck::INITIATIVE); // 关闭心率检测 p_RespiratoryTrainingView->ChangeView(RESPIRATORYTRAINING, RESPIRATORYTRAININGCOMPLETED); } else @@ -86,7 +86,7 @@ namespace OHOS Time = ONE_MINUTE; p_RespiratoryTrainingView->StartRespiratoryTraining(); // 开始呼吸训练 START_FLAG = true; - HeartModel::GetInstance()->Heart_Control(HeartState::Start); // 开启心率检测 + HeartModel::GetInstance()->Heart_Control(HeartState::Start,HeartCheck::INITIATIVE); // 开启心率检测 } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/rtcservice/src/rtc_at_cmd.cpp b/code/sdk/application/wearable/fd230app/nativeui/rtcservice/src/rtc_at_cmd.cpp index 1ae2202be..c38fb8d93 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/rtcservice/src/rtc_at_cmd.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/rtcservice/src/rtc_at_cmd.cpp @@ -97,22 +97,10 @@ extern "C" } return ERRCODE_SUCC; } - static uint32_t rtc_restore_factory_settings(uint8_t *para, uint32_t paraLen, char *strCommonCmd) - { - UNUSED(para); - UNUSED(paraLen); - UNUSED(strCommonCmd); - - // 执行恢复出厂设置的操作 - uapi_restore_factory_setting(); - PRINT("Restoring Factory Settings...\n"); - return ERRCODE_SUCC; - } static const at_cmd_table_t g_rtc_cmd[] = { {(char *)"AT^RTCTEST", rtc_do_test, (char *)"enable"}, - {(char *)"AT^RESTORE", rtc_restore_factory_settings, NULL}, }; at_cmd_table_t *get_rtc_cmd_table(uint32_t *cmd_count) diff --git a/code/sdk/application/wearable/fd230app/nativeui/screensetting/src/ScreenModels.cpp b/code/sdk/application/wearable/fd230app/nativeui/screensetting/src/ScreenModels.cpp index 6b26e3841..5887f6d2d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/screensetting/src/ScreenModels.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/screensetting/src/ScreenModels.cpp @@ -73,7 +73,7 @@ bool ScreenModels::LoadAppImages(std::string file, UIImageView *view, uint32_t r void ScreenModels::PreLoadAppimages(void) { LoadAppMultiImages(PLAYER_IAMGES, PLAYER_BACKGROUND, PLAYER_PLAYING); - LoadAppMultiImages(CLOCK_IAMGES, CLOCK_CLOCK0, CLOCK_SECOND); + //LoadAppMultiImages(CLOCK_IAMGES, CLOCK_CLOCK0, CLOCK_SECOND); LoadAppMultiImages(COMPASS_IAMGES, COMPASS_COMPASS0, COMPASS_COMPASS2); LoadAppMultiImages(DROPDOWN_IAMGES, DROPDOWN_BLUETOOTHCONNECTED, DROPDOWN_SETTING); LoadAppMultiImages(HEART_IAMGES, HEART_HEARTRATECOOR, HEART_HEARTRATE_TOP); diff --git a/code/sdk/application/wearable/fd230app/nativeui/set_dial/src/SetDialModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/set_dial/src/SetDialModel.cpp index b9d56647b..f2e4e1af0 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/set_dial/src/SetDialModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/set_dial/src/SetDialModel.cpp @@ -136,11 +136,13 @@ namespace OHOS /* 注册表盘map */ void SetDialModel::RegisterDial(uint16_t ID, const char *dialname) { + if(ID==0 || strlen(dialname)==0) + return; registeredDials[ID] = std::string(dialname); // 唯一性 - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RegisterDial %s is ok!", dialname); - + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RegisterDial %d %s is ok!",ID, dialname); + LoadAllDial(); saveDialfile(); @@ -170,7 +172,10 @@ namespace OHOS /* 获取当前表盘Id */ uint16_t SetDialModel::GetCurrentDialID() { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "currentDialID is %d,name is %s", currentDialID, registeredDials[currentDialID].c_str()); + if (registeredDials.find(currentDialID) != registeredDials.end()) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "currentDialID is %d,name is %s", currentDialID, registeredDials[currentDialID].c_str()); + } return currentDialID; } /* 获取所有表盘Id 每个表盘Id 2个字节 拼接为字符串 */ @@ -224,6 +229,8 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UninstallDial the dial %d is ok", ID); registeredDials.erase(ID); + LoadAllDial(); + return true; } @@ -236,25 +243,28 @@ namespace OHOS /*更新表盘*/ void SetDialModel::UpdateDialSetting(uint16_t ID) { - std::string dialname = registeredDials[ID]; // 根据ID找到对应的表盘名称 - // 在dialInfoList中查找同名表盘 - for (size_t i = 0; i < dialInfoList.size(); i++) + if (registeredDials.find(ID) != registeredDials.end()) { - if (dialInfoList[i].dialName == dialname) + std::string dialname = registeredDials[ID]; // 根据ID找到对应的表盘名称 + // 在dialInfoList中查找同名表盘 + for (size_t i = 0; i < dialInfoList.size(); i++) { - DialSetting diagSetting; - SetDialInfo &info = dialInfoList[i]; - diagSetting.dialFlag = info.dialFlag; - diagSetting.dialId = info.id; - diagSetting.dialFullName = info.dialFullName; - MainModel::GetInstance().AddDialSetting(diagSetting); // 更新表盘设置 - currentDialID = ID; // 更新当前表盘Id - NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN); - return; // 更新成功后直接返回 + if (dialInfoList[i].dialName == dialname) + { + DialSetting diagSetting; + SetDialInfo &info = dialInfoList[i]; + diagSetting.dialFlag = info.dialFlag; + diagSetting.dialId = info.id; + diagSetting.dialFullName = info.dialFullName; + MainModel::GetInstance().AddDialSetting(diagSetting); // 更新表盘设置 + currentDialID = ID; // 更新当前表盘Id + NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN); + return; // 更新成功后直接返回 + } } + NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDialModel UpdateDialSetting: Cannot find dial with name %s", dialname.c_str()); } - NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDialModel UpdateDialSetting: Cannot find dial with name %s", dialname.c_str()); } /*加载所有表盘*/ 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..9784305f7 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,85 @@ #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); + // 睡眠状态 + enum class SLEEPSTATE + { + NOSLEEP = 0, + SLEEPNOTIFY, + SLEPP, + WALK, + }; + 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(); // 解析目标休息时间 + std::string get_notifiy(); // 获取提醒时间 + std::string get_sleep_notifiy(); // 获取睡眠时间 + std::string get_walk_notifiy(); // 获取起床时间 + + void set_sleep_state(SLEEPSTATE state); + SLEEPSTATE get_sleep_state(); private: SleepModel(); @@ -93,11 +106,18 @@ 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{"--"}; + + std::string goalnotifyStr{"--"}; + std::string goalsleepStr{"--"}; + std::string goalwalkStr{"--"}; + + uint8_t sleep_total_time = 0; + uint8_t goal_total_time = 0; + + SLEEPSTATE sleepstate_ = SLEEPSTATE::NOSLEEP; }; } 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..843d782e9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp @@ -1,12 +1,12 @@ /* * @Author: penglei 1624952103@qq.com - * @Date: 2024-06-26 19:36:48 + * @Date: SLEPPNOTIFY24-06-26 19:36:48 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2024-06-28 16:52:58 + * @LastEditTime: SLEPPNOTIFY24-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) SLEPPNOTIFY24 by ${git_name_email}, All Rights Reserved. */ #include "sleep/include/SleepModel.h" @@ -15,23 +15,39 @@ #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}; +#define SLEPPNOTIFY 20 + + 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 +60,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 +128,223 @@ 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() + { + // 将原3个字符串清空 + goalnotifyStr.clear(); + goalsleepStr.clear(); + goalwalkStr.clear(); + + 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; + // 睡眠时间点字符串 + goalsleepStr = sleeposs.str(); + + /* -------------------------------------------------------------------------- */ + // 需要配置提醒字符串 减去SLEPPNOTIFY分钟的计算 + int notify_min = (goal_sleep_min >= SLEPPNOTIFY) ? goal_sleep_min - SLEPPNOTIFY : ((goal_sleep_min + 60) - SLEPPNOTIFY); // 避免分钟数为负 + int notify_hour = goal_sleep_hour; + if (goal_sleep_min < SLEPPNOTIFY) + { // 如果需要借位 + notify_hour -= 1; // 小时减1 + } + // 确保小时数正确 + notify_hour = (notify_hour < 0) ? 23 : notify_hour; // 处理从0点前SLEPPNOTIFY分钟的情况,变为前一天的23点40分 + // 格式化提醒时间字符串 + std::ostringstream notifyoss; + notifyoss << std::setfill('0') << std::setw(2) << notify_hour << ":" << std::setw(2) << notify_min; + // 设置提醒字符串 + goalnotifyStr = notifyoss.str(); + /* -------------------------------------------------------------------------- */ + + int goal_walk_hour = goal_walk >> 16; + 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; + // 起床时间点字符串 + 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; + } + // 获取实际入睡时间str + std::string SleepModel::get_rest_str() + { + return sleepStr; + } + // 获取实际醒来时间str + std::string SleepModel::get_walk_str() + { + return walkStr; + } + // 获取目标休息时间str + std::string SleepModel::get_goal_str() + { + return goalStr; + } + // 获取 目标睡眠提醒 时间点str + std::string SleepModel::get_notifiy() + { + return goalnotifyStr; + } + // 获取 目标睡眠 时间点str + std::string SleepModel::get_sleep_notifiy() + { + return goalsleepStr; + } + + // 获取 目标起床 时间点str + std::string SleepModel::get_walk_notifiy() + { + return goalwalkStr; + } + // 设置睡眠状态 + void SleepModel::set_sleep_state(SLEEPSTATE state) + { + sleepstate_ = state; + } + // 获取睡眠状态 + SLEEPSTATE SleepModel::get_sleep_state() + { + return sleepstate_; + } } \ 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/fd230app/nativeui/system/include/SystemPresenterC.h b/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemPresenterC.h new file mode 100644 index 000000000..d48a446f0 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemPresenterC.h @@ -0,0 +1,27 @@ +/* + * @Author: penglei 1624952103@qq.com + * @Date: 2024-06-07 11:18:25 + * @LastEditors: penglei 1624952103@qq.com + * @LastEditTime: 2024-07-02 11:07:00 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemPresenterC.h + * @Description: + * + * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. + */ +#ifndef SYSTEM_PRESENTER_H +#define SYSTEM_PRESENTER_H + +#ifdef __cplusplus +#if __cplusplus +extern "C" +{ +#endif +#endif + void factorytest_enter_test_view(int cmd); + +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif +#endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemPresenter.cpp index 88991f015..f79265764 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemPresenter.cpp @@ -225,4 +225,25 @@ namespace OHOS // { // isSystemUpgradeState = falg; // } +#ifdef __cplusplus +#if __cplusplus +extern "C" +{ +#endif /* __cplusplus */ +#endif /* __cplusplus */ + + void factorytest_enter_test_view(int cmd) + { + if(cmd == 1) + NativeAbility::GetInstance().ChangeSlice(VIEW_TEST); + else + NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN); + } + + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cplusplus */ +#endif /* __cplusplus */ } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEnddataPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEnddataPresenter.h index 2a0257af8..197d95d94 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEnddataPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEnddataPresenter.h @@ -1,4 +1,9 @@ - +/*** + * @Date: 2024-04-15 10:55:58 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-06-29 17:46:18 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEnddataPresenter.h + */ #ifndef _TraingEnddata_PRESENTER_H #define _TraingEnddata_PRESENTER_H @@ -11,8 +16,9 @@ namespace OHOS class TraingEnddataView; class TraingEnddataPresenter : public Presenter, - public UIView::OnClickListener, - public UIView::OnDragListener + public UIView::OnClickListener, + public RootView::OnKeyActListener, + public UIView::OnDragListener { public: TraingEnddataPresenter(); @@ -28,7 +34,8 @@ namespace OHOS // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; bool OnClick(UIView &view, const ClickEvent &event) override; bool OnDrag(UIView &view, const DragEvent &event) override; - //bool OnDragEnd(UIView& view, const DragEvent& event) override; + bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 + // bool OnDragEnd(UIView& view, const DragEvent& event) override; }; } // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingNomalPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingNomalPresenter.h index d2e6356b1..cb7e898a1 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingNomalPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingNomalPresenter.h @@ -1,4 +1,4 @@ -/*** +/*** * @Date: 2024-04-15 10:55:58 * @LastEditors: Caisking 3449750381@qq.com * @LastEditTime: 2024-04-17 14:18:05 @@ -17,6 +17,7 @@ namespace OHOS class TraingNomalPresenter : public Presenter, public UIView::OnClickListener, + public RootView::OnKeyActListener, public UIView::OnDragListener { public: @@ -34,6 +35,7 @@ namespace OHOS // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; bool OnClick(UIView &view, const ClickEvent &event) override; bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 // bool OnDragEnd(UIView& view, const DragEvent& event) override; }; } // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingPresenter.h index 7bf2b69c0..50dc63765 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingPresenter.h @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-04-15 10:55:58 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-06-29 17:42:47 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingPresenter.h + */ #ifndef _Traing_PRESENTER_H #define _Traing_PRESENTER_H @@ -11,7 +17,8 @@ namespace OHOS class TraingPresenter : public Presenter, public UIView::OnClickListener, - public UIView::OnDragListener + public UIView::OnDragListener, + public RootView::OnKeyActListener { public: TraingPresenter(); @@ -29,6 +36,7 @@ namespace OHOS bool OnClick(UIView &view, const ClickEvent &event) override; bool OnDrag(UIView &view, const DragEvent &event) override; bool OnDragEnd(UIView &view, const DragEvent &event) override; + bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 }; } // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingSetPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingSetPresenter.h index 114d088b1..9d43f684d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingSetPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingSetPresenter.h @@ -25,6 +25,7 @@ namespace OHOS class TraingSetView; class TraingSetPresenter : public Presenter, public UIView::OnClickListener, + public RootView::OnKeyActListener, public UIView::OnDragListener { public: @@ -37,7 +38,7 @@ namespace OHOS void OnStop() override; static TraingSetPresenter *GetInstance(); - + const char *GetButtonIdFromCard(int cardID); int GetTagFromCard(int cardID); ExerciseTag GetExerciseTagFromCard(int cardID); @@ -47,6 +48,7 @@ namespace OHOS bool OnClick(UIView &view, const ClickEvent &event) override; bool OnDrag(UIView &view, const DragEvent &event) override; bool OnDragEnd(UIView &view, const DragEvent &event) override; + bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 }; } // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataPresenter.cpp index 6d2b73031..b6c37c085 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataPresenter.cpp @@ -20,6 +20,9 @@ #include "components/ui_label_ext.h" #include "language/font/ui_resource_string.h" #include "NativeAbility.h" +#include "KeyInputListener.h" +#include "custom_utils.h" +#include "common/key_code.h" #include #include @@ -94,4 +97,16 @@ namespace OHOS } return true; } + bool TraingEnddataPresenter::OnKeyAct(UIView &view, const KeyEvent &event) + { + unsigned short keyID = event.GetKeyId(); + unsigned short keyState = event.GetState(); + // 如果是power键,且是亮屏状态,按键释放就返回上一级 + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0) + { + // 回退 + NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST, TransitionType::TRANSITION_ZOOM); + } + return true; + } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataView.cpp index 932b8838f..ee598e08f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataView.cpp @@ -277,7 +277,7 @@ namespace OHOS delete scrollView_; scrollView_ = nullptr; } - + delete container_; container_ = nullptr; } @@ -383,6 +383,10 @@ namespace OHOS PreLoad(); InitData(); RootView::GetInstance()->Add(container_); + + // 增加按键监听 + RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::TraingEnddataPresenter::GetInstance(); + RootView::GetInstance()->SetOnKeyActListener(keyactListener); } void TraingEnddataView::OnSetUpView() diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingNomalPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingNomalPresenter.cpp index 978d9ef7b..342df0129 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingNomalPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingNomalPresenter.cpp @@ -4,6 +4,10 @@ #include "components/ui_label_ext.h" #include "language/font/ui_resource_string.h" #include "NativeAbility.h" +#include "KeyInputListener.h" +#include "custom_utils.h" +#include "common/key_code.h" + #include #include @@ -89,4 +93,16 @@ namespace OHOS } return true; } + bool TraingNomalPresenter::OnKeyAct(UIView &view, const KeyEvent &event) + { + unsigned short keyID = event.GetKeyId(); + unsigned short keyState = event.GetState(); + // 如果是power键,且是亮屏状态,按键释放就返回上一级 + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0) + { + // 回退 + NativeAbility::GetInstance().Back(); + } + return true; + } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingNomalView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingNomalView.cpp index 2adc8a910..3ee8f3b3c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingNomalView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingNomalView.cpp @@ -122,6 +122,10 @@ namespace OHOS PreLoad(); RootView::GetInstance()->Add(container_); + + // 增加按键监听 + RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::TraingNomalPresenter::GetInstance(); + RootView::GetInstance()->SetOnKeyActListener(keyactListener); } void TraingNomalView::OnSetUpView() diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingPresenter.cpp index 70a09ba3d..9e7155735 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingPresenter.cpp @@ -9,6 +9,9 @@ #include "components/ui_label_ext.h" #include "language/font/ui_resource_string.h" #include "NativeAbility.h" +#include "KeyInputListener.h" +#include "custom_utils.h" +#include "common/key_code.h" #include #include @@ -98,4 +101,18 @@ namespace OHOS TraingModel::GetInstance()->SetSportType(Exercisetype::FITNESS); return true; } + + // 增加按键事件 + bool TraingPresenter::OnKeyAct(UIView &view, const KeyEvent &event) + { + unsigned short keyID = event.GetKeyId(); + unsigned short keyState = event.GetState(); + // 如果是power键,且是亮屏状态,按键释放就返回上一级 + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0) + { + // 回退 + NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST, TransitionType::TRANSITION_ZOOM); + } + return true; + } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingSetPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingSetPresenter.cpp index 054c1048f..b47137d1d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingSetPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingSetPresenter.cpp @@ -8,6 +8,9 @@ #include "components/ui_label_ext.h" #include "language/font/ui_resource_string.h" #include "NativeAbility.h" +#include "KeyInputListener.h" +#include "custom_utils.h" +#include "common/key_code.h" #include #include @@ -71,7 +74,27 @@ namespace OHOS { return true; } - + // 增加按键事件 + bool TraingSetPresenter::OnKeyAct(UIView &view, const KeyEvent &event) + { + int CardID = TraingSetView::GetInstance()->GetCurrentViewId(); + unsigned short keyID = event.GetKeyId(); + unsigned short keyState = event.GetState(); + // 如果是power键,且是亮屏状态,按键释放就返回上一级 + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0) + { + // 不在设置页面 + if (CardID != SET_VIEW) + { + TraingSetView::GetInstance()->ChangeView(CardID, SET_VIEW); + } + else + { + NativeAbility::GetInstance().Back(); + } + } + return true; + } bool TraingSetPresenter::OnDragEnd(UIView &view, const DragEvent &event) { int CardID = TraingSetView::GetInstance()->GetCurrentViewId(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingView.cpp index 00f35bffe..9f6440d2c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingView.cpp @@ -70,7 +70,7 @@ namespace OHOS bool TraingView::AddLabel() { // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingModel::AddLabel"); - // 初始化标签 + // 初始化标签 InitLabelExt(title_label, TITLE_LABEL_X, TITLE_LABEL_Y, LABEL_X_SIZE, LABEL_Y_SIZE, "title_label", STR_RAPID_TRAINING, DEFAULT_VECTOR_FONT_FILENAME, LABEL_FONT_SIZE); InitLabelExt(btn1_label, BTN1_LABEL_X, BTN1_LABEL_Y, LABEL_X_SIZE, LABEL_Y_SIZE, "btu1_label", STR_EXERCISE_OUTDOORWALKING, DEFAULT_VECTOR_FONT_FILENAME, LABEL_FONT_SIZE); @@ -261,7 +261,6 @@ namespace OHOS return; } container_->SetOnDragListener(draglistener); - container_->SetTouchable(true); container_->SetDraggable(true); @@ -269,6 +268,9 @@ namespace OHOS RootView::GetInstance()->Add(container_); SetContainerView(container_); + // 增加按键监听 + RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::TraingPresenter::GetInstance(); + RootView::GetInstance()->SetOnKeyActListener(keyactListener); } void TraingView::OnSetUpView() 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..2f92ec084 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 @@ -33,7 +34,9 @@ ${ROOT_DIR}/middleware/services/gui/uikit/proprietary/src/utils/innerkits ${ROOT_DIR}/middleware/services/gui/uikit/proprietary/include ${ROOT_DIR}/middleware/services/gui/uikit/proprietary/include/common ${ROOT_DIR}/application/wearable/fd230app/nativeui/set_dial/include -#/home/hcj/FD230/code/sdk/middleware/services/gui/uikit/proprietary/include/common/image_cache_manager.h +${ROOT_DIR}/application/wearable/fd230app/nativeui/aivoice/include + + ) 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 b98539d94..c3842503d 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp @@ -28,13 +28,16 @@ #include "uiservice/include/ui_service.h" #include "TraingModel.h" #include "WeatherModel.h" +#include "SleepModel.h" #endif #include "AlmmgrAlarmClockManage.h" +#include "AlarmClockTimerConfig.h" #include "AlarmClockManage.h" #include "SetDialModel.h" +#include "AiVoiceModel.h" #include "SleepModel.h" //#include "AlarmClockModel.h" #ifdef __cplusplus @@ -70,6 +73,171 @@ extern "C" { #include +void ble_set_ai_Question_str(char *buf) +{ + OHOS::AiVoiceModel::GetInstance().SetUserQuestionStr(std::string(buf)); +} + +void ble_set_ai_Answer_str(char *buf) +{ + OHOS::AiVoiceModel::GetInstance().SetaiAnswerStrStr(std::string(buf)); +} + +// { +// "type":3, +// "list":[ +// { +// "uid":3758, +// "name":"plate_3758.bin", +// "size":129600 +// }, +// { +// "uid":3759, +// "name":"plate_3759.bin", +// "size":129600 +// } +// ] +// } +// 注:MP3文件目录格式 +// { +// "type":2, +// "list": [ +// { +// "uid":2461, //指定唯一编号,便于APP发送编号删除文件 +// "name":"夜曲.mp3", +// "size":3894464, +// "artist":"周杰伦", +// "dur":223000 //歌曲时长,单位毫秒 +// }, +// { +// "uid":2465, //指定唯一编号,便于APP发送编号删除文件 +// "name":"告白气球.mp3", +// "size":3894464, +// "artist":"周杰伦", +// "dur":223000 //歌曲时长,单位毫秒 +// } +// ] +// } +// Tag_Trailer_t Mp3Trailer; + +// void Tag_GetTrailer( FILE *fp) +// { +// // Get Header +// fseek(fp,-128,SEEK_END); +// fread(Mp3Trailer.Header,3,1,fp); +// // Get Title +// fseek(fp,-125,SEEK_END); +// fread(Mp3Trailer.Title,30,1,fp); +// // Get Artist +// fseek(fp,-95,SEEK_END); +// fread(Mp3Trailer.Artist,30,1,fp); +// // Get Album +// fseek(fp,-65,SEEK_END); +// fread(Mp3Trailer.Album,30,1,fp); +// // Get Year +// fseek(fp,-35,SEEK_END); +// fread(Mp3Trailer.Year,4,1,fp); +// // Get Comment +// fseek(fp,-31,SEEK_END); +// fread(Mp3Trailer.Comment,30,1,fp); +// // Get Cenre +// fseek(fp,-1,SEEK_END); +// fread(Mp3Trailer.Cenre,1,1,fp); +// } + + + +char * dir_to_json_buf_malloc_(uint8_t type) +{ + char dir_path[128]={0}; + type=2; + switch (type) + { + case 2: // + sprintf_s(dir_path,64,"%s","user/music"); + break; + case 3: // + sprintf_s(dir_path,64,"%s","user/userdata/dial"); + break; + default: + break; + } + cJSON *dataJSON = cJSON_CreateObject(); + cJSON* data_arryJSON = cJSON_CreateArray(); + + struct DIR *dir; + struct dirent *ent; + uint32_t file_size=0; + uint8_t file_index=1; + if ((dir = opendir(dir_path)) != NULL) + { + while ((ent = readdir(dir)) != NULL) + { + std::string fileName = ent->d_name; + + if (fileName != "." && fileName != "..") + { + //std::string filePath = directory + fileName; + + + if (ent->d_type == DT_REG || ent->d_type == DT_UNKNOWN ) // 普通文件 + { + char file_path[128]={0}; + sprintf_s(file_path,128,"%s/%s","user/music",ent->d_name); + + FILE * fp = fopen(file_path,"rb+"); + if(fp==NULL) + { + printf(" fopen fail %s\r\n",file_path); + return NULL; + } + if (fp != NULL) + { + fseek(fp, 0, SEEK_END); // 将文件指针移动到文件末尾 + file_size = ftell(fp); // 获取当前文件指针位置,即文件大小 + fseek(fp, 0, SEEK_SET); // 将文件指针移回文件开头 + } + //Tag_GetTrailer(fp); + + fclose(fp); + + cJSON* itemJSON = cJSON_CreateObject(); + cJSON_AddNumberToObject(itemJSON,"uid",file_index); + cJSON_AddStringToObject(itemJSON,"name",fileName.c_str()); + cJSON_AddNumberToObject(itemJSON,"size",file_size); + cJSON_AddStringToObject(itemJSON,"artist", "未知"); + cJSON_AddStringToObject(itemJSON,"dur", "未知"); + cJSON_AddItemReferenceToArray(data_arryJSON,itemJSON); + file_index++; + + } + else if (ent->d_type == DT_DIR) // 目录 + { + continue; + } + } + } + closedir(dir); + } + else + { + printf("opendir fail\r\n"); + } + cJSON_AddNumberToObject(dataJSON,"type",2); + + cJSON_AddItemToObject(dataJSON,"list",data_arryJSON); + + char *json_format = cJSON_PrintUnformatted(dataJSON); + + int pSize = cJSON_GetArraySize(dataJSON); + cJSON_Delete(dataJSON); + printf("mp3 :%s\r\n",json_format); + return json_format; +} + + + + uint8_t ble_AT_add_nap_data(uint16_t time) { OHOS::NAP_T data; @@ -418,6 +586,11 @@ 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(); + set_sleep_and_wake_time(); + get_sleep_time_notify(); } return; } @@ -437,8 +610,8 @@ void ble_get_sleep_remind(msg_get_sleep_param_info_t *data) printf("开始时间:%d\r\n",data->bedtime_min); uint32_t wakettime= p_ConfigModel->get_configData_int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SLEEP_GET_UP); - data->waketime_hour=bedtime>>16; - data->waketime_min=bedtime&0x00ff; + data->waketime_hour=wakettime>>16; + data->waketime_min=wakettime&0x00ff; printf("结束时间:%d\r\n",data->waketime_hour); printf("结束时间:%d\r\n",data->waketime_min); @@ -658,6 +831,13 @@ char * struct_to_json_buf_malloc_(uint8_t day) cJSON_AddNumberToObject(itemJSON,"di",data->di); cJSON_AddNumberToObject(itemJSON,"hr",data->hr); cJSON_AddNumberToObject(itemJSON,"stp",data->stp); + cJSON_AddNumberToObject(itemJSON,"ti",data->ti); + cJSON_AddNumberToObject(itemJSON,"cir",data->cir); + cJSON_AddNumberToObject(itemJSON,"alt",data->alt); + cJSON_AddNumberToObject(itemJSON,"fpc",data->fpc); + cJSON_AddNumberToObject(itemJSON,"spc",data->spc); + cJSON_AddNumberToObject(itemJSON,"std",data->std); + cJSON_AddNumberToObject(itemJSON,"cdc",data->cdc); cJSON_AddItemReferenceToArray(data_arryJSON,itemJSON); free(data); diff --git a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h index b87b1dedc..e8ca3112a 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.h @@ -256,6 +256,28 @@ uint8_t ble_get_sleep_data(uint32_t file_size,uint8_t day_,uint8_t *data); uint8_t ble_AT_add_nap_data(uint16_t time); +/////////////////////////////AI相关///////////////////////// +void ble_set_ai_Question_str(char *buf); + +void ble_set_ai_Answer_str(char *buf); + +/////////////////////////////MP3相关///////////////////////// + +typedef struct Tag_Trailer +{ +char Header[3]; +char Title[30]; +char Artist[30]; +char Album[30]; +char Year[4]; +char Comment[30]; +char Cenre[1]; +}Tag_Trailer_t; + +char * dir_to_json_buf_malloc_(uint8_t type); + +char * dir_to_json_buf_malloc_(uint8_t type); + #ifdef __cplusplus #if __cplusplus } diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c index ff7c50de0..413982566 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -2078,13 +2078,13 @@ uint8_t binCheck_AI(uint8_t *buf,uint8_t *check,uint16_t len)//json 格式解析 uint8_t flag = 0; // printf("jsonCheck_weather:len: json:%f jsonlen:%d\r\n",0.011,strlen((char *)json)); #if 0 - FILE *fp=fopen("user/weather.json","wb+"); - printf("jsonCheck_weather len %d",strlen((char *)buf)+1); - //fwrite((void*)buf,1,strlen((char *)buf)+1,fp); - fputs((char *)buf,fp); + FILE *fp=fopen("user/AI.txt","wb+"); + printf("binCheck_AI len %d\r\n",len); + fwrite((void*)buf,1,len,fp); + //fputs((char *)buf,fp); fclose(fp); - 1+1+2 #endif + uint16_t offset=0; while (len>offset) @@ -2092,22 +2092,27 @@ uint8_t binCheck_AI(uint8_t *buf,uint8_t *check,uint16_t len)//json 格式解析 if(buf[offset]==1) { offset++; - uint16_t txt_len=buf[offset]; - offset++; - char buf[128]={0}; - memcpy_s(buf,128,buf[offset],txt_len); - printf("%s\r\n",buf); + uint16_t txt_len; + memcpy_s(&txt_len,2,&buf[offset],2); + + offset+=2; + char txt_buf[128]={0}; + memcpy_s(txt_buf,128,&buf[offset],txt_len); + printf("binCheck_AI txtbuf:%s %d\r\n",txt_buf,txt_len); + ble_set_ai_Question_str(txt_buf); offset+=txt_len; offset+=1; } else if(buf[offset]==2) { offset++; - uint16_t txt_len=buf[offset]; - offset++; - char buf[128]={0}; - memcpy_s(buf,128,buf[offset],txt_len); - printf("%s\r\n",buf); + uint16_t txt_len=buf[offset]+buf[offset+1]*256; + offset+=2; + + char txt_buf[128]={0}; + memcpy_s(txt_buf,128,&buf[offset],txt_len); + printf("%s %d\r\n",txt_buf,txt_len); + ble_set_ai_Answer_str(txt_buf); offset+=txt_len; offset+=1; } @@ -2138,6 +2143,9 @@ void GetWeatherCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,ui // printf("GetWeatherCmd:len:%d data:%s\r\n",len,data); if(Check_CRC(data,len,crcvalue)) { + // uint32_t y=(0xff00); + // uint32_t x =(0xff00& 0Xff00)>>16; + // printf("GetWeatherCmd %u\r\n",x); uint8_t check = 1; jsonCheck_weather(data,&check); sendBuf[17] = check; @@ -2153,7 +2161,7 @@ void GetWeatherCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,ui } -void GetAiResultCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//获取天气数据 +void GetAiResultCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,uint8_t crcvalue) { uint32_t tmp = 1; uint16_t tmp_data = 1; @@ -2161,7 +2169,7 @@ void GetAiResultCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,u memset(sendBuf,0,19); sendBuf[0] = 0x72; sendBuf[1] = 0x02; - sendBuf[2] = 0x20; + sendBuf[2] = 0x1f; memcpy(sendBuf+3,&tmp,4); memcpy(sendBuf+7,&tmp,4); memcpy(sendBuf+11,&tmp,4); @@ -2390,9 +2398,8 @@ void getAPPaddressbook(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalDat void type2AE4Data(ble_read_data *buffer_handle,uint8_t *buf_cmd,uint8_t *data,uint16_t datalen,uint8_t *totalData,uint8_t crcvalue) { uint16_t typeID = buf_cmd[1]*256+buf_cmd[2]; - #ifdef BLE_LOG + printf("type2AE4Data typeID:0x%04X\r\n",typeID); - #endif switch (typeID) //ID { case USER_INFOR_CMD://app下发的获取用户信息 @@ -3993,13 +4000,14 @@ static void GetAiRecordCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *tota FILE *fp=fopen(file_name,"rb+"); printf("GetAiRecordCmd size %d\r\n",file_size); - uint16_t pack=file_size/num+1; - uint8_t pack_id=1; + uint32_t pack=file_size/num+1; + uint32_t pack_id=1; if(fp==NULL) { printf("fopen fail %s\r\n",file_name); goto GetAiRecordFail; } + do { memset_s(data,num+1,0,num+1); @@ -4007,7 +4015,7 @@ static void GetAiRecordCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *tota send_big_data(1,data,read_size,file_size,pack_id,pack,0x34,1); pack_id++; - msleep(50); + msleep(10); } while (read_size==num); free(data); @@ -4234,7 +4242,7 @@ static void Send_json_Data_Cmd(uint8_t day,uint16_t pack_size,uint8_t id) json_format=struct_to_json_buf_malloc_Alarm(); break; case 0x21: - json_format=NULL; + json_format=dir_to_json_buf_malloc_(day); break; default: @@ -4561,9 +4569,6 @@ void type2AE3Data(ble_read_data *buffer_handle,uint8_t *cmd_buf ,uint8_t *data,u case REVOKE_CURR_FILE_TRANS_CMD://撤销文件传输 RemoveFileCmd(buffer_handle,cmd,data,datalen,totaldata,crcvalue); break; - case GET_SPECIF_TYPE_FILE_CMD://获取指定类型文件目录 - GetFileTypeCmd(data,datalen); // - break; case DELETE_SPECIF_TYPE_FILE_CMD://删除指定类型的所有文件 DeleteFileTypeCmd(cmd,data,datalen,totaldata,crcvalue); break; @@ -4658,10 +4663,11 @@ void type2AE3Data(ble_read_data *buffer_handle,uint8_t *cmd_buf ,uint8_t *data,u case GET_PASSWORD_CMD: //获取手表密码 GetPasswordCmd(cmd,data,datalen,totaldata,crcvalue); break; - case AI_IS_READ_DATA_CMD: + case APP_GET_AI_PCM_DATA_CMD: GetAiRecordCmd(cmd,data,datalen,totaldata,crcvalue); break; - case APP_GET_AI_PCM_DATA_CMD://获取手表闹钟//同步闹钟 + case GET_SPECIF_TYPE_FILE_CMD://获取指定类型文件目录 + case AI_IS_READ_DATA_CMD: case SYN_HEART_HISTORY_DATA_CMD://同步心率历史数据 //heartDataCmd(cmd,data,datalen,totaldata,crcvalue); case SYN_SPO2_HISTORY_DATA_CMD://同步血氧历史数据 @@ -4829,12 +4835,12 @@ bool Read_Health_BIN_file_buf_send_bin_Data(uint8_t day, uint16_t num,uint16_t i buf = (char *)ym_malloc(sizeof(char)*num+1); if(buf==NULL)return false; - uint16_t pack=1; + uint32_t pack=1; if(file_size%num==0) pack=data_len/num; else pack=data_len/num+1; - uint8_t pack_id=1; + uint32_t pack_id=1; uint32_t read_size=0; do { @@ -5837,8 +5843,8 @@ bool Read_tar_file_buf_send_Data(uint16_t pack_size,uint8_t id) printf("Read_tar_file_buf_send_Data size %d\r\n",file_size); - uint16_t pack=file_size/pack_size+1; - uint8_t pack_id=1; + uint32_t pack=file_size/pack_size+1; + uint32_t pack_id=1; if(fp==NULL) { printf("fopen fail %s\r\n",file_name); diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c index 402d075cb..25ed5dd10 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c @@ -38,7 +38,7 @@ extern "C" { #include "build_version.h" #include "custom_runtime.h" #include "custom_utils.h" - +#include "bletest.h" // extern void bts_data_to_uuid_len2(uint16_t uuid_data, bt_uuid_t *out_uuid); @@ -108,6 +108,7 @@ uint16_t ble_nus_max_data_len = SDK_BLE_MTU_MIN - 3; uint16_t data2ae3Cmd = 0;//2ae3短指令特征值 uint16_t data2ae4Cmd = 0; uint16_t data2ae5Cmd = 0; +uint16_t data2ae2Cmd = 0;//read uint16_t data2ae1Cmd = 0;//安卓消息来电 uint16_t data2ae0Cmd = 0;//OTA @@ -122,7 +123,7 @@ enum{ BLE_CHARACTERISTIC_SNED_LONG_ID_PROPERTIES = GATT_CHARACTER_PROPERTY_BIT_WRITE|GATT_CHARACTER_PROPERTY_BIT_WRITE_NO_RSP, BLE_CHARACTERISTIC_SNED_OTA_ID_PROPERTIES = GATT_CHARACTER_PROPERTY_BIT_WRITE|GATT_CHARACTER_PROPERTY_BIT_WRITE_NO_RSP, BLE_CHARACTERISTIC_SNED_ANDRIOD_ID_PROPERTIES = GATT_CHARACTER_PROPERTY_BIT_WRITE|GATT_CHARACTER_PROPERTY_BIT_WRITE_NO_RSP, - BLE_CHARACTERISTIC_READ_BATTERY_ID_PROPERTIES = GATT_CHARACTER_PROPERTY_BIT_READ, + BLE_CHARACTERISTIC_READ_BATTERY_ID_PROPERTIES = GATT_CHARACTER_PROPERTY_BIT_READ|GATT_CHARACTER_PROPERTY_BIT_NOTIFY, }; static uint8_t ble_adv_falg = 0; void svr_ble_adv_stop(void) @@ -876,6 +877,9 @@ static void svr_ble_bt_gatts_characteristic_add_cb(uint8_t server_id, bt_uuid_t { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "2ae2 result->value_handle6 %d\r\n",result->value_handle); // shortCmdChara = result->value_handle; + if(data2ae2Cmd == 0){ + data2ae2Cmd = result->value_handle; + } } if(ble_gatts_cmp_uuid(uuid, &chara_uuid_data_2ae4)) { @@ -984,13 +988,111 @@ errcode_t svr_ble_bt_gatts_noyify(uint8_t *data, uint16_t data_len)//这里是 WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "gatts_notify_indicate ret:0x%x. serverid:%u,conn_id:%u,handle:%u.data_len:%d", ret, g_ble_server_id, g_ble_conn_id, g_ble_server_handle,data_len); - return ret; + return ret; +} + +errcode_t svr_ble_read_data_value_updata_noyify(void)//2ae2 +{ + gatts_ntf_ind_t data_info; + data_info.attr_handle = data2ae2Cmd; + static uint8_t battery_point_val[20] = {0}; + // 获取电池电压值 + float voltage = 0.0F; + uint8_t power = 0; + power =battery_get_voltage(&voltage); + battery_point_val[0] +=1;//power ;//power;//电量90 + uint16_t dial = ble_get_dial_id(); + memcpy_s(&battery_point_val[1],2,&dial,2); + + uint8_t _major,_mid,_minor; + uapi_get_fw_version(&_major,&_mid,&_minor); + + battery_point_val[3] = _major;//固件版本号 + battery_point_val[4] = _mid; + battery_point_val[5] = _minor; + + bd_addr_t addr_info; + errcode_t ret = gap_ble_get_local_addr(&addr_info); + battery_point_val[6] = addr_info.addr[5]; + battery_point_val[7] = addr_info.addr[4]; + battery_point_val[8] = addr_info.addr[3]; + battery_point_val[9] = addr_info.addr[2]; + battery_point_val[10] = addr_info.addr[1]; + battery_point_val[11] = addr_info.addr[0]; + + battery_point_val[12] = 0;//消息推送开关 默认是关闭 0 + battery_point_val[13] = 0;//多媒体开关 + battery_point_val[14] = 5;//客户编号 + battery_point_val[15] = 5;//产品编号 + + battery_point_val[16] = 0;//硬件版本号 + battery_point_val[17] = 1; + + battery_point_val[18] = 0;//ble版本号 + battery_point_val[19] = 1; + + + data_info.value = battery_point_val; + data_info.value_len = 20; + ret = gatts_notify_indicate(g_ble_server_id, g_ble_conn_id, &data_info); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "gatts_notify_indicate ret:0x%x. serverid:%u,conn_id:%u,handle:%u.data_len:%d", ret, g_ble_server_id, + g_ble_conn_id, g_ble_server_handle,20); + return ret; } + + static void svr_ble_bt_gatts_req_read_cb(uint8_t server_id, uint16_t conn_id, gatts_req_read_cb_t *read_cb_para, errcode_t status) { WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "svr_ble_bt_gatts_req_read_cb ret:is_long:%d",read_cb_para->is_long); + + //WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "svr_ble_bt_gatts_req_read_cb ret:is_long:%d 2ae2 %d read_cb_para->handle :%d",read_cb_para->is_long,data2ae2Cmd,read_cb_para->handle); + if(read_cb_para->handle!=data2ae2Cmd) + return; + + static uint8_t battery_point_val[20] = {0}; + // 获取电池电压值 + float voltage = 0.0F; + uint8_t power = 0; + power =battery_get_voltage(&voltage); + battery_point_val[0] =power;//power ;//power;//电量90 + uint16_t dial = ble_get_dial_id(); + memcpy_s(&battery_point_val[1],2,&dial,2); + + uint8_t _major,_mid,_minor; + uapi_get_fw_version(&_major,&_mid,&_minor); + + battery_point_val[3] = _major;//固件版本号 + battery_point_val[4] = _mid; + battery_point_val[5] = _minor; + + bd_addr_t addr_info; + errcode_t ret = gap_ble_get_local_addr(&addr_info); + battery_point_val[6] = addr_info.addr[5]; + battery_point_val[7] = addr_info.addr[4]; + battery_point_val[8] = addr_info.addr[3]; + battery_point_val[9] = addr_info.addr[2]; + battery_point_val[10] = addr_info.addr[1]; + battery_point_val[11] = addr_info.addr[0]; + + battery_point_val[12] = 0;//消息推送开关 默认是关闭 0 + battery_point_val[13] = 0;//多媒体开关 + battery_point_val[14] = 5;//客户编号 + battery_point_val[15] = 5;//产品编号 + + battery_point_val[16] = 0;//硬件版本号 + battery_point_val[17] = 1; + + battery_point_val[18] = 0;//ble版本号 + battery_point_val[19] = 1; + + static gatts_ntf_ind_t gatts_ntf_ind; + gatts_ntf_ind.attr_handle=read_cb_para->handle; + gatts_ntf_ind.value=battery_point_val; + gatts_ntf_ind.value_len=20; + //read_cb_para->need_rsp=0; + gatts_notify_indicate(server_id,conn_id,&gatts_ntf_ind); } diff --git a/code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h b/code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h index 69c556481..9a0fc1015 100644 --- a/code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h +++ b/code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h @@ -90,6 +90,7 @@ typedef enum { TOPIC_EVENT_CANCEL_FIND_WATCH,//取消查找 TOPIC_EVENT_DRINKREMINDER,//喝水提醒 TOPIC_EVENT_MESSAGENOTE, //消息通知 + TOPIC_EVENT_SLEEPNOTE, //睡眠通知 TOPIC_END_NUM = 20000, } TopicNum; diff --git a/code/sdk/application/wearable/service/broadcast/src/broadcast_implement.c b/code/sdk/application/wearable/service/broadcast/src/broadcast_implement.c index 537e7ba72..56f2665c6 100644 --- a/code/sdk/application/wearable/service/broadcast/src/broadcast_implement.c +++ b/code/sdk/application/wearable/service/broadcast/src/broadcast_implement.c @@ -68,6 +68,7 @@ static const TopicToCore topicToCoreArray[] = { {TOPIC_EVENT_CANCEL_FIND_WATCH,A_CORE_MASK, 1}, {TOPIC_EVENT_DRINKREMINDER,A_CORE_MASK, 1}, {TOPIC_EVENT_MESSAGENOTE,A_CORE_MASK, 1}, + {TOPIC_EVENT_SLEEPNOTE,A_CORE_MASK, 1}, #ifdef SUPPORT_CAT1_MODEM {TOPIC_EVENT_CAT1_INCOMMING, A_CORE_MASK, 1}, {TOPIC_EVENT_CAT1_CALLCONNTED, A_CORE_MASK, 1}, diff --git a/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c b/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c index 206377026..1cd748dfa 100644 --- a/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c +++ b/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: 2024-06-17 14:31:08 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2024-06-22 15:27:12 + * @LastEditTime: 2024-07-02 17:31:37 * @FilePath: /FD230/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c * @Description: * @@ -934,24 +934,23 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint { //LCD显示颜色 uint8_t send_data = 0x00; - char *color_buf[5] ={"0Xffff0000","0xff00ff00","0xff0000ff","0xffffffff","0xff000000"}; - ScreenAlwaysOnCtr(1); + switch (*data) { case 1: - lcd_fill((uint8_t *)color_buf[0], 11); + uapi_factorytest_set_lcd_color(3); break; case 2: - lcd_fill((uint8_t *)color_buf[1], 11); + uapi_factorytest_set_lcd_color(0); break; case 3: - lcd_fill((uint8_t *)color_buf[2], 11); + uapi_factorytest_set_lcd_color(1); break; case 4: - lcd_fill((uint8_t *)color_buf[3], 11); + uapi_factorytest_set_lcd_color(4); break; case 5: - lcd_fill((uint8_t *)color_buf[4], 11); + uapi_factorytest_set_lcd_color(5); break; default: @@ -975,6 +974,33 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint 0x05, &send_data, 1); + } else if(testitem == 0x06) + { + //进入lcd测试 + uint8_t send_data = 0; + + mcu_pm_lcd_on(0,0); + uapi_factorytest_enter_test_view(1); + uapi_factorytest_enter_test_lcd_view(); + uapi_factorytest_hide_test_lcd_button(); + + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, + BLE_TEST_CMD_SOFT_TEST_SUB_MODE_LCD, + 0x06, + &send_data, + 1); + } else if(testitem == 0x07) + { + //退出lcd测试 + uint8_t send_data = 0; + + uapi_factorytest_enter_test_view(0); + + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, + BLE_TEST_CMD_SOFT_TEST_SUB_MODE_LCD, + 0x07, + &send_data, + 1); } break; @@ -1013,18 +1039,28 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint } else if(testitem == 0x03) { //触摸测试 - uint8_t send_data = 0x01; - + uint8_t send_data = 0; + mcu_pm_lcd_on(0,0); + uapi_factorytest_enter_test_view(1); + uapi_factorytest_enter_test_tp_view(); + uapi_factorytest_hide_test_tp_button(); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_TP, 0x03, &send_data, 1); - send_data = 0x00; + + } else if(testitem == 0x04) + { + //退出触摸测试 + uint8_t send_data = 0; + + uapi_factorytest_enter_test_view(0); + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_TP, - 0x03, + 0x04, &send_data, 1); @@ -1112,15 +1148,15 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint case BLE_TEST_CMD_SOFT_TEST_SUB_MODE_HRS: if(testitem == 0x01) { - //获取 hx3695 chip_id - uint8_t chip_id; - chip_id = hx3695_get_chip_id(); + //获取 ppg_id + uint8_t ppg_id; + uapi_ppg_get_id(&ppg_id); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_HRS, 0x01, - &chip_id, - sizeof(chip_id)); + &ppg_id, + sizeof(ppg_id)); } else if(testitem == 0x02) { diff --git a/code/sdk/application/wearable/service/msg_center/CMakeLists.txt b/code/sdk/application/wearable/service/msg_center/CMakeLists.txt index de7150f53..08f6efb7c 100644 --- a/code/sdk/application/wearable/service/msg_center/CMakeLists.txt +++ b/code/sdk/application/wearable/service/msg_center/CMakeLists.txt @@ -170,6 +170,7 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/sedentaryReminder_notification.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/transmitting.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/message_notification.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/sleep_notification.cpp ) else() set(SOURCES @@ -185,6 +186,7 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/sedentaryReminder_notification.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/transmitting.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/message_notification.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/notify/sleep_notification.cpp ) endif() diff --git a/code/sdk/application/wearable/service/msg_center/include/notify/sleep_notification.h b/code/sdk/application/wearable/service/msg_center/include/notify/sleep_notification.h new file mode 100644 index 000000000..0dac41be3 --- /dev/null +++ b/code/sdk/application/wearable/service/msg_center/include/notify/sleep_notification.h @@ -0,0 +1,47 @@ +/*** + * @Date: 2024-07-02 10:15:59 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-07-02 17:27:39 + * @FilePath: /FD230/code/sdk/application/wearable/service/msg_center/include/notify/sleep_notification.h + */ +/*** + * @Date: 2024-07-02 10:15:59 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-07-02 11:27:01 + * @FilePath: /FD230/code/sdk/application/wearable/service/msg_center/include/notify/sleep_notification.h + */ +/*** + * @Date: 2024-06-20 09:43:23 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-06-20 09:47:45 + * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/service/msg_center/include/notify/message_notification.h + */ +#ifndef SLEEP_NOTIFICATION +#define SLEEP_NOTIFICATION + +#include "BaseView.h" +namespace OHOS +{ + UIViewGroup *CreateSleepNotifyView(void); + void FreeSleepView(void); + void SetAlarmClockView(); + + class SleepViewEventListener : public UIView::OnTouchListener, public UIView::OnDragListener + { + public: + static SleepViewEventListener &GetInstance(); + bool OnRelease(UIView &view, const ReleaseEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnDragEnd(UIView &view, const DragEvent &event) override; + + private: + SleepViewEventListener(); + ~SleepViewEventListener(); + SleepViewEventListener(const SleepViewEventListener &) = delete; + const SleepViewEventListener &operator=(const SleepViewEventListener &) = delete; + bool X_DRAG_FLAG{false}; + }; + +} + +#endif \ No newline at end of file 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 730004bfb..5d0943264 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 @@ -29,7 +29,10 @@ #include "power_display_service.h" #include "cat1_server.h" #include "testchanging.h" + #include "message_notification.h" +#include "sleep_notification.h" + #include "testcat1.h" #include "testold.h" #include "testhrsenson.h" @@ -110,6 +113,7 @@ const PriorityMapper PRI_MAPPER[] = { {TOPIC_EVENT_CANCEL_FIND_WATCH,PRIORITY_TWO}, {TOPIC_EVENT_DRINKREMINDER,PRIORITY_TWO}, {TOPIC_EVENT_MESSAGENOTE,PRIORITY_TWO}, + {TOPIC_EVENT_SLEEPNOTE,PRIORITY_TWO}, }; static bool CheckPriority(const Topic topic) @@ -185,6 +189,7 @@ void MsgCenterSubscribe() MsgCenterSubscribeTopic(TOPIC_EVENT_CANCEL_FIND_WATCH); MsgCenterSubscribeTopic(TOPIC_EVENT_DRINKREMINDER); MsgCenterSubscribeTopic(TOPIC_EVENT_MESSAGENOTE); + MsgCenterSubscribeTopic(TOPIC_EVENT_SLEEPNOTE); } static OHOS::UIViewGroup* ShowAlarmNotify(void) @@ -265,7 +270,11 @@ static OHOS::UIViewGroup* showMessageNotify(void) { return OHOS::CreateMessageView(); } - +/*显示睡眠提醒*/ +static OHOS::UIViewGroup* showSleepNotify(void) +{ + return OHOS::CreateSleepNotifyView(); +} void MsgCenterNotifyAlarmProc(const Topic topic, Request* req) { unused(req); @@ -365,31 +374,43 @@ void MsgCenterNotifyLowPowerAlarmProc(const Topic topic, Request* req) //if(req->data); uint8 *x= (uint8 *)(req->data); const power_display_svr_api_t *display_api = power_display_svr_get_api(); - if (display_api->get_screen_state() != SCREEN_ON) - { - display_api->turn_on_screen(); - } - display_api->set_screen_set_keepon_timeout(1000*5); + if(*x==3) { + if (display_api->get_screen_state() != SCREEN_ON) + { + display_api->turn_on_screen(); + } + display_api->set_screen_set_keepon_timeout(1000*5); //倒计时结束后,直接执行关机动画 low_power_play(); } else if(*x==0) { //提醒低电充电 + if (display_api->get_screen_state() != SCREEN_ON) + { + display_api->turn_on_screen(); + } + display_api->set_screen_set_keepon_timeout(1000*5); + set_lowpower_falg(0); - // if (NotificationManager::GetInstance()->HasNotifyShowing()) - // NotificationManager::GetInstance()->StopNotify(); - NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE); + NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO); NotificationManager::GetInstance()->ShowNotify(showlowpowerNotify, (uint16_t)topic, true); } else { //电量过低,直接提醒关机 + if (display_api->get_screen_state() != SCREEN_ON) + { + display_api->turn_on_screen(); + } + display_api->set_screen_set_keepon_timeout(1000*10); + set_lowpower_falg(1); - // if (NotificationManager::GetInstance()->HasNotifyShowing()) - // NotificationManager::GetInstance()->StopNotify(); + if (NotificationManager::GetInstance()->HasNotifyShowing()) + NotificationManager::GetInstance()->StopNotify(); + NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE); NotificationManager::GetInstance()->ShowNotify(showlowpowerNotify, (uint16_t)topic, true); @@ -652,6 +673,22 @@ void MsgCenterNotifyMessageProc(const Topic topic, Request* req) NotificationManager::GetInstance()->ShowNotify(showMessageNotify, (uint16_t)topic, true); } +//睡眠提醒通知 +void MsgCenterNotifySleepProc(const Topic topic, Request* req) +{ + unused(topic); + unused(req); + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifySleepProc !"); + //亮屏显示新信息弹窗 + const power_display_svr_api_t *display_api = power_display_svr_get_api(); + if (display_api->get_screen_state() != SCREEN_ON) + { + display_api->turn_on_screen(); + } + display_api->set_screen_set_keepon_timeout(1000*5); + NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO); + NotificationManager::GetInstance()->ShowNotify(showSleepNotify, (uint16_t)topic, true); +} #endif #ifdef SUPPORT_CAT1_MODEM @@ -1232,6 +1269,7 @@ static MsgCenterNotifyTable g_msgCenterNotifyTable[] = { {TOPIC_EVENT_CANCEL_FIND_WATCH,MsgCenterNotifyCanCelFindWatchProc}, {TOPIC_EVENT_DRINKREMINDER,MsgCenterNotifyDrinkReminderProc}, {TOPIC_EVENT_MESSAGENOTE,MsgCenterNotifyMessageProc}, + {TOPIC_EVENT_SLEEPNOTE,MsgCenterNotifySleepProc}, }; static MsgCenterNotifyTable *MsgCenterGetNotifyTblCb(uint8_t idx) diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/charge_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/charge_notification.cpp index 5fe43358b..5bb1d33ca 100644 --- a/code/sdk/application/wearable/service/msg_center/src/notify/charge_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/charge_notification.cpp @@ -9,6 +9,8 @@ #include "battery_service.h" #include "NativeAbility.h" #include "custom_utils.h" +#include "cmsis_os2.h" +#include "linux/delay.h" namespace OHOS { UIImageView *imageCharge = nullptr; @@ -19,15 +21,15 @@ namespace OHOS UIViewGroup *group=nullptr; UIImageAnimatorView *ShutDownImageAnimatorView=nullptr; static constexpr char *ShutDownPaths = "/user/res/RebootAndShutDown/ShutDown/"; //关机图片路径 - static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES = 30; // 图片帧数 - static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_TIME = 150; // 图片更新间隔 - ImageAnimatorInfo ShutDownImageInfo[SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES]; // 关机图像的信息 + #define SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES 30 // 图片帧数 + static int16_t SHUTDOWN_IMAGE_ANIMATOR_TIME = 130; // 图片更新间隔 + static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_VIEW_X = 0; static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_VIEW_Y = 0; static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_VIEW_W = 466; static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_VIEW_H = 466; const char **ShutDownPathsArray{nullptr}; // 关机图片路径数组 - + ImageAnimatorInfo ShutDownImageInfo[SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES]; // 关机图像的信息 #define LOW_POWER_BUTTON "LOW_POWER_BUTTON" // UIViewGroup *ChargingStatuShow() // { @@ -52,6 +54,17 @@ namespace OHOS // imageCharge->SetVisible(true); // } // } + + static void FreeImagePathsArray(const char **imagePaths, const int numImages) + { + for (int i = 0; i < numImages; i++) + { + // ImageCacheManager::GetInstance().UnloadSingleRes(imagePaths[i]); + delete imagePaths[i]; + imagePaths[i] = nullptr; + } + } + static const char ** CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages) { const char **imagePaths = new const char *[numImages]; @@ -65,15 +78,15 @@ namespace OHOS return imagePaths; } - UIViewGroup * ShowUpShutDownAnimatorView() + void ShowUpShutDownAnimatorView() { group = new UIViewGroup(); if (group == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); - return nullptr; + return ; } - group->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + group->SetPosition(0, 0, 466, 466); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShutDownAnimatorView::ShowUpShutDownAnimatorView"); ShutDownPathsArray = CreateImagePathsArray(ShutDownPaths, "bin", SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); @@ -84,8 +97,9 @@ namespace OHOS if (ShutDownImageAnimatorView == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView new ShutDownImageAnimatorView fail"); - return NULL; + return ; } + for (uint8_t i = 0; i < SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES; i++) { ShutDownImageInfo[i].imagePath = (ShutDownPathsArray[i]); @@ -98,16 +112,24 @@ namespace OHOS ShutDownImageAnimatorView->SetPosition(SHUTDOWN_IMAGE_ANIMATOR_VIEW_X, SHUTDOWN_IMAGE_ANIMATOR_VIEW_Y, SHUTDOWN_IMAGE_ANIMATOR_VIEW_W, SHUTDOWN_IMAGE_ANIMATOR_VIEW_H); ShutDownImageAnimatorView->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); ShutDownImageAnimatorView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - ShutDownImageAnimatorView->SetImageAnimatorSrc(ShutDownImageInfo, SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES, 100); + ShutDownImageAnimatorView->SetImageAnimatorSrc(ShutDownImageInfo, SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES, SHUTDOWN_IMAGE_ANIMATOR_TIME); ShutDownImageAnimatorView->SetRepeat(false); ShutDownImageAnimatorView->SetRepeatTimes(1); } + UIImageAnimatorView::AnimatorStopListener *stoplistener = static_cast(lowppowrAnimatorStopListener::GetInstance()); + ShutDownImageAnimatorView->SetAnimatorStopListener(stoplistener); + if (stoplistener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to Create stoplistener!!"); + return; + } + ShutDownImageAnimatorView->SetVisible(true); //ShutDownImageAnimatorView->Start(); group->SetVisible(false); group->Add(ShutDownImageAnimatorView); - return group; + return ; } static uint8_t battery_falg=0; @@ -140,6 +162,7 @@ namespace OHOS if(group) { group->RemoveAll(); + ShutDownImageAnimatorView->Stop(); if(ShutDownImageAnimatorView) { delete ShutDownImageAnimatorView; @@ -149,6 +172,7 @@ namespace OHOS group = nullptr; } + FreeImagePathsArray(ShutDownPathsArray,SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); RootView::GetInstance()->Remove(UIViewGroup_lowpower); delete UIViewGroup_lowpower; @@ -292,13 +316,6 @@ namespace OHOS if(battery_falg>=3) { group->SetVisible(true); - UIImageAnimatorView::AnimatorStopListener *stoplistener = static_cast(lowppowrAnimatorStopListener::GetInstance()); - ShutDownImageAnimatorView->SetAnimatorStopListener(stoplistener); - if (stoplistener == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to Create stoplistener!!"); - return NULL; - } ShutDownImageAnimatorView->Start(); } return UIViewGroup_lowpower; @@ -344,11 +361,17 @@ namespace OHOS void lowppowrAnimatorStopListener::OnAnimatorStop(UIView &view) { //UNUSED(view); + NotificationManager::GetInstance()->StopNotify(); + msleep(500); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "xxxxxxxxxxxxxxxxxxxxOnAnimatorStop"); + if(battery_falg==4) uapi_reboot_device(); else uapi_poweroff_device(); // 关机 + + + //NotificationManager::GetInstance()->StopNotify(); // // if(strcmp(view.GetViewId(),LOW_POWER_BUTTON)!=0) diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/sleep_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/sleep_notification.cpp new file mode 100644 index 000000000..72a69cdee --- /dev/null +++ b/code/sdk/application/wearable/service/msg_center/src/notify/sleep_notification.cpp @@ -0,0 +1,277 @@ +#include "notification_manager.h" +#include "wearable_log.h" +#include "components/ui_button.h" +#include +#include "ui_service.h" +#include +#include "bleEvent.h" +#include "components/ui_label_ext.h" +#include "uicomponents/UIComponents.h" +#include "sleep/include/SleepModel.h" +#include "sleep_notification.h" +#include "string" +#include "vibrator_service.h" +#include "UiConfig.h" +#include "ConfigModel.h" +extern "C" void custom_VibratorFunc(OHOS::VibratorType vibratorType); + +namespace OHOS +{ + + UIViewGroup *SleepGroupView{nullptr}; + + UILabel *sleeptitle{nullptr}; // 标题 + UIImageView *sleepicon{nullptr}; // 睡眠图标 + UILabelExt *sleepnotifylabel{nullptr}; // 详细label + UILabelButtonExt *sleepbutton{nullptr}; // 删除按键 + + UILabelExt *alarmtitle{nullptr}; // 标题 + UIImageView *backimage{nullptr}; + UIImageView *sunnyicon{nullptr}; + UIImageView *alarmicon{nullptr}; + UILabelExt *nowlabel{nullptr}; + UILabelExt *walklabel{nullptr}; // 早安时间 + UILabelButtonExt *closebutton{nullptr}; // 关闭按键 + UILabelButtonExt *nopbutton{nullptr}; // 小睡按键 + + static std::string titleStr; + static constexpr const char *PNG_SLEEP_SUUNY_IMAGE = "/user/res/Sleep/sunny.bin"; + static constexpr const char *PNG_SLEEP_ALARM_IMAGE = "/user/res/Sleep/alarmicon.bin"; + static constexpr const char *PNG_SLEEP_BACK_IMAGE = "/user/res/Sleep/goodmorning.bin"; + +#define DELETEBUTTON "delete_button" +#define NOPBUTTON "nop_button" + + SleepViewEventListener::SleepViewEventListener() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SleepViewEventListener::SleepViewEventListener"); + } + + SleepViewEventListener::~SleepViewEventListener() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SleepViewEventListener::~SleepViewEventListener"); + } + + SleepViewEventListener &SleepViewEventListener::GetInstance() + { + static SleepViewEventListener instance; + return instance; + } + bool SleepViewEventListener::OnRelease(UIView &view, const ReleaseEvent &event) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SleepViewEventListener::OnRelease"); + UNUSED(event); + if (strcmp(view.GetViewId(), DELETEBUTTON) == 0) + { + NotificationManager::GetInstance()->StopNotify(); + } + return true; + } + bool SleepViewEventListener::OnDrag(UIView &view, const DragEvent &event) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SleepViewEventListener::OnDrag"); + UNUSED(view); + return true; + } + + bool SleepViewEventListener::OnDragEnd(UIView &view, const DragEvent &event) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SleepViewEventListener::OnDragEnd"); + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) + { + NotificationManager::GetInstance()->StopNotify(); + } + return true; + } + + /*创建信息弹窗*/ + UIViewGroup *CreateSleepNotifyView(void) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateSleepNotifyView"); + SleepGroupView = new UIViewGroup(); + if (SleepGroupView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateSleepNotifyView] SleepGroupView new fail!!"); + return nullptr; + } + SleepGroupView->SetPosition(0, 0, 466, 466); + SleepGroupView->SetViewId("sleepnotify"); + SleepGroupView->SetTouchable(true); + SleepGroupView->SetDraggable(true); + UIView::OnDragListener *dragListener = static_cast(&SleepViewEventListener::GetInstance()); + if (dragListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateSleepNotifyView] dragListener new fail!!"); + return nullptr; + } + SleepGroupView->SetOnDragListener(dragListener); + /*获取最新sleep*/ + SLEEPSTATE sleepsate = SleepModel::GetInstance().get_sleep_state(); + UIResourceTextId textId = STR_MORNNING; + switch (sleepsate) + { + case SLEEPSTATE::SLEEPNOTIFY: + titleStr = SleepModel::GetInstance().get_notifiy(); + textId = STR_DISTURB; // 即将开启勿扰 + break; + case SLEEPSTATE::SLEPP: + titleStr = SleepModel::GetInstance().get_sleep_notifiy(); + textId = STR_DISTURBNOTE; // 开启勿扰 + ConfigModel::GetInstance()->SetDnotdisturb(true); + break; + case SLEEPSTATE::WALK: + titleStr = SleepModel::GetInstance().get_walk_notifiy(); + textId = STR_MORNNING; + ConfigModel::GetInstance()->SetDnotdisturb(false); // 关闭勿扰 + SetAlarmClockView(); // 设置为早安视图 + return SleepGroupView; + break; + default: + break; + } + + /*初始化label*/ + /* -------------------------------------------------------------------------- */ + sleeptitle = new UILabel(); + if (sleeptitle == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sleeptitle:: new UILabel fail"); + return nullptr; // 内存分配失败,返回 + } + sleeptitle->SetPosition(83, 60, 300, 35); + sleeptitle->SetText(titleStr.c_str()); + sleeptitle->SetStyle(STYLE_TEXT_FONT, 30); + sleeptitle->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); + sleeptitle->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + sleeptitle->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); + sleeptitle->SetVisible(true); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sleeptitle is ok!"); + /* -------------------------------------------------------------------------- */ + /*初始化图片*/ + InitImageView(sleepicon, 193, 130, 80, 80, "image", PNG_APPLIST_SLEEP_IMAGE); + sleepicon->SetResizeMode(UIImageView::ImageResizeMode::SCALE_DOWN); + /* -------------------------------------------------------------------------- */ + /*初始化消息内容*/ + sleepnotifylabel = new UILabelExt(); + if (sleepnotifylabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sleepnotifylabel:: new UILabel fail"); + return nullptr; // 内存分配失败,返回 + } + sleepnotifylabel->SetPosition(53, 220, 360, 144); + sleepnotifylabel->SetViewId("sleepnotifylabel"); + sleepnotifylabel->SetTextId(textId); + sleepnotifylabel->SetTextColor(Color::Gray()); + sleepnotifylabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + sleepnotifylabel->SetLineBreakMode(UILabel::LINE_BREAK_CLIP); // 换行裁剪 + sleepnotifylabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); // 居中显示 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sleepnotifylabel is ok"); + + /*加载清除按键*/ + InitButtonExt(sleepbutton, 0, 366, 466, 100, DELETEBUTTON, STR_KONW, 30); + const char *buttonImgSrc = "/user/res/466x100button.bin"; + sleepbutton->SetImageSrc(buttonImgSrc, buttonImgSrc); + UIView::OnTouchListener *TouchListener = static_cast(&SleepViewEventListener::GetInstance()); + if (TouchListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CreateSleepView] TouchListener new fail!!"); + return nullptr; + } + sleepbutton->SetOnTouchListener(TouchListener); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sleepbutton"); + /* -------------------------------------------------------------------------- */ + SleepGroupView->Add(sleeptitle); + SleepGroupView->Add(sleepicon); + SleepGroupView->Add(sleepnotifylabel); + SleepGroupView->Add(sleepbutton); + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Create SleepGroupView succeed!!"); + custom_VibratorFunc(VibratorType::VIBRATOR_TYPE_TWO); // 震动提醒 + return SleepGroupView; + } + void SetAlarmClockView() + { + /*初始化图片*/ + InitImageView(backimage, 0, 0, 466, 466, "image", PNG_SLEEP_BACK_IMAGE); + InitImageView(sunnyicon, 153, 95, 160, 160, "image", PNG_SLEEP_SUUNY_IMAGE); + InitImageView(alarmicon, 149, 260, 29, 29, "image", PNG_SLEEP_ALARM_IMAGE); + /*初始化固定label*/ + InitLabelExt(alarmtitle, 83, 50, 300, 35, "labletitle", STR_MORNNING, DEFAULT_VECTOR_FONT_FILENAME, 30); + InitLabelExt(nowlabel, 110, 243, 200, 60, "labletitle", STR_NOW, DEFAULT_VECTOR_FONT_FILENAME, 30); + /*获取起床时间labe*/ + std::string walkStr = SleepModel::GetInstance().get_walk_notifiy(); + InitLabel(walklabel, 190, 245, 200, 60, "labletitle", walkStr.c_str(), DEFAULT_VECTOR_FONT_FILENAME, 30); + /*设置按键*/ + InitButtonExt(nopbutton, 58, 320, 170, 90, NOPBUTTON, STR_NAP, 30); + nopbutton->SetOnTouchListener(static_cast(&SleepViewEventListener::GetInstance())); + nopbutton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c); + nopbutton->SetStyle(STYLE_BORDER_RADIUS, 100); + + InitButtonExt(closebutton, 238, 320, 170, 90, DELETEBUTTON, STR_CLOSE, 30); + closebutton->SetOnTouchListener(static_cast(&SleepViewEventListener::GetInstance())); + closebutton->SetStyle(STYLE_BORDER_RADIUS, 100); + + /* -------------------------------------------------------------------------- */ + SleepGroupView->Add(backimage); + SleepGroupView->Add(sunnyicon); + SleepGroupView->Add(alarmicon); + SleepGroupView->Add(nowlabel); + SleepGroupView->Add(walklabel); + SleepGroupView->Add(nopbutton); + SleepGroupView->Add(closebutton); + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Create SleepGroupView succeed!!"); + custom_VibratorFunc(VibratorType::VIBRATOR_TYPE_TWO); // 震动提醒 + } + /*释放消息弹窗视图*/ + void FreeSleepView(void) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FreeSleepView(void)"); + if (SleepGroupView != nullptr) + { + SleepGroupView->RemoveAll(); + + delete sleeptitle; + sleeptitle = nullptr; + + delete sleepicon; + sleepicon = nullptr; + + delete sleepnotifylabel; + sleepnotifylabel = nullptr; + + delete sleepbutton; + sleepbutton = nullptr; + + delete alarmtitle; + alarmtitle = nullptr; + + delete backimage; + backimage = nullptr; + + delete sunnyicon; + sunnyicon = nullptr; + + delete alarmicon; + alarmicon = nullptr; + + delete nowlabel; + nowlabel = nullptr; + + delete walklabel; + walklabel = nullptr; + + delete closebutton; + closebutton = nullptr; + + delete nopbutton; + nopbutton = nullptr; + + RootView::GetInstance()->Remove(SleepGroupView); + delete SleepGroupView; + SleepGroupView = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Free SleepView succeed!!"); + } + return; + } +} \ No newline at end of file diff --git a/code/sdk/bootloader/flashboot/brandy/main.c b/code/sdk/bootloader/flashboot/brandy/main.c index 3a6c4dcea..ff509faac 100755 --- a/code/sdk/bootloader/flashboot/brandy/main.c +++ b/code/sdk/bootloader/flashboot/brandy/main.c @@ -408,7 +408,7 @@ static bool upg_need_upgrade(fota_upgrade_flag_area_t *upg_flag_info) if ((errcode_t)uapi_flash_exit_from_xip_mode(0) != ERRCODE_SUCC) { goto end; } - if (flash_info.flash_id == FLASH_MANUFACTURER_PUYA_P25Q64SL) { + if (flash_info.flash_id == FLASH_MANUFACTURER_PUYA_P25Q64SL || flash_info.flash_id == FLASH_MANUFACTURER_PUYA_PY25Q128LA) { real_read = uapi_flash_read_data_without_align(0, fota_address, (uint8_t *)(upg_flag_info), sizeof(fota_upgrade_flag_area_t)); } else { diff --git a/code/sdk/bootloader/flashboot/brandy/nandflash/include/nandflash_ds35x1g.h b/code/sdk/bootloader/flashboot/brandy/nandflash/include/nandflash_ds35x1g.h index 8a37759b0..75956dbb4 100755 --- a/code/sdk/bootloader/flashboot/brandy/nandflash/include/nandflash_ds35x1g.h +++ b/code/sdk/bootloader/flashboot/brandy/nandflash/include/nandflash_ds35x1g.h @@ -1,3 +1,13 @@ +/* + * @Author: penglei 1624952103@qq.com + * @Date: 2024-06-29 17:26:01 + * @LastEditors: penglei 1624952103@qq.com + * @LastEditTime: 2024-07-02 16:41:57 + * @FilePath: /FD230/code/sdk/bootloader/flashboot/brandy/nandflash/include/nandflash_ds35x1g.h + * @Description: + * + * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. + */ /* * Copyright (c) @CompanyNameMagicTag 2018-2020. All rights reserved. * Description: NON-OS NANDFLASH DRIVER @@ -12,7 +22,7 @@ #define DS35X1G_BYTES_PER_OOB 64 #define DS35X1G_PAGES_PER_BLOCK 64 #define DS35X1G_TOTAL_BLOCKS 1024 -#define DS35X1G_CHIP_ID 0xE521 +#define DS35X1G_CHIP_ID 0xE521//0xE521,6161 id 没有check #define DS35X1G_OOB_TOTAL_LEN 4 #define DS35X1G_OOB_PER_SIZE 8 #define DS35X1G_OOB_1_OFFSET 0 diff --git a/code/sdk/build/config/target_config/brandy/build_brandy_update.py b/code/sdk/build/config/target_config/brandy/build_brandy_update.py index 55388e64e..26c4ccc58 100755 --- a/code/sdk/build/config/target_config/brandy/build_brandy_update.py +++ b/code/sdk/build/config/target_config/brandy/build_brandy_update.py @@ -109,6 +109,7 @@ def get_new_image(info): # 要升级的image列表,需根据升级的实际情况进行增删 image_list = [] if os.path.exists(os.path.join(info.root_path,"output","ota_all")) : + print( os.path.join(info.root_path,"output","ota_all")+" exist ") image_list.append("=".join([info.ssb_bin, "ssb"])) image_list.append("=".join([info.recovery_bin, "recovery"])) image_list.append("=".join([info.app_bin, "application"])) @@ -116,7 +117,11 @@ def get_new_image(info): image_list.append("=".join([info.dsp_main_bin, "dsp_main"])) image_list.append("=".join([info.dsp_overlay_bin, "dsp_overlay"])) image_list.append("=".join([info.nv_bin, "nv"])) + elif os.path.exists(os.path.join(info.root_path,"output","res_only")) : + print( os.path.join(info.root_path,"output","res_only")+" exist ") + print("update resource only") else: + print( "ota_all or res_only not exist in folder "+os.path.join(info.root_path,"output")+",application only!") image_list.append("=".join([info.app_bin, "application"])) if os.path.exists(info.res_dir) : @@ -157,8 +162,10 @@ def get_old_image(info): image_list.append("=".join([info.bt_old_bin, "bt"])) image_list.append("=".join([info.dsp_main_old_bin, "dsp_main"])) image_list.append("=".join([info.dsp_overlay_old_bin, "dsp_overlay"])) + elif os.path.exists(os.path.join(info.root_path,"output","res_only")) : + print("update resource only") else: - print( os.path.join(info.root_path,"output","ota_all")+" not exist ") + print( " ota_all or res_only not exist in folder "+os.path.join(info.root_path,"output")+",application only!") image_list.append("=".join([info.app_old_bin, "application"])) # image_list.append("=".join([info.app_old_sign, "application_sign"])) # image_list.append("=".join([info.bt_old_sign, "bt_sign"])) diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Sleep/alarmicon.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Sleep/alarmicon.bin new file mode 100644 index 000000000..79d1ccae1 --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Sleep/alarmicon.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a69a4de1b30054eaf54864f8e8cd63ccb22149252ce50dc9ead369b6dd97aa14 +size 664 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Sleep/goodmorning.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Sleep/goodmorning.bin new file mode 100644 index 000000000..a7be2ae9f --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Sleep/goodmorning.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b010e39f71b93cd8b2d0341e0fed8ecdb098481384e574d199ff88557a5084fe +size 146040 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Sleep/sunny.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Sleep/sunny.bin new file mode 100644 index 000000000..3f4034e9b --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Sleep/sunny.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3a5a92b58e1e19d6430fae58dd7d4497b441ef72903038f9563152dd94e0a25d +size 17304 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_BLUETOOTH.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_BLUETOOTH.bin new file mode 100644 index 000000000..f85034587 --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_BLUETOOTH.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6db591e3eb1bb54b9010e4c57c5b0f40d28a1290e95f28a9c0920ba7369e0171 +size 792 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_BLUETOOTHCONNECTED.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_BLUETOOTHCONNECTED.bin new file mode 100644 index 000000000..1e71c6442 --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_BLUETOOTHCONNECTED.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b21cd7b0da5006062af8f7efe3e791ee290322f31cde7581eed65bcc9ebf9df7 +size 2424 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_BLUETOOTHDISCONNECTED.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_BLUETOOTHDISCONNECTED.bin new file mode 100644 index 000000000..f6c06917e --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_BLUETOOTHDISCONNECTED.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:78a4a48c22d14d85354d1fe4d84b0c13244c47d9b1f5858227b63403fbad404d +size 2424 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_DNOTDISTURB.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_DNOTDISTURB.bin new file mode 100644 index 000000000..776256e8e --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_DNOTDISTURB.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:50053d273b582b274ff2e748de6940cc52312ee25adff7bf2bbd2a9e9e27960f +size 1560 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_EARPHONESCONNECTED.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_EARPHONESCONNECTED.bin new file mode 100644 index 000000000..4d3430d5c --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_EARPHONESCONNECTED.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:34a4e1b063eda3fcb6ca9c2e223173e4550620182ecec675ddf8b4971bb6b1af +size 2424 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_EARPHONESDISCONNECTED.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_EARPHONESDISCONNECTED.bin new file mode 100644 index 000000000..5e3af0c6c --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_EARPHONESDISCONNECTED.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9fce27e93e1538cccc7da3120837858f59f48a9df2cedfc07992cacff34ae507 +size 2424 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_FINDPHONE.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_FINDPHONE.bin new file mode 100644 index 000000000..7343389b7 --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_FINDPHONE.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5be34fcd358e742d3a3cab6986d844cb5ccfc33f9c422b7c0ff22f35d63c3ea0 +size 1560 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_LINE.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_LINE.bin new file mode 100644 index 000000000..0704bbcdf --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_LINE.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:492d2eb4af52cf3ef0ddb43cb09a8af13629ec7d5b8d5f723358771f3441e65c +size 472 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_NOSIGNAL.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_NOSIGNAL.bin new file mode 100644 index 000000000..33ed4e860 --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_NOSIGNAL.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:905a252082ea4a712d68b34df64ce107350ba8def9e77b31e93d468d0cd6fe63 +size 984 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_PHONECONNECTED.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_PHONECONNECTED.bin new file mode 100644 index 000000000..ef27e321c --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_PHONECONNECTED.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:52855c1d10dc754e635bc180a5ea72459697a83de535633b6fafd5bc8be26836 +size 2424 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_PHONEDISCONNECTED.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_PHONEDISCONNECTED.bin new file mode 100644 index 000000000..85a601ff2 --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_PHONEDISCONNECTED.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:923ae93925394df078d1451f332acf9e74c49a23f881ae222c30b790d217fe24 +size 2424 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_SAVEPOWER.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_SAVEPOWER.bin new file mode 100644 index 000000000..c403103de --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_SAVEPOWER.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:08218c18c5b6abb4d2427c0e9694e0d97f0046f30ce7f7f3e291f322bc10542d +size 1560 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_SETTING.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_SETTING.bin new file mode 100644 index 000000000..cbd0a861f --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/dropdown/DROPDOWN_SETTING.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:167523518e00aceaa0522319bbb7320b209c46a822635ddf99a1ac1041b967a1 +size 1560 diff --git a/code/sdk/drivers/drivers/driver/nand_flash/nand/include/nandflash_ds35x1g.h b/code/sdk/drivers/drivers/driver/nand_flash/nand/include/nandflash_ds35x1g.h index f7e0dfcd5..2b5c20fc7 100755 --- a/code/sdk/drivers/drivers/driver/nand_flash/nand/include/nandflash_ds35x1g.h +++ b/code/sdk/drivers/drivers/driver/nand_flash/nand/include/nandflash_ds35x1g.h @@ -1,3 +1,13 @@ +/* + * @Author: penglei 1624952103@qq.com + * @Date: 2024-06-07 11:18:26 + * @LastEditors: penglei 1624952103@qq.com + * @LastEditTime: 2024-07-02 16:42:22 + * @FilePath: /FD230/code/sdk/drivers/drivers/driver/nand_flash/nand/include/nandflash_ds35x1g.h + * @Description: + * + * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. + */ /* * Copyright (c) @CompanyNameMagicTag 2018-2020. All rights reserved. * Description: NON-OS NANDFLASH DRIVER @@ -12,7 +22,7 @@ #define DS35X1G_BYTES_PER_OOB 64 #define DS35X1G_PAGES_PER_BLOCK 64 #define DS35X1G_TOTAL_BLOCKS 1024 -#define DS35X1G_CHIP_ID 0xE521 +#define DS35X1G_CHIP_ID 0xE521//0xE521,6161 id 没有check #define DS35X1G_OOB_TOTAL_LEN 4 #define DS35X1G_OOB_PER_SIZE 8 #define DS35X1G_OOB_1_OFFSET 0 diff --git a/code/sdk/drivers/peripheral/config/include/ConfigModelC.h b/code/sdk/drivers/peripheral/config/include/ConfigModelC.h index 8a5a2ef68..dbcd21222 100644 --- a/code/sdk/drivers/peripheral/config/include/ConfigModelC.h +++ b/code/sdk/drivers/peripheral/config/include/ConfigModelC.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-17 09:32:03 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2024-06-21 20:17:12 + * @LastEditTime: 2024-06-28 18:27:45 * @FilePath: /FD230/code/sdk/drivers/peripheral/config/include/ConfigModelC.h */ #ifndef _CONFIG_MODEL_C_H_ @@ -95,6 +95,12 @@ uint8_t cm_get_vibmod(void); //cywee 获取用户信息 void get_user_info_from_config_model(int user_info[5]); +int get_sleep_time_from_config_model(void); +int get_wake_up_time_from_config_model(void); + +//设置睡眠频率 +void set_config_heart(int heartRateDetectionFreq); + #ifdef __cplusplus #if __cplusplus } diff --git a/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp b/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp index ba11493f7..ace4e6b72 100644 --- a/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp +++ b/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp @@ -1445,6 +1445,26 @@ 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; + wake_up_time = OHOS::ConfigModel::GetInstance()->get_configData_int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SLEEP_GET_UP); + return wake_up_time; +} +void set_config_heart(int heartRateDetectionFreq) +{ + // 设置心率检测频率 + OHOS::ConfigModel::GetInstance()->set_condigData_Int(OHOS::ConfigModel::CONFIGMODEL_ITEM_HEARTRATE_DETECTED, heartRateDetectionFreq); +} #ifdef __cplusplus #if __cplusplus } diff --git a/code/sdk/drivers/peripheral/cywee/Inc/cywee_service.h b/code/sdk/drivers/peripheral/cywee/Inc/cywee_service.h index b6c303e24..121a9736a 100644 --- a/code/sdk/drivers/peripheral/cywee/Inc/cywee_service.h +++ b/code/sdk/drivers/peripheral/cywee/Inc/cywee_service.h @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: 2024-03-26 20:29:58 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2024-06-22 15:03:56 + * @LastEditTime: 2024-06-28 18:00:01 * @FilePath: /FD230/code/sdk/drivers/peripheral/cywee/Inc/cywee_service.h * @Description: * @@ -61,7 +61,8 @@ extern "C" { #define CYWEE_SERVICE_CMD_HRS_WEARSTATUS_CHANGE 0x21 #define CYWEE_SERVICE_CMD_SEDENTARY_MODE 0x22 -#define CYWEE_SERVICE_CMD_NAP_MODE 0x23 +#define CYWEE_SERVICE_CMD_NAP_MODE 0x32 +#define CYWEE_SERVICE_CMD_NAP_SEDENTARY_MODE 0x23 #define CYWEE_SERVICE_CMD_SLEEPING_MODE 0x24 #define CYWEE_SERVICE_CMD_OPEN_HAND_UPDOWN 0x25 diff --git a/code/sdk/drivers/peripheral/cywee/service/cywee_service.c b/code/sdk/drivers/peripheral/cywee/service/cywee_service.c index 0c117f868..0d8b92707 100644 --- a/code/sdk/drivers/peripheral/cywee/service/cywee_service.c +++ b/code/sdk/drivers/peripheral/cywee/service/cywee_service.c @@ -341,8 +341,11 @@ static void cywee_service_check_task(void const *arg) case CYWEE_SERVICE_CMD_NAP_MODE: cywee_inactivity_mode_change(INACTIVITY_MODE_NAP); + + case CYWEE_SERVICE_CMD_NAP_SEDENTARY_MODE: + cywee_inactivity_mode_change(INACTIVITY_MODE_SEDENTARY_AND_NAP); break; - + case CYWEE_SERVICE_CMD_SLEEPING_MODE: cywee_inactivity_mode_change(INACTIVITY_MODE_SLEEPING); break; diff --git a/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c b/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c index 5acf5a5cd..3b337282f 100644 --- a/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c +++ b/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c @@ -263,10 +263,10 @@ int CWM_OS_dbgPrintf(const char * format,...) return 0; } typedef enum { - CYWEE_SAVE_DATA_STEP, - CYWEE_SAVE_DATA_DISTANCE, - CYWEE_SAVE_DATA_CALORIES, - CYWEE_SAVE_DATA_FAT, + CYWEE_DATA_STEP, + CYWEE_DATA_DISTANCE, + CYWEE_DATA_CALORIES, + CYWEE_DATA_FAT, } CYWEE_SAVE_DATA_TYPE; #define CWM_STEP_DATA_PATH "/user/userdata/sport/stepcount.bin" @@ -290,16 +290,16 @@ void CWM_OS_saveData(int* data, uint32_t len,uint8_t type){ FILE * fp=NULL; switch (type) { - case CYWEE_SAVE_DATA_CALORIES: + case CYWEE_DATA_CALORIES: fp = fopen(CWM_CALORIES_DATA_PATH,"wb"); break; - case CYWEE_SAVE_DATA_STEP: + case CYWEE_DATA_STEP: fp = fopen(CWM_STEP_DATA_PATH,"wb"); break; - case CYWEE_SAVE_DATA_DISTANCE: + case CYWEE_DATA_DISTANCE: fp = fopen(CWM_DISTANCE_DATA_PATH,"wb"); break; - case CYWEE_SAVE_DATA_FAT: + case CYWEE_DATA_FAT: fp = fopen(CWM_FAT_DATA_PATH,"wb"); break; @@ -354,16 +354,16 @@ void CWM_OS_saveData_history(int* new_data,int *history ,uint32_t len,uint8_t ty switch (type) { - case CYWEE_SAVE_DATA_CALORIES: + case CYWEE_DATA_CALORIES: sprintf_s(path_,64,"%s%s.bin",CWM_HISTORY_DATA_CALORIES_PATH,timeday); break; - case CYWEE_SAVE_DATA_STEP: + case CYWEE_DATA_STEP: sprintf_s(path_,64,"%s%s.bin",CWM_HISTORY_DATA_PATH,timeday); break; - case CYWEE_SAVE_DATA_DISTANCE: + case CYWEE_DATA_DISTANCE: sprintf_s(path_,64,"%s%s.bin",CWM_HISTORY_DATA_DISTANCE_PATH,timeday); break; - case CYWEE_SAVE_DATA_FAT: + case CYWEE_DATA_FAT: sprintf_s(path_,64,"%s%s.bin",CWM_HISTORY_DATA_FAT_PATH,timeday); break; @@ -373,15 +373,15 @@ void CWM_OS_saveData_history(int* new_data,int *history ,uint32_t len,uint8_t ty CWM_OS_dbgPrintf(" save path %s \n",path_); - int data= *new_data-*history;//新数据减去旧数据,作为这一个小时的步数值 - if(data<=0) - { - data=0; - *history=0; - CWM_OS_dbgPrintf("异常 清除步数数据\n"); - return; + // int data= *new_data-*history;//新数据减去旧数据,作为这一个小时的步数值 + // if(data<=0) + // { + // data=0; + // *history=0; + // CWM_OS_dbgPrintf("异常 清除步数数据\n"); + // return; - } + // } FILE * fp = fopen(path_,"ab+"); if(fp==NULL) @@ -401,14 +401,14 @@ void CWM_OS_saveData_history(int* new_data,int *history ,uint32_t len,uint8_t ty } - ret =fwrite(&data,1,len,fp); + ret =fwrite(new_data,1,len,fp); if(ret==0) { CWM_OS_dbgPrintf("fwrite failed %d\n",ret); } - CWM_OS_dbgPrintf("fwrite data %d\n",data); + CWM_OS_dbgPrintf("fwrite data %d\n",*new_data); - *history=*new_data; + //*history=*new_data; fclose(fp); } @@ -476,16 +476,16 @@ void CWM_OS_restoreData(int* data, uint32_t len,uint8_t type){ FILE * fp=NULL; switch (type) { - case CYWEE_SAVE_DATA_CALORIES: + case CYWEE_DATA_CALORIES: fp = fopen(CWM_CALORIES_DATA_PATH,"rb"); break; - case CYWEE_SAVE_DATA_STEP: + case CYWEE_DATA_STEP: fp = fopen(CWM_STEP_DATA_PATH,"rb"); break; - case CYWEE_SAVE_DATA_DISTANCE: + case CYWEE_DATA_DISTANCE: fp = fopen(CWM_DISTANCE_DATA_PATH,"rb"); break; - case CYWEE_SAVE_DATA_FAT: + case CYWEE_DATA_FAT: fp = fopen(CWM_FAT_DATA_PATH,"rb"); break; default: diff --git a/code/sdk/drivers/peripheral/cywee/src/main_dml.c b/code/sdk/drivers/peripheral/cywee/src/main_dml.c index 1123001bc..de3bc37c6 100644 --- a/code/sdk/drivers/peripheral/cywee/src/main_dml.c +++ b/code/sdk/drivers/peripheral/cywee/src/main_dml.c @@ -138,7 +138,7 @@ void set_calories_data(uint32_t data) void set_distance_data(uint32_t data) { - new_fat++; + new_distance=data; } int get_distance_data(void ) @@ -148,7 +148,12 @@ int get_distance_data(void ) void set_fat_time_data(void) { - new_calories++; + new_fat++; +} + +int get_fat_time_data(void) +{ + return new_fat+history_fat; } @@ -164,17 +169,21 @@ void stand_history_save(void) void calories_history_save(void) { - CWM_OS_saveData_history(&new_calories,&history_calories_,sizeof(int),CYWEE_SAVE_DATA_CALORIES); + + int data= get_calories_data(); + CWM_OS_saveData_history(&data,&history_calories_,sizeof(int),CYWEE_SAVE_DATA_CALORIES); } void distances_history_save(void) { - CWM_OS_saveData_history(&new_distance,&history_calories_,sizeof(int),CYWEE_SAVE_DATA_DISTANCE); + int data= get_distance_data(); + CWM_OS_saveData_history(&data,&history_calories_,sizeof(int),CYWEE_SAVE_DATA_DISTANCE); } void fat_history_save(void) { - CWM_OS_saveData_history(&new_fat,&history_fat_,sizeof(int),CYWEE_SAVE_DATA_FAT); + int data= get_fat_time_data(); + CWM_OS_saveData_history(&data,&history_fat_,sizeof(int),CYWEE_SAVE_DATA_FAT); } void cywee_goal_history_save(void) @@ -251,7 +260,7 @@ void cywee_time_sync(void) struct tm* timeinfo; time(&rawtime); timeinfo = localtime(&rawtime); - CWM_OS_dbgPrintf("cywee_time_sync : year[%d], mon[%d], day[%d], hour[%d], min[%d], msc[%d] \r\n", + CWM_OS_dbgPrintf("cywee_time_sync : year[%d], mon[%d], day[%d], hour[%d], min[%d], sec[%d] \r\n", timeinfo->tm_year+1900,timeinfo->tm_mon+1,timeinfo->tm_mday, timeinfo->tm_hour,timeinfo->tm_min,timeinfo->tm_sec); diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c index da23b2020..6fbff27ca 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c @@ -381,24 +381,6 @@ bool hx3695_chip_check(void) return false; } -uint8_t hx3695_get_chip_id(void) -{ - uint8_t i = 0; - uint8_t chip_id = 0; - for(i=0; i<5; i++) - { - hx3695_ppg_on(); - chip_id = hx3695_read_reg(0x00); - - if (chip_id == 0x65) - { - return chip_id; - } - } - - return chip_id; -} - uint8_t hx3695_read_fifo_size(void) { uint8_t data_len_h,data_len_l; diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.h b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.h index 326b3997b..8eb2b292d 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.h +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.h @@ -297,9 +297,6 @@ void heart_rate_meas_timeout_handler(void * p_context); void wear_mode_timeout_handler(void * p_context); void Efuse_Mode_Check(void); -uint8_t hx3695_get_chip_id(void); - - #include "hx3695_hal.h" #endif diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.c b/code/sdk/drivers/peripheral/utils/custom_utils.c index 235d8789a..247fcee9d 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils.c @@ -28,6 +28,10 @@ #include "soundandvibration/include/SoundAndVibrationVolumeSettingC.h" #include "networkandcall/include/NetworkAndCallC.h" #include "producttest/include/testmicrophoneC.h" +#include "producttest/include/testLCDC.h" +#include "producttest/include/testTPC.h" +#include "system/include/SystemPresenterC.h" +#include "producttest/include/testPresenterC.h" #endif #include #include @@ -790,11 +794,12 @@ errcode_t uapi_get_yyyymmddhhmmss_Date(char *date) /** * @param {uint32_t} time 时间戳 * @param {char} *p_time 字符串 - * @param {bool} *include_seconds 是否包含秒 - * @param {char} 隔断符 + * @param {bool} include_seconds 是否包含秒 + * @param {bool} include_year 是否包含年份 + * * @param {char} 隔断符 * @brief 通过时间戳获取日期 */ -errcode_t uapi_get_TIME_STR(uint32_t time,char *p_time, char separator, bool include_seconds) +errcode_t uapi_get_TIME_STR(uint32_t time, char *p_time, char separator, bool include_seconds, bool include_year) { if (p_time == NULL) { @@ -812,18 +817,35 @@ errcode_t uapi_get_TIME_STR(uint32_t time,char *p_time, char separator, bool inc // 根据需要格式化日期时间字符串,包括时分秒和分隔符 if (include_seconds) { - sprintf(p_time, "%04d%c%02d%c%02d %02d%c%02d", timeinfo->tm_year + 1900, separator, timeinfo->tm_mon + 1, separator, - timeinfo->tm_mday, timeinfo->tm_hour, separator, timeinfo->tm_min); + if (include_year) + { + sprintf(p_time, "%04d%c%02d%c%02d %02d%c%02d", timeinfo->tm_year + 1900, separator, timeinfo->tm_mon + 1, separator, + timeinfo->tm_mday, timeinfo->tm_hour, separator, timeinfo->tm_min); + } + else + { + sprintf(p_time, "%02d%c%02d %02d%c%02d", timeinfo->tm_mon + 1, separator, + timeinfo->tm_mday, timeinfo->tm_hour, separator, timeinfo->tm_min); + } } else { - sprintf(p_time, "%04d%c%02d%c%02d %02d%c%02d", timeinfo->tm_year + 1900, separator, timeinfo->tm_mon + 1, separator, - timeinfo->tm_mday, timeinfo->tm_hour, separator, timeinfo->tm_min); + if (include_year) + { + sprintf(p_time, "%04d%c%02d%c%02d %02d%c%02d", timeinfo->tm_year + 1900, separator, timeinfo->tm_mon + 1, separator, + timeinfo->tm_mday, timeinfo->tm_hour, separator, timeinfo->tm_min); + } + else + { + sprintf(p_time, "%02d%c%02d %02d%c%02d", timeinfo->tm_mon + 1, separator, + timeinfo->tm_mday, timeinfo->tm_hour, separator, timeinfo->tm_min); + } } return ERRCODE_SUCC; } + /** * @param {char} *p_time * @param {char} 隔断符 @@ -913,7 +935,23 @@ errcode_t uapi_get_HHMMSS_Time(char *p_time, char separator, bool include_second return ERRCODE_SUCC; } +/*打印时间戳*/ +void print_current_time(void) +{ + char current_time[9]; // 分配内存给current_time + if (uapi_get_HHMMSS_Time(current_time, ':', true) != ERRCODE_SUCC) + { + return; + } + printf("Current_time: %s\n", current_time); + uint32_t tm; + if(uapi_get_timestampe_ms(&tm) != ERRCODE_SUCC) + { + return; + } + printf("Current timestamp in milliseconds: %u\n", tm); +} const char *weekDays[] = {"星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"}; errcode_t uapi_get_WeekStr(char *p_week) { @@ -2216,6 +2254,48 @@ void uapi_check_spk(bool isopen) #endif } +void uapi_factorytest_set_lcd_color(int color) +{ + #ifdef FD230 + factorytest_set_LCD_color(color); + #endif +} + +void uapi_factorytest_enter_test_view(int cmd) +{ + #ifdef FD230 + factorytest_enter_test_view(cmd); + #endif +} + +void uapi_factorytest_enter_test_tp_view(void) +{ + #ifdef FD230 + factorytest_enter_test_tp_view(); + #endif +} + +void uapi_factorytest_enter_test_lcd_view(void) +{ + #ifdef FD230 + factorytest_enter_test_lcd_view(); + #endif +} + +void uapi_factorytest_hide_test_lcd_button(void) +{ + #ifdef FD230 + factorytest_hide_test_lcd_button(); + #endif +} + +void uapi_factorytest_hide_test_tp_button(void) +{ + #ifdef FD230 + factorytest_hide_test_tp_button(); + #endif +} + void uapi_efuse_test_write(uint8_t *data,uint32_t byte_number,uint8_t len) { uint8_t readdata[10] = {0}; @@ -2261,14 +2341,15 @@ errcode_t custom_i2c_test(void) uapi_ppg_get_id(&ppg_id); if(ppg_id != 0x65) return ERRCODE_FAIL; - + PRINT("ppg_id[%x] \n",ppg_id); mmc5603_getid(&mmc_id); if(mmc_id != 0X10) return ERRCODE_FAIL; - + PRINT("mmc_id[%x] \n",mmc_id); uapi_cywee_get_id(&cywee_id); if(cywee_id != 0X44) return ERRCODE_FAIL; + PRINT("cywee_id[%x] \n",cywee_id); return ERRCODE_SUCC; -} \ No newline at end of file +} diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.h b/code/sdk/drivers/peripheral/utils/custom_utils.h index 10b0903a2..9fbd97a54 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.h +++ b/code/sdk/drivers/peripheral/utils/custom_utils.h @@ -67,22 +67,21 @@ errcode_t uapi_set_time_from_cat1(char* cat1time); /**获取日期*/ errcode_t uapi_get_yyyymmddhhmmss_Date(char *date); - -/*获取日期*/ -errcode_t uapi_get_YYMMDD_Time(char *p_time, char separator); - /*获取日期扩展版*/ errcode_t uapi_get_YYMMDD_Time_extend(char *p_time, char separator,uint8_t day); - +/*获取日期*/ +errcode_t uapi_get_YYMMDD_Time(char *p_time, char separator); /*获取时间*/ errcode_t uapi_get_HHMMSS_Time(char *p_time, char separator, bool include_seconds); +/*打印时间戳*/ +void print_current_time(void); /*获取星期*/ errcode_t uapi_get_WeekStr(char *p_week); /*设置屏幕亮屏*/ void uapi_set_screen_on_api(void); /*通过时间戳解析时间字符串*/ -errcode_t uapi_get_TIME_STR(uint32_t time,char *p_time, char separator, bool include_seconds); +errcode_t uapi_get_TIME_STR(uint32_t time, char *p_time, char separator, bool include_seconds, bool include_year); char *uapi_get_local_yyyymmdd_date(void); @@ -205,6 +204,12 @@ void uapi_ppg_get_id(uint8_t *chip_id); void uapi_microhone_switch(bool isopen); void uapi_check_spk(bool isopen); +void uapi_factorytest_set_lcd_color(int color); +void uapi_factorytest_enter_test_view(int cmd); +void uapi_factorytest_enter_test_tp_view(void); +void uapi_factorytest_enter_test_lcd_view(void); +void uapi_factorytest_hide_test_lcd_button(void); +void uapi_factorytest_hide_test_tp_button(void); void uapi_efuse_test_write(uint8_t *data,uint32_t byte_number,uint8_t len); void uapi_efuse_test_read(uint32_t byte_number,uint8_t len); diff --git a/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c b/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c index 01f3818cc..03f5954a4 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c @@ -8,6 +8,7 @@ #include "debug_print.h" #include "custom_runtime.h" #include "lwip/altcp_tls.h" +#include "ConfigModelC.h" #define ARRAY_COUNT(array) (sizeof(array) / sizeof(array[0])) #define CUSTOM_UTILS_MAX_ARGC 8 @@ -690,6 +691,52 @@ static uint32_t custom_mem_debug(uint8_t *para, uint32_t paraLen, char *strCommo return ERRCODE_SUCC; } + /*恢复出厂设置*/ + static uint32_t custom_restore_factory_settings(uint8_t *para, uint32_t paraLen, char *strCommonCmd) + { + UNUSED(para); + UNUSED(paraLen); + UNUSED(strCommonCmd); + + // 执行恢复出厂设置的操作 + uapi_restore_factory_setting(); + + PRINT("Restoring Factory Settings...\n"); + return ERRCODE_SUCC; + } + +#if 1 + /*设置心率检测频率*/ + static uint32_t custom_set_heart(uint8_t *para, uint32_t paraLen, char *strCommonCmd) + { + UNUSED(strCommonCmd); + + uint8_t argv[CUSTOM_UTILS_MAX_ARGC][CUSTOM_UTILS_MAX_ARGV_LEN] = {0}; + uint32_t argc = 0; + + int ret = ConvertCmdToParam(para, paraLen, argv, &argc); + if (ret != CUSTOM_UTILS_SUCCESS) + { + PRINT("CUSTOM_UTILSTEST ATCMD Convert Command Failed\n"); + return ERRCODE_FAIL; + } + + if (argc != 1) + { + PRINT("CUSTOM_UTILSTEST power_test ATCMD Set Parameter Failed argc %d\r\n"); + return ERRCODE_FAIL; + } + int heartRateDetectionFreq = atol((char *)argv[0]); + + // 设置心率检测频率 + set_config_heart(heartRateDetectionFreq); + + PRINT("heartRateDetectionFreq is %d\n", heartRateDetectionFreq); + return ERRCODE_SUCC; + } +#endif + + static const at_cmd_table_t g_custom_utils_cmd[] = { { (char *)"AT^CUSTOM_SN", custom_utils_setsn, (char *)"123456789ABCDEF2345678" }, { (char *)"AT^CUSTOM_SN_REQ", custom_utils_getsn, (char *)" " }, @@ -740,7 +787,9 @@ static const at_cmd_table_t g_custom_utils_cmd[] = { { (char *)"AT^EFUSEWRITE", custom_uapi_efuse_test_write, (char *)" " }, { (char *)"AT^SCHEDDEBUG", custom_task_sched_debug, (char *)" " }, { (char *)"AT^MEMDEBUG", custom_mem_debug, (char *)" " }, - + + {(char *)"AT^RESTORE", custom_restore_factory_settings, (char *)" "}, + {(char *)"AT^SETHEART", custom_set_heart, (char *)" "}, }; diff --git a/code/sdk/include/driver/flash/flash_common_config.h b/code/sdk/include/driver/flash/flash_common_config.h index a9c5b9602..d541fa469 100755 --- a/code/sdk/include/driver/flash/flash_common_config.h +++ b/code/sdk/include/driver/flash/flash_common_config.h @@ -115,6 +115,8 @@ #define FLASH_MANUFACTURER_XTX_XT25Q64D 0x17600B #define FLASH_MANUFACTURER_XTX_XT25Q128D 0x18600B +#define FLASH_MANUFACTURER_PUYA_PY25Q128LA 0x186585 + #define FLASH_CMD_LEN_MAX 4 #define addr_unalign(Addr, Boundary) ((Addr) & ((Boundary) - 1)) @@ -180,6 +182,7 @@ typedef enum flash_support_manufacturer { FLASH_XTX_XT25Q128D, FLASH_PUYA_P25Q64SL, FLASH_MXIC_MX25U256, + FLASH_PUYA_PY25Q128LA, FLASH_MANUFACTURER_MAX } flash_support_manufacturer_t; diff --git a/code/sdk/include/driver/flash/flash_config_info.h b/code/sdk/include/driver/flash/flash_config_info.h index 157fb76e9..51b64218e 100755 --- a/code/sdk/include/driver/flash/flash_config_info.h +++ b/code/sdk/include/driver/flash/flash_config_info.h @@ -125,6 +125,10 @@ static const flash_device_parameter_t g_flash_device_parameter[FLASH_MANUFACTURE g_puya_p25q32lc_enter_qspi_mode_cmd, NULL, &g_puya_p25q32lc_config }, { FLASH_MANUFACTURER_MXIC_MX25U256, FLASH_SIZE_32MB, 0xA5, 0xAA, WAIT_CYCLES_4, 0x2B, 0xB0, 0x30, g_mxic_mx25uxx_enter_qspi_mode_cmd, NULL, &g_mxic_mx25uxx_config }, + // { FLASH_MANUFACTURER_PUYA_PY25Q128LA, FLASH_SIZE_16MB, 0x38, 0xFF, WAIT_CYCLES_6, 0x48, 0x75, 0x7A, + // g_puya_py25q128la_enter_qspi_mode_cmd, NULL, &g_puya_py25q128la_config }, + { FLASH_MANUFACTURER_PUYA_PY25Q128LA, FLASH_SIZE_16MB, 0x20, 0xFF, WAIT_CYCLES_4, 0x05, 0x75, 0x7A, + g_puya_py25q128la_enter_qspi_mode_cmd, NULL, &g_puya_py25q128la_config }, }; static const uint32_t g_xip_use_cmd_mode[] = { @@ -142,6 +146,7 @@ static const uint32_t g_xip_use_cmd_mode[] = { FLASH_MANUFACTURER_ELITE_EN25S32A, FLASH_MANUFACTURER_DOSILICON_DS25M4AB, FLASH_MANUFACTURER_PUYA_P25Q64SL, + FLASH_MANUFACTURER_PUYA_PY25Q128LA, }; static flash_cmd_exe_t g_winbond_w25qxx_set_qe_cmd[] = { @@ -204,6 +209,22 @@ static flash_cmd_exe_t g_xtx_xt25q128d_set_qe_cmd[] = { { FLASH_CMD_TYPE_END, HAL_SPI_FRAME_FORMAT_MAX_NUM, 0, { 0 } } }; +static flash_cmd_exe_t g_puya_py25q128la_set_qe_cmd[] = { + /* Check QE bit. */ + { FLASH_CMD_TYPE_CHECK, HAL_SPI_FRAME_FORMAT_STANDARD, 3, { FLASH_RDSR2_CMD, 0x1, 0x2 } }, + /* Write enable. */ + { FLASH_CMD_TYPE_CMD, HAL_SPI_FRAME_FORMAT_STANDARD, 1, { FLASH_WREN_CMD } }, + /* Write status register-2 to 0x2, set QE bit. */ + { FLASH_CMD_TYPE_CMD, HAL_SPI_FRAME_FORMAT_STANDARD, 2, { 0x31, 0x02 } }, + /* Waite config done. */ + { FLASH_CMD_TYPE_PROCESSING, HAL_SPI_FRAME_FORMAT_STANDARD, 3, { FLASH_RDSR1_CMD, 0, 0 } }, + /* Check QE bit. */ + { FLASH_CMD_TYPE_PROCESSING, HAL_SPI_FRAME_FORMAT_STANDARD, 3, { FLASH_RDSR2_CMD, 0x1, 0x2 } }, + /* End cmd, will not execute and need return. */ + { FLASH_CMD_TYPE_END, HAL_SPI_FRAME_FORMAT_MAX_NUM, 0, { 0 } } +}; + + static const flash_qe_config_t g_flash_need_set_qe[] = { {FLASH_MANUFACTURER_WINBOND_W25Q32, g_winbond_w25qxx_set_qe_cmd}, {FLASH_MANUFACTURER_WINBOND_W25Q64, g_winbond_w25qxx_set_qe_cmd}, @@ -214,6 +235,7 @@ static const flash_qe_config_t g_flash_need_set_qe[] = { {FLASH_MANUFACTURER_DOSILICON_DS25M4AB, g_winbond_w25qxx_set_qe_cmd}, {FLASH_MANUFACTURER_ELITE_EN25SX128A, g_winbond_en25sx128a_set_qe_cmd}, {FLASH_MANUFACTURER_XTX_XT25Q128D, g_xtx_xt25q128d_set_qe_cmd}, + {FLASH_MANUFACTURER_PUYA_PY25Q128LA, g_puya_py25q128la_set_qe_cmd} }; #define FLASH_WIP (bit(0)) diff --git a/code/sdk/include/driver/flash/flash_others_config.h b/code/sdk/include/driver/flash/flash_others_config.h index c6e19d0eb..a95513dab 100755 --- a/code/sdk/include/driver/flash/flash_others_config.h +++ b/code/sdk/include/driver/flash/flash_others_config.h @@ -141,6 +141,33 @@ static flash_cmd_exe_t g_xtx_xt25qxxd_enter_qspi_mode_cmd[] = { { FLASH_CMD_TYPE_END, HAL_SPI_FRAME_FORMAT_MAX_NUM, 0, { 0 } } }; +/* PUYA config. */ +/* PY25Q128LA PUYA flash config. */ +static flash_cmd_exe_t g_puya_py25q128la_enter_qspi_mode_cmd[] = { + // /* Write enable for Volatils status register. */ + // { FLASH_CMD_TYPE_CMD, HAL_SPI_FRAME_FORMAT_STANDARD, 1, { 0x50 } }, + // /* Write status register-2 to 0x2, enable QPI write bit. */ + // { FLASH_CMD_TYPE_CMD, HAL_SPI_FRAME_FORMAT_STANDARD, 2, { 0x01, 0x02 } }, + // /* Enable QPI. */ + // { FLASH_CMD_TYPE_CMD, HAL_SPI_FRAME_FORMAT_STANDARD, 1, { 0x38 } }, + // /* Set dummy 6, maxinum read freq 70MHZ. */ + // { FLASH_CMD_TYPE_CMD, HAL_SPI_FRAME_FORMAT_QUAD, 2, { 0xC0, 0x20} }, + // /* End cmd, will not execute and need return. */ + // { FLASH_CMD_TYPE_END, HAL_SPI_FRAME_FORMAT_MAX_NUM, 0, { 0 } } + /* Write enable for Volatils status register. */ + { FLASH_CMD_TYPE_CMD, HAL_SPI_FRAME_FORMAT_STANDARD, 1, { 0x50 } }, + /* Write status register-2 to 0x2, enable QPI write bit. */ + { FLASH_CMD_TYPE_CMD, HAL_SPI_FRAME_FORMAT_STANDARD, 2, { 0x31, 0x02 } }, + /* Waite config done. */ + { FLASH_CMD_TYPE_PROCESSING, HAL_SPI_FRAME_FORMAT_STANDARD, 3, { FLASH_RDSR1_CMD, 0, 0 } }, + /* Enable QPI. */ + { FLASH_CMD_TYPE_CMD, HAL_SPI_FRAME_FORMAT_STANDARD, 1, { 0x38 } }, + /* Set dummy 6, maxinum read freq 70MHZ. */ + { FLASH_CMD_TYPE_CMD, HAL_SPI_FRAME_FORMAT_QUAD, 2, { 0xC0, 0x20} }, + /* End cmd, will not execute and need return. */ + { FLASH_CMD_TYPE_END, HAL_SPI_FRAME_FORMAT_MAX_NUM, 0, { 0 } } +}; + /* OTHERS enter xip mode config. */ /* Micro config. */ /* MT25QU128 Micro flash config. */ @@ -248,6 +275,24 @@ static flash_qspi_xip_config_t g_xtx_xt25qxxd_config = { false, false, }; + +/* PUYA config. */ +/* PY25Q128LA PUYA flash config. */ +static flash_qspi_xip_config_t g_puya_py25q128la_config = { + /* The config that before enter XIP mode. */ + WAIT_CYCLES_6, + HAL_SPI_INST_LEN_8, + HAL_SPI_ADDR_LEN_24, + HAL_SPI_TRANS_TYPE_INST_Q_ADDR_Q, + /* The config that after enter XIP mode. */ + WAIT_CYCLES_6, + HAL_SPI_INST_LEN_8, + HAL_SPI_ADDR_LEN_24, + HAL_SPI_TRANS_TYPE_INST_Q_ADDR_Q, + /* XIP 32bit addr & wrap config. */ + false, + false, +}; /** * @} */ diff --git a/code/sdk/middleware/chips/brandy/nv/nv_porting/nv_flash.c b/code/sdk/middleware/chips/brandy/nv/nv_porting/nv_flash.c index 0a8d37d33..8b340840a 100644 --- a/code/sdk/middleware/chips/brandy/nv/nv_porting/nv_flash.c +++ b/code/sdk/middleware/chips/brandy/nv/nv_porting/nv_flash.c @@ -34,7 +34,7 @@ errcode_t kv_flash_read(const uint32_t flash_offset, const uint32_t size, uint8_ } uint32_t read_len = 0; - if (flash_info.flash_id == FLASH_MANUFACTURER_PUYA_P25Q64SL) { + if (flash_info.flash_id == FLASH_MANUFACTURER_PUYA_P25Q64SL || flash_info.flash_id == FLASH_MANUFACTURER_PUYA_PY25Q128LA) { read_len = uapi_flash_read_data_without_align(0, flash_offset, tmp_ram_data, size); } else { read_len = uapi_flash_read_data(0, flash_offset, tmp_ram_data, size); @@ -72,7 +72,7 @@ errcode_t kv_flash_write(const uint32_t flash_offset, uint32_t size, const uint8 goto end; } - if (flash_info.flash_id == FLASH_MANUFACTURER_PUYA_P25Q64SL) { + if (flash_info.flash_id == FLASH_MANUFACTURER_PUYA_P25Q64SL || flash_info.flash_id == FLASH_MANUFACTURER_PUYA_PY25Q128LA) { write_len = uapi_flash_write_data_without_align(0, flash_offset, ram_data, size); } else { write_len = uapi_flash_write_data(0, flash_offset, ram_data, size); diff --git a/code/sdk/middleware/chips/brandy/update/common/upg_common_porting.c b/code/sdk/middleware/chips/brandy/update/common/upg_common_porting.c index b414a90f0..a102468a4 100755 --- a/code/sdk/middleware/chips/brandy/update/common/upg_common_porting.c +++ b/code/sdk/middleware/chips/brandy/update/common/upg_common_porting.c @@ -228,7 +228,7 @@ errcode_t upg_flash_read(const uint32_t flash_offset, const uint32_t size, uint8 uint32_t tail_size = UPG_FLASH_PAGE_SIZE - (flash_offset + UPG_FLASH_PAGE_SIZE) % UPG_FLASH_PAGE_SIZE; if (tail_size < size) { /* 跨页时,按页读取 */ - if ((flash_info.flash_id == FLASH_MANUFACTURER_PUYA_P25Q64SL) && (flash_offset >= status_flag_offset) && + if ((flash_info.flash_id == FLASH_MANUFACTURER_PUYA_P25Q64SL || flash_info.flash_id == FLASH_MANUFACTURER_PUYA_PY25Q128LA) && (flash_offset >= status_flag_offset) && (flash_offset < status_flag_offset + status_flag_size)) { read_len = uapi_flash_read_data_without_align(0, flash_offset, ram_data, tail_size); } else { @@ -240,7 +240,7 @@ errcode_t upg_flash_read(const uint32_t flash_offset, const uint32_t size, uint8 } uint32_t remain_size = size - read_len; - if ((flash_info.flash_id == FLASH_MANUFACTURER_PUYA_P25Q64SL) && (flash_offset >= status_flag_offset) && + if ((flash_info.flash_id == FLASH_MANUFACTURER_PUYA_P25Q64SL || flash_info.flash_id == FLASH_MANUFACTURER_PUYA_PY25Q128LA) && (flash_offset >= status_flag_offset) && (flash_offset < status_flag_offset + status_flag_size)) { read_len = uapi_flash_read_data_without_align(0, flash_offset, ram_data + read_len, remain_size); } else { @@ -309,7 +309,7 @@ errcode_t upg_flash_write(const uint32_t flash_offset, uint32_t size, const uint } uint32_t write_len = 0; - if ((flash_info.flash_id == FLASH_MANUFACTURER_PUYA_P25Q64SL) && (flash_offset >= status_flag_offset) && + if ((flash_info.flash_id == FLASH_MANUFACTURER_PUYA_P25Q64SL || flash_info.flash_id == FLASH_MANUFACTURER_PUYA_PY25Q128LA) && (flash_offset >= status_flag_offset) && (flash_offset < status_flag_offset + status_flag_size)) { write_len = uapi_flash_write_data_without_align(0, flash_offset, ram_data, size); } else { @@ -320,7 +320,7 @@ errcode_t upg_flash_write(const uint32_t flash_offset, uint32_t size, const uint } uint32_t read_len = 0; - if ((flash_info.flash_id == FLASH_MANUFACTURER_PUYA_P25Q64SL) && (flash_offset >= status_flag_offset) && + if ((flash_info.flash_id == FLASH_MANUFACTURER_PUYA_P25Q64SL || flash_info.flash_id == FLASH_MANUFACTURER_PUYA_PY25Q128LA) && (flash_offset >= status_flag_offset) && (flash_offset < status_flag_offset + status_flag_size)) { read_len = uapi_flash_read_data_without_align(0, flash_offset, cmp_data, size); } else { diff --git a/code/sdk/middleware/utils/codeloader/private/codeloader_execute_command_flash_writing_commands.c b/code/sdk/middleware/utils/codeloader/private/codeloader_execute_command_flash_writing_commands.c index 9ab9b48a5..2d7f92deb 100755 --- a/code/sdk/middleware/utils/codeloader/private/codeloader_execute_command_flash_writing_commands.c +++ b/code/sdk/middleware/utils/codeloader/private/codeloader_execute_command_flash_writing_commands.c @@ -526,7 +526,7 @@ static void extract_flash_write(const uint8_t *input_buffer_to_write, uint32_t b { flash_info_t flash_info; uapi_flash_get_info(0, &flash_info); - if ((flash_info.flash_id == FLASH_MANUFACTURER_PUYA_P25Q64SL) && + if ((flash_info.flash_id == FLASH_MANUFACTURER_PUYA_P25Q64SL || flash_info.flash_id == FLASH_MANUFACTURER_PUYA_PY25Q128LA) && ((g_codeloader_flash_writing_commands_location >= NV_FLASH_REGION_START) && (g_codeloader_flash_writing_commands_location < (NV_FLASH_REGION_START + NV_FLASH_REGION_LENGTH)))) { uapi_flash_write_data_without_align(CHIP_FLASH_ID, @@ -873,7 +873,7 @@ int8_t codeloader_command_processor_set_bin_sha_data(const codeloader_rx_buffer_ /* puya flash do not verification */ flash_info_t flash_info; uapi_flash_get_info(0, &flash_info); - if ((flash_info.flash_id == FLASH_MANUFACTURER_PUYA_P25Q64SL) && + if ((flash_info.flash_id == FLASH_MANUFACTURER_PUYA_P25Q64SL || flash_info.flash_id == FLASH_MANUFACTURER_PUYA_PY25Q128LA) && ((g_codeloader_data_save_position.load_start_addr >= NV_FLASH_REGION_START) && (g_codeloader_data_save_position.load_length <= NV_FLASH_REGION_LENGTH))) { (void)uapi_flash_exit_from_xip_mode(0); diff --git a/tools/dial_converter_tool/instance/asteroid/asteroid.xml b/tools/dial_converter_tool/instance/asteroid/asteroid.xml index 32cef6199..5fbe3dc48 100644 --- a/tools/dial_converter_tool/instance/asteroid/asteroid.xml +++ b/tools/dial_converter_tool/instance/asteroid/asteroid.xml @@ -1,13 +1,13 @@ - + - + diff --git a/tools/dial_converter_tool/instance/asteroid/preview_asteroid.png b/tools/dial_converter_tool/instance/asteroid/preview_asteroid.png new file mode 100644 index 000000000..09d024ae3 Binary files /dev/null and b/tools/dial_converter_tool/instance/asteroid/preview_asteroid.png differ diff --git a/tools/dial_converter_tool/instance/satellite/preview_satellite.png b/tools/dial_converter_tool/instance/satellite/preview_satellite.png new file mode 100644 index 000000000..f98433943 Binary files /dev/null and b/tools/dial_converter_tool/instance/satellite/preview_satellite.png differ diff --git a/tools/dial_converter_tool/instance/satellite/satellite.xml b/tools/dial_converter_tool/instance/satellite/satellite.xml index 29a5439f8..3e48b8c26 100644 --- a/tools/dial_converter_tool/instance/satellite/satellite.xml +++ b/tools/dial_converter_tool/instance/satellite/satellite.xml @@ -1,13 +1,13 @@ - + - + diff --git a/tools/image_converter_tool/test/hert/Sleep/alarmicon.png b/tools/image_converter_tool/test/hert/Sleep/alarmicon.png new file mode 100644 index 000000000..7e1b66c95 Binary files /dev/null and b/tools/image_converter_tool/test/hert/Sleep/alarmicon.png differ diff --git a/tools/image_converter_tool/test/hert/Sleep/goodmorning.png b/tools/image_converter_tool/test/hert/Sleep/goodmorning.png new file mode 100644 index 000000000..dc0c487bd Binary files /dev/null and b/tools/image_converter_tool/test/hert/Sleep/goodmorning.png differ diff --git a/tools/image_converter_tool/test/hert/Sleep/sunny.png b/tools/image_converter_tool/test/hert/Sleep/sunny.png new file mode 100644 index 000000000..e4796222f Binary files /dev/null and b/tools/image_converter_tool/test/hert/Sleep/sunny.png differ