Quick payload deploy test

This commit is contained in:
alexlynd
2022-03-18 23:08:26 -07:00
parent 5476b1cc7b
commit 137ee9ae03
39 changed files with 1426 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
# SPDX-FileCopyrightText: 2019 Limor Fried for Adafruit Industries
#
# SPDX-License-Identifier: MIT
"""
`line`
================================================================================
Various common shapes for use with displayio - Line shape!
* Author(s): Melissa LeBlanc-Williams
Implementation Notes
--------------------
**Software and Dependencies:**
* Adafruit CircuitPython firmware for the supported boards:
https://github.com/adafruit/circuitpython/releases
"""
from adafruit_display_shapes.polygon import Polygon
__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Display_Shapes.git"
class Line(Polygon):
# pylint: disable=too-many-arguments,invalid-name, too-few-public-methods
"""A line.
:param x0: The x-position of the first vertex.
:param y0: The y-position of the first vertex.
:param x1: The x-position of the second vertex.
:param y1: The y-position of the second vertex.
:param color: The color of the line.
"""
def __init__(self, x0, y0, x1, y1, color):
super().__init__([(x0, y0), (x1, y1)], outline=color)
@property
def color(self):
"""The line color value. Can be a hex value for a color or
``None`` for no line color."""
return self.outline
@color.setter
def color(self, color):
self.outline = color

View File

@@ -0,0 +1,136 @@
# SPDX-FileCopyrightText: 2019 Limor Fried for Adafruit Industries
#
# SPDX-License-Identifier: MIT
"""
`polygon`
================================================================================
Various common shapes for use with displayio - Polygon shape!
* Author(s): Melissa LeBlanc-Williams
Implementation Notes
--------------------
**Software and Dependencies:**
* Adafruit CircuitPython firmware for the supported boards:
https://github.com/adafruit/circuitpython/releases
"""
import displayio
__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Display_Shapes.git"
class Polygon(displayio.TileGrid):
# pylint: disable=too-many-arguments,invalid-name
"""A polygon.
:param points: A list of (x, y) tuples of the points
:param outline: The outline of the polygon. Can be a hex value for a color or
``None`` for no outline.
"""
def __init__(self, points, *, outline=None):
xs = []
ys = []
for point in points:
xs.append(point[0])
ys.append(point[1])
x_offset = min(xs)
y_offset = min(ys)
# Find the largest and smallest X values to figure out width for bitmap
width = max(xs) - min(xs) + 1
height = max(ys) - min(ys) + 1
self._palette = displayio.Palette(3)
self._palette.make_transparent(0)
self._bitmap = displayio.Bitmap(width, height, 3)
if outline is not None:
# print("outline")
self.outline = outline
for index, _ in enumerate(points):
point_a = points[index]
if index == len(points) - 1:
point_b = points[0]
else:
point_b = points[index + 1]
self._line(
point_a[0] - x_offset,
point_a[1] - y_offset,
point_b[0] - x_offset,
point_b[1] - y_offset,
1,
)
super().__init__(
self._bitmap, pixel_shader=self._palette, x=x_offset, y=y_offset
)
# pylint: disable=invalid-name, too-many-locals, too-many-branches
def _line(self, x0, y0, x1, y1, color):
if x0 == x1:
if y0 > y1:
y0, y1 = y1, y0
for _h in range(y0, y1 + 1):
self._bitmap[x0, _h] = color
elif y0 == y1:
if x0 > x1:
x0, x1 = x1, x0
for _w in range(x0, x1 + 1):
self._bitmap[_w, y0] = color
else:
steep = abs(y1 - y0) > abs(x1 - x0)
if steep:
x0, y0 = y0, x0
x1, y1 = y1, x1
if x0 > x1:
x0, x1 = x1, x0
y0, y1 = y1, y0
dx = x1 - x0
dy = abs(y1 - y0)
err = dx / 2
if y0 < y1:
ystep = 1
else:
ystep = -1
for x in range(x0, x1 + 1):
if steep:
self._bitmap[y0, x] = color
else:
self._bitmap[x, y0] = color
err -= dy
if err < 0:
y0 += ystep
err += dx
# pylint: enable=invalid-name, too-many-locals, too-many-branches
@property
def outline(self):
"""The outline of the polygon. Can be a hex value for a color or
``None`` for no outline."""
return self._palette[1]
@outline.setter
def outline(self, color):
if color is None:
self._palette[1] = 0
self._palette.make_transparent(1)
else:
self._palette[1] = color
self._palette.make_opaque(1)

