LandscapeJohn
Member
- Joined
- Dec 7, 2022
- Messages
- 10
- Likes
- 14
Also, are you using Ubuntu? The reason I went with lgpio initially is that I had read that RPi.GPIO was unavailable on kernels newer than 5.11 -> https://ubuntu.com//blog/raspberry-pi-gpio-support-in-ubuntu but maybe this is no longer the case? Actually looking at this further it seems like RPi.GPIO may still be on the way out -> https://waldorf.waveform.org.uk/2022/the-one-where-dave-breaks-stuff.html.
Michael
That's a good point, it does look like RPi.GPIO is on borrowed time. The thing is that using a direct library seems WAY faster than using the lgpio method of accessing the pins. In my benchmark testing the old way is 11+ times faster than the new way. Maybe I'm doing something wrong but here's the result of five test runs using Python, one using lgpio and the other using RPi.GPIO:
john@camilla:~/source/pybench$ python3 t2.py ;python3 t3.py
lgpio 84111 toggles per second
RPi.GPIO 962372 toggles per second
john@camilla:~/source/pybench$ python3 t2.py ;python3 t3.py
lgpio 83317 toggles per second
RPi.GPIO 979529 toggles per second
john@camilla:~/source/pybench$ python3 t2.py ;python3 t3.py
lgpio 83688 toggles per second
RPi.GPIO 974429 toggles per second
john@camilla:~/source/pybench$ python3 t2.py ;python3 t3.py
lgpio 84055 toggles per second
RPi.GPIO 998126 toggles per second
john@camilla:~/source/pybench$ python3 t2.py ;python3 t3.py
lgpio 84964 toggles per second
RPi.GPIO 1027179 toggles per second
Doing a similar test with C comparing pigpio to lgpio shows an even greater improvement with pigpio being 27+ times faster than lgpio:
john@camilla:~/source/bench$ ./lgpio ;sudo ./pigpio
C lgpio: 141463 toggles per second
C pigpio: 3900408 toggles per second
john@camilla:~/source/bench$ ./lgpio ;sudo ./pigpio
C lgpio: 141355 toggles per second
C pigpio: 4009276 toggles per second
john@camilla:~/source/bench$ ./lgpio ;sudo ./pigpio
C lgpio: 139096 toggles per second
C pigpio: 3930747 toggles per second
john@camilla:~/source/bench$ ./lgpio ;sudo ./pigpio
C lgpio: 142311 toggles per second
C pigpio: 3885954 toggles per second
john@camilla:~/source/bench$ ./lgpio ;sudo ./pigpio
C lgpio: 141962 toggles per second
C pigpio: 3735742 toggles per second
john@camilla:~/source/bench$
For what it's worth I'm using Ubuntu 22.04.1 LTS with kernel 5.15.0-1023-raspi.
Here's my modified version of the OLED Python script.Please feel free to share any modifications to oled.py.