webduino.module.Button
The Button Class.
Table of Contents
Constructor
webduino.module.Button
-
board -
pin -
buttonMode -
sustainedPressInterval
Parameters:
-
boardwebduino.BoardThe board the button is attached to.
-
pinwebduino.pinThe pin the button is connected to.
-
[buttonMode]Number optionalType of resistor the button is connected to, either Button.PULL_DOWN or Button.PULL_UP.
-
[sustainedPressInterval]Number optionalA period of time when the button is pressed and hold for that long, it would be considered a "sustained press." Measured in ms.
Methods
addListener
-
type -
listener
Add a listener for a certain type of event.
Parameters:
-
typeStringEvent type.
-
listenerFunctionEvent listener.
emit
-
type -
object,...
Emit an event of certain type.
Parameters:
-
typeStringEvent type.
-
[object,...]Object optionalEvent object(s).
listeners
-
type
Return the listener list bound to certain type of event.
Parameters:
-
typeStringEvnet type.
on
-
type -
listener
Alias for EventEmitter.addListener(type, listener)
Parameters:
-
typeStringEvent type.
-
listenerFunctionEvent listener.
once
-
type -
listener
Add a one-time listener for a certain type of event.
Parameters:
-
typeStringEvent type.
-
listenerFunctionEvent listener.
removeAllListeners
-
type
Remove all listeners of certain type.
Parameters:
-
typeStringEvent type.
removeListener
-
type -
listener
Remove a listener for certain type of event.
Parameters:
-
typeStringEvent type.
-
listenerFunctionEvent listener.
setMaxListeners
-
n
Set maximum number of listeners that is allow to bind on an emitter.
Parameters:
-
nNumberNumber of listeners.
Properties
INTERNAL_PULL_UP
Number
const
static
Indicates the internal-pull-up resistor type.
PULL_DOWN
Number
const
static
Indicates the pull-down resistor type.
PULL_UP
Number
const
static
Indicates the pull-up resistor type.
Attributes
Events
ButtonEvent.LONG_PRESS
Fires when a button is long-pressed.
ButtonEvent.PRESS
Fires when a button is pressed.
ButtonEvent.RELEASE
Fires when a button is released.
ButtonEvent.SUSTAINED_PRESS
Fires when a button is sustained-pressed.