View File

@@ -0,0 +1,144 @@
# SPDX-FileCopyrightText: 2019 Limor Fried for Adafruit Industries
#
# SPDX-License-Identifier: MIT
"""
`triangle`
================================================================================
Various common shapes for use with displayio - Triangle shape!
* Author(s): Melissa LeBlanc-Williams
Implementation Notes
--------------------
**Software and Dependencies:**
* Adafruit CircuitPython firmware for the supported boards:
https://github.com/adafruit/circuitpython/releases
"""
from adafruit_display_shapes.polygon import Polygon
__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Display_Shapes.git"
class Triangle(Polygon):
# pylint: disable=too-many-arguments,invalid-name
"""A triangle.
:param x0: The x-position of the first vertex.
:param y0: The y-position of the first vertex.
:param x1: The x-position of the second vertex.
:param y1: The y-position of the second vertex.
:param x2: The x-position of the third vertex.
:param y2: The y-position of the third vertex.
:param fill: The color to fill the triangle. Can be a hex value for a color or
``None`` for transparent.
:param outline: The outline of the triangle. Can be a hex value for a color or
``None`` for no outline.
"""
# pylint: disable=too-many-locals
def __init__(self, x0, y0, x1, y1, x2, y2, *, fill=None, outline=None):
# Sort coordinates by Y order (y2 >= y1 >= y0)
if y0 > y1:
y0, y1 = y1, y0
x0, x1 = x1, x0
if y1 > y2:
y1, y2 = y2, y1
x1, x2 = x2, x1
if y0 > y1:
y0, y1 = y1, y0
x0, x1 = x1, x0
# Find the largest and smallest X values to figure out width for bitmap
xs = [x0, x1, x2]
points = [(x0, y0), (x1, y1), (x2, y2)]
# Initialize the bitmap and palette
super().__init__(points)
if fill is not None:
self._draw_filled(
x0 - min(xs), 0, x1 - min(xs), y1 - y0, x2 - min(xs), y2 - y0
)
self.fill = fill
else:
self.fill = None
if outline is not None:
self.outline = outline
for index, _ in enumerate(points):
point_a = points[index]
if index == len(points) - 1:
point_b = points[0]
else:
point_b = points[index + 1]
self._line(
point_a[0] - min(xs),
point_a[1] - y0,
point_b[0] - min(xs),
point_b[1] - y0,
1,
)
# pylint: disable=invalid-name, too-many-branches
def _draw_filled(self, x0, y0, x1, y1, x2, y2):
if y0 == y2: # Handle awkward all-on-same-line case as its own thing
a = x0
b = x0
if x1 < a:
a = x1
elif x1 > b:
b = x1
if x2 < a:
a = x2
elif x2 > b:
b = x2
self._line(a, y0, b, y0, 2)
return
if y1 == y2:
last = y1 # Include y1 scanline
else:
last = y1 - 1 # Skip it
# Upper Triangle
for y in range(y0, last + 1):
a = round(x0 + (x1 - x0) * (y - y0) / (y1 - y0))
b = round(x0 + (x2 - x0) * (y - y0) / (y2 - y0))
if a > b:
a, b = b, a
self._line(a, y, b, y, 2)
# Lower Triangle
for y in range(last + 1, y2 + 1):
a = round(x1 + (x2 - x1) * (y - y1) / (y2 - y1))
b = round(x0 + (x2 - x0) * (y - y0) / (y2 - y0))
if a > b:
a, b = b, a
self._line(a, y, b, y, 2)
# pylint: enable=invalid-name, too-many-locals, too-many-branches
@property
def fill(self):
"""The fill of the triangle. Can be a hex value for a color or
``None`` for transparent."""
return self._palette[2]
@fill.setter
def fill(self, color):
if color is None:
self._palette[2] = 0
self._palette.make_transparent(2)
else:
self._palette[2] = color
self._palette.make_opaque(2)