diff --git a/src/lumos.gresource.xml b/src/lumos.gresource.xml
index c379aa1..21dce98 100644
--- a/src/lumos.gresource.xml
+++ b/src/lumos.gresource.xml
@@ -5,6 +5,7 @@
widgets/time_priority_page.uiwidgets/aperture_priority_page.uiwidgets/manual_exposure_page.ui
+ widgets/sensor_readings_page.uigtk/help-overlay.uistyle.css
diff --git a/src/meson.build b/src/meson.build
index b98729d..56401cc 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -36,6 +36,7 @@ lumos_sources = [
'widgets/time_priority_page.py',
'widgets/aperture_priority_page.py',
'widgets/manual_exposure_page.py',
+ 'widgets/sensor_readings_page.py',
]
install_data(lumos_sources, install_dir: moduledir)
diff --git a/src/widgets/sensor_readings_page.py b/src/widgets/sensor_readings_page.py
new file mode 100644
index 0000000..4b8dd47
--- /dev/null
+++ b/src/widgets/sensor_readings_page.py
@@ -0,0 +1,46 @@
+# sensor_readings_page.py
+#
+# Copyright 2024 Daniele Verducci
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+from gi.repository import Adw
+from gi.repository import Gtk
+from .ev_calculator import EVCalculator
+
+@Gtk.Template(resource_path='/eu/ichibi/Lumos/widgets/sensor_readings_page.ui')
+class SensorReadingsPage(Gtk.Box):
+ __gtype_name__ = 'SensorReadingsPage'
+
+ # Labels
+ lux_label = Gtk.Template.Child()
+ ev_label = Gtk.Template.Child()
+
+ def onValuesChanged(self, isoSpeed: int, sensorValue: float, sensorUnit: str):
+ # Called when the light value changed
+
+ if self.lux_label:
+ self.lux_label.set_label("{:.0f} {}".format(sensorValue, sensorUnit))
+
+ # Check the unit is absolute ("lux"), otherwise there's no way to convert to an absolute EV value
+ if sensorUnit != "lux":
+ return
+
+ # Convert lux to EV
+ ev = EVCalculator.luxToEV(sensorValue)
+ if self.ev_label:
+ self.ev_label.set_label("{:.1f} EV".format(ev))
+
diff --git a/src/widgets/sensor_readings_page.ui b/src/widgets/sensor_readings_page.ui
new file mode 100644
index 0000000..e82eb39
--- /dev/null
+++ b/src/widgets/sensor_readings_page.ui
@@ -0,0 +1,33 @@
+
+
+
+
+ 1
+ 3
+ 3
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/widgets/widgets_loader.py b/src/widgets/widgets_loader.py
index b540e28..7b48066 100644
--- a/src/widgets/widgets_loader.py
+++ b/src/widgets/widgets_loader.py
@@ -3,10 +3,12 @@ from gi.repository import GObject
from .time_priority_page import TimePriorityPage
from .aperture_priority_page import AperturePriorityPage
from .manual_exposure_page import ManualExposurePage
+from .sensor_readings_page import SensorReadingsPage
# Register widgets to be used in templates UI
def registerWidgets() -> None:
GObject.type_ensure(TimePriorityPage)
GObject.type_ensure(AperturePriorityPage)
GObject.type_ensure(ManualExposurePage)
+ GObject.type_ensure(SensorReadingsPage)
diff --git a/src/window.py b/src/window.py
index db3f7df..59b632f 100644
--- a/src/window.py
+++ b/src/window.py
@@ -19,17 +19,16 @@
from gi.repository import Adw, Gtk, GObject
from .sensors_polling_timer import SensorsPollingTimer
-from .ev_calculator import EVCalculator
@Gtk.Template(resource_path='/eu/ichibi/Lumos/window.ui')
class LumosWindow(Adw.ApplicationWindow):
__gtype_name__ = 'LumosWindow'
# Labels
- lux_label = Gtk.Template.Child()
- ev_label = Gtk.Template.Child()
error_banner = Gtk.Template.Child()
sensor_unit_error_banner = Gtk.Template.Child()
+ # Pages
+ sensor_readings_page_widget = Gtk.Template.Child()
def __init__(self, **kwargs):
super().__init__(**kwargs)
@@ -49,22 +48,16 @@ class LumosWindow(Adw.ApplicationWindow):
self.sensorsPollingTimer.cancel()
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))
+ # Called when the light value changed: notify all pages
+ if self.sensor_readings_page_widget:
+ self.sensor_readings_page_widget.onValuesChanged(100, 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:
- self.ev_label.set_label("{:.1f} EV".format(ev))
def onError(self, e: Exception):
+ print(e)
self.lastError = e
self.error_banner.set_revealed(True)
diff --git a/src/window.ui b/src/window.ui
index e47551c..f5596da 100644
--- a/src/window.ui
+++ b/src/window.ui
@@ -104,44 +104,16 @@
-
+
-