I am trying to use the rb-matrixctrl (from joy-it) with a button in my pi4B, since the rb-matrixctrl is using all pins but two (27, 28 for the i2c id eeprom), i am tring to use one of those for my button, i have made two different scripts that work correctly along, but when i mixed them i get an error.
i disabled eeprom by adding this "dtoverlay=disable-eeprom" at the end of config.txt
https://joy-it.net/en/products/RB-MatrixCtrl
### buttonTest.py - works
### matrixTest.py - works
### prototypeTest.py - does not work
### command### error
i disabled eeprom by adding this "dtoverlay=disable-eeprom" at the end of config.txt
https://joy-it.net/en/products/RB-MatrixCtrl
### buttonTest.py - works
Code:
from gpiozero import Buttonfrom signal import pausedef pressed(): print("button was pressed")def released(): print("button was released")btn = Button(0, bounce_time=0.1) # pin 27 (GPIO 0)btn.when_pressed = pressedbtn.when_released = releasedpause() # Keeps the script running
Code:
from samplebase import SampleBaseimport timeclass CustomSampleBase(SampleBase): def __init__(self, *args, **kwargs): super(CustomSampleBase, self).__init__(*args, **kwargs) def run(self): offscreen_canvas = self.matrix.CreateFrameCanvas()# 2. left to right > top to bottom for y in range(32): for x in range(64): offscreen_canvas.SetPixel(x, y, 255, 0, 0) self.matrix.SwapOnVSync(offscreen_canvas) time.sleep(0.01) # pause for visual effect print("\nPress Enter to exit...") input()# Main functionif __name__ == "__main__": customSB = CustomSampleBase() if (not customSB.process()): customSB.print_help()
Code:
#!/usr/bin/env pythonfrom gpiozero import Buttonfrom signal import pausefrom samplebase import SampleBaseimport timeclass CustomSampleBase(SampleBase): def __init__(self, *args, **kwargs): super(CustomSampleBase, self).__init__(*args, **kwargs) def run_animation(self): offscreen_canvas = self.matrix.CreateFrameCanvas() for y in range(32): for x in range(64): offscreen_canvas.SetPixel(x, y, 255, 0, 0) self.matrix.SwapOnVSync(offscreen_canvas) time.sleep(0.01) # visual effect print("Animation finished.")# Initialize matrixcustomSB = CustomSampleBase()if not customSB.process(): customSB.print_help() exit(1)# Button setupdef pressed(): print("Button was pressed. Running animation...") customSB.run_animation()def released(): print("Button was released.")btn = Button(0, bounce_time=0.1) # GPIO 0 (pin 27)btn.when_pressed = pressedbtn.when_released = releasedprint("Waiting for button press...")pause()
Code:
sudo python prototypeTest.py --led-rows=32 --led-cols=64 --led-slowdown-gpio=4 --led-brightness=80 --led-no-hardware-pulse=1 --led-multiplexing=1
Code:
(venv) pi@pi001:~/ws/rpi-rgb-led-matrix/bindings/python/samples $ sudo python prototypeTest.py --led-rows=32 --led-cols=64 --led-slowdown-gpio=4 --led-brightness=80 --led-no-hardware-pulse=1 --led-multiplexing=1Press CTRL-C to stop sampleRunning2025-04-08 17:58:40 lguGetWorkDir: can't set working directory (Permission denied)2025-04-08 17:58:40 xCreatePipe: Can't set permissions (436) for /home/pi/ws/rpi-rgb-led-matrix/bindings/python/samples/.lgd-nfy0, Permission denied/usr/lib/python3/dist-packages/gpiozero/devices.py:300: PinFactoryFallback: Falling back from lgpio: [Errno 2] No such file or directory: '.lgd-nfy-3' warnings.warn(Traceback (most recent call last): File "/usr/lib/python3/dist-packages/gpiozero/pins/pi.py", line 411, in pin pin = self.pins[info] ~~~~~~~~~^^^^^^KeyError: PinInfo(number=27, name='GPIO0', names=frozenset({0, 'GPIO0', '0', 'BOARD27', 'BCM0', 'WPI30', 'J8:27'}), pull='', row=14, col=1, interfaces=frozenset({'', 'uart', 'dpi', 'i2c', 'gpio', 'spi'}))During handling of the above exception, another exception occurred:Traceback (most recent call last): File "/home/pi/ws/rpi-rgb-led-matrix/bindings/python/samples/prototypeTest.py", line 41, in <module> File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 108, in __call__ self = super().__call__(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/gpiozero/input_devices.py", line 412, in __init__ super().__init__( File "/usr/lib/python3/dist-packages/gpiozero/mixins.py", line 417, in __init__ super().__init__(*args, **kwargs) File "/usr/lib/python3/dist-packages/gpiozero/input_devices.py", line 162, in __init__ super().__init__( File "/usr/lib/python3/dist-packages/gpiozero/mixins.py", line 243, in __init__ super().__init__(*args, **kwargs) File "/usr/lib/python3/dist-packages/gpiozero/input_devices.py", line 79, in __init__ super().__init__(pin, pin_factory=pin_factory) File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 553, in __init__ pin = self.pin_factory.pin(pin) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/gpiozero/pins/pi.py", line 413, in pin pin = self.pin_class(self, info) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/gpiozero/pins/rpigpio.py", line 101, in __init__ GPIO.setup(self._number, GPIO.IN, self.GPIO_PULL_UPS[self._pull])RuntimeError: No access to /dev/mem. Try running as root!
Statistics: Posted by luckyMERLO — Tue Apr 08, 2025 5:41 pm