ISO Selector on header bar, WIP EV calculator class
This commit is contained in:
parent
47731ad887
commit
a0fbde0596
@ -1,9 +1,24 @@
|
|||||||
from math import log
|
from math import log
|
||||||
|
|
||||||
|
'''
|
||||||
|
This class does all the required math. It is based on the Wikipedia page
|
||||||
|
https://en.wikipedia.org/wiki/Exposure_value
|
||||||
|
(N^2)/t = L*S/K
|
||||||
|
where:
|
||||||
|
N is the relative aperture (f-number)
|
||||||
|
t is the exposure time ("shutter speed") in seconds
|
||||||
|
L is the average scene luminance
|
||||||
|
S is the ISO arithmetic speed
|
||||||
|
K is the reflected-light meter calibration constant
|
||||||
|
'''
|
||||||
class EVCalculator:
|
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:
|
def luxToEV(lux: float) -> float:
|
||||||
# Wikipedia (https://en.wikipedia.org/wiki/Exposure_value#EV_as_a_measure_of_luminance_and_illuminance)
|
# Wikipedia (https://en.wikipedia.org/wiki/Exposure_value#EV_as_a_measure_of_luminance_and_illuminance)
|
||||||
# says E = 2.5 * (2^EV), so the inverse is EV = ln(2*E/5)/ln(2)
|
# says E = 2.5 * (2^EV), so the inverse is EV = ln(2*E/5)/ln(2)
|
||||||
return log(2*lux/5, 2)
|
return log(2*lux/5, 2)
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="time-priority-aperture-label">
|
<object class="GtkLabel" id="time-priority-aperture-label">
|
||||||
<property name="label" translatable="no">f/60</property>
|
<property name="label" translatable="no">--s</property>
|
||||||
<style>
|
<style>
|
||||||
<class name="lumos-big-result"/>
|
<class name="lumos-big-result"/>
|
||||||
</style>
|
</style>
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="time-priority-aperture-label">
|
<object class="GtkLabel" id="time-priority-aperture-label">
|
||||||
<property name="label" translatable="no">f/11</property>
|
<property name="label" translatable="no">f/--</property>
|
||||||
<style>
|
<style>
|
||||||
<class name="lumos-big-result"/>
|
<class name="lumos-big-result"/>
|
||||||
</style>
|
</style>
|
||||||
|
@ -38,8 +38,6 @@ class LumosWindow(Adw.ApplicationWindow):
|
|||||||
|
|
||||||
def onSensorRead(self, value: float, unit: str):
|
def onSensorRead(self, value: float, unit: str):
|
||||||
# Called when the light value changed
|
# Called when the light value changed
|
||||||
print("Read {} {}".format(value, unit))
|
|
||||||
|
|
||||||
if self.lux_label:
|
if self.lux_label:
|
||||||
self.lux_label.set_label("{:.0f} {}".format(value, unit))
|
self.lux_label.set_label("{:.0f} {}".format(value, unit))
|
||||||
|
|
||||||
|
@ -9,6 +9,26 @@
|
|||||||
<object class="AdwToolbarView">
|
<object class="AdwToolbarView">
|
||||||
<child type="top">
|
<child type="top">
|
||||||
<object class="AdwHeaderBar" id="header_bar">
|
<object class="AdwHeaderBar" id="header_bar">
|
||||||
|
<child type="start">
|
||||||
|
<!-- ISO Selector in header bar (left) -->
|
||||||
|
<object class="GtkDropDown" id="iso-dropdown">
|
||||||
|
<property name="model">
|
||||||
|
<object class="GtkStringList">
|
||||||
|
<items>
|
||||||
|
<item translatable="no">ISO 50</item>
|
||||||
|
<item translatable="no">ISO 100</item>
|
||||||
|
<item translatable="no">ISO 200</item>
|
||||||
|
<item translatable="no">ISO 400</item>
|
||||||
|
<item translatable="no">ISO 800</item>
|
||||||
|
<item translatable="no">ISO 1600</item>
|
||||||
|
<item translatable="no">ISO 3200</item>
|
||||||
|
<item translatable="no">ISO 6400</item>
|
||||||
|
</items>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
<property name="selected">1</property> <!-- ISO 100 -->
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
<child type="end">
|
<child type="end">
|
||||||
<object class="GtkMenuButton">
|
<object class="GtkMenuButton">
|
||||||
<property name="primary">True</property>
|
<property name="primary">True</property>
|
||||||
@ -31,7 +51,7 @@
|
|||||||
<!-- Aperture priority page -->
|
<!-- Aperture priority page -->
|
||||||
<object class="AdwViewStackPage" id="aperture-priority-page">
|
<object class="AdwViewStackPage" id="aperture-priority-page">
|
||||||
<property name="name">aperture-priority-page</property>
|
<property name="name">aperture-priority-page</property>
|
||||||
<property name="title" translatable="true">Aperture priority</property>
|
<property name="title" translatable="true">Aperture</property>
|
||||||
<property name="icon-name">camera-shutter-symbolic</property>
|
<property name="icon-name">camera-shutter-symbolic</property>
|
||||||
<property name="use-underline">true</property>
|
<property name="use-underline">true</property>
|
||||||
<property name="child">
|
<property name="child">
|
||||||
@ -45,7 +65,7 @@
|
|||||||
<child>
|
<child>
|
||||||
<object class="AdwViewStackPage" id="time-priority-page">
|
<object class="AdwViewStackPage" id="time-priority-page">
|
||||||
<property name="name">time-priority-page</property>help
|
<property name="name">time-priority-page</property>help
|
||||||
<property name="title" translatable="true">Time priority</property>
|
<property name="title" translatable="true">Time</property>
|
||||||
<property name="icon-name">camera-timer-symbolic</property>
|
<property name="icon-name">camera-timer-symbolic</property>
|
||||||
<property name="use-underline">true</property>
|
<property name="use-underline">true</property>
|
||||||
<property name="child">
|
<property name="child">
|
||||||
@ -118,9 +138,12 @@
|
|||||||
<child>
|
<child>
|
||||||
<object class="AdwViewSwitcher" id="switcher_title">
|
<object class="AdwViewSwitcher" id="switcher_title">
|
||||||
<property name="stack">stack</property>
|
<property name="stack">stack</property>
|
||||||
|
<property name="margin-bottom">8</property>
|
||||||
|
<property name="margin-start">2</property>
|
||||||
|
<property name="margin-end">2</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
|
||||||
</object>
|
</object>
|
||||||
</property>
|
</property>
|
||||||
</object>
|
</object>
|
||||||
|
Loading…
Reference in New Issue
Block a user