diff --git a/src/raspi_poe_mon/ctrl.py b/src/raspi_poe_mon/ctrl.py index e81bfdb..b2a0a42 100644 --- a/src/raspi_poe_mon/ctrl.py +++ b/src/raspi_poe_mon/ctrl.py @@ -17,6 +17,7 @@ def __init__( fan_on_temp=60.0, fan_off_temp=50.0, frame_time=2.0, + brightness=100, dry_run=False, profiling=False, ): @@ -24,7 +25,7 @@ def __init__( self.fan_off_temp = fan_off_temp self.frame_time = frame_time self.profiling = profiling - self.poe_hat = PoeHat(dry_run=dry_run) + self.poe_hat = PoeHat(dry_run=dry_run, brightness=brightness) self.display = IpDisplay(self.poe_hat) self._frame_counter = 0 self._terminate = False diff --git a/src/raspi_poe_mon/main.py b/src/raspi_poe_mon/main.py index 2d38bba..ee5c16f 100644 --- a/src/raspi_poe_mon/main.py +++ b/src/raspi_poe_mon/main.py @@ -62,6 +62,10 @@ def run( float, typer.Option(help="update the display every n seconds") ] = 2.0, + brightness: Annotated[ + int, + typer.Option(min=0, max=100, help="brightness level of the display in percent") + ] = 50, verbose: Annotated[ bool, typer.Option(help="log detailed status information") @@ -88,6 +92,7 @@ def run( fan_on_temp=fan_on_temp, fan_off_temp=fan_off_temp, frame_time=frame_time, + brightness=brightness, dry_run=dry, profiling=profiling, ) diff --git a/src/raspi_poe_mon/poe_hat.py b/src/raspi_poe_mon/poe_hat.py index 336d64d..6e3b588 100644 --- a/src/raspi_poe_mon/poe_hat.py +++ b/src/raspi_poe_mon/poe_hat.py @@ -11,8 +11,9 @@ class PoeHat: - def __init__(self, dry_run=False) -> None: + def __init__(self, dry_run=False, brightness=100) -> None: self.dry_run = dry_run + self.brightness = brightness self.i2c_fan: Optional[serial.i2c] = None self.i2c_display: Optional[serial.i2c] = None self.display: Optional[device.ssd1306] = None @@ -29,6 +30,7 @@ def display_connect(self, force=False): self.i2c_display = serial.i2c(port=1, address=0x3C) if force or self.display is None: self.display = device.ssd1306(serial_interface=self.i2c_display, width=128, height=32) + self.display.contrast(int(255 * self.brightness / 100)) def display_clear(self): self.display_connect()