Skip to content

Commit

Permalink
pybricks.hubs: Change button to buttons.
Browse files Browse the repository at this point in the history
  • Loading branch information
laurensvalk committed Mar 5, 2024
1 parent b2b183e commit 2e538b6
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 21 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
## Changed

- Updates for v3.4.0b3 firmware.
- Changed `hub.button` to `hub.buttons` on single button hubs. Access via
`hub.button` will keep working in the firmware for backwards compatibility.

## 3.4.0b4 - 2024-02-14

Expand Down
2 changes: 1 addition & 1 deletion doc/main/hubs/cityhub.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ City Hub

.. blockimg:: pybricks_blockButtonIsPressed_CityHub

.. automethod:: pybricks.hubs::CityHub.button.pressed
.. automethod:: pybricks.hubs::CityHub.buttons.pressed

.. automethod:: pybricks.hubs::CityHub.system.set_stop_button

Expand Down
2 changes: 1 addition & 1 deletion doc/main/hubs/essentialhub.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Essential Hub

.. blockimg:: pybricks_blockButtonIsPressed_EssentialHub

.. automethod:: pybricks.hubs::EssentialHub.button.pressed
.. automethod:: pybricks.hubs::EssentialHub.buttons.pressed

.. automethod:: pybricks.hubs::EssentialHub.system.set_stop_button

Expand Down
2 changes: 1 addition & 1 deletion doc/main/hubs/movehub.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Move Hub

.. blockimg:: pybricks_blockButtonIsPressed_PrimeHub

.. automethod:: pybricks.hubs::MoveHub.button.pressed
.. automethod:: pybricks.hubs::MoveHub.buttons.pressed

.. automethod:: pybricks.hubs::MoveHub.system.set_stop_button

Expand Down
2 changes: 1 addition & 1 deletion doc/main/hubs/technichub.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Technic Hub

.. blockimg:: pybricks_blockButtonIsPressed_TechnicHub

.. automethod:: pybricks.hubs::TechnicHub.button.pressed
.. automethod:: pybricks.hubs::TechnicHub.buttons.pressed

.. automethod:: pybricks.hubs::TechnicHub.system.set_stop_button

Expand Down
2 changes: 1 addition & 1 deletion examples/pup/hub_common/button_single.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
while watch.time() < 5000:

# Set light to green if pressed, else red.
if hub.button.pressed():
if hub.buttons.pressed():
hub.light.on(Color.GREEN)
else:
hub.light.on(Color.RED)
Expand Down
4 changes: 2 additions & 2 deletions jedi/tests/test_complete_city_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_hub_dot():
assert [c["insertText"] for c in completions] == [
"battery",
"ble",
"button",
"buttons",
"light",
"system",
]
Expand All @@ -51,7 +51,7 @@ def test_hub_dot_battery_dot():


