Skip to content

Commit

Permalink
Merge pull request #322 from DexterInd/develop
Browse files Browse the repository at this point in the history
bring in the gopigo2 cleanup into the production branch
  • Loading branch information
RobertLucian authored Mar 11, 2019
2 parents 3eccaef + f7f946e commit 47dba08
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions Software/Python/easygopigo.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,13 @@ def __init__(self,
except:
raise ValueError("Line Follower Library not found")

# Needed for Bloxter
try:
from di_sensors import easy_line_follower
self._lf = easy_line_follower.EasyLineFollower(port=port)
except:
self._lf = None

self.use_mutex = use_mutex

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

# Bloxter Support
def position_bw(self):
"""
This method is only here to support Bloxter and
fake di_sensors.easy_line_follower
"""
try:
return self._lf.position_bw()
except ValueError as e:
print(e)
raise
except Exception as e:
print(e)
return -1

def position_01(self):
"""
This method is only here to support Bloxter and
fake di_sensors.easy_line_follower
"""
try:
return self._lf.position_01()
except:
return -1

def position(self):
"""
This method is only here to support Bloxter and
fake di_sensors.easy_line_follower
"""
try:
return self._lf.position()
except:
return -1

def set_calibration(self, color):
"""
This method is only here to support Bloxter and
fake di_sensors.easy_line_follower
"""
try:
return self._lf.set_calibration(color)
except ValueError as e:
print(e)
except Exception as e:
print(e)
line_val = []

def get_calibration(self, color):
"""
This method is only here to support Bloxter and
fake di_sensors.easy_line_follower
"""
try:
return self._lf.get_calibration(color)
except ValueError as e:
print(e)
except Exception as e:
print(e)
line_val = []

#######################################################################
#
Expand Down

0 comments on commit 47dba08

Please sign in to comment.