Browse Source

添加心率显示动态放大

master
zhaohe 1 year ago
parent
commit
4b8ed8cc7d
  1. 5
      app/src/basic/qrs_time_domain_zh.c
  2. 3
      app/src/basic/qrs_time_domain_zh.h
  3. 8
      app/src/display_manager.c
  4. 26
      app/src/heart_wave_sample_service.c

5
app/src/basic/qrs_time_domain_zh.c

@ -153,7 +153,6 @@ void QRS_resetBuf() { //
HeartRateMeanFilter_reset();
}
void QRS_processData(uint16_t _data) {
uint16_t data = pQRS_median_filter(_data);
/*******************************************************************************
@ -215,4 +214,6 @@ void QRS_processData(uint16_t _data) {
}
}
}
uint16_t QRS_getHeartRate() { return m_heartrate; }
uint16_t QRS_getHeartRate() { return m_heartrate; }
uint16_t QRS_getMaxValueLastVal() { return m_max_val_in_m_data; }

3
app/src/basic/qrs_time_domain_zh.h

@ -10,8 +10,9 @@
*/
#pragma once
#include <stdint.h>
#define TABLE_SIZE 500
#define TABLE_SIZE 1000
void QRS_resetBuf();
void QRS_processData(uint16_t data);
uint16_t QRS_getHeartRate();
uint16_t QRS_getMaxValueLastVal();

8
app/src/display_manager.c

@ -282,7 +282,7 @@ void dsp_mgr_change_to_sampling(int progress_s, int heartrate) { //
sample_page_state_t* sps = &m_sample_page_state;
sps->progress_x = SMAPLE_PAGE_START_X + 10;
sps->progress_y = SMAPLE_PAGE_START_Y + 2;
sps->progress_y = SMAPLE_PAGE_START_Y + 3;
sps->progress_width = 100;
sps->progress_hight = 8;
@ -291,7 +291,7 @@ void dsp_mgr_change_to_sampling(int progress_s, int heartrate) { //
sps->wave_drawser_hight = 45;
sps->wave_drawser_width = 90;
sps->heartrate_x = sps->wave_drawser_x + sps->wave_drawser_width + 5;
sps->heartrate_x = sps->wave_drawser_x + sps->wave_drawser_width + 2;
sps->heartrate_y = sps->wave_drawser_y + 5;
int progress = progress_s / SAMPLE_MIN_TIME_S * 25;
@ -360,7 +360,7 @@ void samplePage_schedule() {
int wave_y = (int)hwss_read_val();
int heartrate = (int)hwss_read_heart_rate();
// ZLOGI("samplePage_schedule %d %d %d", capturetime, wave_y, heartrate);
samplePage_update_state(capturetime / 1000, wave_y, hwss_read_heart_rate(), count % 30 == 0, count % 5 == 0);
samplePage_update_state(capturetime / 1000, wave_y, hwss_read_heart_rate(), count % 30 == 0, count % 10 == 0);
}
/*******************************************************************************
@ -435,7 +435,7 @@ void dsp_mgr_init(void) {
ZERROR_CHECK(app_timer_create(&m_dsp_mgr_schedule_tmr, APP_TIMER_MODE_REPEATED, dsp_mgr_schedule_tmr_cb));
}
//
ZERROR_CHECK(app_timer_start(m_dsp_mgr_schedule_tmr, APP_TIMER_TICKS(25), NULL));
ZERROR_CHECK(app_timer_start(m_dsp_mgr_schedule_tmr, APP_TIMER_TICKS(12), NULL));
timer_inited = true;
}
void dsp_mgr_uninit(void) {

26
app/src/heart_wave_sample_service.c

@ -94,16 +94,38 @@ static inline void prvf_light_block_trigger_event() {
AppEvent_pushEvent(&event);
}
// QRS_getMaxValueLastVal();
uint16_t getRecommendedMagnification() {
// return 0;
uint16_t max = QRS_getMaxValueLastVal();
if (max == 0) {
return 1;
}
// 3750.0f
if (max <= (3750 / 2)) {
return 10;
}
float af = (3750 / 2) / (max - 3750 / 2);
if (af > 10) {
return 10;
}
return af;
}
void nrfx_timer_event_handler(nrf_timer_event_t event_type, void* p_context) { //
uint16_t val = BoardEcgSensor_plod_get_ecg_val(); // 12bit
/*******************************************************************************
* *
*******************************************************************************/
// QRS_getMaxValueLastVal();
QRS_processData(val);
float val_af100 = (float)val / 4096.0f * 100;
float val_af100 = (float)val / 3750.0f * 100; // 3.6v,3.3v
m_frame_index++;
val_af100 = amp_val(val_af100, 45, 3.5f);
val_af100 = amp_val(val_af100, 50, getRecommendedMagnification());
val_af100 = Filter(&m_filter, val_af100);
m_sensor_display_data = val_af100;

Loading…
Cancel
Save