diff --git a/meshtastic/powermon/power_supply.py b/meshtastic/powermon/power_supply.py index cb4d044..50a3a83 100644 --- a/meshtastic/powermon/power_supply.py +++ b/meshtastic/powermon/power_supply.py @@ -20,6 +20,9 @@ class PowerMeter: self.prevPowerTime = datetime.now() self.prevWattHour = self._getRawWattHour() + def close(self) -> None: + """Close the power meter.""" + def getAverageWatts(self) -> float: """Get watts consumed since last call to this method.""" now = datetime.now() diff --git a/meshtastic/powermon/ppk2.py b/meshtastic/powermon/ppk2.py index bec4c1d..3ebf44f 100644 --- a/meshtastic/powermon/ppk2.py +++ b/meshtastic/powermon/ppk2.py @@ -37,6 +37,11 @@ class PPK2PowerSupply(PowerSupply): super().__init__() # we call this late so that the port is already open and _getRawWattHour callback works + def close(self) -> None: + """Close the power meter.""" + self.r.stop_measuring() + super().close() + def setIsSupply(self, s: bool): """If in supply mode we will provide power ourself, otherwise we are just an amp meter.""" if ( diff --git a/meshtastic/slog/slog.py b/meshtastic/slog/slog.py index bc8df62..31e3a14 100644 --- a/meshtastic/slog/slog.py +++ b/meshtastic/slog/slog.py @@ -73,6 +73,7 @@ class PowerLogger: def close(self) -> None: """Close the PowerLogger and stop logging.""" if self.is_logging: + self.pMeter.close() self.is_logging = False self.thread.join() self.writer.close()