Commit d5e64915 authored by Felix Kettner's avatar Felix Kettner

pep8

parent b75d1121
Pipeline #34322 passed with stage
in 28 seconds
...@@ -50,22 +50,18 @@ class Nano: ...@@ -50,22 +50,18 @@ class Nano:
else: else:
print("Battery voltage okay! ({} mV)".format(voltage)) print("Battery voltage okay! ({} mV)".format(voltage))
def set_stat_led(self, toggle): def set_stat_led(self, toggle):
write_order(self.serial_file, order=Order.STAT_LED) write_order(self.serial_file, order=Order.STAT_LED)
write_i8(self.serial_file, toggle) write_i8(self.serial_file, toggle)
def open_gripper(self): def open_gripper(self):
write_order(self.serial_file, order=Order.GRIPPER) write_order(self.serial_file, order=Order.GRIPPER)
write_i8(self.serial_file, 0) write_i8(self.serial_file, 0)
def close_gripper(self): def close_gripper(self):
write_order(self.serial_file, order=Order.GRIPPER) write_order(self.serial_file, order=Order.GRIPPER)
write_i8(self.serial_file, 1) write_i8(self.serial_file, 1)
def set_motors(self, left, right): def set_motors(self, left, right):
write_order(self.serial_file, order=Order.MOTORS) write_order(self.serial_file, order=Order.MOTORS)
# Write left # Write left
...@@ -73,7 +69,6 @@ class Nano: ...@@ -73,7 +69,6 @@ class Nano:
# Write right # Write right
write_i8(self.serial_file, clamp(right, -128, 127)) write_i8(self.serial_file, clamp(right, -128, 127))
def get_encoders(self): def get_encoders(self):
write_order(self.serial_file, order=Order.GET_ENCODERS) write_order(self.serial_file, order=Order.GET_ENCODERS)
...@@ -81,8 +76,7 @@ class Nano: ...@@ -81,8 +76,7 @@ class Nano:
left = read_i16(self.serial_file) left = read_i16(self.serial_file)
right = read_i16(self.serial_file) right = read_i16(self.serial_file)
return left, right return left, right
def get_line_sensors(self): def get_line_sensors(self):
write_order(self.serial_file, order=Order.GET_LINE_SENSORS) write_order(self.serial_file, order=Order.GET_LINE_SENSORS)
...@@ -92,7 +86,6 @@ class Nano: ...@@ -92,7 +86,6 @@ class Nano:
right = read_i16(self.serial_file) right = read_i16(self.serial_file)
return left, mid, right return left, mid, right
def reset_encoders(self): def reset_encoders(self):
write_order(self.serial_file, order=Order.RESET_ENCODERS) write_order(self.serial_file, order=Order.RESET_ENCODERS)
...@@ -101,7 +94,6 @@ class Nano: ...@@ -101,7 +94,6 @@ class Nano:
write_order(self.serial_file, order=Order.VOLTAGE) write_order(self.serial_file, order=Order.VOLTAGE)
return read_i16(self.serial_file) return read_i16(self.serial_file)
def get_distances(self): def get_distances(self):
write_order(self.serial_file, order=Order.DISTANCES) write_order(self.serial_file, order=Order.DISTANCES)
...@@ -111,7 +103,6 @@ class Nano: ...@@ -111,7 +103,6 @@ class Nano:
right = read_ui8(self.serial_file) right = read_ui8(self.serial_file)
return left, mid, right return left, mid, right
def set_buzzer(self, freq, duration): def set_buzzer(self, freq, duration):
write_order(self.serial_file, order=Order.BUZZER) write_order(self.serial_file, order=Order.BUZZER)
# send the frequency # send the frequency
...@@ -119,48 +110,46 @@ class Nano: ...@@ -119,48 +110,46 @@ class Nano:
# send the duration # send the duration
write_ui16(self.serial_file, duration) write_ui16(self.serial_file, duration)
def get_color_rgb(self): def get_color_rgb(self):
# red # red
GPIO.output(c.COLOR_SENSOR_S2,GPIO.LOW) GPIO.output(c.COLOR_SENSOR_S2,GPIO.LOW)
GPIO.output(c.COLOR_SENSOR_S3,GPIO.LOW) GPIO.output(c.COLOR_SENSOR_S3,GPIO.LOW)
write_order(self.serial_file, order=Order.COLOR) write_order(self.serial_file, order=Order.COLOR)
red = read_i16(self.serial_file) red = read_i16(self.serial_file)
# blue # blue
GPIO.output(c.COLOR_SENSOR_S2,GPIO.LOW) GPIO.output(c.COLOR_SENSOR_S2,GPIO.LOW)
GPIO.output(c.COLOR_SENSOR_S3,GPIO.HIGH) GPIO.output(c.COLOR_SENSOR_S3,GPIO.HIGH)
write_order(self.serial_file, order=Order.COLOR) write_order(self.serial_file, order=Order.COLOR)
blue = read_i16(self.serial_file) blue = read_i16(self.serial_file)
# green # green
GPIO.output(c.COLOR_SENSOR_S2,GPIO.HIGH) GPIO.output(c.COLOR_SENSOR_S2,GPIO.HIGH)
GPIO.output(c.COLOR_SENSOR_S3,GPIO.HIGH) GPIO.output(c.COLOR_SENSOR_S3,GPIO.HIGH)
write_order(self.serial_file, order=Order.COLOR) write_order(self.serial_file, order=Order.COLOR)
green = read_i16(self.serial_file) green = read_i16(self.serial_file)
return red, green, blue return red, green, blue
def get_color(self): def get_color(self):
# red # red
GPIO.output(c.COLOR_SENSOR_S2,GPIO.LOW) GPIO.output(c.COLOR_SENSOR_S2,GPIO.LOW)
GPIO.output(c.COLOR_SENSOR_S3,GPIO.LOW) GPIO.output(c.COLOR_SENSOR_S3,GPIO.LOW)
write_order(self.serial_file, order=Order.COLOR) write_order(self.serial_file, order=Order.COLOR)
red = read_i16(self.serial_file) red = read_i16(self.serial_file)
# blue # blue
GPIO.output(c.COLOR_SENSOR_S2,GPIO.LOW) GPIO.output(c.COLOR_SENSOR_S2,GPIO.LOW)
GPIO.output(c.COLOR_SENSOR_S3,GPIO.HIGH) GPIO.output(c.COLOR_SENSOR_S3,GPIO.HIGH)
write_order(self.serial_file, order=Order.COLOR) write_order(self.serial_file, order=Order.COLOR)
blue = read_i16(self.serial_file) blue = read_i16(self.serial_file)
# green # green
GPIO.output(c.COLOR_SENSOR_S2,GPIO.HIGH) GPIO.output(c.COLOR_SENSOR_S2,GPIO.HIGH)
GPIO.output(c.COLOR_SENSOR_S3,GPIO.HIGH) GPIO.output(c.COLOR_SENSOR_S3,GPIO.HIGH)
write_order(self.serial_file, order=Order.COLOR) write_order(self.serial_file, order=Order.COLOR)
green = read_i16(self.serial_file) green = read_i16(self.serial_file)
if red > green and blue > green: if red > green and blue > green:
return "green" return "green"
elif red > blue and green > blue: elif red > blue and green > blue:
...@@ -169,8 +158,7 @@ class Nano: ...@@ -169,8 +158,7 @@ class Nano:
return "red" return "red"
else: else:
return "none" return "none"
@staticmethod @staticmethod
def reset_nano(): def reset_nano():
GPIO.setmode(GPIO.BCM) GPIO.setmode(GPIO.BCM)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment