GY-63_MS5611/libraries/AverageAngle/AverageAngle.h

40 lines
743 B
C
Raw Normal View History

2020-11-27 05:10:47 -05:00
#pragma once
2017-12-09 12:23:18 -05:00
//
// FILE: AverageAngle.h
// AUTHOR: Rob dot Tillaart at gmail dot com
2021-01-29 06:31:58 -05:00
// VERSION: 0.1.5
// PURPOSE: class for averaging angles.
2017-12-09 12:23:18 -05:00
// HISTORY: See AverageAngle.cpp
//
2020-11-27 05:10:47 -05:00
#include "math.h"
2017-12-09 12:23:18 -05:00
#include "Arduino.h"
2021-01-29 06:31:58 -05:00
#define AVERAGE_ANGLE_LIB_VERSION "0.1.5"
2017-12-09 12:23:18 -05:00
class AverageAngle
{
public:
2021-01-29 06:31:58 -05:00
enum AngleType { DEGREES = 0, RADIANS = 1 };
2017-12-09 12:23:18 -05:00
2021-01-29 06:31:58 -05:00
AverageAngle(const enum AngleType type = DEGREES);
2017-12-09 12:23:18 -05:00
2021-01-29 06:31:58 -05:00
uint32_t add(float alpha, float length = 1.0);
void reset();
uint32_t count() { return _count; };
float getAverage();
2021-01-29 06:31:58 -05:00
float getTotalLength();
float getAverageLength();
2021-01-29 06:31:58 -05:00
AngleType type() { return _type; };
2017-12-09 12:23:18 -05:00
private:
2021-01-29 06:31:58 -05:00
AngleType _type;
float _sumx;
float _sumy;
uint32_t _count;
2017-12-09 12:23:18 -05:00
};
2020-11-27 05:10:47 -05:00
// -- END OF FILE --