diff --git a/docs/requirements.txt b/docs/requirements.txt
index 88e6733..979f568 100644
--- a/docs/requirements.txt
+++ b/docs/requirements.txt
@@ -2,4 +2,6 @@
#
# SPDX-License-Identifier: Unlicense
-sphinx>=4.0.0
+sphinx
+sphinxcontrib-jquery
+sphinx-rtd-theme
diff --git a/examples/touchscreen_calibrator_built_in.py b/examples/touchscreen_calibrator_built_in.py
new file mode 100755
index 0000000..20482f2
--- /dev/null
+++ b/examples/touchscreen_calibrator_built_in.py
@@ -0,0 +1,199 @@
+# SPDX-FileCopyrightText: 2022 Cedar Grove Maker Studios
+# SPDX-License-Identifier: MIT
+
+"""
+touch_calibrator_built_in.py 2022-05-27 v2.2
+
+Author(s): JG for Cedar Grove Maker Studios
+
+On-screen touchscreen calibrator for built-in displays.
+
+When the test screen appears, use a stylus to swipe to the four edges
+of the visible display area. As the screen is calibrated, the small red
+square tracks the stylus tip (REPL_ONLY=False). Minimum and maximum
+calibration values will display on the screen and in the REPL. The calibration
+tuple can be copied and pasted into the calling code's touchscreen
+instantiation statement.
+
+DISPLAY_ROTATION: Display rotation value in degrees. Only values of
+None, 0, 90, 180, and 270 degrees are accepted. Defaults to None, the
+previous orientation of the display.
+
+REPL_ONLY: If False, calibration values are shown graphically on the screen
+and printed to the REPL. If True, the values are only printed to the REPL.
+Default value is False.
+"""
+
+import time
+
+import board
+import displayio
+import terminalio
+import vectorio
+from adafruit_display_text.label import Label
+from simpleio import map_range
+
+import adafruit_touchscreen
+
+# Operational parameters:
+DISPLAY_ROTATION = 0 # Specify 0, 90, 180, or 270 degrees
+REPL_ONLY = False # True to disable graphics
+
+
+class Colors:
+ """A collection of colors used for graphic objects."""
+
+ BLUE_DK = 0x000060 # Screen fill
+ RED = 0xFF0000 # Boundary
+ WHITE = 0xFFFFFF # Text
+
+
+# Instantiate the built-in display
+display = board.DISPLAY
+
+# Check rotation value and update display.
+# Always set rotation before instantiating the touchscreen.
+if DISPLAY_ROTATION is not None and DISPLAY_ROTATION in {0, 90, 180, 270}:
+ display.rotation = DISPLAY_ROTATION
+else:
+ print("Warning: invalid rotation value -- defaulting to zero")
+ display.rotation = 0
+ time.sleep(1)
+
+# Activate the display graphics unless REPL_ONLY=True
+if not REPL_ONLY:
+ display_group = displayio.Group()
+ display.root_group = display_group
+
+# Instantiate touch screen without calibration or display size parameters
+if display.rotation == 0:
+ ts = adafruit_touchscreen.Touchscreen(
+ board.TOUCH_XL,
+ board.TOUCH_XR,
+ board.TOUCH_YD,
+ board.TOUCH_YU,
+ # calibration=((5200, 59000), (5250, 59500)),
+ # size=(board.DISPLAY.width, board.DISPLAY.height),
+ )
+
+elif display.rotation == 90:
+ ts = adafruit_touchscreen.Touchscreen(
+ board.TOUCH_YU,
+ board.TOUCH_YD,
+ board.TOUCH_XL,
+ board.TOUCH_XR,
+ # calibration=((5250, 59500), (5200, 59000)),
+ # size=(board.DISPLAY.width, board.DISPLAY.height),
+ )
+
+elif display.rotation == 180:
+ ts = adafruit_touchscreen.Touchscreen(
+ board.TOUCH_XR,
+ board.TOUCH_XL,
+ board.TOUCH_YU,
+ board.TOUCH_YD,
+ # calibration=((5200, 59000), (5250, 59500)),
+ # size=(board.DISPLAY.width, board.DISPLAY.height),
+ )
+
+elif display.rotation == 270:
+ ts = adafruit_touchscreen.Touchscreen(
+ board.TOUCH_YD,
+ board.TOUCH_YU,
+ board.TOUCH_XR,
+ board.TOUCH_XL,
+ # calibration=((5250, 59500), (5200, 59000)),
+ # size=(board.DISPLAY.width, board.DISPLAY.height),
+ )
+else:
+ raise ValueError("Rotation value must be 0, 90, 180, or 270")
+
+# Define the graphic objects if REPL_ONLY = False
+if not REPL_ONLY:
+ # Define the text graphic objects
+ font_0 = terminalio.FONT
+
+ coordinates = Label(
+ font=font_0,
+ text="calib: ((x_min, x_max), (y_min, y_max))",
+ color=Colors.WHITE,
+ )
+ coordinates.anchor_point = (0.5, 0.5)
+ coordinates.anchored_position = (
+ board.DISPLAY.width // 2,
+ board.DISPLAY.height // 4,
+ )
+
+ display_rotation = Label(
+ font=font_0,
+ text="rotation: " + str(display.rotation),
+ color=Colors.WHITE,
+ )
+ display_rotation.anchor_point = (0.5, 0.5)
+ display_rotation.anchored_position = (
+ board.DISPLAY.width // 2,
+ board.DISPLAY.height // 4 - 30,
+ )
+
+ # Define graphic objects for the screen fill, boundary, and touch pen
+ target_palette = displayio.Palette(1)
+ target_palette[0] = Colors.BLUE_DK
+ screen_fill = vectorio.Rectangle(
+ pixel_shader=target_palette,
+ x=2,
+ y=2,
+ width=board.DISPLAY.width - 4,
+ height=board.DISPLAY.height - 4,
+ )
+
+ target_palette = displayio.Palette(1)
+ target_palette[0] = Colors.RED
+ boundary = vectorio.Rectangle(
+ pixel_shader=target_palette,
+ x=0,
+ y=0,
+ width=board.DISPLAY.width,
+ height=board.DISPLAY.height,
+ )
+
+ pen = vectorio.Rectangle(
+ pixel_shader=target_palette,
+ x=board.DISPLAY.width // 2,
+ y=board.DISPLAY.height // 2,
+ width=10,
+ height=10,
+ )
+
+ display_group.append(boundary)
+ display_group.append(screen_fill)
+ display_group.append(pen)
+ display_group.append(coordinates)
+ display_group.append(display_rotation)
+
+# Reset x and y values to raw touchscreen mid-point before measurement
+x_min = x_max = y_min = y_max = 65535 // 2
+
+print("Touchscreen Calibrator")
+print(" Use a stylus to swipe slightly beyond the")
+print(" four edges of the visible display area.")
+print(" ")
+print(f" display rotation: {display.rotation} degrees")
+print(" Calibration values follow:")
+print(" ")
+
+while True:
+ time.sleep(0.100)
+ touch = ts.touch_point # Check for touch
+ if touch:
+ # Remember minimum and maximum values for the calibration tuple
+ x_min = min(x_min, touch[0])
+ x_max = max(x_max, touch[0])
+ y_min = min(y_min, touch[1])
+ y_max = max(y_max, touch[1])
+
+ # Show the calibration tuple.
+ print(f"(({x_min}, {x_max}), ({y_min}, {y_max}))")
+ if not REPL_ONLY:
+ pen.x = int(map_range(touch[0], x_min, x_max, 0, board.DISPLAY.width)) - 5
+ pen.y = int(map_range(touch[1], y_min, y_max, 0, board.DISPLAY.height)) - 5
+ coordinates.text = f"calib: (({x_min}, {x_max}), ({y_min}, {y_max}))"
diff --git a/examples/touchscreen_orientation.py b/examples/touchscreen_orientation.py
index cf7c670..a3e9119 100644
--- a/examples/touchscreen_orientation.py
+++ b/examples/touchscreen_orientation.py
@@ -2,6 +2,7 @@
# SPDX-License-Identifier: MIT
import board
+
import adafruit_touchscreen
# Allign the touchscreen so that the top left corner reads as x=0, y=0
diff --git a/examples/touchscreen_simpletest.py b/examples/touchscreen_simpletest.py
index f827dd8..db2e4eb 100644
--- a/examples/touchscreen_simpletest.py
+++ b/examples/touchscreen_simpletest.py
@@ -2,6 +2,7 @@
# SPDX-License-Identifier: MIT
import board
+
import adafruit_touchscreen
# These pins are used as both analog and digital! XL, XR and YU must be analog
diff --git a/optional_requirements.txt b/optional_requirements.txt
new file mode 100644
index 0000000..d4e27c4
--- /dev/null
+++ b/optional_requirements.txt
@@ -0,0 +1,3 @@
+# SPDX-FileCopyrightText: 2022 Alec Delaney, for Adafruit Industries
+#
+# SPDX-License-Identifier: Unlicense
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 0000000..6dbbdef
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,45 @@
+# SPDX-FileCopyrightText: 2022 Alec Delaney for Adafruit Industries
+#
+# SPDX-License-Identifier: MIT
+
+[build-system]
+requires = [
+ "setuptools",
+ "wheel",
+ "setuptools-scm",
+]
+
+[project]
+name = "adafruit-circuitpython-touchscreen"
+description = "CircuitPython library for 4-wire resistive touchscreens"
+version = "0.0.0+auto.0"
+readme = "README.rst"
+authors = [
+ {name = "Adafruit Industries", email = "circuitpython@adafruit.com"}
+]
+urls = {Homepage = "https://github.com/adafruit/Adafruit_CircuitPython_Touchscreen"}
+keywords = [
+ "adafruit",
+ "blinka",
+ "circuitpython",
+ "micropython",
+ "touchscreen",
+ "resistive",
+]
+license = {text = "MIT"}
+classifiers = [
+ "Intended Audience :: Developers",
+ "Topic :: Software Development :: Libraries",
+ "Topic :: Software Development :: Embedded Systems",
+ "Topic :: System :: Hardware",
+ "License :: OSI Approved :: MIT License",
+ "Programming Language :: Python :: 3",
+]
+dynamic = ["dependencies", "optional-dependencies"]
+
+[tool.setuptools]
+py-modules = ["adafruit_touchscreen"]
+
+[tool.setuptools.dynamic]
+dependencies = {file = ["requirements.txt"]}
+optional-dependencies = {optional = {file = ["optional_requirements.txt"]}}
diff --git a/requirements.txt b/requirements.txt
index 17a850d..7a984a4 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,4 +1,4 @@
-# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
+# SPDX-FileCopyrightText: 2022 Alec Delaney, for Adafruit Industries
#
# SPDX-License-Identifier: Unlicense
diff --git a/ruff.toml b/ruff.toml
new file mode 100644
index 0000000..09747f2
--- /dev/null
+++ b/ruff.toml
@@ -0,0 +1,106 @@
+# 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
+ "PLR6301", # could-be-static no-self-use
+]
+
+[format]
+line-ending = "lf"
diff --git a/setup.py b/setup.py
deleted file mode 100644
index c0920f8..0000000
--- a/setup.py
+++ /dev/null
@@ -1,57 +0,0 @@
-# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
-#
-# SPDX-License-Identifier: MIT
-
-"""A setuptools based setup module.
-
-See:
-https://packaging.python.org/en/latest/distributing.html
-https://github.com/pypa/sampleproject
-"""
-
-from setuptools import setup, find_packages
-
-# To use a consistent encoding
-from codecs import open
-from os import path
-
-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:
- long_description = f.read()
-
-setup(
- name="adafruit-circuitpython-touchscreen",
- use_scm_version=True,
- setup_requires=["setuptools_scm"],
- description="CircuitPython library for 4-wire resistive touchscreens",
- long_description=long_description,
- long_description_content_type="text/x-rst",
- # The project's main homepage.
- url="https://github.com/adafruit/Adafruit_CircuitPython_Touchscreen",
- # Author details
- author="Adafruit Industries",
- author_email="circuitpython@adafruit.com",
- install_requires=["Adafruit-Blinka"],
- # Choose your license
- 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",
- ],
- # What does your project relate to?
- keywords="adafruit blinka circuitpython micropython touchscreen resistive",
- # You can just specify the packages manually here if your project is
- # simple. Or you can use find_packages().
- # TODO: IF LIBRARY FILES ARE A PACKAGE FOLDER,
- # CHANGE `py_modules=['...']` TO `packages=['...']`
- py_modules=["adafruit_touchscreen"],
-)
pFad - Phonifier reborn
Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy