Changing default parameters

Hello all,

I have a noob question about changing the default parameters in the led-matrix.h file.

First off - what do I do with it? I see this bit of code:

#include “led-matrix.h”

using rgb_matrix::RGBMatrix;

int main(int argc, char **argv) {
// Set some defaults
RGBMatrix::Options my_defaults;
my_defaults.hardware_mapping = “adafruit-hat”; // or e.g. “adafruit-hat” or “adafruit-hat-pwm”
my_defaults.chain_length = 2;
my_defaults.show_refresh_rate = true;
rgb_matrix::RuntimeOptions runtime_defaults;
// If you drop privileges, the root user you start the program with
// to be able to initialize the hardware will be switched to an unprivileged
// user to minimize a potential security attack surface.
runtime_defaults.drop_privileges = 1;
RGBMatrix *matrix = RGBMatrix::CreateFromFlags(&argc, &argv,
&my_defaults,
&runtime_defaults);
if (matrix == NULL) {
PrintMatrixFlags(stderr, my_defaults, runtime_defaults);
return 1;
}

// matrix->ApplyPixelMapper(…); // Optional

// Do your own command line handling with the remaining options.

// … now use matrix

delete matrix; // Make sure to delete it in the end.
}

Where do I put this? Do I need to insert it into the led-matrix.h file?

I have two 32x64 running chained (32x128) and using “adafruit-hat”, but when I enter these values into the led-matrix.h with the aforementioned code, adding " my_defaults.rows=32" and " my_defaults.cols=64", and then I run ./demo, it just says that all the standard defaults are all still the same defaults without any changes.

Thank you!!

Mikey

can you look at what I did there?

I went through the “led-matrix.h” file and made the following changes:

// Convenience utility functions to read standard rgb-matrix flags and create
// a RGBMatrix. Commandline flags are something like --led-rows, --led-chain,
// --led-parallel. See output of PrintMatrixFlags() for all available options
// and detailed description in
// GitHub - hzeller/rpi-rgb-led-matrix: Controlling up to three chains of 64x64, 32x32, 16x32 or similar RGB LED displays using Raspberry Pi GPIO
//
// Example use:

using rgb_matrix::RGBMatrix;
int main(int argc, char **argv) {
RGBMatrix::Options led_options;
rgb_matrix::RuntimeOptions runtime;
// Set defaults

led_options.chain_length = 2;
led_options.rows=32;
led_options.cols=64;
led_options.hardware_mapping= “adafruit-hat”;

led_options.show_refresh_rate = true;
runtime.drop_privileges = 1;
if (!rgb_matrix::ParseOptionsFromFlags(&argc, &argv, &led_options, &runtime)) {
rgb_matrix::PrintMatrixFlags(stderr);
return 1;
}
// Do your own command line handling with the remaining flags.
while (getopt()) {…}
// Looks like we’re ready to start
RGBMatrix *matrix = RGBMatrix::CreateFromOptions(led_options, runtime);
if (matrix == NULL) {
return 1;
}
// … now use matrix
delete matrix; // Make sure to delete it in the end to switch off LEDs.
return 0;
}

// This parses the flags from argv and updates the structs with the parsed-out
// values. Structs can be NULL if you are not interested in it.

But I’m still getting:

Size: 32x32. Hardware gpio mapping: regular

Do I also need to change the “led-matrix-c.h” file?

thanks!