Skip to content

Commit db918da

Browse files
caternusontannewt
authored andcommitted
updated I2C example (#371)
1 parent ca1a9b9 commit db918da

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

docs/design_guide.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,12 +250,13 @@ I2C Example
250250
251251
from adafruit_bus_device import i2c_device
252252
253+
DEVICE_DEFAULT_I2C_ADDR = 0x42
254+
253255
class Widget:
254256
"""A generic widget."""
255257
256-
def __init__(self, i2c):
257-
# Always on address 0x40.
258-
self.i2c_device = i2c_device.I2CDevice(i2c, 0x40)
258+
def __init__(self, i2c, address=DEVICE_DEFAULT_I2C_ADDR):
259+
self.i2c_device = i2c_device.I2CDevice(i2c, address)
259260
self.buf = bytearray(1)
260261
261262
@property

0 commit comments

Comments
 (0)