#include "debug_print.h"
#include "custom_utils.h"
+#include <math.h>
#define HAL_ADC_SAMPLE_NUMBER_CONFIG_0 10 /* Channel with buffer manual sample average number. */
#define HAL_ADC_SAMPLE_NUMBER_CONFIG_1 10 /* Channel without buffer manual sample average number. */
if(get_charge_stat())
{
- if(history_percent > percent)
+ if(history_percent > percent && abs(history_percent - percent) < 10)
+ // if(history_percent > percent)
{
percent = history_percent;
break;
}
//电量均匀增加
- else if(percent > history_percent && history_percent)
+ else if(percent > history_percent && history_percent && abs(history_percent - percent) < 10)
+ // else if(percent > history_percent && history_percent)
{
history_percent++;
percent = history_percent;
}
else
{
- if(history_percent < percent && history_percent != 0)
+ if(history_percent < percent && history_percent != 0 && abs(history_percent - percent) < 10)
+ // if(history_percent < percent && history_percent != 0)
{
percent = history_percent;
break;
}
//电量均匀减少
- else if(history_percent > percent)
+ else if(history_percent > percent && abs(history_percent - percent) < 10)
+ // else if(history_percent > percent)
{
history_percent--;
percent = history_percent;
uint16_t len = 1;
uapi_get_file_data("/user/userdata/battery.bin",&percent,&len);
PRINT("battery_get_percent_onstart : %d",percent);
- return percent;
+ if(percent <= 100 && percent >= 0)
+ return percent;
+ else
+ return 0;
}
uint8_t read_fifo_first_flg = 0;\r
\r
//HRS_INFRARED_THRES\r
-const int32_t hrs_ir_unwear_thres = 8000;\r
-const int32_t hrs_ir_wear_thres = 10000;\r
+const int32_t hrs_ir_unwear_thres = 10000;\r
+const int32_t hrs_ir_wear_thres = 15000;\r
//HRV_INFRARED_THRES\r
const int32_t hrv_ir_unwear_thres = 8000; //demo143b 25000\r
const int32_t hrv_ir_wear_thres = 10000;\r
const uint8_t spo2_ir_wear_offset = 15;\r
//CHECK_WEAR_MODE_THRES\r
const int32_t check_mode_unwear_thre = 20000;\r
-const int32_t check_mode_wear_thre = 20000;\r
+const int32_t check_mode_wear_thre = 22000;\r
\r
\r
uint8_t alg_ram[11 * 1024] __attribute__((aligned(4)));\r
void hx3695_hrs_ppg_init(void) // ppg fs=25hz, phase conversion ready interupt en\r
{\r
uint16_t sample_rate = 25; /*config the data rate of chip alps2_fm ,uint is Hz*/\r
- uint32_t prf_clk_num = 32000/sample_rate*24/25; /*period in clk num, num = Fclk/fs */\r
+ uint32_t prf_clk_num = 32000/sample_rate; /*period in clk num, num = Fclk/fs */\r
\r
uint16_t fifo_watermark= 81 ;\r
uint8_t adc_rst_post_num=0; /* 00=16,01=32,10=64,11=128*/ \r
void hx3695_spo2_ppg_init(void) //20200615 ericy ppg fs=25hz, phase3 conversion ready interupt en\r
{\r
uint16_t sample_rate = 25; /*config the data rate of chip alps2_fm ,uint is Hz*/\r
- uint32_t prf_clk_num = 32000/sample_rate*24/25; /*period in clk num, num = Fclk/fs */\r
+ uint32_t prf_clk_num = 32000/sample_rate; /*period in clk num, num = Fclk/fs */\r
\r
uint16_t fifo_watermark= 250 ;\r
uint8_t adc_rst_post_num=0; /* 00=16,01=32,10=64,11=128*/ \r
void hx3695_hrv_ppg_init(void) //20200615 ericy ppg fs=25hz, phase3 conversion ready interupt en\r
{\r
uint16_t sample_rate = 125; /*config the data rate of chip alps2_fm ,uint is Hz*/\r
- uint32_t prf_clk_num = 32000/sample_rate*24/25; /*period in clk num, num = Fclk/fs */\r
+ uint32_t prf_clk_num = 32000/sample_rate; /*period in clk num, num = Fclk/fs */\r
\r
uint8_t adc_rst_post_num=0; /* 00=16,01=32,10=64,11=128*/ \r
uint8_t samp_delay_leden_num = 0; /* 00=8,01=16,10=32,11=64*/ \r
void hx3695_check_touch_init(void) //\r
{ \r
uint16_t sample_rate = 5; /*config the data rate of chip alps2_fm ,uint is Hz*/\r
- uint32_t prf_clk_num = 32000/sample_rate*24/25; /*period in clk num, num = Fclk/fs */\r
+ uint32_t prf_clk_num = 32000/sample_rate; /*period in clk num, num = Fclk/fs */\r
\r
uint16_t fifo_watermark= 250 ;\r
uint8_t adc_rst_post_num= 0; /* 00=16,01=32,10=64,11=128*/ \r
//PRINT("*count : %d \r\n",*count);\r
\r
//count7-9 为捕捉到的绿光值正常数据数量范围,不在此范围,心率数据不准,直接返回.\r
- if(*count < 7 || *count > 9) \r
- {\r
- return;\r
- }\r
+ // if(*count < 7 || *count > 9) \r
+ // {\r
+ // return;\r
+ // }\r
memset(gsensordata,0.0f,sizeof(gsenson_t) * *count);\r
\r
gsensor_get_n_data(*count,gsensordata); \r
// uint32_t tm;\r
// uapi_get_timestampe_ss(&tm);\r
// CWM_OS_dbgPrintf("ir_data : %d tm : %d\r\n",ir_data,tm);\r
- if(ir_data > 60000)\r
- {\r
- touch_cnt = 0;\r
- if(notouch_cnt>=2)\r
- {\r
- hx3695_wear_status = MSG_NO_WEAR;\r
- notouch_cnt=0;\r
- }\r
- else\r
- {\r
- notouch_cnt++;\r
- }\r
- }\r
- else if(ir_data>check_mode_wear_thre && ir_data < 60000)\r
+ // if(ir_data > 60000)\r
+ // {\r
+ // touch_cnt = 0;\r
+ // if(notouch_cnt>=2)\r
+ // {\r
+ // hx3695_wear_status = MSG_NO_WEAR;\r
+ // notouch_cnt=0;\r
+ // }\r
+ // else\r
+ // {\r
+ // notouch_cnt++;\r
+ // }\r
+ // }\r
+ // else\r
+ if(ir_data>check_mode_wear_thre)\r
{\r
notouch_cnt = 0;\r
if(touch_cnt>=2)\r
void hx3695_hrs_cal_init(void)\r
{\r
uint16_t sample_rate = 200; //200 /*config the data rate of chip alps2_fm ,uint is Hz*/\r
- uint32_t prf_clk_num = 32000/sample_rate*24/25; /*period in clk num, num = Fclk/fs */\r
+ uint32_t prf_clk_num = 32000/sample_rate; /*period in clk num, num = Fclk/fs */\r
uint8_t data_avg_num = 0;\r
hx3695_write_reg(0X2a, (uint8_t)prf_clk_num); // prf bit<7:0>\r
hx3695_write_reg(0X2b, (uint8_t)(prf_clk_num>>8)); // prf bit<15:8>\r
{\r
uint16_t sample_rate = 5; /*config the data rate of chip alps2_fm ,uint is Hz*/\r
uint8_t data_avg_num = 0; /* 0 = 1 ; 1 = 2; 2 =4 ; 3 =8 ; 4 =16 ;*/\r
- uint32_t prf_clk_num = 32000/sample_rate*24/25; /*period in clk num, num = Fclk/fs */\r
+ uint32_t prf_clk_num = 32000/sample_rate; /*period in clk num, num = Fclk/fs */\r
\r
uint8_t phase2_offset_idac = 0; /* 0~127 = 0 ~ 32ua , step = 0.25ua */\r
uint8_t phase5_offset_idac = 0; /* 0~127 = 0 ~ 32ua , step = 0.25ua */\r
int32_t Ir_src_data;\r
bool recal = false;\r
uint8_t size = 0;\r
- uint16_t data_count = 0;\r
+ uint8_t data_count = 0;\r
uint8_t size_byte = 0;\r
int32_t *PPG_buf = &(s_dat->green_data[0]);\r
int32_t *ir_buf = &(s_dat->ir_data[0]); \r
} \r
// TYHX_LOG("ppg_state: %d ,hrs_cal_state: %d\r\n",s_ppg_state,hrs_cal_state); \r
data_count = hx3695_read_fifo_data(s_buf,hrs_phase_num,1); \r
- //SEGGER_RTT_printf(0,"ppg data size: %d %d\r\n", data_count,hrs_phase_num);\r
+ // PRINT("ppg data size: %d %d\r\n", data_count,hrs_phase_num);\r
// SEGGER_RTT_printf(0,"af_hx3695_read_fifo_data:::%d %d %d\r\n", hx3695_read_reg(0X2a),hx3695_read_reg(0X2b),hx3695_read_reg(0X2c));\r
s_dat->count = data_count; \r
\r
PPG_buf[i] = PPG_src_data * 2;\r
ir_buf[i] = Ir_src_data; //Ir_src_data;\r
// SEGGER_RTT_printf(0,"PPG_data: %d , PPG_src_data2: %d\r\n", PPG_src_data,PPG_src_data2);\r
- //my_printf("hx3695 Ir_src_data %d \r\n", Ir_src_data);\r
+ // PRINT("hx3695 Ir_src_data %d \r\n", Ir_src_data);\r
hx3695_hrs_wear_mode_check(HRS_MODE,Ir_src_data); \r
\r
}\r