Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public class MainActivity extends Activity implements SensorEventListener {

//Sensordata damping elements
private List<Float> rollingAverage = new ArrayList<Float>();
private static final int MAX_SAMPLE_SIZE = 5;
private static final int MAX_SAMPLE_SIZE = 1;
private float gravity;

//UI Elements
Expand Down Expand Up @@ -318,7 +318,7 @@ public boolean onTouch(View v, MotionEvent event) {
@Override
public void onSensorChanged(SensorEvent event) {
switch (event.sensor.getType()) {
case Sensor.TYPE_ACCELEROMETER:
case Sensor.TYPE_GRAVITY:

angle = (float) (Math.asin(
-event.values[1] / Math.sqrt(
Expand Down Expand Up @@ -397,7 +397,7 @@ public void onAccuracyChanged(Sensor sensor, int accuracy) {
// This function registers sensor listeners for the accelerometer
public void initListeners() {
mSensorManager.registerListener(this,
mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
mSensorManager.getDefaultSensor(Sensor.TYPE_GRAVITY),
SensorManager.SENSOR_DELAY_GAME);

mSensorManager.registerListener(this,
Expand Down