Skip to content

Commit e7ab95b

Browse files
committed
feat: get_distance_top
get_distance_bottom fix: get methods using conversions must always return floats
1 parent cb2a602 commit e7ab95b

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

arduino_alvik.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ def get_color_raw(self) -> (int, int, int):
541541
# int((self.green/COLOR_FULL_SCALE)*255),
542542
# int((self.blue/COLOR_FULL_SCALE)*255))
543543

544-
def get_distance(self, unit: str = 'cm') -> (int, int, int, int, int):
544+
def get_distance(self, unit: str = 'cm') -> (float, float, float, float, float):
545545
"""
546546
Returns the distance readout of the TOF sensor
547547
:param unit: distance output unit
@@ -553,6 +553,22 @@ def get_distance(self, unit: str = 'cm') -> (int, int, int, int, int):
553553
convert_distance(self.center_right_tof, 'mm', unit),
554554
convert_distance(self.right_tof, 'mm', unit))
555555

556+
def get_distance_top(self, unit: str = 'cm') -> float:
557+
"""
558+
Returns the obstacle top distance readout
559+
:param unit:
560+
:return:
561+
"""
562+
return convert_distance(self.top_tof, 'mm', unit)
563+
564+
def get_distance_bottom(self, unit: str = 'cm') -> float:
565+
"""
566+
Returns the obstacle bottom distance readout
567+
:param unit:
568+
:return:
569+
"""
570+
return convert_distance(self.bottom_tof, 'mm', unit)
571+
556572
def get_version(self) -> str:
557573
"""
558574
Returns the firmware version of the Alvik

0 commit comments

Comments
 (0)