Hi, I’ve been trying to work out the basics of using this library to write code for my LED matrix. I’ve got the demos working well with the addition of some runtime flags (–led-cols=64 etc.) however now that I’m trying to translate these into python code I am getting an error. The code is as follows:
#!/usr/bin/env python
from samplebase import SampleBase
import time
from rgbmatrix import RGBMatrix, RGBMatrixOptions, graphics
class LEDTest(SampleBase):
def init(self, *args, **kwargs):
super(LEDTest, self).init(*args, **kwargs)
def run(self):
ops = RGBMatrixOptions()
ops.hardware_mapping = 'adafruit-hat'
ops.rows = 32
ops.cols = 64
ops.gpio_slowdown = 2
ops.brightness = 50
matrix = RGBMatrix(options = ops)
font = graphics.Font()
font.LoadFont("../../../fonts/7x13.bdf")
red = graphics.Color(255, 0, 0)
graphics.DrawLine(matrix, 5, 5, 22, 13, red)
green = graphics.Color(0, 255, 0)
graphics.DrawCircle(matrix, 15, 15, 10, green)
blue = graphics.Color(0, 0, 255)
graphics.DrawText(matrix, font, 2, 10, blue, "Text")
time.sleep(10)
if name == “main”:
ledtest = LEDTest()
if (not ledtest.process()):
ledtest.print_help()
I run this using:
sudo python LEDtest.py
but get the following error message: “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.7”
Clearly, I am running as root so not sure what the problem is. The code runs but as warned the image is noisy and flickering. I am very new to python so apologies if I’m overlooking something simple.
Thanks