From 91bc9a5d607445bd8e460148611dc0f3c4f0a3b2 Mon Sep 17 00:00:00 2001 From: Laurens Valk Date: Mon, 13 Nov 2023 10:45:51 +0100 Subject: [PATCH] pybricks.hubs.MoveHub: Enable imu orientation. --- doc/main/hubs/movehub.rst | 2 ++ doc/main/parameters/axis.rst | 3 +++ jedi/tests/test_complete_move_hub.py | 1 + jedi/tests/test_get_signature.py | 9 +++++++-- src/pybricks/hubs.py | 6 +++++- 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/doc/main/hubs/movehub.rst b/doc/main/hubs/movehub.rst index 837c39d..7c32e79 100644 --- a/doc/main/hubs/movehub.rst +++ b/doc/main/hubs/movehub.rst @@ -25,6 +25,8 @@ Move Hub .. automethod:: pybricks.hubs::MoveHub.imu.up + .. automethod:: pybricks.hubs::TechnicHub.imu.tilt + .. automethod:: pybricks.hubs::MoveHub.imu.acceleration .. versionchanged:: 3.2 diff --git a/doc/main/parameters/axis.rst b/doc/main/parameters/axis.rst index 49b19ff..42f1246 100644 --- a/doc/main/parameters/axis.rst +++ b/doc/main/parameters/axis.rst @@ -5,3 +5,6 @@ Axis .. autoclass:: pybricks.parameters.Axis :no-members: + +On Move Hub, doing math with these vectors is not supported. The axes can still +be used to set up the hub orientation. diff --git a/jedi/tests/test_complete_move_hub.py b/jedi/tests/test_complete_move_hub.py index 63d86c7..9c099dc 100644 --- a/jedi/tests/test_complete_move_hub.py +++ b/jedi/tests/test_complete_move_hub.py @@ -66,6 +66,7 @@ def test_hub_dot_imu_dot(): completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1)) assert [c["insertText"] for c in completions] == [ "acceleration", + "tilt", "up", ] diff --git a/jedi/tests/test_get_signature.py b/jedi/tests/test_get_signature.py index dca8a27..616d143 100644 --- a/jedi/tests/test_get_signature.py +++ b/jedi/tests/test_get_signature.py @@ -910,9 +910,14 @@ METHOD_PARAMS = [ [(["name: str"], "None"), ([], "str")], ), pytest.param( - "pybricks.pupdevices", "Remote", "light.on", [(["color: Color"], "None")] + "pybricks.pupdevices", + "Remote", + "light.on", + [(["color: Color"], "MaybeAwaitable")], + ), + pytest.param( + "pybricks.pupdevices", "Remote", "light.off", [([], "MaybeAwaitable")] ), - pytest.param("pybricks.pupdevices", "Remote", "light.off", [([], "None")]), pytest.param( "pybricks.pupdevices", "Remote", diff --git a/src/pybricks/hubs.py b/src/pybricks/hubs.py index 1f0208b..8ba1e8b 100644 --- a/src/pybricks/hubs.py +++ b/src/pybricks/hubs.py @@ -46,9 +46,13 @@ class MoveHub: def __init__( self, broadcast_channel: int = 0, observe_channels: Sequence[int] = [] ): - """MoveHub(broadcast_channel=0, observe_channels=[]) + """MoveHub(top_side=Axis.Z, front_side=Axis.X, broadcast_channel=0, observe_channels=[]) Arguments: + top_side (Axis): The axis that passes through the *top side* of + the hub. + front_side (Axis): The axis that passes through the *front side* of + the hub. broadcast_channel: A value from 0 to 255 indicating which channel ``hub.ble.broadcast()`` will use. Default is channel 0.