change to ruff

This commit is contained in:
foamyguy 2025-05-14 14:20:31 +00:00
parent a67a1a41d5
commit 6664962573
28 changed files with 290 additions and 614 deletions

11
.gitattributes vendored Normal file
View file

@ -0,0 +1,11 @@
# SPDX-FileCopyrightText: 2024 Justin Myers for Adafruit Industries
#
# SPDX-License-Identifier: Unlicense
.py text eol=lf
.rst text eol=lf
.txt text eol=lf
.yaml text eol=lf
.toml text eol=lf
.license text eol=lf
.md text eol=lf

View file

@ -1,42 +1,21 @@
# SPDX-FileCopyrightText: 2020 Diego Elio Pettenò # SPDX-FileCopyrightText: 2024 Justin Myers for Adafruit Industries
# #
# SPDX-License-Identifier: Unlicense # SPDX-License-Identifier: Unlicense
repos: repos:
- repo: https://github.com/python/black
rev: 23.3.0
hooks:
- id: black
- repo: https://github.com/fsfe/reuse-tool
rev: v1.1.2
hooks:
- id: reuse
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0 rev: v4.5.0
hooks: hooks:
- id: check-yaml - id: check-yaml
- id: end-of-file-fixer - id: end-of-file-fixer
- id: trailing-whitespace - id: trailing-whitespace
- repo: https://github.com/pycqa/pylint - repo: https://github.com/astral-sh/ruff-pre-commit
rev: v2.17.4 rev: v0.3.4
hooks: hooks:
- id: pylint - id: ruff-format
name: pylint (library code) - id: ruff
types: [python] args: ["--fix"]
args: - repo: https://github.com/fsfe/reuse-tool
- --disable=consider-using-f-string,duplicate-code rev: v3.0.1
exclude: "^(docs/|examples/|tests/|setup.py$)" hooks:
- id: pylint - id: reuse
name: pylint (example code)
description: Run pylint rules on "examples/*.py" files
types: [python]
files: "^examples/"
args:
- --disable=missing-docstring,invalid-name,consider-using-f-string,duplicate-code
- id: pylint
name: pylint (test code)
description: Run pylint rules on "tests/*.py" files
types: [python]
files: "^tests/"
args:
- --disable=missing-docstring,consider-using-f-string,duplicate-code

399
.pylintrc
View file

@ -1,399 +0,0 @@
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
#
# SPDX-License-Identifier: Unlicense
[MASTER]
# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code
extension-pkg-whitelist=
# Add files or directories to the ignore-list. They should be base names, not
# paths.
ignore=CVS
# Add files or directories matching the regex patterns to the ignore-list. The
# regex matches against base names, not paths.
ignore-patterns=
# Python code to execute, usually for sys.path manipulation such as
# pygtk.require().
#init-hook=
# Use multiple processes to speed up Pylint.
jobs=1
# List of plugins (as comma separated values of python modules names) to load,
# usually to register additional checkers.
load-plugins=pylint.extensions.no_self_use
# Pickle collected data for later comparisons.
persistent=yes
# Specify a configuration file.
#rcfile=
# Allow loading of arbitrary C extensions. Extensions are imported into the
# active Python interpreter and may run arbitrary code.
unsafe-load-any-extension=no
[MESSAGES CONTROL]
# Only show warnings with the listed confidence levels. Leave empty to show
# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED
confidence=
# Disable the message, report, category or checker with the given id(s). You
# can either give multiple identifiers separated by comma (,) or put this
# option multiple times (only on the command line, not in the configuration
# file where it should appear only once).You can also use "--disable=all" to
# disable everything first and then reenable specific checks. For example, if
# you want to run only the similarities checker, you can use "--disable=all
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
# disable=import-error,raw-checker-failed,bad-inline-option,locally-disabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,deprecated-str-translate-call
disable=raw-checker-failed,bad-inline-option,locally-disabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,import-error,pointless-string-statement,unspecified-encoding
# 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
# multiple time (only on the command line, not in the configuration file where
# it should appear only once). See also the "--disable" option for examples.
enable=
[REPORTS]
# Python expression which should return a note less than 10 (10 is the highest
# note). You have access to the variables errors warning, statement which
# respectively contain the number of errors / warnings messages and the total
# number of statements analyzed. This is used by the global evaluation report
# (RP0004).
evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
# Template used to display messages. This is a python new-style format string
# used to format the message information. See doc for all details
#msg-template=
# Set the output format. Available formats are text, parseable, colorized, json
# and msvs (visual studio).You can also give a reporter class, eg
# mypackage.mymodule.MyReporterClass.
output-format=text
# Tells whether to display a full report or only the messages
reports=no
# Activate the evaluation score.
score=yes
[REFACTORING]
# Maximum number of nested blocks for function / method body
max-nested-blocks=5
[LOGGING]
# Logging modules to check that the string format arguments are in logging
# function parameter format
logging-modules=logging
[SPELLING]
# Spelling dictionary name. Available dictionaries: none. To make it working
# install python-enchant package.
spelling-dict=
# List of comma separated words that should not be checked.
spelling-ignore-words=
# A path to a file that contains private dictionary; one word per line.
spelling-private-dict-file=
# Tells whether to store unknown words to indicated private dictionary in
# --spelling-private-dict-file option instead of raising a message.
spelling-store-unknown-words=no
[MISCELLANEOUS]
# List of note tags to take in consideration, separated by a comma.
# notes=FIXME,XXX,TODO
notes=FIXME,XXX
[TYPECHECK]
# List of decorators that produce context managers, such as
# contextlib.contextmanager. Add to this list to register other decorators that
# produce valid context managers.
contextmanager-decorators=contextlib.contextmanager
# List of members which are set dynamically and missed by pylint inference
# system, and so shouldn't trigger E1101 when accessed. Python regular
# expressions are accepted.
generated-members=
# Tells whether missing members accessed in mixin class should be ignored. A
# mixin class is detected if its name ends with "mixin" (case insensitive).
ignore-mixin-members=yes
# This flag controls whether pylint should warn about no-member and similar
# checks whenever an opaque object is returned when inferring. The inference
# can return multiple potential results while evaluating a Python object, but
# some branches might not be evaluated, which results in partial inference. In
# that case, it might be useful to still emit no-member and other checks for
# the rest of the inferred objects.
ignore-on-opaque-inference=yes
# List of class names for which member attributes should not be checked (useful
# for classes with dynamically set attributes). This supports the use of
# qualified names.
ignored-classes=optparse.Values,thread._local,_thread._local
# List of module names for which member attributes should not be checked
# (useful for modules/projects where namespaces are manipulated during runtime
# and thus existing member attributes cannot be deduced by static analysis. It
# supports qualified module names, as well as Unix pattern matching.
ignored-modules=board
# Show a hint with possible names when a member name was not found. The aspect
# of finding the hint is based on edit distance.
missing-member-hint=yes
# The minimum edit distance a name should have in order to be considered a
# similar match for a missing member name.
missing-member-hint-distance=1
# The total number of similar names that should be taken in consideration when
# showing a hint for a missing member.
missing-member-max-choices=1
[VARIABLES]
# List of additional names supposed to be defined in builtins. Remember that
# you should avoid to define new builtins when possible.
additional-builtins=
# Tells whether unused global variables should be treated as a violation.
allow-global-unused-variables=yes
# List of strings which can identify a callback function by name. A callback
# name must start or end with one of those strings.
callbacks=cb_,_cb
# A regular expression matching the name of dummy variables (i.e. expectedly
# not used).
dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_
# Argument names that match this expression will be ignored. Default to name
# with leading underscore
ignored-argument-names=_.*|^ignored_|^unused_
# Tells whether we should check for unused import in __init__ files.
init-import=no
# List of qualified module names which can have objects that can redefine
# builtins.
redefining-builtins-modules=six.moves,future.builtins
[FORMAT]
# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
# expected-line-ending-format=
expected-line-ending-format=LF
# Regexp for a line that is allowed to be longer than the limit.
ignore-long-lines=^\s*(# )?<?https?://\S+>?$
# Number of spaces of indent required inside a hanging or continued line.
indent-after-paren=4
# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
# tab).
indent-string=' '
# Maximum number of characters on a single line.
max-line-length=100
# Maximum number of lines in a module
max-module-lines=1000
# Allow the body of a class to be on the same line as the declaration if body
# contains single statement.
single-line-class-stmt=no
# Allow the body of an if to be on the same line as the test if there is no
# else.
single-line-if-stmt=no
[SIMILARITIES]
# Ignore comments when computing similarities.
ignore-comments=yes
# Ignore docstrings when computing similarities.
ignore-docstrings=yes
# Ignore imports when computing similarities.
ignore-imports=yes
# Minimum lines number of a similarity.
min-similarity-lines=12
[BASIC]
# Regular expression matching correct argument names
argument-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
# Regular expression matching correct attribute names
attr-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
# Bad variable names which should always be refused, separated by a comma
bad-names=foo,bar,baz,toto,tutu,tata
# Regular expression matching correct class attribute names
class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
# Regular expression matching correct class names
# class-rgx=[A-Z_][a-zA-Z0-9]+$
class-rgx=[A-Z_][a-zA-Z0-9_]+$
# Regular expression matching correct constant names
const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$
# Minimum line length for functions/classes that require docstrings, shorter
# ones are exempt.
docstring-min-length=-1
# Regular expression matching correct function names
function-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
# Good variable names which should always be accepted, separated by a comma
# good-names=i,j,k,ex,Run,_
good-names=r,g,b,w,i,j,k,n,x,y,z,ex,ok,Run,_
# Include a hint for the correct naming format with invalid-name
include-naming-hint=no
# Regular expression matching correct inline iteration names
inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
# Regular expression matching correct method names
method-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
# Regular expression matching correct module names
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
# Colon-delimited sets of names that determine each other's naming style when
# the name regexes allow several styles.
name-group=
# Regular expression which should only match function or class names that do
# not require a docstring.
no-docstring-rgx=^_
# List of decorators that produce properties, such as abc.abstractproperty. Add
# to this list to register other decorators that produce valid properties.
property-classes=abc.abstractproperty
# Regular expression matching correct variable names
variable-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
[IMPORTS]
# Allow wildcard imports from modules that define __all__.
allow-wildcard-with-all=no
# Analyse import fallback blocks. This can be used to support both Python 2 and
# 3 compatible code, which means that the block might have code that exists
# only in one or another interpreter, leading to false positives when analysed.
analyse-fallback-blocks=no
# Deprecated modules which should not be used, separated by a comma
deprecated-modules=optparse,tkinter.tix
# Create a graph of external dependencies in the given file (report RP0402 must
# not be disabled)
ext-import-graph=
# Create a graph of every (i.e. internal and external) dependencies in the
# given file (report RP0402 must not be disabled)
import-graph=
# Create a graph of internal dependencies in the given file (report RP0402 must
# not be disabled)
int-import-graph=
# Force import order to recognize a module as part of the standard
# compatibility libraries.
known-standard-library=
# Force import order to recognize a module as part of a third party library.
known-third-party=enchant
[CLASSES]
# List of method names used to declare (i.e. assign) instance attributes.
defining-attr-methods=__init__,__new__,setUp
# List of member names, which should be excluded from the protected access
# warning.
exclude-protected=_asdict,_fields,_replace,_source,_make
# List of valid names for the first argument in a class method.
valid-classmethod-first-arg=cls
# List of valid names for the first argument in a metaclass class method.
valid-metaclass-classmethod-first-arg=mcs
[DESIGN]
# Maximum number of arguments for function / method
max-args=5
# Maximum number of attributes for a class (see R0902).
# max-attributes=7
max-attributes=11
# Maximum number of boolean expressions in a if statement
max-bool-expr=5
# Maximum number of branch for function / method body
max-branches=12
# Maximum number of locals for function / method body
max-locals=15
# Maximum number of parents for a class (see R0901).
max-parents=7
# Maximum number of public methods for a class (see R0904).
max-public-methods=20
# Maximum number of return / yield for function / method body
max-returns=6
# Maximum number of statements in function / method body
max-statements=50
# Minimum number of public methods for a class (see R0903).
min-public-methods=1
[EXCEPTIONS]
# Exceptions that will emit a warning when being caught. Defaults to
# "Exception"
overgeneral-exceptions=builtins.Exception

View file

@ -13,9 +13,9 @@ Introduction
:target: https://github.com/adafruit/Adafruit_CircuitPython_EPD/actions/ :target: https://github.com/adafruit/Adafruit_CircuitPython_EPD/actions/
:alt: Build Status :alt: Build Status
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg .. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
:target: https://github.com/psf/black :target: https://github.com/astral-sh/ruff
:alt: Code Style: Black :alt: Code Style: Ruff
This library is for using CircuitPython with e-ink displays with built in SRAM. This library is for using CircuitPython with e-ink displays with built in SRAM.

View file

@ -10,16 +10,19 @@ CircuitPython driver for Adafruit EK79686 display breakouts
""" """
import time import time
from micropython import const
import adafruit_framebuf import adafruit_framebuf
from micropython import const
from adafruit_epd.epd import Adafruit_EPD from adafruit_epd.epd import Adafruit_EPD
try: try:
"Needed for type annotations" "Needed for type annotations"
import typing # pylint: disable=unused-import import typing # pylint: disable=unused-import
from typing_extensions import Literal
from busio import SPI from busio import SPI
from digitalio import DigitalInOut from digitalio import DigitalInOut
from typing_extensions import Literal
except ImportError: except ImportError:
pass pass
@ -67,11 +70,9 @@ class Adafruit_EK79686(Adafruit_EPD):
dc_pin: DigitalInOut, dc_pin: DigitalInOut,
sramcs_pin: DigitalInOut, sramcs_pin: DigitalInOut,
rst_pin: DigitalInOut, rst_pin: DigitalInOut,
busy_pin: DigitalInOut busy_pin: DigitalInOut,
) -> None: ) -> None:
super().__init__( super().__init__(width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin)
width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
)
self._buffer1_size = int(width * height / 8) self._buffer1_size = int(width * height / 8)
self._buffer2_size = int(width * height / 8) self._buffer2_size = int(width * height / 8)
@ -158,9 +159,7 @@ class Adafruit_EK79686(Adafruit_EPD):
return self.command(_EK79686_DTM2, end=False) return self.command(_EK79686_DTM2, end=False)
raise RuntimeError("RAM index must be 0 or 1") raise RuntimeError("RAM index must be 0 or 1")
def set_ram_address( def set_ram_address(self, x: int, y: int) -> None: # noqa: PLR6301, F841
self, x: int, y: int
) -> None: # pylint: disable=unused-argument, no-self-use
"""Set the RAM address location, not used on this chipset but required by """Set the RAM address location, not used on this chipset but required by
the superclass""" the superclass"""
return # on this chip it does nothing return # on this chip it does nothing

View file

