BO.Pin Class
Each analog and digital pin of the physical I/O board is represented by a Pin object. The Pin object is the foundation for many of the io objects and is also very useful on its own. See the Using The Pin Object Guide on http://breakoutjs.com for a detailed overview.
Constructor
BO.Pin
-
number
-
type
Parameters:
-
number
NumberThe pin number
-
type
NumberThe type of pin
Item Index
Methods
Properties
- analogNumber
- analogReadResolution
- analogWriteResolution
- average
- filters
- generator
- lastValue
- maximum
- minimum
- number
- Pin.AIN static
- Pin.AOUT static
- Pin.DIN static
- Pin.DOUT static
- Pin.HIGH static
- Pin.I2C static
- Pin.INPUT_PULLUP static
- Pin.LOW static
- Pin.OFF static
- Pin.ON static
- Pin.ONEWIRE static
- Pin.PWM static
- Pin.SERIAL static
- Pin.SERIAL static
- Pin.SERVO static
- Pin.SHIFT static
- Pin.STEPPER static
- Pin.TOTAL_PIN_MODES static
- preFilterValue
- state
- value
Events
Methods
addEventListener
-
type
-
listener
Parameters:
-
type
StringThe event type
-
listener
FunctionThe function to be called when the event is fired
addFilter
-
newFilter
Add a new filter to the Pin.
Parameters:
-
newFilter
FilterBaseA filter object that extends FilterBase.
addGenerator
-
newGenerator
Add a new generator to the Pin. A pin can only have one generator assigned. Assigning a new generator will replace the previously assigned generator.
Parameters:
-
newGenerator
GeneratorBaseA generator object that extends GeneratorBase.
applyFilters
()
private
autoSetValue
()
private
calculateMinMaxAndMean
()
private
From funnel Pin.as
clear
()
Resets the minimum, maximum, average and lastValue of the pin.
clearWeight
()
private
From funnel Pin.as
detectChange
()
private
Dispatch a Change event whenever a pin value changes
dispatchEvent
-
type
-
optionalParams
Parameters:
-
type
EventThe Event object.
-
optionalParams
ObjectOptional parameters passed as an object. return {boolean} True if dispatch is successful, false if not.
getCapabilities
()
Object
An object storing the capabilities of the pin.
Returns:
An object describing the capabilities of this Pin.
getType
()
Number
The type/mode of the pin (0: DIN, 1: DOUT, 2: AIN, 3: AOUT / PWM, 4: SERVO, 5: SHIFT, 6: I2C). Use IOBoard.setDigitalPinMode(pinNumber) to set the pin type.
Returns:
The pin type/mode
hasEventListener
-
type
Parameters:
-
type
StringThe event type return {boolean} True is listener exists for this type, false if not.
removeAllFilters
()
Removes all filters from the pin.
removeEventListener
-
type
-
listener
Parameters:
-
type
StringThe event type
-
listener
FunctionThe function to be called when the event is fired
removeFilter
-
filterToRemove
Remove a specified filter from the Pin.
Parameters:
-
filterToRemove
FilterBaseThe filter to remove.
removeGenerator
()
Removes the generator from the pin.
Properties
analogNumber
Number
[read-only] The analog pin number used by the IOBoard (printed on board or datasheet).
analogReadResolution
Number
[read-only] The analog read resolution for this pin.
This is the analog read resolution specified by Arduino rather than the resolution specified by the microcontroller datasheet.
analogWriteResolution
Number
[read-only] The analog write (PWM) resolution for this pin.
This is the PWM resolution specified by Arduino rather than the resolution specified by the microcontroller datasheet.
average
Number
[read-only] The average value of the pin over time. Call clear() to reset.
filters
FilterBase
Get and set filters for the Pin.
generator
GeneratorBase
[read-only] Get a reference to the current generator.
lastValue
Number
[read-only] The last pin value.
maximum
Number
[read-only] The maximum value of the pin over time. Call clear() to reset.
minimum
Number
[read-only] The minimum value of the pin over time. Call clear() to reset.
number
Number
[read-only] The pin number corresponding to the Arduino documentation for the type of board.
Pin.AIN
Unknown
static
Pin.AOUT
Unknown
static
Pin.DIN
Unknown
static
Pin.DOUT
Unknown
static
Pin.HIGH
Unknown
static
Pin.I2C
Unknown
static
Pin.INPUT_PULLUP
Unknown
static
Pin.LOW
Unknown
static
Pin.OFF
Unknown
static
Pin.ON
Unknown
static
Pin.ONEWIRE
Unknown
static
Pin.PWM
Unknown
static
Pin.SERIAL
Unknown
static
Placeholder only - not yet supported
Pin.SERIAL
Unknown
static
Pin.SERVO
Unknown
static
Pin.SHIFT
Unknown
static
Pin.STEPPER
Unknown
static
Pin.TOTAL_PIN_MODES
Unknown
static
preFilterValue
Number
[read-only] The value before any filters were applied.
state
Number
[read-only] The state of the pin. For output modes, the state is any value that has been previously written to the pin. For input modes, the state is typically zero, however for digital inputs the state is the status of the pullup resistor.
This propery is populated by calling the queryPinState method of the IOBoard object. This is useful if there are multiple client applications connected to a single physical IOBoard and you want to get the state of a pin that is set by another client application.
value
Number
The current digital or analog value of the pin.
Events
fallingEdge
BO.PinEvent.FALLING_EDGE
The change event is dispatched when the pin value decreased (from 1 to 0).
Event Payload:
-
target
BO.PinA reference to the Pin object.
pinChange
BO.PinEvent.CHANGE
The pinChange event is dispatched when the pin value changes.
Event Payload:
-
target
BO.PinA reference to the Pin object.
risingEdge
BO.PinEvent.RISING_EDGE
The risingEdge event is dispatched when the pin value increased (from 0 to 1).
Event Payload:
-
target
BO.PinA reference to the Pin object.