Bruno Allaire-Lemay
/
APP1test
df
Fork of APP1 by
Utility.hpp@23:2531e72d92b9, 2017-02-09 (annotated)
- Committer:
- GaiSensei
- Date:
- Thu Feb 09 15:55:18 2017 +0000
- Revision:
- 23:2531e72d92b9
- Parent:
- 21:a111be2582be
gh
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dupm2216 | 21:a111be2582be | 1 | ///////////////////////////////////////////////////////////// |
dupm2216 | 21:a111be2582be | 2 | // APP 1: Systèmes à microprocesseurs // |
dupm2216 | 21:a111be2582be | 3 | // // |
dupm2216 | 21:a111be2582be | 4 | // Université de Sherbrooke // |
dupm2216 | 21:a111be2582be | 5 | // Génie informatique // |
dupm2216 | 21:a111be2582be | 6 | // Session 5, Hiver 2017 // |
dupm2216 | 21:a111be2582be | 7 | // // |
dupm2216 | 21:a111be2582be | 8 | // Date: 17 janvier 2017 // |
dupm2216 | 21:a111be2582be | 9 | // // |
dupm2216 | 21:a111be2582be | 10 | // Auteurs: Maxime Dupuis, dupm2216 // |
dupm2216 | 21:a111be2582be | 11 | // Bruno Allaire-Lemay, allb2701 // |
dupm2216 | 21:a111be2582be | 12 | ///////////////////////////////////////////////////////////// |
dupm2216 | 21:a111be2582be | 13 | |
dupm2216 | 6:3facf0329142 | 14 | #ifndef UTILITY_HPP |
dupm2216 | 6:3facf0329142 | 15 | #define UTILITY_HPP |
dupm2216 | 18:a21199781d20 | 16 | #include <list> |
dupm2216 | 6:3facf0329142 | 17 | |
dupm2216 | 6:3facf0329142 | 18 | namespace utility |
dupm2216 | 6:3facf0329142 | 19 | { |
dupm2216 | 18:a21199781d20 | 20 | const double PI = 3.14159265; |
dupm2216 | 6:3facf0329142 | 21 | |
dupm2216 | 6:3facf0329142 | 22 | bool is_almost_equal(double a, double b, double tolerance); |
dupm2216 | 6:3facf0329142 | 23 | |
dupm2216 | 6:3facf0329142 | 24 | //Return angle between 0 and 360 degree |
dupm2216 | 6:3facf0329142 | 25 | double wrap_angle(double angle); |
dupm2216 | 6:3facf0329142 | 26 | double degree_from_radian(const double angle_radian); |
GaiSensei | 12:1c341b119b23 | 27 | |
GaiSensei | 12:1c341b119b23 | 28 | //Calculate the 4 bytes required to represent a previous 4 bytes value |
GaiSensei | 12:1c341b119b23 | 29 | //after changing a single bit at a given position (position 0 being the LSB) |
GaiSensei | 13:bb9669053eb3 | 30 | unsigned int update_bit(const unsigned int previous_4_bytes, const int position, const bool new_bit_value); |
GaiSensei | 13:bb9669053eb3 | 31 | |
dupm2216 | 15:b38d9d210e32 | 32 | 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 | 33 | //Hang the program and blink an LED on the mbed |
dupm2216 | 15:b38d9d210e32 | 34 | void blink(); |
dupm2216 | 18:a21199781d20 | 35 | |
dupm2216 | 18:a21199781d20 | 36 | class MovingAverageFilter |
dupm2216 | 18:a21199781d20 | 37 | { |
dupm2216 | 18:a21199781d20 | 38 | public: |
dupm2216 | 18:a21199781d20 | 39 | MovingAverageFilter(const int subSize); |
dupm2216 | 18:a21199781d20 | 40 | int calculate(int newValue); |
dupm2216 | 18:a21199781d20 | 41 | |
dupm2216 | 18:a21199781d20 | 42 | private: |
dupm2216 | 18:a21199781d20 | 43 | const int subsetSize; |
dupm2216 | 18:a21199781d20 | 44 | std::list<int> subset; |
dupm2216 | 18:a21199781d20 | 45 | }; |
dupm2216 | 9:12519f9dd3cd | 46 | } |
dupm2216 | 6:3facf0329142 | 47 | |
dupm2216 | 6:3facf0329142 | 48 | #endif |