@@ -46,12 +46,9 @@ def __init__(
46
46
self .pwm_generator = PWMGenerator (device = self )
47
47
self .multimeter = Multimeter (device = self )
48
48
self .power_supply = PowerSupply (device = self )
49
- self .i2c = I2CMaster (device = self )
50
- self .spi = SPIMaster (device = self )
51
- self .nrf = NRF24L01 (device = self )
52
-
53
- if "V6" in self .version : # Set the built-in WS2812B to green :)
54
- self .rgb_led ([0 , 20 , 0 ])
49
+ # self.i2c = I2CMaster(device=self)
50
+ # self.spi = SPIMaster(device=self)
51
+ # self.nrf = NRF24L01(device=self)
55
52
56
53
@property
57
54
def temperature (self ):
@@ -105,7 +102,7 @@ def _get_ctmu_voltage(self, channel: int, current_range: int, tgen: bool = True)
105
102
self .get_ack ()
106
103
vmax = 3.3
107
104
resolution = 12
108
- voltage = vmax * raw_voltage / (2 ** resolution - 1 )
105
+ voltage = vmax * raw_voltage / (2 ** resolution - 1 )
109
106
return voltage
110
107
111
108
def _start_ctmu (self , current_range : int , trim : int , tgen : int = 1 ):
@@ -160,15 +157,17 @@ def rgb_led(self, colors: List, output: str = "RGB", order: str = "GRB"):
160
157
161
158
>>> psl.rgb_led([[10,0,0],[0,10,10],[10,0,10]], output="SQ1", order="RGB")
162
159
"""
163
- if output == "RGB" :
164
- pin = CP .SET_RGB1
165
- elif output == "PGC" :
166
- pin = CP .SET_RGB2
167
- elif output == "SQ1" :
168
- pin = CP .SET_RGB3
160
+ if "6" in self .version :
161
+ pins = {"ONBOARD" : 0 , "SQ1" : 1 , "SQ2" : 2 , "SQ3" : 3 , "SQ4" : 4 }
169
162
else :
163
+ pins = {"RGB" : CP .SET_RGB1 , "PGC" : CP .SET_RGB2 , "SQ1" : CP .SET_RGB3 }
164
+
165
+ try :
166
+ pin = pins [output ]
167
+ except KeyError :
168
+ pinnames = ", " .join (pins .keys ())
170
169
raise ValueError (
171
- f"Invalid output: { output } . output must be 'RGB', 'PCG', or 'SQ1' ."
170
+ f"Invalid output: { output } . output must be one of { pinnames } ."
172
171
)
173
172
174
173
if not isinstance (colors [0 ], Iterable ):
@@ -185,14 +184,22 @@ def rgb_led(self, colors: List, output: str = "RGB", order: str = "GRB"):
185
184
)
186
185
187
186
self .send_byte (CP .COMMON )
188
- self .send_byte (pin )
187
+
188
+ if "6" in self .version :
189
+ self .send_byte (CP .SET_RGB_COMMON )
190
+ else :
191
+ self .send_byte (pin )
192
+
189
193
self .send_byte (len (colors ) * 3 )
190
194
191
195
for color in colors :
192
196
self .send_byte (color [order .index ("R" )])
193
197
self .send_byte (color [order .index ("G" )])
194
198
self .send_byte (color [order .index ("B" )])
195
199
200
+ if "6" in self .version :
201
+ self .send_byte (pin )
202
+
196
203
self .get_ack ()
197
204
198
205
def _read_program_address (self , address : int ):
0 commit comments