|
1 |
| -Coming Soon |
2 |
| -============ |
3 |
| - |
4 |
| -.. image:: https://readthedocs.org/projects/sparkfun-circuitpython-qwiicrelay/badge/?version=latest |
5 |
| - :target: https://circuitpython.readthedocs.io/projects/qwiicrelay/en/latest/ |
6 |
| - :alt: Documentation Status |
7 |
| - |
8 |
| -.. image:: https://img.shields.io/discord/327254708534116352.svg |
9 |
| - :target: https://discord.gg/nBQh6qu |
10 |
| - :alt: Discord |
11 |
| - |
12 |
| -.. image:: https://travis-ci.com/fourstix/Sparkfun_CircuitPython_QwiicRelay.svg?branch=master |
13 |
| - :target: https://travis-ci.com/fourstix/Sparkfun_CircuitPython_QwiicRelay |
14 |
| - :alt: Build Status |
15 |
| - |
16 |
| -CircuitPython library for Sparkfun Qwiic Relay |
17 |
| - |
18 |
| -.. image:: https://cdn.sparkfun.com//assets/parts/1/3/4/5/1/15093-SparkFun_Qwiic_Single_Relay-01.jpg |
19 |
| - :target: https://www.sparkfun.com/products/15093 |
20 |
| - :alt: SparkFun Qwiic Relay (DEV-15093) |
21 |
| - |
22 |
| -`SparkFun Qwiic Relay (DEV-15093) <https://www.sparkfun.com/products/15093>`_ |
23 |
| - |
24 |
| - |
25 |
| - |
26 |
| -Dependencies |
27 |
| -============= |
28 |
| -This driver depends on: |
29 |
| - |
30 |
| -* `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_ |
31 |
| -* `Qwiic Relay Product Repository <https://github.com/sparkfun/Qwiic_Relay>`_ |
32 |
| - |
33 |
| -Please ensure all dependencies are available on the CircuitPython filesystem. |
34 |
| -This is easily achieved by downloading |
35 |
| -`the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_. |
36 |
| - |
37 |
| -Installing from PyPI |
38 |
| --------------------- |
39 |
| -.. note:: This library is not available on PyPI yet. Install documentation is included |
40 |
| - as a standard element. Stay tuned for PyPI availability! |
41 |
| -.. todo:: Remove the above note if PyPI version is/will be available at time of release. |
42 |
| - If the library is not planned for PyPI, remove the entire 'Installing from PyPI' section. |
43 |
| -On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from |
44 |
| -PyPI <https://pypi.org/project/sparkfun-circuitpython-qwiicrelay/>`_. To install for current user: |
45 |
| - |
46 |
| -.. code-block:: shell |
47 |
| -
|
48 |
| - pip3 install sparkfun-circuitpython-qwiicrelay |
49 |
| -
|
50 |
| -To install system-wide (this may be required in some cases): |
51 |
| - |
52 |
| -.. code-block:: shell |
53 |
| -
|
54 |
| - sudo pip3 install sparkfun-circuitpython-qwiicrelay |
55 |
| -
|
56 |
| -To install in a virtual environment in your current project: |
57 |
| - |
58 |
| -.. code-block:: shell |
59 |
| -
|
60 |
| - mkdir project-name && cd project-name |
61 |
| - python3 -m venv .env |
62 |
| - source .env/bin/activate |
63 |
| - pip3 install sparkfun-circuitpython-qwiicrelay |
64 |
| -
|
65 |
| -Usage Example |
66 |
| -============= |
67 |
| -* `Qwiic Single Relay Hookup Guide <https://learn.sparkfun.com/tutorials/qwiic-single-relay-hookup-guide>`_ - The Arduino examples in the Hookup Guide are available for Python with this library |
68 |
| -* `CircuitPython on a Raspberry Pi <https://learn.adafruit.com/circuitpython-on-raspberrypi-linux>`_ - Basic information on how to install CircuitPython on a Raspberry Pi. |
69 |
| - |
70 |
| -Contributing |
71 |
| -============ |
72 |
| - |
73 |
| -Contributions are welcome! Please read our `Code of Conduct |
74 |
| -<https://github.com/fourstix/Sparkfun_CircuitPython_QwiicRelay/blob/master/CODE_OF_CONDUCT.md>`_ |
75 |
| -before contributing to help this project stay welcoming. |
76 |
| - |
77 |
| -Building locally |
78 |
| -================ |
79 |
| - |
80 |
| -Zip release files |
81 |
| ------------------ |
82 |
| - |
83 |
| -To build this library locally you'll need to install the |
84 |
| -`circuitpython-build-tools <https://github.com/adafruit/circuitpython-build-tools>`_ package. |
85 |
| - |
86 |
| -.. code-block:: shell |
87 |
| -
|
88 |
| - python3 -m venv .env |
89 |
| - source .env/bin/activate |
90 |
| - pip install circuitpython-build-tools |
91 |
| -
|
92 |
| -Once installed, make sure you are in the virtual environment: |
93 |
| - |
94 |
| -.. code-block:: shell |
95 |
| -
|
96 |
| - source .env/bin/activate |
97 |
| -
|
98 |
| -Then run the build: |
99 |
| - |
100 |
| -.. code-block:: shell |
101 |
| -
|
102 |
| - circuitpython-build-bundles --filename_prefix sparkfun-circuitpython-qwiicrelay --library_location . |
103 |
| -
|
104 |
| -Sphinx documentation |
105 |
| ------------------------ |
106 |
| - |
107 |
| -Sphinx is used to build the documentation based on rST files and comments in the code. First, |
108 |
| -install dependencies (feel free to reuse the virtual environment from above): |
109 |
| - |
110 |
| -.. code-block:: shell |
111 |
| -
|
112 |
| - python3 -m venv .env |
113 |
| - source .env/bin/activate |
114 |
| - pip install Sphinx sphinx-rtd-theme |
115 |
| -
|
116 |
| -Now, once you have the virtual environment activated: |
117 |
| - |
118 |
| -.. code-block:: shell |
119 |
| -
|
120 |
| - cd docs |
121 |
| - sphinx-build -E -W -b html . _build/html |
122 |
| -
|
123 |
| -This will output the documentation to ``docs/_build/html``. Open the index.html in your browser to |
124 |
| -view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to |
125 |
| -locally verify it will pass. |
126 |
| - |
127 |
| -License Information |
128 |
| ------------------------ |
129 |
| -This product is **open source**! |
130 |
| - |
131 |
| -Please review the LICENSE.md file for license information. |
132 |
| - |
133 |
| -Please use, reuse, and modify these files as you see fit. |
134 |
| - |
135 |
| -Please maintain the attributions to SparkFun Electronics and Adafruit and release any derivative under the same license. |
136 |
| - |
137 |
| -Distributed as-is; no warranty is given. |
138 |
| - |
139 |
| - |
140 |
| - |
| 1 | +Coming Soon |
| 2 | +============ |
| 3 | + |
| 4 | +.. image:: https://readthedocs.org/projects/sparkfun-circuitpython-qwiicrelay/badge/?version=latest |
| 5 | + :target: https://circuitpython.readthedocs.io/projects/qwiicrelay/en/latest/ |
| 6 | + :alt: Documentation Status |
| 7 | + |
| 8 | +.. image:: https://img.shields.io/discord/327254708534116352.svg |
| 9 | + :target: https://discord.gg/nBQh6qu |
| 10 | + :alt: Discord |
| 11 | + |
| 12 | +.. image:: https://travis-ci.com/fourstix/Sparkfun_CircuitPython_QwiicRelay.svg?branch=master |
| 13 | + :target: https://travis-ci.com/fourstix/Sparkfun_CircuitPython_QwiicRelay |
| 14 | + :alt: Build Status |
| 15 | + |
| 16 | +CircuitPython library for Sparkfun Qwiic Relay. This library is ported from examples |
| 17 | +at `SparkFun Qwiic Relay <https://github.com/sparkfun/SparkFun_Qwiic_Releay>`_ |
| 18 | + |
| 19 | +.. image:: https://cdn.sparkfun.com//assets/parts/1/3/4/5/1/15093-SparkFun_Qwiic_Single_Relay-01.jpg |
| 20 | + :target: https://www.sparkfun.com/products/15093 |
| 21 | + :alt: SparkFun Qwiic Single Relay (COM-15093) |
| 22 | + |
| 23 | +`SparkFun Qwiic Single Relay (COM-15093) <https://www.sparkfun.com/products/15093>`_ |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | +Dependencies |
| 28 | +============= |
| 29 | +This driver depends on: |
| 30 | + |
| 31 | +* `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_ |
| 32 | +* `Adafruit Bus Device <https://github.com/adafruit/Adafruit_CircuitPython_BusDevice>`_ |
| 33 | +* `Qwiic Relay Hardware <https://github.com/sparkfun/Qwiic_Relay>`_ |
| 34 | + |
| 35 | +Please ensure all dependencies are available on the CircuitPython filesystem. |
| 36 | +This is easily achieved by downloading |
| 37 | +`the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_. |
| 38 | + |
| 39 | +Raspberry Pi Setup |
| 40 | +------------------ |
| 41 | + Adafruit has an excellent tutorial on `Installing CircuitPython Libraries on Raspberry Pi |
| 42 | + <https://learn.adafruit.com/circuitpython-on-raspberrypi-linux/installing-circuitpython-on-raspberry-pi/>`_. |
| 43 | + |
| 44 | +Quick Start Summary: |
| 45 | + |
| 46 | +* Start with the latest version of Raspbian with Wifi configured. |
| 47 | + |
| 48 | +* Enable SSH, I2C and SPI. |
| 49 | + |
| 50 | +.. code-block:: shell |
| 51 | +
|
| 52 | + sudo raspi-config |
| 53 | +
|
| 54 | +* Update your system to the latest version. |
| 55 | + |
| 56 | +.. code-block:: shell |
| 57 | +
|
| 58 | + sudo apt-get update |
| 59 | + sudo apt-get upgrade |
| 60 | +
|
| 61 | +* Update the python tools |
| 62 | + |
| 63 | +.. code-block:: shell |
| 64 | +
|
| 65 | + sudo pip3 install --upgrade setuptools |
| 66 | +
|
| 67 | +(If pip3 is not installed, install it and rerun the command) |
| 68 | + |
| 69 | +.. code-block:: shell |
| 70 | +
|
| 71 | + sudo apt-get install python3-pip |
| 72 | +
|
| 73 | +* Install the CircuitPython libraries |
| 74 | + |
| 75 | +.. code-block:: shell |
| 76 | +
|
| 77 | + pip3 install RPI.GPIO |
| 78 | + pip3 install adafruit-blinka |
| 79 | +
|
| 80 | +Installing from PyPI |
| 81 | +-------------------- |
| 82 | + On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from |
| 83 | + PyPI <https://pypi.org/project/sparkfun-circuitpython-qwiicrelay/>`_. |
| 84 | + |
| 85 | + Installing this library will also install the dependency adafruit-circuitpython-busdevice. |
| 86 | + |
| 87 | +Installing from PyPI |
| 88 | + |
| 89 | +.. code-block:: shell |
| 90 | +
|
| 91 | + pip3 install sparkfun-circuitpython-qwiicrelay |
| 92 | +
|
| 93 | +To install system-wide (this may be required in some cases): |
| 94 | + |
| 95 | +.. code-block:: shell |
| 96 | +
|
| 97 | + sudo pip3 install sparkfun-circuitpython-qwiicrelay |
| 98 | +
|
| 99 | +To install in a virtual environment in your current project: |
| 100 | + |
| 101 | +.. code-block:: shell |
| 102 | +
|
| 103 | + mkdir project-name && cd project-name |
| 104 | + python3 -m venv .env |
| 105 | + source .env/bin/activate |
| 106 | + pip3 install sparkfun-circuitpython-qwiicrelay |
| 107 | +
|
| 108 | +Usage Example |
| 109 | +============= |
| 110 | +* `Qwiic Relay Hookup Guide <https://learn.sparkfun.com/tutorials/qwiic-single-relay-hookup-guide>`_ - The Arduino examples in the Hookup Guide are available for Python with this library |
| 111 | +* `CircuitPython on a Raspberry Pi <https://learn.adafruit.com/circuitpython-on-raspberrypi-linux>`_ - Basic information on how to install CircuitPython on a Raspberry Pi. |
| 112 | +* Code Example: |
| 113 | + |
| 114 | + .. code-block:: shell |
| 115 | +
|
| 116 | + # import the CircuitPython board and busio libraries |
| 117 | + import board |
| 118 | + import busio |
| 119 | +
|
| 120 | + # Create bus object using the board's I2C port |
| 121 | + i2c = busio.I2C(board.SCL, board.SDA) |
| 122 | +
|
| 123 | + relay = QwiicRelay(i2c) # default address is 0x20 |
| 124 | +
|
| 125 | + # For a different address use QwiicRelay(i2c, address) |
| 126 | + # relay = QwiicJoystick(i2c, 0x21) |
| 127 | +
|
| 128 | +
|
| 129 | +Contributing |
| 130 | +============ |
| 131 | + |
| 132 | +Contributions are welcome! Please read our `Code of Conduct |
| 133 | +<https://github.com/fourstix/Sparkfun_CircuitPython_QwiicRelay/blob/master/CODE_OF_CONDUCT.md>`_ |
| 134 | +before contributing to help this project stay welcoming. |
| 135 | + |
| 136 | +Building locally |
| 137 | +================ |
| 138 | + |
| 139 | +Zip release files |
| 140 | +----------------- |
| 141 | + |
| 142 | +To build this library locally you'll need to install the |
| 143 | +`circuitpython-build-tools <https://github.com/adafruit/circuitpython-build-tools>`_ package. |
| 144 | + |
| 145 | +.. code-block:: shell |
| 146 | +
|
| 147 | + python3 -m venv .env |
| 148 | + source .env/bin/activate |
| 149 | + pip install circuitpython-build-tools |
| 150 | +
|
| 151 | +Once installed, make sure you are in the virtual environment: |
| 152 | + |
| 153 | +.. code-block:: shell |
| 154 | +
|
| 155 | + source .env/bin/activate |
| 156 | +
|
| 157 | +Then run the build: |
| 158 | + |
| 159 | +.. code-block:: shell |
| 160 | +
|
| 161 | + circuitpython-build-bundles --filename_prefix sparkfun-circuitpython-qwiicrelay --library_location . |
| 162 | +
|
| 163 | +Sphinx documentation |
| 164 | +----------------------- |
| 165 | + |
| 166 | +Sphinx is used to build the documentation based on rST files and comments in the code. First, |
| 167 | +install dependencies (feel free to reuse the virtual environment from above): |
| 168 | + |
| 169 | +.. code-block:: shell |
| 170 | +
|
| 171 | + python3 -m venv .env |
| 172 | + source .env/bin/activate |
| 173 | + pip install Sphinx sphinx-rtd-theme |
| 174 | +
|
| 175 | +Now, once you have the virtual environment activated: |
| 176 | + |
| 177 | +.. code-block:: shell |
| 178 | +
|
| 179 | + cd docs |
| 180 | + sphinx-build -E -W -b html . _build/html |
| 181 | +
|
| 182 | +This will output the documentation to ``docs/_build/html``. Open the index.html in your browser to |
| 183 | +view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to |
| 184 | +locally verify it will pass. |
| 185 | + |
| 186 | +License Information |
| 187 | +----------------------- |
| 188 | +This product is **open source**! |
| 189 | + |
| 190 | +Please review the LICENSE.md file for license information. |
| 191 | + |
| 192 | +Please use, reuse, and modify these files as you see fit. |
| 193 | + |
| 194 | +Please maintain the attributions to SparkFun Electronics and Adafruit and release any derivative under the same license. |
| 195 | + |
| 196 | +Distributed as-is; no warranty is given. |
| 197 | + |
| 198 | + |
| 199 | + |
0 commit comments