Skip to content

Updating I2C instantiation to be more obvious. #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion adafruit_motorkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@
class MotorKit:
"""Class representing an Adafruit DC & Stepper Motor FeatherWing, Shield or Pi Hat kit.

Automatically uses the I2C bus on a Feather, Metro or Raspberry Pi."""
Automatically uses the I2C bus on a Feather, Metro or Raspberry Pi if no I2C bus
is supplied.

Alternately, if using with multiple I2C devices, you can specify the I2C bus."""

def __init__(self, address=0x60, i2c=None, steppers_microsteps=16):
self._motor1 = None
Expand Down
3 changes: 2 additions & 1 deletion examples/motorkit_dc_motor_simpletest.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""Simple test for using adafruit_motorkit with a DC motor"""
import time
import board
from adafruit_motorkit import MotorKit

kit = MotorKit()
kit = MotorKit(i2c=board.I2C())

kit.motor1.throttle = 1.0
time.sleep(0.5)
Expand Down
3 changes: 2 additions & 1 deletion examples/motorkit_dc_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import time
import board
from adafruit_motorkit import MotorKit

kit = MotorKit()
kit = MotorKit(i2c=board.I2C())

kit.motor1.throttle = 0

Expand Down
3 changes: 2 additions & 1 deletion examples/motorkit_dual_stepper_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
import atexit
import threading
import random
import board
from adafruit_motor import stepper as STEPPER
from adafruit_motorkit import MotorKit

# create a default object, no changes to I2C address or frequency
kit = MotorKit()
kit = MotorKit(i2c=board.I2C())

# create empty threads (these will hold the stepper 1 and 2 threads)
st1 = threading.Thread() # pylint: disable=bad-thread-instantiation
Expand Down
3 changes: 2 additions & 1 deletion examples/motorkit_robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@

import time
import atexit
import board
from adafruit_motorkit import MotorKit

kit = MotorKit()
kit = MotorKit(i2c=board.I2C())


class Robot:
Expand Down
3 changes: 2 additions & 1 deletion examples/motorkit_stepper_simpletest.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""Simple test for using adafruit_motorkit with a stepper motor"""
import time
import board
from adafruit_motorkit import MotorKit

kit = MotorKit()
kit = MotorKit(i2c=board.I2C())

for i in range(100):
kit.stepper1.onestep()
Expand Down
3 changes: 2 additions & 1 deletion examples/motorkit_stepper_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import board
from adafruit_motor import stepper
from adafruit_motorkit import MotorKit

kit = MotorKit()
kit = MotorKit(i2c=board.I2C())

kit.stepper1.release()

Expand Down