ECE 4180 Final Project

Dependencies:   mbed PulseSensor mbed-rtos LSM9DS1_Library_cal

Committer:
zhihanzhang
Date:
Thu Dec 02 18:46:01 2021 +0000
Revision:
9:dcbd546412ea
Parent:
8:2d43385e7784
Child:
10:63d223104806
12/2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yutation 7:88d71c228407 1 #ifndef __STEPCOUNTER_H__
yutation 7:88d71c228407 2 #define __STEPCOUNTER_H__
zhihanzhang 9:dcbd546412ea 3
yutation 7:88d71c228407 4 #include "stdint.h"
yutation 7:88d71c228407 5 #include "math.h"
zhihanzhang 9:dcbd546412ea 6
yutation 7:88d71c228407 7 #define FILTER_CNT 3
zhihanzhang 9:dcbd546412ea 8
yutation 7:88d71c228407 9 #define MAX(a, b) ((a) > (b) ? (a) : (b))
yutation 7:88d71c228407 10 #define MIN(a, b) ((a) < (b) ? (a) : (b))
yutation 7:88d71c228407 11 #define SAMPLE_SIZE 10
zhihanzhang 9:dcbd546412ea 12
yutation 7:88d71c228407 13 #define ABS(a) (0 - (a)) > 0 ? (-(a)) : (a)
yutation 7:88d71c228407 14 #define DYNAMIC_PRECISION 30
zhihanzhang 9:dcbd546412ea 15
yutation 7:88d71c228407 16 #define MOST_ACTIVE_NULL 0
yutation 7:88d71c228407 17 #define MOST_ACTIVE_X 1
yutation 7:88d71c228407 18 #define MOST_ACTIVE_Y 2
yutation 7:88d71c228407 19 #define MOST_ACTIVE_Z 3
zhihanzhang 9:dcbd546412ea 20
yutation 7:88d71c228407 21 #define ACTIVE_PRECISION 6
zhihanzhang 9:dcbd546412ea 22
yutation 7:88d71c228407 23 #define DATA_FACTOR 1000
zhihanzhang 9:dcbd546412ea 24
yutation 7:88d71c228407 25 typedef struct
yutation 7:88d71c228407 26 {
yutation 7:88d71c228407 27 short x;
yutation 7:88d71c228407 28 short y;
yutation 7:88d71c228407 29 short z;
yutation 7:88d71c228407 30 } axis_info_t;
zhihanzhang 9:dcbd546412ea 31
yutation 7:88d71c228407 32 typedef struct
yutation 7:88d71c228407 33 {
yutation 7:88d71c228407 34 axis_info_t newmax;
yutation 7:88d71c228407 35 axis_info_t newmin;
yutation 7:88d71c228407 36 axis_info_t oldmax;
yutation 7:88d71c228407 37 axis_info_t oldmin;
yutation 7:88d71c228407 38 } peak_value_t;
zhihanzhang 9:dcbd546412ea 39
yutation 7:88d71c228407 40 typedef struct filter_avg
yutation 7:88d71c228407 41 {
yutation 7:88d71c228407 42 axis_info_t info[FILTER_CNT];
yutation 7:88d71c228407 43 unsigned char count;
yutation 7:88d71c228407 44 } filter_avg_t;
zhihanzhang 9:dcbd546412ea 45
zhihanzhang 9:dcbd546412ea 46
zhihanzhang 9:dcbd546412ea 47
yutation 7:88d71c228407 48 typedef struct slid_reg
yutation 7:88d71c228407 49 {
yutation 7:88d71c228407 50 axis_info_t new_sample;
yutation 7:88d71c228407 51 axis_info_t old_sample;
yutation 7:88d71c228407 52 } slid_reg_t;
zhihanzhang 9:dcbd546412ea 53
zhihanzhang 9:dcbd546412ea 54
zhihanzhang 9:dcbd546412ea 55
yutation 7:88d71c228407 56 void filter_calculate(filter_avg_t *filter, axis_info_t *sample);
yutation 7:88d71c228407 57 void peak_value_init(peak_value_t *peak);
yutation 7:88d71c228407 58 void peak_update(peak_value_t *peak, axis_info_t *cur_sample);
yutation 7:88d71c228407 59 char slid_update(slid_reg_t *slid, axis_info_t *cur_sample);
yutation 7:88d71c228407 60 char is_most_active(peak_value_t *peak);
yutation 7:88d71c228407 61 void detect_step(peak_value_t *peak, slid_reg_t *slid, axis_info_t *cur_sample);
yutation 8:2d43385e7784 62 uint8_t get_step();
zhihanzhang 9:dcbd546412ea 63
yutation 7:88d71c228407 64 #endif