BO.io.SoftPot Class
Creates an interface to a SoftPot sensor. A softpot is a type of analog resistive sensor that acts as a type of slider input. There are straight and curved variations. This object provides a number of useful events such as Press, Release, Drag, Tap and capturing Flick gestures. See Breakout/examples/sensors/softpot.html for an example application.
Constructor
BO.io.SoftPot
-
board
-
pin
-
softPotLength
Parameters:
-
board
IOBoardA reference to the IOBoard instance
-
pin
PinA reference to the Pin the softpot is connected to.
-
softPotLength
NumberThe length of the softpot in mm. Default = 100.
Item Index
Methods
Methods
addEventListener
-
type
-
listener
Parameters:
-
type
StringThe event type
-
listener
FunctionThe function to be called when the event is fired
dispatch
()
private
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.
onMove
-
touchPoint
Parameters:
-
touchPoint
NumberThe value where the touch is occuring on the strip
onPinChange
-
evt
Parameters:
-
evt
EventPinEvent.CHANGE
onRelease
()
private
removeEventListener
-
type
-
listener
Parameters:
-
type
StringThe event type
-
listener
FunctionThe function to be called when the event is fired
resetForNext
()
private
Reset whenever you need the next Touch point.
setMinFlickMovement
-
touchPoint
Parameters:
-
touchPoint
NumberThe value where the touch is occuring on the strip
setRange
-
minimum
-
maximum
Scale from the minimum and maximum input values to 0.0 -> 1.0.
Parameters:
-
minimum
NumberThe minimum value
-
maximum
NumberThe maximum value
startTouch
()
private
Properties
distanceFromPressed
Number
The current distance from the press point.
minDragMovement
Number
The minimum distance required to trigger a drag event. Change this value to fine tune the drag response.
minFlickMovement
Number
The minimum distance required to trigger a flick event. Change this value to fine tune the flick gesture.
minValue
Number
The minimum value required to set the Release state. This number should be as close to zero as possible. Increase this value if you are noticing fluttering between the Pressed and Released states. Default value = 0.01;
tapTimeout
Number
The maximum time (in milliseconds) between a press and release in order to trigger a TAP event.
value
Number
The current value.
Events
softPotDrag
BO.io.SoftPotEvent.DRAG
The softPotDrag event is dispatched when a drag is detected along the length of the softpot sensor.
Event Payload:
-
target
BO.io.SoftPotA reference to the SoftPot object
softPotFlickDown
BO.io.SoftPotEvent.FLICK_DOWN
The softPotFlickDown event is dispatched when a flick gesture is detected in the direction away from the sensor pins.
Event Payload:
-
target
BO.io.SoftPotA reference to the SoftPot object
softPotFlickUp
BO.io.SoftPotEvent.FLICK_UP
The softPotFlickUp event is dispatched when a flick gesture is detected in the direction of the sensor pins.
Event Payload:
-
target
BO.io.SoftPotA reference to the SoftPot object
softPotPressed
BO.io.SoftPotEvent.PRESS
The softPotPressed event is dispatched when pressure is applied to the softpot surface.
Event Payload:
-
target
BO.io.SoftPotA reference to the SoftPot object
softPotReleased
BO.io.SoftPotEvent.RELEASE
The softPotReleased event is dispatched when pressure is released from the softpot surface.
Event Payload:
-
target
BO.io.SoftPotA reference to the SoftPot object
softPotTap
BO.io.SoftPotEvent.TAP
The softPotTap event is dispatched when a press and release occurs in in less than the duration specified by the tapTimeout property.
Event Payload:
-
target
BO.io.SoftPotA reference to the SoftPot object