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

Change pin numbering from BOARD to BCM #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ In order to use this tangoDS you need to specify the occupied GPIO of Raspbrerry

You can see the pinout of RaspberryPI GPIO in the picture below:
![](doc/gpio-pinout.png)
The TangoDS uses the internal GPIO numbering of the Broadcom chip as set by the command

`GPIO.setmode(GPIO.BCM) . `

## Authors
Leonid Lunin
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="tangods_rpigpio",
version="0.0.2",
version="0.0.3",
description="tango device to control raspberry GPIO",
author="Leonid Lunin",
author_email="[email protected]",
Expand All @@ -14,7 +14,7 @@
"pytango",
"RPi.GPIO>=0.7.0",
],
url="https://github.com/lrlunin/pytango-moenchZmqServer",
url="https://github.com/MBI-Div-B/pytango-raspigpio",
keywords=[
"tango device",
"tango",
Expand Down
5 changes: 3 additions & 2 deletions tangods_rpigpio/rpigpio.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def initialize_dynamic_attributes(self):
access=AttrWriteType.READ_WRITE if gpio_mode == "OUT" else AttrWriteType.READ,
fget=self.gpio_read,
fset=self.gpio_write if gpio_mode == "OUT" else None,
memorized=True,
memorized=True if gpio_mode == "OUT" else False,
)
self.add_attribute(attr)

Expand All @@ -38,7 +38,8 @@ def gpio_write(self, attr):
def init_device(self):
Device.init_device(self)
if self.validate_properties():
GPIO.setmode(GPIO.BOARD)
# use internal chip numbering of GPIOs
GPIO.setmode(GPIO.BCM)
self.gpio_dict = dict(zip(self.GPIO_LABELS, self.GPIO_PINS))
for gpio_pin, gpio_mode in zip(self.GPIO_PINS, self.GPIO_MODES):
try:
Expand Down