adafruit / Adafruit-Raspberry-Pi-Python-Code

Adafruit library code for Raspberry Pi
1.43k stars 686 forks source link

Hardcoded reference to 0x70 address #150

Closed gavinB-orange closed 4 years ago

gavinB-orange commented 8 years ago

The last line of LEDBackpack.py contains an instantiation of LEDBackpack with address 0x70. If there is no device at this address, anyone using the library gets a series of

Error accessing 0x70: Check your I2C address
Error accessing 0x70: Check your I2C address
Error accessing 0x70: Check your I2C address
Error accessing 0x70: Check your I2C address

This fix is to remove the line, or add the usual if name == 'main' condition. Proposed patch:

diff --git a/Adafruit_LEDBackpack/Adafruit_LEDBackpack.py b/Adafruit_LEDBackpack/Adafruit_LEDBackpack.py
index 00d7ba6..32287bb 100644
--- a/Adafruit_LEDBackpack/Adafruit_LEDBackpack.py
+++ b/Adafruit_LEDBackpack/Adafruit_LEDBackpack.py
@@ -98,4 +98,5 @@ class LEDBackpack:
     if (update):
       self.writeDisplay()

-led = LEDBackpack(0x70)
+if __name__ == '__main__':
+    led = LEDBackpack(0x70)
ladyada commented 4 years ago

Thank you for the Issue! This library has been deprecated in favor of our python3 Blinka library. We have replaced all of the libraries that use this repo with CircuitPython libraries that are Python3 compatible, and support a wide variety of single board/linux computers!

Visit https://circuitpython.org/blinka for more information

CircuitPython has support for almost 200 different drivers, and a as well as FT232H support for Mac/Win/Linux!