Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Available options are
-h Print this help screen and exit
-i control_variable Ignore control with defined variable name\n");
-l List available controls
-p file Load camera preset file
-v device V4L2 Video Capture device

# default config file - /boot/camera.txt
Expand Down
24 changes: 17 additions & 7 deletions camera-ctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ static char * v4l2_devname = "/dev/video0";
static int v4l2_dev_fd;
static unsigned int v4l2_dev_pixelformat;
static char * config_file = "/boot/camera.txt";
char * preset_file = NULL;
static int highlight = 0;
static int last_offset = 0;

Expand Down Expand Up @@ -431,12 +432,12 @@ static void control_free()
}
}

static void control_load()
static void control_load(char * control_file)
{
char name[30];
int value;
int i;
FILE * fp = fopen(config_file, "r");
FILE * fp = fopen(control_file, "r");

if (fp != NULL) {
// Assume control=value file format
Expand All @@ -451,10 +452,10 @@ static void control_load()
}
}
}
mvprintw(0, 20, "Config file %s loaded", config_file);
mvprintw(0, 20, "Config file %s loaded", control_file);
fclose(fp);
} else {
mvprintw(0, 20, "Cannot load %s", config_file);
mvprintw(0, 20, "Cannot load %s", control_file);
}
refresh();
}
Expand Down Expand Up @@ -673,6 +674,10 @@ static int init()
goto end;
}

if (preset_file != NULL) {
control_load(preset_file);
}

curs_set(0);
initscr();
clear();
Expand Down Expand Up @@ -765,7 +770,7 @@ static int init()
case 'l':
mvprintw(0, 20, "%*s", 58, " ");
if (!DEBUG) {
control_load();
control_load(config_file);
}
break;

Expand Down Expand Up @@ -815,14 +820,15 @@ static void usage(const char * argv0)
fprintf(stderr, " -h Print this help screen and exit\n");
fprintf(stderr, " -i control_variable Ignore control with defined name\n");
fprintf(stderr, " -l List available controls\n");
fprintf(stderr, " -p file Load camera preset file\n");
fprintf(stderr, " -v device V4L2 Video Capture device\n");
}

int main(int argc, char * argv[])
{
int opt;

while ((opt = getopt(argc, argv, "c:dhi:lv:")) != -1) {
while ((opt = getopt(argc, argv, "c:dhi:lp:v:")) != -1) {
switch (opt) {
case 'c':
config_file = optarg;
Expand All @@ -848,6 +854,10 @@ int main(int argc, char * argv[])
list_controls = true;
break;

case 'p':
preset_file = optarg;
break;

case 'v':
v4l2_devname = optarg;
break;
Expand All @@ -862,4 +872,4 @@ int main(int argc, char * argv[])
err:
usage(argv[0]);
return 1;
}
}