Skip to content

Commit 0da77a1

Browse files
authored
Merge pull request #20 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents f87d693 + 0f5df77 commit 0da77a1

File tree

5 files changed

+144
-123
lines changed

5 files changed

+144
-123
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
source actions-ci/install.sh
4141
- name: Pip install pylint, black, & Sphinx
4242
run: |
43-
pip install --force-reinstall pylint==1.9.2 black==19.10b0 Sphinx sphinx-rtd-theme
43+
pip install --force-reinstall pylint black==19.10b0 Sphinx sphinx-rtd-theme
4444
- name: Library version
4545
run: git describe --dirty --always --tags
4646
- name: PyLint

adafruit_rtttl.py

Lines changed: 47 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
try:
4040
import audioio
4141
from adafruit_waveform import sine
42+
4243
AUDIOIO_AVAILABLE = True
4344
try:
4445
import audiocore
@@ -47,44 +48,47 @@
4748
except ImportError:
4849
pass
4950

50-
PIANO = {"4c" : 261.626,
51-
"4c#": 277.183,
52-
"4d" : 293.665,
53-
"4d#": 311.127,
54-
"4e" : 329.628,
55-
"4f" : 349.228,
56-
"4f#": 369.994,
57-
"4g" : 391.995,
58-
"4g#": 415.305,
59-
"4a" : 440,
60-
"4a#": 466.164,
61-
"4b" : 493.883,
62-
"5c" : 523.251,
63-
"5c#": 554.365,
64-
"5d" : 587.330,
65-
"5d#": 622.254,
66-
"5e" : 659.255,
67-
"5f" : 698.456,
68-
"5f#": 739.989,
69-
"5g" : 783.991,
70-
"5g#": 830.609,
71-
"5a" : 880,
72-
"5a#": 932.328,
73-
"5b" : 987.767,
74-
"6c" : 1046.50,
75-
"6c#": 1108.73,
76-
"6d" : 1174.66,
77-
"6d#": 1244.51,
78-
"6e" : 1318.51,
79-
"6f" : 1396.91,
80-
"6f#": 1479.98,
81-
"6g" : 1567.98,
82-
"6g#": 1661.22,
83-
"6a" : 1760,
84-
"6a#": 1864.66,
85-
"6b" : 1975.53,
86-
"7c" : 2093,
87-
"7c#": 2217.46}
51+
PIANO = {
52+
"4c": 261.626,
53+
"4c#": 277.183,
54+
"4d": 293.665,
55+
"4d#": 311.127,
56+
"4e": 329.628,
57+
"4f": 349.228,
58+
"4f#": 369.994,
59+
"4g": 391.995,
60+
"4g#": 415.305,
61+
"4a": 440,
62+
"4a#": 466.164,
63+
"4b": 493.883,
64+
"5c": 523.251,
65+
"5c#": 554.365,
66+
"5d": 587.330,
67+
"5d#": 622.254,
68+
"5e": 659.255,
69+
"5f": 698.456,
70+
"5f#": 739.989,
71+
"5g": 783.991,
72+
"5g#": 830.609,
73+
"5a": 880,
74+
"5a#": 932.328,
75+
"5b": 987.767,
76+
"6c": 1046.50,
77+
"6c#": 1108.73,
78+
"6d": 1174.66,
79+
"6d#": 1244.51,
80+
"6e": 1318.51,
81+
"6f": 1396.91,
82+
"6f#": 1479.98,
83+
"6g": 1567.98,
84+
"6g#": 1661.22,
85+
"6a": 1760,
86+
"6a#": 1864.66,
87+
"6b": 1975.53,
88+
"7c": 2093,
89+
"7c#": 2217.46,
90+
}
91+
8892

8993
def _parse_note(note, duration=2, octave="6"):
9094
note = note.strip()
@@ -108,6 +112,7 @@ def _parse_note(note, duration=2, octave="6"):
108112
piano_note = note_octave + piano_note
109113
return piano_note, note_duration
110114

