From 008565f650683dcf7c0d8337f6ba309c583b08e1 Mon Sep 17 00:00:00 2001 From: Thomas Franks Date: Sun, 19 Mar 2023 21:08:14 -0400 Subject: [PATCH 1/5] add addtional RTD info --- adafruit_pn532/i2c.py | 36 ++++++++++++++++++++++++++++++++++++ adafruit_pn532/spi.py | 35 ++++++++++++++++++++++++++++++++++- adafruit_pn532/uart.py | 28 ++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+), 1 deletion(-) diff --git a/adafruit_pn532/i2c.py b/adafruit_pn532/i2c.py index 63c4365..84d5b7d 100644 --- a/adafruit_pn532/i2c.py +++ b/adafruit_pn532/i2c.py @@ -49,6 +49,42 @@ class PN532_I2C(PN532): """Create an instance of the PN532 class using I2C. Note that PN532 uses clock stretching. Optional IRQ pin (not used), resetp pin and debugging output. + + :param busio.I2C i2c: The I2C bus the PN532 is connected to. + :param int address: The I2C device address. Defaults to :const:`0x24` + :param DigitalInOut reset: board pin the PN532 reset is connected to + :param DigitalInOut req: board pin the PN532 P32 is connected to + :param bool debug: if true print additional debug statements + + **Quickstart: Importing and using the device** + Here is an example of using the :class:`PN532_I2C` class. + First you will need to import the libraries to use the sensor + + .. code-block:: python + + import board + import busio + from digitalio import DigitalInOut + from adafruit_pn532.i2c import PN532_I2C + + Once this is done you can define your `board.I2C` object and define your object + .. code-block:: python + + i2c = busio.I2C(board.SCL, board.SDA) + reset_pin = DigitalInOut(board.D6) + # On Raspberry Pi, you must also connect a pin to P32 "H_Request" for hardware + # wakeup! this means we don't need to do the I2C clock-stretch thing + req_pin = DigitalInOut(board.D12) + pn532 = PN532_I2C(i2c, debug=False, reset=reset_pin, req=req_pin) + # Configure PN532 to communicate with MiFare cards + pn532.SAM_configuration() + + Now you have access to the attributes and functions of the PN532 RFID/NFC shield or breakout + + .. code-block:: python + + uid = pn532.read_passive_target(timeout=0.5) + """ self.debug = debug self._req = req diff --git a/adafruit_pn532/spi.py b/adafruit_pn532/spi.py index 72afa18..ad58fc1 100644 --- a/adafruit_pn532/spi.py +++ b/adafruit_pn532/spi.py @@ -61,7 +61,40 @@ class PN532_SPI(PN532): reset: Optional[DigitalInOut] = None, debug: bool = False ) -> None: - """Create an instance of the PN532 class using SPI""" + """Create an instance of the PN532 class using SPI + Optional IRQ pin (not used) + + :param busio.SPI spi: The spi bus the PN532 is connected to. + :param DigitalInOut cs: board pin the PN532 chip select line is connected to + :param DigitalInOut irq: board pin the PN532 P32 is connected to + :param DigitalInOut reset: board pin the PN532 reset is connected to + :param bool debug: if true print additional debug statements + + **Quickstart: Importing and using the device** + Here is an example of using the :class:`PN532_I2C` class. + First you will need to import the libraries to use the sensor + + .. code-block:: python + + import board + import busio + from digitalio import DigitalInOut + from adafruit_pn532.spi import PN532_SPI + + Once this is done you can define your `busio.SPI` object and define your PN532 object + .. code-block:: python + + spi = busio.SPI(board.SCK, board.MOSI, board.MISO) + cs_pin = DigitalInOut(board.D5) + pn532 = PN532_SPI(spi, cs_pin, debug=False) + + Now you have access to the attributes and functions of the PN532 RFID/NFC shield or breakout + + .. code-block:: python + + uid = pn532.read_passive_target(timeout=0.5) + + """ self.debug = debug self._spi = spi_device.SPIDevice(spi, cs_pin) super().__init__(debug=debug, irq=irq, reset=reset) diff --git a/adafruit_pn532/uart.py b/adafruit_pn532/uart.py index 57548c3..597b1c2 100644 --- a/adafruit_pn532/uart.py +++ b/adafruit_pn532/uart.py @@ -37,6 +37,34 @@ class PN532_UART(PN532): ) -> None: """Create an instance of the PN532 class using Serial connection. Optional reset pin and debugging output. + + :param busio.UART i2c: The I2C bus the PN532 is connected to. + :param DigitalInOut reset: board pin the PN532 reset is connected to + :param bool debug: if true print additional debug statements + + **Quickstart: Importing and using the device** + Here is an example of using the :class:`PN532_I2C` class. + First you will need to import the libraries to use the sensor + + .. code-block:: python + + import board + import busio + from digitalio import DigitalInOut + from adafruit_pn532.uart import PN532_UART + + Once this is done you can define your `busio.UART` object and define your PN532 object + .. code-block:: python + + uart = busio.UART(board.TX, board.RX, baudrate=115200, timeout=0.1) + pn532 = PN532_UART(uart, debug=False) + + Now you have access to the attributes and functions of the PN532 RFID/NFC shield or breakout + + .. code-block:: python + + uid = pn532.read_passive_target(timeout=0.5) + """ self.debug = debug self._uart = uart From 1859ca77d8db5f68771e15aa5061a292b372ef3f Mon Sep 17 00:00:00 2001 From: Thomas Franks Date: Tue, 21 Mar 2023 14:49:32 -0400 Subject: [PATCH 2/5] changes per comments --- adafruit_pn532/i2c.py | 51 ++++++++++++++++++++++-------------------- adafruit_pn532/spi.py | 16 +++++++------ adafruit_pn532/uart.py | 37 ++++++++++++++++-------------- docs/conf.py | 2 ++ 4 files changed, 58 insertions(+), 48 deletions(-) diff --git a/adafruit_pn532/i2c.py b/adafruit_pn532/i2c.py index 84d5b7d..ade7c18 100644 --- a/adafruit_pn532/i2c.py +++ b/adafruit_pn532/i2c.py @@ -50,40 +50,43 @@ class PN532_I2C(PN532): uses clock stretching. Optional IRQ pin (not used), resetp pin and debugging output. - :param busio.I2C i2c: The I2C bus the PN532 is connected to. + :param ~busio.I2C i2c: The I2C bus the PN532 is connected to. :param int address: The I2C device address. Defaults to :const:`0x24` - :param DigitalInOut reset: board pin the PN532 reset is connected to - :param DigitalInOut req: board pin the PN532 P32 is connected to - :param bool debug: if true print additional debug statements + :param digitalio.DigitalInOut reset: board pin the PN532 reset is connected to + :param digitalio.DigitalInOut req: board pin the PN532 P32 is connected to + :param bool debug: if True print additional debug statements. Defaults to False **Quickstart: Importing and using the device** - Here is an example of using the :class:`PN532_I2C` class. - First you will need to import the libraries to use the sensor - .. code-block:: python + Here is an example of using the :class:`PN532_I2C` class. + First you will need to import the libraries to use the sensor - import board - import busio - from digitalio import DigitalInOut - from adafruit_pn532.i2c import PN532_I2C + .. code-block:: python - Once this is done you can define your `board.I2C` object and define your object - .. code-block:: python + import board + import busio + from digitalio import DigitalInOut + from adafruit_pn532.i2c import PN532_I2C - i2c = busio.I2C(board.SCL, board.SDA) - reset_pin = DigitalInOut(board.D6) - # On Raspberry Pi, you must also connect a pin to P32 "H_Request" for hardware - # wakeup! this means we don't need to do the I2C clock-stretch thing - req_pin = DigitalInOut(board.D12) - pn532 = PN532_I2C(i2c, debug=False, reset=reset_pin, req=req_pin) - # Configure PN532 to communicate with MiFare cards - pn532.SAM_configuration() + Once this is done you can define your `board.I2C` object and define your object - Now you have access to the attributes and functions of the PN532 RFID/NFC shield or breakout + .. code-block:: python - .. code-block:: python + i2c = busio.I2C(board.SCL, board.SDA) + reset_pin = DigitalInOut(board.D6) + # On Raspberry Pi, you must also connect a pin to P32 "H_Request" for hardware + # wakeup! this means we don't need to do the I2C clock-stretch thing + req_pin = DigitalInOut(board.D12) + pn532 = PN532_I2C(i2c, debug=False, reset=reset_pin, req=req_pin) + # Configure PN532 to communicate with MiFare cards + pn532.SAM_configuration() - uid = pn532.read_passive_target(timeout=0.5) + Now you have access to the attributes and functions of the PN532 RFID/NFC + shield or breakout + + .. code-block:: python + + uid = pn532.read_passive_target(timeout=0.5) """ self.debug = debug diff --git a/adafruit_pn532/spi.py b/adafruit_pn532/spi.py index ad58fc1..18857b2 100644 --- a/adafruit_pn532/spi.py +++ b/adafruit_pn532/spi.py @@ -64,14 +64,14 @@ class PN532_SPI(PN532): """Create an instance of the PN532 class using SPI Optional IRQ pin (not used) - :param busio.SPI spi: The spi bus the PN532 is connected to. - :param DigitalInOut cs: board pin the PN532 chip select line is connected to - :param DigitalInOut irq: board pin the PN532 P32 is connected to - :param DigitalInOut reset: board pin the PN532 reset is connected to - :param bool debug: if true print additional debug statements + :param ~busio.SPI spi: The spi bus the PN532 is connected to. + :param digitalio.DigitalInOut cs: board pin the PN532 chip select line is connected to + :param digitalio.DigitalInOut irq: board pin the PN532 P32 is connected to + :param digitalio.DigitalInOut reset: board pin the PN532 reset is connected to + :param bool debug: if True print additional debug statements. Defaults to False **Quickstart: Importing and using the device** - Here is an example of using the :class:`PN532_I2C` class. + Here is an example of using the :class:`PN532_SPI` class. First you will need to import the libraries to use the sensor .. code-block:: python @@ -82,13 +82,15 @@ class PN532_SPI(PN532): from adafruit_pn532.spi import PN532_SPI Once this is done you can define your `busio.SPI` object and define your PN532 object + .. code-block:: python spi = busio.SPI(board.SCK, board.MOSI, board.MISO) cs_pin = DigitalInOut(board.D5) pn532 = PN532_SPI(spi, cs_pin, debug=False) - Now you have access to the attributes and functions of the PN532 RFID/NFC shield or breakout + Now you have access to the attributes and functions of the PN532 RFID/NFC + shield or breakout .. code-block:: python diff --git a/adafruit_pn532/uart.py b/adafruit_pn532/uart.py index 597b1c2..b99bf1c 100644 --- a/adafruit_pn532/uart.py +++ b/adafruit_pn532/uart.py @@ -38,32 +38,35 @@ class PN532_UART(PN532): """Create an instance of the PN532 class using Serial connection. Optional reset pin and debugging output. - :param busio.UART i2c: The I2C bus the PN532 is connected to. - :param DigitalInOut reset: board pin the PN532 reset is connected to - :param bool debug: if true print additional debug statements + :param ~busio.UART uart: The uart object the PN532 is connected to. + :param digitalio.DigitalInOut reset: board pin the PN532 reset is connected to + :param bool debug: if True print additional debug statements. Defaults to False **Quickstart: Importing and using the device** - Here is an example of using the :class:`PN532_I2C` class. - First you will need to import the libraries to use the sensor - .. code-block:: python + Here is an example of using the :class:`PN532_I2C` class. + First you will need to import the libraries to use the sensor - import board - import busio - from digitalio import DigitalInOut - from adafruit_pn532.uart import PN532_UART + .. code-block:: python - Once this is done you can define your `busio.UART` object and define your PN532 object - .. code-block:: python + import board + import busio + from digitalio import DigitalInOut + from adafruit_pn532.uart import PN532_UART - uart = busio.UART(board.TX, board.RX, baudrate=115200, timeout=0.1) - pn532 = PN532_UART(uart, debug=False) + Once this is done you can define your `busio.UART` object and define your PN532 object - Now you have access to the attributes and functions of the PN532 RFID/NFC shield or breakout + .. code-block:: python - .. code-block:: python + uart = busio.UART(board.TX, board.RX, baudrate=115200, timeout=0.1) + pn532 = PN532_UART(uart, debug=False) - uid = pn532.read_passive_target(timeout=0.5) + Now you have access to the attributes and functions of the PN532 RFID/NFC + shield or breakout + + .. code-block:: python + + uid = pn532.read_passive_target(timeout=0.5) """ self.debug = debug diff --git a/docs/conf.py b/docs/conf.py index 1d78ab7..4651af0 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -39,6 +39,8 @@ intersphinx_mapping = { "CircuitPython": ("https://docs.circuitpython.org/en/latest/", None), } +autoclass_content = "both" + # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] From 875703768e488ee39ce7f077c1dfda78b5dfbbcb Mon Sep 17 00:00:00 2001 From: jposada202020 <34255413+jposada202020@users.noreply.github.com> Date: Fri, 24 Mar 2023 00:14:44 -0400 Subject: [PATCH 3/5] Update adafruit_pn532/spi.py --- adafruit_pn532/spi.py | 1 + 1 file changed, 1 insertion(+) diff --git a/adafruit_pn532/spi.py b/adafruit_pn532/spi.py index 18857b2..1ca70e4 100644 --- a/adafruit_pn532/spi.py +++ b/adafruit_pn532/spi.py @@ -71,6 +71,7 @@ class PN532_SPI(PN532): :param bool debug: if True print additional debug statements. Defaults to False **Quickstart: Importing and using the device** + Here is an example of using the :class:`PN532_SPI` class. First you will need to import the libraries to use the sensor From 58f1c32526c0d184284fec14f528b1f8ab9a94c8 Mon Sep 17 00:00:00 2001 From: jposada202020 <34255413+jposada202020@users.noreply.github.com> Date: Fri, 7 Apr 2023 15:26:35 -0400 Subject: [PATCH 4/5] Update spi.py --- adafruit_pn532/spi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_pn532/spi.py b/adafruit_pn532/spi.py index 1ca70e4..cbb7dbf 100644 --- a/adafruit_pn532/spi.py +++ b/adafruit_pn532/spi.py @@ -70,8 +70,8 @@ class PN532_SPI(PN532): :param digitalio.DigitalInOut reset: board pin the PN532 reset is connected to :param bool debug: if True print additional debug statements. Defaults to False + **Quickstart: Importing and using the device** - Here is an example of using the :class:`PN532_SPI` class. First you will need to import the libraries to use the sensor From 2628c4aa0969c0594b76f51bfb7cdc0a8ec60c25 Mon Sep 17 00:00:00 2001 From: Thomas Franks Date: Sat, 8 Apr 2023 20:50:43 -0400 Subject: [PATCH 5/5] changes after local build of RTD and review --- adafruit_pn532/adafruit_pn532.py | 3 +-- adafruit_pn532/i2c.py | 3 ++- adafruit_pn532/spi.py | 2 +- adafruit_pn532/uart.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/adafruit_pn532/adafruit_pn532.py b/adafruit_pn532/adafruit_pn532.py index 35c0f86..513dcec 100644 --- a/adafruit_pn532/adafruit_pn532.py +++ b/adafruit_pn532/adafruit_pn532.py @@ -28,7 +28,6 @@ Implementation Notes import time from digitalio import Direction - from micropython import const try: @@ -164,7 +163,7 @@ class PN532: *, debug: bool = False, irq: Optional[DigitalInOut] = None, - reset: Optional[DigitalInOut] = None + reset: Optional[DigitalInOut] = None, ) -> None: """Create an instance of the PN532 class""" self.low_power = True diff --git a/adafruit_pn532/i2c.py b/adafruit_pn532/i2c.py index ade7c18..657688c 100644 --- a/adafruit_pn532/i2c.py +++ b/adafruit_pn532/i2c.py @@ -52,7 +52,8 @@ class PN532_I2C(PN532): :param ~busio.I2C i2c: The I2C bus the PN532 is connected to. :param int address: The I2C device address. Defaults to :const:`0x24` - :param digitalio.DigitalInOut reset: board pin the PN532 reset is connected to + :param digitalio.DigitalInOut irq: board pin the PN532 IRQ is connected to + :param digitalio.DigitalInOut reset: board pin the PN532 RSTOUT_N is connected to :param digitalio.DigitalInOut req: board pin the PN532 P32 is connected to :param bool debug: if True print additional debug statements. Defaults to False diff --git a/adafruit_pn532/spi.py b/adafruit_pn532/spi.py index 18857b2..50ccfd1 100644 --- a/adafruit_pn532/spi.py +++ b/adafruit_pn532/spi.py @@ -67,7 +67,7 @@ class PN532_SPI(PN532): :param ~busio.SPI spi: The spi bus the PN532 is connected to. :param digitalio.DigitalInOut cs: board pin the PN532 chip select line is connected to :param digitalio.DigitalInOut irq: board pin the PN532 P32 is connected to - :param digitalio.DigitalInOut reset: board pin the PN532 reset is connected to + :param digitalio.DigitalInOut reset: board pin the PN532 RSTOUT_N is connected to :param bool debug: if True print additional debug statements. Defaults to False **Quickstart: Importing and using the device** diff --git a/adafruit_pn532/uart.py b/adafruit_pn532/uart.py index b99bf1c..8f8949b 100644 --- a/adafruit_pn532/uart.py +++ b/adafruit_pn532/uart.py @@ -39,7 +39,7 @@ class PN532_UART(PN532): Optional reset pin and debugging output. :param ~busio.UART uart: The uart object the PN532 is connected to. - :param digitalio.DigitalInOut reset: board pin the PN532 reset is connected to + :param digitalio.DigitalInOut reset: board pin the PN532 RSTOUT_N is connected to :param bool debug: if True print additional debug statements. Defaults to False **Quickstart: Importing and using the device**