summaryrefslogtreecommitdiff
path: root/src/drivers/include
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-01-21 14:10:25 +1100
committerjacqueline <me@jacqueline.id.au>2023-01-21 14:10:25 +1100
commitf013bab7276b8d5e606cee636e31f2157cd6e34d (patch)
treec7ccac33cb17fe2afc4b4d7dd3bcf923121c027d /src/drivers/include
parent393b268e159a40b23bc63464f4d04d5be09e070f (diff)
downloadtangara-fw-f013bab7276b8d5e606cee636e31f2157cd6e34d.tar.gz
Migrate to the v5 adc api
Diffstat (limited to 'src/drivers/include')
-rw-r--r--src/drivers/include/battery.hpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/drivers/include/battery.hpp b/src/drivers/include/battery.hpp
index 9358f9b0..9366a5b1 100644
--- a/src/drivers/include/battery.hpp
+++ b/src/drivers/include/battery.hpp
@@ -1,16 +1,25 @@
#pragma once
-#include <stdint.h>
+#include <cstdint>
+#include "esp_adc/adc_oneshot.h"
#include "esp_err.h"
+#include "result.hpp"
namespace drivers {
-esp_err_t init_adc(void);
+class Battery {
+ public:
+ Battery();
+ ~Battery();
-/**
- * Returns the current battery level in millivolts.
- */
-uint32_t read_battery_voltage(void);
+ /**
+ * Returns the current battery level in millivolts.
+ */
+ auto Millivolts() -> uint32_t;
+ private:
+ adc_oneshot_handle_t adc_handle_;
+ adc_cali_handle_t adc_calibration_handle_;
+};
} // namespace drivers