From 041b1f84affb937ca8d0935104e507e3740236c6 Mon Sep 17 00:00:00 2001 From: brentru Date: Mon, 15 Apr 2019 12:10:41 -0400 Subject: [PATCH 1/3] updating README and documentation examples --- README.rst | 81 +++++++++++++++++++++++++++++++++++++++-------- docs/examples.rst | 12 +++++++ 2 files changed, 79 insertions(+), 14 deletions(-) diff --git a/README.rst b/README.rst index fb823c2..02d252d 100644 --- a/README.rst +++ b/README.rst @@ -35,15 +35,15 @@ Usage Example ============= -Single Ended ------------- +MCP3008 Single Ended +--------------------- .. code-block:: python import busio import digitalio import board - from adafruit_mcp3xxx.mcp3008 import MCP3008 + import adafruit_mcp3xxx.mcp3008 as MCP from adafruit_mcp3xxx.analog_in import AnalogIn # create the spi bus @@ -52,26 +52,26 @@ Single Ended # create the cs (chip select) cs = digitalio.DigitalInOut(board.D5) - # create the mcp object from MCP3008 class - mcp = MCP3008(spi, cs) + # create the mcp object + mcp = MCP.MCP3008(spi, cs) # create an analog input channel on pin 0 - chan = AnalogIn(mcp, MCP3008.pin_0) + chan = AnalogIn(mcp, MCP.P0) print('Raw ADC Value: ', chan.value) print('ADC Voltage: ' + str(chan.voltage) + 'V') -Differential ------------- +MCP3008 Differential +-------------------- .. code-block:: python import busio import digitalio import board - from adafruit_mcp3xxx.mcp3008 import MCP3008 - from adafruit_mcp3xxx.differential_analog_in import DifferentialAnalogIn + import adafruit_mcp3xxx.mcp3008 as MCP + from adafruit_mcp3xxx.analog_in import AnalogIn # create the spi bus spi = busio.SPI(clock=board.SCK, MISO=board.MISO, MOSI=board.MOSI) @@ -79,15 +79,68 @@ Differential # create the cs (chip select) cs = digitalio.DigitalInOut(board.D5) - # create the mcp object from MCP3008 class - mcp = MCP3008(spi, cs) + # create the mcp object + mcp = MCP.MCP3008(spi, cs) - # create a differential analog input channel with pin 0 and pin 1 - chan = DifferentialAnalogIn(mcp, MCP3008.pin_0, MCP3008.pin_1) + # create a differential ADC channel between Pin 0 and Pin 1 + chan = AnalogIn(mcp, MCP.P0, MCP.P1) print('Differential ADC Value: ', chan.value) print('Differential ADC Voltage: ' + str(chan.voltage) + 'V') +MCP3004 Single-Ended +--------------------- + +.. code-block:: python + + import busio + import digitalio + import board + import adafruit_mcp3xxx.mcp3004 as MCP + from adafruit_mcp3xxx.analog_in import AnalogIn + + # create the spi bus + spi = busio.SPI(clock=board.SCK, MISO=board.MISO, MOSI=board.MOSI) + + # create the cs (chip select) + cs = digitalio.DigitalInOut(board.D5) + + # create the mcp object + mcp = MCP.MCP3004(spi, cs) + + # create an analog input channel on pin 0 + chan = AnalogIn(mcp, MCP.P0, MCP.P1) + + print('Raw ADC Value: ', chan.value) + print('ADC Voltage: ' + str(chan.voltage) + 'V') + +MCP3004 Differential +-------------------- + +.. code-block:: python + + import busio + import digitalio + import board + import adafruit_mcp3xxx.mcp3004 as MCP + from adafruit_mcp3xxx.analog_in import AnalogIn + + # create the spi bus + spi = busio.SPI(clock=board.SCK, MISO=board.MISO, MOSI=board.MOSI) + + # create the cs (chip select) + cs = digitalio.DigitalInOut(board.D5) + + # create the mcp object + mcp = MCP.MCP3004(spi, cs) + + # create a differential ADC channel between Pin 0 and Pin 1 + chan = AnalogIn(mcp, MCP.P0, MCP.P1) + + print('Differential ADC Value: ', chan.value) + print('Differential ADC Voltage: ' + str(chan.voltage) + 'V') + + Contributing ============ diff --git a/docs/examples.rst b/docs/examples.rst index 53e6c04..baf75a6 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -6,3 +6,15 @@ Ensure your device works with this simple test. .. literalinclude:: ../examples/mcp3008_single_ended_simpletest.py :caption: examples/mcp3008_single_ended_simpletest.py :linenos: + +.. literalinclude:: ../examples/mcp3004_single_ended_simpletest.py + :caption: examples/mcp3004_single_ended_simpletest.py + :linenos: + +.. literalinclude:: ../examples/mcp3008_differential_simpletest.py + :caption: mcp3008_differential_simpletest.py + :linenos: + +.. literalinclude:: ../examples/mcp3004_differential_simpletest.py + :caption: mcp3004_differential_simpletest.py + :linenos: \ No newline at end of file From e5df4ca19d85e3e4e41e7d8ad2b93113f1ea98ec Mon Sep 17 00:00:00 2001 From: brentru Date: Mon, 15 Apr 2019 12:13:54 -0400 Subject: [PATCH 2/3] updating API docs --- docs/api.rst | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/api.rst b/docs/api.rst index 8c4d12e..13b351d 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -1,5 +1,14 @@ API ------------ -.. automodule:: adafruit_mcp3xxx +.. automodule:: adafruit_mcp3xxx.adafruit_mcp3xxx :members: + +.. automodule:: adafruit_mcp3xxx.adafruit_mcp3004 + :members: + +.. automodule:: adafruit_mcp3xxx.adafruit_mcp3008 + :members: + +.. automodule:: adafruit_mcp3xxx.analog_in + :members: \ No newline at end of file From e21fa0a9fa290a66b71a54db836ad6b822c42daf Mon Sep 17 00:00:00 2001 From: brentru Date: Thu, 18 Apr 2019 09:51:33 -0400 Subject: [PATCH 3/3] update for pylint --- docs/api.rst | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index 13b351d..7918dbb 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -1,14 +1,5 @@ API ------------ -.. automodule:: adafruit_mcp3xxx.adafruit_mcp3xxx - :members: - -.. automodule:: adafruit_mcp3xxx.adafruit_mcp3004 - :members: - -.. automodule:: adafruit_mcp3xxx.adafruit_mcp3008 - :members: - -.. automodule:: adafruit_mcp3xxx.analog_in +.. automodule:: adafruit_mcp3xxx :members: \ No newline at end of file