Skip to content

Commit

Permalink
fix docs generation, a few changes per review
Browse files Browse the repository at this point in the history
  • Loading branch information
jerryneedell committed Aug 7, 2024
1 parent 829d767 commit 033ac44
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 10 deletions.
7 changes: 4 additions & 3 deletions adafruit_rfm/rfm69.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: MIT

"""
`adafruit_rfm69`
`adafruit_rfm.rfm69`
====================================================
CircuitPython RFM69 packet radio module. This supports sending and
Expand Down Expand Up @@ -33,12 +33,12 @@
except ImportError:
pass


try:
from typing import Optional

import busio
import digitalio
from circuitpython_typing import ReadableBuffer

except ImportError:
pass
Expand Down Expand Up @@ -567,6 +567,7 @@ def enable_crc(self, val: bool) -> None:
else:
self.crc_on = 0

@property
def crc_error(self) -> bool:
"""crc status"""
return (self.read_u8(_RF69_REG_28_IRQ_FLAGS2) & 0x2) >> 1
Expand Down Expand Up @@ -629,7 +630,7 @@ def clear_interrupt(self) -> None:
self.write_u8(_RF69_REG_27_IRQ_FLAGS1, 0xFF)
self.write_u8(_RF69_REG_28_IRQ_FLAGS2, 0xFF)

def fill_fifo(self, payload: bytearray) -> None:
def fill_fifo(self, payload: ReadableBuffer) -> None:
"""Write the payload to the FIFO."""
complete_payload = bytearray(1) # prepend packet length to payload
complete_payload[0] = len(payload)
Expand Down
6 changes: 4 additions & 2 deletions adafruit_rfm/rfm9x.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: MIT

"""
`adafruit_rfm9x`
`adafruit_rfm.rfm9x`
====================================================
CircuitPython module for the RFM95/6/7/8 LoRa 433/915mhz radio modules.
Expand All @@ -20,6 +20,7 @@
try:
import busio
import digitalio
from circuitpython_typing import ReadableBuffer

try:
from typing import Literal
Expand Down Expand Up @@ -490,6 +491,7 @@ def enable_crc(self, val: bool) -> None:
self.read_u8(_RF95_REG_1E_MODEM_CONFIG2) & 0xFB,
)

@property
def crc_error(self) -> bool:
"""crc status"""
return (self.read_u8(_RF95_REG_12_IRQ_FLAGS) & 0x20) >> 5
Expand All @@ -506,7 +508,7 @@ def clear_interrupt(self) -> None:
"""Clear Interrupt flags"""
self.write_u8(_RF95_REG_12_IRQ_FLAGS, 0xFF)

def fill_fifo(self, payload: bytearray) -> None:
def fill_fifo(self, payload: ReadableBuffer) -> None:
"""len_data is not used but is here for compatibility with rfm69
Fill the FIFO with a packet to send"""
self.write_u8(_RF95_REG_0D_FIFO_ADDR_PTR, 0x00) # FIFO starts at 0.
Expand Down
6 changes: 4 additions & 2 deletions adafruit_rfm/rfm9xfsk.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: MIT

"""
`adafruit_rfm9xFSK`
`adafruit_rfm.rfm9xfsk`
====================================================
CircuitPython module for the RFM95/6/7/8 FSK 433/915mhz radio modules.
Expand All @@ -22,6 +22,7 @@

import busio
import digitalio
from circuitpython_typing import ReadableBuffer

try:
from typing import Literal
Expand Down Expand Up @@ -490,6 +491,7 @@ def enable_crc(self, val: bool) -> None:
else:
self.crc_on = 0

@property
def crc_error(self) -> bool:
"""crc status"""
return (self.read_u8(_RF95_REG_3F_IRQ_FLAGS_2) & 0x2) >> 1
Expand Down Expand Up @@ -552,7 +554,7 @@ def clear_interrupt(self) -> None:
self.write_u8(_RF95_REG_3E_IRQ_FLAGS_1, 0xFF)
self.write_u8(_RF95_REG_3F_IRQ_FLAGS_2, 0xFF)

def fill_fifo(self, payload: bytearray) -> None:
def fill_fifo(self, payload: ReadableBuffer) -> None:
"""Write the payload to the FIFO."""
complete_payload = bytearray(1) # prepend packet length to payload
complete_payload[0] = len(payload)
Expand Down
16 changes: 14 additions & 2 deletions adafruit_rfm/rfm_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,9 @@ async def asyncio_send( # noqa: PLR0912 PLR0913
return not timed_out

send = asyncio_to_blocking(asyncio_send)
"""Non-asyncio wrapper to Send a string of data using the transmitter
using the same arguments and keywords as asyncio_send()
"""

async def asyncio_send_with_ack(self, data: ReadableBuffer) -> bool:
"""Reliable Datagram mode:
Expand Down Expand Up @@ -377,6 +380,9 @@ async def asyncio_send_with_ack(self, data: ReadableBuffer) -> bool:
return got_ack

send_with_ack = asyncio_to_blocking(asyncio_send_with_ack)
"""Non-asyncio wrapper to Send a string of data using the transmitter
using the same arguments and keywords as asyncio_send_with_ack()
"""

async def asyncio_receive( # noqa: PLR0912
self,
Expand Down Expand Up @@ -420,7 +426,7 @@ async def asyncio_receive( # noqa: PLR0912
# Enter idle mode to stop receiving other packets.
self.idle()
if not timed_out:
if self.enable_crc and self.crc_error():
if self.enable_crc and self.crc_error:
self.crc_error_count += 1
else:
packet = self.read_fifo()
Expand All @@ -447,6 +453,9 @@ async def asyncio_receive( # noqa: PLR0912
return packet

receive = asyncio_to_blocking(asyncio_receive)
"""Non-asyncio wrapper to Receive a packet
using the same arguments and keywords as asyncio_receive()
"""

async def asyncio_receive_with_ack( # noqa: PLR0912
self,
Expand Down Expand Up @@ -490,7 +499,7 @@ async def asyncio_receive_with_ack( # noqa: PLR0912
# Enter idle mode to stop receiving other packets.
self.idle()
if not timed_out:
if self.enable_crc and self.crc_error():
if self.enable_crc and self.crc_error:
self.crc_error_count += 1
else:
packet = self.read_fifo()
Expand Down Expand Up @@ -543,3 +552,6 @@ async def asyncio_receive_with_ack( # noqa: PLR0912
return packet

receive_with_ack = asyncio_to_blocking(asyncio_receive_with_ack)
"""Non-asyncio wrapper to Receive a packet
using the same arguments and keywords as asyncio_receive_with_ack()
"""
11 changes: 10 additions & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,14 @@
.. If your library file(s) are nested in a directory (e.g. /adafruit_foo/foo.py)
.. use this format as the module name: "adafruit_foo.foo"
.. automodule:: adafruit_rfm
.. automodule:: adafruit_rfm.rfm_common
:members:

.. automodule:: adafruit_rfm.rfm69
:members:

.. automodule:: adafruit_rfm.rfm9x
:members:

.. automodule:: adafruit_rfm.rfm9xfsk
:members:

0 comments on commit 033ac44

Please sign in to comment.