diff options
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/battery/BatteryController.cpp | 2 | ||||
| -rw-r--r-- | src/components/utility/LinearApproximation.h | 42 |
2 files changed, 1 insertions, 43 deletions
diff --git a/src/components/battery/BatteryController.cpp b/src/components/battery/BatteryController.cpp index d9e198c5..fdb461f8 100644 --- a/src/components/battery/BatteryController.cpp +++ b/src/components/battery/BatteryController.cpp @@ -1,5 +1,5 @@ #include "components/battery/BatteryController.h" -#include "components/utility/LinearApproximation.h" +#include "utility/LinearApproximation.h" #include "drivers/PinMap.h" #include <hal/nrf_gpio.h> #include <nrfx_saadc.h> diff --git a/src/components/utility/LinearApproximation.h b/src/components/utility/LinearApproximation.h deleted file mode 100644 index 1fe58d44..00000000 --- a/src/components/utility/LinearApproximation.h +++ /dev/null @@ -1,42 +0,0 @@ -#pragma once - -#include <cstddef> -#include <array> - -namespace Pinetime { - namespace Utility { - - // based on: https://github.com/SHristov92/LinearApproximation/blob/main/Linear.h - template <typename Key, typename Value, std::size_t Size> - class LinearApproximation { - using Point = struct { - Key key; - Value value; - }; - - public: - LinearApproximation(const std::array<Point, Size>&& sorted_points) : points {sorted_points} { - } - - Value GetValue(Key key) const { - if (key <= points[0].key) { - return points[0].value; - } - - for (std::size_t i = 1; i < Size; i++) { - const auto& p = points[i]; - const auto& p_prev = points[i - 1]; - - if (key < p.key) { - return p_prev.value + (key - p_prev.key) * (p.value - p_prev.value) / (p.key - p_prev.key); - } - } - - return points[Size - 1].value; - } - - private: - std::array<Point, Size> points; - }; - } -} |
