Skip to content

Commit

Permalink
Fix strip types on A2 models (#297)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Jan 3, 2022
1 parent 3edd335 commit ac984dd
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
21 changes: 20 additions & 1 deletion flux_led/models_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
A1_NUM_TO_PROTOCOL,
A1_OPERATING_MODE_TO_NUM,
A1_PROTOCOL_TO_NUM,
A2_NUM_TO_OPERATING_MODE,
A2_NUM_TO_PROTOCOL,
A2_OPERATING_MODE_TO_NUM,
A2_PROTOCOL_TO_NUM,
ADDRESSABLE_RGB_NUM_TO_WIRING,
ADDRESSABLE_RGB_WIRING_TO_NUM,
NEW_ADDRESSABLE_NUM_TO_OPERATING_MODE,
Expand Down Expand Up @@ -279,6 +283,21 @@ class LEDENETDeviceConfigurationOptions:
num_to_ic_type=A1_NUM_TO_PROTOCOL,
ic_type_to_num=A1_PROTOCOL_TO_NUM,
)
A2_DEVICE_CONFIG = LEDENETDeviceConfigurationOptions(
wiring=True,
num_to_wiring=ADDRESSABLE_RGB_NUM_TO_WIRING,
wiring_to_num=ADDRESSABLE_RGB_WIRING_TO_NUM,
operating_modes=False,
num_to_operating_mode=A2_NUM_TO_OPERATING_MODE,
operating_mode_to_num=A2_OPERATING_MODE_TO_NUM,
pixels=True,
segments=True,
music_pixels=True,
music_segments=True,
ic_type=True,
num_to_ic_type=A2_NUM_TO_PROTOCOL,
ic_type_to_num=A2_PROTOCOL_TO_NUM,
)
NEW_ADDRESABLE_DEVICE_CONFIG = LEDENETDeviceConfigurationOptions(
wiring=True,
num_to_wiring=ADDRESSABLE_RGB_NUM_TO_WIRING,
Expand Down Expand Up @@ -1083,7 +1102,7 @@ def protocol_for_version_num(self, version_num: int) -> str:
color_modes=COLOR_MODES_ADDRESSABLE,
channel_map={},
microphone=True,
device_config=NEW_ADDRESABLE_DEVICE_CONFIG,
device_config=A2_DEVICE_CONFIG,
),
LEDENETModel(
model_num=0xA3,
Expand Down
30 changes: 30 additions & 0 deletions flux_led/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,36 @@ class LEDENETRawState(NamedTuple):
}
A1_OPERATING_MODE_TO_NUM = {v: k for k, v in A1_NUM_TO_OPERATING_MODE.items()}

A2_NUM_TO_PROTOCOL = {
1: "UCS1903",
2: "SM16703",
3: "WS2811",
4: "WS2811B",
5: "SK6812",
6: "INK1003",
7: "WS2801",
8: "WS2815",
9: "APA102",
10: "TM1914",
11: "UCS2904B",
}
A2_PROTOCOL_TO_NUM = {v: k for k, v in A2_NUM_TO_PROTOCOL.items()}

A2_NUM_TO_OPERATING_MODE = {
1: COLOR_MODE_RGB,
2: COLOR_MODE_RGB,
3: COLOR_MODE_RGB,
4: COLOR_MODE_RGB,
5: COLOR_MODE_RGB,
6: COLOR_MODE_RGB,
7: COLOR_MODE_RGB,
8: COLOR_MODE_RGB,
9: COLOR_MODE_RGB,
10: COLOR_MODE_RGB,
11: COLOR_MODE_RGB,
}
A2_OPERATING_MODE_TO_NUM = {v: k for k, v in A2_NUM_TO_OPERATING_MODE.items()}

NEW_ADDRESSABLE_NUM_TO_PROTOCOL = {
1: "WS2812B",
2: "SM16703",
Expand Down
2 changes: 1 addition & 1 deletion tests_aio.py
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ def _updated_callback(*args, **kwargs):
)
assert len(transport.mock_calls) == 1
assert transport.mock_calls[0][0] == "write"
assert transport.mock_calls[0][1][0] == b"b\x01,\x00\x02\x06\x02\x19\x02\xf0\xa4"
assert transport.mock_calls[0][1][0] == b"b\x01,\x00\x02\x05\x02\x19\x02\xf0\xa3"

transport.reset_mock()
with patch.object(light, "_async_device_config_resync", mock_coro):
Expand Down

0 comments on commit ac984dd

Please sign in to comment.