Show:

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 IOBoard

    A reference to the IOBoard instance

  • pin Pin

    A reference to the Pin the softpot is connected to.

  • softPotLength Number

    The length of the softpot in mm. Default = 100.

Methods

addEventListener

(
  • type
  • listener
)

Parameters:

  • type String

    The event type

  • listener Function

    The function to be called when the event is fired

dispatch

() private

dispatchEvent

(
  • type
  • optionalParams
)

Parameters:

  • type Event

    The Event object.

  • optionalParams Object

    Optional parameters passed as an object. return {boolean} True if dispatch is successful, false if not.

hasEventListener

(
  • type
)

Parameters:

  • type String

    The event type return {boolean} True is listener exists for this type, false if not.

onMove

(
  • touchPoint
)
private

Parameters:

  • touchPoint Number

    The value where the touch is occuring on the strip

onPinChange

(
  • evt
)
private

Parameters:

  • evt Event

    PinEvent.CHANGE

onRelease

() private

removeEventListener

(
  • type
  • listener
)

Parameters:

  • type String

    The event type

  • listener Function

    The function to be called when the event is fired

resetForNext

() private

Reset whenever you need the next Touch point.

setMinFlickMovement

(
  • touchPoint
)
private

Parameters:

  • touchPoint Number

    The 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 Number

    The minimum value

  • maximum Number

    The 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:

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:

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:

softPotPressed

BO.io.SoftPotEvent.PRESS

The softPotPressed event is dispatched when pressure is applied to the softpot surface.

Event Payload:

softPotReleased

BO.io.SoftPotEvent.RELEASE

The softPotReleased event is dispatched when pressure is released from the softpot surface.

Event Payload:

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: