Skip to content

Commit 47dba08

Browse files
authored
Merge pull request #322 from DexterInd/develop
bring in the gopigo2 cleanup into the production branch
2 parents 3eccaef + f7f946e commit 47dba08

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

Software/Python/easygopigo.py

+67
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,13 @@ def __init__(self,
686686
except:
687687
raise ValueError("Line Follower Library not found")
688688

689+
# Needed for Bloxter
690+
try:
691+
from di_sensors import easy_line_follower
692+
self._lf = easy_line_follower.EasyLineFollower(port=port)
693+
except:
694+
self._lf = None
695+
689696
self.use_mutex = use_mutex
690697

691698
def read_raw_sensors(self):
@@ -821,6 +828,66 @@ def read_position_str(self):
821828
out_str = "".join(["b" if sensor_val == 1 else "w" for sensor_val in five_vals])
822829
return out_str
823830

831+
# Bloxter Support
832+
def position_bw(self):
833+
"""
834+
This method is only here to support Bloxter and
835+
fake di_sensors.easy_line_follower
836+
"""
837+
try:
838+
return self._lf.position_bw()
839+
except ValueError as e:
840+
print(e)
841+
raise
842+
except Exception as e:
843+
print(e)
844+
return -1
845+
846+
def position_01(self):
847+
"""
848+
This method is only here to support Bloxter and
849+
fake di_sensors.easy_line_follower
850+
"""
851+
try:
852+
return self._lf.position_01()
853+
except:
854+
return -1
855+
856+
def position(self):
857+
"""
858+
This method is only here to support Bloxter and
859+
fake di_sensors.easy_line_follower
860+
"""
861+
try:
862+
return self._lf.position()
863+
except:
864+
return -1
865+
866+
def set_calibration(self, color):
867+
"""
868+
This method is only here to support Bloxter and
869+
fake di_sensors.easy_line_follower
870+
"""
871+
try:
872+
return self._lf.set_calibration(color)
873+
except ValueError as e:
874+
print(e)
875+
except Exception as e:
876+
print(e)
877+
line_val = []
878+
879+
def get_calibration(self, color):
880+
"""
881+
This method is only here to support Bloxter and
882+
fake di_sensors.easy_line_follower
883+
"""
884+
try:
885+
return self._lf.get_calibration(color)
886+
except ValueError as e:
887+
print(e)
888+
except Exception as e:
889+
print(e)
890+
line_val = []
824891

825892
#######################################################################
826893
#

0 commit comments

Comments
 (0)