aboutsummaryrefslogtreecommitdiff
path: root/battery.h
diff options
context:
space:
mode:
Diffstat (limited to 'battery.h')
-rw-r--r--battery.h24
1 files changed, 17 insertions, 7 deletions
diff --git a/battery.h b/battery.h
index 825a3ab..e53341b 100644
--- a/battery.h
+++ b/battery.h
@@ -1,19 +1,16 @@
#pragma once
#include <Arduino.h>
+#include "data.h"
+
/*
code inspired by https://gist.github.com/jenschr/dfc765cb9404beb6333a8ea30d2e78a1
*/
class Battery {
+private:
uint8_t pin;
-public:
- /*
- the schematics at
- https://github.com/Xinyuan-LilyGO/LilyGo-T5-Epaper-Series/tree/master/schematic
- show a voltage divider connected to pin 35
- */
- Battery(uint8_t _pin=35) : pin(_pin) {};
+
float voltage() {
/*
Comment from the gist:
@@ -35,4 +32,17 @@ public:
*/
return (float)(analogRead(pin)) / 4095*2*3.3*1.1;
}
+public:
+ /*
+ the schematics at
+ https://github.com/Xinyuan-LilyGO/LilyGo-T5-Epaper-Series/tree/master/schematic
+ show a voltage divider connected to pin 35
+ */
+ Battery(uint8_t _pin=35) : pin(_pin) {};
+
+ void start() {}
+ bool dataReady() { return true; }
+ void read(SensorData *data) {
+ data->batteryVoltage = voltage();
+ }
};