Skip to content

Commit b31c0e7

Browse files
author
panky-codes
committed
Added more descriptive comments in doxygen format.
1 parent 952021c commit b31c0e7

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

src/components/battery/BatteryController.h

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,21 @@
66

77
namespace Pinetime {
88
namespace Controllers {
9-
// A simple circular buffer that can be used to average
10-
// out the sensor values
9+
/** A simple circular buffer that can be used to average
10+
out the sensor values. The total capacity of the CircBuffer
11+
is given as the template parameter N.
12+
*/
1113
template <int N>
1214
class CircBuffer {
1315
public:
14-
CircBuffer() : arr{}, sz{}, cap{N}, loc{} {}
16+
CircBuffer() : arr{}, sz{}, cap{N}, head{} {}
17+
/**
18+
insert member function overwrites the next data to the current
19+
HEAD and moves the HEAD to the newly inserted value.
20+
*/
1521
void insert(const int num) {
16-
loc %= cap;
17-
arr[loc++] = num;
22+
head %= cap;
23+
arr[head++] = num;
1824
if (sz != cap) {
1925
sz++;
2026
}
@@ -26,10 +32,10 @@ namespace Pinetime {
2632
}
2733

2834
private:
29-
std::array<int, N> arr;
30-
uint8_t sz;
31-
uint8_t cap;
32-
uint8_t loc;
35+
std::array<int, N> arr; /**< internal array used to store the values*/
36+
uint8_t sz; /**< The current size of the array.*/
37+
uint8_t cap; /**< Total capacity of the CircBuffer.*/
38+
uint8_t head; /**< The current head of the CircBuffer*/
3339
};
3440

3541
class Battery {

0 commit comments

Comments
 (0)