Skip to content

now renders API Reference page correctly #17

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 8 commits into from
Oct 14, 2019
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ bundles
*.DS_Store
.eggs
dist
**/*.egg-info
**/*.egg-info
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ MCP3004 Single-Ended
mcp = MCP.MCP3004(spi, cs)

# create an analog input channel on pin 0
chan = AnalogIn(mcp, MCP.P0, MCP.P1)
chan = AnalogIn(mcp, MCP.P0)

print('Raw ADC Value: ', chan.value)
print('ADC Voltage: ' + str(chan.voltage) + 'V')
Expand Down
21 changes: 10 additions & 11 deletions adafruit_mcp3xxx/analog_in.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,23 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
"""
`analog_in`
==============================
:py:class:`~adafruit_mcp3xxx.analog_in.AnalogIn`
======================================================
AnalogIn for single-ended and
differential ADC readings.

* Author(s): Brent Rubell
"""

class AnalogIn():
"""AnalogIn Mock Implementation for ADC Reads."""
"""AnalogIn Mock Implementation for ADC Reads.

def __getitem__(self, key):
return self._channels[self._pins[key]]
:param ~mcp3004.MCP3004,~mcp3008.MCP3008 mcp: The mcp object.
:param int positive_pin: Required pin for single-ended.
:param int negative_pin: Optional pin for differential reads.

"""
def __init__(self, mcp, positive_pin, negative_pin=None):
"""AnalogIn

:param mcp: The mcp object.
:param ~digitalio.DigitalInOut positive_pin: Required pin for single-ended.
:param ~digitalio.DigitalInOut negative_pin: Optional pin for differential reads.
"""
self._mcp = mcp
self._pin_setting = positive_pin
self._negative_pin = negative_pin
Expand All @@ -55,6 +51,9 @@ def __init__(self, mcp, positive_pin, negative_pin=None):
self._pin_setting = self._pins.get((self._pin_setting, self._negative_pin),
"Difference pin not found.")

def __getitem__(self, key):
return self._channels[self._pins[key]]

@property
def value(self):
"""Returns the value of an ADC pin as an integer."""
Expand Down
2 changes: 1 addition & 1 deletion adafruit_mcp3xxx/mcp3004.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
"""
`mcp3004.py`
:py:class:`~adafruit_mcp3xxx.mcp3004.MCP3004`
================================================
MCP3004 4-channel, 10-bit, analog-to-digital
converter instance.
Expand Down
4 changes: 2 additions & 2 deletions adafruit_mcp3xxx/mcp3008.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
"""
`mcp3008.py`
=============================================
:py:class:`~adafruit_mcp3xxx.mcp3008.MCP3008`
=============================================================
MCP3008 8-channel, 10-bit, analog-to-digital
converter instance.

Expand Down
18 changes: 9 additions & 9 deletions adafruit_mcp3xxx/mcp3xxx.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
"""
`adafruit_mcp3xxx.py`
================================================
:py:class:`~adafruit_mcp3xxx.adafruit_mcp3xxx.MCP3xxx`
============================================================

CircuitPython Library for MCP3xxx ADCs with SPI

Expand Down Expand Up @@ -59,10 +59,10 @@ class MCP3xxx:
"""
MCP3xxx Interface.

params:
:param ~busdevice.SPIDevice spi_bus: SPI bus the ADC is connected to.
:param ~digitalio.DigitalInOut cs: Chip Select Pin.
:param float ref_voltage: Voltage into (Vin) the ADC.
:param ~adafruit_bus_device.spi_device.SPIDevice spi_bus: SPI bus the ADC is connected to.
:param ~digitalio.DigitalInOut cs: Chip Select Pin.
:param float ref_voltage: Voltage into (Vin) the ADC.

"""
def __init__(self, spi_bus, cs, ref_voltage=3.3):
self._spi_device = SPIDevice(spi_bus, cs)
Expand All @@ -78,9 +78,9 @@ def reference_voltage(self):
def read(self, pin, is_differential=False):
"""SPI Interface for MCP3xxx-based ADCs reads.

params:
:param pin: individual or differential pin.
:param bool is_differential: single-ended or differential read.
:param int pin: individual or differential pin.
:param bool is_differential: single-ended or differential read.

"""
command = (_MCP30084_DIFF_READ if is_differential else _MCP30084_SINGLE_READ) << 6
command |= pin << 3
Expand Down
15 changes: 13 additions & 2 deletions docs/api.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
API
------------

.. automodule:: adafruit_mcp3xxx
:members:
.. automodule:: adafruit_mcp3xxx.mcp3xxx
:members:

.. automodule:: adafruit_mcp3xxx.mcp3004
:members:
:show-inheritance:

.. automodule:: adafruit_mcp3xxx.mcp3008
:members:
:show-inheritance:

.. automodule:: adafruit_mcp3xxx.analog_in
:members:
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# Uncomment the below if you use native CircuitPython modules such as
# digitalio, micropython and busio. List the modules you use. Without it, the
# autodoc module docs will fail to generate with a warning.
# autodoc_mock_imports = ["digitalio", "busio"]
autodoc_mock_imports = ["busio"]


intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'BusDevice': ('https://circuitpython.readthedocs.io/projects/busdevice/en/latest/', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
Expand Down
2 changes: 1 addition & 1 deletion examples/mcp3xxx_mcp3004_single_ended_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
mcp = MCP.MCP3004(spi, cs)

# create an analog input channel on pin 0
chan = AnalogIn(mcp, MCP.P0, MCP.P1)
chan = AnalogIn(mcp, MCP.P0)

print('Raw ADC Value: ', chan.value)
print('ADC Voltage: ' + str(chan.voltage) + 'V')