ISO value change callback

This commit is contained in:
Daniele Verducci 2024-05-03 08:57:25 +02:00
parent 0734153bcf
commit 95164ddb41
6 changed files with 40 additions and 4 deletions

View File

@ -43,13 +43,23 @@ class AperturePriorityPage(Gtk.Box):
aperture_priority_aperture_dropdown = Gtk.Template.Child()
aperture_priority_time_label = Gtk.Template.Child()
def onValuesChanged(self, isoSpeed: int, sensorValue: float, sensorUnit: str):
lastSensorValue = None
def onValuesChanged(self, isoSpeed: int, sensorValue: float, sensorUnit: str):
# Check the unit is absolute ("lux")
if sensorUnit != "lux":
return
self.lastSensorValue = sensorValue
self.updateView(isoSpeed, sensorValue)
def onIsoSpeedChanged(self, isoSpeed: int):
if self.lastSensorValue:
self.updateView(isoSpeed, self.lastSensorValue)
def updateView(self, isoSpeed: int, sensorValue: float):
apertureValue = self.aperture_priority_speed_dropdown_values[self.aperture_priority_aperture_dropdown.get_selected()]
shutterSpeed = EVCalculator.calcShutterSpeed(isoSpeed, sensorValue, apertureValue)
# TODO: Round shutter speed value to nearest existing value and set label color to red if outside 1 stop range
self.aperture_priority_time_label.set_label("f/ {:.2f}".format(shutterSpeed))

View File

@ -30,3 +30,5 @@ class ManualExposurePage(Gtk.Box):
if sensorUnit != "lux":
return
def onIsoSpeedChanged(self, isoSpeed: int):
print("ME: onIsoSpeedChanged {}".format(isoSpeed))

View File

@ -44,3 +44,5 @@ class SensorReadingsPage(Gtk.Box):
if self.ev_label:
self.ev_label.set_label("{:.1f} EV".format(ev))
def onIsoSpeedChanged(self, isoSpeed: int):
print("SR: onIsoSpeedChanged {}".format(isoSpeed))

View File

@ -51,13 +51,22 @@ class TimePriorityPage(Gtk.Box):
time_priority_speed_dropdown = Gtk.Template.Child()
time_priority_aperture_label = Gtk.Template.Child()
lastSensorValue = None
def onValuesChanged(self, isoSpeed: int, sensorValue: float, sensorUnit: str):
# Check the unit is absolute ("lux")
if sensorUnit != "lux":
return
self.lastSensorValue = sensorValue
self.updateView(isoSpeed, sensorValue)
def onIsoSpeedChanged(self, isoSpeed: int):
if self.lastSensorValue:
self.updateView(isoSpeed, self.lastSensorValue)
def updateView(self, isoSpeed: int, sensorValue: float):
shutterSpeed = self.time_priority_speed_dropdown_values[self.time_priority_speed_dropdown.get_selected()]
apertureValue = EVCalculator.calcAperture(isoSpeed, sensorValue, shutterSpeed)
# TODO: Round aperture value to nearest existing value and set label color to red if outside 1 stop range
self.time_priority_aperture_label.set_label("f/ {:.2f}".format(apertureValue))

View File

@ -89,4 +89,16 @@ class LumosWindow(Adw.ApplicationWindow):
dialog.add_response("close", "Close")
dialog.choose(self, None, None)
@Gtk.Template.Callback()
def onIsoSpeedChanged(self, dropDown: Gtk.DropDown, _: any) -> None:
# Changed ISO value, notify all pages
isoSpeed = int(dropDown.get_selected_item().get_string()[4:])
if self.aperture_priority_page_widget:
self.aperture_priority_page_widget.onIsoSpeedChanged(isoSpeed)
if self.time_priority_page_widget:
self.time_priority_page_widget.onIsoSpeedChanged(isoSpeed)
if self.manual_page_widget:
self.manual_page_widget.onIsoSpeedChanged(isoSpeed)
if self.sensor_readings_page_widget:
self.sensor_readings_page_widget.onIsoSpeedChanged(isoSpeed)

View File

@ -27,6 +27,7 @@
</object>
</property>
<property name="selected">1</property> <!-- ISO 100 -->
<signal name="notify::selected-item" handler="onIsoSpeedChanged"/>
</object>
</child>
<child type="end">
@ -48,7 +49,7 @@
<object class="AdwBanner" id="error_banner">
<property name="title" translatable="true">Unable to access light sensor</property>
<property name="button-label" translatable="true">Details</property>
<signal name="button-clicked" handler="showErrorDetails"/>"
<signal name="button-clicked" handler="showErrorDetails"/>
</object>
</child>
<child>