From 5e557cc29f619736c75a91c06a1d6e73a2a0dd5b Mon Sep 17 00:00:00 2001 From: Daniele Verducci Date: Fri, 26 Apr 2024 09:43:55 +0200 Subject: [PATCH] Managed light sensor unit error --- src/window.py | 7 +++++++ src/window.ui | 8 +++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/window.py b/src/window.py index c05c6f6..db3f7df 100644 --- a/src/window.py +++ b/src/window.py @@ -29,6 +29,7 @@ class LumosWindow(Adw.ApplicationWindow): lux_label = Gtk.Template.Child() ev_label = Gtk.Template.Child() error_banner = Gtk.Template.Child() + sensor_unit_error_banner = Gtk.Template.Child() def __init__(self, **kwargs): super().__init__(**kwargs) @@ -49,9 +50,15 @@ class LumosWindow(Adw.ApplicationWindow): def onSensorRead(self, value: float, unit: str): # Called when the light value changed + if self.lux_label: self.lux_label.set_label("{:.0f} {}".format(value, unit)) + # Check the unit is absolute ("lux"), otherwise there's no way to convert to an absolute EV value + if unit != "lux": + self.sensor_unit_error_banner.set_revealed(True) + return + # Convert lux to EV ev = EVCalculator.luxToEV(value) if self.ev_label: diff --git a/src/window.ui b/src/window.ui index 46b7c8a..e47551c 100644 --- a/src/window.ui +++ b/src/window.ui @@ -51,6 +51,12 @@ " + + + Light sensor does not support absolute light measurement: unable to compute exposition + + +" @@ -127,7 +133,7 @@ - XXX EV + -- EV