49 lines
1.5 KiB
C
49 lines
1.5 KiB
C
|
|
#ifndef ECG_GENERATOR_H
|
|||
|
|
#define ECG_GENERATOR_H
|
|||
|
|
|
|||
|
|
#include <stdint.h>
|
|||
|
|
#include <stdbool.h>
|
|||
|
|
|
|||
|
|
#ifdef __cplusplus
|
|||
|
|
extern "C" {
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
// ECG生成器结构体
|
|||
|
|
typedef struct {
|
|||
|
|
// 用户可调参数
|
|||
|
|
float heart_rate; // 心率 (次/分)
|
|||
|
|
float amplitude; // 幅值 (V)
|
|||
|
|
|
|||
|
|
// 内部状态
|
|||
|
|
uint32_t sample_count; // 样本计数器
|
|||
|
|
float sample_rate; // 采样率 (Hz)
|
|||
|
|
bool is_running; // 是否正在运行
|
|||
|
|
|
|||
|
|
// 固定波形参数 (保持正常ECG比例)
|
|||
|
|
float p_amp_ratio; // P波幅度比例
|
|||
|
|
float q_amp_ratio; // Q波幅度比例
|
|||
|
|
float r_amp_ratio; // R波幅度比例
|
|||
|
|
float s_amp_ratio; // S波幅度比例
|
|||
|
|
float t_amp_ratio; // T波幅度比例
|
|||
|
|
|
|||
|
|
// 固定时间参数 (保持正常ECG时序)
|
|||
|
|
float p_width; // P波宽度
|
|||
|
|
float qrs_width; // QRS波群宽度
|
|||
|
|
float t_width; // T波宽度
|
|||
|
|
} ecg_generator_t;
|
|||
|
|
|
|||
|
|
// 函数声明
|
|||
|
|
void ecg_generator_init(ecg_generator_t *generator, float sample_rate);
|
|||
|
|
void ecg_generator_set_heart_rate(ecg_generator_t *generator, float heart_rate);
|
|||
|
|
void ecg_generator_set_amplitude(ecg_generator_t *generator, float amplitude_mv); // 直接输入mV值,内部自动转换
|
|||
|
|
void ecg_generator_start(ecg_generator_t *generator);
|
|||
|
|
void ecg_generator_stop(ecg_generator_t *generator);
|
|||
|
|
void ecg_generator_reset(ecg_generator_t *generator);
|
|||
|
|
float ecg_generator_get_next_sample(ecg_generator_t *generator);
|
|||
|
|
|
|||
|
|
#ifdef __cplusplus
|
|||
|
|
}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#endif // ECG_GENERATOR_H
|