0

For a school project I wanted to use a 128x64 OLED i2c OLED screen and a RFID reader. I tested everything separate and it worked, but when I wanted to join everything in my main program it failed, because the library for the OLED screen used BCM numbering and the library for the RFID reader used BOARD numbering (just like I did). Is there a way to fix this, I searched the internet but couldn't find anyone with the same problem.

i2c library: https://github.com/adafruit/Adafruit_Python_SSD1306 RFID library: https://github.com/mxgxw/MFRC522-python (uses SPI)

Some extra information: it's a raspberry pi 3 and I use python 3. (I don't know if that's important to know, but better safe then sorry)

  • You can do a mapping during your setup, this table might be useful for you to map the BCM to Board or vice versa. – hcheung Jan 31 '18 at 1:40
  • @hcheung I understand that, but that is not my problem, I know that site, but it's impossible to change all the pins in the library – DwarfNebula Jan 31 '18 at 7:50
1

The library Adafruit_Python_SSD1306 is based on another library Adafruit_GPIO, if you read the Adafruit_GPIO github source code on get_platform_gpio(**keywords) function, you will noticed that it is actually just a wrapper of RPi.GPIO package, and returning a RPi.GPIO object. The RPi.GPIO does has the method setmode() for setting BOARD or BCM ping numbering, so you can map or specify the mode by passing a **keywords using the follow code:

import RPi.GPIO
import Adafruit_GPIO as GPIO

gpio = GPIO.get_platform_gpio(mode=RPi.GPIO.BOARD)

Now use the gpio object like normal, but with Pi board numbering.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.