removing support for far in ultrasonic (#441)
* removing support for far in ultrasonic * removing more far
This commit is contained in:
parent
e11b11d19c
commit
5277cc847c
@ -15,10 +15,10 @@ The distance value returned is the number of centimeters to the object that the
|
||||
|
||||
## Example
|
||||
|
||||
When the ultrasonic sensor on port 4 detects a far object, display its distance on the screen.
|
||||
When the ultrasonic sensor on port 4 detects a near object, display its distance on the screen.
|
||||
|
||||
```blocks
|
||||
sensors.ultrasonic4.onEvent(UltrasonicSensorEvent.ObjectFar, function () {
|
||||
sensors.ultrasonic4.onEvent(UltrasonicSensorEvent.ObjecNear, function () {
|
||||
brick.showString("Object detected at:", 1)
|
||||
brick.showNumber(sensors.ultrasonic4.distance(), 2)
|
||||
brick.showString("centimeters", 3)
|
||||
|
@ -8,10 +8,9 @@ sensors.ultrasonic1.onEvent(UltrasonicSensorEvent.ObjectDetected, function () {
|
||||
})
|
||||
```
|
||||
|
||||
How an object is detected depends on the distance and movement _thresholds_ set for the sensor. A threshold is a number that is some distance in centimeters or the strength of ultrasonic sound. You can set a distance to detect something that is far, near, or is sending out ultrasound (like the sensor of another robot in the area). The three thresholds you can set are:
|
||||
How an object is detected depends on the distance and movement _thresholds_ set for the sensor. A threshold is a number that is some distance in centimeters or the strength of ultrasonic sound. You can set a distance to detect something that is far, near, or is sending out ultrasound (like the sensor of another robot in the area). The two thresholds you can set are:
|
||||
|
||||
* **near**: a distance to set to detect objects coming close
|
||||
* **far**: a distance to set to detect objects farther away but not as close as the **near** threshold
|
||||
* **detected**: the strength of ultrasound to needed to detect presence of another ultrasonic sensor
|
||||
|
||||
Both **near** and **far** have distance thresholds set in centimeters. The **detect** threshold is a value of strength the ultrasonic sound in decibels.
|
||||
@ -19,17 +18,16 @@ Both **near** and **far** have distance thresholds set in centimeters. The **det
|
||||
## Parameters
|
||||
|
||||
* **event**: the object detection action to wait for. The detection types (events) are:
|
||||
> * ``object detected``: some other object is sending out an ultrasonic sound
|
||||
> * ``object detected``: the detected something that moved
|
||||
> * ``object near``: the sensor detected something within the distance of the near threshold
|
||||
> * ``object far``: the sensor detected somethin within the distance of the far threshold
|
||||
* **handler**: the code you want to run when something is dectected by the ultrasonic sensor.
|
||||
|
||||
## Example
|
||||
|
||||
When the ultrasonic sensor on port 4 detects a far object, display its distance on the screen.
|
||||
When the ultrasonic sensor on port 4 detects a near object, display its distance on the screen.
|
||||
|
||||
```blocks
|
||||
sensors.ultrasonic4.onEvent(UltrasonicSensorEvent.ObjectFar, function () {
|
||||
sensors.ultrasonic4.onEvent(UltrasonicSensorEvent.ObjectNear, function () {
|
||||
brick.showString("Object detected at:", 1)
|
||||
brick.showNumber(sensors.ultrasonic4.distance(), 2)
|
||||
brick.showString("centimeters", 3)
|
||||
|
@ -19,7 +19,6 @@ Both **near** and **far** have distance thresholds set in centimeters. The **det
|
||||
* **event**: the object detection action to wait for. The detection types (events) are:
|
||||
> * ``detected``: some other object is sending out an ultrasonic sound
|
||||
> * ``near``: the sensor detected something within the distance of the near threshold
|
||||
> * ``far``: the sensor detected somethin within the distance of the far threshold
|
||||
|
||||
## Example
|
||||
|
||||
|
@ -8,13 +8,13 @@ sensors.ultrasonic1.setThreshold(UltrasonicSensorEvent.ObjectDetected, 0)
|
||||
|
||||
Whether something is near or far away really depends on the situation. A object moving towards you is "near" at further distance than something that isn't moving due to the time necessary to move out of its way. So, in certain situations you may want change which distances mean near or far.
|
||||
|
||||
You can change the distances for near and far by setting their _thresholds_. A threshold is a boundary or a limit. If you wanted near to mean anything that's closer that 20 centimeters, then that is your threshold for ``near``. Also, if anything further than 35 centimeters is thought of as far, then the threshold for ``far`` is `35`.
|
||||
You can change the distances for near and far by setting their _thresholds_. A threshold is a boundary or a limit. If you wanted near to mean anything that's closer that 20 centimeters, then that is your threshold for ``near``.
|
||||
|
||||
Similarly, if you are just concerned about knowing that something has moved within a distance from you, then you set that distance as the threshold for ``detected``.
|
||||
|
||||
## Parameters
|
||||
|
||||
* **condition**: the threshold condition to set a distance for. These are: ``near``, ``far``, and ``detected``.
|
||||
* **condition**: the threshold condition to set a distance for. These are: ``near`` and ``detected``.
|
||||
* **value**: a [number](/types/number) that the distance in centimeters to set the threshold for.
|
||||
|
||||
## Example
|
||||
|
@ -6,15 +6,15 @@ Get the distance threshold for when objects are near, far, or detected.
|
||||
sensors.ultrasonic1.threshold(UltrasonicSensorEvent.ObjectDetected)
|
||||
```
|
||||
|
||||
Whether something is near or far away really depends on the situation. A object moving towards you is "near" at further distance than something that isn't moving due to the time necessary to move out of its way.
|
||||
Whether something is near really depends on the situation. A object moving towards you is "near" at further distance than something that isn't moving due to the time necessary to move out of its way.
|
||||
|
||||
Distances for near and far by have set _thresholds_. A threshold is a boundary or a limit. If near means anything that's closer that 20 centimeters, then the threshold for ``near``. Also, if anything further than 35 centimeters is thought of as far, then the threshold for ``far`` is `35`.
|
||||
Distances for near have set _thresholds_. A threshold is a boundary or a limit. If near means anything that's closer that 20 centimeters, then the threshold for ``near``.
|
||||
|
||||
Also, the threshold for nowing that something has moved within a distance from you is set for ``detected``.
|
||||
|
||||
## Parameters
|
||||
|
||||
* **condition**: the condition to get the threshold distance for. These are: ``near``, ``far``, and ``detected``.
|
||||
* **condition**: the condition to get the threshold distance for. These are: ``near`` and ``detected``.
|
||||
|
||||
## Returns
|
||||
|
||||
|
@ -2,9 +2,7 @@ enum UltrasonicSensorEvent {
|
||||
//% block="object detected"
|
||||
ObjectDetected = 10,
|
||||
//% block="object near"
|
||||
ObjectNear = sensors.ThresholdState.Low,
|
||||
//% block="object far"
|
||||
ObjectFar = sensors.ThresholdState.High
|
||||
ObjectNear = sensors.ThresholdState.Low
|
||||
}
|
||||
|
||||
namespace sensors {
|
||||
@ -43,7 +41,7 @@ namespace sensors {
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers code to run when an object is close or far
|
||||
* Registers code to run when an object is close or detected
|
||||
* @param handler the code to run when detected
|
||||
*/
|
||||
//% help=sensors/ultrasonic/on-event
|
||||
@ -94,7 +92,7 @@ namespace sensors {
|
||||
|
||||
/**
|
||||
* Sets a threshold value
|
||||
* @param condition the dark or bright light condition
|
||||
* @param condition the near or detected condition
|
||||
* @param value the value threshold
|
||||
*/
|
||||
//% blockId=ultrasonicSetThreshold block="set **ultrasonic** %this|%condition|to %value"
|
||||
@ -104,7 +102,6 @@ namespace sensors {
|
||||
setThreshold(condition: UltrasonicSensorEvent, value: number) {
|
||||
switch (condition) {
|
||||
case UltrasonicSensorEvent.ObjectNear: this.promixityThreshold.setLowThreshold(value); break;
|
||||
case UltrasonicSensorEvent.ObjectFar: this.promixityThreshold.setHighThreshold(value); break;
|
||||
case UltrasonicSensorEvent.ObjectDetected: this.movementThreshold = value; break;
|
||||
}
|
||||
}
|
||||
@ -119,7 +116,6 @@ namespace sensors {
|
||||
threshold(condition: UltrasonicSensorEvent): number {
|
||||
switch (condition) {
|
||||
case UltrasonicSensorEvent.ObjectNear: this.promixityThreshold.threshold(ThresholdState.Low); break;
|
||||
case UltrasonicSensorEvent.ObjectFar: this.promixityThreshold.threshold(ThresholdState.Low); break;
|
||||
case UltrasonicSensorEvent.ObjectDetected: this.movementThreshold; break;
|
||||
}
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user