|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.drismo.logic.AccelerationHandler
public class AccelerationHandler
This object handles everything regarding collecting and filtering acceleration data. To listen for filtered
acceleration data, implement the FilteredAccelerationListener
interface.
FilteredAccelerationListener
Nested Class Summary | |
---|---|
private static class |
AccelerationHandler.MAQueue
An inner static class used to remove noise from the acceleration values. |
Field Summary | |
---|---|
private java.util.ArrayList<FilteredAccelerationListener> |
filteredAccelerationListeners
|
private AccelerationHandler.MAQueue |
maQueue
|
private double |
pitch
|
private double |
roll
|
private android.hardware.SensorManager |
sensorManager
|
private double |
yaw
|
Constructor Summary | |
---|---|
AccelerationHandler(android.hardware.SensorManager sm)
Set up the sensor manager and the moving average queue. |
Method Summary | |
---|---|
void |
onAccuracyChanged(android.hardware.Sensor sensor,
int i)
Never used |
void |
onSensorChanged(android.hardware.SensorEvent event)
Filters the incoming acceleration data using the WMA or EMA algorithm, and fires the callback method of all the listeners. |
void |
registerFilteredAccelerationListener(FilteredAccelerationListener listener)
Add an object to listen for filtered acceleration data. |
static void |
rotate(double radAngle,
int indexX,
int indexY,
float[] vectors)
Rotates two vectors using polar rotation, using each vector as a coordinate. |
void |
rotateAll(float[] vectors)
Rotates all the acceleration vectors given as parameter, according to the roll ,
pitch and yaw angles. |
void |
startListening()
Start listening for acceleration data. |
void |
stopListening()
Stop listening for acceleration data. |
void |
unregisterFilteredAccelerationListener(FilteredAccelerationListener listener)
Remove an added listener from the list. |
void |
updatePitchAngle(double YZ)
Updates the pitch angle relative to the vehicle. |
void |
updateRollAngle(double XZ)
Updates the roll angle relative to the vehicle. |
void |
updateYawAngle(double XY)
Updates the yaw angle relative to the vehicle. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private android.hardware.SensorManager sensorManager
private double pitch
private double roll
private double yaw
private AccelerationHandler.MAQueue maQueue
private final java.util.ArrayList<FilteredAccelerationListener> filteredAccelerationListeners
Constructor Detail |
---|
public AccelerationHandler(android.hardware.SensorManager sm)
sm
- The sensor manager used to register a accelerometer data listener.Method Detail |
---|
public void startListening()
public void stopListening()
public void registerFilteredAccelerationListener(FilteredAccelerationListener listener)
listener
- The listener to add.public void unregisterFilteredAccelerationListener(FilteredAccelerationListener listener)
listener
- The listener to remove.public void onSensorChanged(android.hardware.SensorEvent event)
onSensorChanged
in interface android.hardware.SensorEventListener
event
- Sensor event. Only using Sensor.TYPE_ACCELEROMETER.FilteredAccelerationListener.onFilteredAccelerationChange(float[], float[])
public void updatePitchAngle(double YZ)
YZ
- The new angle (radians)public void updateYawAngle(double XY)
XY
- The new angle (radians)public void updateRollAngle(double XZ)
XZ
- The new angle (radians)public void rotateAll(float[] vectors)
roll
,
pitch
and yaw
angles.
vectors
- The acceleration vectorspublic static void rotate(double radAngle, int indexX, int indexY, float[] vectors)
radAngle
- The rotation angle in radians.indexX
- Index of the X coordinateindexY
- Index of the Y coordinatevectors
- Acceleration vector array.public void onAccuracyChanged(android.hardware.Sensor sensor, int i)
onAccuracyChanged
in interface android.hardware.SensorEventListener
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |