From 2a0e60c309e56283da6beea0d2351d7d1ac91531 Mon Sep 17 00:00:00 2001 From: dherrada Date: Sun, 15 Mar 2020 17:03:57 -0400 Subject: [PATCH] Ran black, updated to pylint 2.x --- .github/workflows/build.yml | 2 +- adafruit_is31fl3731.py | 55 +++++----- docs/conf.py | 114 ++++++++++++--------- examples/is31fl3731_blink_example.py | 16 +-- examples/is31fl3731_frame_example.py | 16 +-- examples/is31fl3731_pillow_animated_gif.py | 17 +-- examples/is31fl3731_pillow_marquee.py | 12 ++- examples/is31fl3731_pillow_numbers.py | 6 +- examples/is31fl3731_simpletest.py | 6 +- examples/is31fl3731_text_example.py | 12 ++- examples/is31fl3731_wave_example.py | 35 ++++++- setup.py | 52 ++++------ 12 files changed, 200 insertions(+), 143 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fff3aa9..1dad804 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 diff --git a/adafruit_is31fl3731.py b/adafruit_is31fl3731.py index 74ace68..63894ab 100644 --- a/adafruit_is31fl3731.py +++ b/adafruit_is31fl3731.py @@ -62,12 +62,12 @@ _AUDIOSYNC_REGISTER = const(0x06) _BREATH1_REGISTER = const(0x08) _BREATH2_REGISTER = const(0x09) -_SHUTDOWN_REGISTER = const(0x0a) -_GAIN_REGISTER = const(0x0b) -_ADC_REGISTER = const(0x0c) +_SHUTDOWN_REGISTER = const(0x0A) +_GAIN_REGISTER = const(0x0B) +_ADC_REGISTER = const(0x0C) -_CONFIG_BANK = const(0x0b) -_BANK_ADDRESS = const(0xfd) +_CONFIG_BANK = const(0x0B) +_BANK_ADDRESS = const(0xFD) _PICTURE_MODE = const(0x00) _AUTOPLAY_MODE = const(0x08) @@ -77,6 +77,7 @@ _BLINK_OFFSET = const(0x12) _COLOR_OFFSET = const(0x24) + class Matrix: """ The Matrix class support the main function for driving the 16x9 matrix Display @@ -84,6 +85,7 @@ class Matrix: :param ~adafruit_bus_device.i2c_device i2c_device: the connected i2c bus i2c_device :param address: the device address; defaults to 0x74 """ + width = 16 height = 9 @@ -127,7 +129,6 @@ def _bank(self, bank=None): self._i2c_write_reg(_BANK_ADDRESS, bytearray([bank])) return None - def _register(self, bank, register, value=None): self._bank(bank) if value is None: @@ -145,7 +146,7 @@ def _init(self): for frame in range(8): self.fill(0, False, frame=frame) for col in range(18): - self._register(frame, _ENABLE_OFFSET + col, 0xff) + self._register(frame, _ENABLE_OFFSET + col, 0xFF) self.audio_sync(False) def reset(self): @@ -184,7 +185,6 @@ def autoplay(self, delay=0, loops=0, frames=0): self._register(_CONFIG_BANK, _AUTOPLAY2_REGISTER, delay % 64) self._mode(_AUTOPLAY_MODE | self._frame) - def fade(self, fade_in=None, fade_out=None, pause=0): """ Start and stop the fade feature. If both fade_in and fade_out are None (the @@ -234,8 +234,7 @@ def audio_sync(self, value=None): """ return self._register(_CONFIG_BANK, _AUDIOSYNC_REGISTER, value) - def audio_play(self, sample_rate, audio_gain=0, - agc_enable=False, agc_fast=False): + def audio_play(self, sample_rate, audio_gain=0, agc_enable=False, agc_fast=False): """Controls the audio play feature """ if sample_rate == 0: @@ -248,8 +247,11 @@ def audio_play(self, sample_rate, audio_gain=0, audio_gain //= 3 if not 0 <= audio_gain <= 7: raise ValueError("Audio gain out of range") - self._register(_CONFIG_BANK, _GAIN_REGISTER, - bool(agc_enable) << 3 | bool(agc_fast) << 4 | audio_gain) + self._register( + _CONFIG_BANK, + _GAIN_REGISTER, + bool(agc_enable) << 3 | bool(agc_fast) << 4 | audio_gain, + ) self._mode(_AUDIOPLAY_MODE) def blink(self, rate=None): @@ -280,7 +282,7 @@ def fill(self, color=None, blink=None, frame=None): if color is not None: if not 0 <= color <= 255: raise ValueError("Color out of range") - data = bytearray([color] * 25) # Extra byte at front for address. + data = bytearray([color] * 25) # Extra byte at front for address. while not self.i2c.try_lock(): pass try: @@ -290,7 +292,7 @@ def fill(self, color=None, blink=None, frame=None): finally: self.i2c.unlock() if blink is not None: - data = bool(blink) * 0xff + data = bool(blink) * 0xFF for col in range(18): self._register(frame, _BLINK_OFFSET + col, data) @@ -300,7 +302,7 @@ def pixel_addr(x, y): """ return x + y * 16 - #pylint: disable-msg=too-many-arguments + # pylint: disable-msg=too-many-arguments def pixel(self, x, y, color=None, blink=None, frame=None): """ Blink or brightness for x-, y-pixel @@ -333,7 +335,8 @@ def pixel(self, x, y, color=None, blink=None, frame=None): bits &= ~(1 << bit) self._register(frame, _BLINK_OFFSET + addr, bits) return None - #pylint: enable-msg=too-many-arguments + + # pylint: enable-msg=too-many-arguments def image(self, img, blink=None, frame=None): """Set buffer to value of Python Imaging Library image. The image should @@ -343,17 +346,20 @@ def image(self, img, blink=None, frame=None): :param blink: True to blink :param frame: the frame to set the image """ - if img.mode != 'L': - raise ValueError('Image must be in mode L.') + if img.mode != "L": + raise ValueError("Image must be in mode L.") imwidth, imheight = img.size if imwidth != self.width or imheight != self.height: - raise ValueError('Image must be same dimensions as display ({0}x{1}).' \ - .format(self.width, self.height)) + raise ValueError( + "Image must be same dimensions as display ({0}x{1}).".format( + self.width, self.height + ) + ) # Grab all the pixels from the image, faster than getpixel. pixels = img.load() # Iterate through the pixels - for x in range(self.width): # yes this double loop is slow, + for x in range(self.width): # yes this double loop is slow, for y in range(self.height): # but these displays are small! self.pixel(x, y, pixels[(x, y)], blink=blink, frame=frame) @@ -361,6 +367,7 @@ def image(self, img, blink=None, frame=None): class CharlieWing(Matrix): """Supports the Charlieplexed feather wing """ + width = 15 height = 7 @@ -378,6 +385,7 @@ def pixel_addr(x, y): class CharlieBonnet(Matrix): """Supports the Charlieplexed bonnet""" + width = 16 height = 8 @@ -385,12 +393,13 @@ class CharlieBonnet(Matrix): def pixel_addr(x, y): """Calulate the offset into the device array for x,y pixel""" if x >= 8: - return (x-6) * 16 - (y + 1) - return (x+1) * 16 + (7 - y) + return (x - 6) * 16 - (y + 1) + return (x + 1) * 16 + (7 - y) class ScrollPhatHD(Matrix): """Supports the Scroll pHAT HD by Pimoroni""" + width = 17 height = 7 diff --git a/docs/conf.py b/docs/conf.py index 2636466..766d563 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -2,7 +2,8 @@ import os import sys -sys.path.insert(0, os.path.abspath('..')) + +sys.path.insert(0, os.path.abspath("..")) # -- General configuration ------------------------------------------------ @@ -10,9 +11,9 @@ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.intersphinx', - 'sphinx.ext.viewcode', + "sphinx.ext.autodoc", + "sphinx.ext.intersphinx", + "sphinx.ext.viewcode", ] # Uncomment the below if you use native CircuitPython modules such as @@ -20,29 +21,36 @@ # autodoc module docs will fail to generate with a warning. # autodoc_mock_imports = ["micropython"] -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 IS31FL3731 Library' -copyright = u'2017 Radomir Dopieralski' -author = u'Radomir Dopieralski' +project = u"Adafruit IS31FL3731 Library" +copyright = u"2017 Radomir Dopieralski" +author = u"Radomir Dopieralski" # 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. @@ -54,7 +62,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. @@ -66,7 +74,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 @@ -80,59 +88,62 @@ # 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 = 'AdafruitIS31FL3731Librarydoc' +htmlhelp_basename = "AdafruitIS31FL3731Librarydoc" # -- 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, 'AdafruitIS31FL3731Library.tex', u'Adafruit IS31FL3731 Library Documentation', - author, 'manual'), + ( + master_doc, + "AdafruitIS31FL3731Library.tex", + u"Adafruit IS31FL3731 Library Documentation", + author, + "manual", + ), ] # -- Options for manual page output --------------------------------------- @@ -140,8 +151,13 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (master_doc, 'adafruitIS31FL3731library', u'Adafruit IS31FL3731 Library Documentation', - [author], 1) + ( + master_doc, + "adafruitIS31FL3731library", + u"Adafruit IS31FL3731 Library Documentation", + [author], + 1, + ) ] # -- Options for Texinfo output ------------------------------------------- @@ -150,7 +166,13 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'AdafruitIS31FL3731Library', u'Adafruit IS31FL3731 Library Documentation', - author, 'AdafruitIS31FL3731Library', 'One line description of project.', - 'Miscellaneous'), + ( + master_doc, + "AdafruitIS31FL3731Library", + u"Adafruit IS31FL3731 Library Documentation", + author, + "AdafruitIS31FL3731Library", + "One line description of project.", + "Miscellaneous", + ), ] diff --git a/examples/is31fl3731_blink_example.py b/examples/is31fl3731_blink_example.py index b375f62..5319879 100644 --- a/examples/is31fl3731_blink_example.py +++ b/examples/is31fl3731_blink_example.py @@ -5,27 +5,27 @@ i2c = busio.I2C(board.SCL, board.SDA) # array pattern in bits; top row-> bottom row, 8 bits in each row -an_arrow = bytearray((0x08, 0x0c, 0xfe, 0xff, 0xfe, 0x0c, 0x08, 0x00, 0x00)) +an_arrow = bytearray((0x08, 0x0C, 0xFE, 0xFF, 0xFE, 0x0C, 0x08, 0x00, 0x00)) # initial display using Feather CharlieWing LED 15 x 7 display = adafruit_is31fl3731.CharlieWing(i2c) # uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -#display = adafruit_is31fl3731.Matrix(i2c) +# display = adafruit_is31fl3731.Matrix(i2c) # uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -#display = adafruit_is31fl3731.CharlieBonnet(i2c) +# display = adafruit_is31fl3731.CharlieBonnet(i2c) # initial display using Pimoroni Scroll Phat HD LED 17 x 7 -#display = adafruit_is31fl3731.ScrollPhatHD(i2c) +# display = adafruit_is31fl3731.ScrollPhatHD(i2c) # first load the frame with the arrows; moves the an_arrow to the right in each # frame -display.sleep(True) # turn display off while updating blink bits +display.sleep(True) # turn display off while updating blink bits display.fill(0) for y in range(display.height): row = an_arrow[y] for x in range(8): - bit = 1 << (7-x) & row + bit = 1 << (7 - x) & row if bit: display.pixel(x + 4, y, 50, blink=True) -display.blink(1000) # ranges from 270 to 2159; smaller the number to faster blink -display.sleep(False) # turn display on +display.blink(1000) # ranges from 270 to 2159; smaller the number to faster blink +display.sleep(False) # turn display on diff --git a/examples/is31fl3731_frame_example.py b/examples/is31fl3731_frame_example.py index 2c626c4..b678daa 100644 --- a/examples/is31fl3731_frame_example.py +++ b/examples/is31fl3731_frame_example.py @@ -6,34 +6,34 @@ i2c = busio.I2C(board.SCL, board.SDA) # arrow pattern in bits; top row-> bottom row, 8 bits in each row -arrow = bytearray((0x08, 0x0c, 0xfe, 0xff, 0xfe, 0x0c, 0x08, 0x00, 0x00)) +arrow = bytearray((0x08, 0x0C, 0xFE, 0xFF, 0xFE, 0x0C, 0x08, 0x00, 0x00)) # initial display using Feather CharlieWing LED 15 x 7 display = adafruit_is31fl3731.CharlieWing(i2c) # uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -#display = adafruit_is31fl3731.Matrix(i2c) +# display = adafruit_is31fl3731.Matrix(i2c) # uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -#display = adafruit_is31fl3731.CharlieBonnet(i2c) +# display = adafruit_is31fl3731.CharlieBonnet(i2c) # initial display using Pimoroni Scroll Phat HD LED 17 x 7 -#display = adafruit_is31fl3731.ScrollPhatHD(i2c) +# display = adafruit_is31fl3731.ScrollPhatHD(i2c) # first load the frame with the arrows; moves the arrow to the right in each # frame -display.sleep(True) # turn display off while frames are updated +display.sleep(True) # turn display off while frames are updated for frame in range(8): display.frame(frame, show=False) display.fill(0) for y in range(display.height): row = arrow[y] for x in range(8): - bit = 1 << (7-x) & row + bit = 1 << (7 - x) & row # display the pixel into selected frame with varying intensity if bit: - display.pixel(x + frame, y, frame**2 + 1) + display.pixel(x + frame, y, frame ** 2 + 1) display.sleep(False) # now tell the display to show the frame one at time while True: for frame in range(8): display.frame(frame) - time.sleep(.1) + time.sleep(0.1) diff --git a/examples/is31fl3731_pillow_animated_gif.py b/examples/is31fl3731_pillow_animated_gif.py index f5c622b..dffbfc9 100644 --- a/examples/is31fl3731_pillow_animated_gif.py +++ b/examples/is31fl3731_pillow_animated_gif.py @@ -20,7 +20,7 @@ i2c = board.I2C() # uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -#display = adafruit_is31fl3731.Matrix(i2c) +# display = adafruit_is31fl3731.Matrix(i2c) # uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix display = adafruit_is31fl3731.CharlieBonnet(i2c) @@ -38,11 +38,11 @@ sys.exit() # Get the autoplay information from the gif -delay = image.info['duration'] +delay = image.info["duration"] # Figure out the correct loop count if "loop" in image.info: - loops = image.info['loop'] + loops = image.info["loop"] if loops > 0: loops += 1 else: @@ -60,9 +60,14 @@ # Load each frame of the gif onto the Matrix for frame in range(frame_count): image.seek(frame) - frame_image = Image.new('L', (display.width, display.height)) - frame_image.paste(image.convert("L"), (display.width // 2 - image.width // 2, - display.height // 2 - image.height // 2)) + frame_image = Image.new("L", (display.width, display.height)) + frame_image.paste( + image.convert("L"), + ( + display.width // 2 - image.width // 2, + display.height // 2 - image.height // 2, + ), + ) display.image(frame_image, frame=frame) display.autoplay(delay=delay, loops=loops) diff --git a/examples/is31fl3731_pillow_marquee.py b/examples/is31fl3731_pillow_marquee.py index 67ede1c..5b24b00 100644 --- a/examples/is31fl3731_pillow_marquee.py +++ b/examples/is31fl3731_pillow_marquee.py @@ -18,26 +18,28 @@ i2c = board.I2C() # uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -#display = adafruit_is31fl3731.Matrix(i2c) +# display = adafruit_is31fl3731.Matrix(i2c) # uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix display = adafruit_is31fl3731.CharlieBonnet(i2c) # Load a font -font = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf', 8) +font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 8) # Create an image that contains the text text_width, text_height = font.getsize(SCROLLING_TEXT) -text_image = Image.new('L', (text_width, text_height)) +text_image = Image.new("L", (text_width, text_height)) text_draw = ImageDraw.Draw(text_image) text_draw.text((0, 0), SCROLLING_TEXT, font=font, fill=BRIGHTNESS) # Create an image for the display -image = Image.new('L', (display.width, display.height)) +image = Image.new("L", (display.width, display.height)) draw = ImageDraw.Draw(image) # Load the text in each frame while True: for x in range(text_width + display.width): draw.rectangle((0, 0, display.width, display.height), outline=0, fill=0) - image.paste(text_image, (display.width - x, display.height // 2 - text_height // 2 - 1)) + image.paste( + text_image, (display.width - x, display.height // 2 - text_height // 2 - 1) + ) display.image(image) diff --git a/examples/is31fl3731_pillow_numbers.py b/examples/is31fl3731_pillow_numbers.py index e833bd4..2f298c9 100644 --- a/examples/is31fl3731_pillow_numbers.py +++ b/examples/is31fl3731_pillow_numbers.py @@ -18,18 +18,18 @@ i2c = board.I2C() # uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -#display = adafruit_is31fl3731.Matrix(i2c) +# display = adafruit_is31fl3731.Matrix(i2c) # uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix display = adafruit_is31fl3731.CharlieBonnet(i2c) display.fill(0) # 256 Color Grayscale Mode -image = Image.new('L', (display.width, display.height)) +image = Image.new("L", (display.width, display.height)) draw = ImageDraw.Draw(image) # Load a font in 2 different sizes. -font = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf', 10) +font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 10) # Load the text in each frame for x in range(8): diff --git a/examples/is31fl3731_simpletest.py b/examples/is31fl3731_simpletest.py index e887700..221c8b3 100644 --- a/examples/is31fl3731_simpletest.py +++ b/examples/is31fl3731_simpletest.py @@ -8,13 +8,13 @@ display = adafruit_is31fl3731.CharlieWing(i2c) # uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -#display = adafruit_is31fl3731.Matrix(i2c) +# display = adafruit_is31fl3731.Matrix(i2c) # uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet -#display = adafruit_is31fl3731.CharlieBonnet(i2c) +# display = adafruit_is31fl3731.CharlieBonnet(i2c) # initial display using Pimoroni Scroll Phat HD LED 17 x 7 -#display = adafruit_is31fl3731.ScrollPhatHD(i2c) +# display = adafruit_is31fl3731.ScrollPhatHD(i2c) # draw a box on the display # first draw the top and bottom edges diff --git a/examples/is31fl3731_text_example.py b/examples/is31fl3731_text_example.py index c55020d..e570176 100644 --- a/examples/is31fl3731_text_example.py +++ b/examples/is31fl3731_text_example.py @@ -7,22 +7,24 @@ i2c = busio.I2C(board.SCL, board.SDA) # initial display using Feather CharlieWing LED 15 x 7 -#display = adafruit_is31fl3731.CharlieWing(i2c) +# display = adafruit_is31fl3731.CharlieWing(i2c) # uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -#display = adafruit_is31fl3731.Matrix(i2c) +# display = adafruit_is31fl3731.Matrix(i2c) # uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix display = adafruit_is31fl3731.CharlieBonnet(i2c) # initial display using Pimoroni Scroll Phat HD LED 17 x 7 -#display = adafruit_is31fl3731.ScrollPhatHD(i2c) +# display = adafruit_is31fl3731.ScrollPhatHD(i2c) text_to_show = "Adafruit!!" # Create a framebuffer for our display buf = bytearray(32) # 2 bytes tall x 16 wide = 32 bytes (9 bits is 2 bytes) -fb = adafruit_framebuf.FrameBuffer(buf, display.width, display.height, adafruit_framebuf.MVLSB) +fb = adafruit_framebuf.FrameBuffer( + buf, display.width, display.height, adafruit_framebuf.MVLSB +) -frame = 0 # start with frame 0 +frame = 0 # start with frame 0 while True: for i in range(len(text_to_show) * 9): fb.fill(0) diff --git a/examples/is31fl3731_wave_example.py b/examples/is31fl3731_wave_example.py index edb98f4..332f0a5 100644 --- a/examples/is31fl3731_wave_example.py +++ b/examples/is31fl3731_wave_example.py @@ -4,18 +4,43 @@ i2c = busio.I2C(board.SCL, board.SDA) -sweep = [1, 2, 3, 4, 6, 8, 10, 15, 20, 30, 40, 60, 60, 40, 30, 20, 15, 10, 8, 6, 4, 3, 2, 1] +sweep = [ + 1, + 2, + 3, + 4, + 6, + 8, + 10, + 15, + 20, + 30, + 40, + 60, + 60, + 40, + 30, + 20, + 15, + 10, + 8, + 6, + 4, + 3, + 2, + 1, +] frame = 0 # initialize display using Feather CharlieWing LED 15 x 7 display = adafruit_is31fl3731.CharlieWing(i2c) # uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix -#display = adafruit_is31fl3731.Matrix(i2c) +# display = adafruit_is31fl3731.Matrix(i2c) # uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet -#display = adafruit_is31fl3731.CharlieBonnet(i2c) +# display = adafruit_is31fl3731.CharlieBonnet(i2c) # initial display using Pimoroni Scroll Phat HD LED 17 x 7 -#display = adafruit_is31fl3731.ScrollPhatHD(i2c) +# display = adafruit_is31fl3731.ScrollPhatHD(i2c) while True: for incr in range(24): @@ -25,7 +50,7 @@ # fill the display with the next frame for x in range(display.width): for y in range(display.height): - display.pixel(x, y, sweep[(x+y+incr)%24]) + display.pixel(x, y, sweep[(x + y + incr) % 24]) # show the next frame display.frame(frame, show=True) if frame: diff --git a/setup.py b/setup.py index dc3a267..6204d76 100644 --- a/setup.py +++ b/setup.py @@ -7,6 +7,7 @@ # Always prefer setuptools over distutils from setuptools import setup, find_packages + # To use a consistent encoding from codecs import open from os import path @@ -14,48 +15,39 @@ here = path.abspath(path.dirname(__file__)) # Get the long description from the README file -with open(path.join(here, 'README.rst'), encoding='utf-8') as f: +with open(path.join(here, "README.rst"), encoding="utf-8") as f: long_description = f.read() setup( - name='adafruit-circuitpython-is31fl3731', - + name="adafruit-circuitpython-is31fl3731", use_scm_version=True, - setup_requires=['setuptools_scm'], - - description='CircuitPython library for IS31FL3731 charlieplex LED matrices.', + setup_requires=["setuptools_scm"], + description="CircuitPython library for IS31FL3731 charlieplex LED matrices.", long_description=long_description, - long_description_content_type='text/x-rst', - + long_description_content_type="text/x-rst", # The project's main homepage. - url='https://github.com/adafruit/Adafruit_CircuitPython_IS31FL3731', - + url="https://github.com/adafruit/Adafruit_CircuitPython_IS31FL3731", # Author details - author='Adafruit Industries', - author_email='circuitpython@adafruit.com', - - install_requires=['Adafruit-Blinka'], - + author="Adafruit Industries", + author_email="circuitpython@adafruit.com", + install_requires=["Adafruit-Blinka"], # Choose your license - license='MIT', - + license="MIT", # See https://pypi.python.org/pypi?%3Aaction=list_classifiers classifiers=[ - 'Development Status :: 3 - Alpha', - 'Intended Audience :: Developers', - 'Topic :: Software Development :: Libraries', - 'Topic :: System :: Hardware', - 'License :: OSI Approved :: MIT License', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', + "Development Status :: 3 - Alpha", + "Intended Audience :: Developers", + "Topic :: Software Development :: Libraries", + "Topic :: System :: Hardware", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.4", + "Programming Language :: Python :: 3.5", ], - # What does your project relate to? - keywords='adafruit is31fl3731 led matrix charlieplex featherwing' - 'breakout hardware micropython circuitpython', - + keywords="adafruit is31fl3731 led matrix charlieplex featherwing" + "breakout hardware micropython circuitpython", # You can just specify the packages manually here if your project is # simple. Or you can use find_packages(). - py_modules=['adafruit_is31fl3731'], + py_modules=["adafruit_is31fl3731"], )