1
- # The MIT License (MIT)
1
+ # SPDX-FileCopyrightText: 2017 Scott Shawcroft for Adafruit Industries
2
+ # SPDX-FileCopyrightText: 2018 Kattni Rembor for Adafruit Industries
2
3
#
3
- # Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
4
- # Copyright (c) 2018 Kattni Rembor for Adafruit Industries
5
- #
6
- # Permission is hereby granted, free of charge, to any person obtaining a copy
7
- # of this software and associated documentation files (the "Software"), to deal
8
- # in the Software without restriction, including without limitation the rights
9
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- # copies of the Software, and to permit persons to whom the Software is
11
- # furnished to do so, subject to the following conditions:
12
- #
13
- # The above copyright notice and this permission notice shall be included in
14
- # all copies or substantial portions of the Software.
15
- #
16
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- # THE SOFTWARE.
4
+ # SPDX-License-Identifier: MIT
5
+
23
6
"""
24
7
`adafruit_motorkit`
25
8
====================================================
61
44
class MotorKit :
62
45
"""Class representing an Adafruit DC & Stepper Motor FeatherWing, Shield or Pi Hat kit.
63
46
64
- Automatically uses the I2C bus on a Feather, Metro or Raspberry Pi if no I2C bus
65
- is supplied.
47
+ Automatically uses the I2C bus on a Feather, Metro or Raspberry Pi if no I2C bus
48
+ is supplied.
66
49
67
- Alternately, if using with multiple I2C devices, you can specify the I2C bus."""
50
+ Alternately, if using with multiple I2C devices, you can specify the I2C bus."""
68
51
69
52
def __init__ (
70
53
self , address = 0x60 , i2c = None , steppers_microsteps = 16 , pwm_frequency = 1600
@@ -110,129 +93,129 @@ def _motor(self, motor_name, channels, stepper_name):
110
93
def motor1 (self ):
111
94
""":py:class:``~adafruit_motor.motor.DCMotor`` controls for motor 1.
112
95
113
- The following image shows the location of the M1 terminal on the DC/Stepper FeatherWing.
114
- The label on the FeatherWing is found on the bottom of the board.
115
- The terminal is labeled on the top of the Shield and Pi Hat.
96
+ The following image shows the location of the M1 terminal on the DC/Stepper FeatherWing.
97
+ The label on the FeatherWing is found on the bottom of the board.
98
+ The terminal is labeled on the top of the Shield and Pi Hat.
116
99
117
- .. image :: ../docs/_static/motor_featherwing/m1.jpg
118
- :alt: Motor 1 location
100
+ .. image :: ../docs/_static/motor_featherwing/m1.jpg
101
+ :alt: Motor 1 location
119
102
120
- This example moves the motor forwards for one fifth of a second at full speed.
103
+ This example moves the motor forwards for one fifth of a second at full speed.
121
104
122
- .. code-block:: python
105
+ .. code-block:: python
123
106
124
- import time
125
- from adafruit_motorkit import motorkit
107
+ import time
108
+ from adafruit_motorkit import motorkit
126
109
127
- kit = MotorKit()
110
+ kit = MotorKit()
128
111
129
- kit.motor1.throttle = 1.0
130
- time.sleep(0.2)
112
+ kit.motor1.throttle = 1.0
113
+ time.sleep(0.2)
131
114
132
- kit.motor1.throttle = 0
115
+ kit.motor1.throttle = 0
133
116
"""
134
117
return self ._motor (1 , (8 , 9 , 10 ), 1 )
135
118
136
119
@property
137
120
def motor2 (self ):
138
121
""":py:class:``~adafruit_motor.motor.DCMotor`` controls for motor 2.
139
122
140
- The following image shows the location of the M2 terminal on the DC/Stepper FeatherWing.
141
- The label on the FeatherWing is found on the bottom of the board.
142
- The terminal is labeled on the top of the Shield and Pi Hat.
123
+ The following image shows the location of the M2 terminal on the DC/Stepper FeatherWing.
124
+ The label on the FeatherWing is found on the bottom of the board.
125
+ The terminal is labeled on the top of the Shield and Pi Hat.
143
126
144
- .. image :: ../docs/_static/motor_featherwing/m2.jpg
145
- :alt: Motor 2 location
127
+ .. image :: ../docs/_static/motor_featherwing/m2.jpg
128
+ :alt: Motor 2 location
146
129
147
- This example moves the motor forwards for one fifth of a second at full speed.
130
+ This example moves the motor forwards for one fifth of a second at full speed.
148
131
149
- .. code-block:: python
132
+ .. code-block:: python
150
133
151
- import time
152
- from adafruit_motorkit import motorkit
134
+ import time
135
+ from adafruit_motorkit import motorkit
153
136
154
- kit = MotorKit()
137
+ kit = MotorKit()
155
138
156
- kit.motor2.throttle = 1.0
157
- time.sleep(0.2)
139
+ kit.motor2.throttle = 1.0
140
+ time.sleep(0.2)
158
141
159
- kit.motor1.throttle = 0
142
+ kit.motor1.throttle = 0
160
143
"""
161
144
return self ._motor (2 , (13 , 11 , 12 ), 1 )
162
145
163
146
@property
164
147
def motor3 (self ):
165
148
""":py:class:``~adafruit_motor.motor.DCMotor`` controls for motor 3.
166
149
167
- The following image shows the location of the M2 terminal on the DC/Stepper FeatherWing.
168
- The label on the FeatherWing is found on the bottom of the board.
169
- The terminal is labeled on the top of the Shield and Pi Hat.
150
+ The following image shows the location of the M2 terminal on the DC/Stepper FeatherWing.
151
+ The label on the FeatherWing is found on the bottom of the board.
152
+ The terminal is labeled on the top of the Shield and Pi Hat.
170
153
171
- .. image :: ../docs/_static/motor_featherwing/m3.jpg
172
- :alt: Motor 3 location
154
+ .. image :: ../docs/_static/motor_featherwing/m3.jpg
155
+ :alt: Motor 3 location
173
156
174
- This example moves the motor forwards for one fifth of a second at full speed.
157
+ This example moves the motor forwards for one fifth of a second at full speed.
175
158
176
- .. code-block:: python
159
+ .. code-block:: python
177
160
178
- import time
179
- from adafruit_motorkit import motorkit
161
+ import time
162
+ from adafruit_motorkit import motorkit
180
163
181
- kit = MotorKit()
164
+ kit = MotorKit()
182
165
183
- kit.motor3.throttle = 1.0
184
- time.sleep(0.2)
166
+ kit.motor3.throttle = 1.0
167
+ time.sleep(0.2)
185
168
186
- kit.motor1.throttle = 0
169
+ kit.motor1.throttle = 0
187
170
"""
188
171
return self ._motor (3 , (2 , 3 , 4 ), 2 )
189
172
190
173
@property
191
174
def motor4 (self ):
192
175
""":py:class:``~adafruit_motor.motor.DCMotor`` controls for motor 4.
193
176
194
- .. image :: ../docs/_static/motor_featherwing/m4.jpg
195
- :alt: Motor 4 location
177
+ .. image :: ../docs/_static/motor_featherwing/m4.jpg
178
+ :alt: Motor 4 location
196
179
197
- This example moves the motor forwards for one fifth of a second at full speed.
180
+ This example moves the motor forwards for one fifth of a second at full speed.
198
181
199
- .. code-block:: python
182
+ .. code-block:: python
200
183
201
- import time
202
- from adafruit_motorkit import motorkit
184
+ import time
185
+ from adafruit_motorkit import motorkit
203
186
204
- kit = MotorKit()
187
+ kit = MotorKit()
205
188
206
- kit.motor4.throttle = 1.0
207
- time.sleep(0.2)
189
+ kit.motor4.throttle = 1.0
190
+ time.sleep(0.2)
208
191
209
- kit.motor1.throttle = 0
192
+ kit.motor1.throttle = 0
210
193
"""
211
194
return self ._motor (4 , (7 , 5 , 6 ), 2 )
212
195
213
196
@property
214
197
def stepper1 (self ):
215
198
""":py:class:``~adafruit_motor.stepper.StepperMotor`` controls for one connected to stepper
216
- 1 (also labeled motor 1 and motor 2).
199
+ 1 (also labeled motor 1 and motor 2).
217
200
218
- The following image shows the location of the stepper1 terminals on the DC/Stepper
219
- FeatherWing. stepper1 is made up of the M1 and M2 terminals.
220
- The labels on the FeatherWing are found on the bottom of the board.
221
- The terminals are labeled on the top of the Shield and Pi Hat.
201
+ The following image shows the location of the stepper1 terminals on the DC/Stepper
202
+ FeatherWing. stepper1 is made up of the M1 and M2 terminals.
203
+ The labels on the FeatherWing are found on the bottom of the board.
204
+ The terminals are labeled on the top of the Shield and Pi Hat.
222
205
223
- .. image :: ../docs/_static/motor_featherwing/stepper1.jpg
224
- :alt: Stepper 1 location
206
+ .. image :: ../docs/_static/motor_featherwing/stepper1.jpg
207
+ :alt: Stepper 1 location
225
208
226
- This example moves the stepper motor 100 steps forwards.
209
+ This example moves the stepper motor 100 steps forwards.
227
210
228
- .. code-block:: python
211
+ .. code-block:: python
229
212
230
- from adafruit_motorkit import MotorKit
213
+ from adafruit_motorkit import MotorKit
231
214
232
- kit = MotorKit()
215
+ kit = MotorKit()
233
216
234
- for i in range(100):
235
- kit.stepper1.onestep()
217
+ for i in range(100):
218
+ kit.stepper1.onestep()
236
219
"""
237
220
if not self ._stepper1 :
238
221
from adafruit_motor import ( # pylint: disable=import-outside-toplevel
@@ -257,26 +240,26 @@ def stepper1(self):
257
240
@property
258
241
def stepper2 (self ):
259
242
""":py:class:``~adafruit_motor.stepper.StepperMotor`` controls for one connected to stepper
260
- 2 (also labeled motor 3 and motor 4).
243
+ 2 (also labeled motor 3 and motor 4).
261
244
262
- The following image shows the location of the stepper2 terminals on the DC/Stepper
263
- FeatherWing. stepper2 is made up of the M3 and M4 terminals.
264
- The labels on the FeatherWing are found on the bottom of the board.
265
- The terminals are labeled on the top of the Shield and Pi Hat.
245
+ The following image shows the location of the stepper2 terminals on the DC/Stepper
246
+ FeatherWing. stepper2 is made up of the M3 and M4 terminals.
247
+ The labels on the FeatherWing are found on the bottom of the board.
248
+ The terminals are labeled on the top of the Shield and Pi Hat.
266
249
267
- .. image :: ../docs/_static/motor_featherwing/stepper2.jpg
268
- :alt: Stepper 2 location
250
+ .. image :: ../docs/_static/motor_featherwing/stepper2.jpg
251
+ :alt: Stepper 2 location
269
252
270
- This example moves the stepper motor 100 steps forwards.
253
+ This example moves the stepper motor 100 steps forwards.
271
254
272
- .. code-block:: python
255
+ .. code-block:: python
273
256
274
- from adafruit_motorkit import MotorKit
257
+ from adafruit_motorkit import MotorKit
275
258
276
- kit = MotorKit()
259
+ kit = MotorKit()
277
260
278
- for i in range(100):
279
- kit.stepper2.onestep()
261
+ for i in range(100):
262
+ kit.stepper2.onestep()
280
263
"""
281
264
if not self ._stepper2 :
282
265
from adafruit_motor import ( # pylint: disable=import-outside-toplevel
0 commit comments