From: penglei <1624952103@qq.com> Date: Sat, 27 Apr 2024 11:05:04 +0000 (+0800) Subject: 优化血氧驱动,解决血氧检测经常不出值的问题,优化心率血氧蓝牙服务。 X-Git-Tag: release_V1.2.70_20241020_135402~1025^2~57^2~1 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=refs%2Fchanges%2F103%2F1;p=mirrors%2FFD230.git 优化血氧驱动,解决血氧检测经常不出值的问题,优化心率血氧蓝牙服务。 --- diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c index 98d82f50a..5c396a8fd 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c @@ -2959,12 +2959,12 @@ void hx3695_hrs_ppg_Int_handle(void) encoded_hrm[7] = (uint8_t)((ir_buf[ii] & 0xFF00) >> 8); //ir原始数据 encoded_hrm[8] = (uint8_t)(ir_buf[ii] & 0xFF); //ir原始数据 - encoded_hrm[9] = (uint8_t)((1234&0xFF00)>>8);//模拟x,1234换成填入自己的x数据 - encoded_hrm[10] = (uint8_t)(1234&0xFF); - encoded_hrm[11] = (uint8_t)((-1234&0xFF00)>>8);//模拟y,-1234换成填入自己的y数据 - encoded_hrm[12] = (uint8_t)(-1234&0xFF); - encoded_hrm[13] = (uint8_t)((3987&0xFF00)>>8);//模拟z,3987换成填入自己的z数据 - encoded_hrm[14] = (uint8_t)(3987&0xFF); + encoded_hrm[9] = (uint8_t)((gsen_fifo_x_send[ii]&0xFF00)>>8);//模拟x,1234换成填入自己的x数据 + encoded_hrm[10] = (uint8_t)(gsen_fifo_x_send[ii]&0xFF); + encoded_hrm[11] = (uint8_t)((gsen_fifo_y_send[ii]&0xFF00)>>8);//模拟y,-1234换成填入自己的y数据 + encoded_hrm[12] = (uint8_t)(gsen_fifo_y_send[ii]&0xFF); + encoded_hrm[13] = (uint8_t)((gsen_fifo_z_send[ii]&0xFF00)>>8);//模拟z,3987换成填入自己的z数据 + encoded_hrm[14] = (uint8_t)(gsen_fifo_z_send[ii]&0xFF); encoded_hrm[15] = ppg_s_data.green_cur;//绿灯电流 encoded_hrm[16] = ppg_s_data.ir_cur;//红外电流 @@ -3233,17 +3233,28 @@ void hx3695_spo2_ppg_Int_handle(void) PRINT("*count[%d] \r\n",*count); if(*count < 10) { - for(ii=0; ii<*count; ii++) - { - gsen_fifo_x_send[ii] = gsen_fifo_x[32-*count+ii]; - gsen_fifo_y_send[ii] = gsen_fifo_y[32-*count+ii]; - gsen_fifo_z_send[ii] = gsen_fifo_z[32-*count+ii]; - PRINT("hxdata:%d/%d %d %d %d %d %d %d\r\n", - 1+ii,*count,red_buf[ii],ir_buf[ii],green_buf[ii],gsen_fifo_x[ii],gsen_fifo_y[ii],gsen_fifo_z[ii]); + gsensor_get_n_data(8,gsensordata); + for(ii=0; ii<*count; ii++) + { + if(ii == 8) + { + gsen_fifo_x_send[ii] = gsen_fifo_x_send[ii - 1]; + gsen_fifo_y_send[ii] = gsen_fifo_y_send[ii - 1]; + gsen_fifo_z_send[ii] = gsen_fifo_z_send[ii - 1]; + } + else + { + // gsen_fifo_x_send[ii] = (gsensordata[ii*2].x + gsensordata[2*ii + 1].x)/2; + // gsen_fifo_y_send[ii] = (gsensordata[ii*2].y + gsensordata[2*ii + 1].y)/2; + // gsen_fifo_z_send[ii] = (gsensordata[ii*2].z + gsensordata[2*ii + 1].z)/2; + gsen_fifo_x_send[ii] = gsensordata[ii].x * 2048; + gsen_fifo_y_send[ii] = gsensordata[ii].y * 2048; + gsen_fifo_z_send[ii] = gsensordata[ii].z * 2048; + } + PRINT("hxdata:%d/%d %d %d %d %d %d %d\r\n", + 1+ii,*count,red_buf[ii],ir_buf[ii],green_buf[ii],gsen_fifo_x_send[ii],gsen_fifo_y_send[ii],gsen_fifo_z_send[ii]); //printf("FFF==>spo2 red_buf : %d, %d, %d, %d \n", 1+ii, *count, red_buf[ii], ir_buf[0]); - - - } + } // ft_ppg_iir = spo2_s_dat.red_data[0]; // hx3695_factory_test_process(NULL, APP_FACTORY_TEST_SPO2_START, &ft_ppg_iir); @@ -3311,9 +3322,8 @@ void hx3695_spo2_ppg_Int_handle(void) spo2_alg_results = tyhx_spo2_alg_get_results(); //------------------------adjust------------------- DEBUG_PRINTF("block_cnt: %d, data_cnt:%d, hr_result:%d,ir_quality:%d,motion:%d,poor_signal:%d,reliable_score_result:%d,screen_up:%d,spo2_result:%d\r\n",spo2_alg_results.block_cnt,spo2_alg_results.data_cnt,spo2_alg_results.hr_result,spo2_alg_results.ir_quality,spo2_alg_results.motion,spo2_alg_results.poor_signal,spo2_alg_results.reliable_score_result,spo2_alg_results.screen_up,spo2_alg_results.spo2_result); - + hrsresult.lastestspo2 = spo2_alg_results.spo2_result; - if(hrsresult.lastestspo2 > 0) ble_spo2_flag = 1; // if(hrsresult.lastestspo2) @@ -3327,6 +3337,7 @@ void hx3695_spo2_ppg_Int_handle(void) hx3695_msg_callback_t func = hx3695_get_send_msg_callback_func(); if(func != NULL) { + hrsresult.wearstatus = spo2_wear_status; func(HX3695_MSG_TYPE_WEARSTAT_UPDATE,&hrsresult,sizeof(FT_CUSTOM_RESULTS_t)); func(HX3695_MSG_TYPE_SPO2_UPDATE,&hrsresult,sizeof(FT_CUSTOM_RESULTS_t)); } @@ -3402,14 +3413,14 @@ void hx3695_spo2_ppg_Int_handle(void) encoded_hrm[9] = (uint8_t)((gdiff[0]&0xFF00)>>8);//sar diff encoded_hrm[10] = (uint8_t)(gdiff[0]&0xFF); #else - encoded_hrm[9] = (uint8_t)((1234&0xFF00)>>8);//模拟x - encoded_hrm[10] = (uint8_t)(1234&0xFF); + encoded_hrm[9] = (uint8_t)((gsen_fifo_x_send[ii]&0xFF00)>>8);//模拟x + encoded_hrm[10] = (uint8_t)(gsen_fifo_x_send[ii]&0xFF); #endif - encoded_hrm[11] = (uint8_t)((-1234&0xFF00)>>8);//模拟y - encoded_hrm[12] = (uint8_t)(-1234&0xFF); - encoded_hrm[13] = (uint8_t)((3987&0xFF00)>>8);//模拟z - encoded_hrm[14] = (uint8_t)(3987&0xFF); + encoded_hrm[11] = (uint8_t)((gsen_fifo_y_send[ii]&0xFF00)>>8);//模拟y + encoded_hrm[12] = (uint8_t)(gsen_fifo_y_send[ii]&0xFF); + encoded_hrm[13] = (uint8_t)((gsen_fifo_z_send[ii]&0xFF00)>>8);//模拟z + encoded_hrm[14] = (uint8_t)(gsen_fifo_z_send[ii]&0xFF); encoded_hrm[15] = cal.R_LED; encoded_hrm[16] = cal.IR_LED1;