@ -11,17 +11,20 @@ CircuitPython driver for Adafruit ePaper display breakouts
# pylint: disable=ungrouped-imports # pylint: disable=ungrouped-imports
import time import time
from micropython import const
from digitalio import Direction from digitalio import Direction
from micropython import const
from adafruit_epd import mcp_sram from adafruit_epd import mcp_sram
try: try:
"""Needed for type annotations""" """Needed for type annotations"""
from typing import Any, Union, Callable, Optional from typing import Any, Callable, Optional, Union
from typing_extensions import Literal
from busio import SPI from busio import SPI
from digitalio import DigitalInOut
from circuitpython_typing.pil import Image from circuitpython_typing.pil import Image
from digitalio import DigitalInOut
from typing_extensions import Literal
except ImportError: except ImportError:
pass pass
@ -163,8 +166,7 @@ class Adafruit_EPD: # pylint: disable=too-many-instance-attributes, too-many-pu
self._cs.value = True self._cs.value = True
self.spi_device.unlock() self.spi_device.unlock()
else: elif self.sram:
if self.sram:
self.sram.cs_pin.value = True self.sram.cs_pin.value = True
self.update() self.update()
@ -177,9 +179,7 @@ class Adafruit_EPD: # pylint: disable=too-many-instance-attributes, too-many-pu
self._rst.value = True self._rst.value = True
time.sleep(0.1) time.sleep(0.1)
def command( def command(self, cmd: int, data: Optional[bytearray] = None, end: bool = True) -> int:
self, cmd: int, data: Optional[bytearray] = None, end: bool = True
) -> int:
"""Send command byte to display.""" """Send command byte to display."""
self._cs.value = True self._cs.value = True
self._dc.value = False self._dc.value = False
@ -298,21 +298,15 @@ class Adafruit_EPD: # pylint: disable=too-many-instance-attributes, too-many-pu
self._blackframebuf.fill(black_fill) self._blackframebuf.fill(black_fill)
self._colorframebuf.fill(red_fill) self._colorframebuf.fill(red_fill)
def rect( def rect(self, x: int, y: int, width: int, height: int, color: int) -> None: # pylint: disable=too-many-arguments
self, x: int, y: int, width: int, height: int, color: int
) -> None: # pylint: disable=too-many-arguments
"""draw a rectangle""" """draw a rectangle"""
self._color_dup("rect", (x, y, width, height), color) self._color_dup("rect", (x, y, width, height), color)
def fill_rect( def fill_rect(self, x: int, y: int, width: int, height: int, color: int) -> None: # pylint: disable=too-many-arguments
self, x: int, y: int, width: int, height: int, color: int
) -> None: # pylint: disable=too-many-arguments
"""fill a rectangle with the passed color""" """fill a rectangle with the passed color"""
self._color_dup("fill_rect", (x, y, width, height), color) self._color_dup("fill_rect", (x, y, width, height), color)
def line( def line(self, x_0: int, y_0: int, x_1: int, y_1: int, color: int) -> None: # pylint: disable=too-many-arguments
self, x_0: int, y_0: int, x_1: int, y_1: int, color: int
) -> None: # pylint: disable=too-many-arguments
"""Draw a line from (x_0, y_0) to (x_1, y_1) in passed color""" """Draw a line from (x_0, y_0) to (x_1, y_1) in passed color"""
self._color_dup("line", (x_0, y_0, x_1, y_1), color) self._color_dup("line", (x_0, y_0, x_1, y_1), color)
@ -324,7 +318,7 @@ class Adafruit_EPD: # pylint: disable=too-many-instance-attributes, too-many-pu
color: int, color: int,
*, *,
font_name: str = "font5x8.bin", font_name: str = "font5x8.bin",
size: int = 1 size: int = 1,
) -> None: ) -> None:
"""Write text string at location (x, y) in given color, using font file""" """Write text string at location (x, y) in given color, using font file"""
if self._blackframebuf is self._colorframebuf: # monochrome if self._blackframebuf is self._colorframebuf: # monochrome
@ -357,14 +351,14 @@ class Adafruit_EPD: # pylint: disable=too-many-instance-attributes, too-many-pu
@property @property
def width(self) -> int: def width(self) -> int:
"""The width of the display, accounting for rotation""" """The width of the display, accounting for rotation"""
if self.rotation in (0, 2): if self.rotation in {0, 2}:
return self._width return self._width
return self._height return self._height
@property @property
def height(self) -> int: def height(self) -> int:
"""The height of the display, accounting for rotation""" """The height of the display, accounting for rotation"""
if self.rotation in (0, 2): if self.rotation in {0, 2}:
return self._height return self._height
return self._width return self._width
@ -406,9 +400,7 @@ class Adafruit_EPD: # pylint: disable=too-many-instance-attributes, too-many-pu
imwidth, imheight = image.size imwidth, imheight = image.size
if imwidth != self.width or imheight != self.height: if imwidth != self.width or imheight != self.height:
raise ValueError( raise ValueError(
"Image must be same dimensions as display ({0}x{1}).".format( f"Image must be same dimensions as display ({self.width}x{self.height})."
self.width, self.height
)
) )
if self.sram: if self.sram:
raise RuntimeError("PIL image is not for use with SRAM assist") raise RuntimeError("PIL image is not for use with SRAM assist")

View file

@ -10,16 +10,19 @@ CircuitPython driver for Adafruit il0373 display breakouts
""" """
import time import time
from micropython import const
import adafruit_framebuf import adafruit_framebuf
from micropython import const
from adafruit_epd.epd import Adafruit_EPD from adafruit_epd.epd import Adafruit_EPD
try: try:
"""Needed for type annotations""" """Needed for type annotations"""
import typing # pylint: disable=unused-import import typing # pylint: disable=unused-import
from typing_extensions import Literal
from busio import SPI from busio import SPI
from digitalio import DigitalInOut from digitalio import DigitalInOut
from typing_extensions import Literal
except ImportError: except ImportError:
pass pass
@ -67,11 +70,9 @@ class Adafruit_IL0373(Adafruit_EPD):
dc_pin: DigitalInOut, dc_pin: DigitalInOut,
sramcs_pin: DigitalInOut, sramcs_pin: DigitalInOut,
rst_pin: DigitalInOut, rst_pin: DigitalInOut,
busy_pin: DigitalInOut busy_pin: DigitalInOut,
) -> None: ) -> None:
super().__init__( super().__init__(width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin)
width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
)
self._buffer1_size = int(width * height / 8) self._buffer1_size = int(width * height / 8)
self._buffer2_size = int(width * height / 8) self._buffer2_size = int(width * height / 8)
@ -155,9 +156,7 @@ class Adafruit_IL0373(Adafruit_EPD):
return self.command(_IL0373_DTM2, end=False) return self.command(_IL0373_DTM2, end=False)
raise RuntimeError("RAM index must be 0 or 1") raise RuntimeError("RAM index must be 0 or 1")
def set_ram_address( def set_ram_address(self, x: int, y: int) -> None: # noqa: PLR6301, F841
self, x: int, y: int
) -> None: # pylint: disable=unused-argument, no-self-use
"""Set the RAM address location, not used on this chipset but required by """Set the RAM address location, not used on this chipset but required by
the superclass""" the superclass"""
return # on this chip it does nothing return # on this chip it does nothing

View file

@ -10,16 +10,19 @@ CircuitPython driver for Adafruit IL0398 display breakouts
""" """
import time import time
from micropython import const
import adafruit_framebuf import adafruit_framebuf
from micropython import const
from adafruit_epd.epd import Adafruit_EPD from adafruit_epd.epd import Adafruit_EPD
try: try:
"""Needed for type annotations""" """Needed for type annotations"""
import typing # pylint: disable=unused-import import typing # pylint: disable=unused-import
from typing_extensions import Literal
from busio import SPI from busio import SPI
from digitalio import DigitalInOut from digitalio import DigitalInOut
from typing_extensions import Literal
except ImportError: except ImportError:
pass pass
@ -68,11 +71,9 @@ class Adafruit_IL0398(Adafruit_EPD):
dc_pin: DigitalInOut, dc_pin: DigitalInOut,
sramcs_pin: DigitalInOut, sramcs_pin: DigitalInOut,
rst_pin: DigitalInOut, rst_pin: DigitalInOut,
busy_pin: DigitalInOut busy_pin: DigitalInOut,
) -> None: ) -> None:
super().__init__( super().__init__(width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin)
width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
)
self._buffer1_size = int(width * height / 8) self._buffer1_size = int(width * height / 8)
self._buffer2_size = int(width * height / 8) self._buffer2_size = int(width * height / 8)
@ -155,9 +156,7 @@ class Adafruit_IL0398(Adafruit_EPD):
return self.command(_IL0398_DTM2, end=False) return self.command(_IL0398_DTM2, end=False)
raise RuntimeError("RAM index must be 0 or 1") raise RuntimeError("RAM index must be 0 or 1")
def set_ram_address( def set_ram_address(self, x: int, y: int) -> None: # noqa: PLR6301, F841
self, x: int, y: int
) -> None: # pylint: disable=unused-argument, no-self-use
"""Set the RAM address location, not used on this chipset but required by """Set the RAM address location, not used on this chipset but required by
the superclass""" the superclass"""
return # on this chip it does nothing return # on this chip it does nothing

View file

