diff options
| author | ailurux <ailuruxx@gmail.com> | 2023-08-28 14:59:52 +1000 |
|---|---|---|
| committer | ailurux <ailuruxx@gmail.com> | 2023-08-28 14:59:52 +1000 |
| commit | db601935c6145445467692c0a4ff2b81e27cf6ce (patch) | |
| tree | e2eed4a38abd03f14dba504ce5e8dedee0da6a12 /src/drivers/include/adc.hpp | |
| parent | 6f4ace1dd4b9b34f95af1ba365b68624e209d147 (diff) | |
| parent | 3a0c42f9240eedfbc6a1e94ad3a59c52664fb5b5 (diff) | |
| download | tangara-fw-db601935c6145445467692c0a4ff2b81e27cf6ce.tar.gz | |
Merge branch 'main' of git.sr.ht:~jacqueline/tangara-fw
Diffstat (limited to 'src/drivers/include/adc.hpp')
| -rw-r--r-- | src/drivers/include/adc.hpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/drivers/include/adc.hpp b/src/drivers/include/adc.hpp new file mode 100644 index 00000000..3e94a9ee --- /dev/null +++ b/src/drivers/include/adc.hpp @@ -0,0 +1,37 @@ +/* + * Copyright 2023 jacqueline <me@jacqueline.id.au> + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#pragma once + +#include <cstdint> + +#include "esp_adc/adc_cali.h" +#include "esp_adc/adc_oneshot.h" +#include "esp_err.h" +#include "result.hpp" + +namespace drivers { + +/* + * Handles measuring the battery's current voltage. + */ +class AdcBattery { + public: + static auto Create() -> AdcBattery* { return new AdcBattery(); } + AdcBattery(); + ~AdcBattery(); + + /** + * Returns the current battery level in millivolts. + */ + auto Millivolts() -> uint32_t; + + private: + adc_oneshot_unit_handle_t adc_handle_; + adc_cali_handle_t adc_calibration_handle_; +}; + +} // namespace drivers |
