diff options
author | panky-codes <pankaj.sarathy1992@gmail.com> | 2021-01-17 11:06:24 +0100 |
---|---|---|
committer | panky-codes <pankaj.sarathy1992@gmail.com> | 2021-01-17 11:06:24 +0100 |
commit | b31c0e7e4571a2aef46672d49eedab0f31b820f4 (patch) | |
tree | fa605d76d330cfb535a9b812451bb49a082c0212 /src | |
parent | 952021cdb689f966fd745a37db0658f6787d9dc0 (diff) |
Added more descriptive comments in doxygen format.
Diffstat (limited to 'src')
-rw-r--r-- | src/components/battery/BatteryController.h | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/components/battery/BatteryController.h b/src/components/battery/BatteryController.h index 3138d243..86250a57 100644 --- a/src/components/battery/BatteryController.h +++ b/src/components/battery/BatteryController.h @@ -6,15 +6,21 @@ namespace Pinetime { namespace Controllers { - // A simple circular buffer that can be used to average - // out the sensor values + /** A simple circular buffer that can be used to average + out the sensor values. The total capacity of the CircBuffer + is given as the template parameter N. + */ template <int N> class CircBuffer { 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) { - loc %= cap; - arr[loc++] = num; + head %= cap; + arr[head++] = num; if (sz != cap) { sz++; } @@ -26,10 +32,10 @@ namespace Pinetime { } private: - std::array<int, N> arr; - uint8_t sz; - uint8_t cap; - uint8_t loc; + std::array<int, N> arr; /**< internal array used to store the values*/ + uint8_t sz; /**< The current size of the array.*/ + uint8_t cap; /**< Total capacity of the CircBuffer.*/ + uint8_t head; /**< The current head of the CircBuffer*/ }; class Battery { |