@ -10,16 +10,19 @@ CircuitPython driver for Adafruit IL91874 display breakouts
""" """
import time import time
from micropython import const
import adafruit_framebuf import adafruit_framebuf
from micropython import const
from adafruit_epd.epd import Adafruit_EPD from adafruit_epd.epd import Adafruit_EPD
try: try:
"Needed for type annotations" "Needed for type annotations"
import typing # pylint: disable=unused-import import typing # pylint: disable=unused-import
from typing_extensions import Literal
from busio import SPI from busio import SPI
from digitalio import DigitalInOut from digitalio import DigitalInOut
from typing_extensions import Literal
except ImportError: except ImportError:
pass pass
@ -52,13 +55,11 @@ _IL91874_CDI = const(0x50)
_IL91874_RESOLUTION = const(0x61) _IL91874_RESOLUTION = const(0x61)
_IL91874_VCM_DC_SETTING = const(0x82) _IL91874_VCM_DC_SETTING = const(0x82)
# pylint: disable=line-too-long _LUT_VCOMDC = b"\x00\x00\x00\x1a\x1a\x00\x00\x01\x00\n\n\x00\x00\x08\x00\x0e\x01\x0e\x01\x10\x00\n\n\x00\x00\x08\x00\x04\x10\x00\x00\x05\x00\x03\x0e\x00\x00\n\x00#\x00\x00\x00\x01" # noqa: E501
_LUT_VCOMDC = b"\x00\x00\x00\x1a\x1a\x00\x00\x01\x00\n\n\x00\x00\x08\x00\x0e\x01\x0e\x01\x10\x00\n\n\x00\x00\x08\x00\x04\x10\x00\x00\x05\x00\x03\x0e\x00\x00\n\x00#\x00\x00\x00\x01" _LUT_WW = b"\x90\x1a\x1a\x00\x00\x01@\n\n\x00\x00\x08\x84\x0e\x01\x0e\x01\x10\x80\n\n\x00\x00\x08\x00\x04\x10\x00\x00\x05\x00\x03\x0e\x00\x00\n\x00#\x00\x00\x00\x01" # noqa: E501
_LUT_WW = b"\x90\x1a\x1a\x00\x00\x01@\n\n\x00\x00\x08\x84\x0e\x01\x0e\x01\x10\x80\n\n\x00\x00\x08\x00\x04\x10\x00\x00\x05\x00\x03\x0e\x00\x00\n\x00#\x00\x00\x00\x01" _LUT_BW = b"\xa0\x1a\x1a\x00\x00\x01\x00\n\n\x00\x00\x08\x84\x0e\x01\x0e\x01\x10\x90\n\n\x00\x00\x08\xb0\x04\x10\x00\x00\x05\xb0\x03\x0e\x00\x00\n\xc0#\x00\x00\x00\x01" # noqa: E501
_LUT_BW = b"\xa0\x1a\x1a\x00\x00\x01\x00\n\n\x00\x00\x08\x84\x0e\x01\x0e\x01\x10\x90\n\n\x00\x00\x08\xb0\x04\x10\x00\x00\x05\xb0\x03\x0e\x00\x00\n\xc0#\x00\x00\x00\x01" _LUT_BB = b"\x90\x1a\x1a\x00\x00\x01@\n\n\x00\x00\x08\x84\x0e\x01\x0e\x01\x10\x80\n\n\x00\x00\x08\x00\x04\x10\x00\x00\x05\x00\x03\x0e\x00\x00\n\x00#\x00\x00\x00\x01" # noqa: E501
_LUT_BB = b"\x90\x1a\x1a\x00\x00\x01@\n\n\x00\x00\x08\x84\x0e\x01\x0e\x01\x10\x80\n\n\x00\x00\x08\x00\x04\x10\x00\x00\x05\x00\x03\x0e\x00\x00\n\x00#\x00\x00\x00\x01" _LUT_WB = b"\x90\x1a\x1a\x00\x00\x01 \n\n\x00\x00\x08\x84\x0e\x01\x0e\x01\x10\x10\n\n\x00\x00\x08\x00\x04\x10\x00\x00\x05\x00\x03\x0e\x00\x00\n\x00#\x00\x00\x00\x01" # noqa: E501
_LUT_WB = b"\x90\x1a\x1a\x00\x00\x01 \n\n\x00\x00\x08\x84\x0e\x01\x0e\x01\x10\x10\n\n\x00\x00\x08\x00\x04\x10\x00\x00\x05\x00\x03\x0e\x00\x00\n\x00#\x00\x00\x00\x01"
# pylint: enable=line-too-long
class Adafruit_IL91874(Adafruit_EPD): class Adafruit_IL91874(Adafruit_EPD):
@ -75,11 +76,9 @@ class Adafruit_IL91874(Adafruit_EPD):
dc_pin: DigitalInOut, dc_pin: DigitalInOut,
sramcs_pin: DigitalInOut, sramcs_pin: DigitalInOut,
rst_pin: DigitalInOut, rst_pin: DigitalInOut,
busy_pin: DigitalInOut busy_pin: DigitalInOut,
) -> None: ) -> None:
super().__init__( super().__init__(width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin)
width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
)
self._buffer1_size = int(width * height / 8) self._buffer1_size = int(width * height / 8)
self._buffer2_size = int(width * height / 8) self._buffer2_size = int(width * height / 8)
@ -178,9 +177,7 @@ class Adafruit_IL91874(Adafruit_EPD):
return self.command(_IL91874_DTM2, end=False) return self.command(_IL91874_DTM2, end=False)
raise RuntimeError("RAM index must be 0 or 1") raise RuntimeError("RAM index must be 0 or 1")
def set_ram_address( def set_ram_address(self, x: int, y: int) -> None: # noqa: PLR6301, F841
self, x: int, y: int
) -> None: # pylint: disable=unused-argument, no-self-use
"""Set the RAM address location, not used on this chipset but required by """Set the RAM address location, not used on this chipset but required by
the superclass""" the superclass"""
return # on this chip it does nothing return # on this chip it does nothing

View file

@ -9,15 +9,15 @@ CircuitPython driver for Microchip SRAM chips
* Author(s): Dean Miller * Author(s): Dean Miller
""" """
from micropython import const
from adafruit_bus_device import spi_device from adafruit_bus_device import spi_device
from micropython import const
try: try:
"""Needed for type annotations""" """Needed for type annotations"""
from typing import Any, List from typing import Any, List
from digitalio import DigitalInOut
from busio import SPI from busio import SPI
from digitalio import DigitalInOut
except ImportError: except ImportError:
pass pass

View file

@ -10,16 +10,19 @@ CircuitPython driver for Adafruit SSD1608 display breakouts
""" """
import time import time
from micropython import const
import adafruit_framebuf import adafruit_framebuf
from micropython import const
from adafruit_epd.epd import Adafruit_EPD from adafruit_epd.epd import Adafruit_EPD
try: try:
"""Needed for type annotations""" """Needed for type annotations"""
import typing # pylint: disable=unused-import import typing # pylint: disable=unused-import
from typing_extensions import Literal
from busio import SPI from busio import SPI
from digitalio import DigitalInOut from digitalio import DigitalInOut
from typing_extensions import Literal
except ImportError: except ImportError:
pass pass
@ -59,7 +62,9 @@ _SSD1608_SET_RAMYPOS = const(0x45)
_SSD1608_SET_RAMXCOUNT = const(0x4E) _SSD1608_SET_RAMXCOUNT = const(0x4E)
_SSD1608_SET_RAMYCOUNT = const(0x4F) _SSD1608_SET_RAMYCOUNT = const(0x4F)
_SSD1608_NOP = const(0xFF) _SSD1608_NOP = const(0xFF)
_LUT_DATA = b'\x02\x02\x01\x11\x12\x12""fiiYX\x99\x99\x88\x00\x00\x00\x00\xf8\xb4\x13Q5QQ\x19\x01\x00' # pylint: disable=line-too-long _LUT_DATA = (
b'\x02\x02\x01\x11\x12\x12""fiiYX\x99\x99\x88\x00\x00\x00\x00\xf8\xb4\x13Q5QQ\x19\x01\x00' # noqa: E501
)
class Adafruit_SSD1608(Adafruit_EPD): class Adafruit_SSD1608(Adafruit_EPD):
@ -76,11 +81,9 @@ class Adafruit_SSD1608(Adafruit_EPD):
dc_pin: DigitalInOut, dc_pin: DigitalInOut,
sramcs_pin: DigitalInOut, sramcs_pin: DigitalInOut,
rst_pin: DigitalInOut, rst_pin: DigitalInOut,
busy_pin: DigitalInOut busy_pin: DigitalInOut,
) -> None: ) -> None:
super().__init__( super().__init__(width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin)
width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
)
if height % 8 != 0: if height % 8 != 0:
height += 8 - height % 8 height += 8 - height % 8
@ -165,9 +168,7 @@ class Adafruit_SSD1608(Adafruit_EPD):
return self.command(_SSD1608_WRITE_RAM, end=False) return self.command(_SSD1608_WRITE_RAM, end=False)
raise RuntimeError("RAM index must be 0") raise RuntimeError("RAM index must be 0")
def set_ram_address( def set_ram_address(self, x: int, y: int) -> None: # noqa: PLR6301, F841
self, x: int, y: int
) -> None: # pylint: disable=unused-argument, no-self-use
"""Set the RAM address location, not used on this chipset but required by """Set the RAM address location, not used on this chipset but required by
the superclass""" the superclass"""
# Set RAM X address counter # Set RAM X address counter