def test_hub_dot_button_dot():
line = "hub.button."
line = "hub.buttons."
code = _create_snippet(line)
completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1))
assert [c["insertText"] for c in completions] == [
Expand Down
4 changes: 2 additions & 2 deletions jedi/tests/test_complete_essential_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_hub_dot():
assert [c["insertText"] for c in completions] == [
"battery",
"ble",
"button",
"buttons",
"charger",
"imu",
"light",
Expand All @@ -53,7 +53,7 @@ def test_hub_dot_battery_dot():


def test_hub_dot_buttons_dot():
line = "hub.button."
line = "hub.buttons."
code = _create_snippet(line)
completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1))
assert [c["insertText"] for c in completions] == [
Expand Down
4 changes: 2 additions & 2 deletions jedi/tests/test_complete_move_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_hub_dot():
assert [c["insertText"] for c in completions] == [
"battery",
"ble",
"button",
"buttons",
"imu",
"light",
"system",
Expand All @@ -52,7 +52,7 @@ def test_hub_dot_battery_dot():


def test_hub_dot_button_dot():
line = "hub.button."
line = "hub.buttons."
code = _create_snippet(line)
completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1))
assert [c["insertText"] for c in completions] == [
Expand Down
4 changes: 2 additions & 2 deletions jedi/tests/test_complete_technic_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_hub_dot():
assert [c["insertText"] for c in completions] == [
"battery",
"ble",
"button",
"buttons",
"imu",
"light",
"system",
Expand All @@ -52,7 +52,7 @@ def test_hub_dot_battery_dot():


def test_hub_dot_button_dot():
line = "hub.button."
line = "hub.buttons."
code = _create_snippet(line)
completions: list[CompletionItem] = json.loads(complete(code, 3, len(line) + 1))
assert [c["insertText"] for c in completions] == [
Expand Down
8 changes: 4 additions & 4 deletions jedi/tests/test_get_signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def _get_method_signature(module: str, type: str, method: str) -> SignatureHelp:
),
pytest.param("pybricks.hubs", "MoveHub", "battery.voltage", [([], "int")]),
pytest.param("pybricks.hubs", "MoveHub", "battery.current", [([], "int")]),
pytest.param("pybricks.hubs", "MoveHub", "button.pressed", [([], "Set[Button]")]),
pytest.param("pybricks.hubs", "MoveHub", "buttons.pressed", [([], "Set[Button]")]),
pytest.param(
"pybricks.hubs",
"MoveHub",
Expand Down Expand Up @@ -288,7 +288,7 @@ def _get_method_signature(module: str, type: str, method: str) -> SignatureHelp:
),
pytest.param("pybricks.hubs", "CityHub", "battery.voltage", [([], "int")]),
pytest.param("pybricks.hubs", "CityHub", "battery.current", [([], "int")]),
pytest.param("pybricks.hubs", "CityHub", "button.pressed", [([], "Set[Button]")]),
pytest.param("pybricks.hubs", "CityHub", "buttons.pressed", [([], "Set[Button]")]),
pytest.param(
"pybricks.hubs",
"CityHub",
Expand Down Expand Up @@ -354,7 +354,7 @@ def _get_method_signature(module: str, type: str, method: str) -> SignatureHelp:
pytest.param("pybricks.hubs", "TechnicHub", "battery.voltage", [([], "int")]),
pytest.param("pybricks.hubs", "TechnicHub", "battery.current", [([], "int")]),
pytest.param(
"pybricks.hubs", "TechnicHub", "button.pressed", [([], "Set[Button]")]
"pybricks.hubs", "TechnicHub", "buttons.pressed", [([], "Set[Button]")]
),
pytest.param(
"pybricks.hubs",
Expand Down Expand Up @@ -506,7 +506,7 @@ def _get_method_signature(module: str, type: str, method: str) -> SignatureHelp:
[(["colors: Collection[Color]", "interval: Number"], "None")],
),
pytest.param(
"pybricks.hubs", "EssentialHub", "button.pressed", [([], "Set[Button]")]
"pybricks.hubs", "EssentialHub", "buttons.pressed", [([], "Set[Button]")]
),
pytest.param("pybricks.hubs", "EssentialHub", "imu.up", [([], "Side")]),
pytest.param(
Expand Down
8 changes: 4 additions & 4 deletions src/pybricks/hubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class MoveHub:
light = _common.ColorLight()
imu = _common.SimpleAccelerometer()
system = _common.System()
button = _common.Keypad([_Button.CENTER])
buttons = _common.Keypad([_Button.CENTER])
ble = _common.BLE()

def __init__(
Expand Down Expand Up @@ -74,7 +74,7 @@ class CityHub:
battery = _common.Battery()
light = _common.ColorLight()
system = _common.System()
button = _common.Keypad([_Button.CENTER])
buttons = _common.Keypad([_Button.CENTER])
ble = _common.BLE()

def __init__(
Expand Down Expand Up @@ -105,7 +105,7 @@ class TechnicHub:
light = _common.ColorLight()
imu = _common.IMU()
system = _common.System()
button = _common.Keypad([_Button.CENTER])
buttons = _common.Keypad([_Button.CENTER])
ble = _common.BLE()

def __init__(
Expand Down Expand Up @@ -146,7 +146,7 @@ class EssentialHub:
# These class attributes are here for auto-documentation only.
# In reality, they are instance attributes created by __init__.
battery = _common.Battery()
button = _common.Keypad([_Button.CENTER])
buttons = _common.Keypad([_Button.CENTER])
charger = _common.Charger()
light = _common.ColorLight()
imu = _common.IMU()
Expand Down

0 comments on commit 2e538b6

Please sign in to comment.