@@ -332,25 +332,9 @@ class Device:
332332 name : str
333333 interfaces : list
334334 functions_enabled : dict
335- _pins : dict [int , Pin ] = field (default_factory = dict )
335+ pins : dict [int , Pin ] = field (default_factory = dict )
336336 aux_params : dict = field (default_factory = dict )
337337
338- def get_pin (self , pin_index ) -> Pin :
339- """Return a pin object corresponding to index.
340-
341- :param pin_index: The index of the pin to return.
342- :return: Pin object for provided index.
343- """
344- if pin_index not in self ._pins :
345- raise UOSRuntimeError (
346- f"Pin index { pin_index } doesn't exist for device { self .name } "
347- )
348- return self ._pins [pin_index ]
349-
350- def get_pins (self ) -> set :
351- """Return a set of pin indices known by this device."""
352- return set (self ._pins .keys ())
353-
354338 def get_compatible_pins (self , function : UOSFunction ) -> set :
355339 """Get pins suitable for use with a particular UOS Function.
356340
@@ -366,7 +350,7 @@ def get_compatible_pins(self, function: UOSFunction) -> set:
366350 return set ()
367351 return {
368352 pin_index
369- for pin_index , pin in self ._pins .items ()
353+ for pin_index , pin in self .pins .items ()
370354 if all (
371355 getattr (pin , requirement ) for requirement in function .pin_requirements
372356 )
@@ -386,11 +370,11 @@ def update_adc_samples(self, result: ComResult):
386370 sample_values = result .get_rx_payload (0 )
387371 logger .debug ("Device returned sampled adc values %s" , sample_values )
388372 for sample_index , pin in enumerate (result .tx_packet .payload ):
389- if pin not in self ._pins :
373+ if pin not in self .pins :
390374 raise UOSRuntimeError (
391375 f"Can't update ADC samples on pin { pin } as it's invalid for { self .name } ."
392376 )
393- self ._pins [pin ].adc_reading = ADCSample (
377+ self .pins [pin ].adc_reading = ADCSample (
394378 sample_values [sample_index * 2 : sample_index * 2 + 2 ],
395379 steps = pow (2 , self .aux_params ["adc_resolution" ]),
396380 reference = self .aux_params ["adc_reference" ],
@@ -399,7 +383,7 @@ def update_adc_samples(self, result: ComResult):
399383 "Setting pin %s adc reading to %s" ,
400384 pin ,
401385 # This is a false call as it can't be None here.
402- self ._pins [pin ].adc_reading .value , # type: ignore
386+ self .pins [pin ].adc_reading .value , # type: ignore
403387 )
404388
405389 def update_gpio_samples (self , result : ComResult ):
@@ -412,14 +396,14 @@ def update_gpio_samples(self, result: ComResult):
412396 logger .debug ("Device returned sampled gpio values %s" , sample_values )
413397 for sample_index , pin in enumerate (sample_values ):
414398 pin = result .tx_packet .payload [2 * sample_index ]
415- if pin not in self ._pins :
399+ if pin not in self .pins :
416400 raise UOSRuntimeError (
417401 f"Can't update GPIO samples on pin { pin } as it's invalid for { self .name } ."
418402 )
419- self ._pins [pin ].gpio_reading = DigitalSample (sample_values [sample_index ])
403+ self .pins [pin ].gpio_reading = DigitalSample (sample_values [sample_index ])
420404 logger .debug (
421405 "Setting pin %s gpio reading to %s" ,
422406 pin ,
423407 # This is a false call as it can't be None here.
424- self ._pins [pin ].gpio_reading .value , # type: ignore
408+ self .pins [pin ].gpio_reading .value , # type: ignore
425409 )
0 commit comments