diff options
author | Mihael Koep <koep@schneide.com> | 2012-09-13 12:00:03 +0200 |
---|---|---|
committer | Mihael Koep <koep@schneide.com> | 2012-09-13 12:00:03 +0200 |
commit | 12a110995cd7d5aeffe363ca8dfbe5c4f7be0de0 (patch) | |
tree | a5bd951761f64b6745043a5d8470482ebff3a653 /src | |
parent | 4f04ef64bf8c737b68500ecc8a72f4a374315abc (diff) | |
download | libuca-12a110995cd7d5aeffe363ca8dfbe5c4f7be0de0.tar.gz libuca-12a110995cd7d5aeffe363ca8dfbe5c4f7be0de0.tar.bz2 libuca-12a110995cd7d5aeffe363ca8dfbe5c4f7be0de0.tar.xz libuca-12a110995cd7d5aeffe363ca8dfbe5c4f7be0de0.zip |
Implement gain and trigger mode properties.
Diffstat (limited to 'src')
-rw-r--r-- | src/cameras/uca-dexela-camera.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/cameras/uca-dexela-camera.c b/src/cameras/uca-dexela-camera.c index 436bea6..52b8b47 100644 --- a/src/cameras/uca-dexela-camera.c +++ b/src/cameras/uca-dexela-camera.c @@ -85,6 +85,41 @@ static void fill_binnings(UcaDexelaCameraPrivate *priv) g_value_array_append(priv->binnings, &val); } +static void map_dexela_trigger_mode_to_uca(GValue* value, TriggerMode mode) +{ + if (mode == SOFTWARE) { + g_value_set_enum(value, UCA_CAMERA_TRIGGER_INTERNAL); + return; + } + if (mode == EDGE) { + g_value_set_enum(value, UCA_CAMERA_TRIGGER_EXTERNAL); + return; + } + // XXX: this mapping is only a hack/guess + if (mode == DURATION) { + g_value_set_enum(value, UCA_CAMERA_TRIGGER_AUTO); + return; + } + g_warning("Unsupported dexela trigger mode: %d", mode); +} + +static void set_trigger_mode(UcaCameraTrigger mode) +{ + if (mode == UCA_CAMERA_TRIGGER_INTERNAL) { + setTriggerMode(SOFTWARE); + return; + } + if (mode == UCA_CAMERA_TRIGGER_EXTERNAL) { + setTriggerMode(EDGE); + return; + } + if (mode == UCA_CAMERA_TRIGGER_AUTO) { + setTriggerMode(DURATION); + return; + } + g_warning("Unsupported uca trigger mode: %d", mode); +} + static gboolean is_binning_allowed(UcaDexelaCameraPrivate *priv, guint binning) { for (int i = 0; i < priv->binnings->n_values; i++) { @@ -175,9 +210,21 @@ static void uca_dexela_camera_get_property(GObject *object, guint property_id, G break; } case PROP_SENSOR_MAX_FRAME_RATE: + { // TODO: we do not know how to compute the correct value, so just return 0 for now g_value_set_float(value, 0.0f); break; + } + case PROP_GAIN_MODE: + { + g_value_set_uint(value, getGain()); + break; + } + case PROP_TRIGGER_MODE: + { + map_dexela_trigger_mode_to_uca(value, getTriggerMode()); + break; + } default: { G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); @@ -217,6 +264,25 @@ static void uca_dexela_camera_set_property(GObject *object, guint property_id, c setBinningMode(getBinningModeHorizontal(), verticalBinning); break; } + case PROP_GAIN_MODE: + { + const guint gain = g_value_get_uint(value); + if (gain == 0) { + setGain(LOW); + return; + } + if (gain == 1) { + setGain(HIGH); + return; + } + g_warning("Illegal attempt to set gain: %d", gain); + break; + } + case PROP_TRIGGER_MODE: + { + set_trigger_mode(g_value_get_enum(value)); + break; + } default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); return; |