@@ -35,19 +35,63 @@ def _mapi(self, x, in_min, in_max, out_min, out_max) -> int:
3535 return int (self ._map (x , in_min , in_max , out_min , out_max ))
3636
3737 def set_range_rgb (self , index_from , index_to , r , g , b , brightness = 100 ):
38+ """
39+ Sets the color of the LEDs in the given range to the given RGB values.
40+
41+ Parameters:
42+ index_from (int): The starting index of the range.
43+ index_to (int): The ending index (inclusive) of the range.
44+ r (int): The red value of the color.
45+ g (int): The green value of the color.
46+ b (int): The blue value of the color.
47+ brightness (int): The brightness of the LED. It should be a value between 0 and 100.
48+ """
3849 self .set_range_color (index_from , index_to , ModulinoColor (r , g , b ), brightness )
3950
4051 def set_range_color (self , index_from , index_to , color , brightness = 100 ):
52+ """
53+ Sets the color of the LEDs in the given range to the given color.
54+
55+ Parameters:
56+ index_from (int): The starting index of the range.
57+ index_to (int): The ending index (inclusive) of the range.
58+ color (ModulinoColor): The color of the LEDs.
59+ brightness (int): The brightness of the LED. It should be a value between 0 and 100.
60+ """
4161 for i in range (index_from , index_to + 1 ):
4262 self .set_color (i , color , brightness )
4363
4464 def set_all_rgb (self , r , g , b , brightness = 100 ):
65+ """
66+ Sets the color of all the LEDs to the given RGB values.
67+
68+ Parameters:
69+ r (int): The red value of the color.
70+ g (int): The green value of the color.
71+ b (int): The blue value of the color.
72+ brightness (int): The brightness of the LED. It should be a value between 0 and 100.
73+ """
4574 self .set_all_color (ModulinoColor (r , g , b ), brightness )
4675
4776 def set_all_color (self , color , brightness = 100 ):
77+ """
78+ Sets the color of all the LEDs to the given color.
79+
80+ Parameters:
81+ color (ModulinoColor): The color of the LEDs.
82+ brightness (int): The brightness of the LED. It should be a value between 0 and 100.
83+ """
4884 self .set_range_color (0 , NUM_LEDS - 1 , color , brightness )
4985
5086 def set_color (self , idx , rgb : ModulinoColor , brightness = 100 ):
87+ """
88+ Sets the color of the given LED index to the given color.
89+
90+ Parameters:
91+ idx (int): The index of the LED.
92+ rgb (ModulinoColor): The color of the LED.
93+ brightness (int): The brightness of the LED. It should be a value between 0 and 100.
94+ """
5195 if idx < 0 or idx >= NUM_LEDS :
5296 raise ValueError (f"LED index out of range { idx } (Valid: 0..{ NUM_LEDS - 1 } )" )
5397
@@ -57,17 +101,43 @@ def set_color(self, idx, rgb : ModulinoColor , brightness=100):
57101 self .data [byte_index : byte_index + 4 ] = color_data_bytes .to_bytes (4 , 'little' )
58102
59103 def set_rgb (self , idx , r , g , b , brightness = 100 ):
104+ """
105+ Set the color of the given LED index to the given RGB values.
106+
107+ Parameters:
108+ idx (int): The index of the LED.
109+ r (int): The red value of the color.
110+ g (int): The green value of the color.
111+ b (int): The blue value of the color.
112+ brightness (int): The brightness of the LED. It should be a value between 0 and 100.
113+ """
60114 self .set_color (idx , ModulinoColor (r , g , b ), brightness )
61115
62116 def clear (self , idx ):
117+ """
118+ Turns off the LED at the given index.
119+
120+ Parameters:
121+ idx (int): The index of the LED.
122+ """
63123 self .set_color (idx , ModulinoColor (0 , 0 , 0 ), 0 )
64124
65125 def clear_range (self , start , end ):
66126 for i in range (start , end ):
67127 self .clear (i )
68128
69129 def clear_all (self ):
130+ """
131+ Turns all the LEDs off.
132+
133+ Parameters:
134+ idx (int): The index of the LED
135+ """
70136 self .data = bytearray ([0xE0 ] * NUM_LEDS * 4 )
71137
72138 def show (self ):
139+ """
140+ Applies the changes to the LEDs. This function needs to be called after any changes to the LEDs.
141+ Otherwise, the changes will not be visible.
142+ """
73143 self .write (self .data )
0 commit comments