From cc96e209c645dc53e3bafdaf8d89a3ecda8dfeb8 Mon Sep 17 00:00:00 2001 From: Henner Zeller Date: Fri, 16 Sep 2016 18:24:34 -0700 Subject: [PATCH] o C-API: Report back options actually used. --- include/led-matrix-c.h | 7 ++++++- lib/led-matrix-c.cc | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/include/led-matrix-c.h b/include/led-matrix-c.h index b7c74ba..e999e6a 100644 --- a/include/led-matrix-c.h +++ b/include/led-matrix-c.h @@ -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: * ---------------- diff --git a/lib/led-matrix-c.cc b/lib/led-matrix-c.cc index ce0660b..f20c07f 100644 --- a/lib/led-matrix-c.cc +++ b/lib/led-matrix-c.cc @@ -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);