Skip to content

Commit

Permalink
Merge pull request #1 from pilotak/dev
Browse files Browse the repository at this point in the history
travis fix
  • Loading branch information
pilotak authored Sep 15, 2018
2 parents 6afd7d1 + 95b25e5 commit bb28bab
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 43 deletions.
21 changes: 14 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
55 changes: 28 additions & 27 deletions MovingAverageAngle.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,37 @@ SOFTWARE.
#define MOVINGAVERAGEANGLE_H

#if defined(__MBED__)
#include "mbed.h"
#include "MovingAverageFloat.h"
#include "mbed.h"
#endif

#include <math.h>
#include <MovingAverageFloat.h>

#define PI 3.141592653589793238463

template <uint8_t N>
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 <N> _filterSin;
MovingAverageFloat <N> _filterCos;
private:
MovingAverageFloat <N> _filterSin;
MovingAverageFloat <N> _filterCos;

float toRadian(float value);
float toRadian(float value);

float _result;
float _result;
};

template <uint8_t N>
MovingAverageAngle<N>::MovingAverageAngle() {
_result = 0;
_result = 0;
}

template <uint8_t N>
Expand All @@ -65,37 +65,38 @@ MovingAverageAngle<N>::~MovingAverageAngle(void) {

template <uint8_t N>
float MovingAverageAngle<N>::get() {
return _result;
return _result;
}

template <uint8_t N>
float MovingAverageAngle<N>::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 <uint8_t N>
void MovingAverageAngle<N>::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 <uint8_t N>
void MovingAverageAngle<N>::reset() {
_filterSin.reset();
_filterCos.reset();
_filterSin.reset();
_filterCos.reset();
}

template <uint8_t N>
float MovingAverageAngle<N>::toRadian(float value) {
return 2.0 * PI * (value / 360.0);
return 2.0 * PI * (value / 360.0);
}

#endif
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion examples/MovingAverageAngle/MovingAverageAngle.ino
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 4 additions & 6 deletions library.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ maintainer=Pavel Slama <[email protected]>
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=*

0 comments on commit bb28bab

Please sign in to comment.