Browse Source

v501

master
zhaohe 1 year ago
parent
commit
1f95c172c9
  1. 2
      app/src/app_basic_service/device_version_info_mgr.c
  2. 31
      app/src/app_service/ecg_service/algo/iflytop_simple_filter.c
  3. 14
      app/src/app_service/ecg_service/algo/iflytop_simple_filter.h
  4. 14
      app/src/app_service/ecg_service/ecg_algo.c
  5. 15
      app/src/app_service/ecg_service/ecg_service.c
  6. 2
      app/src/aproject_config/config.h
  7. 2
      libznordic
  8. 8
      scripter/build_app.bat

2
app/src/app_basic_service/device_version_info_mgr.c

@ -54,7 +54,7 @@ void device_info_read_sn(sn_t *sn) {
uint32_t id = NRF_UICR->CUSTOMER[1];
static char sn_str[15];
if ((lot == 0 && id == 0) || lot == 0xffffffff || id == 0xffffffff) {
sprintf(sn_str, "%s-%s", "IFLYTOP", "TEST");
sprintf(sn_str, "%s%04d%05d", CATEGORY, 0, 0);
} else {
sprintf(sn_str, "%s%04d%05d", CATEGORY, lot, id);
}

31
app/src/app_service/ecg_service/algo/iflytop_simple_filter.c

@ -181,3 +181,34 @@ float median_filter_update(median_filter_t *filter, float val) {
return filter->temp[filter->numVal / 2];
}
}
void SmoothingFilter_Init(SmoothingFilter_t *filter, int windows_size, bool enable) {
if (windows_size > SMOOTHINGFILTER_MAX_SIZE) {
windows_size = SMOOTHINGFILTER_MAX_SIZE;
return;
}
filter->windows_size = windows_size;
filter->datanum = 0;
filter->sum = 0;
filter->datanum = 0;
for (int i = 0; i < windows_size; i++) {
filter->datawindows[i] = 0;
}
filter->data_offset = 0;
filter->enable = enable;
}
float SmoothingFilter_Update(SmoothingFilter_t *filter, float vin) {
if (!filter->enable) return vin;
filter->sum -= filter->datawindows[filter->data_offset];
filter->datawindows[filter->data_offset] = vin;
filter->sum += filter->datawindows[filter->data_offset];
filter->data_offset = (filter->data_offset + 1) % filter->windows_size;
filter->datanum++;
if (filter->datanum > filter->windows_size) {
filter->datanum = filter->windows_size;
}
return filter->sum / filter->datanum;
}

14
app/src/app_service/ecg_service/algo/iflytop_simple_filter.h

@ -80,4 +80,18 @@ typedef struct {
void median_filter_init(median_filter_t *filter, int medianSize);
float median_filter_update(median_filter_t *filter, float val);
#define SMOOTHINGFILTER_MAX_SIZE 50
typedef struct {
float datawindows[SMOOTHINGFILTER_MAX_SIZE];
int windows_size;
int datanum;
int data_offset;
float sum;
bool enable;
} SmoothingFilter_t;
void SmoothingFilter_Init(SmoothingFilter_t *filter, int windows_size, bool enable);
float SmoothingFilter_Update(SmoothingFilter_t *filter, float vin);
#endif

14
app/src/app_service/ecg_service/ecg_algo.c

@ -5,9 +5,10 @@
#include "algo/zsimple_qrs.h"
#include "znordic.h"
LPFilterExt_t m_lp_filter;
HPFilterExt_t m_hp_filter;
NOTCHFilterExt_t m_notch_filter;
LPFilterExt_t m_lp_filter;
HPFilterExt_t m_hp_filter;
NOTCHFilterExt_t m_notch_filter;
SmoothingFilter_t m_smoothingFilter;
int32_t m_data_statistics_buf[STATISTICS_BUF_SIZE]; // ÐÄÂÊÅÐÏ
zdata_statistics_t m_data_statistics;
@ -33,6 +34,7 @@ void ecg_algo_process_data(int32_t indata) {
data = LPFilterExt_update(&m_lp_filter, data);
data = NOTCHFilterExt_update(&m_notch_filter, data);
data = SmoothingFilter_Update(&m_smoothingFilter, data);
reportdata = data;
zdata_statistics_push(&m_data_statistics, data);
@ -57,9 +59,11 @@ void ecg_algo_process_data(int32_t indata) {
}
}
void ecg_algo_reset() {
LPFilterExt_init(&m_lp_filter, 40, SAMPLE_PERIOD_S, 13, true);
LPFilterExt_init(&m_lp_filter, 40, SAMPLE_PERIOD_S, 5, true);
HPFilterExt_init(&m_hp_filter, 1, SAMPLE_PERIOD_S, 1, true);
NOTCHFilterExt_init(&m_notch_filter, 50, 10, SAMPLE_PERIOD_S, 3, false);
NOTCHFilterExt_init(&m_notch_filter, 125, 2, SAMPLE_PERIOD_S, 2, true);
SmoothingFilter_Init(&m_smoothingFilter, 8, true);
zdata_statistics_clear(&m_data_statistics);
zsimple_qrs_clear();
}

15
app/src/app_service/ecg_service/ecg_service.c

@ -207,14 +207,15 @@ static void leadoff_state_process(ads129x_capture_data_t* capture_data) {
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 (ecg_algo_get_data_after_high_pass_filter_data() > 25000 || ecg_algo_get_data_after_high_pass_filter_data() < -25000) {
// 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;

2
app/src/aproject_config/config.h

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

2
libznordic

@ -1 +1 @@
Subproject commit 6fb5f63c43ea9866bef9eacd918ddd00468fa4f6
Subproject commit 87862e2d0f9e5d1e412ea2cd62b0ff90bdff7ec8

8
scripter/build_app.bat

@ -6,8 +6,8 @@ call scripter\keil_build.bat app\app.uvprojx app\_build\app.hex
del output\app_whole.hex
del output\app.zip
del output\one_lead_ecg.zip
del output\one_lead_ecg.hex
del output\one_lead_ecg_ads1291.zip
del output\one_lead_ecg_ads1291.hex
@REM 检查是否编译成功
if not exist app\_build\app.hex (
@ -59,5 +59,5 @@ del output\settings.hex
del output\app.hex
copy /y output\app.zip output\one_lead_ecg.zip
copy /y output\app_whole.hex output\one_lead_ecg.hex
copy /y output\app.zip output\one_lead_ecg_ads1291.zip
copy /y output\app_whole.hex output\one_lead_ecg_ads1291.hex
Loading…
Cancel
Save