ISO value change callback
This commit is contained in:
parent
0734153bcf
commit
95164ddb41
@ -43,13 +43,23 @@ class AperturePriorityPage(Gtk.Box):
|
|||||||
aperture_priority_aperture_dropdown = Gtk.Template.Child()
|
aperture_priority_aperture_dropdown = Gtk.Template.Child()
|
||||||
aperture_priority_time_label = 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")
|
# Check the unit is absolute ("lux")
|
||||||
if sensorUnit != "lux":
|
if sensorUnit != "lux":
|
||||||
return
|
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()]
|
apertureValue = self.aperture_priority_speed_dropdown_values[self.aperture_priority_aperture_dropdown.get_selected()]
|
||||||
shutterSpeed = EVCalculator.calcShutterSpeed(isoSpeed, sensorValue, apertureValue)
|
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
|
# 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))
|
self.aperture_priority_time_label.set_label("f/ {:.2f}".format(shutterSpeed))
|
||||||
|
|
||||||
|
@ -30,3 +30,5 @@ class ManualExposurePage(Gtk.Box):
|
|||||||
if sensorUnit != "lux":
|
if sensorUnit != "lux":
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def onIsoSpeedChanged(self, isoSpeed: int):
|
||||||
|
print("ME: onIsoSpeedChanged {}".format(isoSpeed))
|
||||||
|
@ -44,3 +44,5 @@ class SensorReadingsPage(Gtk.Box):
|
|||||||
if self.ev_label:
|
if self.ev_label:
|
||||||
self.ev_label.set_label("{:.1f} EV".format(ev))
|
self.ev_label.set_label("{:.1f} EV".format(ev))
|
||||||
|
|
||||||
|
def onIsoSpeedChanged(self, isoSpeed: int):
|
||||||
|
print("SR: onIsoSpeedChanged {}".format(isoSpeed))
|
||||||
|
@ -51,13 +51,22 @@ class TimePriorityPage(Gtk.Box):
|
|||||||
time_priority_speed_dropdown = Gtk.Template.Child()
|
time_priority_speed_dropdown = Gtk.Template.Child()
|
||||||
time_priority_aperture_label = Gtk.Template.Child()
|
time_priority_aperture_label = Gtk.Template.Child()
|
||||||
|
|
||||||
|
lastSensorValue = None
|
||||||
|
|
||||||
def onValuesChanged(self, isoSpeed: int, sensorValue: float, sensorUnit: str):
|
def onValuesChanged(self, isoSpeed: int, sensorValue: float, sensorUnit: str):
|
||||||
# Check the unit is absolute ("lux")
|
# Check the unit is absolute ("lux")
|
||||||
if sensorUnit != "lux":
|
if sensorUnit != "lux":
|
||||||
return
|
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()]
|
shutterSpeed = self.time_priority_speed_dropdown_values[self.time_priority_speed_dropdown.get_selected()]
|
||||||
apertureValue = EVCalculator.calcAperture(isoSpeed, sensorValue, shutterSpeed)
|
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
|
# 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))
|
self.time_priority_aperture_label.set_label("f/ {:.2f}".format(apertureValue))
|
||||||
|
|
||||||
|
@ -89,4 +89,16 @@ class LumosWindow(Adw.ApplicationWindow):
|
|||||||
dialog.add_response("close", "Close")
|
dialog.add_response("close", "Close")
|
||||||
dialog.choose(self, None, None)
|
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)
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
</object>
|
</object>
|
||||||
</property>
|
</property>
|
||||||
<property name="selected">1</property> <!-- ISO 100 -->
|
<property name="selected">1</property> <!-- ISO 100 -->
|
||||||
|
<signal name="notify::selected-item" handler="onIsoSpeedChanged"/>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child type="end">
|
<child type="end">
|
||||||
@ -48,7 +49,7 @@
|
|||||||
<object class="AdwBanner" id="error_banner">
|
<object class="AdwBanner" id="error_banner">
|
||||||
<property name="title" translatable="true">Unable to access light sensor</property>
|
<property name="title" translatable="true">Unable to access light sensor</property>
|
||||||
<property name="button-label" translatable="true">Details</property>
|
<property name="button-label" translatable="true">Details</property>
|
||||||
<signal name="button-clicked" handler="showErrorDetails"/>"
|
<signal name="button-clicked" handler="showErrorDetails"/>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
|
Loading…
Reference in New Issue
Block a user