Skip to content

Ran black, updated to pylint 2.x #40

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 1 commit into from
Mar 17, 2020
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 .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
source actions-ci/install.sh
- name: Pip install pylint, black, & Sphinx
run: |
pip install --force-reinstall pylint==1.9.2 black==19.10b0 Sphinx sphinx-rtd-theme
pip install --force-reinstall pylint black==19.10b0 Sphinx sphinx-rtd-theme
- name: Library version
run: git describe --dirty --always --tags
- name: PyLint
Expand Down
409 changes: 216 additions & 193 deletions adafruit_rfm9x.py

Large diffs are not rendered by default.

114 changes: 68 additions & 46 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@

import os
import sys
sys.path.insert(0, os.path.abspath('..'))

sys.path.insert(0, os.path.abspath(".."))

# -- General configuration ------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.intersphinx',
"sphinx.ext.autodoc",
"sphinx.ext.intersphinx",
#'sphinx.ext.napoleon'
'sphinx.ext.todo',
"sphinx.ext.todo",
]

# Uncomment the below if you use native CircuitPython modules such as
Expand All @@ -22,29 +23,36 @@
# autodoc_mock_imports = ["digitalio", "busio", "micropython", "adafruit_bus_device.spi_device", "adafruit_bus_device"]


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)}
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),
}

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

source_suffix = '.rst'
source_suffix = ".rst"

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# General information about the project.
project = u'Adafruit rfm9x Library'
copyright = u'2018 Tony DiCola'
author = u'Tony DiCola'
project = u"Adafruit rfm9x Library"
copyright = u"2018 Tony DiCola"
author = u"Tony DiCola"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = u'1.0'
version = u"1.0"
# The full version, including alpha/beta/rc tags.
release = u'1.0'
release = u"1.0"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand All @@ -56,7 +64,7 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"]

# The reST default role (used for this markup: `text`) to use for all
# documents.
Expand All @@ -68,7 +76,7 @@
add_function_parentheses = True

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
Expand All @@ -83,68 +91,76 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
on_rtd = os.environ.get("READTHEDOCS", None) == "True"

if not on_rtd: # only import and set the theme if we're building docs locally
try:
import sphinx_rtd_theme
html_theme = 'sphinx_rtd_theme'
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']

html_theme = "sphinx_rtd_theme"
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
except:
html_theme = 'default'
html_theme_path = ['.']
html_theme = "default"
html_theme_path = ["."]
else:
html_theme_path = ['.']
html_theme_path = ["."]

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]

# The name of an image file (relative to this directory) to use as a favicon of
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#
html_favicon = '_static/favicon.ico'
html_favicon = "_static/favicon.ico"

# Output file base name for HTML help builder.
htmlhelp_basename = 'AdafruitRfm9xLibrarydoc'
htmlhelp_basename = "AdafruitRfm9xLibrarydoc"

# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'Adafruitrfm9xLibrary.tex', u'Adafruitrfm9x Library Documentation',
author, 'manual'),
(
master_doc,
"Adafruitrfm9xLibrary.tex",
u"Adafruitrfm9x Library Documentation",
author,
"manual",
),
]

# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'Adafruitrfm9xlibrary', u'Adafruit rfm9x Library Documentation',
[author], 1)
(
master_doc,
"Adafruitrfm9xlibrary",
u"Adafruit rfm9x Library Documentation",
[author],
1,
)
]

# -- Options for Texinfo output -------------------------------------------
Expand All @@ -153,7 +169,13 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'Adafruitrfm9xLibrary', u'Adafruit rfm9x Library Documentation',
author, 'Adafruitrfm9xLibrary', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"Adafruitrfm9xLibrary",
u"Adafruit rfm9x Library Documentation",
author,
"Adafruitrfm9xLibrary",
"One line description of project.",
"Miscellaneous",
),
]
28 changes: 14 additions & 14 deletions examples/rfm9x_rpi_interrupt.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@

# setup interrupt callback function
def rfm9x_callback(rfm9x_irq):
global packet_received #pylint: disable=global-statement
print("IRQ detected ",rfm9x_irq, rfm9x.rx_done)
global packet_received # pylint: disable=global-statement
print("IRQ detected ", rfm9x_irq, rfm9x.rx_done)
# check to see if this was a rx interrupt - ignore tx
if rfm9x.rx_done:
packet = rfm9x.receive(timeout = None)
packet = rfm9x.receive(timeout=None)
if packet is not None:
packet_received = True
# Received a packet!
# Print out the raw bytes of the packet:
print('Received (raw bytes): {0}'.format(packet))
print("Received (raw bytes): {0}".format(packet))
print([hex(x) for x in packet])
print('RSSI: {0}'.format(rfm9x.rssi))
print("RSSI: {0}".format(rfm9x.rssi))


# Define radio parameters.
RADIO_FREQ_MHZ = 915.0 # Frequency of the radio in Mhz. Must match your
# module! Can be a value like 915.0, 433.0, etc.
# module! Can be a value like 915.0, 433.0, etc.

# Define pins connected to the chip, use these if wiring up the breakout according to the guide:
CS = digitalio.DigitalInOut(board.CE1)
Expand All @@ -51,25 +51,25 @@ def rfm9x_callback(rfm9x_irq):
# configure the interrupt pin and event handling.
RFM9X_G0 = 22
io.setmode(io.BCM)
io.setup(RFM9X_G0, io.IN,pull_up_down=io.PUD_DOWN) # activate input
io.add_event_detect(RFM9X_G0,io.RISING)
io.add_event_callback(RFM9X_G0,rfm9x_callback)
io.setup(RFM9X_G0, io.IN, pull_up_down=io.PUD_DOWN) # activate input
io.add_event_detect(RFM9X_G0, io.RISING)
io.add_event_callback(RFM9X_G0, rfm9x_callback)

