Changing RGBMatrixOptions programmatically does not work in Python

Hello,

I am trying to write a program that should change the rotation programmatically upon some event.

I start the program with default options: the option led-pixel-mapper value is set to whatever is given via --led-pixel-mapper program argument.

But when in runtime I want to change this value:

self.matrix.options.pixel_mapper_config = "Rotate:270"

I get this error:

AttributeError: 'rgbmatrix.core.RGBMatrix' object has no attribute 'options'

I know this is a noob question but I am new to Python and would appreciate your help very much.

I tried to re-create the whole RGBMatrix object using a workaround, but then I am getting this error:

Can't set realtime thread priority=99: Operation not permitted.
        You are probably not running as root ?
        This will seriously mess with color stability and flicker
        of the matrix. Please run as `root` (e.g. by invoking this
        program with `sudo`), or setting the capability on this
        binary by calling
        sudo setcap 'cap_sys_nice=eip' /usr/bin/python3.9

Yes, I am running as root and I did call the setcap, but this has had no effect.

Thanks.

Hello mate :slight_smile:

Might be a bit late, but i just started my own project with this api a couple of days ago.

To answer your two questions:

At least the bindinds of python does not have any reference to the options after cython initialized the object. The only things you can change afterwards are “luminanceCorrection”, “pwmBits”, “brightness”, “height” and “width”. You can check out the doc here core.pyx

As also mention in his endless pages of explanation, the api does drop priviliges after initializing the hardware, so you cant recreate another instance of the RGBMatrix without an error. If you want to prevent that you can
(A) use the flag –led-no-drop-privs or
(B) change the value from options.drop_privileges = False
I didnt tested this so far, since i dont know a reason to change the matrix afterwards, but as of my understand this should be a workaround.

"You need to start programs as root as it needs to access some low-level hardware at initialization time. After that, it is typically not desirable to stay in this role, so the library then drops the privileges.

This flag allows to switch off this behavior, so that you stay root. Not recommended unless you have a specific reason for it (e.g. you need root to access other hardware or you do the privilege dropping yourself)."