本文整理汇总了Java中android.hardware.Sensor.TYPE_PRESSURE属性的典型用法代码示例。如果您正苦于以下问题:Java Sensor.TYPE_PRESSURE属性的具体用法?Java Sensor.TYPE_PRESSURE怎么用?Java Sensor.TYPE_PRESSURE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.hardware.Sensor
的用法示例。
在下文中一共展示了Sensor.TYPE_PRESSURE属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onSensorChanged
@Override
public void onSensorChanged(SensorEvent event) {
final float value = event.values[0];
if (event.sensor.getType() == Sensor.TYPE_AMBIENT_TEMPERATURE) {
updateTemperatureDisplay(value);
} else if (event.sensor.getType() == Sensor.TYPE_PRESSURE) {
updateBarometerDisplay(value);
}
}
示例2: onSensorChanged
@Override
public void onSensorChanged(SensorEvent sensorEvent) {
switch (sensorEvent.sensor.getType()) {
case Sensor.TYPE_AMBIENT_TEMPERATURE:
mSensorData.temperature = sensorEvent.values[0];
mSensorData.temperature_timestamp = sensorEvent.timestamp;
break;
case Sensor.TYPE_RELATIVE_HUMIDITY:
mSensorData.humidity = sensorEvent.values[0];
mSensorData.humidity_timestamp = sensorEvent.timestamp;
break;
case Sensor.TYPE_PRESSURE:
mSensorData.pressure = sensorEvent.values[0];
mSensorData.pressure_timestamp = sensorEvent.timestamp;
break;
case Sensor.TYPE_DEVICE_PRIVATE_BASE:
if (HpmSensorDriver.SENSOR_STRING_TYPE.equals(sensorEvent.sensor.getStringType())) {
mSensorData.pm25 = (int) sensorEvent.values[0];
mSensorData.pm10 = (int) sensorEvent.values[1];
mSensorData.particle_timestamp = sensorEvent.timestamp;
break;
}
default:
Log.w(TAG, "Unexpected sensor type: " + sensorEvent.sensor.getType());
}
}
示例3: onSensorChanged
@Override
public void onSensorChanged(SensorEvent event) {
// when pressure value is changed, this method will be called.
float pressure_value = 0.0f;
// if you use this listener as listener of only one sensor (ex, Pressure), then you don't need to check sensor type.
if( Sensor.TYPE_PRESSURE == event.sensor.getType() ) {
pressure_value = event.values[0];
//mAddressLabel = (TextView)findViewById(R.id.hostlobby_address);
// mAddressLabel.setText(String.valueOf(pressure_value));
mCurrentPressure = pressure_value;
}
}
示例4: onSensorChanged
@RequiresApi(api = Build.VERSION_CODES.CUPCAKE)
@Override
public void onSensorChanged(SensorEvent event) {
// when pressure value is changed, this method will be called.
float pressure_value = 0.0f;
// if you use this listener as listener of only one sensor (ex, Pressure), then you don't need to check sensor type.
if( Sensor.TYPE_PRESSURE == event.sensor.getType() ) {
pressure_value = event.values[0];
//mAddressLabel = (TextView)findViewById(R.id.hostlobby_address);
// mAddressLabel.setText(String.valueOf(pressure_value));
mCurrentPressure = pressure_value;
}
}
示例5: onSensorChanged
@Override
public void onSensorChanged(SensorEvent event) {
// when pressure value is changed, this method will be called.
float pressure_value = 0.0f;
// if you use this listener as listener of only one sensor (ex, Pressure), then you don't need to check sensor type.
if (Sensor.TYPE_PRESSURE == event.sensor.getType()) {
pressure_value = event.values[0];
//mAddressLabel = (TextView)findViewById(R.id.hostlobby_address);
// mAddressLabel.setText(String.valueOf(pressure_value));
mCurrentPressure = pressure_value;
}
}
示例6: onSensorChanged
@Override
public void onSensorChanged(SensorEvent sensorEvent) {
if(sensorEvent.sensor.getType() == Sensor.TYPE_PRESSURE) {
synchronized (this.mutex) {
this.pressure = sensorEvent.values[0];
logger.debug("Sensor Barometer value : " + this.pressure);
System.out.println("Sensor Barometer value : " + this.pressure);
}
}
}
示例7: isRestricted
@SuppressWarnings("deprecation")
private boolean isRestricted(XParam param, int type) throws Throwable {
if (type == Sensor.TYPE_ALL)
return false;
else if (type == Sensor.TYPE_ACCELEROMETER || type == Sensor.TYPE_LINEAR_ACCELERATION) {
if (isRestricted(param, "acceleration"))
return true;
} else if (type == Sensor.TYPE_GRAVITY) {
if (isRestricted(param, "gravity"))
return true;
} else if (type == Sensor.TYPE_RELATIVE_HUMIDITY) {
if (isRestricted(param, "humidity"))
return true;
} else if (type == Sensor.TYPE_LIGHT) {
if (isRestricted(param, "light"))
return true;
} else if (type == Sensor.TYPE_MAGNETIC_FIELD || type == Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED) {
if (isRestricted(param, "magnetic"))
return true;
} else if (type == Sensor.TYPE_SIGNIFICANT_MOTION) {
if (isRestricted(param, "motion"))
return true;
} else if (type == Sensor.TYPE_ORIENTATION || type == Sensor.TYPE_GYROSCOPE
|| type == Sensor.TYPE_GYROSCOPE_UNCALIBRATED) {
if (isRestricted(param, "orientation"))
return true;
} else if (type == Sensor.TYPE_PRESSURE) {
if (isRestricted(param, "pressure"))
return true;
} else if (type == Sensor.TYPE_PROXIMITY) {
if (isRestricted(param, "proximity"))
return true;
} else if (type == Sensor.TYPE_GAME_ROTATION_VECTOR || type == Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR
|| type == Sensor.TYPE_ROTATION_VECTOR) {
if (isRestricted(param, "rotation"))
return true;
} else if (type == Sensor.TYPE_TEMPERATURE || type == Sensor.TYPE_AMBIENT_TEMPERATURE) {
if (isRestricted(param, "temperature"))
return true;
} else if (type == Sensor.TYPE_STEP_COUNTER || type == Sensor.TYPE_STEP_DETECTOR) {
if (isRestricted(param, "step"))
return true;
} else if (type == Sensor.TYPE_HEART_RATE) {
if (isRestricted(param, "heartrate"))
return true;
} else if (type == 22) {
// 22 = TYPE_TILT_DETECTOR
// Do nothing
} else if (type == 23 || type == 24 || type == 25) {
// 23 = TYPE_WAKE_GESTURE
// 24 = TYPE_GLANCE_GESTURE
// 25 = TYPE_PICK_UP_GESTURE
// 23/24 This sensor is expected to only be used by the system ui
// 25 Expected to be used internally for always on display
} else
Util.log(this, Log.WARN, "Unknown sensor type=" + type);
return false;
}
示例8: AirPressureUpdatesProvider
AirPressureUpdatesProvider(int sensorDelay) {
super(Sensor.TYPE_PRESSURE, sensorDelay);
}
示例9: PressureMonitor
public PressureMonitor(Context ctx, SensorManager sensorManager, ServerConnection serverConnection) throws SensorMissingException {
super(ctx, sensorManager, serverConnection, "pressure", Sensor.TYPE_PRESSURE);
}
示例10: onSensorChanged
public void onSensorChanged(SensorEvent event) {
long curTime = System.currentTimeMillis();
// only allow one update every 100ms.
if (event.sensor.getType() == Sensor.TYPE_PRESSURE) {
if ((curTime - lastUpdate) > CHECK_INTERVAL) {
long diffTime = (curTime - lastUpdate);
lastUpdate = curTime;
accel_values = event.values.clone();
if (alert && remainingAlertPeriod > 0) {
remainingAlertPeriod = remainingAlertPeriod - 1;
} else {
alert = false;
}
if (last_accel_values != null) {
float diffValue = Math.abs(accel_values[0] - last_accel_values[0]);
Log.d("Pressure","diff: " + diffValue);
boolean logit = (diffValue > CHANGE_THRESHOLD);
if (logit) {
/*
* Send Alert
*/
alert = true;
remainingAlertPeriod = maxAlertPeriod;
Message message = new Message();
message.what = EventTrigger.PRESSURE;
message.getData().putString("path",diffValue+"");
try {
if (serviceMessenger != null) {
serviceMessenger.send(message);
}
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
last_accel_values = accel_values.clone();
}
}
}
示例11: PPressure
public PPressure(AppRunner appRunner) {
super(appRunner);
type = Sensor.TYPE_PRESSURE;
}
示例12: onSensorChanged
@Override
public void onSensorChanged(SensorEvent event) {
switch (event.sensor.getType()) {
case Sensor.TYPE_PRESSURE:
if (groundCount > 3) {
groundPressures.add(event.values[0]);
if (groundPressures.size() > 4) {
publishAverageGroundPressure();
}
pressures.clear();
} else {
if (groundPressures.size() > 0) {
publishAverageGroundPressure();
}
pressures.offer(event.values[0]);
if (pressures.size() > 4) {
pressures.poll();
}
publishAveragePressure();
}
break;
case Sensor.TYPE_ACCELEROMETER:
// keep running window of XYZ accelerations
accelXWindow[windowIndex] = event.values[0];
accelYWindow[windowIndex] = event.values[1];
accelZWindow[windowIndex] = event.values[2];
windowIndex = (windowIndex + 1) % 3;
// find deviation on each axis
float maxX = Math.max(accelXWindow[0], Math.max(accelXWindow[1], accelXWindow[2]));
float minX = Math.min(accelXWindow[0], Math.min(accelXWindow[1], accelXWindow[2]));
float maxY = Math.max(accelYWindow[0], Math.max(accelYWindow[1], accelYWindow[2]));
float minY = Math.min(accelYWindow[0], Math.min(accelYWindow[1], accelYWindow[2]));
float maxZ = Math.max(accelZWindow[0], Math.max(accelZWindow[1], accelZWindow[2]));
float minZ = Math.min(accelZWindow[0], Math.min(accelZWindow[1], accelZWindow[2]));
// use max deviation among the 3 axes
float globalMax = Math.max(maxX - minX, Math.max(maxY - minY, maxZ - minZ));
if (globalMax < GROUND_THRESHOLD) { // assume phone is on the ground
groundCount++;
} else { // assume phone is in user's hand
groundCount = 0;
}
break;
}
}