zhaohe 1 year ago
parent
commit
384a8d3eaf
  1. 4
      README.md
  2. 6
      app/src/basic/qrs_time_domain_zh.c
  3. 1
      app/src/basic/qrs_time_domain_zh.h
  4. 2
      app/src/basic/version.h
  5. 16
      app/src/board/board_battery_state.c
  6. 42
      app/src/heart_wave_sample_service.c
  7. 16713
      release/V6/one_lead_ecg_v6.hex
  8. BIN
      release/V6/one_lead_ecg_v6.zip

4
README.md

@ -13,6 +13,10 @@ V5:
1. 在系统启动的初期就初始化看门狗
2. 优化静态功耗到300ua
V6:
1. 优化显示心电波形效果
2. 优化电池电量显示
TODO
0. 支持无线升级,修改SN码 OK
6. 开始采集蜂鸣器响响一声,结束采集蜂鸣器响一声 OK

6
app/src/basic/qrs_time_domain_zh.c

@ -224,4 +224,8 @@ uint16_t QRS_getHeartRate() {
return heartrate;
}
uint16_t QRS_getMaxValueLastVal() { return m_max_val_in_m_data; }
uint16_t QRS_getMaxValueLastVal() { return m_max_val_in_m_data; }
uint16_t QRS_getAvgValueVal() { //
return m_avg;
}

1
app/src/basic/qrs_time_domain_zh.h

@ -16,3 +16,4 @@ void QRS_resetBuf();
void QRS_processData(uint16_t data);
uint16_t QRS_getHeartRate();
uint16_t QRS_getMaxValueLastVal();
uint16_t QRS_getAvgValueVal();

2
app/src/basic/version.h

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

16
app/src/board/board_battery_state.c

@ -47,6 +47,19 @@ int16_t BoardBattery_get_adc_val() {
int16_t BoardBattery_get_charging_state() { //
return !nrf_gpio_pin_read(BATTERY_CHARGE_DETECT_PIN);
}
static int16_t battery_level_filter(int16_t nowlevel) {
static int16_t lastlevel = 0;
if (abs(nowlevel - lastlevel) >= 5) {
lastlevel = nowlevel;
} else if (nowlevel >= 95) {
lastlevel = 100;
} else if (nowlevel <= 5) {
lastlevel = nowlevel;
}
return lastlevel;
}
int16_t BoardBattery_get_battery_level() {
static const float maxv = 4.15;
static const float minv = 3.5;
@ -64,5 +77,6 @@ int16_t BoardBattery_get_battery_level() {
} else if (percent_int > 100) {
percent_int = 100;
}
return percent_int;
return battery_level_filter(percent_int);
// return percent_int;
}

42
app/src/heart_wave_sample_service.c

@ -57,14 +57,40 @@ typedef struct {
float efectiveFactor;
} filter_t;
typedef struct {
float coef[2];
float v_out[2];
} LPFilter;
#define PI 3.14159265358979323846f
filter_t m_filter = {0, 0.8};
LPFilter m_lpfilter_01;
LPFilter m_lpfilter_02;
static float Filter(filter_t* filter, float newInput) {
float newv = ((float)filter->value * (1.0f - filter->efectiveFactor)) + ((float)newInput * filter->efectiveFactor);
filter->value = newv;
return newv;
}
void LPFilter_Init(LPFilter* filter, float cutoffFreqHz, float sampleTimeS) {
float RC = 0.0;
RC = 1.0 / (2 * PI * cutoffFreqHz);
filter->coef[0] = sampleTimeS / (sampleTimeS + RC);
filter->coef[1] = RC / (sampleTimeS + RC);
filter->v_out[0] = 0.0;
filter->v_out[1] = 0.0;
}
float LPFilter_Update(LPFilter* filter, float v_in) {
filter->v_out[1] = filter->v_out[0];
filter->v_out[0] = (filter->coef[0] * v_in) + (filter->coef[1] * filter->v_out[1]);
return (filter->v_out[0]);
}
/*******************************************************************************
* *
*******************************************************************************/
@ -104,11 +130,11 @@ uint16_t getRecommendedMagnification() {
}
// 3750.0f
if (max <= (3750 / 2)) {
return 10;
return 15;
}
float af = (3750 / 2) / (max - 3750 / 2);
if (af > 10) {
return 10;
if (af > 15) {
return 15;
}
return af;
}
@ -121,12 +147,12 @@ void nrfx_timer_event_handler(nrf_timer_event_t event_type, void* p_context) {
*******************************************************************************/
// QRS_getMaxValueLastVal();
QRS_processData(val);
float val_af100 = (float)val / 3750.0f * 100; // 3.6v,3.3v
int16_t lowpassf_val = LPFilter_Update(&m_lpfilter_01, val);
QRS_processData(lowpassf_val);
float val_af100 = (float)lowpassf_val / 3750.0f * 100; // 3.6v,3.3v
m_frame_index++;
val_af100 = amp_val(val_af100, 50, getRecommendedMagnification());
val_af100 = Filter(&m_filter, val_af100);
val_af100 = LPFilter_Update(&m_lpfilter_02, val_af100);
m_sensor_display_data = val_af100;
/*******************************************************************************
@ -189,6 +215,8 @@ void hwss_start_capture(void) {
m_start_capture_tp = znordic_getpower_on_s();
swap_buffer();
m_frame_index = 0;
LPFilter_Init(&m_lpfilter_01, 15, 0.002);
LPFilter_Init(&m_lpfilter_02, 15, 0.002);
QRS_resetBuf();

16713
release/V6/one_lead_ecg_v6.hex
File diff suppressed because it is too large
View File

BIN
release/V6/one_lead_ecg_v6.zip

Loading…
Cancel
Save