summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorCarter Nelson <caternuson@gmail.com>2017-10-25 17:32:00 -0700
committerScott Shawcroft <scott@tannewt.org>2017-10-25 17:32:00 -0700
commitdb918da5f0624e3cc723e7def3d805755f4cffa2 (patch)
tree629b7a3bf2ae614b8a41871e24323789a3fb9ea3 /docs
parentca1a9b9a102b0d4937dd1bbc03b912281c12b6c4 (diff)
updated I2C example (#371)
Diffstat (limited to 'docs')
-rw-r--r--docs/design_guide.rst7
1 files changed, 4 insertions, 3 deletions
diff --git a/docs/design_guide.rst b/docs/design_guide.rst
index 26e57cf53..a3c22a086 100644
--- a/docs/design_guide.rst
+++ b/docs/design_guide.rst
@@ -250,12 +250,13 @@ I2C Example
from adafruit_bus_device import i2c_device
+ DEVICE_DEFAULT_I2C_ADDR = 0x42
+
class Widget:
"""A generic widget."""
- def __init__(self, i2c):
- # Always on address 0x40.
- self.i2c_device = i2c_device.I2CDevice(i2c, 0x40)
+ def __init__(self, i2c, address=DEVICE_DEFAULT_I2C_ADDR):
+ self.i2c_device = i2c_device.I2CDevice(i2c, address)
self.buf = bytearray(1)
@property