diff --git a/.travis.yml b/.travis.yml index cbfedc9..60a52a6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,18 +1,25 @@ language: python python: - - "2.7" + - "2.7" sudo: false cache: - directories: - - "~/.platformio" + directories: + - "~/.platformio" env: - - PLATFORMIO_CI_SRC=examples/MovingAverageAngle + - PLATFORMIO_CI_SRC=examples/MovingAverageAngle install: - - pip install -U platformio - - platformio update + - pip install -U platformio + - platformio update + - platformio lib -g install 1383 script: - - platformio ci --lib="." --board=uno --board=zero --board=esp01_1m + - platformio ci --lib="." --board=uno --board=zero --board=esp01_1m + + +notifications: + email: + on_success: change + on_failure: change diff --git a/MovingAverageAngle.h b/MovingAverageAngle.h index e21c579..38177c7 100644 --- a/MovingAverageAngle.h +++ b/MovingAverageAngle.h @@ -26,37 +26,37 @@ SOFTWARE. #define MOVINGAVERAGEANGLE_H #if defined(__MBED__) -#include "mbed.h" -#include "MovingAverageFloat.h" + #include "mbed.h" #endif #include +#include #define PI 3.141592653589793238463 template class MovingAverageAngle { - public: - MovingAverageAngle(); - virtual ~MovingAverageAngle(void); + public: + MovingAverageAngle(); + virtual ~MovingAverageAngle(void); - float add(float value); - float get(); - void fill(float value); - void reset(); + float add(float value); + float get(); + void fill(float value); + void reset(); - private: - MovingAverageFloat _filterSin; - MovingAverageFloat _filterCos; + private: + MovingAverageFloat _filterSin; + MovingAverageFloat _filterCos; - float toRadian(float value); + float toRadian(float value); - float _result; + float _result; }; template MovingAverageAngle::MovingAverageAngle() { - _result = 0; + _result = 0; } template @@ -65,37 +65,38 @@ MovingAverageAngle::~MovingAverageAngle(void) { template float MovingAverageAngle::get() { - return _result; + return _result; } template float MovingAverageAngle::add(float value) { - float radian = toRadian(value); - float deg = atan2(_filterSin.add(sin(radian)), _filterCos.add(cos(radian))) * (180.0 / PI); + float radian = toRadian(value); + float deg = atan2(_filterSin.add(sin(radian)), _filterCos.add(cos(radian))) * (180.0 / PI); - if (deg < 0) deg += 360.0; - _result = deg; + if (deg < 0) deg += 360.0; - return _result; + _result = deg; + + return _result; } template void MovingAverageAngle::fill(float value) { - float radian = toRadian(value); + float radian = toRadian(value); - _filterSin.fill(sin(radian)); - _filterCos.fill(cos(radian)); + _filterSin.fill(sin(radian)); + _filterCos.fill(cos(radian)); } template void MovingAverageAngle::reset() { - _filterSin.reset(); - _filterCos.reset(); + _filterSin.reset(); + _filterCos.reset(); } template float MovingAverageAngle::toRadian(float value) { - return 2.0 * PI * (value / 360.0); + return 2.0 * PI * (value / 360.0); } #endif diff --git a/README.md b/README.md index a44c9e6..b11ce86 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,6 @@ int main() { ``` ## Arduino example ```cpp -#include "MovingAverageFloat.h" // https://github.com/pilotak/MovingAverageFloat #include "MovingAverageAngle.h" // https://github.com/pilotak/MovingAverageAngle // Buffer will be 4 samples long, it will take 4 * sizeof(float) = 16 bytes of RAM diff --git a/examples/MovingAverageAngle/MovingAverageAngle.ino b/examples/MovingAverageAngle/MovingAverageAngle.ino index a10a92a..7ee81c9 100644 --- a/examples/MovingAverageAngle/MovingAverageAngle.ino +++ b/examples/MovingAverageAngle/MovingAverageAngle.ino @@ -1,4 +1,3 @@ -#include "MovingAverageFloat.h" // https://github.com/pilotak/MovingAverageFloat #include "MovingAverageAngle.h" // https://github.com/pilotak/MovingAverageAngle // Buffer will be 4 samples long, it will take 4 * sizeof(float) = 16 bytes of RAM diff --git a/library.json b/library.json index 626aeb0..bda228c 100644 --- a/library.json +++ b/library.json @@ -14,12 +14,10 @@ "url": "https://github.com/pilotak" }, "dependencies": - [ - { - "name": "MovingAverageFloat", - "version": "https://github.com/pilotak/MovingAverageFloat.git#1.0.0" - } - ], + { + "name": "MovingAverageFloat", + "version": "^1.0.0" + }, "version": "1.0.0", "frameworks": "arduino, mbed" } \ No newline at end of file diff --git a/library.properties b/library.properties index 098d625..f89738d 100644 --- a/library.properties +++ b/library.properties @@ -4,7 +4,7 @@ maintainer=Pavel Slama sentence=Arduino & Mbed Library for averaging angles 0-360° paragraph= url=https://github.com/pilotak/MovingAverageAngle -includes=MovingAverageFloat.h,MovingAverageAngle.h +includes=MovingAverageAngle.h category=Signal Input/Output version=1.0.0 architectures=*