List of usage examples for android.hardware Sensor TYPE_GYROSCOPE
int TYPE_GYROSCOPE
To view the source code for android.hardware Sensor TYPE_GYROSCOPE.
Click Source Link
From source file:foam.starwisp.StarwispActivity.java
protected void DeclareSensors() { String str = ""; str += "(define sensor-accelerometer " + Sensor.TYPE_ACCELEROMETER + ")"; str += "(define sensor-ambient-temperature " + Sensor.TYPE_AMBIENT_TEMPERATURE + ")"; str += "(define sensor-game-rotation-vector " + Sensor.TYPE_GAME_ROTATION_VECTOR + ")"; str += "(define sensor-geomagnetic-rotation-vector " + Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR + ")"; str += "(define sensor-gravity " + Sensor.TYPE_GRAVITY + ")"; str += "(define sensor-gyroscope " + Sensor.TYPE_GYROSCOPE + ")"; str += "(define sensor-gyroscope-uncalibrated " + Sensor.TYPE_GYROSCOPE_UNCALIBRATED + ")"; str += "(define sensor-heart-rate " + Sensor.TYPE_HEART_RATE + ")"; str += "(define sensor-light " + Sensor.TYPE_LIGHT + ")"; str += "(define sensor-linear-acceleration " + Sensor.TYPE_LINEAR_ACCELERATION + ")"; str += "(define sensor-magnetic-field " + Sensor.TYPE_MAGNETIC_FIELD + ")"; str += "(define sensor-magnetic-field-uncalibrated " + Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED + ")"; str += "(define sensor-orientation " + Sensor.TYPE_ORIENTATION + ")"; str += "(define sensor-pressure " + Sensor.TYPE_PRESSURE + ")"; str += "(define sensor-proximity " + Sensor.TYPE_PROXIMITY + ")"; str += "(define sensor-relative-humidity " + Sensor.TYPE_RELATIVE_HUMIDITY + ")"; str += "(define sensor-rotation-vector " + Sensor.TYPE_ROTATION_VECTOR + ")"; str += "(define sensor-significant-motion " + Sensor.TYPE_SIGNIFICANT_MOTION + ")"; str += "(define sensor-step-counter " + Sensor.TYPE_STEP_COUNTER + ")"; str += "(define sensor-step-detector " + Sensor.TYPE_STEP_DETECTOR + ")"; m_Scheme.eval(str);/*from w w w . j a v a 2s.c o m*/ }
From source file:ch.bfh.sensordataprocessor.sensor.SensorDisplayFragment.java
/** * @see android.hardware.SensorEventListener#onSensorChanged(android.hardware.SensorEvent) *//*from w ww . j a v a 2 s. c o m*/ @Override public void onSensorChanged(SensorEvent event) { onAccuracyChanged(event.sensor, event.accuracy); timestampLabel.setVisibility(View.VISIBLE); timestamp.setVisibility(View.VISIBLE); timestamp.setText(String.valueOf(event.timestamp)); timestampUnits.setVisibility(View.VISIBLE); switch (event.sensor.getType()) { case Sensor.TYPE_ACCELEROMETER: showEventData("Acceleration - gravity on axis", ACCELERATION_UNITS, event.values[0], event.values[1], event.values[2]); break; case Sensor.TYPE_MAGNETIC_FIELD: showEventData("Abient Magnetic Field", "uT", event.values[0], event.values[1], event.values[2]); break; case Sensor.TYPE_GYROSCOPE: showEventData("Angular speed around axis", "radians/sec", event.values[0], event.values[1], event.values[2]); break; case Sensor.TYPE_LIGHT: showEventData("Ambient light", "lux", event.values[0]); break; case Sensor.TYPE_PRESSURE: showEventData("Atmospheric pressure", "hPa", event.values[0]); break; case Sensor.TYPE_PROXIMITY: showEventData("Distance", "cm", event.values[0]); break; case Sensor.TYPE_GRAVITY: showEventData("Gravity", ACCELERATION_UNITS, event.values[0], event.values[1], event.values[2]); break; case Sensor.TYPE_LINEAR_ACCELERATION: showEventData("Acceleration (not including gravity)", ACCELERATION_UNITS, event.values[0], event.values[1], event.values[2]); break; case Sensor.TYPE_ROTATION_VECTOR: showEventData("Rotation Vector", null, event.values[0], event.values[1], event.values[2]); xAxisLabel.setText("x*sin(" + THETA + "/2)"); yAxisLabel.setText("y*sin(" + THETA + "/2)"); zAxisLabel.setText("z*sin(" + THETA + "/2)"); if (event.values.length == 4) { cosLabel.setVisibility(View.VISIBLE); cos.setVisibility(View.VISIBLE); cos.setText(String.valueOf(event.values[3])); } break; case Sensor.TYPE_ORIENTATION: showEventData("Angle", "Degrees", event.values[0], event.values[1], event.values[2]); xAxisLabel.setText(R.string.azimuthLabel); yAxisLabel.setText(R.string.pitchLabel); zAxisLabel.setText(R.string.rollLabel); break; case Sensor.TYPE_RELATIVE_HUMIDITY: showEventData("Relatice ambient air humidity", "%", event.values[0]); break; case Sensor.TYPE_AMBIENT_TEMPERATURE: showEventData("Ambien temperature", "degree Celcius", event.values[0]); break; } }
From source file:com.example.android.camera2video.CameraActivity.java
@Override public void onSensorChanged(SensorEvent event) { if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) { logText("ACCELEROMETER," + event.values[0] + "," + event.values[1] + "," + event.values[2]); mAccVal = event.values;// w w w . j a v a2s . c o m } else if (event.sensor.getType() == Sensor.TYPE_GRAVITY) { logText("GRAVITY," + event.values[0] + "," + event.values[1] + "," + event.values[2]); } else if (event.sensor.getType() == Sensor.TYPE_LINEAR_ACCELERATION) { logText("LINEAR_ACCELERATION," + event.values[0] + "," + event.values[1] + "," + event.values[2]); } else if (event.sensor.getType() == Sensor.TYPE_GYROSCOPE) { logText("GYROSCOPE," + event.values[0] + "," + event.values[1] + "," + event.values[2]); } else if (event.sensor.getType() == Sensor.TYPE_GYROSCOPE_UNCALIBRATED) { logText("GYROSCOPE_UNCALIBRATED," + event.values[0] + "," + event.values[1] + "," + event.values[2] + "," + event.values[3] + "," + event.values[4] + "," + event.values[5]); } else if (event.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD) { logText("MAGNETIC_FIELD," + event.values[0] + "," + event.values[1] + "," + event.values[2]); mMagVal = event.values; if (mAccVal != null) { float R[] = new float[9]; float I[] = new float[9]; boolean success = SensorManager.getRotationMatrix(R, I, mAccVal, mMagVal); if (success) { float orientation[] = new float[3]; SensorManager.getOrientation(R, orientation); logText("ORIENTATION," + orientation[0] + "," + orientation[1] + "," + orientation[2]); //azimuth, pitch and roll } } } }
From source file:devbox.com.br.minercompanion.ProfileActivity.java
@Override public void onSensorChanged(SensorEvent event) { synchronized (this) { switch (event.sensor.getType()) { case Sensor.TYPE_ACCELEROMETER: float[] sensor1 = event.values; sensors.acelerometer = sensor1; //acelerText.setText("x: " + sensor1[0] + " y: " + sensor1[1] + " z: " + sensor1[2]); break; case Sensor.TYPE_ORIENTATION: float[] sensor2 = event.values; sensors.orientation = sensor2; //gyroText.setText("x: " + sensor2[0] + " y: " + sensor2[1] + " z: " + sensor2[2]); break; case Sensor.TYPE_GYROSCOPE: float[] sensor3 = event.values; sensors.gyroscope = sensor3; //orienText.setText("x: " + sensor3[0] + " y: " + sensor3[1] + " z: " + sensor3[2]); break; case Sensor.TYPE_LIGHT: sensors.luminosity = event.values[0]; //ligthText.setText("Luminosidade: " + event.values[0]); break; }// w w w . j av a2 s. c o m } }
From source file:com.inloc.dr.StepService.java
private void registerDetector() { mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER /*| Sensor.TYPE_MAGNETIC_FIELD | Sensor.TYPE_ORIENTATION*/); mSensorManager.registerListener(mStepDetector, mSensor, SensorManager.SENSOR_DELAY_FASTEST); mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE); mSensorManager.registerListener(mTurnDetector, mSensor, SensorManager.SENSOR_DELAY_GAME); }
From source file:de.tudarmstadt.dvs.myhealthassistant.myhealthhub.fragments.GraphPlotFragment.java
private void updateTitleAndType() { ArrayList<String> grpTitle = new ArrayList<String>(); ArrayList<Integer> grpType = new ArrayList<Integer>(); ArrayList<Boolean> grpBarType = new ArrayList<Boolean>(); SharedPreferences pref = PreferenceManager .getDefaultSharedPreferences(getActivity().getApplicationContext()); if (pref.getBoolean(getResources().getString(R.string.in_hum), false)) { grpTitle.add("Humidity"); grpType.add(Sensor.TYPE_RELATIVE_HUMIDITY); grpBarType.add(false);//from w w w .j a v a2s .co m } if (pref.getBoolean(getResources().getString(R.string.in_lig), false)) { grpTitle.add("Light in lux/min"); grpType.add(Sensor.TYPE_LIGHT); grpBarType.add(false); } if (pref.getBoolean(getResources().getString(R.string.in_pres), false)) { grpTitle.add("Pressure in min"); grpType.add(Sensor.TYPE_PRESSURE); grpBarType.add(false); } if (pref.getBoolean(getResources().getString(R.string.in_prox), false)) { grpTitle.add("Proximity in min"); grpType.add(Sensor.TYPE_PROXIMITY); grpBarType.add(false); } if (pref.getBoolean(getResources().getString(R.string.in_tem), false)) { grpTitle.add("Ambient Temperature in C"); grpType.add(Sensor.TYPE_AMBIENT_TEMPERATURE); grpBarType.add(false); } if (pref.getBoolean(getResources().getString(R.string.pulse), false)) { grpTitle.add("Heart Rate bpm"); grpType.add(999); grpBarType.add(false); } if (pref.getBoolean(getResources().getString(R.string.in_acc), false)) { grpTitle.add("Motion Strength/min"); grpType.add(Sensor.TYPE_ACCELEROMETER); grpBarType.add(true); } if (pref.getBoolean(getResources().getString(R.string.in_mag), false)) { grpTitle.add("Magnetic Field Strength/min"); grpType.add(Sensor.TYPE_MAGNETIC_FIELD); grpBarType.add(true); } if (pref.getBoolean(getResources().getString(R.string.in_grav), false)) { grpTitle.add("Gravity Strength/min"); grpType.add(Sensor.TYPE_GRAVITY); grpBarType.add(true); } if (pref.getBoolean(getResources().getString(R.string.in_gyrs), false)) { grpTitle.add("Gyroscope Strength/min"); grpType.add(Sensor.TYPE_GYROSCOPE); grpBarType.add(true); } if (pref.getBoolean(getResources().getString(R.string.in_lin_acc), false)) { grpTitle.add("Linear Accelerometer Strength/min"); grpType.add(Sensor.TYPE_LINEAR_ACCELERATION); grpBarType.add(true); } if (grpTitle.size() == 2 && grpType.size() == 2) { firstGrpTitle = grpTitle.get(0); firstGrpType = grpType.get(0); isFirstBar = grpBarType.get(0); secondGrpTitle = grpTitle.get(1); secondGrpType = grpType.get(1); isSecondBar = grpBarType.get(1); } else if (grpTitle.size() == 1 && grpType.size() == 1) { firstGrpTitle = grpTitle.get(0); firstGrpType = grpType.get(0); isFirstBar = grpBarType.get(0); secondGrpTitle = ""; secondGrpType = -1; } }
From source file:it.unime.mobility4ckan.MainActivity.java
private void createListView() { overviewList.clear();/* w ww.j a v a 2 s .com*/ Overview overviewTitle = new Overview(getApplicationContext()); overviewTitle.setSensorName("Nome Sensore"); overviewTitle.setCurrentValue("Valore Corrente"); overviewTitle.setValueSend("Valore Inviato"); overviewList.add(overviewTitle); Overview overview0 = new Overview(getApplicationContext()); overview0.setSensorName("Speed"); overview0.setCurrentValue("" + mySensor.getCurrentSpeed()); overview0.setValueSend(lastSpeedValue); overviewList.add(overview0); for (int k = 0; k < sensorList.size(); k++) { Overview overview = new Overview(getApplicationContext()); switch (sensorList.get(k).getType()) { case Sensor.TYPE_AMBIENT_TEMPERATURE: // Gradi Celsius (C) overview.setSensorName("Temperature"); overview.setCurrentValue("" + mySensor.getCurrentTemp()); overview.setValueSend(lastTempValue); overviewList.add(overview); break; case Sensor.TYPE_PRESSURE: overview.setSensorName("Pressure"); overview.setCurrentValue("" + mySensor.getCurrentPressure()); overview.setValueSend(lastPressureValue); overviewList.add(overview); break; case Sensor.TYPE_LIGHT: // lx overview.setSensorName("Light"); overview.setCurrentValue("" + mySensor.getCurrentLight()); overview.setValueSend(lastLightValue); overviewList.add(overview); break; case Sensor.TYPE_ACCELEROMETER: // m/s2 overview.setSensorName("Accelerometer"); overview.setCurrentValue("" + mySensor.getCurrentAcceleration()); overview.setValueSend(lastAccelerationValue); overviewList.add(overview); break; case Sensor.TYPE_GYROSCOPE: // rad/s overview.setSensorName("Gyroscope"); overview.setCurrentValue("" + mySensor.getCurrentGyroscope()); overview.setValueSend(lastGyroscopeValue); overviewList.add(overview); break; case Sensor.TYPE_MAGNETIC_FIELD: // T overview.setSensorName("Magnetic Field"); overview.setCurrentValue("" + mySensor.getCurrentMagnetic()); overview.setValueSend(lastMagneticValue); overviewList.add(overview); break; case Sensor.TYPE_PROXIMITY: // cm overview.setSensorName("Proximity"); overview.setCurrentValue("" + mySensor.getCurrentProximity()); overview.setValueSend(lastProximityValue); overviewList.add(overview); break; case Sensor.TYPE_ROTATION_VECTOR: // unita di misura sconosciuta overview.setSensorName("Rotation Vector"); overview.setCurrentValue("" + mySensor.getCurrentRotation()); overview.setValueSend(lastRotationValue); overviewList.add(overview); break; case Sensor.TYPE_GRAVITY: // m/s2 overview.setSensorName("Gravity"); overview.setCurrentValue("" + mySensor.getCurrentGravity()); overview.setValueSend(lastGravityValue); overviewList.add(overview); break; case Sensor.TYPE_LINEAR_ACCELERATION: // m/s2 overview.setSensorName("Linear Acceleration"); overview.setCurrentValue("" + mySensor.getCurrentLinearAcceleration()); overview.setValueSend(lastLinearAccelerationValue); overviewList.add(overview); break; case Sensor.TYPE_RELATIVE_HUMIDITY: // % overview.setSensorName("Relative Humidity"); overview.setCurrentValue("" + mySensor.getCurrentHumidity()); overview.setValueSend(lastRelativeHumidity); overviewList.add(overview); break; default: break; } } listView.setAdapter(new OverviewAdapter(getApplicationContext(), overviewList)); }
From source file:com.android.camera2.its.ItsService.java
@Override public void onCreate() { try {/*from www. jav a 2 s. co m*/ mThreadExitFlag = false; // Get handle to camera manager. mCameraManager = (CameraManager) this.getSystemService(Context.CAMERA_SERVICE); if (mCameraManager == null) { throw new ItsException("Failed to connect to camera manager"); } mBlockingCameraManager = new BlockingCameraManager(mCameraManager); mCameraListener = new BlockingStateCallback(); // Register for motion events. mEvents = new LinkedList<MySensorEvent>(); mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); mAccelSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); mMagSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); mGyroSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE); mSensorManager.registerListener(this, mAccelSensor, SensorManager.SENSOR_DELAY_FASTEST); mSensorManager.registerListener(this, mMagSensor, SensorManager.SENSOR_DELAY_FASTEST); mSensorManager.registerListener(this, mGyroSensor, SensorManager.SENSOR_DELAY_FASTEST); // Get a handle to the system vibrator. mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); // Create threads to receive images and save them. for (int i = 0; i < MAX_NUM_OUTPUT_SURFACES; i++) { mSaveThreads[i] = new HandlerThread("SaveThread" + i); mSaveThreads[i].start(); mSaveHandlers[i] = new Handler(mSaveThreads[i].getLooper()); } // Create a thread to handle object serialization. (new Thread(new SerializerRunnable())).start(); ; // Create a thread to receive capture results and process them. mResultThread = new HandlerThread("ResultThread"); mResultThread.start(); mResultHandler = new Handler(mResultThread.getLooper()); // Create a thread for the camera device. mCameraThread = new HandlerThread("ItsCameraThread"); mCameraThread.start(); mCameraHandler = new Handler(mCameraThread.getLooper()); // Create a thread to process commands, listening on a TCP socket. mSocketRunnableObj = new SocketRunnable(); (new Thread(mSocketRunnableObj)).start(); } catch (ItsException e) { Logt.e(TAG, "Service failed to start: ", e); } }
From source file:com.richwareham.android.logallthethings.Camera2VideoFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mGoogleApiClient = new GoogleApiClient.Builder(getActivity()).addConnectionCallbacks(this) .addApi(LocationServices.API).build(); mLocationRequest = new LocationRequest(); mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); mLocationRequest.setInterval(5000);// w w w. ja v a 2s . co m mSensorManager = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE); int sensor_types[] = { Sensor.TYPE_ACCELEROMETER, Sensor.TYPE_GYROSCOPE, Sensor.TYPE_MAGNETIC_FIELD, }; mSensors = new ArrayList<Sensor>(); for (int type : sensor_types) { Sensor s = mSensorManager.getDefaultSensor(type); if (s == null) { continue; } mSensors.add(s); } }
From source file:com.vonglasow.michael.satstat.SensorSectionFragment.java
/** * Called by {@link MainActivity} when a sensor's reading changes. Updates sensor display. *//* w w w . j a v a2 s .c o m*/ public void onSensorChanged(SensorEvent event) { switch (event.sensor.getType()) { case Sensor.TYPE_ACCELEROMETER: accX.setText(String.format("%." + mAccSensorRes + "f", event.values[0])); accY.setText(String.format("%." + mAccSensorRes + "f", event.values[1])); accZ.setText(String.format("%." + mAccSensorRes + "f", event.values[2])); accTotal.setText(String.format("%." + mAccSensorRes + "f", Math.sqrt( Math.pow(event.values[0], 2) + Math.pow(event.values[1], 2) + Math.pow(event.values[2], 2)))); accStatus.setTextColor(getResources().getColor(accuracyToColor(event.accuracy))); break; case Sensor.TYPE_ORIENTATION: orAzimuth.setText(String.format("%.0f%s", event.values[0], getString(R.string.unit_degree))); orAziText.setText(MainActivity.formatOrientation(this.getContext(), event.values[0])); orPitch.setText(String.format("%.0f%s", event.values[1], getString(R.string.unit_degree))); orRoll.setText(String.format("%.0f%s", event.values[2], getString(R.string.unit_degree))); orStatus.setTextColor(getResources().getColor(accuracyToColor(event.accuracy))); break; case Sensor.TYPE_GYROSCOPE: rotX.setText(String.format("%." + mGyroSensorRes + "f", event.values[0])); rotY.setText(String.format("%." + mGyroSensorRes + "f", event.values[1])); rotZ.setText(String.format("%." + mGyroSensorRes + "f", event.values[2])); rotTotal.setText(String.format("%." + mGyroSensorRes + "f", Math.sqrt( Math.pow(event.values[0], 2) + Math.pow(event.values[1], 2) + Math.pow(event.values[2], 2)))); rotStatus.setTextColor(getResources().getColor(accuracyToColor(event.accuracy))); break; case Sensor.TYPE_MAGNETIC_FIELD: magX.setText(String.format("%." + mMagSensorRes + "f", event.values[0])); magY.setText(String.format("%." + mMagSensorRes + "f", event.values[1])); magZ.setText(String.format("%." + mMagSensorRes + "f", event.values[2])); magTotal.setText(String.format("%." + mMagSensorRes + "f", Math.sqrt( Math.pow(event.values[0], 2) + Math.pow(event.values[1], 2) + Math.pow(event.values[2], 2)))); magStatus.setTextColor(getResources().getColor(accuracyToColor(event.accuracy))); break; case Sensor.TYPE_LIGHT: light.setText(String.format("%." + mLightSensorRes + "f", event.values[0])); lightStatus.setTextColor(getResources().getColor(accuracyToColor(event.accuracy))); break; case Sensor.TYPE_PROXIMITY: proximity.setText(String.format("%." + mProximitySensorRes + "f", event.values[0])); proximityStatus.setTextColor(getResources().getColor(accuracyToColor(event.accuracy))); break; case Sensor.TYPE_PRESSURE: metPressure.setText(String.format("%." + mPressureSensorRes + "f", event.values[0])); pressureStatus.setTextColor(getResources().getColor(accuracyToColor(event.accuracy))); break; case Sensor.TYPE_RELATIVE_HUMIDITY: metHumid.setText(String.format("%." + mHumiditySensorRes + "f", event.values[0])); humidStatus.setTextColor(getResources().getColor(accuracyToColor(event.accuracy))); break; case Sensor.TYPE_AMBIENT_TEMPERATURE: metTemp.setText(String.format("%." + mTempSensorRes + "f", event.values[0])); tempStatus.setTextColor(getResources().getColor(accuracyToColor(event.accuracy))); break; } }