diff --git a/app/src/app_service/ecg_service/ecg_algo.c b/app/src/app_service/ecg_service/ecg_algo.c index 31a6590..656a9f5 100644 --- a/app/src/app_service/ecg_service/ecg_algo.c +++ b/app/src/app_service/ecg_service/ecg_algo.c @@ -6,7 +6,7 @@ #include "algo/zsimple_qrs.h" #include "znordic.h" -#define REPORT_MEDIAN_WINDOWS_SIZE 151 // 必须是奇数 +#define REPORT_MEDIAN_WINDOWS_SIZE 101 // 必须是奇数 LPFilterExt_t m_lp_filter; HPFilterExt_t m_hp_filter; @@ -30,6 +30,21 @@ static int32_t m_frame_cnt; void ecg_algo_init() { ecg_algo_reset(); } +void leadoff_data_process(int32_t indata) { + zdata_statistics_push(&m_leadoff_statistics, indata); + if (zdata_statistics_is_full(&m_leadoff_statistics)) { + int32_t max = zdata_statistics_get_max(&m_leadoff_statistics); + int32_t min = zdata_statistics_get_min(&m_leadoff_statistics); + if (max - min < 6000) { + m_leadoff = true; + } else { + m_leadoff = false; + } + } else { + m_leadoff = true; + } +} + void report_data_process(int32_t indata) { m_frame_cnt++; float data = indata; @@ -47,27 +62,11 @@ void report_data_process(int32_t indata) { data = delay_data - medianValue; data = SmoothingFilter_Update(&m_report_smoothing_filter, data); reportdata = data; -} -void leadoff_data_process(int32_t indata) { - zdata_statistics_push(&m_leadoff_statistics, indata); - if (zdata_statistics_is_full(&m_leadoff_statistics)) { - int32_t max = zdata_statistics_get_max(&m_leadoff_statistics); - int32_t min = zdata_statistics_get_min(&m_leadoff_statistics); - if (max - min > 45000) { - m_leadoff = true; - } else { - m_leadoff = false; - } - } else { - m_leadoff = true; - } + leadoff_data_process(data); } -void ecg_algo_process_data(int32_t indata) { - leadoff_data_process(indata); - report_data_process(indata); -} +void ecg_algo_process_data(int32_t indata) { report_data_process(indata); } void ecg_algo_reset() { LPFilterExt_init(&m_lp_filter, 40, SAMPLE_PERIOD_S, 5, true); diff --git a/app/src/app_service/ecg_service/ecg_algo.h b/app/src/app_service/ecg_service/ecg_algo.h index c58b36e..7582062 100644 --- a/app/src/app_service/ecg_service/ecg_algo.h +++ b/app/src/app_service/ecg_service/ecg_algo.h @@ -5,7 +5,7 @@ #include "app_basic_service/zapp.h" #define SAMPLE_PERIOD_S ((float)(1.0 / SAMPLE_RATE)) -#define STATISTICS_BUF_SIZE ((int32_t)(0.5 / SAMPLE_PERIOD_S)) /*1s的数据*/ +#define STATISTICS_BUF_SIZE ((int32_t)(1 / SAMPLE_PERIOD_S)) /*1s的数据*/ void ecg_algo_init(); void ecg_algo_process_data(int32_t indata); diff --git a/app/src/app_service/ecg_service/ecg_service.c b/app/src/app_service/ecg_service/ecg_service.c index d50f956..d1c136a 100644 --- a/app/src/app_service/ecg_service/ecg_service.c +++ b/app/src/app_service/ecg_service/ecg_service.c @@ -334,6 +334,8 @@ void ecg_service_start_capture() { // regcache.resp2 = 0x07; // 10 regcache.gpio = 0x0c; // 11 + regcache.ch1set = ADS129X_SET_BITS(regcache.ch1set, ADS129X_GAINx, ADS129X_GAIN_12); + if (m_testmode_flag) { regcache.cfg2 = ADS129X_SET_BITS(regcache.cfg2, ADS129X_INT_TEST, ADS129X_INT_TEST_ON); regcache.cfg2 = ADS129X_SET_BITS(regcache.cfg2, ADS129X_INT_FREQ, ADS129X_INT_FREQ_AC); @@ -371,5 +373,5 @@ void ecg_service_set_report_data_in_raw_mode(bool rawmode) { m_report_data_in_ra bool ecg_leadoff_detect() { // return false; - return ecg_algo_get_leadoff_state(); + return ecg_algo_get_leadoff_state(); } diff --git a/app/src/aproject_config/config.h b/app/src/aproject_config/config.h index 12947d7..4ffc764 100644 --- a/app/src/aproject_config/config.h +++ b/app/src/aproject_config/config.h @@ -7,7 +7,7 @@ #define CATEGORY "M1003" // 单导联 #define MANUFACTURER_NAME "iflytop" -#define FIRMWARE_VERSION (509) +#define FIRMWARE_VERSION (513) #define BLESTACK_VERSION 1 #define BOOTLOADER_VERSION 1 #define HARDWARE_VERSION (2) diff --git a/app/src/one_conduction_main.c b/app/src/one_conduction_main.c index f99e879..ddd53e2 100644 --- a/app/src/one_conduction_main.c +++ b/app/src/one_conduction_main.c @@ -340,6 +340,9 @@ void on_zapp_ebus_event(void* p_event_data, uint16_t event_size) { beep_set_effect(START_SAMPLE_EFFECT); } else if (event == kappevent_state_machine_state_exit) { } else { + zapp_state_machine_change_state(kstate_capture); + +#if 0 if (zble_module_has_disconnected_ms() >= 5000) { ecg_service_stop_capture(); zapp_state_machine_change_state(kstate_standby); @@ -365,6 +368,7 @@ void on_zapp_ebus_event(void* p_event_data, uint16_t event_size) { } } } +#endif } } else if (zapp_state_machine_now_state() == kstate_capture) {