Welcome to Adafruit-Motor-Hat’s documentation!¶
Contents:
Adafruit-Motor-Hat¶
An improved pip available Adafruit Motor Hat Package
- Free software: MIT license
- Documentation: https://adafruit-motor-hat.readthedocs.io.
Features¶
- Improve the Stepper performance for the original Adafruit-Motor-HAT-Python-Library
Credits¶
This package is based and mostly contains code from Adafruit-Motor-HAT-Python-Library
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
Installation¶
Stable release¶
To install Adafruit-Motor-Hat, run this command in your terminal:
$ pip install adafruit_motor_hat
This is the preferred method to install Adafruit-Motor-Hat, as it will always install the most recent stable release.
If you don’t have pip installed, this Python installation guide can guide you through the process.
From sources¶
The sources for Adafruit-Motor-Hat can be downloaded from the Github repo.
You can either clone the public repository:
$ git clone git://github.com/ferret-guy/adafruit_motor_hat
Or download the tarball:
$ curl -OL https://github.com/ferret-guy/adafruit_motor_hat/tarball/master
Once you have a copy of the source, you can install it with:
$ python setup.py install
Reference¶
-
class
adafruit_motor_hat.MotorHat.
AdafruitStepperMotor
(controller, num, steps=200)[source]¶ -
align_step
(reverse=False)[source]¶ Align the current step position with a full step
Parameters: reverse (bool) – run in reverse Returns: None
-
double_step
(steps=1, reverse=False)[source]¶ Double stepping, 2 coils at once
Parameters: - steps (int) – The number of steps to execute
- reverse (bool) – step in reverse
Returns: None
-
interleaved_step
(steps=1, reverse=False)[source]¶ Interleaved stepping, single stepping and interleaved stepping
Parameters: - steps (int) – The number of steps to execute
- reverse (bool) – step in reverse
Returns: None
-
micro_step
(steps=1, reverse=False)[source]¶ Microstepping
Parameters: - steps (int) – The number of steps to execute
- reverse (bool) – step in reverse
Returns: None
-
-
class
adafruit_motor_hat.MotorHat.
AdafruitMotorHAT
(addr=96, freq=1600, i2c=None, i2c_bus=None)[source]¶ -
get_motor
(num)[source]¶ Get a motor instance
Parameters: num (int) – the stepper to get 1-4 Returns: :class:`AdafruitDCMotor’
-
-
class
adafruit_motor_hat.Adafruit_PWM_Servo_Driver.
PWM
(address=64, debug=False, i2c=None, i2c_bus=None)[source]¶ Adafruit PCA9685 16-Channel PWM Servo Driver
-
setAllPWM
(on, off)[source]¶ Sets all the pwm outputs to the corresponding outputs
Parameters: - on – the portion of the PWM period in 1/4096ths of a period (0 corresponds to the start, 4096 corresponds to the end) to wait before the signal turns on
- off – the portion of the PWM period in 1/4096ths of a period (0 corresponds to the start, 4096 corresponds to the end) to wait before the signal turns off
Returns: None
-
setPWM
(channel, on, off)[source]¶ Set a single pwm channel
Parameters: - channel – the channel number from 0-15 inclusive
- on – the portion of the PWM period in 1/4096ths of a period (0 corresponds to the start, 4096 corresponds to the end) to wait before the signal turns on
- off – the portion of the PWM period in 1/4096ths of a period (0 corresponds to the start, 4096 corresponds to the end) to wait before the signal turns off
Returns: None
-
-
adafruit_motor_hat.Adafruit_PWM_Servo_Driver.
get_i2c_device
(address, i2c, i2c_bus)[source]¶ Helper method to get a device at the specified address from the I2C bus. If no i2c bus is specified (i2c param is None) then the default I2C bus for the platform will be used.
Parameters: - address (hex) – i2c address to get the handle for
- i2c – GPIO i2c class, None to use the Adafruit_GPIO.I2C class
- i2c_bus – i2c bus number, passed to busnum, none to autodetect
Returns: i2c Address
Contributing¶
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
You can contribute in many ways:
Types of Contributions¶
Report Bugs¶
Report bugs at https://github.com/ferret-guy/adafruit_motor_hat/issues.
If you are reporting a bug, please include:
- Your operating system name and version.
- Any details about your local setup that might be helpful in troubleshooting.
- Detailed steps to reproduce the bug.
Fix Bugs¶
Look through the GitHub issues for bugs. Anything tagged with “bug” and “help wanted” is open to whoever wants to implement it.
Implement Features¶
Look through the GitHub issues for features. Anything tagged with “enhancement” and “help wanted” is open to whoever wants to implement it.
Write Documentation¶
Adafruit-Motor-Hat could always use more documentation, whether as part of the official Adafruit-Motor-Hat docs, in docstrings, or even on the web in blog posts, articles, and such.
Submit Feedback¶
The best way to send feedback is to file an issue at https://github.com/ferret-guy/adafruit_motor_hat/issues.
If you are proposing a feature:
- Explain in detail how it would work.
- Keep the scope as narrow as possible, to make it easier to implement.
- Remember that this is a volunteer-driven project, and that contributions are welcome :)
Get Started!¶
Ready to contribute? Here’s how to set up adafruit_motor_hat for local development.
Fork the adafruit_motor_hat repo on GitHub.
Clone your fork locally:
$ git clone git@github.com:your_name_here/adafruit_motor_hat.git
Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:
$ mkvirtualenv adafruit_motor_hat $ cd adafruit_motor_hat/ $ python setup.py develop
Create a branch for local development:
$ git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.
When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:
$ flake8 adafruit_motor_hat tests $ python setup.py test or py.test $ tox
To get flake8 and tox, just pip install them into your virtualenv.
Commit your changes and push your branch to GitHub:
$ git add . $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature
Submit a pull request through the GitHub website.
Pull Request Guidelines¶
Before you submit a pull request, check that it meets these guidelines:
- The pull request should include tests.
- If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.
- The pull request should work for Python 2.6, 2.7, 3.3, 3.4 and 3.5, and for PyPy. Check https://travis-ci.org/ferret-guy/adafruit_motor_hat/pull_requests and make sure that the tests pass for all supported Python versions.
Credits¶
Development Lead¶
- Mark Omo <mark@markomo.me>
Contributors¶
None yet. Why not be the first?
Original Contributors to Adafruit-Motor-HAT-Python-Library¶
- tdicola
- caternuson
- ladyada