View file

@ -10,16 +10,19 @@ CircuitPython driver for Adafruit SSD1675 display breakouts
""" """
import time import time
from micropython import const
import adafruit_framebuf import adafruit_framebuf
from micropython import const
from adafruit_epd.epd import Adafruit_EPD from adafruit_epd.epd import Adafruit_EPD
try: try:
"""Needed for type annotations""" """Needed for type annotations"""
import typing # pylint: disable=unused-import import typing # pylint: disable=unused-import
from typing_extensions import Literal
from busio import SPI from busio import SPI
from digitalio import DigitalInOut from digitalio import DigitalInOut
from typing_extensions import Literal
except ImportError: except ImportError:
pass pass
@ -53,7 +56,7 @@ _SSD1675_SET_RAMXCOUNT = const(0x4E)
_SSD1675_SET_RAMYCOUNT = const(0x4F) _SSD1675_SET_RAMYCOUNT = const(0x4F)
_SSD1675_SET_ANALOGBLOCK = const(0x74) _SSD1675_SET_ANALOGBLOCK = const(0x74)
_SSD1675_SET_DIGITALBLOCK = const(0x7E) _SSD1675_SET_DIGITALBLOCK = const(0x7E)
_LUT_DATA = b"\x80`@\x00\x00\x00\x00\x10` \x00\x00\x00\x00\x80`@\x00\x00\x00\x00\x10` \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x03\x00\x00\x02\t\t\x00\x00\x02\x03\x03\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x15A\xa820\n" # pylint: disable=line-too-long _LUT_DATA = b"\x80`@\x00\x00\x00\x00\x10` \x00\x00\x00\x00\x80`@\x00\x00\x00\x00\x10` \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x03\x00\x00\x02\t\t\x00\x00\x02\x03\x03\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x15A\xa820\n" # noqa: E501
class Adafruit_SSD1675(Adafruit_EPD): class Adafruit_SSD1675(Adafruit_EPD):
@ -70,11 +73,9 @@ class Adafruit_SSD1675(Adafruit_EPD):
dc_pin: DigitalInOut, dc_pin: DigitalInOut,
sramcs_pin: DigitalInOut, sramcs_pin: DigitalInOut,
rst_pin: DigitalInOut, rst_pin: DigitalInOut,
busy_pin: DigitalInOut busy_pin: DigitalInOut,
): ):
super().__init__( super().__init__(width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin)
width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
)
stride = width stride = width
if stride % 8 != 0: if stride % 8 != 0:
stride += 8 - stride % 8 stride += 8 - stride % 8
@ -189,9 +190,7 @@ class Adafruit_SSD1675(Adafruit_EPD):
return self.command(_SSD1675_WRITE_RAM2, end=False) return self.command(_SSD1675_WRITE_RAM2, end=False)
raise RuntimeError("RAM index must be 0 or 1") raise RuntimeError("RAM index must be 0 or 1")
def set_ram_address( def set_ram_address(self, x: int, y: int) -> None: # noqa: PLR6301, F841
self, x: int, y: int
) -> None: # pylint: disable=unused-argument, no-self-use
"""Set the RAM address location, not used on this chipset but required by """Set the RAM address location, not used on this chipset but required by
the superclass""" the superclass"""
self.command(_SSD1675_SET_RAMXCOUNT, bytearray([x])) self.command(_SSD1675_SET_RAMXCOUNT, bytearray([x]))

View file

@ -10,16 +10,19 @@ CircuitPython driver for Adafruit SSD1675 display breakouts
""" """
import time import time
from micropython import const
import adafruit_framebuf import adafruit_framebuf
from micropython import const
from adafruit_epd.epd import Adafruit_EPD from adafruit_epd.epd import Adafruit_EPD
try: try:
"""Needed for type annotations""" """Needed for type annotations"""
import typing # pylint: disable=unused-import import typing # pylint: disable=unused-import
from typing_extensions import Literal
from busio import SPI from busio import SPI
from digitalio import DigitalInOut from digitalio import DigitalInOut
from typing_extensions import Literal
except ImportError: except ImportError:
pass pass
@ -79,7 +82,7 @@ _SSD1675B_SET_RAMYCOUNT = const(0x4F)
_SSD1675B_SET_ANALOGBLOCK = const(0x74) _SSD1675B_SET_ANALOGBLOCK = const(0x74)
_SSD1675B_SET_DIGITALBLOCK = const(0x7E) _SSD1675B_SET_DIGITALBLOCK = const(0x7E)
_SSD1675B_NOP = const(0xFF) _SSD1675B_NOP = const(0xFF)
_LUT_DATA = b"\xa0\x90P\x00\x00\x00\x00\x00\x00\x00P\x90\xa0\x00\x00\x00\x00\x00\x00\x00\xa0\x90P\x00\x00\x00\x00\x00\x00\x00P\x90\xa0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0f\x0f\x00\x00\x00\x0f\x0f\x00\x00\x03\x0f\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x15A\xa82P,\x0b" # pylint: disable=line-too-long _LUT_DATA = b"\xa0\x90P\x00\x00\x00\x00\x00\x00\x00P\x90\xa0\x00\x00\x00\x00\x00\x00\x00\xa0\x90P\x00\x00\x00\x00\x00\x00\x00P\x90\xa0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0f\x0f\x00\x00\x00\x0f\x0f\x00\x00\x03\x0f\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x15A\xa82P,\x0b" # noqa: E501
class Adafruit_SSD1675B(Adafruit_EPD): class Adafruit_SSD1675B(Adafruit_EPD):
@ -96,11 +99,9 @@ class Adafruit_SSD1675B(Adafruit_EPD):
dc_pin: DigitalInOut, dc_pin: DigitalInOut,
sramcs_pin: DigitalInOut, sramcs_pin: DigitalInOut,
rst_pin: DigitalInOut, rst_pin: DigitalInOut,
busy_pin: DigitalInOut busy_pin: DigitalInOut,
) -> None: ) -> None:
super().__init__( super().__init__(width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin)
width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
)
stride = width stride = width
if stride % 8 != 0: if stride % 8 != 0:
stride += 8 - stride % 8 stride += 8 - stride % 8
@ -231,9 +232,7 @@ class Adafruit_SSD1675B(Adafruit_EPD):
return self.command(_SSD1675B_WRITE_RAM2, end=False) return self.command(_SSD1675B_WRITE_RAM2, end=False)
raise RuntimeError("RAM index must be 0 or 1") raise RuntimeError("RAM index must be 0 or 1")
def set_ram_address( def set_ram_address(self, x: int, y: int) -> None: # noqa: PLR6301, F841
self, x: int, y: int
) -> None: # pylint: disable=unused-argument, no-self-use
"""Set the RAM address location, not used on this chipset but required by """Set the RAM address location, not used on this chipset but required by
the superclass""" the superclass"""
self.command(_SSD1675B_SET_RAMXCOUNT, bytearray([x])) self.command(_SSD1675B_SET_RAMXCOUNT, bytearray([x]))

View file

