From 90062a13c42c82596e7181da5bd396930cd004be Mon Sep 17 00:00:00 2001 From: nebman Date: Thu, 7 Nov 2024 10:56:27 +0100 Subject: [PATCH] move getCurrentMa() to new CurrentSensor class --- src/modules/Telemetry/Sensor/CurrentSensor.h | 14 ++++++++++++++ src/modules/Telemetry/Sensor/INA219Sensor.h | 5 +++-- 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 src/modules/Telemetry/Sensor/CurrentSensor.h diff --git a/src/modules/Telemetry/Sensor/CurrentSensor.h b/src/modules/Telemetry/Sensor/CurrentSensor.h new file mode 100644 index 0000000000..b026cb8521 --- /dev/null +++ b/src/modules/Telemetry/Sensor/CurrentSensor.h @@ -0,0 +1,14 @@ +#include "configuration.h" + +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + +#pragma once + +class CurrentSensor +{ + public: + virtual int16_t getCurrentMa() = 0; +}; + + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/INA219Sensor.h b/src/modules/Telemetry/Sensor/INA219Sensor.h index 472174df75..dff62d79ac 100644 --- a/src/modules/Telemetry/Sensor/INA219Sensor.h +++ b/src/modules/Telemetry/Sensor/INA219Sensor.h @@ -5,9 +5,10 @@ #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" #include "VoltageSensor.h" +#include "CurrentSensor.h" #include -class INA219Sensor : public TelemetrySensor, VoltageSensor +class INA219Sensor : public TelemetrySensor, VoltageSensor, CurrentSensor { private: Adafruit_INA219 ina219; @@ -20,7 +21,7 @@ class INA219Sensor : public TelemetrySensor, VoltageSensor virtual int32_t runOnce() override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override; virtual uint16_t getBusVoltageMv() override; - int16_t getCurrentMa(); + virtual int16_t getCurrentMa() override; }; #endif \ No newline at end of file