Repository navigation
Update demos for python3 - #205
Conversation
|
Some fixes for #204 |
| def fire_ball(self, state): | ||
| if state: | ||
| self.medium_motor.run_to_rel_pos(duty_cycle_sp=100, position_sp=3*360) | ||
| self.medium_motor.run_to_rel_pos(speed_sp=100, position_sp=3*360) |
There was a problem hiding this comment.
duty_cycle_sp and speed_sp use different units of measurement, so you are also changing the effective speed here. For large motors you can multiply by 10 to get close enough. e.g. This should be speed_sp=100.
There was a problem hiding this comment.
ah, did not realize that. What should I multiply by for medium motors?
| * jQuery UI Touch Punch 0.2.3 | ||
| * | ||
| * Copyright 2011–2014, Dave Furfero | ||
| * Copyright 2011-2014, Dave Furfero |
There was a problem hiding this comment.
The original - above was not an ascii character, the web server was unable to serve jquery.ui.touch-punch.min.js due to it containing a non-ascii character.
| with open(filename, 'w') as fh: | ||
| fh.write(current_platform + '\n') | ||
|
|
||
| if current_platform == 'brickpi': |
There was a problem hiding this comment.
These changes allow us to avoid import platform and running platform.machine() every time the user runs a program that imports ev3dev.auto. This saves us about 1s.
| import re | ||
| import stat | ||
| from os.path import abspath | ||
| from PIL import Image, ImageDraw |
There was a problem hiding this comment.
With python3, this import takes 42s so only import when needed.
| stop_mode_choices = (ev3dev.auto.Motor.STOP_COMMAND_COAST, | ||
| ev3dev.auto.Motor.STOP_COMMAND_BRAKE, | ||
| ev3dev.auto.Motor.STOP_COMMAND_HOLD) | ||
|
|
There was a problem hiding this comment.
These no longer exists
| import time | ||
| import ev3dev.auto | ||
| from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer | ||
| from http.server import BaseHTTPRequestHandler, HTTPServer |
There was a problem hiding this comment.
python2 vs. python3 change
| else: | ||
| # Open as plain text and encode | ||
| with open(filename, mode='r') as fh: | ||
| self.wfile.write(fh.read().encode()) |
There was a problem hiding this comment.
python2 vs. python3 change
No description provided.