@ -10,16 +10,19 @@ CircuitPython driver for Adafruit SSD1680 display breakouts
""" """
import time import time
from micropython import const
import adafruit_framebuf import adafruit_framebuf
from micropython import const
from adafruit_epd.epd import Adafruit_EPD from adafruit_epd.epd import Adafruit_EPD
try: try:
"""Needed for type annotations""" """Needed for type annotations"""
import typing # pylint: disable=unused-import import typing # pylint: disable=unused-import
from typing_extensions import Literal
from busio import SPI from busio import SPI
from digitalio import DigitalInOut from digitalio import DigitalInOut
from typing_extensions import Literal
except ImportError: except ImportError:
pass pass
@ -91,11 +94,9 @@ class Adafruit_SSD1680(Adafruit_EPD):
dc_pin: DigitalInOut, dc_pin: DigitalInOut,
sramcs_pin: DigitalInOut, sramcs_pin: DigitalInOut,
rst_pin: DigitalInOut, rst_pin: DigitalInOut,
busy_pin: DigitalInOut busy_pin: DigitalInOut,
) -> None: ) -> None:
super().__init__( super().__init__(width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin)
width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
)
stride = width stride = width
if stride % 8 != 0: if stride % 8 != 0:
@ -202,9 +203,7 @@ class Adafruit_SSD1680(Adafruit_EPD):
return self.command(_SSD1680_WRITE_REDRAM, end=False) return self.command(_SSD1680_WRITE_REDRAM, end=False)
raise RuntimeError("RAM index must be 0 or 1") raise RuntimeError("RAM index must be 0 or 1")
def set_ram_address( def set_ram_address(self, x: int, y: int) -> None: # noqa: PLR6301, F841
self, x: int, y: int
) -> None: # pylint: disable=unused-argument, no-self-use
"""Set the RAM address location, not used on this chipset but required by """Set the RAM address location, not used on this chipset but required by
the superclass""" the superclass"""
# Set RAM X address counter # Set RAM X address counter
@ -217,9 +216,7 @@ class Adafruit_SSD1680Z(Adafruit_SSD1680):
"""Driver for SSD1680Z ePaper display, overriding SSD1680 settings.""" """Driver for SSD1680Z ePaper display, overriding SSD1680 settings."""
# pylint: disable=too-many-arguments, useless-parent-delegation # pylint: disable=too-many-arguments, useless-parent-delegation
def __init__( def __init__(self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin):
self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
):
# Call the parent class's __init__() to initialize attributes # Call the parent class's __init__() to initialize attributes
super().__init__( super().__init__(
width, width,
@ -276,9 +273,7 @@ class Adafruit_SSD1680Z(Adafruit_SSD1680):
if not self.busy_pin: if not self.busy_pin:
time.sleep(3) # Wait for update to complete time.sleep(3) # Wait for update to complete
def set_ram_address( def set_ram_address(self, x: int, y: int) -> None: # noqa: PLR6301, F841
self, x: int, y: int
) -> None: # pylint: disable=unused-argument, no-self-use
"""Set the RAM address location, not used on this chipset but required by """Set the RAM address location, not used on this chipset but required by
the superclass""" the superclass"""
# Set RAM X address counter # Set RAM X address counter

View file

@ -10,15 +10,18 @@ CircuitPython driver for Adafruit SSD1681 display breakouts
""" """
import time import time
from micropython import const
import adafruit_framebuf import adafruit_framebuf
from micropython import const
from adafruit_epd.epd import Adafruit_EPD from adafruit_epd.epd import Adafruit_EPD
try: try:
import typing # pylint: disable=unused-import import typing # pylint: disable=unused-import
from typing_extensions import Literal
from busio import SPI from busio import SPI
from digitalio import DigitalInOut from digitalio import DigitalInOut
from typing_extensions import Literal
except ImportError: except ImportError:
pass pass
@ -90,11 +93,9 @@ class Adafruit_SSD1681(Adafruit_EPD):
dc_pin: DigitalInOut, dc_pin: DigitalInOut,
sramcs_pin: DigitalInOut, sramcs_pin: DigitalInOut,
rst_pin: DigitalInOut, rst_pin: DigitalInOut,
busy_pin: DigitalInOut busy_pin: DigitalInOut,
) -> None: ) -> None:
super().__init__( super().__init__(width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin)
width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
)
if height % 8 != 0: if height % 8 != 0:
height += 8 - height % 8 height += 8 - height % 8
@ -184,9 +185,7 @@ class Adafruit_SSD1681(Adafruit_EPD):
return self.command(_SSD1681_WRITE_REDRAM, end=False) return self.command(_SSD1681_WRITE_REDRAM, end=False)
raise RuntimeError("RAM index must be 0 or 1") raise RuntimeError("RAM index must be 0 or 1")
def set_ram_address( def set_ram_address(self, x: int, y: int) -> None: # noqa: PLR6301, F841
self, x: int, y: int
) -> None: # pylint: disable=unused-argument, no-self-use
"""Set the RAM address location, not used on this chipset but required by """Set the RAM address location, not used on this chipset but required by
the superclass""" the superclass"""
# Set RAM X address counter # Set RAM X address counter

View file

@ -10,16 +10,19 @@ CircuitPython driver for Adafruit UC8151D display breakouts
""" """
import time import time
from micropython import const
import adafruit_framebuf import adafruit_framebuf
from micropython import const
from adafruit_epd.epd import Adafruit_EPD from adafruit_epd.epd import Adafruit_EPD
try: try:
"""Needed for type annotations""" """Needed for type annotations"""
import typing # pylint: disable=unused-import import typing # pylint: disable=unused-import
from typing_extensions import Literal
from busio import SPI from busio import SPI
from digitalio import DigitalInOut from digitalio import DigitalInOut
from typing_extensions import Literal
except ImportError: except ImportError:
pass pass
@ -82,11 +85,9 @@ class Adafruit_UC8151D(Adafruit_EPD):
dc_pin: DigitalInOut, dc_pin: DigitalInOut,
sramcs_pin: DigitalInOut, sramcs_pin: DigitalInOut,
rst_pin: DigitalInOut, rst_pin: DigitalInOut,
busy_pin: DigitalInOut busy_pin: DigitalInOut,
) -> None: ) -> None:
super().__init__( super().__init__(width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin)
width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
)
self._buffer1_size = int(width * height / 8) self._buffer1_size = int(width * height / 8)
self._buffer2_size = int(width * height / 8) self._buffer2_size = int(width * height / 8)
@ -163,9 +164,7 @@ class Adafruit_UC8151D(Adafruit_EPD):
return self.command(_UC8151D_DTM2, end=False) return self.command(_UC8151D_DTM2, end=False)
raise RuntimeError("RAM index must be 0 or 1") raise RuntimeError("RAM index must be 0 or 1")
def set_ram_address( def set_ram_address(self, x: int, y: int) -> None: # noqa: PLR6301, F841
self, x: int, y: int
) -> None: # pylint: disable=unused-argument, no-self-use
"""Set the RAM address location, not used on this chipset but required by """Set the RAM address location, not used on this chipset but required by
the superclass""" the superclass"""
return # on this chip it does nothing return # on this chip it does nothing

View file

@ -4,5 +4,8 @@
.. If your library file(s) are nested in a directory (e.g. /adafruit_foo/foo.py) .. If your library file(s) are nested in a directory (e.g. /adafruit_foo/foo.py)
.. use this format as the module name: "adafruit_foo.foo" .. use this format as the module name: "adafruit_foo.foo"
API Reference
#############
.. automodule:: adafruit_epd.epd .. automodule:: adafruit_epd.epd
:members: :members:

View file

@ -1,12 +1,10 @@
# -*- coding: utf-8 -*-
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# #
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
import datetime
import os import os
import sys import sys
import datetime
sys.path.insert(0, os.path.abspath("..")) sys.path.insert(0, os.path.abspath(".."))
@ -55,9 +53,7 @@ project = "Adafruit EPD Library"
creation_year = "2018" creation_year = "2018"
current_year = str(datetime.datetime.now().year) current_year = str(datetime.datetime.now().year)
year_duration = ( year_duration = (
current_year current_year if current_year == creation_year else creation_year + " - " + current_year
if current_year == creation_year
else creation_year + " - " + current_year
) )
copyright = year_duration + " Dean Miller" copyright = year_duration + " Dean Miller"
author = "Dean Miller" author = "Dean Miller"

