diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fbda35c..6cd77e3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ repos: - repo: https://github.com/python/black - rev: latest + rev: 19.10b0 hooks: - id: black - repo: https://github.com/fsfe/reuse-tool diff --git a/README.rst b/README.rst index d696977..cfbf734 100644 --- a/README.rst +++ b/README.rst @@ -27,6 +27,9 @@ This driver depends on: * `Adafruit CircuitPython `_ * `Bus Device `_ * `Register `_ +* `Seesaw `_ +* `LIS3DH `_ +* `ST7789 `_ Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading diff --git a/adafruit_monsterm4sk.py b/adafruit_monsterm4sk.py index bea6c94..893a262 100644 --- a/adafruit_monsterm4sk.py +++ b/adafruit_monsterm4sk.py @@ -1,4 +1,3 @@ -# SPDX-FileCopyrightText: 2020 Foamyguy, written for Adafruit Industries # SPDX-FileCopyrightText: Copyright (c) 2020 Foamyguy for Adafruit Industries # # SPDX-License-Identifier: MIT @@ -16,8 +15,7 @@ **Hardware:** -* `MONSTER M4SK ` - +* `MONSTER M4SK `_ **Software and Dependencies:** @@ -30,15 +28,15 @@ """ # imports +import time import board +import pulseio import busio -import displayio -import time -import touchio import digitalio from adafruit_seesaw.seesaw import Seesaw +import displayio +import touchio from adafruit_st7789 import ST7789 -import pulseio import adafruit_lis3dh __version__ = "0.0.0-auto.0" @@ -54,10 +52,10 @@ class MonsterM4sk: - """Class representing a `MONSTER M4SK` - `_. + """Represents a single Monster M4sk - The terms "left" and "right" are always used from the perspective of looking out of the mask. + The terms "left" and "right" are always used from the + perspective of looking out of the mask. The right screen is the one USB port directly above it. """ @@ -99,7 +97,9 @@ def __init__(self, i2c=None): self.left_display = ST7789(left_display_bus, width=240, height=240, rowstart=80) - self.right_backlight = pulseio.PWMOut(board.RIGHT_TFT_LITE, frequency=5000, duty_cycle=0) + self.right_backlight = pulseio.PWMOut( + board.RIGHT_TFT_LITE, frequency=5000, duty_cycle=0 + ) self.right_backlight.duty_cycle = 65535 # right display @@ -108,10 +108,15 @@ def __init__(self, i2c=None): right_tft_dc = board.RIGHT_TFT_DC right_display_bus = displayio.FourWire( - right_spi, command=right_tft_dc, chip_select=right_tft_cs, reset=board.RIGHT_TFT_RST + right_spi, + command=right_tft_dc, + chip_select=right_tft_cs, + reset=board.RIGHT_TFT_RST, ) - self.right_display = ST7789(right_display_bus, width=240, height=240, rowstart=80) + self.right_display = ST7789( + right_display_bus, width=240, height=240, rowstart=80 + ) if i2c is not None: int1 = digitalio.DigitalInOut(board.ACCELEROMETER_INTERRUPT) @@ -146,7 +151,7 @@ def buttons(self): return { "S9": self._ss.digital_read(SS_SWITCH1_PIN) is False, "S10": self._ss.digital_read(SS_SWITCH2_PIN) is False, - "S11": self._ss.digital_read(SS_SWITCH3_PIN) is False + "S11": self._ss.digital_read(SS_SWITCH3_PIN) is False, } @property diff --git a/docs/conf.py b/docs/conf.py index 8d56bc4..3653811 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -25,12 +25,28 @@ # Uncomment the below if you use native CircuitPython modules such as # digitalio, micropython and busio. List the modules you use. Without it, the # autodoc module docs will fail to generate with a warning. -# autodoc_mock_imports = ["digitalio", "busio"] +autodoc_mock_imports = [ + "digitalio", + "busio", + "pulseio", + "displayio", + "touchio", + "adafruit_st7789", + "adafruit_seesaw", + "adafruit_lis3dh", +] intersphinx_mapping = { - "python": ("https://docs.python.org/3.4", None),"BusDevice": ("https://circuitpython.readthedocs.io/projects/busdevice/en/latest/", None), - "Register": ("https://circuitpython.readthedocs.io/projects/register/en/latest/", None), + "python": ("https://docs.python.org/3.4", None), + "BusDevice": ( + "https://circuitpython.readthedocs.io/projects/busdevice/en/latest/", + None, + ), + "Register": ( + "https://circuitpython.readthedocs.io/projects/register/en/latest/", + None, + ), "CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None), } diff --git a/docs/index.rst b/docs/index.rst index f82d3fa..d31cd62 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -23,14 +23,10 @@ Table of Contents .. toctree:: :caption: Tutorials -.. todo:: Add any Learn guide links here. If there are none, then simply delete this todo and leave - the toctree above for use later. - .. toctree:: :caption: Related Products -.. todo:: Add any product links here. If there are none, then simply delete this todo and leave - the toctree above for use later. + MONSTER M4SK .. toctree:: :caption: Other Links diff --git a/examples/monsterm4sk_rainbow_stars.py b/examples/monsterm4sk_rainbow_stars.py index a7d1d66..e001b98 100644 --- a/examples/monsterm4sk_rainbow_stars.py +++ b/examples/monsterm4sk_rainbow_stars.py @@ -10,11 +10,12 @@ make the eyes change through the rainbow. """ +import time import board import displayio -import adafruit_monsterm4sk import adafruit_imageload -import time +import adafruit_monsterm4sk + SCREEN_SIZE = 240 IMAGE_SIZE = 64 * 3 @@ -36,21 +37,33 @@ right_group.y = (SCREEN_SIZE - IMAGE_SIZE) // 2 # load in party parrot bitmap -parrot_bit, parrot_pal = adafruit_imageload.load("/rainbow_star.bmp", - bitmap=displayio.Bitmap, - palette=displayio.Palette) - -right_star_grid = displayio.TileGrid(parrot_bit, pixel_shader=parrot_pal, - width=1, height=1, - tile_height=64, tile_width=64, - default_tile=0, - x=0, y=0) - -left_star_grid = displayio.TileGrid(parrot_bit, pixel_shader=parrot_pal, - width=1, height=1, - tile_height=64, tile_width=64, - default_tile=0, - x=0, y=0) +star_bitmap, star_palette = adafruit_imageload.load( + "/rainbow_star.bmp", bitmap=displayio.Bitmap, palette=displayio.Palette +) + +right_star_grid = displayio.TileGrid( + star_bitmap, + pixel_shader=star_palette, + width=1, + height=1, + tile_height=64, + tile_width=64, + default_tile=0, + x=0, + y=0, +) + +left_star_grid = displayio.TileGrid( + star_bitmap, + pixel_shader=star_palette, + width=1, + height=1, + tile_height=64, + tile_width=64, + default_tile=0, + x=0, + y=0, +) right_group.append(right_star_grid) left_group.append(left_star_grid) diff --git a/examples/rainbow_star.bmp.license b/examples/rainbow_star.bmp.license new file mode 100644 index 0000000..8ec10a2 --- /dev/null +++ b/examples/rainbow_star.bmp.license @@ -0,0 +1,3 @@ +# SPDX-FileCopyrightText: 2020 Foamyguy, created for Adafruit Industries +# +# SPDX-License-Identifier: Unlicense diff --git a/setup.py b/setup.py index 0be6bca..2eba876 100644 --- a/setup.py +++ b/setup.py @@ -56,7 +56,7 @@ ], # What does your project relate to? keywords="adafruit blinka circuitpython micropython monsterm4sk dualscreen bothscreens " - "monster_m4sk", + "monster_m4sk", # 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,