aboutsummaryrefslogtreecommitdiff
path: root/battery.h
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2022-03-27 12:48:36 +0100
committerdakkar <dakkar@thenautilus.net>2022-03-27 12:48:36 +0100
commit3443edf23337fb5d9ce63075ead80c4779cf823a (patch)
tree7010ca3559702ab816686d4fbc9c26f51a3b10c2 /battery.h
parentbattery voltage, move display around (diff)
downloadenv-sensor-3443edf23337fb5d9ce63075ead80c4779cf823a.tar.gz
env-sensor-3443edf23337fb5d9ce63075ead80c4779cf823a.tar.bz2
env-sensor-3443edf23337fb5d9ce63075ead80c4779cf823a.zip
break code into logical components
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();
+ }
};