List of usage examples for android.hardware SensorManager PRESSURE_STANDARD_ATMOSPHERE
float PRESSURE_STANDARD_ATMOSPHERE
To view the source code for android.hardware SensorManager PRESSURE_STANDARD_ATMOSPHERE.
Click Source Link
From source file:root.gast.playground.sensor.altitude.DetermineAltitudeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.determine_altitude); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); gpsAltitudeView = (TextView) findViewById(R.id.gpsAltitude); gpsRelativeAltitude = (TextView) findViewById(R.id.gpsRelativeAltitude); barometerAltitudeView = (TextView) findViewById(R.id.barometerAltitude); barometerRelativeAltitude = (TextView) findViewById(R.id.barometerRelativeAltitude); mslpBarometerAltitudeView = (TextView) findViewById(R.id.mslpBarometerAltitude); mslpBarometerRelativeAltitude = (TextView) findViewById(R.id.mslpBarometerRelativeAltitude); mslpView = (TextView) findViewById(R.id.mslp); webServiceFetching = false;//from w ww. j av a2 s .co m TextView standardPressure = (TextView) findViewById(R.id.standardPressure); String standardPressureString = String.valueOf(SensorManager.PRESSURE_STANDARD_ATMOSPHERE); standardPressure.setText(standardPressureString); }
From source file:root.gast.playground.sensor.altitude.DetermineAltitudeActivity.java
@Override public void onSensorChanged(SensorEvent event) { float altitude; currentBarometerValue = event.values[0]; double currentTimestamp = event.timestamp / NS_TO_MS_CONVERSION; double elapsedTime = currentTimestamp - lastBarometerAltitudeTimestamp; if (lastBarometerAltitudeTimestamp == -1 || elapsedTime > TIMEOUT) { altitude = SensorManager.getAltitude(SensorManager.PRESSURE_STANDARD_ATMOSPHERE, currentBarometerValue); barometerAltitudeView.setText(String.valueOf(altitude)); if (mslp != null) { altitude = SensorManager.getAltitude(mslp, currentBarometerValue); mslpBarometerAltitudeView.setText(String.valueOf(altitude)); mslpView.setText(String.valueOf(mslp)); }//from ww w .j a v a 2 s . co m lastBarometerAltitudeTimestamp = (long) currentTimestamp; } }
From source file:root.gast.playground.sensor.altitude.DetermineAltitudeActivity.java
public void onToggleClick(View view) { if (((ToggleButton) view).isChecked()) { lastGpsAltitude = currentGpsAltitude; lastBarometerValue = currentBarometerValue; gpsRelativeAltitude.setVisibility(View.INVISIBLE); barometerRelativeAltitude.setVisibility(View.INVISIBLE); if (mslp != null) { mslpBarometerRelativeAltitude.setVisibility(View.INVISIBLE); }/*from ww w . jav a2s . com*/ } else { double delta; delta = currentGpsAltitude - lastGpsAltitude; gpsRelativeAltitude.setText(String.valueOf(delta)); gpsRelativeAltitude.setVisibility(View.VISIBLE); delta = SensorManager.getAltitude(SensorManager.PRESSURE_STANDARD_ATMOSPHERE, currentBarometerValue) - SensorManager.getAltitude(SensorManager.PRESSURE_STANDARD_ATMOSPHERE, lastBarometerValue); barometerRelativeAltitude.setText(String.valueOf(delta)); barometerRelativeAltitude.setVisibility(View.VISIBLE); if (mslp != null) { delta = SensorManager.getAltitude(mslp, currentBarometerValue) - SensorManager.getAltitude(mslp, lastBarometerValue); mslpBarometerRelativeAltitude.setText(String.valueOf(delta)); mslpBarometerRelativeAltitude.setVisibility(View.VISIBLE); } } }
From source file:tv.piratemedia.flightcontroller.BluetoothComputerFragment.java
public void setupAtimiter() { SensorManager mSensorManager = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE); List<Sensor> sensors = mSensorManager.getSensorList(Sensor.TYPE_PRESSURE); SensorEventListener sensorListener = new SensorEventListener() { @Override//from w w w.jav a 2 s.c o m public void onSensorChanged(SensorEvent event) { if (currentPreasure > event.values[0] - 0.5 || currentPreasure < event.values[0] + 0.5) { currentPreasure = event.values[0]; currentAltitude = SensorManager.getAltitude(SensorManager.PRESSURE_STANDARD_ATMOSPHERE, currentPreasure); JSONObject msg = new JSONObject(); try { msg.put("action", "altitude_update"); msg.put("value", currentAltitude); } catch (JSONException e) { e.printStackTrace(); } sendTextMessage(msg.toString()); } } @Override public void onAccuracyChanged(Sensor sensor, int accuracy) { } }; if (sensors.size() > 0) { sensor = sensors.get(0); mSensorManager.registerListener(sensorListener, sensor, SensorManager.SENSOR_DELAY_NORMAL); } else { } }