BO.io.AnalogAccelerometer Class
Creates an interface to an analog accelerometer. Use the accelerometer to read the acceleration along the x, y, and z axis of an object it is attached to. You can also obtain the pitch and roll. This object should interface with most analog accelerometers. See Breakout/examples/sensors/analog_accelerometer.html and Breakout/examples/three_js/accelerometer.html for example applications.
Constructor
BO.io.AnalogAccelerometer
-
board -
xPin -
yPin -
zPin -
dynamicRange -
enableSmoothing
Parameters:
-
boardIOBoardA reference to the IOBoard instance
-
xPinPinA reference to the Pin connected to the x axis of the accelerometer
-
yPinPinA reference to the Pin connected to the y axis of the accelerometer
-
zPinPinA reference to the Pin connected to the z axis of the accelerometer
-
dynamicRangeNumberThe range of the acceleromter in Gs (typically 2 or 3 for an analog accelerometer). See the datasheet for the acceleromter to get the exact value.
-
enableSmoothingBooleanTrue to enable smoothing, false to disable. Default is false.
Item Index
Methods
Properties
- AnalogAccelerometer.X_AXIS static
- AnalogAccelerometer.Y_AXIS static
- AnalogAccelerometer.Z_AXIS static
- dynamicRange
- pitch
- roll
- x
- y
- z
Events
Methods
addEventListener
-
type -
listener
Parameters:
-
typeStringThe event type
-
listenerFunctionThe function to be called when the event is fired
dispatchEvent
-
type -
optionalParams
Parameters:
-
typeEventThe Event object.
-
optionalParamsObjectOptional parameters passed as an object. return {boolean} True if dispatch is successful, false if not.
getCalibratedRange
-
minVoltage -
maxVoltage -
supplyVoltage
Use this method to get the minimum and maximum range values for an axis. Create a new object to store the return value and then pass obj.min and obj.max along with the respective axis identifier to the setRangeFor method.
Parameters:
-
minVoltageNumberThe minimum value reported on the axis
-
maxVoltageNumberThe maximum value reported on the axis
-
supplyVoltageNumberThe supply voltage of the Acceleromter (enter as 3.3, 3.0, 5.0, etc).
Returns:
An object containing the min and max range values to be passed to the setRangeFor method.
hasEventListener
-
type
Parameters:
-
typeStringThe event type return {boolean} True is listener exists for this type, false if not.
removeEventListener
-
type -
listener
Parameters:
-
typeStringThe event type
-
listenerFunctionThe function to be called when the event is fired
setRangeFor
-
axis -
minimum -
maximum
Scale the range for the specified axis (from 0 to 1) to (minimum to maximum).
Parameters:
-
axisObjectthe axis to set new range (AnalogAccelerometer.X_AXIS, AnalogAccelerometer.Y_AXIS or AnalogAccelerometer.Z_AXIS).
-
minimumNumberThe new minimum value
-
maximumNumberThe new maximum value
xAxisChanged
()
private
yAxisChanged
()
private
zAxisChanged
()
private
Properties
AnalogAccelerometer.X_AXIS
Unknown
static
AnalogAccelerometer.Y_AXIS
Unknown
static
AnalogAccelerometer.Z_AXIS
Unknown
static
dynamicRange
Number
[read-only] the accelerometer dynamic range in Gs (either 2G, 4G, 8G, or 16G for this sensor)..
pitch
Number
[read-only] The pitch value in degrees
roll
Number
[read-only] The roll value in degrees
x
Number
[read-only] The acceleration value in Gs (9.8m/sec^2) along the x-axis.
y
Number
[read-only] The acceleration value in Gs (9.8m/sec^2) along the y-axis.
z
Number
[read-only] The acceleration value in Gs (9.8m/sec^2) along the z-axis.
Events
update
BO.io.AccelerometerEvent.UPDATE
The update event is dispatched when the accelerometer values are updated.
Event Payload:
-
targetBO.io.AnalogAccelerometerA reference to the AnalogAccelerometer object.
