Skip to content

Commit

Permalink
pybricks.common.LightMatrix: Rename image() to icon().
Browse files Browse the repository at this point in the history
  • Loading branch information
laurensvalk committed Nov 22, 2022
1 parent 3a60d40 commit 08e20f1
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 20 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion doc/main/hubs/primehub.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions examples/pup/hub_primehub/button_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
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()):
wait(10)

# 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)
6 changes: 2 additions & 4 deletions examples/pup/hub_primehub/display_expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@

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)
4 changes: 2 additions & 2 deletions examples/pup/hub_primehub/display_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
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)
4 changes: 2 additions & 2 deletions examples/pup/hub_primehub/display_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
)

# 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
Expand All @@ -26,5 +26,5 @@
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)
2 changes: 1 addition & 1 deletion examples/pup/hub_primehub/display_orientation_imu.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
hub.display.orientation(up_side)

# Display something, like an arrow.
hub.display.image(Icon.UP)
hub.display.icon(Icon.UP)

wait(10)
2 changes: 1 addition & 1 deletion jedi/tests/test_complete_prime_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_hub_dot_display_dot():
assert [c["insertText"] for c in completions] == [
"animate",
"char",
"image",
"icon",
"number",
"off",
"orientation",
Expand Down
2 changes: 1 addition & 1 deletion jedi/tests/test_get_signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def _get_method_signature(module: str, type: str, method: str) -> SignatureHelp:
[(["row: Number", "column: Number", "brightness: Number=100"], "None")],
),
pytest.param(
"pybricks.hubs", "PrimeHub", "display.image", [(["matrix: Matrix"], "None")]
"pybricks.hubs", "PrimeHub", "display.icon", [(["matrix: Matrix"], "None")]
),
pytest.param(
"pybricks.hubs",
Expand Down
8 changes: 4 additions & 4 deletions src/pybricks/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,14 +708,14 @@ def orientation(self, up: Side) -> None:
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.
"""

Expand Down

0 comments on commit 08e20f1

Please sign in to comment.