Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose RF24_DRIVER and fix linking to shared utility driver libs #46

Merged
merged 5 commits into from
Mar 19, 2024

Conversation

2bndy5
Copy link
Member

@2bndy5 2bndy5 commented Mar 19, 2024

This leverages CMake's target_compile_definitions() to expose the selected RF24_DRIVER as a module attribute. I wanted this to programmatically declare the right pin numbers in the examples.

from pyrf24 import RF24, RF24_PA_LOW, RF24_DRIVER
########### USER CONFIGURATION ###########
# See https://github.com/TMRh20/RF24/blob/master/pyRF24/readme.md
# Radio CE Pin, CSN Pin, SPI Speed
# CE Pin uses GPIO number with BCM and SPIDEV drivers, other platforms use
# their own pin numbering
# CS Pin addresses the SPI bus number at /dev/spidev<a>.<b>
# ie: RF24 radio(<ce_pin>, <a>*10+<b>); spidev1.0 is 10, spidev1.1 is 11 etc..
CSN_PIN = 0 # aka CE0 on SPI bus 0: /dev/spidev0.0
if RF24_DRIVER == "MRAA":
CE_PIN = 15 # for GPIO22
elif RF24_DRIVER == "wiringPi":
CE_PIN = 3 # for GPIO22
else:
CE_PIN = 22
radio = RF24(CE_PIN, CSN_PIN)

Important

In testing this, I found and fixed a problem when building this package with utility drivers pigpio, MRAA, and wiringPi. All of which were not properly found and linked to during the build... This constitutes a minor version bump.


Also replaced usage of pylint and black with ruff for linting and formatting python code.

use this new attr to declare different pin numbers according to the chosen driver in the examples
@2bndy5 2bndy5 added the enhancement New feature or request label Mar 19, 2024
Copy link
Member Author

@2bndy5 2bndy5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Backporting this to the individual RF24 wrapper can be tricky because it is compiling against installed library's binary. I might be able to extract the driver from certain #defines or the contents of /usr/local/includes/RF24/utility/includes.h

docs/conf.py Outdated Show resolved Hide resolved
- remove dependency on black and pylint
- remove pylint problem matcher script in .github/workflows
- ran `ruff format` and `ruff check` on all python sources
- remove pylint config
- remove pylint config ignore pattern in pkg MANIFEST.in template
affects wiringPi, pigpio, MRAA drivers.
Using these drivers previously to build from source ended up with undefined symbols in the dist.
@2bndy5 2bndy5 changed the title Expose rf24 driver Expose RF24_DRIVER and fix linking to shared utility driver libs Mar 19, 2024
@2bndy5 2bndy5 added the bug Something isn't working label Mar 19, 2024
@2bndy5 2bndy5 merged commit 0805c5f into main Mar 19, 2024
2 checks passed
@2bndy5 2bndy5 deleted the expose-rf24-driver branch March 19, 2024 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant