From bfda33a18f8f4adefc1e748ff0c9a5b9422f88d3 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Thu, 4 Jun 2020 09:11:54 -0700 Subject: [PATCH 1/3] Ported stats to SSD1305 --- examples/ssd1305_stats.py | 103 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 examples/ssd1305_stats.py diff --git a/examples/ssd1305_stats.py b/examples/ssd1305_stats.py new file mode 100644 index 0000000..01e1ecc --- /dev/null +++ b/examples/ssd1305_stats.py @@ -0,0 +1,103 @@ +# Copyright (c) 2020 Adafruit Industries +# Author: Tony DiCola, James DeVito, Melissa LeBlanc-Williams +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + + +# This example is for use on (Linux) computers that are using CPython with +# Adafruit Blinka to support CircuitPython libraries. CircuitPython does +# not support PIL/pillow (python imaging library)! + +import time +import subprocess + +from board import SCL, SDA +import busio +from PIL import Image, ImageDraw, ImageFont +import adafruit_ssd1305 + + +# Create the I2C interface. +i2c = busio.I2C(SCL, SDA) + +# Create the SSD1305 OLED class. +# The first two parameters are the pixel width and pixel height. Change these +# to the right size for your display! +disp = adafruit_ssd1305.SSD1305_I2C(128, 32, i2c) + +# Clear display. +disp.fill(0) +disp.show() + +# Create blank image for drawing. +# Make sure to create image with mode '1' for 1-bit color. +width = disp.width +height = disp.height +image = Image.new("1", (width, height)) + +# Get drawing object to draw on image. +draw = ImageDraw.Draw(image) + +# Draw a black filled box to clear the image. +draw.rectangle((0, 0, width, height), outline=0, fill=0) + +# Draw some shapes. +# First define some constants to allow easy resizing of shapes. +padding = -2 +top = padding +bottom = height - padding +# Move left to right keeping track of the current x position for drawing shapes. +x = 0 + + +# Load default font. +font = ImageFont.load_default() + +# Alternatively load a TTF font. Make sure the .ttf font file is in the +# same directory as the python script! +# Some other nice fonts to try: http://www.dafont.com/bitmap.php +# font = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf', 9) + +while True: + + # Draw a black filled box to clear the image. + draw.rectangle((0, 0, width, height), outline=0, fill=0) + + # Shell scripts for system monitoring from here: + # https://unix.stackexchange.com/questions/119126/command-to-display-memory-usage-disk-usage-and-cpu-load + cmd = "hostname -I | cut -d' ' -f1" + IP = subprocess.check_output(cmd, shell=True).decode("utf-8") + cmd = "top -bn1 | grep load | awk '{printf \"CPU Load: %.2f\", $(NF-2)}'" + CPU = subprocess.check_output(cmd, shell=True).decode("utf-8") + cmd = "free -m | awk 'NR==2{printf \"Mem: %s/%s MB %.2f%%\", $3,$2,$3*100/$2 }'" + MemUsage = subprocess.check_output(cmd, shell=True).decode("utf-8") + cmd = 'df -h | awk \'$NF=="/"{printf "Disk: %d/%d GB %s", $3,$2,$5}\'' + Disk = subprocess.check_output(cmd, shell=True).decode("utf-8") + + # Write four lines of text. + + draw.text((x, top + 0), "IP: " + IP, font=font, fill=255) + draw.text((x, top + 8), CPU, font=font, fill=255) + draw.text((x, top + 16), MemUsage, font=font, fill=255) + draw.text((x, top + 25), Disk, font=font, fill=255) + + # Display image. + disp.image(image) + disp.show() + time.sleep(0.1) From c620e092f06a429413e7b162fc84b0a9da5e3099 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Thu, 4 Jun 2020 09:14:25 -0700 Subject: [PATCH 2/3] Black formatted --- adafruit_ssd1305.py | 157 +++++++++++++++++++++----------- docs/conf.py | 123 +++++++++++++++---------- examples/ssd1305_pillow_demo.py | 23 +++-- examples/ssd1305_simpletest.py | 2 +- setup.py | 55 +++++------ 5 files changed, 216 insertions(+), 144 deletions(-) diff --git a/adafruit_ssd1305.py b/adafruit_ssd1305.py index 2bb2b45..3e64ee5 100644 --- a/adafruit_ssd1305.py +++ b/adafruit_ssd1305.py @@ -52,6 +52,7 @@ from micropython import const from adafruit_bus_device import i2c_device, spi_device + try: import framebuf except ImportError: @@ -60,35 +61,36 @@ __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_SSD1305.git" -#pylint: disable-msg=bad-whitespace +# pylint: disable-msg=bad-whitespace # register definitions -SET_CONTRAST = const(0x81) -SET_ENTIRE_ON = const(0xa4) -SET_NORM_INV = const(0xa6) -SET_DISP = const(0xae) -SET_MEM_ADDR = const(0x20) -SET_COL_ADDR = const(0x21) -SET_PAGE_ADDR = const(0x22) +SET_CONTRAST = const(0x81) +SET_ENTIRE_ON = const(0xA4) +SET_NORM_INV = const(0xA6) +SET_DISP = const(0xAE) +SET_MEM_ADDR = const(0x20) +SET_COL_ADDR = const(0x21) +SET_PAGE_ADDR = const(0x22) SET_DISP_START_LINE = const(0x40) -SET_LUT = const(0x91) -SET_SEG_REMAP = const(0xa0) -SET_MUX_RATIO = const(0xa8) -SET_MASTER_CONFIG = const(0xad) -SET_COM_OUT_DIR = const(0xc0) -SET_COMSCAN_DEC = const(0xc8) -SET_DISP_OFFSET = const(0xd3) -SET_COM_PIN_CFG = const(0xda) -SET_DISP_CLK_DIV = const(0xd5) -SET_AREA_COLOR = const(0xd8) -SET_PRECHARGE = const(0xd9) -SET_VCOM_DESEL = const(0xdb) -SET_CHARGE_PUMP = const(0x8d) -#pylint: enable-msg=bad-whitespace +SET_LUT = const(0x91) +SET_SEG_REMAP = const(0xA0) +SET_MUX_RATIO = const(0xA8) +SET_MASTER_CONFIG = const(0xAD) +SET_COM_OUT_DIR = const(0xC0) +SET_COMSCAN_DEC = const(0xC8) +SET_DISP_OFFSET = const(0xD3) +SET_COM_PIN_CFG = const(0xDA) +SET_DISP_CLK_DIV = const(0xD5) +SET_AREA_COLOR = const(0xD8) +SET_PRECHARGE = const(0xD9) +SET_VCOM_DESEL = const(0xDB) +SET_CHARGE_PUMP = const(0x8D) +# pylint: enable-msg=bad-whitespace class _SSD1305(framebuf.FrameBuffer): """Base class for SSD1305 display driver""" - #pylint: disable-msg=too-many-arguments + + # pylint: disable-msg=too-many-arguments def __init__(self, buffer, width, height, *, external_vcc, reset): super().__init__(buffer, width, height) self.width = width @@ -101,7 +103,7 @@ def __init__(self, buffer, width, height, *, external_vcc, reset): self.pages = self.height // 8 self._column_offset = 0 if self.height == 32: - self._column_offset = 4 # hardcoded for now... + self._column_offset = 4 # hardcoded for now... # Note the subclass must initialize self.framebuf to a framebuffer. # This is necessary because the underlying data buffer is different # between I2C and SPI implementations (I2C needs an extra byte). @@ -111,26 +113,43 @@ def __init__(self, buffer, width, height, *, external_vcc, reset): def init_display(self): """Base class to initialize display""" for cmd in ( - SET_DISP | 0x00, # off - # timing and driving scheme - SET_DISP_CLK_DIV, 0x80, #SET_DISP_CLK_DIV - SET_SEG_REMAP | 0x01, # column addr 127 mapped to SEG0 SET_SEG_REMAP - SET_MUX_RATIO, self.height - 1, #SET_MUX_RATIO - SET_DISP_OFFSET, 0x00, #SET_DISP_OFFSET - SET_MASTER_CONFIG, 0x8e, #Set Master Configuration - SET_AREA_COLOR, 0x05, #Set Area Color Mode On/Off & Low Power Display Mode - SET_MEM_ADDR, 0x00, # horizontal SET_MEM_ADDR ADD - SET_DISP_START_LINE | 0x00, 0x2E, #SET_DISP_START_LINE ADD - SET_COMSCAN_DEC, #Set COM Output Scan Direction 64 to 1 - SET_COM_PIN_CFG, 0x12, #SET_COM_PIN_CFG - SET_LUT, 0x3f, 0x3f, 0x3f, 0x3f,#Current drive pulse width of BANK0, Color A, B, C - SET_CONTRAST, 0xff, # maximum SET_CONTRAST to maximum - SET_PRECHARGE, 0xd2, #SET_PRECHARGE orig: 0xd9, 0x22 if self.external_vcc else 0xf1, - SET_VCOM_DESEL, 0x34, #SET_VCOM_DESEL 0xdb, 0x30, $ 0.83* Vcc - SET_NORM_INV, # not inverted SET_NORM_INV - SET_ENTIRE_ON, # output follows RAM contents SET_ENTIRE_ON - SET_CHARGE_PUMP, 0x10 if self.external_vcc else 0x14, #SET_CHARGE_PUMP - SET_DISP | 0x01): #//--turn on oled panel + SET_DISP | 0x00, # off + # timing and driving scheme + SET_DISP_CLK_DIV, + 0x80, # SET_DISP_CLK_DIV + SET_SEG_REMAP | 0x01, # column addr 127 mapped to SEG0 SET_SEG_REMAP + SET_MUX_RATIO, + self.height - 1, # SET_MUX_RATIO + SET_DISP_OFFSET, + 0x00, # SET_DISP_OFFSET + SET_MASTER_CONFIG, + 0x8E, # Set Master Configuration + SET_AREA_COLOR, + 0x05, # Set Area Color Mode On/Off & Low Power Display Mode + SET_MEM_ADDR, + 0x00, # horizontal SET_MEM_ADDR ADD + SET_DISP_START_LINE | 0x00, + 0x2E, # SET_DISP_START_LINE ADD + SET_COMSCAN_DEC, # Set COM Output Scan Direction 64 to 1 + SET_COM_PIN_CFG, + 0x12, # SET_COM_PIN_CFG + SET_LUT, + 0x3F, + 0x3F, + 0x3F, + 0x3F, # Current drive pulse width of BANK0, Color A, B, C + SET_CONTRAST, + 0xFF, # maximum SET_CONTRAST to maximum + SET_PRECHARGE, + 0xD2, # SET_PRECHARGE orig: 0xd9, 0x22 if self.external_vcc else 0xf1, + SET_VCOM_DESEL, + 0x34, # SET_VCOM_DESEL 0xdb, 0x30, $ 0.83* Vcc + SET_NORM_INV, # not inverted SET_NORM_INV + SET_ENTIRE_ON, # output follows RAM contents SET_ENTIRE_ON + SET_CHARGE_PUMP, + 0x10 if self.external_vcc else 0x14, # SET_CHARGE_PUMP + SET_DISP | 0x01, + ): # //--turn on oled panel self.write_cmd(cmd) self.fill(0) self.show() @@ -183,6 +202,7 @@ def show(self): self.write_cmd(self.pages - 1) self.write_framebuf() + class SSD1305_I2C(_SSD1305): """ I2C class for SSD1305 @@ -195,7 +215,9 @@ class SSD1305_I2C(_SSD1305): :param reset: if needed, DigitalInOut designating reset pin """ - def __init__(self, width, height, i2c, *, addr=0x3c, external_vcc=False, reset=None): + def __init__( + self, width, height, i2c, *, addr=0x3C, external_vcc=False, reset=None + ): self.i2c_device = i2c_device.I2CDevice(i2c, addr) self.addr = addr self.temp = bytearray(2) @@ -206,12 +228,17 @@ def __init__(self, width, height, i2c, *, addr=0x3c, external_vcc=False, reset=N # buffer). self.buffer = bytearray(((height // 8) * width) + 1) self.buffer[0] = 0x40 # Set first byte of data buffer to Co=0, D/C=1 - super().__init__(memoryview(self.buffer)[1:], width, height, - external_vcc=external_vcc, reset=reset) + super().__init__( + memoryview(self.buffer)[1:], + width, + height, + external_vcc=external_vcc, + reset=reset, + ) def write_cmd(self, cmd): """Send a command to the SPI device""" - self.temp[0] = 0x80 # Co=1, D/C#=0 + self.temp[0] = 0x80 # Co=1, D/C#=0 self.temp[1] = cmd with self.i2c_device: self.i2c_device.write(self.temp) @@ -222,7 +249,8 @@ def write_framebuf(self): with self.i2c_device: self.i2c_device.write(self.buffer) -#pylint: disable-msg=too-many-arguments + +# pylint: disable-msg=too-many-arguments class SSD1305_SPI(_SSD1305): """ SPI class for SSD1305 @@ -234,18 +262,37 @@ class SSD1305_SPI(_SSD1305): :param reset: the reset pin to use, :param cs: the chip-select pin to use (sometimes labeled "SS"). """ + # pylint: disable=no-member # Disable should be reconsidered when refactor can be tested. - def __init__(self, width, height, spi, dc, reset, cs, *, - external_vcc=False, baudrate=8000000, polarity=0, phase=0): + def __init__( + self, + width, + height, + spi, + dc, + reset, + cs, + *, + external_vcc=False, + baudrate=8000000, + polarity=0, + phase=0 + ): self.rate = 10 * 1024 * 1024 dc.switch_to_output(value=0) - self.spi_device = spi_device.SPIDevice(spi, cs, baudrate=baudrate, - polarity=polarity, phase=phase) + self.spi_device = spi_device.SPIDevice( + spi, cs, baudrate=baudrate, polarity=polarity, phase=phase + ) self.dc_pin = dc self.buffer = bytearray((height // 8) * width) - super().__init__(memoryview(self.buffer), width, height, - external_vcc=external_vcc, reset=reset) + super().__init__( + memoryview(self.buffer), + width, + height, + external_vcc=external_vcc, + reset=reset, + ) def write_cmd(self, cmd): """Send a command to the SPI device""" diff --git a/docs/conf.py b/docs/conf.py index 978bf11..f782fbe 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,42 +11,54 @@ # 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! # Uncomment the below if you use native CircuitPython modules such as # digitalio, micropython and busio. List the modules you use. Without it, the # autodoc module docs will fail to generate with a warning. -autodoc_mock_imports = ["micropython", "adafruit_bus_device", "adafruit_framebuf", "busio"] +autodoc_mock_imports = [ + "micropython", + "adafruit_bus_device", + "adafruit_framebuf", + "busio", +] -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 SSD1305 Library' -copyright = u'2019 Bryan Siepert' -author = u'Bryan Siepert' +project = "Adafruit SSD1305 Library" +copyright = "2019 Bryan Siepert" +author = "Bryan Siepert" # 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 +70,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 +82,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 +97,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 = 'AdafruitSsd1305Librarydoc' +htmlhelp_basename = "AdafruitSsd1305Librarydoc" # -- 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, 'AdafruitSSD1305Library.tex', u'AdafruitSSD1305 Library Documentation', - author, 'manual'), + ( + master_doc, + "AdafruitSSD1305Library.tex", + "AdafruitSSD1305 Library Documentation", + author, + "manual", + ), ] # -- Options for manual page output --------------------------------------- @@ -144,8 +160,13 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (master_doc, 'AdafruitSSD1305library', u'Adafruit SSD1305 Library Documentation', - [author], 1) + ( + master_doc, + "AdafruitSSD1305library", + "Adafruit SSD1305 Library Documentation", + [author], + 1, + ) ] # -- Options for Texinfo output ------------------------------------------- @@ -154,7 +175,13 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'AdafruitSSD1305Library', u'Adafruit SSD1305 Library Documentation', - author, 'AdafruitSSD1305Library', 'One line description of project.', - 'Miscellaneous'), + ( + master_doc, + "AdafruitSSD1305Library", + "Adafruit SSD1305 Library Documentation", + author, + "AdafruitSSD1305Library", + "One line description of project.", + "Miscellaneous", + ), ] diff --git a/examples/ssd1305_pillow_demo.py b/examples/ssd1305_pillow_demo.py index 7619dc2..c135d44 100644 --- a/examples/ssd1305_pillow_demo.py +++ b/examples/ssd1305_pillow_demo.py @@ -18,7 +18,7 @@ # Change these # to the right size for your display! WIDTH = 128 -HEIGHT = 64 # Change to 32 if needed +HEIGHT = 64 # Change to 32 if needed BORDER = 8 # Use for SPI @@ -28,8 +28,8 @@ oled = adafruit_ssd1305.SSD1305_SPI(WIDTH, HEIGHT, spi, oled_dc, oled_reset, oled_cs) # Use for I2C. -#i2c = board.I2C() -#oled = adafruit_ssd1305.SSD1305_I2C(WIDTH, HEIGHT, i2c, addr=0x3c, reset=oled_reset) +# i2c = board.I2C() +# oled = adafruit_ssd1305.SSD1305_I2C(WIDTH, HEIGHT, i2c, addr=0x3c, reset=oled_reset) # Clear display. oled.fill(0) @@ -37,7 +37,7 @@ # Create blank image for drawing. # Make sure to create image with mode '1' for 1-bit color. -image = Image.new('1', (oled.width, oled.height)) +image = Image.new("1", (oled.width, oled.height)) # Get drawing object to draw on image. draw = ImageDraw.Draw(image) @@ -46,8 +46,11 @@ draw.rectangle((0, 0, oled.width, oled.height), outline=255, fill=255) # Draw a smaller inner rectangle -draw.rectangle((BORDER, BORDER, oled.width - BORDER - 1, oled.height - BORDER - 1), - outline=0, fill=0) +draw.rectangle( + (BORDER, BORDER, oled.width - BORDER - 1, oled.height - BORDER - 1), + outline=0, + fill=0, +) # Load default font. font = ImageFont.load_default() @@ -55,8 +58,12 @@ # Draw Some Text text = "Hello World!" (font_width, font_height) = font.getsize(text) -draw.text((oled.width//2 - font_width//2, oled.height//2 - font_height//2), - text, font=font, fill=255) +draw.text( + (oled.width // 2 - font_width // 2, oled.height // 2 - font_height // 2), + text, + font=font, + fill=255, +) # Display image oled.image(image) diff --git a/examples/ssd1305_simpletest.py b/examples/ssd1305_simpletest.py index d057e68..b7221b0 100644 --- a/examples/ssd1305_simpletest.py +++ b/examples/ssd1305_simpletest.py @@ -14,7 +14,7 @@ display = adafruit_ssd1305.SSD1305_I2C(128, 32, i2c) # Alternatively you can change the I2C address of the device with an addr parameter: -#display = adafruit_ssd1305.SSD1305_I2C(128, 32, i2c, addr=0x31) +# display = adafruit_ssd1305.SSD1305_I2C(128, 32, i2c, addr=0x31) # Clear the display. Always call show after changing pixels to make the display # update visible! diff --git a/setup.py b/setup.py index 047359c..b397e92 100644 --- a/setup.py +++ b/setup.py @@ -6,6 +6,7 @@ """ from setuptools import setup, find_packages + # To use a consistent encoding from codecs import open from os import path @@ -13,52 +14,42 @@ 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-ssd1305', - + name="adafruit-circuitpython-ssd1305", use_scm_version=True, - setup_requires=['setuptools_scm'], - - description='Framebuf (non-displayio) driver for SSD1305 displays', + setup_requires=["setuptools_scm"], + description="Framebuf (non-displayio) driver for SSD1305 displays", 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_SSD1305', - + url="https://github.com/adafruit/Adafruit_CircuitPython_SSD1305", # Author details - author='Adafruit Industries', - author_email='circuitpython@adafruit.com', - + author="Adafruit Industries", + author_email="circuitpython@adafruit.com", install_requires=[ - 'Adafruit-Blinka', - 'adafruit-circuitpython-busdevice', - 'adafruit-circuitpython-framebuf' + "Adafruit-Blinka", + "adafruit-circuitpython-busdevice", + "adafruit-circuitpython-framebuf", ], - # 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 blinka circuitpython micropython ssd1305 framebuf rpi', - + keywords="adafruit blinka circuitpython micropython ssd1305 framebuf rpi", # You can just specify the packages manually here if your project is # simple. Or you can use find_packages(). - - py_modules=['adafruit_ssd1305'], + py_modules=["adafruit_ssd1305"], ) From a08532f32cade8c54ac72fcf9bda6f34b67f5c22 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Thu, 4 Jun 2020 09:16:08 -0700 Subject: [PATCH 3/3] Fixed bad continuation error --- .pylintrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pylintrc b/.pylintrc index 039eaec..d8f0ee8 100644 --- a/.pylintrc +++ b/.pylintrc @@ -52,7 +52,7 @@ confidence= # no Warning level messages displayed, use"--disable=all --enable=classes # --disable=W" # disable=import-error,print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call -disable=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,import-error +disable=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,import-error,bad-continuation # Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option