summaryrefslogtreecommitdiff
path: root/camlibs/canon
diff options
context:
space:
mode:
authorMarcus Meissner <marcus@jet.franken.de>2010-05-05 08:07:58 +0000
committerMarcus Meissner <marcus@jet.franken.de>2010-05-05 08:07:58 +0000
commit340bc4c1a98a9f85977af4d55072453e4087ddfe (patch)
tree0cd8e24f70c5778d6197bd3b4d94929753c87957 /camlibs/canon
parent1fc71a5c32913b39fb63a7979a5b1e674248c62d (diff)
downloadlibgphoto2-340bc4c1a98a9f85977af4d55072453e4087ddfe.tar.gz
sven killig: zoom -> range widget, added new iso, added canon
shootingmode git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@13054 67ed7778-7388-44ab-90cf-0a291f65f57c
Diffstat (limited to 'camlibs/canon')
-rw-r--r--camlibs/canon/ChangeLog7
-rw-r--r--camlibs/canon/canon.c57
-rw-r--r--camlibs/canon/canon.h33
-rw-r--r--camlibs/canon/library.c159
4 files changed, 187 insertions, 69 deletions
diff --git a/camlibs/canon/ChangeLog b/camlibs/canon/ChangeLog
index 86dd29609..fc43c28f2 100644
--- a/camlibs/canon/ChangeLog
+++ b/camlibs/canon/ChangeLog
@@ -1,3 +1,10 @@
+2010-05-05 Sven Killig <sven@killig.de>
+
+ * canon.c, canon.h, library.c:
+ - added shooting mode
+ - added ISO 50
+ - converted zoom level to GP_WIDGET_RANGE
+
2009-07-28 Axel Waggershauser <awagger@web.de>
* canon.c,canon.h,library.c,usb.c: Unified all configuration
diff --git a/camlibs/canon/canon.c b/camlibs/canon/canon.c
index 6ec80ab31..21a3bd1e2 100644
--- a/camlibs/canon/canon.c
+++ b/camlibs/canon/canon.c
@@ -1782,6 +1782,9 @@ canon_int_get_release_params (Camera *camera, GPContext *context)
GP_DEBUG ("canon_int_get_release_params: exposurebias = 0x%02x",
camera->pl->release_params[EXPOSUREBIAS_INDEX]);
+ GP_DEBUG ("canon_int_get_release_params: shooting mode = 0x%02x",
+ camera->pl->release_params[SHOOTING_MODE_INDEX]);
+
camera->pl->secondary_image = 0;
/* Based on the image format settings in the release params,
@@ -1992,17 +1995,16 @@ canon_int_set_flash (Camera *camera, canonFlashMode flash_mode,
/**
* canon_int_set_zoom
* @camera: camera to work with
- * @zoom_level: zoom level to set - use one of the defines such as
- * ZOOM_0 for no zoom
+ * @zoom_level: zoom level to set - A40: 1..10; G1: 0..40 (pMaxOpticalZoomPos*4)
* @context: context for error reporting
*
- * Sets the camera's zoom. Only tested for A40 via USB.
+ * Sets the camera's zoom. Only tested for A40 and G1 via USB.
*
* Returns: gphoto2 error code
*
*/
int
-canon_int_set_zoom (Camera *camera, canonZoomLevel zoom_level,
+canon_int_set_zoom (Camera *camera, unsigned char zoom_level,
GPContext *context)
{
int status;
@@ -2155,6 +2157,53 @@ canon_int_set_iso (Camera *camera, canonIsoState iso,
return GP_OK;
}
+
+/**
+ * canon_int_set_shooting_mode
+ * @camera: camera to work with
+ * @shooting_mode: use the unsigned char 8bit value in the array
+ * @context: context for error reporting
+ *
+ * Sets the camera's shooting mode.
+ *
+ * Returns: gphoto2 error code
+ *
+ */
+int
+canon_int_set_shooting_mode (Camera *camera, unsigned char shooting_mode,
+ GPContext *context)
+{
+ int status;
+
+ GP_DEBUG ("canon_int_set_shooting_mode() called for shooting_mode 0x%02x", shooting_mode);
+ /* Get the current camera settings */
+ status = canon_int_get_release_params (camera, context);
+ if (status < 0)
+ return status;
+ /* Modify the shotting mode */
+ camera->pl->release_params[SHOOTING_MODE_INDEX] = shooting_mode;
+ /* Upload the shotting mode to the camera */
+ status = canon_int_set_release_params (camera, context);
+ if (status < 0)
+ return status;
+ /* Make sure the camera changed it! (not all are able to) */
+ status = canon_int_get_release_params (camera, context);
+ if (status < 0)
+ return status;
+ if (camera->pl->release_params[SHOOTING_MODE_INDEX] != shooting_mode) {
+ GP_DEBUG ("canon_int_set_shooting_mode: Could not set shooting mode "
+ "to 0x%02x (camera returned 0x%02x)",
+ shooting_mode,
+ camera->pl->release_params[SHOOTING_MODE_INDEX]);
+ return GP_ERROR_CORRUPTED_DATA;
+ } else {
+ GP_DEBUG ("canon_int_set_shooting_mode: shooting_mode change verified");
+ }
+ GP_DEBUG ("canon_int_set_shooting_mode() finished successfully");
+ return GP_OK;
+}
+
+
/**
* canon_int_set_aperture
* @camera: camera to work with
diff --git a/camlibs/canon/canon.h b/camlibs/canon/canon.h
index 229738d78..577c8a1aa 100644
--- a/camlibs/canon/canon.h
+++ b/camlibs/canon/canon.h
@@ -192,10 +192,11 @@ typedef enum {
/**
- * These ISO, shutter speed, aperture, etc. settings are correct for the
- * EOS 5D; unsure about other cameras.
+ * These ISO, shutter speed, aperture, etc. settings are correct for the
+ * EOS 5D and some for the G1; unsure about other cameras.
*/
typedef enum {
+ ISO_50 = 0x40,
ISO_100 = 0x48,
ISO_125 = 0x4b,
ISO_160 = 0x4d,
@@ -217,6 +218,11 @@ struct canonIsoStateStruct {
char *label;
};
+struct canonShootingModeStateStruct {
+ unsigned char value;
+ char *label;
+};
+
typedef enum {
APERTURE_F1_4 = 0x10,
APERTURE_F1_6 = 0x13,
@@ -386,25 +392,8 @@ struct canonBeepModeStateStruct {
char* label;
};
-/*
- * Controls che camera zoom. These values have been verified for the
- * A40 only.
- */
-typedef enum {
- ZOOM_0 = 0x01, /* minimum (no zoom) */
- ZOOM_1 = 0x02,
- ZOOM_2 = 0x03,
- ZOOM_3 = 0x04,
- ZOOM_4 = 0x05,
- ZOOM_5 = 0x06,
- ZOOM_6 = 0x07,
- ZOOM_7 = 0x08,
- ZOOM_8 = 0x09,
- ZOOM_9 = 0x0a /* maximum zoom ?? */
-} canonZoomLevel;
-
struct canonZoomLevelStateStruct {
- canonZoomLevel value;
+ unsigned char value;
char* label;
};
@@ -430,6 +419,7 @@ struct canonExposureBiasStateStruct {
#define APERTURE_INDEX 0x1c
#define SHUTTERSPEED_INDEX 0x1e
#define EXPOSUREBIAS_INDEX 0x20
+#define SHOOTING_MODE_INDEX 0x08
/**
* canonCaptureSizeClass:
@@ -701,6 +691,7 @@ int canon_int_set_file_attributes(Camera *camera, const char *file, const char *
int canon_int_delete_file(Camera *camera, const char *name, const char *dir, GPContext *context);
int canon_int_set_shutter_speed(Camera *camera, canonShutterSpeedState shutter_speed, GPContext *context);
int canon_int_set_iso(Camera *camera, canonIsoState iso, GPContext *context);
+int canon_int_set_shooting_mode (Camera *camera, unsigned char shooting_mode, GPContext *context);
int canon_int_set_aperture(Camera *camera, canonApertureState aperture, GPContext *context);
int canon_int_set_exposurebias(Camera *camera, unsigned char expbias, GPContext *context);
int canon_int_set_focus_mode (Camera *camera, canonFocusModeState focus_mode, GPContext *context);
@@ -715,7 +706,7 @@ int canon_int_start_remote_control(Camera *camera, GPContext *context);
int canon_int_end_remote_control(Camera *camera, GPContext *context);
int canon_int_set_beep(Camera *camera, canonBeepMode beep_mode, GPContext *context);
int canon_int_set_flash(Camera *camera, canonFlashMode flash_mode, GPContext *context);
-int canon_int_set_zoom(Camera *camera, canonZoomLevel zoom_level, GPContext *context);
+int canon_int_set_zoom(Camera *camera, unsigned char zoom_level, GPContext *context);
/*
* introduced for capturing
diff --git a/camlibs/canon/library.c b/camlibs/canon/library.c
index c12bad745..2bee2ee7f 100644
--- a/camlibs/canon/library.c
+++ b/camlibs/canon/library.c
@@ -100,6 +100,7 @@ static const struct canonCaptureSizeClassStruct captureSizeArray[] = {
};
static const struct canonIsoStateStruct isoStateArray[] = {
+ {ISO_50, "50"},
{ISO_100, "100"},
{ISO_125, "125"},
{ISO_160, "160"},
@@ -230,20 +231,6 @@ static const struct canonFlashModeStateStruct flashModeStateArray[] = {
{0, NULL},
};
-static const struct canonZoomLevelStateStruct zoomLevelStateArray[] = {
- {ZOOM_0, N_("No zoom")},
- {ZOOM_1, N_("Zoom 1")},
- {ZOOM_2, N_("Zoom 2")},
- {ZOOM_3, N_("Zoom 3")},
- {ZOOM_4, N_("Zoom 4")},
- {ZOOM_5, N_("Zoom 5")},
- {ZOOM_6, N_("Zoom 6")},
- {ZOOM_7, N_("Zoom 7")},
- {ZOOM_8, N_("Zoom 8")},
- {ZOOM_9, N_("Zoom 9")},
- {0, NULL},
-};
-
static const struct canonExposureBiasStateStruct exposureBiasStateArray[] = {
{0x10,"+2"},
{0x0d,"+1 2/3"},
@@ -266,6 +253,47 @@ static const struct canonExposureBiasStateStruct exposureBiasStateArray[] = {
};
+static const struct canonShootingModeStateStruct shootingModeStateArray[] = {
+ {0x00,N_("AUTO")},
+ {0x01,N_("P")},
+ {0x02,N_("Tv")},
+ {0x03,N_("Av")},
+ {0x04,N_("M")},
+ {0x05,N_("A-DEP")},
+ {0x06,N_("M-DEP")},
+ {0x07,N_("Bulb")},
+ {0x65,N_("Manual 2")},
+ {0x66,N_("Far scene")},
+ {0x67,N_("Fast shutter")},
+ {0x68,N_("Slow shutter")},
+ {0x69,N_("Night scene")},
+ {0x6a,N_("Gray scale")},
+ {0x6b,N_("Sepia")},
+ {0x6c,N_("Portrait")},
+ {0x6d,N_("Spot")},
+ {0x6e,N_("Macro")},
+ {0x6f,N_("BW")},
+ {0x70,N_("PanFocus")},
+ {0x71,N_("Vivid")},
+ {0x72,N_("Neutral")},
+ {0x73,N_("Flash off")},
+ {0x74,N_("Long shutter")},
+ {0x75,N_("Super macro")},
+ {0x76,N_("Foilage")},
+ {0x77,N_("Indoor")},
+ {0x78,N_("Fireworks")},
+ {0x79,N_("Beach")},
+ {0x7a,N_("Underwater")},
+ {0x7b,N_("Snow")},
+ {0x7c,N_("Kids and pets")},
+ {0x7d,N_("Night snapshot")},
+ {0x7e,N_("Digital macro")},
+ {0x7f,N_("MyColors")},
+ {0x80,N_("Photo in movie")},
+ {0, NULL}
+};
+
+
static const struct canonImageFormatStateStruct imageFormatStateArray[] = {
{IMAGE_FORMAT_RAW, N_("RAW"),
0x04, 0x02, 0x00},
@@ -1531,7 +1559,7 @@ camera_get_config (Camera *camera, CameraWidget **window, GPContext *context)
CameraWidget *t, *section;
char power_str[128], firm[64];
- int iso, shutter_speed, aperture, focus_mode, flash_mode, beep_mode;
+ int iso, shutter_speed, aperture, focus_mode, flash_mode, beep_mode, shooting_mode;
int res_byte1, res_byte2, res_byte3;
int pwr_status, pwr_source, res, i, menuval;
unsigned int expbias;
@@ -1621,6 +1649,40 @@ camera_get_config (Camera *camera, CameraWidget **window, GPContext *context)
gp_widget_append (section, t);
+ /* Shooting mode */
+ gp_widget_new (GP_WIDGET_MENU, _("Shooting mode"), &t);
+ gp_widget_set_name (t, "shootingmode");
+
+ /* Get the camera's current shooting mode setting */
+ shooting_mode = -1;
+ if (camera->pl->cached_ready == 1) {
+ res = canon_int_get_release_params(camera, context);
+ if (res == GP_OK)
+ iso = camera->pl->release_params[SHOOTING_MODE_INDEX];
+ }
+
+ /* Map it to the list of choices */
+ i = 0;
+ menuval = -1;
+ while (shootingModeStateArray[i].label) {
+ gp_widget_add_choice (t, _(shootingModeStateArray[i].label));
+ if (shooting_mode == (int)shootingModeStateArray[i].value) {
+ gp_widget_set_value (t, _(shootingModeStateArray[i].label));
+ menuval = i;
+ }
+ i++;
+ }
+
+ /* Set an unknown shooting mode value if the
+ * camera is set to something weird */
+ if (menuval == -1) {
+ gp_widget_add_choice (t, _("Unknown"));
+ gp_widget_set_value (t, _("Unknown"));
+ };
+
+ gp_widget_append (section, t);
+
+
/* Shutter speed */
gp_widget_new (GP_WIDGET_MENU, _("Shutter Speed"), &t);
gp_widget_set_name (t, "shutterspeed");
@@ -1657,21 +1719,13 @@ camera_get_config (Camera *camera, CameraWidget **window, GPContext *context)
/* Zoom level */
- gp_widget_new (GP_WIDGET_MENU, _("Zoom"), &t);
+ gp_widget_new (GP_WIDGET_RANGE, _("Zoom"), &t);
gp_widget_set_name (t, "zoom");
-
- i = 0;
- while (zoomLevelStateArray[i].label) {
- gp_widget_add_choice (t, _(zoomLevelStateArray[i].label));
- i++;
- }
-
-
+ gp_widget_set_range (t, 0, 255, 1);
/* Set an unknown zoom level (at the moment we don't read the
* zoom level */
- gp_widget_add_choice (t, _("Unknown"));
- gp_widget_set_value (t, _("Unknown"));
-
+ float zoom = -1;
+ gp_widget_set_value (t, &zoom);
gp_widget_append (section, t);
@@ -1983,7 +2037,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
char *wvalue;
int i, val;
int res;
- unsigned char iso, shutter_speed, aperture, focus_mode, flash_mode, beep, zoom;
+ unsigned char iso, shutter_speed, aperture, focus_mode, flash_mode, beep, shooting_mode;
char str[16];
GP_DEBUG ("camera_set_config()");
@@ -2055,6 +2109,36 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
}
}
+
+ gp_widget_get_child_by_label (window, _("Shooting mode"), &w);
+ if (gp_widget_changed (w)) {
+ gp_widget_get_value (w, &wvalue);
+ if (!check_readiness (camera, context)) {
+ gp_context_status (context, _("Camera unavailable"));
+ } else {
+
+ /* Map the menu option setting to the camera binary value */
+ i = 0;
+ while (shootingModeStateArray[i].label) {
+ if (strcmp (shootingModeStateArray[i].label, wvalue) == 0) {
+ shooting_mode = shootingModeStateArray[i].value;
+ break;
+ }
+ i++;
+ }
+
+ if (!shootingModeStateArray[i].label) {
+ gp_context_status (context, _("Invalid shooting mode setting"));
+ } else {
+ if (canon_int_set_shooting_mode (camera, shooting_mode, context) == GP_OK)
+ gp_context_status (context, _("Shooting mode changed"));
+ else
+ gp_context_status (context, _("Could not change shooting mode"));
+ }
+ }
+ }
+
+
gp_widget_get_child_by_label (window, _("Shutter Speed"), &w);
if (gp_widget_changed (w)) {
gp_widget_get_value (w, &wvalue);
@@ -2228,31 +2312,18 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context)
/* Zoom */
gp_widget_get_child_by_label (window, _("Zoom"), &w);
if (gp_widget_changed (w)) {
- gp_widget_get_value (w, &wvalue);
+ float zoom;
+ gp_widget_get_value (w, &zoom);
if (!check_readiness (camera, context)) {
gp_context_status (context, _("Camera unavailable"));
} else {
-
- /* Map the menu option setting to the camera binary value */
- i = 0;
- while (zoomLevelStateArray[i].label) {
- if (strcmp (_(zoomLevelStateArray[i].label), wvalue) == 0) {
- zoom = zoomLevelStateArray[i].value;
- break;
- }
- i++;
- }
-
- if (!zoomLevelStateArray[i].label) {
- gp_context_status (context, _("Invalid zoom level"));
- } else {
if (canon_int_set_zoom (camera, zoom, context) == GP_OK)
gp_context_status (context, _("Zoom level changed"));
else
gp_context_status (context, _("Could not change zoom level"));
}
}
- }
+
/* Aperture */
gp_widget_get_child_by_label (window, _("Aperture"), &w);