use CANON_USB_CONTROL_GET_ZOOM_POS to get and set zoom levels

from "Daniel P. Berrange" <dan@berrange.com>                                                                                                                                                


git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@14148 67ed7778-7388-44ab-90cf-0a291f65f57c
This commit is contained in:
Marcus Meissner
2012-12-09 19:20:49 +00:00
parent f74aaca759
commit c260c8138e
3 changed files with 63 additions and 3 deletions

View File

@@ -2026,6 +2026,65 @@ canon_int_set_zoom (Camera *camera, unsigned char zoom_level,
}
/**
* canon_int_get_zoom
* @camera: camera to work with
* @zoom_level: pointer to hold returned zoom level - A40: 1..10; G1: 0..40 (pMaxOpticalZoomPos*4)
* @context: context for error reporting
*
* Gets the camera's zoom. Only tested for G1 via USB.
*
* Returns: gphoto2 error code
*
*/
int
canon_int_get_zoom (Camera *camera, unsigned char *zoom_level,
GPContext *context)
{
unsigned char *msg = NULL;
unsigned int datalen = 0;
unsigned char payload[0x4c];
int payloadlen;
char desc[128];
*zoom_level = 0;
GP_DEBUG ("canon_int_get_zoom() called");
payloadlen = canon_int_pack_control_subcmd( payload,
CANON_USB_CONTROL_GET_ZOOM_POS,
0, 0, desc );
if ( camera->pl->md->model == CANON_CLASS_6 ) {
/* Newer protocol uses a different code, but with same
* response. It also needs an extra zero byte at the
* end. */
payload[payloadlen++] = 0;
msg = canon_usb_dialogue ( camera,
CANON_USB_FUNCTION_CONTROL_CAMERA_2,
&datalen, payload, payloadlen );
}
else
msg = canon_usb_dialogue ( camera,
CANON_USB_FUNCTION_CONTROL_CAMERA,
&datalen, payload, payloadlen );
if ( msg == NULL && datalen != 0x1c) {
/* ERROR */
GP_DEBUG ("%s datalen=%x",
desc, datalen);
return GP_ERROR_CORRUPTED_DATA;
}
*zoom_level = msg[12];
msg = NULL;
datalen = 0;
GP_DEBUG ("canon_int_get_zoom() finished successfully level=%d", *zoom_level);
return GP_OK;
}
/**
* canon_int_set_image_format
* @camera: camera to work with

View File

@@ -713,6 +713,7 @@ 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, unsigned char zoom_level, GPContext *context);
int canon_int_get_zoom(Camera *camera, unsigned char *zoom_level, GPContext *context);
/*
* introduced for capturing

View File

@@ -1577,6 +1577,7 @@ camera_get_config (Camera *camera, CameraWidget **window, GPContext *context)
time_t camtime;
char formatted_camera_time[30];
float zoom;
unsigned char zoomVal;
GP_DEBUG ("camera_get_config()");
@@ -1734,9 +1735,8 @@ camera_get_config (Camera *camera, CameraWidget **window, GPContext *context)
gp_widget_new (GP_WIDGET_RANGE, _("Zoom"), &t);
gp_widget_set_name (t, "zoom");
gp_widget_set_range (t, 0, 255, 1);
/* Set an unknown zoom level (at the moment we don't read the
* zoom level */
zoom = -1;
canon_int_get_zoom(camera, &zoomVal, context);
zoom = zoomVal;
gp_widget_set_value (t, &zoom);
gp_widget_append (section, t);