From 4ff1ac3c5ba70ecf7922497f3f69db909cad40e8 Mon Sep 17 00:00:00 2001 From: Sebastian Straub Date: Mon, 23 Sep 2024 19:08:16 +0200 Subject: [PATCH] docstrings --- src/raspi_poe_mon/ctrl.py | 17 +++++++++++++++++ src/raspi_poe_mon/main.py | 2 +- src/raspi_poe_mon/mock.py | 1 + src/raspi_poe_mon/monitor.py | 2 ++ src/raspi_poe_mon/poe_hat.py | 6 ++++++ 5 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/raspi_poe_mon/ctrl.py b/src/raspi_poe_mon/ctrl.py index d72ba6f..cb7d1b4 100644 --- a/src/raspi_poe_mon/ctrl.py +++ b/src/raspi_poe_mon/ctrl.py @@ -11,6 +11,23 @@ class Controller: + """ + Controller for display and fan of the PoE HAT. + + Contains the main application loop and manages all high level logic like updating display + frames or changing fan state. + + :param show_display: display will only be used when this is True + :param control_fan: fan controls will only be enabled when this is True + :param fan_on_temp: turn on the fan when CPU temperature rises above this value (in °C) + :param fan_off_temp: turn off the fan when CPU temperature drops below this value (in °C) + :param frame_time: show a new frame on the display every n seconds (excluding blank time) + :param blank_time: blank time (seconds) between frames where the display is turned off + :param brightness: brightness level of the display in percent (0-100) + :param timeout: terminate after n seconds; 0 means run until interrupted + :param dry_run: simulate commands without accessing the PoE HAT + :param profiling: log profiling information, very verbose + """ def __init__( self, diff --git a/src/raspi_poe_mon/main.py b/src/raspi_poe_mon/main.py index 2b54308..af84732 100644 --- a/src/raspi_poe_mon/main.py +++ b/src/raspi_poe_mon/main.py @@ -64,7 +64,7 @@ def run( ] = 2.0, blank_time: Annotated[ float, - typer.Option(help="bank time (seconds) between frames where the display is turned off") + typer.Option(help="blank time (seconds) between frames where the display is turned off") ] = 0.0, brightness: Annotated[ int, diff --git a/src/raspi_poe_mon/mock.py b/src/raspi_poe_mon/mock.py index 6c33749..4612b53 100644 --- a/src/raspi_poe_mon/mock.py +++ b/src/raspi_poe_mon/mock.py @@ -11,6 +11,7 @@ def monkeypatch(): + """monkeypatch all real hardware so the mock version is used instead. restart to undo""" serial.i2c = MockFan device.ssd1306 = MockDisplay render.canvas = MockCanvas diff --git a/src/raspi_poe_mon/monitor.py b/src/raspi_poe_mon/monitor.py index 288bd5e..46a50cf 100644 --- a/src/raspi_poe_mon/monitor.py +++ b/src/raspi_poe_mon/monitor.py @@ -13,6 +13,8 @@ class SystemMonitor: """ Render display frames that show status information about the system + + :param poe_hat: Instance of the PoeHat class with access to the display """ def __init__(self, poe_hat: PoeHat) -> None: diff --git a/src/raspi_poe_mon/poe_hat.py b/src/raspi_poe_mon/poe_hat.py index ca27d2e..19adbbf 100644 --- a/src/raspi_poe_mon/poe_hat.py +++ b/src/raspi_poe_mon/poe_hat.py @@ -10,6 +10,12 @@ class PoeHat: + """ + Get access to the PoE HAT hardware, specifically display and fan via I2C + + :param dry_run: do not access the real hardware when this is set to True + :param brightness: brightness level of the OLED display (0-100%) + """ def __init__(self, dry_run=False, brightness=100) -> None: self.dry_run = dry_run