mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-07-27 19:57:02 +00:00
pybricks.hubs: Change button to buttons.
Fixes https://github.com/pybricks/support/issues/1254
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ watch = StopWatch()
|
||||
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)
|
||||
|
||||
@@ -34,7 +34,7 @@ def test_hub_dot():
|
||||
assert [c["insertText"] for c in completions] == [
|
||||
"battery",
|
||||
"ble",
|
||||
"button",
|
||||
"buttons",
|
||||
"light",
|
||||
"system",
|
||||
]
|
||||
@@ -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] == [
|
||||
|
||||
@@ -34,7 +34,7 @@ def test_hub_dot():
|
||||
assert [c["insertText"] for c in completions] == [
|
||||
"battery",
|
||||
"ble",
|
||||
"button",
|
||||
"buttons",
|
||||
"charger",
|
||||
"imu",
|
||||
"light",
|
||||
@@ -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] == [
|
||||
|
||||
@@ -34,7 +34,7 @@ def test_hub_dot():
|
||||
assert [c["insertText"] for c in completions] == [
|
||||
"battery",
|
||||
"ble",
|
||||
"button",
|
||||
"buttons",
|
||||
"imu",
|
||||
"light",
|
||||
"system",
|
||||
@@ -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] == [
|
||||
|
||||
@@ -34,7 +34,7 @@ def test_hub_dot():
|
||||
assert [c["insertText"] for c in completions] == [
|
||||
"battery",
|
||||
"ble",
|
||||
"button",
|
||||
"buttons",
|
||||
"imu",
|
||||
"light",
|
||||
"system",
|
||||
@@ -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] == [
|
||||
|
||||
@@ -253,7 +253,7 @@ METHOD_PARAMS = [
|
||||
),
|
||||
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",
|
||||
@@ -288,7 +288,7 @@ METHOD_PARAMS = [
|
||||
),
|
||||
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",
|
||||
@@ -354,7 +354,7 @@ METHOD_PARAMS = [
|
||||
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",
|
||||
@@ -506,7 +506,7 @@ METHOD_PARAMS = [
|
||||
[(["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(
|
||||
|
||||
@@ -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__(
|
||||
@@ -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__(
|
||||
@@ -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__(
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user