Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed PulseSensor mbed-rtos LSM9DS1_Library_cal
stepcounter.h
00001 #ifndef __STEPCOUNTER_H__ 00002 #define __STEPCOUNTER_H__ 00003 00004 #include "stdint.h" 00005 #include "math.h" 00006 00007 #define FILTER_CNT 3 00008 00009 #define MAX(a, b) ((a) > (b) ? (a) : (b)) 00010 #define MIN(a, b) ((a) < (b) ? (a) : (b)) 00011 #define SAMPLE_SIZE 10 00012 00013 #define ABS(a) (0 - (a)) > 0 ? (-(a)) : (a) 00014 #define DYNAMIC_PRECISION 60 00015 00016 #define MOST_ACTIVE_NULL 0 00017 #define MOST_ACTIVE_X 1 00018 #define MOST_ACTIVE_Y 2 00019 #define MOST_ACTIVE_Z 3 00020 00021 #define ACTIVE_PRECISION 120 00022 00023 #define DATA_FACTOR 1000 00024 00025 typedef struct 00026 { 00027 short x; 00028 short y; 00029 short z; 00030 } axis_info_t; 00031 00032 typedef struct 00033 { 00034 axis_info_t newmax; 00035 axis_info_t newmin; 00036 axis_info_t oldmax; 00037 axis_info_t oldmin; 00038 } peak_value_t; 00039 00040 typedef struct filter_avg 00041 { 00042 axis_info_t info[FILTER_CNT]; 00043 unsigned char count; 00044 } filter_avg_t; 00045 00046 00047 00048 typedef struct slid_reg 00049 { 00050 axis_info_t new_sample; 00051 axis_info_t old_sample; 00052 } slid_reg_t; 00053 00054 00055 00056 void filter_calculate(filter_avg_t *filter, axis_info_t *sample); 00057 void peak_value_init(peak_value_t *peak); 00058 void peak_update(peak_value_t *peak, axis_info_t *cur_sample); 00059 char slid_update(slid_reg_t *slid, axis_info_t *cur_sample); 00060 char is_most_active(peak_value_t *peak); 00061 void detect_step(peak_value_t *peak, slid_reg_t *slid, axis_info_t *cur_sample); 00062 uint8_t get_step(); 00063 00064 #endif
Generated on Thu Jul 21 2022 04:56:30 by
1.7.2