View file

@ -1,20 +1,20 @@
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
import digitalio
import busio
import board import board
import busio
import digitalio
from adafruit_epd.ek79686 import Adafruit_EK79686 # pylint: disable=unused-import
from adafruit_epd.epd import Adafruit_EPD from adafruit_epd.epd import Adafruit_EPD
from adafruit_epd.il0373 import Adafruit_IL0373 from adafruit_epd.il0373 import Adafruit_IL0373
from adafruit_epd.il91874 import Adafruit_IL91874 # pylint: disable=unused-import
from adafruit_epd.il0398 import Adafruit_IL0398 # pylint: disable=unused-import from adafruit_epd.il0398 import Adafruit_IL0398 # pylint: disable=unused-import
from adafruit_epd.il91874 import Adafruit_IL91874 # pylint: disable=unused-import
from adafruit_epd.ssd1608 import Adafruit_SSD1608 # pylint: disable=unused-import from adafruit_epd.ssd1608 import Adafruit_SSD1608 # pylint: disable=unused-import
from adafruit_epd.ssd1675 import Adafruit_SSD1675 # pylint: disable=unused-import from adafruit_epd.ssd1675 import Adafruit_SSD1675 # pylint: disable=unused-import
from adafruit_epd.ssd1680 import Adafruit_SSD1680 # pylint: disable=unused-import from adafruit_epd.ssd1680 import Adafruit_SSD1680 # pylint: disable=unused-import
from adafruit_epd.ssd1681 import Adafruit_SSD1681 # pylint: disable=unused-import from adafruit_epd.ssd1681 import Adafruit_SSD1681 # pylint: disable=unused-import
from adafruit_epd.uc8151d import Adafruit_UC8151D # pylint: disable=unused-import from adafruit_epd.uc8151d import Adafruit_UC8151D # pylint: disable=unused-import
from adafruit_epd.ek79686 import Adafruit_EK79686 # pylint: disable=unused-import
# create the spi device and pins we will need # create the spi device and pins we will need
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO) spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)

View file

@ -1,24 +1,22 @@
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
import digitalio
import busio
import board import board
import busio
import digitalio
from PIL import Image, ImageDraw, ImageFont
from PIL import Image from adafruit_epd.ek79686 import Adafruit_EK79686 # pylint: disable=unused-import
from PIL import ImageDraw
from PIL import ImageFont
from adafruit_epd.epd import Adafruit_EPD from adafruit_epd.epd import Adafruit_EPD
from adafruit_epd.il0373 import Adafruit_IL0373 # pylint: disable=unused-import from adafruit_epd.il0373 import Adafruit_IL0373 # pylint: disable=unused-import
from adafruit_epd.il91874 import Adafruit_IL91874 # pylint: disable=unused-import
from adafruit_epd.il0398 import Adafruit_IL0398 # pylint: disable=unused-import from adafruit_epd.il0398 import Adafruit_IL0398 # pylint: disable=unused-import
from adafruit_epd.il91874 import Adafruit_IL91874 # pylint: disable=unused-import
from adafruit_epd.ssd1608 import Adafruit_SSD1608 # pylint: disable=unused-import from adafruit_epd.ssd1608 import Adafruit_SSD1608 # pylint: disable=unused-import
from adafruit_epd.ssd1675 import Adafruit_SSD1675 # pylint: disable=unused-import from adafruit_epd.ssd1675 import Adafruit_SSD1675 # pylint: disable=unused-import
from adafruit_epd.ssd1675b import Adafruit_SSD1675B # pylint: disable=unused-import from adafruit_epd.ssd1675b import Adafruit_SSD1675B # pylint: disable=unused-import
from adafruit_epd.ssd1680 import Adafruit_SSD1680 # pylint: disable=unused-import from adafruit_epd.ssd1680 import Adafruit_SSD1680 # pylint: disable=unused-import
from adafruit_epd.ssd1681 import Adafruit_SSD1681 # pylint: disable=unused-import from adafruit_epd.ssd1681 import Adafruit_SSD1681 # pylint: disable=unused-import
from adafruit_epd.uc8151d import Adafruit_UC8151D # pylint: disable=unused-import from adafruit_epd.uc8151d import Adafruit_UC8151D # pylint: disable=unused-import
from adafruit_epd.ek79686 import Adafruit_EK79686 # pylint: disable=unused-import
# create the spi device and pins we will need # create the spi device and pins we will need
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO) spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)

View file

@ -2,13 +2,12 @@
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
import time import time
import busio
import board
from digitalio import DigitalInOut, Direction
from PIL import Image import board
from PIL import ImageDraw import busio
from PIL import ImageFont from digitalio import DigitalInOut, Direction
from PIL import Image, ImageDraw, ImageFont
from adafruit_epd.epd import Adafruit_EPD from adafruit_epd.epd import Adafruit_EPD
from adafruit_epd.ssd1675b import Adafruit_SSD1675B # pylint: disable=unused-import from adafruit_epd.ssd1675b import Adafruit_SSD1675B # pylint: disable=unused-import

View file

@ -6,19 +6,20 @@ ePaper Display Shapes and Text demo using the Pillow Library.
""" """
import digitalio
import busio
import board import board
import busio
import digitalio
from PIL import Image, ImageDraw, ImageFont from PIL import Image, ImageDraw, ImageFont
from adafruit_epd.ek79686 import Adafruit_EK79686 # pylint: disable=unused-import
from adafruit_epd.il0373 import Adafruit_IL0373 from adafruit_epd.il0373 import Adafruit_IL0373
from adafruit_epd.il91874 import Adafruit_IL91874 # pylint: disable=unused-import
from adafruit_epd.il0398 import Adafruit_IL0398 # pylint: disable=unused-import from adafruit_epd.il0398 import Adafruit_IL0398 # pylint: disable=unused-import
from adafruit_epd.il91874 import Adafruit_IL91874 # pylint: disable=unused-import
from adafruit_epd.ssd1608 import Adafruit_SSD1608 # pylint: disable=unused-import from adafruit_epd.ssd1608 import Adafruit_SSD1608 # pylint: disable=unused-import
from adafruit_epd.ssd1675 import Adafruit_SSD1675 # pylint: disable=unused-import from adafruit_epd.ssd1675 import Adafruit_SSD1675 # pylint: disable=unused-import
from adafruit_epd.ssd1680 import Adafruit_SSD1680 # pylint: disable=unused-import from adafruit_epd.ssd1680 import Adafruit_SSD1680 # pylint: disable=unused-import
from adafruit_epd.ssd1681 import Adafruit_SSD1681 # pylint: disable=unused-import from adafruit_epd.ssd1681 import Adafruit_SSD1681 # pylint: disable=unused-import
from adafruit_epd.uc8151d import Adafruit_UC8151D # pylint: disable=unused-import from adafruit_epd.uc8151d import Adafruit_UC8151D # pylint: disable=unused-import
from adafruit_epd.ek79686 import Adafruit_EK79686 # pylint: disable=unused-import
# First define some color constants # First define some color constants
WHITE = (0xFF, 0xFF, 0xFF) WHITE = (0xFF, 0xFF, 0xFF)

View file