packet_received = False
# Send a packet. Note you can only send a packet up to 252 bytes in length.
# This is a limitation of the radio packet size, so if you need to send larger
# amounts of data you will need to break it into smaller send calls. Each send
# call will wait for the previous one to finish before continuing.
rfm9x.send(bytes("Hello world!\r\n","utf-8"), keep_listening = True)
print('Sent Hello World message!')
rfm9x.send(bytes("Hello world!\r\n", "utf-8"), keep_listening=True)
print("Sent Hello World message!")

# Wait to receive packets. Note that this library can't receive data at a fast
# rate, in fact it can only receive and process one 252 byte packet at a time.
# This means you should only use this for low bandwidth scenarios, like sending
# and receiving a single message at a time.
print('Waiting for packets...')
print("Waiting for packets...")
while True:
time.sleep(.1)
time.sleep(0.1)
if packet_received:
print('received message!')
print("received message!")
packet_received = False
20 changes: 10 additions & 10 deletions examples/rfm9x_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

# Define radio parameters.
RADIO_FREQ_MHZ = 915.0 # Frequency of the radio in Mhz. Must match your
# module! Can be a value like 915.0, 433.0, etc.
# module! Can be a value like 915.0, 433.0, etc.

# Define pins connected to the chip, use these if wiring up the breakout according to the guide:
CS = digitalio.DigitalInOut(board.D5)
Expand Down Expand Up @@ -40,36 +40,36 @@
# This is a limitation of the radio packet size, so if you need to send larger
# amounts of data you will need to break it into smaller send calls. Each send
# call will wait for the previous one to finish before continuing.
rfm9x.send(bytes("Hello world!\r\n","utf-8"))
print('Sent Hello World message!')
rfm9x.send(bytes("Hello world!\r\n", "utf-8"))
print("Sent Hello World message!")

# Wait to receive packets. Note that this library can't receive data at a fast
# rate, in fact it can only receive and process one 252 byte packet at a time.
# This means you should only use this for low bandwidth scenarios, like sending
# and receiving a single message at a time.
print('Waiting for packets...')
print("Waiting for packets...")

while True:
packet = rfm9x.receive()
# Optionally change the receive timeout from its default of 0.5 seconds:
#packet = rfm9x.receive(timeout=5.0)
# packet = rfm9x.receive(timeout=5.0)
# If no packet was received during the timeout then None is returned.
if packet is None:
# Packet has not been received
LED.value = False
print('Received nothing! Listening again...')
print("Received nothing! Listening again...")
else:
# Received a packet!
LED.value = True
# Print out the raw bytes of the packet:
print('Received (raw bytes): {0}'.format(packet))
print("Received (raw bytes): {0}".format(packet))
# And decode to ASCII text and print it too. Note that you always
# receive raw bytes and need to convert to a text format like ASCII
# if you intend to do string processing on your data. Make sure the
# sending side is sending ASCII data before you try to decode!
packet_text = str(packet, 'ascii')
print('Received (ASCII): {0}'.format(packet_text))
packet_text = str(packet, "ascii")
print("Received (ASCII): {0}".format(packet_text))
# Also read the RSSI (signal strength) of the last received message and
# print it.
rssi = rfm9x.rssi
print('Received signal strength: {0} dB'.format(rssi))
print("Received signal strength: {0} dB".format(rssi))
34 changes: 17 additions & 17 deletions examples/rfm9x_transmit.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
import adafruit_rfm9x

# set the time interval (seconds) for sending packets
transmit_interval=10
transmit_interval = 10

# Define radio parameters.
RADIO_FREQ_MHZ = 915.0 # Frequency of the radio in Mhz. Must match your
# module! Can be a value like 915.0, 433.0, etc.
RADIO_FREQ_MHZ = 915.0 # Frequency of the radio in Mhz. Must match your
# module! Can be a value like 915.0, 433.0, etc.

# Define pins connected to the chip.
CS = digitalio.DigitalInOut(board.CE1)
CS = digitalio.DigitalInOut(board.CE1)
RESET = digitalio.DigitalInOut(board.D25)

# Initialize SPI bus.
Expand All @@ -34,27 +34,27 @@

# initialize counter
counter = 0
#send a broadcast mesage
rfm9x.send(bytes("message number {}".format(counter),"UTF-8"))
# send a broadcast mesage
rfm9x.send(bytes("message number {}".format(counter), "UTF-8"))

# Wait to receive packets.
print('Waiting for packets...')
#initialize flag and timer
send_reading=False
time_now=time.monotonic()
print("Waiting for packets...")
# initialize flag and timer
send_reading = False
time_now = time.monotonic()
while True:
# Look for a new packet - wait up to 5 seconds:
packet = rfm9x.receive(timeout=5.0)
# If no packet was received during the timeout then None is returned.
if packet is not None:
# Received a packet!
# Print out the raw bytes of the packet:
print('Received (raw bytes): {0}'.format(packet))
print("Received (raw bytes): {0}".format(packet))
# send reading after any packet received
if time.monotonic()-time_now>transmit_interval:
#reset timeer
time_now=time.monotonic()
#clear flag to send data
send_reading=False
if time.monotonic() - time_now > transmit_interval:
# reset timeer
time_now = time.monotonic()
# clear flag to send data
send_reading = False
counter = counter + 1
rfm9x.send(bytes("message number {}".format(counter),"UTF-8"))
rfm9x.send(bytes("message number {}".format(counter), "UTF-8"))
Loading