# Changing default parameters

**URL:** <https://rpi-rgb-led-matrix.discourse.group/t/changing-default-parameters/324>\
**Category:** Uncategorized\
**Created:** [September 12, 2021, 7:57pm UTC](https://rpi-rgb-led-matrix.discourse.group/t/changing-default-parameters/324 "2021-09-12T19:57:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PoopTrainDix](https://avatars.discourse-cdn.com/v4/letter/p/97f17d/32.png) [@PoopTrainDix](https://rpi-rgb-led-matrix.discourse.group/u/PoopTrainDix)\
**Post date:** [September 12, 2021, 7:57pm UTC](https://rpi-rgb-led-matrix.discourse.group/t/changing-default-parameters/324/1 "2021-09-12T19:57:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![marcmerlin](https://yyz2.discourse-cdn.com/free1/user_avatar/rpi-rgb-led-matrix.discourse.group/marcmerlin/32/40_2.png) [@marcmerlin](https://rpi-rgb-led-matrix.discourse.group/u/marcmerlin)\
**Post date:** [September 16, 2021, 10:43am UTC](https://rpi-rgb-led-matrix.discourse.group/t/changing-default-parameters/324/2 "2021-09-16T10:43:27Z")

</div>

can you look at what I did there?

> <https://github.com/marcmerlin/FastLED_NeoMatrix_SmartMatrix_LEDMatrix_GFX_Demos/blob/97387c52856690374e12631e895f6d6d2668e6dc/neomatrix_config.h#L1186>

---

<div class="post-metadata">

**Author:** ![PoopTrainDix](https://avatars.discourse-cdn.com/v4/letter/p/97f17d/32.png) [@PoopTrainDix](https://rpi-rgb-led-matrix.discourse.group/u/PoopTrainDix)\
**Post date:** [September 25, 2021, 12:46am UTC](https://rpi-rgb-led-matrix.discourse.group/t/changing-default-parameters/324/3 "2021-09-25T00:46:48Z")

</div>

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](https://github.com/hzeller/rpi-rgb-led-matrix#changing-parameters-via-command-line-flags)  
//  
// 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!
