hzeller / rpi-rgb-led-matrix

Controlling up to three chains of 64x64, 32x32, 16x32 or similar RGB LED displays using Raspberry Pi GPIO
GNU General Public License v2.0
3.71k stars 1.17k forks source link

Using keyboard input for python and raspberry pi 4 #1583

Closed pbullion closed 1 year ago

pbullion commented 1 year ago

I'm trying to use the console to change the running variable by just simply hitting enter or something on the keyboard. i keep striking out importing the keyboard from python.

Any ideas? have people run into this before? i get the must be running as root error, even tho i am. Thanks!

Screenshot 2023-08-21 at 6 48 21 PM
Scattercatt commented 9 months ago

I have run into this issue as well. I'm writing my program in python, and it seems like instantiating the RGBMatrix object does something to screw up privileges. Whenever I comment out the line, the keyboard.read_key() runs fine with no error. If I have it not commented out, I get the error OP is getting.

hzeller commented 9 months ago

The privileges are dropped by default to not run as root afterwards. https://github.com/hzeller/rpi-rgb-led-matrix/blob/a3eea997a9254b83ab2de97ae80d83588f696387/include/led-matrix.h#L422-L426 So you can change that by setting a different runtime option (there is an analog in the Python API).

Setting back the privileges should not really be a problem as you only need to be root in the beginning when you set up everything.

Scattercatt commented 9 months ago

Ah perfect thank you!