fix(pm3py): LED return echoes what was sent instead of meaningless status int
This commit is contained in:
12
pm3py/hw.py
12
pm3py/hw.py
@@ -95,9 +95,17 @@ class HWCommands:
|
|||||||
action_code = 1
|
action_code = 1
|
||||||
brightness_val = 0
|
brightness_val = 0
|
||||||
|
|
||||||
|
ACTION_NAMES = {0: "off", 1: "on", 2: "toggle", 3: "pwm", 4: "pulse", 5: "fade", 6: "blink"}
|
||||||
|
|
||||||
payload = struct.pack("<BBBHH", led_mask, action_code, brightness_val, speed, count)
|
payload = struct.pack("<BBBHH", led_mask, action_code, brightness_val, speed, count)
|
||||||
resp = await self._t.send_ng(Cmd.LED_CONTROL, payload)
|
await self._t.send_ng(Cmd.LED_CONTROL, payload)
|
||||||
return {"status": resp.status}
|
return {
|
||||||
|
"led": led_mask,
|
||||||
|
"action": ACTION_NAMES[action_code],
|
||||||
|
"brightness": brightness_val if action_code == 3 else None,
|
||||||
|
"speed": speed if action_code >= 4 else None,
|
||||||
|
"count": count if action_code in (4, 6) else None,
|
||||||
|
}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse_led_str(led: str) -> int:
|
def _parse_led_str(led: str) -> int:
|
||||||
|
|||||||
Reference in New Issue
Block a user