@@ -49,6 +49,7 @@ def open_unit(self, serial_number:str=None, resolution:RESOLUTION | resolution_l
4949 self .resolution = resolution
5050 self .set_all_channels_off ()
5151 self .min_adc_value , self .max_adc_value = super ().get_adc_limits ()
52+ self .n_channels = self .get_variant_details ()['NumberOfAnalogueChannels' ]
5253
5354 return usb_power_struct
5455
@@ -214,7 +215,27 @@ def set_led_brightness(self, brightness:int) -> None:
214215 brightness ,
215216 )
216217
217- def set_led_colours (self , led :led_channel_l , hue :int , saturation :int ) -> None :
218+ def set_all_led_colours (self , hue :int | led_colours_l , saturation :int = 100 ) -> None :
219+ """
220+ Sets all LED's on the PicoScope to a single colour
221+
222+ Args:
223+ hue (int | str): Colour as a hue in [0-359] or a
224+ basic colour from the following:
225+ ['red', 'green', 'blue', 'yellow', 'pink']
226+
227+ saturation (int, optional): Saturation of the colour [0-100]. Defaults to 100.
228+ """
229+ led_list = list (led_channel_m .keys ())
230+ led_list = led_list [:self .n_channels ] + led_list [- 2 :]
231+ self .set_led_colours (led_list , [hue ] * len (led_list ), [saturation ] * len (led_list ))
232+
233+ def set_led_colours (
234+ self ,
235+ led :led_channel_l | list [led_channel_l ],
236+ hue :int | led_colours_l | list [int ] | list [led_colours_l ],
237+ saturation :int | list [int ]
238+ ) -> None :
218239 """Sets the colour of the selected LED using HUE and Saturation
219240
220241 It will not take affect until one of the following
@@ -225,22 +246,53 @@ def set_led_colours(self, led:led_channel_l, hue:int, saturation:int) -> None:
225246 - siggen_apply()
226247
227248 Args:
228- led (str): The selected LED. Must be one of these values:
249+ led (str|list[str] ): The selected LED. Must be one or a list of these values:
229250 `'A'`, `'B'`, `'C'`, `'D'`, `'E'`, `'F'`, `'G'`, `'H'`, `'AWG'`, `'AUX'`.
230- hue (int): Hue of the LED, [0-359].
231- saturation (int): Saturation of the LED, [0-100].
251+ hue (int|list[int]): Colour as a hue in [0-359] or a
252+ basic colour from the following:
253+ ['red', 'green', 'blue', 'yellow', 'pink']
254+ saturation (int|list[int]): Saturation of the LED, [0-100].
232255 """
233- self .set_led_states (led , "on" )
234- led = led_channel_m [led ]
235- led_struct = PICO_LED_COLOUR_PROPERTIES (led , hue , saturation )
256+ # if isinstance(hue, str):
257+ # hue = led_colours_m[hue]
258+
259+ if not isinstance (led , list ):
260+ led = [led ]
261+ hue = [hue ]
262+ saturation = [saturation ]
263+
264+ if isinstance (hue [0 ], str ):
265+ hue = [led_colours_m [i ] for i in hue ]
266+
267+ array_len = len (led )
268+ array_struct = (PICO_LED_COLOUR_PROPERTIES * array_len )()
269+
270+ for i in range (array_len ):
271+ array_struct [i ] = PICO_LED_COLOUR_PROPERTIES (
272+ led_channel_m [led [i ]],
273+ hue [i ],
274+ saturation [i ]
275+ )
276+
236277 self ._call_attr_function (
237278 "SetLedColours" ,
238279 self .handle ,
239- led_struct ,
240- 1 ,
280+ ctypes . byref ( array_struct ) ,
281+ array_len ,
241282 )
283+
284+ def set_all_led_states (self ,state :str | led_state_l ):
285+ """
286+ Sets the state of all LED's on the PicoScope.
242287
243- def set_led_states (self , led :str | led_channel_l , state :str | led_state_l ):
288+ Args:
289+ state (str): ['auto', 'on', 'off']
290+ """
291+ led_list = list (led_channel_m .keys ())
292+ led_list = led_list [:self .n_channels ] + led_list [- 2 :]
293+ self .set_led_states (led_list , [state ] * len (led_list ))
294+
295+ def set_led_states (self , led :str | led_channel_l | list [led_channel_l ], state :str | led_state_l | list [led_state_l ]):
244296 """
245297 Sets the state for a selected LED. Between default behaviour (auto),
246298 on or off.
@@ -250,12 +302,22 @@ def set_led_states(self, led:str|led_channel_l, state:str|led_state_l):
250302 `'A'`, `'B'`, `'C'`, `'D'`, `'E'`, `'F'`, `'G'`, `'H'`, `'AWG'`, `'AUX'`.
251303 state (str): State of selected LED: `'auto'`, `'off'`, `'on'`.
252304 """
253- led = led_channel_m [led ]
254- state = led_state_m [state ]
255- struct = PICO_LED_STATE_PROPERTIES (led , state )
305+ if not isinstance (led , list ):
306+ led = [led ]
307+ state = [state ]
308+
309+ array_len = len (led )
310+ array_struct = (PICO_LED_STATE_PROPERTIES * array_len )()
311+
312+ for i in range (array_len ):
313+ array_struct [i ] = PICO_LED_STATE_PROPERTIES (
314+ led_channel_m [led [i ]],
315+ led_state_m [state [i ]]
316+ )
317+
256318 self ._call_attr_function (
257319 'SetLedStates' ,
258320 self .handle ,
259- struct ,
260- 1
261- )
321+ ctypes . byref ( array_struct ) ,
322+ ctypes . c_uint32 ( array_len )
323+ )
0 commit comments