115+
111116
def _get_wave(tune, octave):
112117
"""Returns the proper waveform to play the song along with the minimum
113118
frequency in the song.
@@ -121,7 +126,7 @@ def _get_wave(tune, octave):
121126
return sine.sine_wave(16000, min_freq), min_freq
122127

123128

124-
#pylint: disable-msg=too-many-arguments
129+
# pylint: disable-msg=too-many-arguments
125130
def _play_to_pin(tune, base_tone, min_freq, duration, octave, tempo):
126131
"""Using the prepared input send the notes to the pin
127132
"""
@@ -140,8 +145,7 @@ def _play_to_pin(tune, base_tone, min_freq, duration, octave, tempo):
140145
sine_wave_sample = audiocore.RawSample(sine_wave)
141146
base_tone.play(sine_wave_sample, loop=True)
142147
else:
143-
base_tone.frequency = int(
144-
16000 * (PIANO[piano_note] / min_freq))
148+
base_tone.frequency = int(16000 * (PIANO[piano_note] / min_freq))
145149
base_tone.play(loop=True)
146150

147151
time.sleep(4 / note_duration * 60 / tempo)
@@ -151,7 +155,8 @@ def _play_to_pin(tune, base_tone, min_freq, duration, octave, tempo):
151155
base_tone.stop()
152156
time.sleep(0.02)
153157

154-
#pylint: disable-msg=too-many-arguments
158+
159+
# pylint: disable-msg=too-many-arguments
155160
def play(pin, rtttl, octave=None, duration=None, tempo=None):
156161
"""Play notes to a digialio pin using ring tone text transfer language (rtttl).
157162
:param ~digitalio.DigitalInOut pin: the speaker pin

docs/conf.py

Lines changed: 64 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,48 @@
22

33
import os
44
import sys
5-
sys.path.insert(0, os.path.abspath('..'))
5+
6+
sys.path.insert(0, os.path.abspath(".."))
67

78
# -- General configuration ------------------------------------------------
89

910
# Add any Sphinx extension module names here, as strings. They can be
1011
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
1112
# ones.
1213
extensions = [
13-
'sphinx.ext.autodoc',
14-
'sphinx.ext.intersphinx',
15-
'sphinx.ext.viewcode',
14+
"sphinx.ext.autodoc",
15+
"sphinx.ext.intersphinx",
16+
"sphinx.ext.viewcode",
1617
]
1718

1819
autodoc_mock_imports = ["pulseio"]
1920

20-
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
21+
intersphinx_mapping = {
22+
"python": ("https://docs.python.org/3.4", None),
23+
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
24+
}
2125

2226
# Add any paths that contain templates here, relative to this directory.
23-
templates_path = ['_templates']
27+
templates_path = ["_templates"]
2428

25-
source_suffix = '.rst'
29+
source_suffix = ".rst"
2630

2731
# The master toctree document.
28-
master_doc = 'index'
32+
master_doc = "index"
2933

3034
# General information about the project.
31-
project = u'Adafruit RTTTL Library'
32-
copyright = u'2017 Scott Shawcroft'
33-
author = u'Scott Shawcroft'
35+
project = u"Adafruit RTTTL Library"
36+
copyright = u"2017 Scott Shawcroft"
37+
author = u"Scott Shawcroft"
3438

3539
# The version info for the project you're documenting, acts as replacement for
3640
# |version| and |release|, also used in various other places throughout the
3741
# built documents.
3842
#
3943
# The short X.Y version.
40-
version = u'1.0'
44+
version = u"1.0"
4145
# The full version, including alpha/beta/rc tags.
42-
release = u'1.0'
46+
release = u"1.0"
4347

4448
# The language for content autogenerated by Sphinx. Refer to documentation
4549
# for a list of supported languages.
@@ -51,7 +55,7 @@
5155
# List of patterns, relative to source directory, that match files and
5256
# directories to ignore when looking for source files.
5357
# This patterns also effect to html_static_path and html_extra_path
54-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md']
58+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"]
5559

5660
# The reST default role (used for this markup: `text`) to use for all
5761
# documents.
@@ -63,7 +67,7 @@
6367
add_function_parentheses = True
6468

6569
# The name of the Pygments (syntax highlighting) style to use.
66-
pygments_style = 'sphinx'
70+
pygments_style = "sphinx"
6771

6872
# If true, `todo` and `todoList` produce output, else they produce nothing.
6973
todo_include_todos = False
@@ -77,68 +81,76 @@
7781
# The theme to use for HTML and HTML Help pages. See the documentation for
7882
# a list of builtin themes.
7983
#
80-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
84+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
8185

8286
if not on_rtd: # only import and set the theme if we're building docs locally
8387
try:
8488
import sphinx_rtd_theme
85-
html_theme = 'sphinx_rtd_theme'
86-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
89+
90+
html_theme = "sphinx_rtd_theme"
91+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
8792
except:
88-
html_theme = 'default'
89-
html_theme_path = ['.']
93+
html_theme = "default"
94+
html_theme_path = ["."]
9095
else:
91-
html_theme_path = ['.']
96+
html_theme_path = ["."]
9297

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

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

104109
# Output file base name for HTML help builder.
105-
htmlhelp_basename = 'AdafruitRTTTLLibrarydoc'
110+
htmlhelp_basename = "AdafruitRTTTLLibrarydoc"
106111

107112
# -- Options for LaTeX output ---------------------------------------------
108113

