11from component import Component , PortType , InvalidPortException
2- from collections .abc import Callable , Protocol
2+ from collections .abc import Protocol
33
44class DistanceCallable (Protocol ):
55 def __call__ (self , distance : float ) -> None :
@@ -11,7 +11,6 @@ def __call__(self, hue : int, saturation : int, value : int) -> None:
1111class ColorRangeSensor (Component ):
1212 # Required methods
1313 def __init__ (self , ports : list [tuple [PortType , int ]]):
14- self .is_pressed = None
1514 portType , port = ports [0 ]
1615 if portType != PortType .I2C_PORT :
1716 raise InvalidPortException
@@ -37,27 +36,29 @@ def periodic(self) -> None:
3736 pass
3837
3938 # Component specific methods
40- def get_color_rgb (self ) -> list [int , int , int ]:
39+ def get_color_rgb (self ) -> tuple [int , int , int ]:
4140 '''gets the color in rgb (red, green, blue)'''
4241 pass
43- def get_color_hsv (self ) -> list [int , int , int ]:
42+ def get_color_hsv (self ) -> tuple [int , int , int ]:
4443 '''gets the color in hsv (hue, saturation, value)'''
4544 pass
4645 def get_distance_mm (self ) -> float :
4746 '''gets the distance of the object seen'''
4847 pass
4948
50- def register_when_less_than_distance (self , distance : float , callback : DistanceCallable ) -> None :
49+ def register_when_less_than_distance (self , distance : float ,
50+ callback : DistanceCallable ) -> None :
5151 '''Event when item is seen closer than a distance'''
5252 self .less_than_distance_callback = callback
5353
54- def register_when_hue_in_range (self , min_hue : int , max_hue : int , callback : ColorCallable ) -> None :
54+ def register_when_hue_in_range (self , min_hue : int ,
55+ max_hue : int ,
56+ callback : ColorCallable ) -> None :
5557 '''Event when hue is in range'''
5658 self .hue_in_range_callback = callback
5759
58- def register_when_saturation_in_range (self , min_saturation : int , max_saturation : int , callback : ColorCallable ) -> None :
60+ def register_when_saturation_in_range (self , min_saturation : int ,
61+ max_saturation : int ,
62+ callback : ColorCallable ) -> None :
5963 '''Event when saturation is in range'''
60- self .saturation_in_range_callback = callback
61-
62-
63-
64+ self .saturation_in_range_callback = callback
0 commit comments