Page 1 of 1

What is the usecase for the methods: disable and enable on the sensor EV3UltrasonicSensor

Posted: Sat Mar 24, 2018 6:43 pm
by esmetaman
Hi Andy,

The EV3 Sensor Ultrasonic Sensor has 2 methods: enable & disable:
http://www.lejos.org/ev3/docs/lejos/har ... ensor.html

And I would like to know what is the use case for that methods.

Reviewed other EV3Sensors, I didnĀ“t see that methods:
http://www.lejos.org/ev3/docs/lejos/har ... ensor.html
http://www.lejos.org/ev3/docs/lejos/har ... ensor.html
http://www.lejos.org/ev3/docs/lejos/har ... ensor.html
http://www.lejos.org/ev3/docs/lejos/har ... ensor.html

Many thanks in advance

Juan Antonio

Re: What is the usecase for the methods: disable and enable on the sensor EV3UltrasonicSensor

Posted: Sat Mar 24, 2018 8:19 pm
by gloomyandy
I assume you have read the documentation? It tells you one use case, it lets you turn the LED surrounding the sensor on and off (see this now very old video...)
https://www.youtube.com/watch?v=NhMYSSVzw14
turning the sensors LED on and off in this video is performed using enable/disable. However they also have other uses. You may have multiple ultrasonic sensors on the same robot, trying to use two at the same time will probably end up with interference between them. Using enable/disable allows you to have just one running with the others turned off. As with most of these lower level functions they simply reflect what functionality the hardware has, the Ultrasonic sensor has a disabled mode (mode 3) so we make that available for use. In effect any mode other than 3 is enabled, calling enable simply sets the sensor to the default mode (mode 0).

Re: What is the usecase for the methods: disable and enable on the sensor EV3UltrasonicSensor

Posted: Sat Mar 24, 2018 11:39 pm
by esmetaman
Many thanks Andy for the clarification,

I will try to implement both methods using the EV3Dev API:
http://docs.ev3dev.org/projects/lego-li ... 3-us-modes

Related issue:
https://github.com/ev3dev-lang-java/ev3 ... issues/436

Cheers

Juan Antonio