1414)
1515from blinkstick .decorators import no_backend_required
1616from blinkstick .devices import BlinkStickDevice
17- from blinkstick .enums import BlinkStickVariant
17+ from blinkstick .enums import BlinkStickVariant , Mode
1818from blinkstick .exceptions import NotConnected
1919from blinkstick .utilities import string_to_info_block_data
2020
@@ -373,7 +373,7 @@ def get_led_data(self, count: int) -> list[int]:
373373
374374 return device_bytes [2 : 2 + count * 3 ]
375375
376- def set_mode (self , mode : int ) -> None :
376+ def set_mode (self , mode : Mode | int ) -> None :
377377 """
378378 Set backend mode for BlinkStick Pro. Device currently supports the following modes:
379379
@@ -388,6 +388,10 @@ def set_mode(self, mode: int) -> None:
388388 @type mode: int
389389 @param mode: Device mode to set
390390 """
391+ # If mode is an enum, get the value
392+ # this will allow the user to pass in the enum directly, and also gate the value to the enum values
393+ if not isinstance (mode , int ):
394+ mode = Mode (mode ).value
391395 control_string = bytes (bytearray ([4 , mode ]))
392396
393397 self .backend .control_transfer (0x20 , 0x9 , 0x0004 , 0 , control_string )
0 commit comments