fix(pm3py): platform-aware LED color mapping (Easy vs RDV4 have different physical layouts)

This commit is contained in:
michael
2026-03-16 00:22:43 -07:00
parent cc7dfa89de
commit a91d862647
2 changed files with 39 additions and 18 deletions

View File

@@ -51,9 +51,12 @@ def test_status():
def test_led_on_by_name():
transport = make_mock_transport()
hw = HWCommands(transport)
hw._is_rdv4 = False # Easy: green=A=0x01
transport.send_ng.return_value = make_ng_response(Cmd.LED_CONTROL, 0, b"")
result = asyncio.get_event_loop().run_until_complete(hw.led("green", on=True))
transport.send_ng.assert_called_once()
payload = transport.send_ng.call_args[0][1]
led_mask = payload[0]
assert led_mask == 0x01 # green on Easy = A
def test_led_pulse():
transport = make_mock_transport()
@@ -82,7 +85,7 @@ def test_led_brightness():
result = asyncio.get_event_loop().run_until_complete(hw.led("green", brightness=50))
payload = transport.send_ng.call_args[0][1]
led_mask, action, bright, _, _ = struct.unpack("<BBBHH", payload)
assert led_mask == 0x02 # green = B
assert led_mask == 0x01 # green on Easy = A
assert action == 3 # pwm
assert bright == 50