diff --git a/src/sensors_polling_timer.py b/src/sensors_polling_timer.py index f0d872c..cfbf260 100644 --- a/src/sensors_polling_timer.py +++ b/src/sensors_polling_timer.py @@ -39,5 +39,6 @@ class SensorsPollingTimer(Timer): value = self.proxy.Get('(ss)', 'net.hadess.SensorProxy', 'LightLevel') if (self.oldValue != value): self.oldValue = value - self.function(value) # Invoke callback + unit = self.proxy.Get('(ss)', 'net.hadess.SensorProxy', 'LightLevelUnit') + self.function(value, unit) # Invoke callback diff --git a/src/window.py b/src/window.py index 7d3577b..9ae01fe 100644 --- a/src/window.py +++ b/src/window.py @@ -25,15 +25,20 @@ from .sensors_polling_timer import SensorsPollingTimer class LumosWindow(Adw.ApplicationWindow): __gtype_name__ = 'LumosWindow' - #label = Gtk.Template.Child() + lux_label = Gtk.Template.Child() def __init__(self, **kwargs): super().__init__(**kwargs) # Start polling sensors - self.sensorsPollingTimer = SensorsPollingTimer(1, self.onSensorRead) - self.sensorsPollingTimer.run() + self.sensorsPollingTimer = SensorsPollingTimer(0.1, self.onSensorRead) + self.sensorsPollingTimer.start() - def onSensorRead(self, value): + def onSensorRead(self, value, unit): # Called when the light value changed - print("Read {} lux".format(value)) + print("Read {} {}".format(value, unit)) + + if self.lux_label: + self.lux_label.set_label("{:.0f} {}".format(value, unit)) + + diff --git a/src/window.ui b/src/window.ui index fa719a4..eca74a4 100644 --- a/src/window.ui +++ b/src/window.ui @@ -89,7 +89,7 @@ - + XXX Lux