109114
latex_elements = {
110-
# The paper size ('letterpaper' or 'a4paper').
111-
#
112-
# 'papersize': 'letterpaper',
113-
114-
# The font size ('10pt', '11pt' or '12pt').
115-
#
116-
# 'pointsize': '10pt',
117-
118-
# Additional stuff for the LaTeX preamble.
119-
#
120-
# 'preamble': '',
121-
122-
# Latex figure (float) alignment
123-
#
124-
# 'figure_align': 'htbp',
115+
# The paper size ('letterpaper' or 'a4paper').
116+
#
117+
# 'papersize': 'letterpaper',
118+
# The font size ('10pt', '11pt' or '12pt').
119+
#
120+
# 'pointsize': '10pt',
121+
# Additional stuff for the LaTeX preamble.
122+
#
123+
# 'preamble': '',
124+
# Latex figure (float) alignment
125+
#
126+
# 'figure_align': 'htbp',
125127
}
126128

127129
# Grouping the document tree into LaTeX files. List of tuples
128130
# (source start file, target name, title,
129131
# author, documentclass [howto, manual, or own class]).
130132
latex_documents = [
131-
(master_doc, 'AdafruitRTTTLLibrary.tex', u'Adafruit RTTTL Library Documentation',
132-
author, 'manual'),
133+
(
134+
master_doc,
135+
"AdafruitRTTTLLibrary.tex",
136+
u"Adafruit RTTTL Library Documentation",
137+
author,
138+
"manual",
139+
),
133140
]
134141

135142
# -- Options for manual page output ---------------------------------------
136143

137144
# One entry per manual page. List of tuples
138145
# (source start file, name, description, authors, manual section).
139146
man_pages = [
140-
(master_doc, 'adafruitRTTTLlibrary', u'Adafruit RTTTL Library Documentation',
141-
[author], 1)
147+
(
148+
master_doc,
149+
"adafruitRTTTLlibrary",
150+
u"Adafruit RTTTL Library Documentation",
151+
[author],
152+
1,
153+
)
142154
]
143155

144156
# -- Options for Texinfo output -------------------------------------------
@@ -147,7 +159,13 @@
147159
# (source start file, target name, title, author,
148160
# dir menu entry, description, category)
149161
texinfo_documents = [
150-
(master_doc, 'AdafruitRTTTLLibrary', u'Adafruit RTTTL Library Documentation',
151-
author, 'AdafruitRTTTLLibrary', 'One line description of project.',
152-
'Miscellaneous'),
162+
(
163+
master_doc,
164+
"AdafruitRTTTLLibrary",
165+
u"Adafruit RTTTL Library Documentation",
166+
author,
167+
"AdafruitRTTTLLibrary",
168+
"One line description of project.",
169+
"Miscellaneous",
170+
),
153171
]

examples/rtttl_simpletest.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,14 @@
2929
enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE)
3030
enable.switch_to_output(value=True)
3131

32-
adafruit_rtttl.play(board.SPEAKER, "itchy:d=8,o=6,b=160:c,a5,4p,c,a,4p,c,a5,c,a5," + \
33-
"c,a,4p,p,c,d,e,p,e,f,g,4p,d,c,4d,f,4a#,4a,2c7")
34-
adafruit_rtttl.play(board.SPEAKER, "Phantom:d=4,o=5,b=140:c,f,c,d#.,8c#,2c#,a#4," + \
35-
"d#,8a#4,2c,c,f,c,d#.,8c#,2c#,a#4,d#.,8a#4,2c,p,c,f,g#,c.6,8a#,2a#,a#,d#.6,8a#," + \
36-
"2c6,p,c6,2f.6,8d#6,8c#6,8c6,8a#,8g#,8g,8f,2e,c#,c#.,8c,2c")
32+
adafruit_rtttl.play(
33+
board.SPEAKER,
34+
"itchy:d=8,o=6,b=160:c,a5,4p,c,a,4p,c,a5,c,a5,"
35+
+ "c,a,4p,p,c,d,e,p,e,f,g,4p,d,c,4d,f,4a#,4a,2c7",
36+
)
37+
adafruit_rtttl.play(
38+
board.SPEAKER,
39+
"Phantom:d=4,o=5,b=140:c,f,c,d#.,8c#,2c#,a#4,"
40+
+ "d#,8a#4,2c,c,f,c,d#.,8c#,2c#,a#4,d#.,8a#4,2c,p,c,f,g#,c.6,8a#,2a#,a#,d#.6,8a#,"
41+
+ "2c6,p,c6,2f.6,8d#6,8c#6,8c6,8a#,8g#,8g,8f,2e,c#,c#.,8c,2c",
42+
)

0 commit comments

Comments
 (0)