From 2903d727487de9aa30e8428f3c3d1517dbc8f079 Mon Sep 17 00:00:00 2001 From: penglei <1624952103@qq.com> Date: Fri, 26 Jul 2024 10:07:25 +0800 Subject: [PATCH] =?utf8?q?=E4=BC=98=E5=8C=96=E5=BF=83=E7=8E=87=E8=AE=A1?= =?utf8?q?=E7=AE=97=EF=BC=8C=E6=B7=BB=E5=8A=A0UI=E8=BF=90=E5=8A=A8?= =?utf8?q?=E8=AF=86=E5=88=AB=E4=B8=8E=E5=BA=95=E5=B1=82=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../src/MotionRecognitionPresenter.cpp | 9 +- .../drivers/peripheral/ppg/hx3695/hx3695.c | 82 +++++++++---------- 2 files changed, 47 insertions(+), 44 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/motionrecognition/src/MotionRecognitionPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/motionrecognition/src/MotionRecognitionPresenter.cpp index de578f75e..42059989e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/motionrecognition/src/MotionRecognitionPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/motionrecognition/src/MotionRecognitionPresenter.cpp @@ -1,9 +1,9 @@ /* * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-28 14:17:43 - * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-24 18:16:48 - * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/language/src/MotionRecognitionPresenter.cpp + * @LastEditors: penglei 1624952103@qq.com + * @LastEditTime: 2024-07-26 10:02:53 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/motionrecognition/src/MotionRecognitionPresenter.cpp */ #include "AppViewIDs.h" #include "NativeAbility.h" @@ -13,6 +13,7 @@ #include #include "ConfigModel.h" #include +#include "cywee_service.h" namespace OHOS { @@ -98,10 +99,12 @@ namespace OHOS { case UICheckBox::SELECTED: WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MotionRecognition is enable!"); + do_cywee_service_check_msg(CYWEE_SERVICE_CMD_OPEN_AR_ALERT,NULL); ConfigModel::GetInstance()->SetMotionRecognition(true); break; case UICheckBox::UNSELECTED: WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MotionRecognition is disable!"); + do_cywee_service_check_msg(CYWEE_SERVICE_CMD_CLOSE_AR_ALERT,NULL); ConfigModel::GetInstance()->SetMotionRecognition(false); break; default: diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c index e6647d45c..ba9408382 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c @@ -2671,12 +2671,13 @@ static uint8_t hrs_num = 0; static int32_t sum_hrs = 0; static int32_t hrs_data[7] = {0}; static uint8_t left = 0; -static uint8_t right = 0; -static int32_t min_hrs = 0; -static int32_t max_hrs = 0; +static uint8_t right = -1; static void get_avg_hrs(int32_t hrs) { + int32_t min_hrs = 0; + int32_t max_hrs = 0; + int32_t avg_hrs = 0; if(hrs_num == 7) { sum_hrs -= hrs_data[left]; @@ -2685,31 +2686,47 @@ static void get_avg_hrs(int32_t hrs) left = left % 7; hrs_num--; } - if(hrs_num == 0) - { - min_hrs = hrs; - max_hrs = hrs; - } - else - { - if (min_hrs > hrs) - min_hrs = hrs; - if (max_hrs < hrs) - max_hrs = hrs; - } + hrs_num++; right++; right = right % 7; + hrs_data[right] = hrs; sum_hrs += hrs_data[right]; - if(hrs_num > 0) + + if(hrs_num > 2) { - if(hrs_num > 2) - hrs = (sum_hrs - max_hrs - min_hrs) / (hrs_num - 2); - else - hrs = sum_hrs / hrs_num; + min_hrs = hrs_data[0]; + max_hrs = hrs_data[0]; + for (int i = 0;i < hrs_num; i++) + { + if (hrs_data[i] < min_hrs) + min_hrs = hrs_data[i]; + if (hrs_data[i] > max_hrs) + max_hrs = hrs_data[i]; + } + avg_hrs = (sum_hrs - max_hrs - min_hrs) / (hrs_num - 2); + } + + hx3695_msg_callback_t func = hx3695_get_send_msg_callback_func(); + if(func != NULL) + { + hrsresult.lastesthrs = avg_hrs; + func(HX3695_MSG_TYPE_WEARSTAT_UPDATE,&hrsresult,sizeof(FT_CUSTOM_RESULTS_t)); + func(HX3695_MSG_TYPE_HRS_UPDATE,&hrsresult,sizeof(FT_CUSTOM_RESULTS_t)); + if(uapi_get_cywee_static_state()) + { + func(HX3695_MSG_TYPE_STATIC_HRS_UPDATE,&hrsresult,sizeof(FT_CUSTOM_RESULTS_t)); + } + } + + if(hrs_mode_state) + { + cywee_data[0] = hrsresult.lastesthrs; + cywee_data[1] = hrsresult.wearstatus; + + do_cywee_service_check_msg(CYWEE_SERVICE_CMD_HRS_WEARSTATUS_CHANGE,cywee_data); } - PRINT("sum_hrs[%d], max_hrs[%d], min_hrs[%d], avg_hrs[%d] \n",sum_hrs,max_hrs,min_hrs,hrs); } @@ -2850,19 +2867,12 @@ void hx3695_hrs_ppg_Int_handle(void) hrsresult.hr_living = alg_results.living_status; hrsresult.hr_living_qu = alg_results.hr_result_qual; hrsresult.hr_living_std = alg_results.hr_result_std; + hrsresult.wearstatus = hrs_wear_status; if(hrsresult.lastesthrs > 50) - get_avg_hrs((hrsresult.lastesthrs)); + get_avg_hrs(hrsresult.lastesthrs); //PRINT("hx3695 data_cnt: %d, hr_living: %d, hr_living_qu: %d, hr_living_std: %d, hr_result:%d \r\n", //alg_results.data_cnt, hrsresult.hr_living, hrsresult.hr_living_qu, hrsresult.hr_living_std, hrsresult.lastesthrs); - if(hrs_mode_state) - { - cywee_data[0] = hrsresult.lastesthrs; - cywee_data[1] = hrs_wear_status; - - do_cywee_service_check_msg(CYWEE_SERVICE_CMD_HRS_WEARSTATUS_CHANGE,cywee_data); - } - if(hrs_wear_status == MSG_HRS_WEAR && hrsresult.hr_living == MSG_LIVING_TRUE) { // app_hr_reset_stop_timer(); @@ -2934,17 +2944,7 @@ void hx3695_hrs_ppg_Int_handle(void) } ble_rawdata_send_handler(); #endif - hx3695_msg_callback_t func = hx3695_get_send_msg_callback_func(); - if(func != NULL) - { - hrsresult.wearstatus = hrs_wear_status; - func(HX3695_MSG_TYPE_WEARSTAT_UPDATE,&hrsresult,sizeof(FT_CUSTOM_RESULTS_t)); - func(HX3695_MSG_TYPE_HRS_UPDATE,&hrsresult,sizeof(FT_CUSTOM_RESULTS_t)); - if(uapi_get_cywee_static_state()) - { - func(HX3695_MSG_TYPE_STATIC_HRS_UPDATE,&hrsresult,sizeof(FT_CUSTOM_RESULTS_t)); - } - } + #if HANKCREAT_APK { -- 2.17.1