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

Allow to not use BOARD pin numbers #1

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions RFM69/radio.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ def __init__(self, freqBand, nodeID, networkID=100, **kwargs):
auto_acknowledge (bool): Automatically send acknowledgements
isHighPower (bool): Is this a high power radio model
power (int): Power level - a percentage in range 10 to 100.
interruptPin (int): Pin number of interrupt pin. This is a pin index not a GPIO number.
resetPin (int): Pin number of reset pin. This is a pin index not a GPIO number.
board_pin_numbers (bool): Force BOARD (not BCM) pin numbers. Defaults to True.
interruptPin (int): Pin number of interrupt pin.
resetPin (int): Pin number of reset pin.
spiBus (int): SPI bus number.
spiDevice (int): SPI device number.
promiscuousMode (bool): Listen to all messages not just those addressed to this node ID.
Expand All @@ -38,10 +39,12 @@ def __init__(self, freqBand, nodeID, networkID=100, **kwargs):

self.address = nodeID

self.board_pin_numbers = kwargs.get('board_pin_numbers', True)

self.auto_acknowledge = kwargs.get('autoAcknowledge', True)
self.isRFM69HW = kwargs.get('isHighPower', True)
self.intPin = kwargs.get('interruptPin', 18)
self.rstPin = kwargs.get('resetPin', 29)
self.intPin = kwargs.get('interruptPin', 18 if self.board_pin_numbers else 24)
self.rstPin = kwargs.get('resetPin', 29 if self.board_pin_numbers else 5)
self.spiBus = kwargs.get('spiBus', 0)
self.spiDevice = kwargs.get('spiDevice', 0)
self.promiscuousMode = kwargs.get('promiscuousMode', 0)
Expand Down Expand Up @@ -74,7 +77,9 @@ def __init__(self, freqBand, nodeID, networkID=100, **kwargs):
self._init_interrupt()

def _init_gpio(self):
GPIO.setmode(GPIO.BOARD)
if self.board_pin_numbers:
GPIO.setmode(GPIO.BOARD)

GPIO.setup(self.intPin, GPIO.IN)
GPIO.setup(self.rstPin, GPIO.OUT)

Expand Down
15 changes: 10 additions & 5 deletions build/lib/RFM69/radio.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ def __init__(self, freqBand, nodeID, networkID=100, **kwargs):
auto_acknowledge (bool): Automatically send acknowledgements
isHighPower (bool): Is this a high power radio model
power (int): Power level - a percentage in range 10 to 100.
interruptPin (int): Pin number of interrupt pin. This is a pin index not a GPIO number.
resetPin (int): Pin number of reset pin. This is a pin index not a GPIO number.
board_pin_numbers (bool): Force BOARD (not BCM) pin numbers. Defaults to True.
interruptPin (int): Pin number of interrupt pin.
resetPin (int): Pin number of reset pin.
spiBus (int): SPI bus number.
spiDevice (int): SPI device number.
promiscuousMode (bool): Listen to all messages not just those addressed to this node ID.
Expand All @@ -38,10 +39,12 @@ def __init__(self, freqBand, nodeID, networkID=100, **kwargs):

self.address = nodeID

self.board_pin_numbers = kwargs.get('board_pin_numbers', True)

self.auto_acknowledge = kwargs.get('autoAcknowledge', True)
self.isRFM69HW = kwargs.get('isHighPower', True)
self.intPin = kwargs.get('interruptPin', 18)
self.rstPin = kwargs.get('resetPin', 29)
self.intPin = kwargs.get('interruptPin', 18 if self.board_pin_numbers else 24)
self.rstPin = kwargs.get('resetPin', 29 if self.board_pin_numbers else 5)
self.spiBus = kwargs.get('spiBus', 0)
self.spiDevice = kwargs.get('spiDevice', 0)
self.promiscuousMode = kwargs.get('promiscuousMode', 0)
Expand Down Expand Up @@ -74,7 +77,9 @@ def __init__(self, freqBand, nodeID, networkID=100, **kwargs):
self._init_interrupt()

def _init_gpio(self):
GPIO.setmode(GPIO.BOARD)
if self.board_pin_numbers:
GPIO.setmode(GPIO.BOARD)

GPIO.setup(self.intPin, GPIO.IN)
GPIO.setup(self.rstPin, GPIO.OUT)

Expand Down