QuirkyCort / ev3dev-sim

Browser based simulator for ev3dev-lang-python
GNU General Public License v3.0
14 stars 8 forks source link

Ultrasonic sensor missing the SENSOR_DELAY : possible javascript tread lock #9

Closed loikun closed 4 years ago

loikun commented 4 years ago

I plan to use this nice simulator for an online teaching due to a coronavirus containment period. I notice that a short ev3dev python script example:

from ev3dev2.sensor import *
from ev3dev2.sensor.lego import UltrasonicSensor

ultrasonic = UltrasonicSensor(INPUT_1)
while True:
    print('Ultrasonic: ' + str(ultrasonic.distance_centimeters))

locks the browser tab.

A solution seems to be , as implemented for the other sensors, to add time.sleep(SENSOR_DELAY) in all the ultrasonic sensor function of sensors/lego.py. Best regards

QuirkyCort commented 4 years ago

You're right. I'm surprised I missed that out. Fixed.