@ -8,20 +8,20 @@ https://learn.adafruit.com/adafruit-eink-display-breakouts/python-code
""" """
import digitalio
import busio
import board import board
import busio
import digitalio
from PIL import Image from PIL import Image
from adafruit_epd.ek79686 import Adafruit_EK79686 # pylint: disable=unused-import
from adafruit_epd.il0373 import Adafruit_IL0373 from adafruit_epd.il0373 import Adafruit_IL0373
from adafruit_epd.il91874 import Adafruit_IL91874 # pylint: disable=unused-import
from adafruit_epd.il0398 import Adafruit_IL0398 # pylint: disable=unused-import from adafruit_epd.il0398 import Adafruit_IL0398 # pylint: disable=unused-import
from adafruit_epd.il91874 import Adafruit_IL91874 # pylint: disable=unused-import
from adafruit_epd.ssd1608 import Adafruit_SSD1608 # pylint: disable=unused-import from adafruit_epd.ssd1608 import Adafruit_SSD1608 # pylint: disable=unused-import
from adafruit_epd.ssd1675 import Adafruit_SSD1675 # pylint: disable=unused-import from adafruit_epd.ssd1675 import Adafruit_SSD1675 # pylint: disable=unused-import
from adafruit_epd.ssd1680 import Adafruit_SSD1680 # pylint: disable=unused-import from adafruit_epd.ssd1680 import Adafruit_SSD1680 # pylint: disable=unused-import
from adafruit_epd.ssd1681 import Adafruit_SSD1681 # pylint: disable=unused-import from adafruit_epd.ssd1681 import Adafruit_SSD1681 # pylint: disable=unused-import
from adafruit_epd.uc8151d import Adafruit_UC8151D # pylint: disable=unused-import from adafruit_epd.uc8151d import Adafruit_UC8151D # pylint: disable=unused-import
from adafruit_epd.ek79686 import Adafruit_EK79686 # pylint: disable=unused-import
# create the spi device and pins we will need # create the spi device and pins we will need
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO) spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)

View file

@ -3,10 +3,12 @@
# EInk Shield test # EInk Shield test
import time import time
import digitalio
import busio
import board import board
import busio
import digitalio
from analogio import AnalogIn from analogio import AnalogIn
from adafruit_epd.epd import Adafruit_EPD from adafruit_epd.epd import Adafruit_EPD
from adafruit_epd.il91874 import Adafruit_IL91874 from adafruit_epd.il91874 import Adafruit_IL91874

View file

@ -1,19 +1,20 @@
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
import digitalio
import busio
import board import board
import busio
import digitalio
from adafruit_epd.ek79686 import Adafruit_EK79686 # pylint: disable=unused-import
from adafruit_epd.epd import Adafruit_EPD from adafruit_epd.epd import Adafruit_EPD
from adafruit_epd.il0373 import Adafruit_IL0373 from adafruit_epd.il0373 import Adafruit_IL0373
from adafruit_epd.il91874 import Adafruit_IL91874 # pylint: disable=unused-import
from adafruit_epd.il0398 import Adafruit_IL0398 # pylint: disable=unused-import from adafruit_epd.il0398 import Adafruit_IL0398 # pylint: disable=unused-import
from adafruit_epd.il91874 import Adafruit_IL91874 # pylint: disable=unused-import
from adafruit_epd.ssd1608 import Adafruit_SSD1608 # pylint: disable=unused-import from adafruit_epd.ssd1608 import Adafruit_SSD1608 # pylint: disable=unused-import
from adafruit_epd.ssd1675 import Adafruit_SSD1675 # pylint: disable=unused-import from adafruit_epd.ssd1675 import Adafruit_SSD1675 # pylint: disable=unused-import
from adafruit_epd.ssd1680 import Adafruit_SSD1680 # pylint: disable=unused-import from adafruit_epd.ssd1680 import Adafruit_SSD1680 # pylint: disable=unused-import
from adafruit_epd.ssd1681 import Adafruit_SSD1681 # pylint: disable=unused-import from adafruit_epd.ssd1681 import Adafruit_SSD1681 # pylint: disable=unused-import
from adafruit_epd.uc8151d import Adafruit_UC8151D # pylint: disable=unused-import from adafruit_epd.uc8151d import Adafruit_UC8151D # pylint: disable=unused-import
from adafruit_epd.ek79686 import Adafruit_EK79686 # pylint: disable=unused-import
# create the spi device and pins we will need # create the spi device and pins we will need
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO) spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)

View file

@ -2,9 +2,11 @@
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
import time import time
import digitalio
import busio
import board import board
import busio
import digitalio
from adafruit_epd.epd import Adafruit_EPD from adafruit_epd.epd import Adafruit_EPD
from adafruit_epd.ssd1680 import Adafruit_SSD1680 from adafruit_epd.ssd1680 import Adafruit_SSD1680

View file

@ -2,12 +2,12 @@
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
import time import time
import digitalio
import busio
import board import board
from PIL import Image import busio
from PIL import ImageDraw import digitalio
from PIL import ImageFont from PIL import Image, ImageDraw, ImageFont
from adafruit_epd.epd import Adafruit_EPD from adafruit_epd.epd import Adafruit_EPD
from adafruit_epd.ssd1680 import Adafruit_SSD1680 from adafruit_epd.ssd1680 import Adafruit_SSD1680

105
ruff.toml Normal file
View file

@ -0,0 +1,105 @@
# SPDX-FileCopyrightText: 2024 Tim Cocks for Adafruit Industries
#
# SPDX-License-Identifier: MIT
target-version = "py38"
line-length = 100
[lint]
preview = true
select = ["I", "PL", "UP"]
extend-select = [
"D419", # empty-docstring
"E501", # line-too-long
"W291", # trailing-whitespace
"PLC0414", # useless-import-alias
"PLC2401", # non-ascii-name
"PLC2801", # unnecessary-dunder-call
"PLC3002", # unnecessary-direct-lambda-call
"E999", # syntax-error
"PLE0101", # return-in-init
"F706", # return-outside-function
"F704", # yield-outside-function
"PLE0116", # continue-in-finally
"PLE0117", # nonlocal-without-binding
"PLE0241", # duplicate-bases
"PLE0302", # unexpected-special-method-signature
"PLE0604", # invalid-all-object
"PLE0605", # invalid-all-format
"PLE0643", # potential-index-error
"PLE0704", # misplaced-bare-raise
"PLE1141", # dict-iter-missing-items
"PLE1142", # await-outside-async
"PLE1205", # logging-too-many-args
"PLE1206", # logging-too-few-args
"PLE1307", # bad-string-format-type
"PLE1310", # bad-str-strip-call
"PLE1507", # invalid-envvar-value
"PLE2502", # bidirectional-unicode
"PLE2510", # invalid-character-backspace
"PLE2512", # invalid-character-sub
"PLE2513", # invalid-character-esc
"PLE2514", # invalid-character-nul
"PLE2515", # invalid-character-zero-width-space
"PLR0124", # comparison-with-itself
"PLR0202", # no-classmethod-decorator
"PLR0203", # no-staticmethod-decorator
"UP004", # useless-object-inheritance
"PLR0206", # property-with-parameters
"PLR0904", # too-many-public-methods
"PLR0911", # too-many-return-statements
"PLR0912", # too-many-branches
"PLR0913", # too-many-arguments
"PLR0914", # too-many-locals
"PLR0915", # too-many-statements
"PLR0916", # too-many-boolean-expressions
"PLR1702", # too-many-nested-blocks
"PLR1704", # redefined-argument-from-local
"PLR1711", # useless-return
"C416", # unnecessary-comprehension
"PLR1733", # unnecessary-dict-index-lookup
"PLR1736", # unnecessary-list-index-lookup
# ruff reports this rule is unstable
#"PLR6301", # no-self-use
"PLW0108", # unnecessary-lambda
"PLW0120", # useless-else-on-loop
"PLW0127", # self-assigning-variable
"PLW0129", # assert-on-string-literal
"B033", # duplicate-value
"PLW0131", # named-expr-without-context
"PLW0245", # super-without-brackets
"PLW0406", # import-self
"PLW0602", # global-variable-not-assigned
"PLW0603", # global-statement
"PLW0604", # global-at-module-level
# fails on the try: import typing used by libraries
#"F401", # unused-import
"F841", # unused-variable
"E722", # bare-except
"PLW0711", # binary-op-exception
"PLW1501", # bad-open-mode
"PLW1508", # invalid-envvar-default
"PLW1509", # subprocess-popen-preexec-fn
"PLW2101", # useless-with-lock
"PLW3301", # nested-min-max
]
ignore = [
"PLR2004", # magic-value-comparison
"UP030", # format literals
"PLW1514", # unspecified-encoding
"PLR0913", # too-many-arguments
"PLR0915", # too-many-statements
"PLR0917", # too-many-positional-arguments
"PLR0904", # too-many-public-methods
"PLR0912", # too-many-branches
"PLR0916", # too-many-boolean-expressions
]
[format]
line-ending = "lf"