Skip to content

Commit 01a59e4

Browse files
authored
read_position_str() is also needed here to keep in sync with easygopigo3 (DexterInd#283)
1 parent 718aff4 commit 01a59e4

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Software/Python/easygopigo.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,24 @@ def read_position(self):
751751
return "right"
752752
return "unknown"
753753

754+
def read_position_str(self):
755+
"""
756+
returns a string of five letters indicating what the line sensor is seeing.
757+
'b' indicates that specific sensor has detected a black line.
758+
'w' indicates that specific sensor has not detected a black line.
759+
760+
:returns: String indicating what the line follower just read.
761+
:rtype: str
762+
763+
Here's an example of what could get returned:
764+
* ``'bbbbb'`` - when the line follower reads black on all sensors.
765+
* ``'wwbww'`` - when the line follower is perfectly centered.
766+
* ``'bbbww'`` - when the line follower reaches an intersection.
767+
"""
768+
five_vals = self.read()
769+
out_str = "".join(["b" if sensor_val == 1 else "w" for sensor_val in five_vals])
770+
return out_str
771+
754772

755773
#######################################################################
756774
#

0 commit comments

Comments
 (0)