From 859840340f9bcedf9818e4995f7777e754005158 Mon Sep 17 00:00:00 2001 From: penglei <1624952103@qq.com> Date: Tue, 24 Sep 2024 20:32:34 +0800 Subject: [PATCH] =?utf8?q?=E8=B0=83=E9=AB=98=E6=8A=AC=E8=85=95=E4=BA=AE?= =?utf8?q?=E5=B1=8F=E7=81=B5=E6=95=8F=E5=BA=A6=EF=BC=8C=E4=BC=98=E5=8C=96?= =?utf8?q?=E5=BF=83=E7=8E=87=E8=84=B1=E8=85=95=E6=8F=90=E9=86=92=E9=80=9F?= =?utf8?q?=E5=BA=A6=EF=BC=8C=E6=B7=BB=E5=8A=A0=E8=A2=AB=E5=8A=A8=E6=A3=80?= =?utf8?q?=E6=B5=8Bruntime=EF=BC=8C=E4=BB=85=E5=9C=A8=E5=BF=83=E7=8E=87?= =?utf8?q?=E5=91=A8=E6=9C=9F=E6=A3=80=E6=B5=8B=E4=B8=8B=E4=B8=8A=E6=8A=A5?= =?utf8?q?=E4=BD=A9=E6=88=B4=E4=BF=A1=E6=81=AF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/heartrate/src/HeartModel.cpp | 12 ++++- .../drivers/peripheral/cywee/src/main_dml.c | 8 ++-- .../drivers/peripheral/ppg/hx3695/hx3695.c | 45 ++++++++++++++----- .../peripheral/ppg/service/ppg_service.cpp | 17 +++++-- .../drivers/peripheral/utils/custom_runtime.c | 12 +++++ .../drivers/peripheral/utils/custom_runtime.h | 5 +++ .../drivers/peripheral/utils/custom_utils.c | 28 +++++++++--- 7 files changed, 101 insertions(+), 26 deletions(-) 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 549a540b8..b19630152 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp @@ -28,7 +28,7 @@ extern "C" { #endif -#define MAX_UNWEAR_COUNT 30 +#define MAX_UNWEAR_COUNT 10 #define MAX_VALID_HRS_COUNT 60 #define MAX_DISVALID_HRS_COUNT 70 #define MIN_DISPLAY_HEART 60 @@ -399,6 +399,9 @@ void HeartModel::Heart_Control(HeartState state, HeartCheck check) { heartstate = false; // 复原检测状态 checkstate = HeartCheck::RESTSTSTE; + LOS_Msleep(500); + uapi_dev_runtime_set_hrs_passivity(0); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "uapi_dev_runtime_set_hrs_passivity(0)"); } else if (state == HeartState::Start && heartstate == false) { /*充电状态下不进行检测*/ bool isCharging = get_charge_stat(); // 获取充电状态 @@ -411,6 +414,13 @@ void HeartModel::Heart_Control(HeartState state, HeartCheck check) { send_ppg_cmd_msg(md); heartstate = true; checkstate = check; + //被动 + if(checkstate==HeartCheck::PASSIVITY) + { + uapi_dev_runtime_set_hrs_passivity(1); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "uapi_dev_runtime_set_hrs_passivity(1)"); + } + } } // 开始检测 diff --git a/code/sdk/drivers/peripheral/cywee/src/main_dml.c b/code/sdk/drivers/peripheral/cywee/src/main_dml.c index 9ae828143..e8b78d072 100644 --- a/code/sdk/drivers/peripheral/cywee/src/main_dml.c +++ b/code/sdk/drivers/peripheral/cywee/src/main_dml.c @@ -1324,10 +1324,10 @@ int cywee_main_dml(void) //设置抬腕功能 memset(&scl, 0, sizeof(scl)); scl.iData[0] = 1; - scl.iData[1] = 6; //调小抬手反应范围 - scl.iData[2] = 5; - scl.iData[3] = 5; - scl.iData[4] = 6; //调小抬手反应范围 + // scl.iData[1] = 5; + // scl.iData[2] = 5; + // scl.iData[3] = 5; + // scl.iData[4] = 5; CWM_SettingControl(SCL_HAND_UPDOWN_CONFIG, &scl); //配置跑步机模式相关参数(进入跑步机模式自动生效) diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c index 6c24c0f63..76d2ee1d5 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c @@ -124,7 +124,8 @@ uint8_t alg_ram[11 * 1024] __attribute__((aligned(4))); ppg_sensor_data_t ppg_s_data; static int cywee_data = 0; -static int wear_status = -1; +static int history_wear_status = -1; +static int cywee_wear_status = 0; static uint8_t hx3695_chip_id = 0; @@ -2720,10 +2721,10 @@ static void get_avg_hrs(int32_t hrs) void hx3695_wearstatus_update(void) { - if(wear_status != hrsresult.wearstatus) + if(history_wear_status != cywee_wear_status) { - wear_status = hrsresult.wearstatus; - cywee_data = wear_status; + history_wear_status = cywee_wear_status; + cywee_data = history_wear_status; do_cywee_service_check_msg(CYWEE_SERVICE_CMD_WEAR_STATUS_CHANGE,&cywee_data); } } @@ -2883,18 +2884,38 @@ void hx3695_hrs_ppg_Int_handle(void) hrsresult.hr_living_std = alg_results.hr_result_std; hrsresult.wearstatus = hrs_wear_status; - if(hrs_wear_status == MSG_HRS_WEAR && hrsresult.hr_living == MSG_LIVING_TRUE) + if(hrsresult.wearstatus == MSG_HRS_WEAR) { - if(hrsresult.lastesthrs > 30 && hrsresult.lastesthrs < 220) - get_avg_hrs(hrsresult.lastesthrs); - - hrsresult.wearstatus = MSG_HRS_WEAR; + if(hrsresult.hr_living == MSG_LIVING_TRUE) + { + if(hrsresult.lastesthrs > 30 && hrsresult.lastesthrs < 220) + get_avg_hrs(hrsresult.lastesthrs); + cywee_wear_status = 1; + } + else + { + cywee_wear_status = 0; + } } else { hrsresult.wearstatus = MSG_HRS_NO_WEAR; hrsresult.lastesthrs = 0; + cywee_wear_status = 0; } + // PRINT("hrsresult.wearstatus : %d , cywee_wear_status : %d , hr_living : %d \n",hrsresult.wearstatus,cywee_wear_status,hrsresult.hr_living); + // if(hrs_wear_status == MSG_HRS_WEAR && hrsresult.hr_living == MSG_LIVING_TRUE) + // { + // if(hrsresult.lastesthrs > 30 && hrsresult.lastesthrs < 220) + // get_avg_hrs(hrsresult.lastesthrs); + + // hrsresult.wearstatus = MSG_HRS_WEAR; + // } + // else + // { + // hrsresult.wearstatus = MSG_HRS_NO_WEAR; + // hrsresult.lastesthrs = 0; + // } hx3695_msg_callback_t func = hx3695_get_send_msg_callback_func(); if(func != NULL) { @@ -3671,10 +3692,10 @@ void hx3695_wear_ppg_Int_handle(void) hx3695_check_touch_read(&ppg_s_data); hx3695_wear_status = hx3695_check_touch_send_data(ir_buf,*count); // PRINT("hx3695_wear_status : %d \r\n",hx3695_wear_status); - if(wear_status != hx3695_wear_status) + if(history_wear_status != hx3695_wear_status) { - wear_status = hx3695_wear_status; - cywee_data = wear_status; + history_wear_status = hx3695_wear_status; + cywee_data = history_wear_status; do_cywee_service_check_msg(CYWEE_SERVICE_CMD_WEAR_STATUS_CHANGE,&cywee_data); } diff --git a/code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp b/code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp index 7c7c21ca7..85a947f79 100644 --- a/code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp +++ b/code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp @@ -284,7 +284,12 @@ static void ppg_service_check_task(void *arg) //do_cywee_service_check_msg(CYWEE_SERVICE_CMD_OPEN_GET_ACC,NULL); cmd = "hrs"; enable = 1; - uapi_pm_add_sleep_veto(PM_ID_HEART); + uint8_t cnt = pm_veto_get_id_cnt(PM_ID_HEART); + if (cnt == 0) + { + uapi_pm_add_sleep_veto(PM_ID_HEART); + } + }else if (mail == PPG_SERVICE_CMD_TYPE_DO_HRV_TEST){ cmd = "hrv"; enable = 1; @@ -315,13 +320,19 @@ static void ppg_service_check_task(void *arg) wear_mode_state = 0; }else if (mail == PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST){ //do_cywee_service_check_msg(CYWEE_SERVICE_CMD_CLOSE_GET_ACC,NULL); - if(uapi_dev_runtime_get_sleep_monitoring_status())//处于睡眠监测 上报活体佩戴 + //PRINT("uapi_dev_runtime_get_sleep_monitoring_status : %d \n",uapi_dev_runtime_get_sleep_monitoring_status()); + //PRINT("uapi_dev_runtime_get_hrs_passivity_flag : %d \n",uapi_dev_runtime_get_hrs_passivity_flag()); + if(uapi_dev_runtime_get_sleep_monitoring_status() && uapi_dev_runtime_get_hrs_passivity_flag())//处于睡眠监测 且在心率周期检测期间 上报活体佩戴 { hx3695_wearstatus_update(); } cmd = "hrs"; enable = 0; - uapi_pm_remove_sleep_veto(PM_ID_HEART); + uint8_t cnt = pm_veto_get_id_cnt(PM_ID_HEART); + if (cnt == 1) + { + uapi_pm_remove_sleep_veto(PM_ID_HEART); + } }else if (mail == PPG_SERVICE_CMD_TYPE_STOP_SPO2_TEST){ cmd = "spo2"; diff --git a/code/sdk/drivers/peripheral/utils/custom_runtime.c b/code/sdk/drivers/peripheral/utils/custom_runtime.c index ae683852a..c138258bd 100644 --- a/code/sdk/drivers/peripheral/utils/custom_runtime.c +++ b/code/sdk/drivers/peripheral/utils/custom_runtime.c @@ -84,6 +84,7 @@ typedef struct uint8_t absolute_static_state; // 绝对静止状态 uint8_t checkres_status;//校验文件状态 uint8_t repair_download_status;//升级下载状态 + uint8_t hrs_passivity_status;//获取被动心率检测状态 } runtime_status_t; @@ -436,4 +437,15 @@ void uapi_dev_runtime_set_safemode_flag(uint8_t status) uint8_t uapi_dev_runtime_get_safemode_flag(void) { return g_runtime.enter_safemode; +} + +// 设置被动心率检测状态 +void uapi_dev_runtime_set_hrs_passivity(uint8_t status) +{ + g_runtime.hrs_passivity_status = status; +} +// 获取被动心率检测状态 +uint8_t uapi_dev_runtime_get_hrs_passivity_flag(void) +{ + return g_runtime.hrs_passivity_status; } \ No newline at end of file diff --git a/code/sdk/drivers/peripheral/utils/custom_runtime.h b/code/sdk/drivers/peripheral/utils/custom_runtime.h index 3395e9250..a2fd51b2d 100644 --- a/code/sdk/drivers/peripheral/utils/custom_runtime.h +++ b/code/sdk/drivers/peripheral/utils/custom_runtime.h @@ -216,6 +216,11 @@ void uapi_dev_runtime_set_safemode_flag(uint8_t status); // 安全模式 uint8_t uapi_dev_runtime_get_safemode_flag(void); + +void uapi_dev_runtime_set_hrs_passivity(uint8_t status); +// 获取被动心率检测状态 +uint8_t uapi_dev_runtime_get_hrs_passivity_flag(void); + #ifdef __cplusplus #if __cplusplus } diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.c b/code/sdk/drivers/peripheral/utils/custom_utils.c index 2571b9337..c63df9404 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils.c @@ -2157,8 +2157,11 @@ errcode_t custom_iic_init(void) errcode_t custom_i2c_read_regs(uint16_t slaveAddr, uint16_t reg, int regLength, uint8_t *readData, int readDataSize, int busIndex) { - - uapi_pm_add_sleep_veto(PM_ID_GSENSOR); + uint8_t cnt = pm_veto_get_id_cnt(PM_ID_GSENSOR); + if (cnt == 0) + { + uapi_pm_add_sleep_veto(PM_ID_GSENSOR); + } errcode_t ret; uint32_t retry; @@ -2198,14 +2201,23 @@ errcode_t custom_i2c_read_regs(uint16_t slaveAddr, uint16_t reg, int regLength, osal_kfree(write_data); error: - uapi_pm_remove_sleep_veto(PM_ID_GSENSOR); - + cnt = pm_veto_get_id_cnt(PM_ID_GSENSOR); + if (cnt == 1) + { + uapi_pm_remove_sleep_veto(PM_ID_GSENSOR); + } + return (ret>0) ? ret*-1: ret; } errcode_t custom_i2c_write_reg(uint16_t slaveAddr, uint16_t reg, int regLength, uint8_t *writeData, int writeDataSize, int busIndex) { - uapi_pm_add_sleep_veto(PM_ID_GSENSOR); + uint8_t cnt = pm_veto_get_id_cnt(PM_ID_GSENSOR); + if (cnt == 0) + { + uapi_pm_add_sleep_veto(PM_ID_GSENSOR); + } + errcode_t ret; uint32_t retry; i2c_data_t data; @@ -2252,7 +2264,11 @@ errcode_t custom_i2c_write_reg(uint16_t slaveAddr, uint16_t reg, int regLength, free_mem: osal_kfree(write_data); error: - uapi_pm_remove_sleep_veto(PM_ID_GSENSOR); + cnt = pm_veto_get_id_cnt(PM_ID_GSENSOR); + if (cnt == 1) + { + uapi_pm_remove_sleep_veto(PM_ID_GSENSOR); + } return (ret>0) ? ret*-1: ret; } -- 2.17.1