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/bitmapsaver_screenshot_simpletest.py b/examples/bitmapsaver_screenshot_simpletest.py
index 047028f..ff1b750 100644
--- a/examples/bitmapsaver_screenshot_simpletest.py
+++ b/examples/bitmapsaver_screenshot_simpletest.py
@@ -1,24 +1,29 @@
# SPDX-FileCopyrightText: 2019 Dave Astels for Adafruit Industries
# SPDX-License-Identifier: MIT
-
"""Example of taking a screenshot."""
# pylint:disable=invalid-name
+import adafruit_sdcard
import board
-import digitalio
import busio
-import adafruit_sdcard
+import digitalio
import storage
+
from adafruit_bitmapsaver import save_pixels
+TAKE_SCREENSHOT = False # Set to True to take a screenshot
-spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
-cs = digitalio.DigitalInOut(board.SD_CS)
-sdcard = adafruit_sdcard.SDCard(spi, cs)
-vfs = storage.VfsFat(sdcard)
-storage.mount(vfs, "/sd")
+if TAKE_SCREENSHOT:
+ # Initialize SD Card & Mount Virtual File System
+ spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
+ cs = digitalio.DigitalInOut(board.SD_CS)
+ sdcard = adafruit_sdcard.SDCard(spi, cs)
+ vfs = storage.VfsFat(sdcard)
+ storage.mount(vfs, "/sd") # /sd is root dir of SD Card
-print("Taking Screenshot...")
-save_pixels("/sd/screenshot.bmp")
-print("Screenshot taken")
+ print("Taking Screenshot... ")
+ save_pixels("/sd/screenshot.bmp")
+ print("Screenshot Saved")
+ storage.umount(vfs)
+ print("SD Card Unmounted") # Do not remove SD card until unmounted
diff --git a/examples/bitmapsaver_screenshot_tft_featherwing.py b/examples/bitmapsaver_screenshot_tft_featherwing.py
new file mode 100644
index 0000000..fe187f4
--- /dev/null
+++ b/examples/bitmapsaver_screenshot_tft_featherwing.py
@@ -0,0 +1,45 @@
+# SPDX-FileCopyrightText: 2023 DJDevon3
+# SPDX-License-Identifier: MIT
+"""Screenshot on a 3.5" TFT Featherwing (integrated SD Card)"""
+# pylint:disable=invalid-name
+
+import adafruit_sdcard
+import board
+import digitalio
+import displayio
+import fourwire
+import storage
+from adafruit_hx8357 import HX8357
+
+from adafruit_bitmapsaver import save_pixels
+
+displayio.release_displays()
+
+# 3.5" TFT Featherwing is 480x320 pixels
+DISPLAY_WIDTH = 480
+DISPLAY_HEIGHT = 320
+
+TAKE_SCREENSHOT = False # Set to True to take a screenshot
+
+# Initialize SPI Bus
+spi = board.SPI()
+
+# Initialize TFT Featherwing Display
+tft_cs = board.D9
+tft_dc = board.D10
+display_bus = fourwire.FourWire(spi, command=tft_dc, chip_select=tft_cs)
+display = HX8357(display_bus, width=DISPLAY_WIDTH, height=DISPLAY_HEIGHT)
+
+if TAKE_SCREENSHOT:
+ # Initialize SD Card & Mount Virtual File System
+ cs = digitalio.DigitalInOut(board.D5)
+ sdcard = adafruit_sdcard.SDCard(spi, cs)
+ vfs = storage.VfsFat(sdcard)
+ virtual_root = "/sd" # /sd is root dir of SD Card
+ storage.mount(vfs, virtual_root)
+
+ print("Taking Screenshot... ")
+ save_pixels("/sd/screenshot.bmp", display)
+ print("Screenshot Saved")
+ storage.umount(vfs)
+ print("SD Card Unmounted") # Do not remove SD card until unmounted
diff --git a/examples/bitmapsaver_simpletest.py b/examples/bitmapsaver_simpletest.py
index 8b2258b..1b53054 100644
--- a/examples/bitmapsaver_simpletest.py
+++ b/examples/bitmapsaver_simpletest.py
@@ -1,25 +1,18 @@
# SPDX-FileCopyrightText: 2019 Dave Astels for Adafruit Industries
# SPDX-License-Identifier: MIT
-
-
"""Example of using save_bitmap"""
+# pylint:disable=invalid-name
+import adafruit_sdcard
import board
import busio
import digitalio
-from displayio import Bitmap, Palette
-import adafruit_sdcard
import storage
-from adafruit_bitmapsaver import save_pixels
+from displayio import Bitmap, Palette
-# pylint:disable=invalid-name
+from adafruit_bitmapsaver import save_pixels
-print("Setting up SD card")
-spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
-cs = digitalio.DigitalInOut(board.SD_CS)
-sdcard = adafruit_sdcard.SDCard(spi, cs)
-vfs = storage.VfsFat(sdcard)
-storage.mount(vfs, "/sd")
+TAKE_SCREENSHOT = False # Set True to take a screenshot
WHITE = 0xFFFFFF
BLACK = 0x000000
@@ -41,7 +34,7 @@
for x in range(16):
for y in range(16):
- if x == 0 or y == 0 or x == 15 or y == 15:
+ if x in {0, 15} or y in {0, 15}:
bitmap[x, y] = 1
elif x == y:
bitmap[x, y] = 4
@@ -50,5 +43,17 @@
else:
bitmap[x, y] = 0
-print("Saving bitmap")
-save_pixels("/sd/test.bmp", bitmap, palette)
+if TAKE_SCREENSHOT:
+ # Initialize SD Card & Mount Virtual File System
+ print("Setting up SD card")
+ spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
+ cs = digitalio.DigitalInOut(board.SD_CS)
+ sdcard = adafruit_sdcard.SDCard(spi, cs)
+ vfs = storage.VfsFat(sdcard)
+ storage.mount(vfs, "/sd") # /sd is root dir of SD Card
+
+ print("Taking Screenshot... ")
+ save_pixels("/sd/screenshot.bmp", bitmap, palette)
+ print("Screenshot Saved")
+ storage.umount(vfs)
+ print("SD Card Unmounted") # Do not remove SD card until unmounted
diff --git a/guide/tft_featherwing_screenshot1.bmp b/guide/tft_featherwing_screenshot1.bmp
new file mode 100644
index 0000000..401d3bc
Binary files /dev/null and b/guide/tft_featherwing_screenshot1.bmp differ
diff --git a/guide/tft_featherwing_screenshot1.bmp.license b/guide/tft_featherwing_screenshot1.bmp.license
new file mode 100644
index 0000000..f022494
--- /dev/null
+++ b/guide/tft_featherwing_screenshot1.bmp.license
@@ -0,0 +1,2 @@
+# SPDX-FileCopyrightText: 2022 DJDevon3 for Adafruit Industries
+# SPDX-License-Identifier: MIT
diff --git a/guide/tft_featherwing_screenshot2.bmp b/guide/tft_featherwing_screenshot2.bmp
new file mode 100644
index 0000000..2ad75ec
Binary files /dev/null and b/guide/tft_featherwing_screenshot2.bmp differ
diff --git a/guide/tft_featherwing_screenshot2.bmp.license b/guide/tft_featherwing_screenshot2.bmp.license
new file mode 100644
index 0000000..f022494
--- /dev/null
+++ b/guide/tft_featherwing_screenshot2.bmp.license
@@ -0,0 +1,2 @@
+# SPDX-FileCopyrightText: 2022 DJDevon3 for Adafruit Industries
+# SPDX-License-Identifier: MIT
diff --git a/mypy.ini b/mypy.ini
new file mode 100644
index 0000000..5e6c3a5
--- /dev/null
+++ b/mypy.ini
@@ -0,0 +1,8 @@
+# SPDX-FileCopyrightText: 2022 Matt Land
+#
+# SPDX-License-Identifier: Unlicense
+[mypy]
+python_version = 3.7
+disallow_untyped_defs = True
+disable_error_code = no-redef
+exclude = (examples|tests|setup.py|docs)
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..aa3e305
--- /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-bitmapsaver"
+description = "Save a displayio.Bitmap (and associated displayio.Palette) into a BMP file."
+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_BitmapSaver"}
+keywords = [
+ "adafruit",
+ "blinka",
+ "circuitpython",
+ "micropython",
+ "bitmapsaver",
+ "displayio",
+]
+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_bitmapsaver"]
+
+[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..1b887b1
--- /dev/null
+++ b/ruff.toml
@@ -0,0 +1,107 @@
+# 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
+ "PLC0415", # import outside toplevel
+]
+
+[format]
+line-ending = "lf"
diff --git a/setup.py b/setup.py
deleted file mode 100644
index 2713ac7..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-bitmapsaver",
- use_scm_version=True,
- setup_requires=["setuptools_scm"],
- description="Save a displayio.Bitmap (and associated displayio.Palette) into a BMP file.",
- long_description=long_description,
- long_description_content_type="text/x-rst",
- # The project's main homepage.
- url="https://github.com/adafruit/Adafruit_CircuitPython_BitmapSaver",
- # 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 bitmapsaver displayio",
- # 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_bitmapsaver"],
-)
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