Browse Source

优化leadoff检测

master
zhaohe 1 year ago
parent
commit
ddfa953c67
  1. 73
      app/src/app_service/ecg_service/ecg_service.c
  2. 2
      app/src/aproject_config/config.h

73
app/src/app_service/ecg_service/ecg_service.c

@ -17,6 +17,8 @@ static bool m_report_data_in_raw_mode_flag;
static bool m_leadoffstate;
uint8_t m_leadoff_raw_state;
static uint32_t predata_filter_cnt = 0;
/***********************************************************************************************************************
* PRIVATE_FUNC *
***********************************************************************************************************************/
@ -203,41 +205,59 @@ static void leadoff_state_process(ads129x_capture_data_t* capture_data) {
*
*
*/
if (!m_leadoffstate) {
/**
* @brief
*/
static uint32_t un_lead_off_cnt = 0;
bool leadoff = false;
if (capture_data->ch1data > 34000 || capture_data->ch1data < -34000) {
leadoff = true;
}
static uint32_t un_leadoffcnt = 0;
bool leadoff = false;
// if (ecg_algo_get_peak2peak() > 15000) {
// leadoff = true;
// }
// if (ecg_algo_get_peak2peak() < 500) {
// leadoff = true;
// }
if (capture_data->ch1data > INT16_MAX || capture_data->ch1data < INT16_MIN) {
leadoff = true;
}
// if (capture_data->loffstate & 0x3) {
// leadoff = true;
// }
if (leadoff) {
un_lead_off_cnt++;
} else {
un_lead_off_cnt = 0;
}
if (un_lead_off_cnt > 10) {
un_lead_off_cnt = 0;
m_leadoffstate = true;
}
if (leadoff) {
un_leadoffcnt = 0;
} else {
un_leadoffcnt++;
}
/**
* @brief
*/
if (leadoff != m_leadoffstate) {
if (m_leadoffstate && un_leadoffcnt > 500) {
m_leadoffstate = false;
static uint32_t cnt = 0;
int32_t absraw = capture_data->ch1data;
if (absraw < 0) {
absraw = -absraw;
}
if (absraw < 25000) {
cnt++;
} else {
m_leadoffstate = true;
cnt = 0;
}
if (cnt > 10) {
cnt = 0;
m_leadoffstate = false;
}
}
}
static void ads1291_ready_pin_irq(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) {
static ads129x_capture_data_t capture_data;
predata_filter_cnt++;
if (predata_filter_cnt < 500) {
return;
}
//
ads129x_read_data(&capture_data);
@ -248,7 +268,7 @@ static void ads1291_ready_pin_irq(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t a
//
one_frame_t frame;
if (m_report_data_in_raw_mode_flag) {
frame.data = capture_data.ch1data;
frame.data = capture_data.ch1data * 0.5;
} else {
frame.data = ecg_algo_get_report_data();
}
@ -353,6 +373,8 @@ static bool m_work_state;
void ecg_service_start_capture() { //
if (m_work_state) return;
predata_filter_cnt = 0;
ecg_data_mgr_clear_buffer();
static ads129x_regs_t regcache;
@ -380,7 +402,6 @@ void ecg_service_start_capture() { //
}
ads129x_write_regs(&regcache);
ads129x_send_cmd(ADS129X_COMMAND_START); /* 发送开始数据转换(等效于拉高START引脚) */
ecg_service_captured_time = znordic_getpower_on_ms();
m_leadoffstate = true;

2
app/src/aproject_config/config.h

@ -7,7 +7,7 @@
#define CATEGORY "M1003" // 데돔젬
#define MANUFACTURER_NAME "iflytop"
#define FIRMWARE_VERSION (501)
#define FIRMWARE_VERSION (505)
#define BLESTACK_VERSION 1
#define BOOTLOADER_VERSION 1
#define HARDWARE_VERSION (2)

Loading…
Cancel
Save