print ('Connected') leds.set_color('LEFT', 'GREEN') leds.set_color('RIGHT', 'GREEN') while True: data = client.recv(size) if data: #print(data, file=sys.stderr) cmd = Command.unpickled(data) if cmd: leftMotor.on(speed=cmd.left_drive) rightMotor.on(speed=cmd.right_drive) do_kick = cmd.do_kick > 0 if do_kick != kicking: kicking = do_kick if do_kick: kickMotor.run_to_abs_pos(position_sp=-100, speed_sp=kick_power*max_kick//screenh, stop_action="hold") kick_power = kick_power - (25 if kick_power > 25 else kick_power) else: kickMotor.run_to_abs_pos(position_sp=-10, speed_sp=200, stop_action="coast") kick_power = kick_power + (1 if kick_power < screenh else 0) display.rectangle(x1=0, y1=0, x2=screenw, y2=kick_power) display.update() except: #print("Closing socket") client.close() s.close()
#!/usr/bin/env python3 from ev3dev2.display import Display from time import sleep lcd = Display() # Draw a circle of ‘radius’ centered at (x, y) lcd.circle(clear_screen=False, x=89, y=64, radius=61, fill_color='lightgrey') lcd.circle(False, x=65, y=45, radius=10, fill_color='black') lcd.circle(False, x=113, y=45, radius=10, fill_color='black') # Draw a line from (x1, y1) to (x2, y2) lcd.line(False, x1=89, y1=50, x2=89, y2=80, line_color='grey', width=4) # Draw a rectangle where the top left corner is at (x, y) # and the bottom right corner is at (width, height). # Some parameter names are incorrect so have been omitted! lcd.rectangle(False, 69, 90, 109, 105, fill_color='grey') # Draw a single pixel at (x, y) lcd.point(False, x=65, y=45, point_color='white') lcd.point(False, x=113, y=45, point_color='white') lcd.update() sleep(10)