webduino.module.Ultrasonic
The Ultrasonic class.
Table of Contents
Constructor
webduino.module.Ultrasonic
-
board
-
trigger
-
echo
Parameters:
-
board
webduino.BoardThe board the ultrasonic sensor is attached to.
-
trigger
webduino.PinThe trigger pin the sensor is connected to.
-
echo
webduino.PinThe echo pin the sensor is connected to.
Methods
addListener
-
type
-
listener
Add a listener for a certain type of event.
Parameters:
-
type
StringEvent type.
-
listener
FunctionEvent listener.
emit
-
type
-
object,...
Emit an event of certain type.
Parameters:
-
type
StringEvent type.
-
[object,...]
Object optionalEvent object(s).
listeners
-
type
Return the listener list bound to certain type of event.
Parameters:
-
type
StringEvnet type.
on
-
type
-
listener
Alias for EventEmitter.addListener(type, listener)
Parameters:
-
type
StringEvent type.
-
listener
FunctionEvent listener.
once
-
type
-
listener
Add a one-time listener for a certain type of event.
Parameters:
-
type
StringEvent type.
-
listener
FunctionEvent listener.
ping
-
callback
-
interval
Transmit an ultrasonic to sense the distance at a (optional) given interval.
Parameters:
-
[callback]
Function optionalCallback when a response is returned.
-
[interval]
Number optionalInterval between each transmission. If omitted the ultrasonic will be transmitted once.
Returns:
A promise when the ping response is returned. Will not return anything if a callback function is given.
removeAllListeners
-
type
Remove all listeners of certain type.
Parameters:
-
type
StringEvent type.
removeListener
-
type
-
listener
Remove a listener for certain type of event.
Parameters:
-
type
StringEvent type.
-
listener
FunctionEvent listener.
setMaxListeners
-
n
Set maximum number of listeners that is allow to bind on an emitter.
Parameters:
-
n
NumberNumber of listeners.
stopPing
()
Stop transmitting any ultrasonic.
Attributes
Events
UltrasonicEvent.PING
Fires when receiving a ping response.
UltrasonicEvent.PING_ERROR
Fires when receiving a ping-error response.