Pigpio

From Autopilot Wiki
Jump to: navigation, search

Pigpio is a C package with Python binding that Autopilot uses as its primary GPIO controller. It has advantages and disadvantages relative to something simpler like the typical RPi.GPIO package or gpiozero - eg. the ability to have better access to things like DMA for PWM, running scripts, waveforms, and so on. The disadvantages are that it is a relatively unwieldy process that doesn't die neatly, and it can cause some unexpected behaviors when care is not taken to configure it for your use. Read the docs for pigpio and edit the PIGPIOARGS Pref accordingly.

Troubleshooting

  • Audio: https://github.com/auto-pi-lot/autopilot/issues/199#issuecomment-1424525314
    • Problem: from Chris Rodgers, allowing pigpio to have control over the PCM clock can have unpredictable consequences on the audio server as it will try to use PWM or another clock in the system. In this case, playing with incorrect sampling rates.
    • Fix: If using audio with pigpio, use the -t 0 to set the clock used by pigpiod to PWM], leaving the PCM clock free for an external sound card like the various HiFiBerry cards.

Examples