mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-09-15 11:04:55 +00:00
pybricks.common.LightMatrix: Rename image() to icon().
Fixes https://github.com/pybricks/support/issues/409
This commit is contained in:
@@ -4,6 +4,10 @@
|
||||
|
||||
## Unreleased
|
||||
|
||||
### Changed
|
||||
- Changed `PrimeHub.display.image()` to `PrimeHub.display.icon()` and renamed
|
||||
its kwarg from `image` to `icon`.
|
||||
|
||||
## 3.2.0b5 - 2022-11-11
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -45,7 +45,7 @@ Prime Hub / Inventor Hub
|
||||
|
||||
.. automethod:: pybricks.hubs::PrimeHub.display.pixel
|
||||
|
||||
.. automethod:: pybricks.hubs::PrimeHub.display.image
|
||||
.. automethod:: pybricks.hubs::PrimeHub.display.icon
|
||||
|
||||
.. automethod:: pybricks.hubs::PrimeHub.display.animate
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ while not any(pressed):
|
||||
wait(10)
|
||||
|
||||
# Display a circle.
|
||||
hub.display.image(Icon.CIRCLE)
|
||||
hub.display.icon(Icon.CIRCLE)
|
||||
|
||||
# Wait for all buttons to be released.
|
||||
while any(hub.buttons.pressed()):
|
||||
@@ -20,10 +20,10 @@ while any(hub.buttons.pressed()):
|
||||
|
||||
# Display an arrow to indicate which button was pressed.
|
||||
if Button.LEFT in pressed:
|
||||
hub.display.image(Icon.ARROW_LEFT_DOWN)
|
||||
hub.display.icon(Icon.ARROW_LEFT_DOWN)
|
||||
elif Button.RIGHT in pressed:
|
||||
hub.display.image(Icon.ARROW_RIGHT_DOWN)
|
||||
hub.display.icon(Icon.ARROW_RIGHT_DOWN)
|
||||
elif Button.BLUETOOTH in pressed:
|
||||
hub.display.image(Icon.ARROW_RIGHT_UP)
|
||||
hub.display.icon(Icon.ARROW_RIGHT_UP)
|
||||
|
||||
wait(3000)
|
||||
|
||||
@@ -24,11 +24,9 @@ while True:
|
||||
|
||||
for i in range(3):
|
||||
# Display eyes open plus the random brows.
|
||||
hub.display.image(Icon.EYE_LEFT + Icon.EYE_RIGHT + brows)
|
||||
hub.display.icon(Icon.EYE_LEFT + Icon.EYE_RIGHT + brows)
|
||||
wait(2000)
|
||||
|
||||
# Display eyes blinked plus the random brows.
|
||||
hub.display.image(
|
||||
Icon.EYE_LEFT_BLINK * 0.7 + Icon.EYE_RIGHT_BLINK * 0.7 + brows
|
||||
)
|
||||
hub.display.icon(Icon.EYE_LEFT_BLINK * 0.7 + Icon.EYE_RIGHT_BLINK * 0.7 + brows)
|
||||
wait(200)
|
||||
|
||||
@@ -6,13 +6,13 @@ from pybricks.parameters import Icon
|
||||
hub = PrimeHub()
|
||||
|
||||
# Display a big arrow pointing up.
|
||||
hub.display.image(Icon.UP)
|
||||
hub.display.icon(Icon.UP)
|
||||
|
||||
# Wait so we can see what is displayed.
|
||||
wait(2000)
|
||||
|
||||
# Display a heart at half brightness.
|
||||
hub.display.image(Icon.HEART / 2)
|
||||
hub.display.icon(Icon.HEART / 2)
|
||||
|
||||
# Wait so we can see what is displayed.
|
||||
wait(2000)
|
||||
|
||||
@@ -17,7 +17,7 @@ SQUARE = Matrix(
|
||||
)
|
||||
|
||||
# Display the square.
|
||||
hub.display.image(SQUARE)
|
||||
hub.display.icon(SQUARE)
|
||||
wait(3000)
|
||||
|
||||
# Make an image using a Python list comprehension. In this image, the
|
||||
@@ -26,5 +26,5 @@ wait(3000)
|
||||
GRADIENT = Matrix([[(r + c) for c in range(5)] for r in range(5)]) * 12.5
|
||||
|
||||
# Display the generated gradient.
|
||||
hub.display.image(GRADIENT)
|
||||
hub.display.icon(GRADIENT)
|
||||
wait(3000)
|
||||
|
||||
@@ -14,6 +14,6 @@ while True:
|
||||
hub.display.orientation(up_side)
|
||||
|
||||
# Display something, like an arrow.
|
||||
hub.display.image(Icon.UP)
|
||||
hub.display.icon(Icon.UP)
|
||||
|
||||
wait(10)
|
||||
|
||||
@@ -80,7 +80,7 @@ def test_hub_dot_display_dot():
|
||||
assert [c["insertText"] for c in completions] == [
|
||||
"animate",
|
||||
"char",
|
||||
"image",
|
||||
"icon",
|
||||
"number",
|
||||
"off",
|
||||
"orientation",
|
||||
|
||||
@@ -360,7 +360,7 @@ METHOD_PARAMS = [
|
||||
[(["row: Number", "column: Number", "brightness: Number=100"], "None")],
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.hubs", "PrimeHub", "display.image", [(["matrix: Matrix"], "None")]
|
||||
"pybricks.hubs", "PrimeHub", "display.icon", [(["icon: Matrix"], "None")]
|
||||
),
|
||||
pytest.param(
|
||||
"pybricks.hubs",
|
||||
|
||||
@@ -708,14 +708,14 @@ class LightMatrix:
|
||||
or ``Side.BOTTOM``.
|
||||
"""
|
||||
|
||||
def image(self, matrix: Matrix) -> None:
|
||||
"""image(matrix)
|
||||
def icon(self, icon: Matrix) -> None:
|
||||
"""icon(icon)
|
||||
|
||||
Displays an image, represented by a matrix of :ref:`brightness`
|
||||
Displays an icon, represented by a matrix of :ref:`brightness`
|
||||
values.
|
||||
|
||||
Arguments:
|
||||
matrix (Matrix): Matrix of intensities (:ref:`brightness`). A 2D
|
||||
icon (Matrix): Matrix of intensities (:ref:`brightness`). A 2D
|
||||
list is also accepted.
|
||||
"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user