You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.3 KiB

  1. #ifndef __HC_CHEN__
  2. #define __HC_CHEN__
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <stdbool.h>
  6. #include <math.h>
  7. #include <stdint.h>
  8. #include "QRS.h"
  9. #define M 9
  10. #define N 54//SAMPLING_RATE * 0.15f
  11. static const uint32_t window_size = SAMPLING_RATE;
  12. static const float HP_CONSTANT = ((float) 1.0f / (float) M);
  13. // circular buffer for input ecg signal
  14. // we need to keep a history of M + 1 samples for HP filter
  15. static float ecg_buff[M + 1] = {0};
  16. static int ecg_buff_WR_idx = 0;
  17. static int ecg_buff_RD_idx = 0;
  18. // circular buffer for input ecg signal
  19. // we need to keep a history of N+1 samples for LP filter
  20. static float hp_buff[N + 1] = {0};
  21. static int hp_buff_WR_idx = 0;
  22. static int hp_buff_RD_idx = 0;
  23. // LP filter outputs a single point for every input point
  24. // This goes straight to adaptive filtering for eval
  25. static float next_eval_pt = 0;
  26. // running sums for HP and LP filters, values shifted in FILO
  27. static float hp_sum = 0;
  28. static float lp_sum = 0;
  29. // parameters for adaptive thresholding
  30. static float treshold = 0;
  31. static bool triggered = false;
  32. static int trig_time = 0;
  33. static float win_max = 0;
  34. static int win_idx = 0;
  35. static int number_iter = 0;
  36. static int sample = 0;
  37. static int last_qrs_point = 0;
  38. static const int DELAY_TIME = 180;//window_size * 0.5f;
  39. extern bool HC_Chen_detect(float);
  40. #endif