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:
-
board
IOBoardA reference to the IOBoard instance
-
xPin
PinA reference to the Pin connected to the x axis of the accelerometer
-
yPin
PinA reference to the Pin connected to the y axis of the accelerometer
-
zPin
PinA reference to the Pin connected to the z axis of the accelerometer
-
dynamicRange
NumberThe 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.
-
enableSmoothing
BooleanTrue 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:
-
type
StringThe event type
-
listener
FunctionThe function to be called when the event is fired
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.
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:
-
minVoltage
NumberThe minimum value reported on the axis
-
maxVoltage
NumberThe maximum value reported on the axis
-
supplyVoltage
NumberThe 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:
-
type
StringThe event type return {boolean} True is listener exists for this type, false if not.
removeEventListener
-
type
-
listener
Parameters:
-
type
StringThe event type
-
listener
FunctionThe 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:
-
axis
Objectthe axis to set new range (AnalogAccelerometer.X_AXIS, AnalogAccelerometer.Y_AXIS or AnalogAccelerometer.Z_AXIS).
-
minimum
NumberThe new minimum value
-
maximum
NumberThe 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:
-
target
BO.io.AnalogAccelerometerA reference to the AnalogAccelerometer object.