From: Caisking <3449750381@qq.com> Date: Mon, 19 Aug 2024 03:44:55 +0000 (+0800) Subject: 修改运动识别接口效果;需要测试 X-Git-Tag: release_V1.2.70_20241020_135402~635 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=refs%2Fchanges%2F724%2F1;p=mirrors%2FFD230.git 修改运动识别接口效果;需要测试 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h index 83ce2fe66..a1fa04387 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h @@ -1,11 +1,4 @@ -/*** - * @Author: Caisking 3449750381@qq.com - * @Date: 2024-03-20 15:35:57 - * @LastEditors: Caisking 3449750381@qq.com - * @LastEditTime: 2024-03-29 11:49:27 - * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h - * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE - */ + #ifndef Traing_MODEL_H #define Traing_MODEL_H @@ -259,15 +252,16 @@ namespace OHOS int GetCal(); /*获取运动卡路里*/ // 训练状态相关配置 - void SetEntryType(ENTEYTYPE type); /*设置进入训练方式*/ - ENTEYTYPE GetEntryType(); /*获取训练进入方式*/ - void SetSportOpenWay(bool way); /*设置运动开始方式*/ - void SetSportOpenState(bool state); /*设置运动是否开始*/ - bool GetSportOpenState(); /*获取运动是否开始*/ - bool GetMomentum(); /*获取训练量是否达标*/ - void SetSportState(ExerciseState state); /*设置运动状态*/ - ExerciseState GetSportState(); /*获取运动状态*/ - void ResetSharedTrainingData(); /*重新初始化训练配置*/ + void SetEntryType(ENTEYTYPE type); /*设置进入训练方式*/ + ENTEYTYPE GetEntryType(); /*获取训练进入方式*/ + void SetSportOpenWay(bool way); /*设置运动开始方式*/ + void SetSportOpenState(bool state); /*设置运动是否开始*/ + bool GetSportOpenState(); /*获取运动是否开始*/ + bool GetMomentum(); /*获取训练量是否达标*/ + void SetSportState(ExerciseState state); /*设置运动状态*/ + ExerciseState GetSportState(); /*获取运动状态*/ + void ResetSharedTrainingData(); /*重新初始化训练配置*/ + void set_sport_config(UIResourceTextId id); // 运动识别进入运动 // 训练时间相关配置 std::string AnalysisTimestamp(uint64_t timestamp); /*解析时间戳*/ diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp index b7ecf8a0f..b295f2153 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp @@ -64,6 +64,8 @@ #define HIGH_INTENSITY_LOWER_THRESHOLD 70 #define HIGH_INTENSITY_UPPER_THRESHOLD 79 +#define MAXSPORTID 176 + extern "C" errcode_t uapi_get_timestampe_ms(uint32_t *tm); #ifdef __cplusplus @@ -1257,6 +1259,26 @@ namespace OHOS sendtraningdata(&data); // 发送数据函数 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SendLiveData Stop!"); } + /* -------------------------------- 运动识别发起处理 -------------------------------- */ + void TraingModel::set_sport_config(UIResourceTextId id) + { + if (id >= MAXSPORTID) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "id is error"); + return; + } + // 开始训练 ->不返回 + NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGCRAD); + // 配置运动项 + SetSportEvent(id); + // 获取运动项目 + ExerciseClass type = GetSportId(); + // 开启对应的运动 + TraingCardPresenter::GetInstance()->OpenSensor(type); + // 设置为手表开启运动 + SetSportOpenWay(false); + } + /* -------------------------------------------------------------------------- */ #if TIMER /* 时间显示 */ diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingCardPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingCardPresenter.h index 9ee46abe6..f6b3ca384 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingCardPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingCardPresenter.h @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-04-15 10:55:58 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-08-19 10:55:50 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingCardPresenter.h + */ /*** * @Author: Caisking 3449750381@qq.com * @Date: 2024-03-19 17:37:18 @@ -55,8 +61,6 @@ namespace OHOS /*蓝牙开启运动*/ bool send_sport_cmd(training_ble *cmd); - /*运动识别开启运动*/ - void set_sport_config(UIResourceTextId id); /*控制*/ void handleStartState(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingCardPrsenterC.h b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingCardPrsenterC.h deleted file mode 100644 index 8a40cd185..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingCardPrsenterC.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef _TraingCard_PRESENTERC_H -#define _TraingCard_PRESENTERC_H -namespace OHOS -{ - /*运动识别开启运动*/ - void set_sport_config(UIResourceTextId id); - -} - -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp index 687c6dfb6..02e49f133 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp @@ -314,25 +314,6 @@ namespace OHOS return false; // 没有匹配的操作 } - /* -------------------------------- 运动识别发起处理 -------------------------------- */ - void TraingCardPresenter::set_sport_config(UIResourceTextId id) - { - if (id >= MAXSPORTID) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "id is error"); - return; - } - // 开始训练 ->不返回 - NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGCRAD); - // 配置运动项 - TraingModel::GetInstance()->SetSportEvent(id); - // 获取运动项目 - ExerciseClass type = TraingModel::GetInstance()->GetSportId(); - // 开启对应的运动 - TraingCardPresenter::GetInstance()->OpenSensor(type); - // 设置为手表开启运动 - TraingModel::GetInstance()->SetSportOpenWay(false); - } /* -------------------------------- 协议发起运动处理 -------------------------------- */ bool TraingCardPresenter::send_sport_cmd(training_ble *cmd) diff --git a/code/sdk/application/wearable/service/msg_center/include/notify/motion_recognition_notification.h b/code/sdk/application/wearable/service/msg_center/include/notify/motion_recognition_notification.h index 7125889c3..02c9d2e41 100644 --- a/code/sdk/application/wearable/service/msg_center/include/notify/motion_recognition_notification.h +++ b/code/sdk/application/wearable/service/msg_center/include/notify/motion_recognition_notification.h @@ -11,6 +11,7 @@ /*运动识别*/ #include "BaseView.h" +#include"ui_resource_string.h" namespace OHOS { UIViewGroup *CreateMotionRecognitionView(void); @@ -26,7 +27,7 @@ namespace OHOS void SetMotionTypeId(int type); int GetMotionType(void); - int GetMotionTypeTextId(void); + UIResourceTextId GetMotionTypeTextId(void); private: MotionRecognitionViewEventListener(); diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/motion_recognition_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/motion_recognition_notification.cpp index fb625cedc..2dbd7a4fd 100644 --- a/code/sdk/application/wearable/service/msg_center/src/notify/motion_recognition_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/motion_recognition_notification.cpp @@ -18,6 +18,7 @@ #endif #include #include "ConfigModel.h" +#include "traing/include/TraingModel.h" namespace OHOS { @@ -69,8 +70,8 @@ namespace OHOS /*关闭弹窗*/ NotificationManager::GetInstance()->StopNotify(); /*开始运动*/ - int textId = GetMotionTypeTextId(); - // set_sport_config(textId); + UIResourceTextId sportId = GetMotionTypeTextId(); + TraingModel::GetInstance()->set_sport_config(sportId); } return true; @@ -131,9 +132,9 @@ namespace OHOS return motionType; } - int MotionRecognitionViewEventListener::GetMotionTypeTextId(void) + UIResourceTextId MotionRecognitionViewEventListener::GetMotionTypeTextId(void) { - int motionTypeTextId; + UIResourceTextId motionTypeTextId; switch (motionTypeId) { case 1: