Added more descriptive comments in doxygen format.
This commit is contained in:
parent
952021cdb6
commit
b31c0e7e45
|
@ -6,15 +6,21 @@
|
||||||
|
|
||||||
namespace Pinetime {
|
namespace Pinetime {
|
||||||
namespace Controllers {
|
namespace Controllers {
|
||||||
// A simple circular buffer that can be used to average
|
/** A simple circular buffer that can be used to average
|
||||||
// out the sensor values
|
out the sensor values. The total capacity of the CircBuffer
|
||||||
|
is given as the template parameter N.
|
||||||
|
*/
|
||||||
template <int N>
|
template <int N>
|
||||||
class CircBuffer {
|
class CircBuffer {
|
||||||
public:
|
public:
|
||||||
CircBuffer() : arr{}, sz{}, cap{N}, loc{} {}
|
CircBuffer() : arr{}, sz{}, cap{N}, head{} {}
|
||||||
|
/**
|
||||||
|
insert member function overwrites the next data to the current
|
||||||
|
HEAD and moves the HEAD to the newly inserted value.
|
||||||
|
*/
|
||||||
void insert(const int num) {
|
void insert(const int num) {
|
||||||
loc %= cap;
|
head %= cap;
|
||||||
arr[loc++] = num;
|
arr[head++] = num;
|
||||||
if (sz != cap) {
|
if (sz != cap) {
|
||||||
sz++;
|
sz++;
|
||||||
}
|
}
|
||||||
|
@ -26,10 +32,10 @@ namespace Pinetime {
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::array<int, N> arr;
|
std::array<int, N> arr; /**< internal array used to store the values*/
|
||||||
uint8_t sz;
|
uint8_t sz; /**< The current size of the array.*/
|
||||||
uint8_t cap;
|
uint8_t cap; /**< Total capacity of the CircBuffer.*/
|
||||||
uint8_t loc;
|
uint8_t head; /**< The current head of the CircBuffer*/
|
||||||
};
|
};
|
||||||
|
|
||||||
class Battery {
|
class Battery {
|
||||||
|
|
Loading…
Reference in a new issue