Skip to content

Rp5 - #18

Open
alexevag wants to merge 14 commits into
mainfrom
rp5
Open

Rp5#18
alexevag wants to merge 14 commits into
mainfrom
rp5

Conversation

@alexevag

Copy link
Copy Markdown
Collaborator

Description

Adds Raspberry Pi 5 support to EthoPy and fixes the display and proximity problems that surfaced while running experiments in the Pi 5.

The Pi 5 dropped the memory-mapped GPIO access that pigpio and the classic RPi.GPIO rely on, so the existing RPPorts interface cannot drive a Pi 5 rig at all. This branch adds a parallel RPPorts5 interface built on rpi-lgpio and lgpio, leaving RPPorts untouched for the Pi 4 setups already in the lab.

New Pi 5 interface (src/ethopy/interfaces/RPPorts5.py)

  • RPPorts5, a full Interface implementation on rpi-lgpio, covering lick detection, proximity, liquid reward, odor, opto stimulation, and sync in/out.
  • Liquid reward pulses go through lgpio.tx_pulse, so the pulse width is timed in hardware rather than by a sleeping Python thread.
  • Sound generation is rebuilt on RPi.GPIO.PWM in place of pigpio wave generation, with a threading.Event to stop continuous and pulsed tones cleanly.
  • The import guard raises a clear ImportError naming rpi-lgpio when the package is missing, instead of failing later at first GPIO call.

Proximity timer fix (RPPorts.py, RPPorts5.py)

The ready timer was restarted on every proximity edge while the animal stayed in position, so the dwell time it measured was reset. It now starts only on a real entry, when the stored position was previously empty. The same fix is applied to both interfaces so their behaviour stays identical.

Display setup (start.py, calibrate.py)

Both pygame screens hardcoded a resolution and requested it explicitly with the fullscreen flag. On a Pi 5 a requested size that differs from the actual desktop mode returns a surface that segfaults on reports its dimensions in the opposite order on some units. Both now ask SDL for the desktop resolution with set_mode((0, 0), FULLSCREEN) and read the real dimensions back from the surface, then scale every font size and widget position from those. This makes the welcome screen and the calibration screen usable on any panel rather than only on 800x480.

- Migrate RPPorts interface to Pi 5 compatible implementation using RPi.GPIO (lgpio backend)
- Add Pi 5 compatible display initialization with auto-detection and frame buffer support in calibration and welcome screens
- Improve pygame display handling with fullscreen support, proper scaling, and FPS control
scales the numpad button padding, which the branch had left at fixed 800x480 values while scaling the rectangles drawn behind them.
unpacks width and height in the right order, and skips the assignment when the framebuffer read fails. Previously a failed read returned None and the unpack raised TypeError, which the surrounding except pygame.error would not have caught.
The ready timer was restarted on every proximity edge while the animal stayed in position, so the dwell time it measured was reset by switch bounce. It now starts only on a real entry, when the stored position was previously empty. The same fix is applied to both interfaces so their behaviour stays identical.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant