From ba434f1670869a8358f55a6a6f0fe17a586c5fc0 Mon Sep 17 00:00:00 2001 From: dherrada Date: Mon, 9 Mar 2020 19:27:51 -0400 Subject: [PATCH] Ran black, updated to pylint 2.x --- .github/workflows/build.yml | 2 +- adafruit_ssd1322.py | 59 ++++++++++------- docs/conf.py | 112 +++++++++++++++++++-------------- examples/ssd1322_gamma.py | 7 ++- examples/ssd1322_simpletest.py | 5 +- 5 files changed, 108 insertions(+), 77 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fff3aa9..97fe64d 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 pylint black==19.10b0 Sphinx sphinx-rtd-theme - name: Library version run: git describe --dirty --always --tags - name: PyLint diff --git a/adafruit_ssd1322.py b/adafruit_ssd1322.py index c54776d..cc93d88 100644 --- a/adafruit_ssd1322.py +++ b/adafruit_ssd1322.py @@ -49,47 +49,58 @@ __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_SSD1322.git" _INIT_SEQUENCE = ( - b"\xfd\x01\x12" # Set_Command_Lock(0x12);// Unlock Basic Commands (0x12/0x16) - b"\xae\x00" # Set_Display_On_Off(0x00);// Display Off (0x00/0x01) - b"\xb3\x01\x91" # Set_Display_Clock(0x91);// Set Clock as 80 Frames/Sec - b"\xca\x01\x3f" # Set_Multiplex_Ratio(0x3F);// 1/64 Duty (0x0F~0x3F) - b"\xa2\x01\x00" # Set_Display_Offset(0x00);// Shift Mapping RAM Counter (0x00~0x3F) - b"\xa1\x01\x00" # Set_Start_Line(0x00);// Set Mapping RAM Display Start Line (0x00~0x7F) - b"\xa0\x02\x14\x11" # Set_Remap_Format(0x14);// Set Horizontal Address Increment + b"\xfd\x01\x12" # Set_Command_Lock(0x12);// Unlock Basic Commands (0x12/0x16) + b"\xae\x00" # Set_Display_On_Off(0x00);// Display Off (0x00/0x01) + b"\xb3\x01\x91" # Set_Display_Clock(0x91);// Set Clock as 80 Frames/Sec + b"\xca\x01\x3f" # Set_Multiplex_Ratio(0x3F);// 1/64 Duty (0x0F~0x3F) + b"\xa2\x01\x00" # Set_Display_Offset(0x00);// Shift Mapping RAM Counter (0x00~0x3F) + b"\xa1\x01\x00" # Set_Start_Line(0x00);// Set Mapping RAM Display Start Line (0x00~0x7F) + b"\xa0\x02\x14\x11" # Set_Remap_Format(0x14);// Set Horizontal Address Increment # // Column Address 0 Mapped to SEG0 # // Disable Nibble Remap # // Scan from COM[N-1] to COM0 # // Disable COM Split Odd Even # // Enable Dual COM Line Mode - b"\xb5\x01\x00" # Set_GPIO(0x00);// Disable GPIO Pins Input - b"\xab\x01\x01" # Set_Function_Selection(0x01);// Enable Internal VDD Regulator - b"\xb4\x02\xa0\xfd" # Set_Display_Enhancement_A(0xA0,0xFD);// Enable External VSL - b"\xc1\x01\x9f" # Set_Contrast_Current(0x9F); // Set Segment Output Current - b"\xc7\x01\x0f" # Set_Master_Current(0x0F);// Set Scale Factor of Segment Output Current Control + b"\xb5\x01\x00" # Set_GPIO(0x00);// Disable GPIO Pins Input + b"\xab\x01\x01" # Set_Function_Selection(0x01);// Enable Internal VDD Regulator + b"\xb4\x02\xa0\xfd" # Set_Display_Enhancement_A(0xA0,0xFD);// Enable External VSL + b"\xc1\x01\x9f" # Set_Contrast_Current(0x9F); // Set Segment Output Current + b"\xc7\x01\x0f" # Set_Master_Current(0x0F);//Set Scale Factor of Segment Output Current Control b"\xb8\x0f\x00\x01\x02\x03\x04\x05\x06\x07\x08\x10\x40\x90\xa0\xb0\xb4" # Set graytable # b"\xb9\x00" # Set_Linear_Gray_Scale_Table();//set default linear gray scale table - b"\xb1\x01\xe2" # Set_Phase_Length(0xE2);// Set Phase 1 as 5 Clocks & Phase 2 as 14 Clocks + b"\xb1\x01\xe2" # Set_Phase_Length(0xE2);// Set Phase 1 as 5 Clocks & Phase 2 as 14 Clocks # Set_Display_Enhancement_B(0x20);// Enhance Driving Scheme Capability (0x00/0x20) b"\xd1\x02\xa2\x20" - b"\xbb\x01\x1f" # Set_Precharge_Voltage(0x1F);// Set Pre-Charge Voltage Level as 0.60*VCC - b"\xb6\x01\x08" # Set_Precharge_Period(0x08);// Set Second Pre-Charge Period as 8 Clocks - b"\xbe\x01\x07" # Set_VCOMH(0x07);// Set Common Pins Deselect Voltage Level as 0.86*VCC - b"\xa6\x00" # Set_Display_Mode(0x02);// Normal Display Mode (0x00/0x01/0x02/0x03) - b"\xa9\x00" # Set_Partial_Display(0x01,0x00,0x00);// Disable Partial Display - b"\xaf\x00" # Set_Display_On_Off(0x01); + b"\xbb\x01\x1f" # Set_Precharge_Voltage(0x1F);// Set Pre-Charge Voltage Level as 0.60*VCC + b"\xb6\x01\x08" # Set_Precharge_Period(0x08);// Set Second Pre-Charge Period as 8 Clocks + b"\xbe\x01\x07" # Set_VCOMH(0x07);// Set Common Pins Deselect Voltage Level as 0.86*VCC + b"\xa6\x00" # Set_Display_Mode(0x02);// Normal Display Mode (0x00/0x01/0x02/0x03) + b"\xa9\x00" # Set_Partial_Display(0x01,0x00,0x00);// Disable Partial Display + b"\xaf\x00" # Set_Display_On_Off(0x01); ) # pylint: disable=too-few-public-methods class SSD1322(displayio.Display): """SSD1322 driver""" + def __init__(self, bus, **kwargs): # Patch the init sequence for 32 pixel high displays. init_sequence = bytearray(_INIT_SEQUENCE) height = kwargs["height"] if "rotation" in kwargs and kwargs["rotation"] % 180 != 0: height = kwargs["width"] - init_sequence[10] = height - 1 # patch mux ratio - super().__init__(bus, _INIT_SEQUENCE, **kwargs, color_depth=4, grayscale=True, - set_column_command=0x15, set_row_command=0x75, - set_vertical_scroll=0xd3, write_ram_command=0x5c, - single_byte_bounds=True, reverse_pixels_in_byte=True, bytes_per_cell=2) + init_sequence[10] = height - 1 # patch mux ratio + super().__init__( + bus, + _INIT_SEQUENCE, + **kwargs, + color_depth=4, + grayscale=True, + set_column_command=0x15, + set_row_command=0x75, + set_vertical_scroll=0xD3, + write_ram_command=0x5C, + single_byte_bounds=True, + reverse_pixels_in_byte=True, + bytes_per_cell=2, + ) diff --git a/docs/conf.py b/docs/conf.py index d636da8..ee2a77a 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,10 +11,10 @@ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.intersphinx', - 'sphinx.ext.napoleon', - 'sphinx.ext.todo', + "sphinx.ext.autodoc", + "sphinx.ext.intersphinx", + "sphinx.ext.napoleon", + "sphinx.ext.todo", ] # TODO: Please Read! @@ -23,29 +24,32 @@ autodoc_mock_imports = ["displayio"] -intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)} +intersphinx_mapping = { + "python": ("https://docs.python.org/3.4", 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 SSD1322 Library' -copyright = u'2019 Scott Shawcroft' -author = u'Scott Shawcroft' +project = "Adafruit SSD1322 Library" +copyright = "2019 Scott Shawcroft" +author = "Scott Shawcroft" # 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 = "1.0" # The full version, including alpha/beta/rc tags. -release = u'1.0' +release = "1.0" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -57,7 +61,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. @@ -69,7 +73,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 @@ -84,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 = 'AdafruitSsd1322Librarydoc' +htmlhelp_basename = "AdafruitSsd1322Librarydoc" # -- 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, 'AdafruitSSD1322Library.tex', u'AdafruitSSD1322 Library Documentation', - author, 'manual'), + ( + master_doc, + "AdafruitSSD1322Library.tex", + "AdafruitSSD1322 Library Documentation", + author, + "manual", + ), ] # -- Options for manual page output --------------------------------------- @@ -144,8 +151,13 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (master_doc, 'AdafruitSSD1322library', u'Adafruit SSD1322 Library Documentation', - [author], 1) + ( + master_doc, + "AdafruitSSD1322library", + "Adafruit SSD1322 Library Documentation", + [author], + 1, + ) ] # -- Options for Texinfo output ------------------------------------------- @@ -154,7 +166,13 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'AdafruitSSD1322Library', u'Adafruit SSD1322 Library Documentation', - author, 'AdafruitSSD1322Library', 'One line description of project.', - 'Miscellaneous'), + ( + master_doc, + "AdafruitSSD1322Library", + "Adafruit SSD1322 Library Documentation", + author, + "AdafruitSSD1322Library", + "One line description of project.", + "Miscellaneous", + ), ] diff --git a/examples/ssd1322_gamma.py b/examples/ssd1322_gamma.py index 136c9e7..9031eaf 100644 --- a/examples/ssd1322_gamma.py +++ b/examples/ssd1322_gamma.py @@ -12,8 +12,9 @@ tft_dc = board.D9 tft_reset = board.D5 -display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=tft_reset, - baudrate=1000000) +display_bus = displayio.FourWire( + spi, command=tft_dc, chip_select=tft_cs, reset=tft_reset, baudrate=1000000 +) time.sleep(1) display = adafruit_ssd1322.SSD1322(display_bus, width=256, height=64, colstart=28) @@ -29,7 +30,7 @@ for i in range(dimension): if i % pixels_per_step == 0: continue - gamma_pattern[i,i] = i // pixels_per_step + gamma_pattern[i, i] = i // pixels_per_step for i in range(color_count): component = i * 255 // (color_count - 1) diff --git a/examples/ssd1322_simpletest.py b/examples/ssd1322_simpletest.py index 8a0491c..a6017d3 100644 --- a/examples/ssd1322_simpletest.py +++ b/examples/ssd1322_simpletest.py @@ -12,7 +12,8 @@ tft_dc = board.D9 tft_reset = board.D5 -display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs, - reset=tft_reset, baudrate=1000000) +display_bus = displayio.FourWire( + spi, command=tft_dc, chip_select=tft_cs, reset=tft_reset, baudrate=1000000 +) time.sleep(1) display = adafruit_ssd1322.SSD1322(display_bus, width=256, height=64, colstart=28)