Skip to content

Commit df22331

Browse files
authored
Merge pull request #31 from kattni/i2c-update
Updating I2C instantiation to be more obvious.
2 parents 14df719 + 19ae57e commit df22331

7 files changed

+16
-7
lines changed

adafruit_motorkit.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@
6262
class MotorKit:
6363
"""Class representing an Adafruit DC & Stepper Motor FeatherWing, Shield or Pi Hat kit.
6464
65-
Automatically uses the I2C bus on a Feather, Metro or Raspberry Pi."""
65+
Automatically uses the I2C bus on a Feather, Metro or Raspberry Pi if no I2C bus
66+
is supplied.
67+
68+
Alternately, if using with multiple I2C devices, you can specify the I2C bus."""
6669

6770
def __init__(self, address=0x60, i2c=None, steppers_microsteps=16):
6871
self._motor1 = None

examples/motorkit_dc_motor_simpletest.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
"""Simple test for using adafruit_motorkit with a DC motor"""
22
import time
3+
import board
34
from adafruit_motorkit import MotorKit
45

5-
kit = MotorKit()
6+
kit = MotorKit(i2c=board.I2C())
67

78
kit.motor1.throttle = 1.0
89
time.sleep(0.5)

examples/motorkit_dc_test.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import time
2+
import board
23
from adafruit_motorkit import MotorKit
34

4-
kit = MotorKit()
5+
kit = MotorKit(i2c=board.I2C())
56

67
kit.motor1.throttle = 0
78

examples/motorkit_dual_stepper_test.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
import atexit
77
import threading
88
import random
9+
import board
910
from adafruit_motor import stepper as STEPPER
1011
from adafruit_motorkit import MotorKit
1112

1213
# create a default object, no changes to I2C address or frequency
13-
kit = MotorKit()
14+
kit = MotorKit(i2c=board.I2C())
1415

1516
# create empty threads (these will hold the stepper 1 and 2 threads)
1617
st1 = threading.Thread() # pylint: disable=bad-thread-instantiation

examples/motorkit_robot.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414

1515
import time
1616
import atexit
17+
import board
1718
from adafruit_motorkit import MotorKit
1819

19-
kit = MotorKit()
20+
kit = MotorKit(i2c=board.I2C())
2021

2122

2223
class Robot:

examples/motorkit_stepper_simpletest.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
"""Simple test for using adafruit_motorkit with a stepper motor"""
22
import time
3+
import board
34
from adafruit_motorkit import MotorKit
45

5-
kit = MotorKit()
6+
kit = MotorKit(i2c=board.I2C())
67

78
for i in range(100):
89
kit.stepper1.onestep()

examples/motorkit_stepper_test.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import board
12
from adafruit_motor import stepper
23
from adafruit_motorkit import MotorKit
34

4-
kit = MotorKit()
5+
kit = MotorKit(i2c=board.I2C())
56

67
kit.stepper1.release()
78

0 commit comments

Comments
 (0)