/** * @file akku.h * @author Alexander Klein (alex@kleiax.de) * @brief * @version 0.1 * @date 2022-02-05 * * @copyright Copyright (c) 2022 * */ #ifndef AKKU_H #define AKKU_H #include #include #include class Akku { public: Akku(uint8_t pin, double maxVolt = 0, double emptyVolt = 0); void setEmptyVoltage(double volt); void setMaxVoltage(double volt); double getVoltage(); uint8_t getPercent(); bool isEmpty(); private: double readVoltage(); double updateOnePercent(); uint8_t pin; double maxVolt; double emptyVolt; double onePercent; const float capacityVoltages[21] = {9.82, 10.83, 11.06, 11.12, 11.18, 11.24, 11.3, 11.36, 11.39, 11.45, 11.51, 11.56, 11.62, 11.74, 11.86, 11.95, 12.07, 12.25, 12.33, 12.45, 12.6 }; }; #endif // AKKU_H