Improve gain/exposure controls

This commit is contained in:
Kristian Vos
2024-05-11 13:59:48 +02:00
parent 8d74a7da06
commit ac80896c0c
3 changed files with 25 additions and 4 deletions

View File

@@ -50,7 +50,7 @@
<child> <child>
<object class="GtkButton" id="iso-controls-button"> <object class="GtkButton" id="iso-controls-button">
<property name="valign">start</property> <property name="valign">start</property>
<property name="icon-name">iso-man-symbolic</property> <property name="icon-name">iso-auto-symbolic</property>
<style> <style>
<class name="flat"/> <class name="flat"/>
<class name="control"/> <class name="control"/>

View File

@@ -232,6 +232,7 @@ start_focus()
static void static void
update_controls() update_controls()
{ {
bool state_changed = false;
// Don't update controls while capturing // Don't update controls while capturing
if (state_io.captures_remaining > 0) { if (state_io.captures_remaining > 0) {
return; return;
@@ -247,6 +248,7 @@ update_controls()
V4L2_CID_AUTOGAIN, V4L2_CID_AUTOGAIN,
!state_io.gain.manual_req); !state_io.gain.manual_req);
state_io.gain.manual = state_io.gain.manual_req; state_io.gain.manual = state_io.gain.manual_req;
state_changed = true;
} }
if ((state_io.gain.manual || if ((state_io.gain.manual ||
@@ -256,6 +258,7 @@ update_controls()
state_io.gain.control, state_io.gain.control,
state_io.gain.value_req); state_io.gain.value_req);
state_io.gain.value = state_io.gain.value_req; state_io.gain.value = state_io.gain.value_req;
state_changed = true;
} }
if (state_io.exposure.manual != state_io.exposure.manual_req) { if (state_io.exposure.manual != state_io.exposure.manual_req) {
@@ -265,6 +268,7 @@ update_controls()
V4L2_EXPOSURE_MANUAL : V4L2_EXPOSURE_MANUAL :
V4L2_EXPOSURE_AUTO); V4L2_EXPOSURE_AUTO);
state_io.exposure.manual = state_io.exposure.manual_req; state_io.exposure.manual = state_io.exposure.manual_req;
state_changed = true;
} }
if (state_io.exposure.manual && if (state_io.exposure.manual &&
@@ -273,6 +277,12 @@ update_controls()
state_io.exposure.control, state_io.exposure.control,
state_io.exposure.value_req); state_io.exposure.value_req);
state_io.exposure.value = state_io.exposure.value_req; state_io.exposure.value = state_io.exposure.value_req;
state_changed = true;
}
if (state_changed) {
pipeline_changed = true;
update_process_pipeline();
} }
} }
@@ -491,6 +501,9 @@ init_controls()
} else { } else {
state_io.blue.control = 0; state_io.blue.control = 0;
} }
pipeline_changed = true;
update_process_pipeline();
} }
/* /*

View File

@@ -157,6 +157,16 @@ update_io_pipeline()
static bool static bool
update_state(const mp_state_main *new_state) update_state(const mp_state_main *new_state)
{ {
if (state.exposure.manual != new_state->exposure.manual) {
const char *icon_name = new_state->exposure.manual ? "shutter-man-symbolic" : "shutter-auto-symbolic";
gtk_button_set_icon_name(GTK_BUTTON(shutter_button), icon_name);
}
if (state.gain.manual != new_state->gain.manual) {
const char *icon_name = new_state->gain.manual ? "iso-man-symbolic" : "iso-auto-symbolic";
gtk_button_set_icon_name(GTK_BUTTON(iso_button), icon_name);
}
state.gain.control = new_state->gain.control; state.gain.control = new_state->gain.control;
state.gain.auto_control = new_state->gain.auto_control; state.gain.auto_control = new_state->gain.auto_control;
state.gain.value = new_state->gain.value; state.gain.value = new_state->gain.value;
@@ -191,8 +201,6 @@ update_state(const mp_state_main *new_state)
gtk_widget_set_visible(iso_button, state.gain.control != 0); gtk_widget_set_visible(iso_button, state.gain.control != 0);
gtk_widget_set_visible(shutter_button, state.exposure.control != 0); gtk_widget_set_visible(shutter_button, state.exposure.control != 0);
update_io_pipeline();
return false; return false;
} }
@@ -885,7 +893,7 @@ static void
open_shutter_controls(GtkWidget *button, gpointer user_data) open_shutter_controls(GtkWidget *button, gpointer user_data)
{ {
float value = float value =
((float)state.exposure.value / (float)state.exposure.max) * 360.0f; (float)state.exposure.value * 360.0f / (float)state.camera->current_mode->height;
open_controls(button, open_controls(button,
"Shutter", "Shutter",
1.0, 1.0,