9
0
Fork 0

add line value and threshold calibration

This commit is contained in:
Silver Kuusik 2018-12-27 09:02:15 +01:00 committed by GitHub
parent 25dd06f4cc
commit 0c580d8c98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 3 deletions

16
hal.py
View File

@ -143,10 +143,20 @@ class Sumorobot(object):
return opponent
# Function to update line calibration and write it to the config file
def calibrate_line(self):
def calibrate_line_value(self):
# Read the line sensor values
self.config["left_line_threshold"] = self.adc_line_left.read()
self.config["right_line_threshold"] = self.adc_line_right.read()
self.config["left_line_value"] = self.adc_line_left.read()
self.config["right_line_value"] = self.adc_line_right.read()
# Update the config file
with open("config.part", "w") as config_file:
config_file.write(ujson.dumps(self.config))
os.rename("config.part", "config.json")
# Function to update line threshold calibration and write it to the config file
def calibrate_line_threshold(self, value):
# Read the line sensor values
self.config["left_line_threshold"] = value
self.config["right_line_threshold"] = value
# Update the config file
with open("config.part", "w") as config_file:
config_file.write(ujson.dumps(self.config))