webduino.module.Button
The Button Class.
Table of Contents
Constructor
webduino.module.Button
-
board
-
pin
-
buttonMode
-
sustainedPressInterval
Parameters:
-
board
webduino.BoardThe board the button is attached to.
-
pin
webduino.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:
-
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.
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.
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.