| 1 |
/* dc210.c |
| 2 |
* |
| 3 |
* Copyright (C) 2002 Michel Koltan <[email protected]> |
| 4 |
* |
| 5 |
* This library is free software; you can redistribute it and/or |
| 6 |
* modify it under the terms of the GNU Lesser General Public |
| 7 |
* License as published by the Free Software Foundation; either |
| 8 |
* version 2 of the License, or (at your option) any later version. |
| 9 |
* |
| 10 |
* This library is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
* Lesser General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU Lesser General Public |
| 16 |
* License along with this library; if not, write to the |
| 17 |
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 |
* Boston, MA 02110-1301 USA |
| 19 |
*/ |
| 20 |
|
| 21 |
#define _DEFAULT_SOURCE |
| 22 |
#include "config.h" |
| 23 |
|
| 24 |
#include <stdlib.h> |
| 25 |
#include <stdio.h> |
| 26 |
#include <string.h> |
| 27 |
#include <time.h> |
| 28 |
|
| 29 |
#include <gphoto2/gphoto2.h> |
| 30 |
#include <gphoto2/gphoto2-port.h> |
| 31 |
|
| 32 |
#include "libgphoto2/i18n.h" |
| 33 |
|
| 34 |
#include "dc210.h" |
| 35 |
|
| 36 |
static char * exp_comp[] = {"-2.0 EV", "-1.5 EV", "-1.0 EV", "-0.5 EV", "AUTO", "+0.5 EV", |
| 37 |
"+1.0 EV", "+1.5 EV", "+2.0 EV"}; |
| 38 |
|
| 39 |
int camera_id (CameraText *id) { |
| 40 |
|
| 41 |
strcpy(id->text, GP_MODULE); |
| 42 |
|
| 43 |
return (GP_OK); |
| 44 |
} |
| 45 |
|
| 46 |
int camera_abilities (CameraAbilitiesList *list) { |
| 47 |
|
| 48 |
CameraAbilities a; |
| 49 |
|
| 50 |
memset (&a, 0, sizeof(a)); |
| 51 |
strcpy(a.model, "Kodak:DC210"); |
| 52 |
a.status = GP_DRIVER_STATUS_PRODUCTION; |
| 53 |
a.port = GP_PORT_SERIAL; |
| 54 |
a.speed[0] = 9600; |
| 55 |
a.speed[1] = 19200; |
| 56 |
a.speed[2] = 38400; |
| 57 |
a.speed[3] = 57600; |
| 58 |
a.speed[4] = 115200; |
| 59 |
a.speed[5] = 0; |
| 60 |
a.operations = GP_OPERATION_CAPTURE_IMAGE | GP_OPERATION_CONFIG; |
| 61 |
a.file_operations = GP_FILE_OPERATION_DELETE | GP_FILE_OPERATION_PREVIEW; |
| 62 |
a.folder_operations = GP_FOLDER_OPERATION_NONE; |
| 63 |
|
| 64 |
gp_abilities_list_append(list, a); |
| 65 |
|
| 66 |
/* Mark Longridge <[email protected]> */ |
| 67 |
strcpy(a.model, "Kodak:DC215"); |
| 68 |
gp_abilities_list_append(list, a); |
| 69 |
|
| 70 |
return (GP_OK); |
| 71 |
} |
| 72 |
|
| 73 |
static int file_list_func (CameraFilesystem *fs, const char *folder, |
| 74 |
CameraList *list, void *data, GPContext *context) |
| 75 |
{ |
| 76 |
Camera *camera = data; |
| 77 |
|
| 78 |
return dc210_get_filenames(camera, list, context); |
| 79 |
} |
| 80 |
|
| 81 |
static int get_file_func (CameraFilesystem *fs, const char *folder, |
| 82 |
const char *filename, CameraFileType type, |
| 83 |
CameraFile *file, void *data, GPContext *context) |
| 84 |
{ |
| 85 |
Camera *camera = data; |
| 86 |
|
| 87 |
switch (type) { |
| 88 |
case GP_FILE_TYPE_NORMAL: |
| 89 |
return dc210_download_picture_by_name(camera, file, filename, DC210_FULL_PICTURE, context); |
| 90 |
case GP_FILE_TYPE_PREVIEW: |
| 91 |
return dc210_download_picture_by_name(camera, file, filename, DC210_CFA_THUMB, context); |
| 92 |
default: |
| 93 |
return (GP_ERROR_NOT_SUPPORTED); |
| 94 |
}; |
| 95 |
|
| 96 |
return GP_OK; |
| 97 |
} |
| 98 |
|
| 99 |
static int delete_file_func (CameraFilesystem *fs, const char *folder, |
| 100 |
const char *filename, void *data, |
| 101 |
GPContext *context) |
| 102 |
{ |
| 103 |
Camera *camera = data; |
| 104 |
|
| 105 |
return dc210_delete_picture_by_name(camera, filename); |
| 106 |
|
| 107 |
}; |
| 108 |
|
| 109 |
static int get_info_func (CameraFilesystem *fs, const char *folder, const char *file, |
| 110 |
CameraFileInfo *info, void *data, GPContext *context) |
| 111 |
{ |
| 112 |
Camera *camera = data; |
| 113 |
dc210_picture_info picinfo; |
| 114 |
|
| 115 |
if (dc210_get_picture_info_by_name(camera, &picinfo, file) == GP_ERROR) |
| 116 |
return GP_ERROR; |
| 117 |
|
| 118 |
info->preview.fields = 0; |
| 119 |
info->preview.fields |= GP_FILE_INFO_TYPE; |
| 120 |
info->preview.fields |= GP_FILE_INFO_SIZE; |
| 121 |
info->preview.fields |= GP_FILE_INFO_WIDTH; |
| 122 |
info->preview.fields |= GP_FILE_INFO_HEIGHT; |
| 123 |
strcpy(info->preview.type, GP_MIME_PPM); |
| 124 |
info->preview.width = 96; |
| 125 |
info->preview.height = 72; |
| 126 |
info->preview.size = picinfo.preview_size; |
| 127 |
|
| 128 |
info->file.fields = 0; |
| 129 |
info->file.fields |= GP_FILE_INFO_TYPE; |
| 130 |
info->file.fields |= GP_FILE_INFO_SIZE; |
| 131 |
info->file.fields |= GP_FILE_INFO_WIDTH; |
| 132 |
info->file.fields |= GP_FILE_INFO_HEIGHT; |
| 133 |
info->file.fields |= GP_FILE_INFO_MTIME; |
| 134 |
|
| 135 |
info->file.size = picinfo.picture_size; |
| 136 |
switch(picinfo.file_type){ |
| 137 |
case DC210_FILE_TYPE_JPEG: |
| 138 |
strcpy(info->file.type, GP_MIME_JPEG); break; |
| 139 |
case DC210_FILE_TYPE_FPX: |
| 140 |
strcpy(info->file.type, GP_MIME_UNKNOWN); break; |
| 141 |
}; |
| 142 |
switch(picinfo.resolution){ |
| 143 |
case DC210_FILE_640: |
| 144 |
info->file.width = 640; |
| 145 |
info->file.height = 480; |
| 146 |
break; |
| 147 |
case DC210_FILE_1152: |
| 148 |
info->file.width = 1152; |
| 149 |
info->file.height = 864; |
| 150 |
break; |
| 151 |
}; |
| 152 |
info->file.mtime = picinfo.picture_time; |
| 153 |
return GP_OK; |
| 154 |
} |
| 155 |
|
| 156 |
|
| 157 |
static int |
| 158 |
camera_get_config (Camera *camera, CameraWidget **window, GPContext *context) |
| 159 |
{ |
| 160 |
CameraWidget *section, *widget; |
| 161 |
CameraAbilities abilities; |
| 162 |
GPPortSettings settings; |
| 163 |
unsigned int i; |
| 164 |
char * wvalue; |
| 165 |
char stringbuffer[12]; |
| 166 |
|
| 167 |
dc210_status status; |
| 168 |
|
| 169 |
if (dc210_get_status(camera, &status) == GP_ERROR) return GP_ERROR; |
| 170 |
|
| 171 |
gp_widget_new (GP_WIDGET_WINDOW, _("Camera Configuration"), window); |
| 172 |
|
| 173 |
gp_widget_new (GP_WIDGET_SECTION, _("File"), §ion); |
| 174 |
gp_widget_append (*window, section); |
| 175 |
|
| 176 |
gp_widget_new (GP_WIDGET_RADIO, _("File type"), &widget); |
| 177 |
gp_widget_append (section, widget); |
| 178 |
gp_widget_add_choice (widget, _("JPEG")); |
| 179 |
gp_widget_add_choice (widget, _("FlashPix")); |
| 180 |
|
| 181 |
switch (status.file_type){ |
| 182 |
case DC210_FILE_TYPE_JPEG: |
| 183 |
gp_widget_set_value (widget, _("JPEG")); break; |
| 184 |
case DC210_FILE_TYPE_FPX: |
| 185 |
gp_widget_set_value (widget, _("FlashPix")); break; |
| 186 |
}; |
| 187 |
gp_widget_get_value (widget, &wvalue); |
| 188 |
|
| 189 |
gp_widget_new (GP_WIDGET_RADIO, _("File resolution"), &widget); |
| 190 |
gp_widget_append (section, widget); |
| 191 |
gp_widget_add_choice (widget, _("640 x 480")); |
| 192 |
gp_widget_add_choice (widget, _("1152 x 864")); |
| 193 |
|
| 194 |
switch (status.resolution){ |
| 195 |
case DC210_FILE_640: |
| 196 |
gp_widget_set_value (widget, _("640 x 480")); break; |
| 197 |
case DC210_FILE_1152: |
| 198 |
gp_widget_set_value (widget, _("1152 x 864")); break; |
| 199 |
default: |
| 200 |
DC210_DEBUG("Undefined value for file resolution.\n"); break; |
| 201 |
}; |
| 202 |
gp_widget_get_value (widget, &wvalue); |
| 203 |
|
| 204 |
gp_widget_new (GP_WIDGET_MENU, _("File compression"), &widget); |
| 205 |
gp_widget_append (section, widget); |
| 206 |
gp_widget_add_choice (widget, _("Low (best quality)")); |
| 207 |
gp_widget_add_choice (widget, _("Medium (better quality)")); |
| 208 |
gp_widget_add_choice (widget, _("High (good quality)")); |
| 209 |
|
| 210 |
switch (status.compression_type){ |
| 211 |
case DC210_LOW_COMPRESSION: |
| 212 |
gp_widget_set_value (widget, _("Low (best quality)")); break; |
| 213 |
case DC210_MEDIUM_COMPRESSION: |
| 214 |
gp_widget_set_value (widget, _("Medium (better quality)")); break; |
| 215 |
case DC210_HIGH_COMPRESSION: |
| 216 |
gp_widget_set_value (widget, _("High (good quality)")); break; |
| 217 |
}; |
| 218 |
gp_widget_get_value (widget, &wvalue); |
| 219 |
|
| 220 |
gp_widget_new (GP_WIDGET_SECTION, _("Capture"), §ion); |
| 221 |
gp_widget_append (*window, section); |
| 222 |
|
| 223 |
gp_widget_new (GP_WIDGET_MENU, _("Zoom"), &widget); |
| 224 |
gp_widget_append (section, widget); |
| 225 |
gp_widget_add_choice (widget, "58 mm"); /* no need to translate strings with SI units! */ |
| 226 |
gp_widget_add_choice (widget, "51 mm"); |
| 227 |
gp_widget_add_choice (widget, "41 mm"); |
| 228 |
gp_widget_add_choice (widget, "34 mm"); |
| 229 |
gp_widget_add_choice (widget, "29 mm"); |
| 230 |
gp_widget_add_choice (widget, _("Macro")); |
| 231 |
|
| 232 |
switch (status.zoom){ |
| 233 |
case DC210_ZOOM_58: |
| 234 |
gp_widget_set_value (widget, _("58 mm")); break; |
| 235 |
case DC210_ZOOM_51: |
| 236 |
gp_widget_set_value (widget, _("51 mm")); break; |
| 237 |
case DC210_ZOOM_41: |
| 238 |
gp_widget_set_value (widget, _("41 mm")); break; |
| 239 |
case DC210_ZOOM_34: |
| 240 |
gp_widget_set_value (widget, _("34 mm")); break; |
| 241 |
case DC210_ZOOM_29: |
| 242 |
gp_widget_set_value (widget, _("29 mm")); break; |
| 243 |
case DC210_ZOOM_MACRO: |
| 244 |
gp_widget_set_value (widget, _("Macro")); break; |
| 245 |
}; |
| 246 |
gp_widget_get_value (widget, &wvalue); |
| 247 |
|
| 248 |
gp_widget_new (GP_WIDGET_MENU, _("Exposure compensation"), &widget); |
| 249 |
gp_widget_append (section, widget); |
| 250 |
for (i = 0; i < sizeof(exp_comp)/sizeof(*exp_comp); i++){ |
| 251 |
gp_widget_add_choice (widget, exp_comp[i]); |
| 252 |
if ((unsigned int)(status.exp_compensation + 4) == i) |
| 253 |
gp_widget_set_value (widget, exp_comp[i]); |
| 254 |
}; |
| 255 |
|
| 256 |
gp_widget_new (GP_WIDGET_RADIO, _("Flash"), &widget); |
| 257 |
gp_widget_append (section, widget); |
| 258 |
gp_widget_add_choice (widget, _("Auto")); |
| 259 |
gp_widget_add_choice (widget, _("Force")); |
| 260 |
gp_widget_add_choice (widget, _("None")); |
| 261 |
|
| 262 |
switch (status.flash){ |
| 263 |
case DC210_FLASH_AUTO: |
| 264 |
gp_widget_set_value (widget, _("Auto")); break; |
| 265 |
case DC210_FLASH_FORCE: |
| 266 |
gp_widget_set_value (widget, _("Force")); break; |
| 267 |
case DC210_FLASH_NONE: |
| 268 |
gp_widget_set_value (widget, _("None")); break; |
| 269 |
}; |
| 270 |
gp_widget_get_value (widget, &wvalue); |
| 271 |
|
| 272 |
gp_widget_new (GP_WIDGET_RADIO, _("Red eye flash"), &widget); |
| 273 |
gp_widget_append (section, widget); |
| 274 |
gp_widget_add_choice (widget, _("On")); |
| 275 |
gp_widget_add_choice (widget, _("Off")); |
| 276 |
|
| 277 |
if (status.preflash) |
| 278 |
gp_widget_set_value (widget, _("On")); |
| 279 |
else |
| 280 |
gp_widget_set_value (widget, _("Off")); |
| 281 |
gp_widget_get_value (widget, &wvalue); |
| 282 |
|
| 283 |
gp_widget_new (GP_WIDGET_SECTION, _("Other"), §ion); |
| 284 |
gp_widget_append (*window, section); |
| 285 |
|
| 286 |
gp_widget_new (GP_WIDGET_BUTTON, "Set time to system time", &widget); |
| 287 |
gp_widget_append (section, widget); |
| 288 |
gp_widget_set_value (widget, dc210_system_time_callback); |
| 289 |
gp_widget_set_info (widget, _("Set clock in camera")); |
| 290 |
|
| 291 |
gp_camera_get_abilities(camera, &abilities); |
| 292 |
gp_port_get_settings (camera->port, &settings); |
| 293 |
gp_widget_new (GP_WIDGET_MENU, _("Port speed"), &widget); |
| 294 |
gp_widget_append (section, widget); |
| 295 |
for (i = 0; i < sizeof(abilities.speed); i++){ |
| 296 |
if (abilities.speed[i] == 0) break; |
| 297 |
snprintf(stringbuffer, 12, "%d", abilities.speed[i]); |
| 298 |
gp_widget_add_choice (widget, stringbuffer); |
| 299 |
if (settings.serial.speed == abilities.speed[i]) |
| 300 |
gp_widget_set_value (widget, stringbuffer); |
| 301 |
}; |
| 302 |
|
| 303 |
gp_widget_new (GP_WIDGET_TEXT, _("Album name"), &widget); |
| 304 |
gp_widget_append (section, widget); |
| 305 |
gp_widget_set_value (widget, status.album_name); |
| 306 |
gp_widget_set_info (widget, _("Name to set on card when formatting.")); |
| 307 |
|
| 308 |
gp_widget_new (GP_WIDGET_BUTTON, _("Format compact flash"), &widget); |
| 309 |
gp_widget_append (section, widget); |
| 310 |
gp_widget_set_value (widget, dc210_format_callback); |
| 311 |
gp_widget_set_info (widget, _("Format card and set album name.")); |
| 312 |
|
| 313 |
#ifdef DEBUG |
| 314 |
gp_widget_new (GP_WIDGET_SECTION, _("Debug"), §ion); |
| 315 |
gp_widget_append (*window, section); |
| 316 |
|
| 317 |
gp_widget_new (GP_WIDGET_TEXT, "Parameter 1", &widget); |
| 318 |
gp_widget_append (section, widget); |
| 319 |
gp_widget_set_value (widget, "0"); |
| 320 |
|
| 321 |
gp_widget_new (GP_WIDGET_TEXT, "Parameter 2", &widget); |
| 322 |
gp_widget_append (section, widget); |
| 323 |
gp_widget_set_value (widget, "0"); |
| 324 |
|
| 325 |
gp_widget_new (GP_WIDGET_TEXT, "Parameter 3", &widget); |
| 326 |
gp_widget_append (section, widget); |
| 327 |
gp_widget_set_value (widget, "0"); |
| 328 |
|
| 329 |
gp_widget_new (GP_WIDGET_BUTTON, "Execute debug command", &widget); |
| 330 |
gp_widget_append (section, widget); |
| 331 |
gp_widget_set_value (widget, dc210_debug_callback); |
| 332 |
gp_widget_set_info (widget, _("Execute predefined command\nwith parameter values.")); |
| 333 |
#endif |
| 334 |
|
| 335 |
return GP_OK; |
| 336 |
} |
| 337 |
|
| 338 |
static int |
| 339 |
camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) |
| 340 |
{ |
| 341 |
CameraWidget *w, *w2; |
| 342 |
char *wvalue, *w2value; |
| 343 |
unsigned int i; |
| 344 |
|
| 345 |
gp_widget_get_child_by_label (window, _("File type"), &w); |
| 346 |
if (gp_widget_changed (w)) { |
| 347 |
gp_widget_set_changed (w, 0); |
| 348 |
gp_widget_get_value (w, &wvalue); |
| 349 |
if (wvalue[0] == 'J') |
| 350 |
dc210_set_file_type(camera, DC210_FILE_TYPE_JPEG); |
| 351 |
else |
| 352 |
dc210_set_file_type(camera, DC210_FILE_TYPE_FPX); |
| 353 |
}; |
| 354 |
|
| 355 |
gp_widget_get_child_by_label (window, _("File resolution"), &w); |
| 356 |
if (gp_widget_changed (w)) { |
| 357 |
gp_widget_set_changed (w, 0); |
| 358 |
gp_widget_get_value (w, &wvalue); |
| 359 |
switch(wvalue[0]){ |
| 360 |
case '6': |
| 361 |
dc210_set_resolution(camera, DC210_FILE_640); |
| 362 |
break; |
| 363 |
case '1': |
| 364 |
dc210_set_resolution(camera, DC210_FILE_1152); |
| 365 |
break; |
| 366 |
}; |
| 367 |
}; |
| 368 |
|
| 369 |
gp_widget_get_child_by_label (window, _("File compression"), &w); |
| 370 |
if (gp_widget_changed (w)) { |
| 371 |
gp_widget_set_changed (w, 0); |
| 372 |
gp_widget_get_value (w, &wvalue); |
| 373 |
switch(wvalue[0]){ |
| 374 |
case 'L': |
| 375 |
dc210_set_compression(camera, DC210_LOW_COMPRESSION); |
| 376 |
break; |
| 377 |
case 'M': |
| 378 |
dc210_set_compression(camera, DC210_MEDIUM_COMPRESSION); |
| 379 |
break; |
| 380 |
case 'H': |
| 381 |
dc210_set_compression(camera, DC210_HIGH_COMPRESSION); |
| 382 |
}; |
| 383 |
}; |
| 384 |
|
| 385 |
gp_widget_get_child_by_label (window, _("Zoom"), &w); |
| 386 |
if (gp_widget_changed (w)) { |
| 387 |
gp_widget_set_changed (w, 0); |
| 388 |
gp_widget_get_value (w, &wvalue); |
| 389 |
switch(wvalue[0]){ |
| 390 |
case '5': |
| 391 |
if (wvalue[1] == '8') |
| 392 |
dc210_set_zoom(camera, DC210_ZOOM_58); |
| 393 |
else |
| 394 |
dc210_set_zoom(camera, DC210_ZOOM_51); |
| 395 |
break; |
| 396 |
case '4': |
| 397 |
dc210_set_zoom(camera, DC210_ZOOM_41); |
| 398 |
break; |
| 399 |
case '3': |
| 400 |
dc210_set_zoom(camera, DC210_ZOOM_34); |
| 401 |
break; |
| 402 |
case '2': |
| 403 |
dc210_set_zoom(camera, DC210_ZOOM_29); |
| 404 |
break; |
| 405 |
case 'M': |
| 406 |
dc210_set_zoom(camera, DC210_ZOOM_MACRO); |
| 407 |
break; |
| 408 |
}; |
| 409 |
}; |
| 410 |
|
| 411 |
gp_widget_get_child_by_label (window, _("Exposure compensation"), &w); |
| 412 |
if (gp_widget_changed (w)) { |
| 413 |
gp_widget_set_changed (w, 0); |
| 414 |
gp_widget_get_value (w, &wvalue); |
| 415 |
for (i = 0; i < sizeof(exp_comp)/sizeof(*exp_comp); i++){ |
| 416 |
if (strncmp(wvalue, exp_comp[i], 4) == 0){ |
| 417 |
dc210_set_exp_compensation(camera, i - 4); |
| 418 |
break; |
| 419 |
}; |
| 420 |
}; |
| 421 |
}; |
| 422 |
|
| 423 |
gp_widget_get_child_by_label (window, _("Port speed"), &w); |
| 424 |
if (gp_widget_changed (w)) { |
| 425 |
gp_widget_set_changed (w, 0); |
| 426 |
gp_widget_get_value (w, &wvalue); |
| 427 |
dc210_set_speed(camera, atoi(wvalue)); |
| 428 |
}; |
| 429 |
|
| 430 |
gp_widget_get_child_by_label (window, _("Flash"), &w); |
| 431 |
gp_widget_get_child_by_label (window, _("Red eye flash"), &w2); |
| 432 |
if (gp_widget_changed (w) || gp_widget_changed(w2)) { |
| 433 |
gp_widget_set_changed (w, 0); |
| 434 |
gp_widget_set_changed (w2, 0); |
| 435 |
gp_widget_get_value (w, &wvalue); |
| 436 |
gp_widget_get_value (w2, &w2value); |
| 437 |
switch(wvalue[0]){ |
| 438 |
case 'A': |
| 439 |
dc210_set_flash(camera, DC210_FLASH_AUTO, |
| 440 |
w2value[1] == 'n' ? 1 : 0); |
| 441 |
break; |
| 442 |
case 'F': |
| 443 |
dc210_set_flash(camera, DC210_FLASH_FORCE, |
| 444 |
w2value[1] == 'n' ? 1 : 0); |
| 445 |
break; |
| 446 |
case 'N': |
| 447 |
dc210_set_flash(camera, DC210_FLASH_NONE, 0); |
| 448 |
gp_widget_set_value(w2, _("Off")); |
| 449 |
break; |
| 450 |
}; |
| 451 |
}; |
| 452 |
|
| 453 |
return GP_OK; |
| 454 |
} |
| 455 |
|
| 456 |
static int camera_capture (Camera *camera, CameraCaptureType type, CameraFilePath *path, GPContext *context) { |
| 457 |
if (type && type != GP_CAPTURE_IMAGE){ |
| 458 |
DC210_DEBUG("Unsupported action 0x%.2X\n", type); |
| 459 |
return (GP_ERROR_NOT_SUPPORTED); |
| 460 |
}; |
| 461 |
|
| 462 |
if (dc210_capture(camera, path, context) == GP_ERROR) |
| 463 |
return GP_ERROR; |
| 464 |
|
| 465 |
return gp_filesystem_append (camera->fs, path->folder, path->name, context); |
| 466 |
} |
| 467 |
|
| 468 |
static int camera_capture_preview (Camera* camera, CameraFile* file, GPContext *context){ |
| 469 |
/* this function is to slow; don't export it */ |
| 470 |
int fatal_error = 0; |
| 471 |
|
| 472 |
if (dc210_take_picture(camera, context) == GP_ERROR) return GP_ERROR; |
| 473 |
if (dc210_download_last_picture(camera, file, DC210_FULL_PICTURE, context) == GP_ERROR) fatal_error = 1; |
| 474 |
if (dc210_delete_last_picture(camera) == GP_ERROR) fatal_error = 1; |
| 475 |
|
| 476 |
if (fatal_error) return GP_ERROR; |
| 477 |
|
| 478 |
return GP_OK; |
| 479 |
|
| 480 |
}; |
| 481 |
|
| 482 |
static int camera_summary (Camera *camera, CameraText *summary, GPContext *context) |
| 483 |
{ |
| 484 |
static char summary_string[2048] = ""; |
| 485 |
char buff[1024]; |
| 486 |
dc210_status status; |
| 487 |
|
| 488 |
if (GP_OK == dc210_get_status (camera, &status)) |
| 489 |
{ |
| 490 |
strcpy(summary_string, "Kodak DC210\n"); |
| 491 |
|
| 492 |
snprintf(buff, 1024, _("Pictures in camera: %d\n"), |
| 493 |
status.numPicturesInCamera); |
| 494 |
strcat(summary_string, buff); |
| 495 |
|
| 496 |
snprintf(buff, 1024, _("There is space for another\n %d low compressed\n %d medium compressed or\n %d high compressed pictures\n"), |
| 497 |
status.remainingLow, status.remainingMedium, status.remainingHigh); |
| 498 |
strcat(summary_string, buff); |
| 499 |
|
| 500 |
snprintf(buff, 1024, _("Total pictures taken: %d\n"), |
| 501 |
status.totalPicturesTaken); |
| 502 |
strcat(summary_string, buff); |
| 503 |
|
| 504 |
snprintf(buff, 1024, _("Total flashes fired: %d\n"), |
| 505 |
status.totalFlashesFired); |
| 506 |
strcat(summary_string, buff); |
| 507 |
|
| 508 |
snprintf(buff, 1024, _("Firmware: %d.%d\n"), status.firmwareMajor, status.firmwareMinor); |
| 509 |
strcat(summary_string, buff); |
| 510 |
|
| 511 |
switch (status.file_type) { |
| 512 |
case DC210_FILE_TYPE_JPEG: |
| 513 |
snprintf(buff, 1024, _("Filetype: JPEG (")); break; |
| 514 |
case DC210_FILE_TYPE_FPX: |
| 515 |
snprintf(buff, 1024, _("Filetype: FlashPix (")); break; |
| 516 |
}; |
| 517 |
strcat(summary_string, buff); |
| 518 |
|
| 519 |
switch (status.compression_type) { |
| 520 |
case DC210_LOW_COMPRESSION: |
| 521 |
snprintf(buff, 1024, _("low compression, ")); break; |
| 522 |
case DC210_MEDIUM_COMPRESSION: |
| 523 |
snprintf(buff, 1024, _("medium compression, ")); break; |
| 524 |
case DC210_HIGH_COMPRESSION: |
| 525 |
snprintf(buff, 1024, _("high compression, ")); break; |
| 526 |
default: |
| 527 |
snprintf(buff, 1024, _("unknown compression %d, "), status.compression_type); break; |
| 528 |
}; |
| 529 |
strcat(summary_string, buff); |
| 530 |
|
| 531 |
switch (status.resolution) { |
| 532 |
case DC210_FILE_640: |
| 533 |
snprintf(buff, 1024, "640x480 pixel)\n"); break; |
| 534 |
case DC210_FILE_1152: |
| 535 |
snprintf(buff, 1024, "1152x864 pixel)\n"); break; |
| 536 |
default: |
| 537 |
snprintf(buff, 1024, _("unknown resolution %d)\n"), status.resolution); break; |
| 538 |
}; |
| 539 |
strcat(summary_string, buff); |
| 540 |
|
| 541 |
/* battery check still doesn't work */ |
| 542 |
/* switch (status.battery){ |
| 543 |
case 0: snprintf(buff,1024,"Battery charge is good\n"); break; |
| 544 |
case 1: snprintf(buff,1024,"Battery charge is low\n"); break; |
| 545 |
case 2: snprintf(buff,1024,"Battery is not charged\n"); break; |
| 546 |
}; |
| 547 |
strcat(summary_string,buff);*/ |
| 548 |
|
| 549 |
if (status.acstatus) |
| 550 |
snprintf(buff, 1024, _("AC adapter is connected.\n")); |
| 551 |
else |
| 552 |
snprintf(buff, 1024, _("AC adapter is not connected.\n")); |
| 553 |
strcat(summary_string, buff); |
| 554 |
|
| 555 |
/* time string, do not change the % escapes */ |
| 556 |
strftime(buff, 1024, _("Time: %a, %d %b %Y %T\n"), |
| 557 |
localtime((time_t *)&status.time)); |
| 558 |
strcat(summary_string, buff); |
| 559 |
|
| 560 |
switch (status.zoom) { |
| 561 |
case DC210_ZOOM_58: |
| 562 |
snprintf(buff, 1024, _("Zoom: 58 mm\n")); break; |
| 563 |
case DC210_ZOOM_51: |
| 564 |
snprintf(buff, 1024, _("Zoom: 51 mm\n")); break; |
| 565 |
case DC210_ZOOM_41: |
| 566 |
snprintf(buff, 1024, _("Zoom: 41 mm\n")); break; |
| 567 |
case DC210_ZOOM_34: |
| 568 |
snprintf(buff, 1024, _("Zoom: 34 mm\n")); break; |
| 569 |
case DC210_ZOOM_29: |
| 570 |
snprintf(buff, 1024, _("Zoom: 29 mm\n")); break; |
| 571 |
case DC210_ZOOM_MACRO: |
| 572 |
snprintf(buff, 1024, _("Zoom: macro\n")); break; |
| 573 |
default: |
| 574 |
snprintf(buff, 1024, _("Unknown zoom mode %d\n"), |
| 575 |
status.zoom); break; |
| 576 |
}; |
| 577 |
strcat(summary_string, buff); |
| 578 |
|
| 579 |
if (status.exp_compensation > -5 && status.exp_compensation < 4) |
| 580 |
snprintf(buff, 1024, _("Exposure compensation: %s\n"), exp_comp[status.exp_compensation + 4]); |
| 581 |
else |
| 582 |
snprintf(buff, 1024, _("Exposure compensation: %d\n"), status.exp_compensation); |
| 583 |
strcat(summary_string, buff); |
| 584 |
|
| 585 |
switch (status.flash) { |
| 586 |
case DC210_FLASH_AUTO: |
| 587 |
snprintf(buff, 1024, _("Flash mode: auto, ")); break; |
| 588 |
case DC210_FLASH_FORCE: |
| 589 |
snprintf(buff, 1024, _("Flash mode: force, ")); break; |
| 590 |
case DC210_FLASH_NONE: |
| 591 |
snprintf(buff, 1024, _("Flash mode: off\n")); break; |
| 592 |
default: |
| 593 |
snprintf(buff, 1024, _("Unknown flash mode %d, "), |
| 594 |
status.flash); break; |
| 595 |
}; |
| 596 |
strcat(summary_string, buff); |
| 597 |
|
| 598 |
if (status.flash != DC210_FLASH_NONE) { |
| 599 |
if (status.preflash) |
| 600 |
/* trans: continuation of "Flash mode:" line */ |
| 601 |
snprintf(buff, 1024, _("red eye flash on.\n")); |
| 602 |
else |
| 603 |
/* trans: continuation of "Flash mode:" line */ |
| 604 |
snprintf(buff, 1024, _("red eye flash off.\n")); |
| 605 |
strcat(summary_string, buff); |
| 606 |
}; |
| 607 |
|
| 608 |
if (status.card_status.open == 0) |
| 609 |
snprintf(buff, 1024, _("No card in camera.\n")); |
| 610 |
else |
| 611 |
snprintf(buff, 1024, _("Card name: %s\nFree space on card: %d kB\n"), |
| 612 |
status.album_name, |
| 613 |
status.card_status.space); |
| 614 |
|
| 615 |
strcat(summary_string, buff); |
| 616 |
|
| 617 |
} else { |
| 618 |
DC210_DEBUG("Couldn't get summary for camera\n"); |
| 619 |
}; |
| 620 |
|
| 621 |
strcpy(summary->text, summary_string); |
| 622 |
|
| 623 |
return (GP_OK); |
| 624 |
} |
| 625 |
|
| 626 |
|
| 627 |
static int camera_manual (Camera *camera, CameraText *manual, |
| 628 |
GPContext *context) |
| 629 |
{ |
| 630 |
strcpy (manual->text, _("This library has been tested with a Kodak DC 215 Zoom camera. " |
| 631 |
"It might work also with DC 200 and DC 210 cameras. " |
| 632 |
"If you happen to have such a camera, please send a " |
| 633 |
"message to [email protected] to let me know, if you have any " |
| 634 |
"troubles with this driver library or if everything is okay.")); |
| 635 |
|
| 636 |
return (GP_OK); |
| 637 |
} |
| 638 |
|
| 639 |
static int camera_about (Camera *camera, CameraText *about, GPContext *context) |
| 640 |
{ |
| 641 |
strcpy(about->text, |
| 642 |
_("Camera Library for the Kodak DC215 Zoom camera.\n" |
| 643 |
"Michael Koltan <[email protected]>\n")); |
| 644 |
|
| 645 |
return (GP_OK); |
| 646 |
} |
| 647 |
|
| 648 |
static CameraFilesystemFuncs fsfuncs = { |
| 649 |
.file_list_func = file_list_func, |
| 650 |
.get_file_func = get_file_func, |
| 651 |
.get_info_func = get_info_func, |
| 652 |
.del_file_func = delete_file_func, |
| 653 |
}; |
| 654 |
|
| 655 |
int camera_init (Camera *camera, GPContext *context) { |
| 656 |
|
| 657 |
DC210_DEBUG("Initializing camera.\n"); |
| 658 |
|
| 659 |
/* First, set up all the function pointers */ |
| 660 |
camera->functions->get_config = camera_get_config; |
| 661 |
camera->functions->set_config = camera_set_config; |
| 662 |
camera->functions->capture = camera_capture; |
| 663 |
camera->functions->capture_preview = camera_capture_preview; |
| 664 |
camera->functions->summary = camera_summary; |
| 665 |
camera->functions->manual = camera_manual; |
| 666 |
camera->functions->about = camera_about; |
| 667 |
|
| 668 |
gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); |
| 669 |
|
| 670 |
if (dc210_init_port (camera) == GP_ERROR) return GP_ERROR; |
| 671 |
if (dc210_open_card (camera) == GP_ERROR) return GP_ERROR; |
| 672 |
|
| 673 |
return (GP_OK); |
| 674 |
} |
| 675 |
/****************************************************************************/ |