Implemented AP and TP calculations
This commit is contained in:
parent
6ef5ad15f7
commit
4f79f51917
@ -11,10 +11,12 @@ where:
|
||||
S is the ISO arithmetic speed
|
||||
K is the reflected-light meter calibration constant
|
||||
'''
|
||||
|
||||
# K is the reflected-light meter calibration constant (unit: cd s/m2 ISO)
|
||||
# (https://en.wikipedia.org/wiki/Light_meter#Calibration_constants)
|
||||
K = 12.5
|
||||
|
||||
class EVCalculator:
|
||||
# K is the reflected-light meter calibration constant (unit: cd s/m2 ISO)
|
||||
# (https://en.wikipedia.org/wiki/Light_meter#Calibration_constants)
|
||||
K = 12.5 # TODO: Add to settings?
|
||||
|
||||
def luxToEV(lux: float) -> float:
|
||||
# Wikipedia (https://en.wikipedia.org/wiki/Light_meter#Exposure_equations)
|
||||
@ -22,8 +24,9 @@ class EVCalculator:
|
||||
return log(2*lux/5, 2)
|
||||
|
||||
def calcShutterSpeed(isoSpeed: int, lux: float, aperture: float):
|
||||
return ((aperture^2)*K)/(lux*isoSpeed)
|
||||
return (aperture*aperture*K)/(lux*isoSpeed)
|
||||
|
||||
def calcAperture(isoSpeed: int, lux: float, shutterSpeed: float):
|
||||
# shutterSpeed is in seconds
|
||||
return sqrt(lux*isoSpeed*shutterSpeed/K)
|
||||
|
||||
|
@ -19,13 +19,37 @@
|
||||
|
||||
from gi.repository import Adw
|
||||
from gi.repository import Gtk
|
||||
from .ev_calculator import EVCalculator
|
||||
|
||||
@Gtk.Template(resource_path='/eu/ichibi/Lumos/widgets/aperture_priority_page.ui')
|
||||
class AperturePriorityPage(Gtk.Box):
|
||||
__gtype_name__ = 'AperturePriorityPage'
|
||||
|
||||
# Values of aperture dropdown entries defined in the .ui file
|
||||
aperture_priority_speed_dropdown_values = [
|
||||
1/32,
|
||||
1/22,
|
||||
1/16,
|
||||
1/11,
|
||||
1/8,
|
||||
1/5.6,
|
||||
1/4,
|
||||
1/2.8,
|
||||
1/2,
|
||||
1/1.4
|
||||
]
|
||||
|
||||
# Widgets
|
||||
aperture_priority_aperture_dropdown = Gtk.Template.Child()
|
||||
aperture_priority_time_label = Gtk.Template.Child()
|
||||
|
||||
def onValuesChanged(self, isoSpeed: int, sensorValue: float, sensorUnit: str):
|
||||
# Check the unit is absolute ("lux")
|
||||
if sensorUnit != "lux":
|
||||
return
|
||||
|
||||
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))
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="time-priority-aperture-label">
|
||||
<object class="GtkLabel" id="aperture_priority_time_label">
|
||||
<property name="label" translatable="no">--s</property>
|
||||
<style>
|
||||
<class name="lumos-big-result"/>
|
||||
@ -43,7 +43,7 @@
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkDropDown" id="aperture-priority-speed-dropdown">
|
||||
<object class="GtkDropDown" id="aperture_priority_aperture_dropdown">
|
||||
<property name="model">
|
||||
<object class="GtkStringList">
|
||||
<items>
|
||||
|
@ -19,13 +19,45 @@
|
||||
|
||||
from gi.repository import Adw
|
||||
from gi.repository import Gtk
|
||||
from .ev_calculator import EVCalculator
|
||||
|
||||
@Gtk.Template(resource_path='/eu/ichibi/Lumos/widgets/time_priority_page.ui')
|
||||
class TimePriorityPage(Gtk.Box):
|
||||
__gtype_name__ = 'TimePriorityPage'
|
||||
|
||||
def onValuesChanged(self, isoSpeed: int, sensorValue: float, sensorUnit: str):
|
||||
# Values of time dropdown entries defined in the .ui file
|
||||
time_priority_speed_dropdown_values = [
|
||||
1/4000,
|
||||
1/2000,
|
||||
1/1000,
|
||||
1/500,
|
||||
1/250,
|
||||
1/125,
|
||||
1/60,
|
||||
1/30,
|
||||
1/15,
|
||||
1/8,
|
||||
1/4,
|
||||
1/2,
|
||||
1,
|
||||
2,
|
||||
4,
|
||||
8,
|
||||
15,
|
||||
30
|
||||
]
|
||||
|
||||
# Widgets
|
||||
time_priority_speed_dropdown = Gtk.Template.Child()
|
||||
time_priority_aperture_label = Gtk.Template.Child()
|
||||
|
||||
def onValuesChanged(self, isoSpeed: int, sensorValue: float, sensorUnit: str):
|
||||
# Check the unit is absolute ("lux")
|
||||
if sensorUnit != "lux":
|
||||
return
|
||||
|
||||
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))
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="time-priority-aperture-label">
|
||||
<object class="GtkLabel" id="time_priority_aperture_label">
|
||||
<property name="label" translatable="no">f/--</property>
|
||||
<style>
|
||||
<class name="lumos-big-result"/>
|
||||
@ -43,7 +43,7 @@
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkDropDown" id="time-priority-speed-dropdown">
|
||||
<object class="GtkDropDown" id="time_priority_speed_dropdown">
|
||||
<property name="model">
|
||||
<object class="GtkStringList">
|
||||
<items>
|
||||
|
Loading…
Reference in New Issue
Block a user