df

Dependencies:   mbed

Fork of APP1 by Team APP

Committer:
dupm2216
Date:
Tue Jan 17 19:45:02 2017 +0000
Revision:
18:a21199781d20
Parent:
15:b38d9d210e32
Child:
21:a111be2582be
Add MovingAverageFilter

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dupm2216 6:3facf0329142 1 #ifndef UTILITY_HPP
dupm2216 6:3facf0329142 2 #define UTILITY_HPP
dupm2216 18:a21199781d20 3 #include <list>
dupm2216 6:3facf0329142 4
dupm2216 6:3facf0329142 5 namespace utility
dupm2216 6:3facf0329142 6 {
dupm2216 18:a21199781d20 7 const double PI = 3.14159265;
dupm2216 6:3facf0329142 8
dupm2216 6:3facf0329142 9 bool is_almost_equal(double a, double b, double tolerance);
dupm2216 6:3facf0329142 10
dupm2216 6:3facf0329142 11 //Return angle between 0 and 360 degree
dupm2216 6:3facf0329142 12 double wrap_angle(double angle);
dupm2216 6:3facf0329142 13 double degree_from_radian(const double angle_radian);
GaiSensei 12:1c341b119b23 14
GaiSensei 12:1c341b119b23 15 //Calculate the 4 bytes required to represent a previous 4 bytes value
GaiSensei 12:1c341b119b23 16 //after changing a single bit at a given position (position 0 being the LSB)
GaiSensei 13:bb9669053eb3 17 unsigned int update_bit(const unsigned int previous_4_bytes, const int position, const bool new_bit_value);
GaiSensei 13:bb9669053eb3 18
dupm2216 15:b38d9d210e32 19 unsigned int update_bits(const unsigned int previous_4_bytes, const int start_bit, const int stop_bit, const unsigned int reserved_bits_mask, const unsigned int new_bits_value);
dupm2216 15:b38d9d210e32 20 //Hang the program and blink an LED on the mbed
dupm2216 15:b38d9d210e32 21 void blink();
dupm2216 18:a21199781d20 22
dupm2216 18:a21199781d20 23 class MovingAverageFilter
dupm2216 18:a21199781d20 24 {
dupm2216 18:a21199781d20 25 public:
dupm2216 18:a21199781d20 26 MovingAverageFilter(const int subSize);
dupm2216 18:a21199781d20 27 int calculate(int newValue);
dupm2216 18:a21199781d20 28
dupm2216 18:a21199781d20 29 private:
dupm2216 18:a21199781d20 30 const int subsetSize;
dupm2216 18:a21199781d20 31 std::list<int> subset;
dupm2216 18:a21199781d20 32 };
dupm2216 9:12519f9dd3cd 33 }
dupm2216 6:3facf0329142 34
dupm2216 6:3facf0329142 35 #endif