o C-API: Report back options actually used.

This commit is contained in:
Henner Zeller 2016-09-16 18:24:34 -07:00
parent f0fb12d716
commit cc96e209c6
2 changed files with 21 additions and 1 deletions

View file

@ -102,12 +102,17 @@ struct RGBLedMatrixOptions {
/**
* Universal way to create and initialize a matrix.
* The "options" struct (if not NULL) contains all configuration values
* The "options" struct (if not NULL) contains all default configuration values
* chosen by the programmer to create the matrix.
*
* If "argc" and "argv" are provided, this function also reads command line
* flags provided, that then can override any of the defaults given.
* The arguments that have been used from the command line are removed from
* the argv list (and argc is adjusted) - that way these don't mess with your
* own command line handling.
*
* The actual options used are filled back into the "options" struct if not
* NULL.
*
* Usage:
* ----------------

View file

@ -75,6 +75,21 @@ struct RGBLedMatrix *led_matrix_create_from_options(
}
}
if (opts) {
#define ACTUAL_VALUE_BACK_TO_OPT(o) opts->o = default_opts.o
ACTUAL_VALUE_BACK_TO_OPT(rows);
ACTUAL_VALUE_BACK_TO_OPT(chain_length);
ACTUAL_VALUE_BACK_TO_OPT(parallel);
ACTUAL_VALUE_BACK_TO_OPT(pwm_bits);
ACTUAL_VALUE_BACK_TO_OPT(brightness);
ACTUAL_VALUE_BACK_TO_OPT(scan_mode);
ACTUAL_VALUE_BACK_TO_OPT(disable_hardware_pulsing);
ACTUAL_VALUE_BACK_TO_OPT(show_refresh_rate);
ACTUAL_VALUE_BACK_TO_OPT(swap_green_blue);
ACTUAL_VALUE_BACK_TO_OPT(inverse_colors);
#undef ACTUAL_VALUE_BACK_TO_OPT
}
rgb_matrix::RGBMatrix *matrix = CreateMatrixFromOptions(matrix_options,
runtime_opt);
return from_matrix(matrix);