Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions openrgb/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ class ModeDirections(IntEnum):


class ModeColors(IntEnum):
"""
Partial list of color_mode values. This is not a comprehensive set so do not use this to unpack.
"""
NONE = 0
PER_LED = 1
MODE_SPECIFIC = 2
Expand Down Expand Up @@ -245,7 +248,7 @@ class ModeData:
speed: Optional[int]
brightness: Optional[int]
direction: Optional[ModeDirections]
color_mode: ModeColors
color_mode: int
colors: Optional[list[RGBColor]]

def validate(self, version: int):
Expand Down Expand Up @@ -329,7 +332,7 @@ def unpack(cls, data: Iterator[int], version: int, index: int = 0) -> ModeData:
else:
brightness = None
direction = parse_var('I', data)
color_mode = ModeColors(parse_var('I', data))
color_mode = parse_var('I', data)
num_colors = parse_var('H', data)

colors = []
Expand All @@ -338,7 +341,10 @@ def unpack(cls, data: Iterator[int], version: int, index: int = 0) -> ModeData:
if (ModeFlags.HAS_DIRECTION_HV in flags
or ModeFlags.HAS_DIRECTION_UD in flags
or ModeFlags.HAS_DIRECTION_LR in flags):
direction = ModeDirections(direction)
try:
direction = ModeDirections(direction)
except ValueError:
direction = None
else:
direction = None
if ModeFlags.HAS_SPEED not in flags:
Expand Down