Add a verbosity flag to getframe

This commit is contained in:
Martijn Braam
2024-02-14 14:25:27 +01:00
parent 2f369fbab1
commit bd1ea477f8
3 changed files with 18 additions and 1 deletions

View File

@@ -123,6 +123,9 @@ typedef struct _lmp_aaa {
EXPORT int
libmegapixels_init(libmegapixels_devconfig **config);
EXPORT void
libmegapixels_loglevel(int loglevel);
EXPORT int
libmegapixels_load_file(libmegapixels_devconfig *config, const char *file);

View File

@@ -17,6 +17,12 @@ init_log(int level)
}
}
void
libmegapixels_loglevel(int level)
{
loglevel = level;
}
void
log_error(const char *fmt, ...)
{

View File

@@ -37,6 +37,7 @@ usage(char *name)
fprintf(stderr, " -c camera Use a specific camera number\n");
fprintf(stderr, " -m modenum Use another camera mode than the first\n");
fprintf(stderr, " -o file File to store the frame in\n");
fprintf(stderr, " -v Show verbose debug info\n");
fprintf(stderr, " -h Display this help text\n");
}
@@ -50,8 +51,9 @@ main(int argc, char *argv[])
char *outfile = NULL;
int count = 5;
int mode_idx = 0;
int verbose = 0;
while ((c = getopt(argc, argv, "hc:n:o:m:")) != -1) {
while ((c = getopt(argc, argv, "hvc:n:o:m:")) != -1) {
switch (c) {
case 'c':
res = strtol(optarg, &end, 10);
@@ -84,6 +86,9 @@ main(int argc, char *argv[])
usage(argv[0]);
return 0;
break;
case 'v':
verbose = 1;
break;
case '?':
if (optopt == 'd' || optopt == 'l') {
fprintf(stderr, "Option -%c requires an argument.\n", optopt);
@@ -104,6 +109,9 @@ main(int argc, char *argv[])
int ret = libmegapixels_find_config(configpath);
libmegapixels_devconfig *config = {0};
libmegapixels_init(&config);
if (verbose) {
libmegapixels_loglevel(2);
}
if (ret) {
printf("Using config: %s\n", configpath);