From b31c0e7e4571a2aef46672d49eedab0f31b820f4 Mon Sep 17 00:00:00 2001 From: panky-codes Date: Sun, 17 Jan 2021 11:06:24 +0100 Subject: [PATCH] Added more descriptive comments in doxygen format. --- src/components/battery/BatteryController.h | 24 ++++++++++++++-------- 1 file 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 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 arr; - uint8_t sz; - uint8_t cap; - uint8_t loc; + std::array 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 {