79 lines
2.3 KiB
C
79 lines
2.3 KiB
C
#include <unistd.h>
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <gphoto2/gphoto2.h>
|
|
#include <time.h>
|
|
|
|
#define FOCUS_WIDGET_NAME "manualfocusdrive"
|
|
#define VIEWFINDER_WIDGET_NAME "viewfinder"
|
|
|
|
/**
|
|
gp_widget_set_value(CameraWidget*, const void) <-sets value
|
|
gp_widget_get_child_by_label(CameraWidget* widget, const char* label, CameraWidget ** child) <- child is widget
|
|
gp_camera_get_config(Camera* camera, CameraWidget **window, GpContext* context) <- window is parent
|
|
|
|
camera_init(Camera* camera, GPContext *context)
|
|
|
|
|
|
Create context:
|
|
context = gp_context_new();
|
|
gp_context_set_error_func (context, ctx_error_func, NULL);
|
|
gp_context_set_status_func (context, ctx_status_func, NULL);
|
|
Create camera:
|
|
gp_camera_new(&camera); <- point to return value
|
|
|
|
**/
|
|
|
|
|
|
int set_widget_value(CameraWidget *widget, void *widget_value, const char *widget_name, Camera *camera, GPContext *context) {
|
|
int err;
|
|
if ((err = gp_widget_set_value(widget, widget_value)) != 0) {
|
|
printf("Error setting local widget value: %s\nThis is not the hardware\'s fault. Fix your code!\n", gp_result_as_string(err));
|
|
return(1);
|
|
}
|
|
if((err = gp_camera_set_single_config(camera, widget_name, widget, context)) != 0) {
|
|
printf("Error modifying camera widget: %s\n", gp_result_as_string(err));
|
|
return(2);
|
|
}
|
|
|
|
}
|
|
|
|
int main() {
|
|
char *focus_large_temp = "Near 3";
|
|
int viewfinder_state = 1; //wish there was a better way to do this...
|
|
int err;
|
|
Camera *cam;
|
|
CameraWidget *widget_root;
|
|
CameraWidget *focus_widget;
|
|
CameraWidget *liveview_widget;
|
|
|
|
GPContext *context = gp_context_new();
|
|
gp_camera_new(&cam);
|
|
|
|
//start up and connect to camera
|
|
printf("Initilizing camera...\n");
|
|
if ((err = gp_camera_init(cam, context)) != 0) {
|
|
printf("Couldn't connect to camera: %s\n", gp_result_as_string(err));
|
|
return(1);
|
|
}
|
|
|
|
//get configuration tree
|
|
gp_camera_get_config(cam, &widget_root, context);
|
|
//get child widgets
|
|
gp_widget_get_child_by_name(widget_root, FOCUS_WIDGET_NAME, &focus_widget);
|
|
gp_widget_get_child_by_name(widget_root, VIEWFINDER_WIDGET_NAME, &liveview_widget);
|
|
|
|
//set to liveview so we can ajust focus
|
|
set_widget_value(liveview_widget, &viewfinder_state, VIEWFINDER_WIDGET_NAME, cam, context);
|
|
|
|
|
|
|
|
|
|
gp_camera_exit(cam, context);
|
|
|
|
|
|
return(1);
|
|
|
|
}
|