diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fff3aa9..1dad804 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -40,7 +40,7 @@ jobs: source actions-ci/install.sh - name: Pip install pylint, black, & Sphinx run: | - pip install --force-reinstall pylint==1.9.2 black==19.10b0 Sphinx sphinx-rtd-theme + pip install --force-reinstall pylint black==19.10b0 Sphinx sphinx-rtd-theme - name: Library version run: git describe --dirty --always --tags - name: PyLint diff --git a/adafruit_pybadger/clue.py b/adafruit_pybadger/clue.py index ba6aeab..850f0f6 100755 --- a/adafruit_pybadger/clue.py +++ b/adafruit_pybadger/clue.py @@ -55,8 +55,10 @@ Buttons = namedtuple("Buttons", "a b") + class Clue(PyBadgerBase): """Class that represents a single CLUE.""" + _audio_out = audiopwmio.PWMAudioOut _neopixel_count = 1 @@ -68,8 +70,10 @@ def __init__(self): if i2c is not None: self._accelerometer = adafruit_lsm6ds.LSM6DS33(i2c) - self._buttons = GamePad(digitalio.DigitalInOut(board.BUTTON_A), - digitalio.DigitalInOut(board.BUTTON_B)) + self._buttons = GamePad( + digitalio.DigitalInOut(board.BUTTON_A), + digitalio.DigitalInOut(board.BUTTON_B), + ) @property def button(self): @@ -88,9 +92,9 @@ def button(self): print("Button B") """ button_values = self._buttons.get_pressed() - return Buttons(button_values & PyBadgerBase.BUTTON_B, - button_values & PyBadgerBase.BUTTON_A) - + return Buttons( + button_values & PyBadgerBase.BUTTON_B, button_values & PyBadgerBase.BUTTON_A + ) @property def _unsupported(self): @@ -103,5 +107,6 @@ def _unsupported(self): play_file = _unsupported light = _unsupported + clue = Clue() # pylint: disable=invalid-name """Object that is automatically created on import.""" diff --git a/adafruit_pybadger/pybadge.py b/adafruit_pybadger/pybadge.py index deb75ba..825735b 100755 --- a/adafruit_pybadger/pybadge.py +++ b/adafruit_pybadger/pybadge.py @@ -61,6 +61,7 @@ Buttons = namedtuple("Buttons", "b a start select right down up left") + class PyBadge(PyBadgerBase): """Class that represents a single PyBadge, PyBadge LC, or EdgeBadge.""" @@ -81,13 +82,17 @@ def __init__(self): if i2c is not None: int1 = digitalio.DigitalInOut(board.ACCELEROMETER_INTERRUPT) try: - self._accelerometer = adafruit_lis3dh.LIS3DH_I2C(i2c, address=0x19, int1=int1) + self._accelerometer = adafruit_lis3dh.LIS3DH_I2C( + i2c, address=0x19, int1=int1 + ) except ValueError: self._accelerometer = adafruit_lis3dh.LIS3DH_I2C(i2c, int1=int1) - self._buttons = GamePadShift(digitalio.DigitalInOut(board.BUTTON_CLOCK), - digitalio.DigitalInOut(board.BUTTON_OUT), - digitalio.DigitalInOut(board.BUTTON_LATCH)) + self._buttons = GamePadShift( + digitalio.DigitalInOut(board.BUTTON_CLOCK), + digitalio.DigitalInOut(board.BUTTON_OUT), + digitalio.DigitalInOut(board.BUTTON_LATCH), + ) self._light_sensor = analogio.AnalogIn(board.A7) @@ -113,11 +118,22 @@ def button(self): """ button_values = self._buttons.get_pressed() - return Buttons(*[button_values & button for button in - (PyBadgerBase.BUTTON_B, PyBadgerBase.BUTTON_A, - PyBadgerBase.BUTTON_START, PyBadgerBase.BUTTON_SELECT, - PyBadgerBase.BUTTON_RIGHT, PyBadgerBase.BUTTON_DOWN, - PyBadgerBase.BUTTON_UP, PyBadgerBase.BUTTON_LEFT)]) + return Buttons( + *[ + button_values & button + for button in ( + PyBadgerBase.BUTTON_B, + PyBadgerBase.BUTTON_A, + PyBadgerBase.BUTTON_START, + PyBadgerBase.BUTTON_SELECT, + PyBadgerBase.BUTTON_RIGHT, + PyBadgerBase.BUTTON_DOWN, + PyBadgerBase.BUTTON_UP, + PyBadgerBase.BUTTON_LEFT, + ) + ] + ) + pybadge = PyBadge() # pylint: disable=invalid-name """Object that is automatically created on import.""" diff --git a/adafruit_pybadger/pybadger_base.py b/adafruit_pybadger/pybadger_base.py index 7c04077..efa8408 100755 --- a/adafruit_pybadger/pybadger_base.py +++ b/adafruit_pybadger/pybadger_base.py @@ -50,6 +50,7 @@ import board from micropython import const import digitalio + try: import audiocore except ImportError: @@ -65,6 +66,7 @@ __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_PyBadger.git" + def load_font(fontname, text): """Load a font and glyphs in the text string @@ -73,9 +75,10 @@ def load_font(fontname, text): """ font = bitmap_font.load_font(fontname) - font.load_glyphs(text.encode('utf-8')) + font.load_glyphs(text.encode("utf-8")) return font + # pylint: disable=too-many-instance-attributes class PyBadgerBase: """PyBadger base class.""" @@ -134,8 +137,9 @@ def __init__(self): self._display_brightness = 1.0 # NeoPixels - self._neopixels = neopixel.NeoPixel(board.NEOPIXEL, self._neopixel_count, - brightness=1, pixel_order=neopixel.GRB) + self._neopixels = neopixel.NeoPixel( + board.NEOPIXEL, self._neopixel_count, brightness=1, pixel_order=neopixel.GRB + ) # Auto dim display based on movement self._last_accelerometer = None @@ -160,8 +164,9 @@ def _create_badge_background(self): if self._background_image_filename: with open(self._background_image_filename, "rb") as file_handle: on_disk_bitmap = displayio.OnDiskBitmap(file_handle) - background_image = displayio.TileGrid(on_disk_bitmap, - pixel_shader=displayio.ColorConverter()) + background_image = displayio.TileGrid( + on_disk_bitmap, pixel_shader=displayio.ColorConverter() + ) self._background_group.append(background_image) for image_label in self._lines: self._background_group.append(image_label) @@ -176,8 +181,13 @@ def _create_badge_background(self): for background_label in self._lines: self._background_group.append(background_label) - def badge_background(self, background_color=(255, 0, 0), rectangle_color=(255, 255, 255), - rectangle_drop=0.4, rectangle_height=0.5): + def badge_background( + self, + background_color=(255, 0, 0), + rectangle_color=(255, 255, 255), + rectangle_drop=0.4, + rectangle_height=0.5, + ): """Create a customisable badge background made up of a background color with a rectangle color block over it. Defaults are for ``show_badge``. @@ -201,13 +211,19 @@ def badge_background(self, background_color=(255, 0, 0), rectangle_color=(255, 2 while True: pybadger.show_custom_badge() """ - self._background_group = self._badge_background(background_color, rectangle_color, - rectangle_drop, rectangle_height) + self._background_group = self._badge_background( + background_color, rectangle_color, rectangle_drop, rectangle_height + ) return self._background_group @classmethod - def _badge_background(cls, background_color=(255, 0, 0), rectangle_color=(255, 255, 255), - rectangle_drop=0.4, rectangle_height=0.5): + def _badge_background( + cls, + background_color=(255, 0, 0), + rectangle_color=(255, 255, 255), + rectangle_drop=0.4, + rectangle_height=0.5, + ): """Populate the background color with a rectangle color block over it as the background for a name badge.""" background_group = displayio.Group(max_size=30) @@ -215,11 +231,18 @@ def _badge_background(cls, background_color=(255, 0, 0), rectangle_color=(255, 2 color_palette = displayio.Palette(1) color_palette[0] = background_color - bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0) + bg_sprite = displayio.TileGrid( + color_bitmap, pixel_shader=color_palette, x=0, y=0 + ) background_group.append(bg_sprite) - rectangle = Rect(0, (int(board.DISPLAY.height * rectangle_drop)), board.DISPLAY.width, - (int(board.DISPLAY.height * rectangle_height)), fill=rectangle_color) + rectangle = Rect( + 0, + (int(board.DISPLAY.height * rectangle_drop)), + board.DISPLAY.width, + (int(board.DISPLAY.height * rectangle_height)), + fill=rectangle_color, + ) background_group.append(rectangle) return background_group @@ -241,8 +264,15 @@ def image_background(self, image_name=None): self._background_image_filename = image_name # pylint: disable=too-many-arguments - def badge_line(self, text=" ", color=(0, 0, 0), scale=1, font=terminalio.FONT, - left_justify=False, padding_above=0): + def badge_line( + self, + text=" ", + color=(0, 0, 0), + scale=1, + font=terminalio.FONT, + left_justify=False, + padding_above=0, + ): """Add a line of text to the display. Designed to work with ``badge_background`` for a color-block style badge, or with ``image_background`` for a badge with a background image. @@ -285,8 +315,9 @@ def badge_line(self, text=" ", color=(0, 0, 0), scale=1, font=terminalio.FONT, if isinstance(font, str): font = load_font(font, text) - text_label = self._label.Label(font=font, text=text, max_glyphs=45, color=color, - scale=scale) + text_label = self._label.Label( + font=font, text=text, max_glyphs=45, color=color, scale=scale + ) self._lines.append(text_label) _, _, width, height = text_label.bounding_box @@ -310,12 +341,16 @@ def badge_line(self, text=" ", color=(0, 0, 0), scale=1, font=terminalio.FONT, self._y_position += height * scale + 4 else: - text_label.y = self._y_position + (((height // 2) * scale) - trim_y) + \ - ((height * padding_above) - trim_padding) + text_label.y = ( + self._y_position + + (((height // 2) * scale) - trim_y) + + ((height * padding_above) - trim_padding) + ) if font is terminalio.FONT: - self._y_position += ((height * scale - trim_y) + ((height * padding_above) - - trim_padding)) + self._y_position += (height * scale - trim_y) + ( + (height * padding_above) - trim_padding + ) else: self._y_position += height * scale + 4 @@ -329,9 +364,16 @@ def show_custom_badge(self): self.display.show(self._background_group) # pylint: disable=too-many-arguments - def _create_label_group(self, text, font, - scale, height_adjustment, - color=0xFFFFFF, width_adjustment=2, line_spacing=0.75): + def _create_label_group( + self, + text, + font, + scale, + height_adjustment, + color=0xFFFFFF, + width_adjustment=2, + line_spacing=0.75, + ): """Create a label group with the given text, font, and spacing.""" # If the given font is a string, treat it as a file path and try to load it if isinstance(font, str): @@ -340,7 +382,7 @@ def _create_label_group(self, text, font, create_label_group = displayio.Group(scale=scale) create_label = self._label.Label(font, text=text, line_spacing=line_spacing) _, _, width, _ = create_label.bounding_box - create_label.x = ((self.display.width // (width_adjustment * scale)) - width // 2) + create_label.x = (self.display.width // (width_adjustment * scale)) - width // 2 create_label.y = int(self.display.height * (height_adjustment / scale)) create_label.color = color create_label_group.append(create_label) @@ -352,8 +394,12 @@ def _check_for_movement(self, movement_threshold=10): if self._last_accelerometer is None: self._last_accelerometer = current_accelerometer return False - acceleration_delta = sum([abs(self._last_accelerometer[n] - current_accelerometer[n]) for n - in range(3)]) + acceleration_delta = sum( + [ + abs(self._last_accelerometer[n] - current_accelerometer[n]) + for n in range(3) + ] + ) self._last_accelerometer = current_accelerometer return acceleration_delta > movement_threshold @@ -392,7 +438,11 @@ def light(self): @property def acceleration(self): """Accelerometer data, +/- 2G sensitivity.""" - return self._accelerometer.acceleration if self._accelerometer is not None else None + return ( + self._accelerometer.acceleration + if self._accelerometer is not None + else None + ) @property def brightness(self): @@ -405,11 +455,20 @@ def brightness(self, value): self.display.brightness = value # pylint: disable=too-many-locals - def show_business_card(self, *, image_name=None, name_string=None, name_scale=1, - name_font=terminalio.FONT, email_string_one=None, - email_scale_one=1, email_font_one=terminalio.FONT, - email_string_two=None, email_scale_two=1, - email_font_two=terminalio.FONT): + def show_business_card( + self, + *, + image_name=None, + name_string=None, + name_scale=1, + name_font=terminalio.FONT, + email_string_one=None, + email_scale_one=1, + email_font_one=terminalio.FONT, + email_string_two=None, + email_scale_two=1, + email_font_two=terminalio.FONT + ): """Display a bitmap image and a text string, such as a personal image and email address. :param str image_name: REQUIRED. The name of the bitmap image including .bmp, e.g. @@ -442,29 +501,37 @@ def show_business_card(self, *, image_name=None, name_string=None, name_scale=1, """ business_card_label_groups = [] if name_string: - name_group = self._create_label_group(text=name_string, - font=name_font, - scale=name_scale, - height_adjustment=0.73) + name_group = self._create_label_group( + text=name_string, + font=name_font, + scale=name_scale, + height_adjustment=0.73, + ) business_card_label_groups.append(name_group) if email_string_one: - email_one_group = self._create_label_group(text=email_string_one, - font=email_font_one, - scale=email_scale_one, - height_adjustment=0.84) + email_one_group = self._create_label_group( + text=email_string_one, + font=email_font_one, + scale=email_scale_one, + height_adjustment=0.84, + ) business_card_label_groups.append(email_one_group) if email_string_two: - email_two_group = self._create_label_group(text=email_string_two, - font=email_font_two, - scale=email_scale_two, - height_adjustment=0.91) + email_two_group = self._create_label_group( + text=email_string_two, + font=email_font_two, + scale=email_scale_two, + height_adjustment=0.91, + ) business_card_label_groups.append(email_two_group) business_card_splash = displayio.Group(max_size=4) self.display.show(business_card_splash) with open(image_name, "rb") as file_name: on_disk_bitmap = displayio.OnDiskBitmap(file_name) - face_image = displayio.TileGrid(on_disk_bitmap, pixel_shader=displayio.ColorConverter()) + face_image = displayio.TileGrid( + on_disk_bitmap, pixel_shader=displayio.ColorConverter() + ) business_card_splash.append(face_image) for group in business_card_label_groups: business_card_splash.append(group) @@ -476,12 +543,23 @@ def show_business_card(self, *, image_name=None, name_string=None, name_scale=1, self.display.wait_for_frame() # pylint: disable=too-many-locals - def show_badge(self, *, background_color=(255, 0, 0), foreground_color=(255, 255, 255), - background_text_color=(255, 255, 255), foreground_text_color=(0, 0, 0), - hello_font=terminalio.FONT, hello_scale=1, hello_string="HELLO", - my_name_is_font=terminalio.FONT, my_name_is_scale=1, - my_name_is_string="MY NAME IS", name_font=terminalio.FONT, name_scale=1, - name_string="Blinka"): + def show_badge( + self, + *, + background_color=(255, 0, 0), + foreground_color=(255, 255, 255), + background_text_color=(255, 255, 255), + foreground_text_color=(0, 0, 0), + hello_font=terminalio.FONT, + hello_scale=1, + hello_string="HELLO", + my_name_is_font=terminalio.FONT, + my_name_is_scale=1, + my_name_is_string="MY NAME IS", + name_font=terminalio.FONT, + name_scale=1, + name_string="Blinka" + ): """Create a "Hello My Name is"-style badge. :param background_color: The color of the background. Defaults to ``(255, 0, 0)``. @@ -511,34 +589,41 @@ def show_badge(self, *, background_color=(255, 0, 0), foreground_color=(255, 255 name_scale=3) """ - hello_group = self._create_label_group(text=hello_string, - font=hello_font, - scale=hello_scale, - height_adjustment=0.117, - color=background_text_color) - - my_name_is_group = self._create_label_group(text=my_name_is_string, - font=my_name_is_font, - scale=my_name_is_scale, - height_adjustment=0.28, - color=background_text_color) - - name_group = self._create_label_group(text=name_string, - font=name_font, - scale=name_scale, - height_adjustment=0.65, - color=foreground_text_color) + hello_group = self._create_label_group( + text=hello_string, + font=hello_font, + scale=hello_scale, + height_adjustment=0.117, + color=background_text_color, + ) + + my_name_is_group = self._create_label_group( + text=my_name_is_string, + font=my_name_is_font, + scale=my_name_is_scale, + height_adjustment=0.28, + color=background_text_color, + ) + + name_group = self._create_label_group( + text=name_string, + font=name_font, + scale=name_scale, + height_adjustment=0.65, + color=foreground_text_color, + ) group = displayio.Group() - group.append(self._badge_background(background_color=background_color, - rectangle_color=foreground_color)) + group.append( + self._badge_background( + background_color=background_color, rectangle_color=foreground_color + ) + ) group.append(hello_group) group.append(my_name_is_group) group.append(name_group) self.display.show(group) - - def show_terminal(self): """Revert to terminalio screen. """ @@ -548,8 +633,9 @@ def show_terminal(self): def bitmap_qr(matrix): """The QR code bitmap.""" border_pixels = 2 - bitmap = displayio.Bitmap(matrix.width + 2 * border_pixels, - matrix.height + 2 * border_pixels, 2) + bitmap = displayio.Bitmap( + matrix.width + 2 * border_pixels, matrix.height + 2 * border_pixels, 2 + ) for y in range(matrix.height): for x in range(matrix.width): if matrix[x, y]: @@ -578,12 +664,19 @@ def show_qr_code(self, data="https://circuitpython.org"): palette = displayio.Palette(2) palette[0] = 0xFFFFFF palette[1] = 0x000000 - qr_code_scale = min(self.display.width // qr_bitmap.width, - self.display.height // qr_bitmap.height) - qr_position_x = int(((self.display.width / qr_code_scale) - qr_bitmap.width) / 2) - qr_position_y = int(((self.display.height / qr_code_scale) - qr_bitmap.height) / 2) - qr_img = displayio.TileGrid(qr_bitmap, pixel_shader=palette, x=qr_position_x, - y=qr_position_y) + qr_code_scale = min( + self.display.width // qr_bitmap.width, + self.display.height // qr_bitmap.height, + ) + qr_position_x = int( + ((self.display.width / qr_code_scale) - qr_bitmap.width) / 2 + ) + qr_position_y = int( + ((self.display.height / qr_code_scale) - qr_bitmap.height) / 2 + ) + qr_img = displayio.TileGrid( + qr_bitmap, pixel_shader=palette, x=qr_position_x, y=qr_position_y + ) qr_code = displayio.Group(scale=qr_code_scale) qr_code.append(qr_img) self.display.show(qr_code) @@ -593,7 +686,7 @@ def _sine_sample(length): tone_volume = (2 ** 15) - 1 shift = 2 ** 15 for i in range(length): - yield int(tone_volume * math.sin(2*math.pi*(i / length)) + shift) + yield int(tone_volume * math.sin(2 * math.pi * (i / length)) + shift) def _generate_sample(self, length=100): if self._sample is not None: diff --git a/adafruit_pybadger/pygamer.py b/adafruit_pybadger/pygamer.py index 94fffba..83098d4 100755 --- a/adafruit_pybadger/pygamer.py +++ b/adafruit_pybadger/pygamer.py @@ -56,6 +56,7 @@ Buttons = namedtuple("Buttons", "b a start select right down up left") + class PyGamer(PyBadgerBase): """Class that represents a single PyGamer.""" @@ -69,13 +70,17 @@ def __init__(self): int1 = digitalio.DigitalInOut(board.ACCELEROMETER_INTERRUPT) try: - self._accelerometer = adafruit_lis3dh.LIS3DH_I2C(i2c, address=0x19, int1=int1) + self._accelerometer = adafruit_lis3dh.LIS3DH_I2C( + i2c, address=0x19, int1=int1 + ) except ValueError: self._accelerometer = adafruit_lis3dh.LIS3DH_I2C(i2c, int1=int1) - self._buttons = GamePadShift(digitalio.DigitalInOut(board.BUTTON_CLOCK), - digitalio.DigitalInOut(board.BUTTON_OUT), - digitalio.DigitalInOut(board.BUTTON_LATCH)) + self._buttons = GamePadShift( + digitalio.DigitalInOut(board.BUTTON_CLOCK), + digitalio.DigitalInOut(board.BUTTON_OUT), + digitalio.DigitalInOut(board.BUTTON_LATCH), + ) self._pygamer_joystick_x = analogio.AnalogIn(board.JOYSTICK_X) self._pygamer_joystick_y = analogio.AnalogIn(board.JOYSTICK_Y) @@ -105,15 +110,16 @@ def button(self): """ button_values = self._buttons.get_pressed() x, y = self.joystick - return Buttons(button_values & PyBadgerBase.BUTTON_B, - button_values & PyBadgerBase.BUTTON_A, - button_values & PyBadgerBase.BUTTON_START, - button_values & PyBadgerBase.BUTTON_SELECT, - x > 50000, # RIGHT - y > 50000, # DOWN - y < 15000, # UP - x < 15000 # LEFT - ) + return Buttons( + button_values & PyBadgerBase.BUTTON_B, + button_values & PyBadgerBase.BUTTON_A, + button_values & PyBadgerBase.BUTTON_START, + button_values & PyBadgerBase.BUTTON_SELECT, + x > 50000, # RIGHT + y > 50000, # DOWN + y < 15000, # UP + x < 15000, # LEFT + ) @property def joystick(self): @@ -122,5 +128,6 @@ def joystick(self): y = self._pygamer_joystick_y.value return x, y + pygamer = PyGamer() # pylint: disable=invalid-name """Object that is automatically created on import.""" diff --git a/docs/conf.py b/docs/conf.py index a1bcd90..dd1af00 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -2,7 +2,8 @@ import os import sys -sys.path.insert(0, os.path.abspath('..')) + +sys.path.insert(0, os.path.abspath("..")) # -- General configuration ------------------------------------------------ @@ -10,46 +11,65 @@ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.intersphinx', - 'sphinx.ext.napoleon', - 'sphinx.ext.todo', + "sphinx.ext.autodoc", + "sphinx.ext.intersphinx", + "sphinx.ext.napoleon", + "sphinx.ext.todo", ] # TODO: Please Read! # Uncomment the below if you use native CircuitPython modules such as # digitalio, micropython and busio. List the modules you use. Without it, the # autodoc module docs will fail to generate with a warning. -autodoc_mock_imports = ["audioio", "displayio", "gamepadshift", "neopixel", "analogio", - "adafruit_display_shapes", "adafruit_display_text", "terminalio", - "adafruit_miniqr", "adafruit_lis3dh", "adafruit_bitmap_font", - "adafruit_lsm6ds", "gamepad", "audiocore", "audiopwmio", "micropython", - "terminalio", "digitalio", "board"] +autodoc_mock_imports = [ + "audioio", + "displayio", + "gamepadshift", + "neopixel", + "analogio", + "adafruit_display_shapes", + "adafruit_display_text", + "terminalio", + "adafruit_miniqr", + "adafruit_lis3dh", + "adafruit_bitmap_font", + "adafruit_lsm6ds", + "gamepad", + "audiocore", + "audiopwmio", + "micropython", + "terminalio", + "digitalio", + "board", +] -intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)} +intersphinx_mapping = { + "python": ("https://docs.python.org/3.4", None), + "CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None), +} # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] -source_suffix = '.rst' +source_suffix = ".rst" # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. -project = u'Adafruit PyBadger Library' -copyright = u'2019 Kattni Rembor' -author = u'Kattni Rembor' +project = u"Adafruit PyBadger Library" +copyright = u"2019 Kattni Rembor" +author = u"Kattni Rembor" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = u'1.0' +version = u"1.0" # The full version, including alpha/beta/rc tags. -release = u'1.0' +release = u"1.0" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -61,7 +81,7 @@ # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This patterns also effect to html_static_path and html_extra_path -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md'] +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"] # The reST default role (used for this markup: `text`) to use for all # documents. @@ -73,7 +93,7 @@ add_function_parentheses = True # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' +pygments_style = "sphinx" # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = False @@ -88,59 +108,62 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -on_rtd = os.environ.get('READTHEDOCS', None) == 'True' +on_rtd = os.environ.get("READTHEDOCS", None) == "True" if not on_rtd: # only import and set the theme if we're building docs locally try: import sphinx_rtd_theme - html_theme = 'sphinx_rtd_theme' - html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.'] + + html_theme = "sphinx_rtd_theme" + html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."] except: - html_theme = 'default' - html_theme_path = ['.'] + html_theme = "default" + html_theme_path = ["."] else: - html_theme_path = ['.'] + html_theme_path = ["."] # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +html_static_path = ["_static"] # The name of an image file (relative to this directory) to use as a favicon of # the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. # -html_favicon = '_static/favicon.ico' +html_favicon = "_static/favicon.ico" # Output file base name for HTML help builder. -htmlhelp_basename = 'AdafruitPybadgerLibrarydoc' +htmlhelp_basename = "AdafruitPybadgerLibrarydoc" # -- Options for LaTeX output --------------------------------------------- latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # - # 'papersize': 'letterpaper', - - # The font size ('10pt', '11pt' or '12pt'). - # - # 'pointsize': '10pt', - - # Additional stuff for the LaTeX preamble. - # - # 'preamble': '', - - # Latex figure (float) alignment - # - # 'figure_align': 'htbp', + # The paper size ('letterpaper' or 'a4paper'). + # + # 'papersize': 'letterpaper', + # The font size ('10pt', '11pt' or '12pt'). + # + # 'pointsize': '10pt', + # Additional stuff for the LaTeX preamble. + # + # 'preamble': '', + # Latex figure (float) alignment + # + # 'figure_align': 'htbp', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'AdafruitPyBadgerLibrary.tex', u'AdafruitPyBadger Library Documentation', - author, 'manual'), + ( + master_doc, + "AdafruitPyBadgerLibrary.tex", + u"AdafruitPyBadger Library Documentation", + author, + "manual", + ), ] # -- Options for manual page output --------------------------------------- @@ -148,8 +171,13 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (master_doc, 'AdafruitPyBadgerlibrary', u'Adafruit PyBadger Library Documentation', - [author], 1) + ( + master_doc, + "AdafruitPyBadgerlibrary", + u"Adafruit PyBadger Library Documentation", + [author], + 1, + ) ] # -- Options for Texinfo output ------------------------------------------- @@ -158,7 +186,13 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'AdafruitPyBadgerLibrary', u'Adafruit PyBadger Library Documentation', - author, 'AdafruitPyBadgerLibrary', 'One line description of project.', - 'Miscellaneous'), + ( + master_doc, + "AdafruitPyBadgerLibrary", + u"Adafruit PyBadger Library Documentation", + author, + "AdafruitPyBadgerLibrary", + "One line description of project.", + "Miscellaneous", + ), ] diff --git a/examples/pybadger_clue_custom_badge.py b/examples/pybadger_clue_custom_badge.py index c4b8aad..7c1c893 100644 --- a/examples/pybadger_clue_custom_badge.py +++ b/examples/pybadger_clue_custom_badge.py @@ -1,13 +1,23 @@ """Custom badge example for Adafruit CLUE.""" from adafruit_pybadger import pybadger -pybadger.badge_background(background_color=pybadger.WHITE, rectangle_color=pybadger.PURPLE, - rectangle_drop=0.2, rectangle_height=0.6) +pybadger.badge_background( + background_color=pybadger.WHITE, + rectangle_color=pybadger.PURPLE, + rectangle_drop=0.2, + rectangle_height=0.6, +) -pybadger.badge_line(text="@circuitpython", color=pybadger.BLINKA_PURPLE, scale=2, padding_above=2) +pybadger.badge_line( + text="@circuitpython", color=pybadger.BLINKA_PURPLE, scale=2, padding_above=2 +) pybadger.badge_line(text="Blinka", color=pybadger.WHITE, scale=5, padding_above=3) -pybadger.badge_line(text="CircuitPythonista", color=pybadger.WHITE, scale=2, padding_above=2) -pybadger.badge_line(text="she/her", color=pybadger.BLINKA_PINK, scale=4, padding_above=4) +pybadger.badge_line( + text="CircuitPythonista", color=pybadger.WHITE, scale=2, padding_above=2 +) +pybadger.badge_line( + text="she/her", color=pybadger.BLINKA_PINK, scale=4, padding_above=4 +) pybadger.show_custom_badge() diff --git a/examples/pybadger_clue_custom_image_badge.py b/examples/pybadger_clue_custom_image_badge.py index fa4ed18..5ad0ac4 100644 --- a/examples/pybadger_clue_custom_image_badge.py +++ b/examples/pybadger_clue_custom_image_badge.py @@ -5,7 +5,9 @@ pybadger.badge_line(text="@circuitpython", color=pybadger.SKY, scale=2, padding_above=2) pybadger.badge_line(text="Blinka", color=pybadger.WHITE, scale=5, padding_above=3) -pybadger.badge_line(text="CircuitPythonista", color=pybadger.WHITE, scale=2, padding_above=2) +pybadger.badge_line( + text="CircuitPythonista", color=pybadger.WHITE, scale=2, padding_above=2 +) pybadger.badge_line(text="she/her", color=pybadger.SKY, scale=4, padding_above=4) while True: diff --git a/examples/pybadger_custom_badge.py b/examples/pybadger_custom_badge.py index 6f86ae8..571a6a0 100644 --- a/examples/pybadger_custom_badge.py +++ b/examples/pybadger_custom_badge.py @@ -1,13 +1,23 @@ """Custom badge for PyBadge or PyGamer.""" from adafruit_pybadger import pybadger -pybadger.badge_background(background_color=pybadger.WHITE, rectangle_color=pybadger.PURPLE, - rectangle_drop=0.2, rectangle_height=0.6) +pybadger.badge_background( + background_color=pybadger.WHITE, + rectangle_color=pybadger.PURPLE, + rectangle_drop=0.2, + rectangle_height=0.6, +) -pybadger.badge_line(text="@circuitpython", color=pybadger.BLINKA_PURPLE, scale=1, padding_above=1) +pybadger.badge_line( + text="@circuitpython", color=pybadger.BLINKA_PURPLE, scale=1, padding_above=1 +) pybadger.badge_line(text="Blinka", color=pybadger.WHITE, scale=3, padding_above=2) -pybadger.badge_line(text="CircuitPythonista", color=pybadger.WHITE, scale=1, padding_above=1) -pybadger.badge_line(text="she/her", color=pybadger.BLINKA_PINK, scale=2, padding_above=2) +pybadger.badge_line( + text="CircuitPythonista", color=pybadger.WHITE, scale=1, padding_above=1 +) +pybadger.badge_line( + text="she/her", color=pybadger.BLINKA_PINK, scale=2, padding_above=2 +) while True: pybadger.show_custom_badge() diff --git a/examples/pybadger_simpletest.py b/examples/pybadger_simpletest.py index 6dba7f8..a912a1d 100644 --- a/examples/pybadger_simpletest.py +++ b/examples/pybadger_simpletest.py @@ -1,13 +1,24 @@ from adafruit_pybadger import pybadger -pybadger.show_badge(name_string="Blinka", hello_scale=2, my_name_is_scale=2, name_scale=3) +pybadger.show_badge( + name_string="Blinka", hello_scale=2, my_name_is_scale=2, name_scale=3 +) while True: - pybadger.auto_dim_display(delay=10) # Remove or comment out this line if you have the PyBadge LC + pybadger.auto_dim_display( + delay=10 + ) # Remove or comment out this line if you have the PyBadge LC if pybadger.button.a: - pybadger.show_business_card(image_name="Blinka.bmp", name_string="Blinka", name_scale=2, - email_string_one="blinka@", email_string_two="adafruit.com") + pybadger.show_business_card( + image_name="Blinka.bmp", + name_string="Blinka", + name_scale=2, + email_string_one="blinka@", + email_string_two="adafruit.com", + ) elif pybadger.button.b: pybadger.show_qr_code(data="https://circuitpython.org") elif pybadger.button.start: - pybadger.show_badge(name_string="Blinka", hello_scale=2, my_name_is_scale=2, name_scale=3) + pybadger.show_badge( + name_string="Blinka", hello_scale=2, my_name_is_scale=2, name_scale=3 + ) diff --git a/setup.py b/setup.py index 6ef62d0..08b58d8 100644 --- a/setup.py +++ b/setup.py @@ -6,6 +6,7 @@ """ from setuptools import setup, find_packages + # To use a consistent encoding from codecs import open from os import path @@ -13,51 +14,40 @@ here = path.abspath(path.dirname(__file__)) # Get the long description from the README file -with open(path.join(here, 'README.rst'), encoding='utf-8') as f: +with open(path.join(here, "README.rst"), encoding="utf-8") as f: long_description = f.read() setup( - name='adafruit-circuitpython-pybadger', - + name="adafruit-circuitpython-pybadger", use_scm_version=True, - setup_requires=['setuptools_scm'], - - description='Badge-focused CircuitPython helper library for PyBadge and PyGamer.', + setup_requires=["setuptools_scm"], + description="Badge-focused CircuitPython helper library for PyBadge and PyGamer.", long_description=long_description, - long_description_content_type='text/x-rst', - + long_description_content_type="text/x-rst", # The project's main homepage. - url='https://github.com/adafruit/Adafruit_CircuitPython_PyBadger', - + url="https://github.com/adafruit/Adafruit_CircuitPython_PyBadger", # Author details - author='Adafruit Industries', - author_email='circuitpython@adafruit.com', - - install_requires=[ - 'Adafruit-Blinka' - ], - + author="Adafruit Industries", + author_email="circuitpython@adafruit.com", + install_requires=["Adafruit-Blinka"], # Choose your license - license='MIT', - + license="MIT", # See https://pypi.python.org/pypi?%3Aaction=list_classifiers classifiers=[ - 'Development Status :: 3 - Alpha', - 'Intended Audience :: Developers', - 'Topic :: Software Development :: Libraries', - 'Topic :: System :: Hardware', - 'License :: OSI Approved :: MIT License', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', + "Development Status :: 3 - Alpha", + "Intended Audience :: Developers", + "Topic :: Software Development :: Libraries", + "Topic :: System :: Hardware", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.4", + "Programming Language :: Python :: 3.5", ], - # What does your project relate to? - keywords='adafruit blinka circuitpython micropython pybadger pybadge pygamer badge', - + keywords="adafruit blinka circuitpython micropython pybadger pybadge pygamer badge", # 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=['...']` - packages=['adafruit_pybadger'], + packages=["adafruit_pybadger"], )