BO.io.Potentiometer Class
Creates an interface to an analog input sensor. This may be a potentiometer (dial) or any other analog input that is connected to a single analog pin.
Constructor
BO.io.Potentiometer
-
board
-
pin
-
enableSmoothing
Parameters:
-
board
IOBoardA reference to the IOBoard instance that the servo is attached to.
-
pin
PinA reference to the Pin the potentiometer is connected to.
-
enableSmoothing
BooleanTrue to enable smoothing, false to disable. Default is false.
Item Index
Methods
Properties
Events
Methods
addEventListener
-
type
-
listener
Parameters:
-
type
StringThe event type
-
listener
FunctionThe function to be called when the event is fired
clear
()
Resets the minimum, maximum, and average values.
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.
hasEventListener
-
type
Parameters:
-
type
StringThe event type return {boolean} True is listener exists for this type, false if not.
onPinChange
()
private
removeEventListener
-
type
-
listener
Parameters:
-
type
StringThe event type
-
listener
FunctionThe function to be called when the event is fired
setRange
-
minimum
-
maximum
Scale from the minimum and maximum input values to 0.0 -> 1.0. This is useful for sensors such as a flex sensor that may not return the full range of 0 to 1.
Parameters:
-
minimum
NumberThe new minimum range (must be less than the maximum).
-
maximum
NumberThe new maximum range.
Properties
average
Number
[read-only] Get the (pre-filtered) average value of the potentiometer.
maximum
Number
[read-only] Get the (pre-filtered) maximum value read by the potentiometer.
minimum
Number
[read-only] Get the (pre-filtered) minimum value read by the potentiometer.
preFilterValue
Number
[read-only] Get the value of the potentiometer before filters are applied.
value
Number
[read-only] The current value of the potentiometer.
Events
change
BO.io.PotEvent.CHANGE
The change event is dispatched when the potentiometer value changes.
Event Payload:
-
target
BO.PotentiometerA reference to the Potentiometer object
Example:
pot.addEventListener(PotEvent.CHANGE, onValueChange);
function onValueChange(event) {
console.log("value = " + event.target.value);
}