List of usage examples for android.hardware GeomagneticField GeomagneticField
public GeomagneticField(float gdLatitudeDeg, float gdLongitudeDeg, float altitudeMeters, long timeMillis)
From source file:br.com.rescue_bots_android.bluetooth.MainActivity.java
@Override public void notifyLocation(Location location) { if (joystickEnabled) { //modo joystick habilitado return;//from w ww .j a va 2 s.c o m } if (vunforiaMode) { return; } if (location.getAccuracy() >= accuraccy) { mTxtReceive.append(location.getAccuracy() + " -> accuracy is menor than -> " + accuraccy); return; } else { mTxtReceive.append("Accuracy -> " + location.getAccuracy()); //accuraccy = location.getAccuracy(); /*if(!isBetterLocation(origin, location)){ mTxtReceive.append("Not is better -> " +location.getAccuracy()); return; }*/ } String locationText = getLocationText(gps.getLocation()); //if(gps.getLocation()!=null){ // trackerController.inserir(fillLocationBean(location)); //} if (locationText != null) { Log.i("INFO", locationText); } else { Log.i("INFO", "Sem coordenada"); } //SharedPreferences settings = this.getSharedPreferences(ConfigActivity.PREFS_NAME, 0); //String serverIP = settings.getString(ConfigActivity.PARAM_SERVERIP , ""); //String serverPort = settings.getString(ConfigActivity.PARAM_SERVERPORT , ""); StringBuilder message = new StringBuilder(); message.append(locationText); /*if(isFinishing()){ message.append("YES;"); //ok i get }else{ message.append("NO;"); //found }*/ //if(origin==null){ origin = new Location(gps.getLocation()); //} geoField = new GeomagneticField(Double.valueOf(location.getLatitude()).floatValue(), Double.valueOf(location.getLongitude()).floatValue(), Double.valueOf(location.getAltitude()).floatValue(), System.currentTimeMillis()); myBearing += geoField.getDeclination(); heading = myBearing - (myBearing + heading); gpsDirection = Math.round(-heading / 360 + 180); if (origin != null && destiny != null) { //Location dest = new Location("dest"); //dest.setLatitude(destiny[0]); //dest.setLongitude(destiny[1]); distance = meterDistanceBetweenPoints(origin.getLatitude(), origin.getLongitude(), destiny[0], destiny[1]); } else { distance = -1; } if (distance > 1) { //distancia in mater around message.append("NO"); //found } else { if (distance >= 0 && distance <= 1) { message.append("YES"); //ok i get destiny = null; sendSerial("g"); } else { message.append("NO"); //found } } SharedPreferences settings = this.getSharedPreferences(ConfigActivity.PREFS_NAME, 0); String serverIP = settings.getString(ConfigActivity.PARAM_SERVERIP, ""); String serverPort = settings.getString(ConfigActivity.PARAM_SERVERPORT, ""); String robotId = settings.getString(ConfigActivity.PARAM_ROBOTID, ""); robottype = settings.getString(ConfigActivity.PARAM_BOTTYPE, ""); message.append(";" + robottype); message.append(";" + robotId); //found message.append(";" + currentDegree); message.append(";" + gpsDirection); message.append(";" + distance); message.append(";" + diference); message.append(";" + index); message.append(";" + lastmessage); message.append(";" + foundsucess); if (sendToServer(serverIP, serverPort, message, robotId)) { message.append("RESCUEBOT CLIENT at " + serverIP + ":" + serverPort + "ONLINE =)"); } else { message.append( "<font color=red>RESCUEBOT CLIENT at " + serverIP + ":" + serverPort + "OFFLINE =(</font>"); } }
From source file:com.android.gpstest.GpsTestActivity.java
private void updateGeomagneticField() { mGeomagneticField = new GeomagneticField((float) mLastLocation.getLatitude(), (float) mLastLocation.getLongitude(), (float) mLastLocation.getAltitude(), mLastLocation.getTime()); }
From source file:com.dragon4.owo.ar_trace.ARCore.MixView.java
@Override protected void onResume() { super.onResume(); try {// www . ja v a 2 s .co m this.mWakeLock.acquire(); // ?? ? killOnError(); // ? ? mixContext.mixView = this; // ?? dataView.doStart(); // ?? dataView.clearEvents(); // ? ? double angleX, angleY; // ? x, y /*? ? ? */ angleX = Math.toRadians(-90); m1.set(1f, 0f, 0f, 0f, (float) Math.cos(angleX), (float) -Math.sin(angleX), 0f, (float) Math.sin(angleX), (float) Math.cos(angleX)); angleX = Math.toRadians(-90); angleY = Math.toRadians(-90); m2.set(1f, 0f, 0f, 0f, (float) Math.cos(angleX), (float) -Math.sin(angleX), 0f, (float) Math.sin(angleX), (float) Math.cos(angleX)); m3.set((float) Math.cos(angleY), 0f, (float) Math.sin(angleY), 0f, 1f, 0f, (float) -Math.sin(angleY), 0f, (float) Math.cos(angleY)); m4.toIdentity(); for (int i = 0; i < histR.length; i++) { histR[i] = new Matrix(); } /* */ // ? sensorMgr = (SensorManager) getSystemService(SENSOR_SERVICE); // ? ? // ?? sensors = sensorMgr.getSensorList(Sensor.TYPE_ACCELEROMETER); if (sensors.size() > 0) { sensorGrav = sensors.get(0); } // ? sensors = sensorMgr.getSensorList(Sensor.TYPE_MAGNETIC_FIELD); if (sensors.size() > 0) { sensorMag = sensors.get(0); } //// TODO: 2016-06-01 if (sensors.size() > 0) { sensors = sensorMgr_ori.getSensorList(Sensor.TYPE_ORIENTATION); orientationSensor = sensors.get(0); } // ?? ? ? ? ? sensorMgr.registerListener(this, sensorGrav, SENSOR_DELAY_GAME); sensorMgr.registerListener(this, sensorMag, SENSOR_DELAY_GAME); if (orientationSensor != null) { sensorMgr_ori.registerListener(this, orientationSensor, sensorMgr_ori.SENSOR_DELAY_GAME); } try { // ?? (Criteria) // http://developer.android.com/reference/android/location/Criteria.html Criteria c = new Criteria(); // ? c.setAccuracy(Criteria.ACCURACY_FINE); //c.setBearingRequired(true); // ? locationMgr = (LocationManager) getSystemService(Context.LOCATION_SERVICE); // ?? ? ? ? . 2 , 3 locationMgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 4, this); // ?? ? , String bestP = locationMgr.getBestProvider(c, true); isGpsEnabled = locationMgr.isProviderEnabled(bestP); // gps, ? ? ? Location hardFix = new Location("reverseGeocoded"); try { // ? gps, ?? Location gps = locationMgr.getLastKnownLocation(LocationManager.GPS_PROVIDER); Location network = locationMgr.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); // ? ? // gps > ? > if (gps != null) mixContext.curLoc = gps; else if (network != null) mixContext.curLoc = network; else mixContext.curLoc = hardFix; } catch (Exception ex2) { // ? ex2.printStackTrace(); // mixContext.curLoc = hardFix; // } // ? ? ?? mixContext.setLocationAtLastDownload(mixContext.curLoc); // ?? . ? GeomagneticField gmf = new GeomagneticField((float) mixContext.curLoc.getLatitude(), (float) mixContext.curLoc.getLongitude(), (float) mixContext.curLoc.getAltitude(), System.currentTimeMillis()); // ?? angleY = Math.toRadians(-gmf.getDeclination()); m4.set((float) Math.cos(angleY), 0f, (float) Math.sin(angleY), 0f, 1f, 0f, (float) -Math.sin(angleY), 0f, (float) Math.cos(angleY)); mixContext.declination = gmf.getDeclination(); } catch (Exception ex) { Log.d("mixare", "GPS Initialize Error", ex); // ? } // ? downloadThread = new Thread(mixContext.downloadManager); downloadThread.start(); } catch (Exception ex) { doError(ex); // ? try { // ??? if (sensorMgr != null) { sensorMgr.unregisterListener(this, sensorGrav); sensorMgr.unregisterListener(this, sensorMag); sensorMgr = null; } // ?? if (locationMgr != null) { locationMgr.removeUpdates(this); locationMgr = null; } // ?? ?? if (mixContext != null) { if (mixContext.downloadManager != null) mixContext.downloadManager.stop(); } } catch (Exception ignore) { } } // ?? // ?? ? ( ?? ) ? if (dataView.isFrozen() && searchNotificationTxt == null) { searchNotificationTxt = new TextView(this); searchNotificationTxt.setWidth(dWindow.getWidth()); searchNotificationTxt.setPadding(10, 2, 0, 0); searchNotificationTxt.setBackgroundColor(Color.DKGRAY); searchNotificationTxt.setTextColor(Color.WHITE); searchNotificationTxt.setOnTouchListener(this); addContentView(searchNotificationTxt, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); } else if (!dataView.isFrozen() && searchNotificationTxt != null) { searchNotificationTxt.setVisibility(View.GONE); searchNotificationTxt = null; } }
From source file:com.androzic.Androzic.java
public double getDeclination(double lat, double lon) { GeomagneticField mag = new GeomagneticField((float) lat, (float) lon, 0.0f, System.currentTimeMillis()); return mag.getDeclination(); }
From source file:com.spoiledmilk.ibikecph.navigation.SMRouteNavigationMapFragment.java
public void onSensorChanged(SensorEvent event) { if (event.sensor == mAccelerometer) { accValues.put(event.values);//from ww w . jav a2 s .c o m // System.arraycopy(event.values, 0, mLastAccelerometer, 0, event.values.length); mLastAccelerometerSet = true; } else if (event.sensor == mMagnetometer) { if (Math.sqrt(event.values[0] * event.values[0] + event.values[1] * event.values[1] + event.values[2] * event.values[2]) > SensorManager.MAGNETIC_FIELD_EARTH_MAX * 1.5) { return; } if (event.values.length < 3) { return; } magValues.put(event.values); // System.arraycopy(event.values, 0, mLastMagnetometer, 0, event.values.length); mLastMagnetometerSet = true; } if (mLastAccelerometerSet && mLastMagnetometerSet) { SensorManager.getRotationMatrix(mR, null, accValues.get(), magValues.get()); // SensorManager.remapCoordinateSystem(mR, SensorManager.AXIS_X, // SensorManager.AXIS_Z, remapMatrix); SensorManager.getOrientation(mR, mOrientation); // remapMatrx if (SMLocationManager.getInstance().hasValidLocation()) { Location currentLoc = SMLocationManager.getInstance().getLastValidLocation(); float azimuth = -(float) Math.toDegrees(mOrientation[0]); final GeomagneticField geoField = new GeomagneticField( Double.valueOf(currentLoc.getLatitude()).floatValue(), Double.valueOf(currentLoc.getLongitude()).floatValue(), Double.valueOf(currentLoc.getAltitude()).floatValue(), System.currentTimeMillis()); azimuth += geoField.getDeclination(); // converts magnetic north // into true north // LOG.d("azimuth = " + azimuth); compassOrientation = azimuth;// - bearing; // if (Math.abs(locationOverlay.compassOrientation - compassOrientation) > 5) { // locationOverlay.compassOrientation = compassOrientation; // mapView.invalidate(); // } // } // } } } }
From source file:com.vonglasow.michael.satstat.MainActivity.java
/** * Called when a new location is found by a registered location provider. * Stores the location and updates GPS display and map view. *///ww w.j a va 2 s. c o m public void onLocationChanged(Location location) { // some providers may report NaN for latitude and longitude: // if that happens, do not process this location and mark any previous // location from that provider as stale if (Double.isNaN(location.getLatitude()) || Double.isNaN(location.getLongitude())) { markLocationAsStale(providerLocations.get(location.getProvider())); if (isMapViewReady) applyLocationProviderStyle(this, location.getProvider(), LOCATION_PROVIDER_GRAY); return; } if (providerLocations.containsKey(location.getProvider())) providerLocations.put(location.getProvider(), new Location(location)); // update map view if (isMapViewReady) { LatLong latLong = new LatLong(location.getLatitude(), location.getLongitude()); Circle circle = mapCircles.get(location.getProvider()); Marker marker = mapMarkers.get(location.getProvider()); if (circle != null) { circle.setLatLong(latLong); if (location.hasAccuracy()) { circle.setVisible(true); circle.setRadius(location.getAccuracy()); } else { Log.d("MainActivity", "Location from " + location.getProvider() + " has no accuracy"); circle.setVisible(false); } } if (marker != null) { marker.setLatLong(latLong); marker.setVisible(true); } applyLocationProviderStyle(this, location.getProvider(), null); Runnable invalidator = providerInvalidators.get(location.getProvider()); if (invalidator != null) { providerInvalidationHandler.removeCallbacks(invalidator); providerInvalidationHandler.postDelayed(invalidator, PROVIDER_EXPIRATION_DELAY); } // redraw, move locations into view and zoom out as needed if ((circle != null) || (marker != null) || (invalidator != null)) updateMap(); } // update GPS view if ((location.getProvider().equals(LocationManager.GPS_PROVIDER)) && (isGpsViewReady)) { if (location.hasAccuracy()) { gpsAccuracy.setText(String.format("%.0f", location.getAccuracy())); } else { gpsAccuracy.setText(getString(R.string.value_none)); } gpsLat.setText(String.format("%.5f%s", location.getLatitude(), getString(R.string.unit_degree))); gpsLon.setText(String.format("%.5f%s", location.getLongitude(), getString(R.string.unit_degree))); gpsTime.setText(String.format("%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS", location.getTime())); if (location.hasAltitude()) { gpsAlt.setText(String.format("%.0f", location.getAltitude())); orDeclination.setText(String.format("%.0f%s", new GeomagneticField((float) location.getLatitude(), (float) location.getLongitude(), (float) location.getAltitude(), location.getTime()).getDeclination(), getString(R.string.unit_degree))); } else { gpsAlt.setText(getString(R.string.value_none)); orDeclination.setText(getString(R.string.value_none)); } if (location.hasBearing()) { gpsBearing.setText(String.format("%.0f%s", location.getBearing(), getString(R.string.unit_degree))); gpsOrientation.setText(formatOrientation(location.getBearing())); } else { gpsBearing.setText(getString(R.string.value_none)); gpsOrientation.setText(getString(R.string.value_none)); } if (location.hasSpeed()) { gpsSpeed.setText(String.format("%.0f", (location.getSpeed()) * 3.6)); } else { gpsSpeed.setText(getString(R.string.value_none)); } // note: getting number of sats in fix by looking for "satellites" // in location's extras doesn't seem to work, always returns 0 sats } }
From source file:com.example.sensingapp.SensingApp.java
public void recordSensingInfo(SensorData senData) { String sRecordLine;//w ww .ja v a 2s . c o m String sTimeField; Date dtCurDate; int i; long lStartTime = 0; long lCurrentTime = 0; SimpleDateFormat spdRecordTime, spdCurDateTime; final String DATE_FORMAT = "yyyyMMddHHmmss"; final String DATE_FORMAT_S = "yyMMddHHmmssSSS"; //"yyyyMMddHHmmssSSS" int nSensorReadingType = SENSOR_EVENT_NULL; int nSensorDataType; if (m_blnRecordStatus == false) { //Stopped return; } dtCurDate = new Date(); // Timestamp for the record spdRecordTime = new SimpleDateFormat(DATE_FORMAT_S); sTimeField = spdRecordTime.format(dtCurDate); nSensorDataType = senData.getSensorDataType(); if (nSensorDataType == DATA_TYPE_SENSOR) { SensorEvent event; event = senData.getSensorEvent(); synchronized (this) { switch (event.sensor.getType()) { case Sensor.TYPE_ACCELEROMETER: //X, Y, Z if (m_blnAcclEnabled) { m_sAccl = Float.toString(event.values[0]) + "," + Float.toString(event.values[1]) + "," + Float.toString(event.values[2]) + ","; nSensorReadingType = SENSOR_EVENT_ACCL; } // if (m_blnOrientEnabled) { // m_arrfAcclValues = event.values.clone(); // // if (calculateOrientation()) { // //Azimuth (rotation around z-axis); Pitch (rotation around x-axis), Roll (rotation around y-axis) // m_sOrient = Float.toString(m_arrfOrientValues[0]) + "," + // Float.toString(m_arrfOrientValues[1]) + "," + // Float.toString(m_arrfOrientValues[2]) + ","; // // nSensorReadingType = SENSOR_EVENT_ORIENT; // // } // } break; case Sensor.TYPE_LINEAR_ACCELERATION: //X,Y,Z if (m_blnLinearAcclEnabled) { m_sLinearAccl = Float.toString(event.values[0]) + "," + Float.toString(event.values[1]) + "," + Float.toString(event.values[2]) + ","; nSensorReadingType = SENSOR_EVENT_LINEAR_ACCL; } break; case Sensor.TYPE_GRAVITY: //X,Y,Z if (m_blnGravityEnabled) { m_sGravity = Float.toString(event.values[0]) + "," + Float.toString(event.values[1]) + "," + Float.toString(event.values[2]) + ","; nSensorReadingType = SENSOR_EVENT_GRAVITY; } break; case Sensor.TYPE_GYROSCOPE: //X,Y,Z m_sGyro = Float.toString(event.values[0]) + "," + Float.toString(event.values[1]) + "," + Float.toString(event.values[2]) + ","; nSensorReadingType = SENSOR_EVENT_GYRO; break; case Sensor.TYPE_MAGNETIC_FIELD: // Values are in micro-Tesla (uT) and measure the ambient magnetic field if (m_blnMagnetEnabled) { m_sMagnet = Float.toString(event.values[0]) + "," + Float.toString(event.values[1]) + "," + Float.toString(event.values[2]) + ","; nSensorReadingType = SENSOR_EVENT_MAGNET; } // if (m_blnOrientEnabled) { // m_arrfMagnetValues = event.values.clone(); // // if (calculateOrientation()) { // //Azimuth (rotation around z-axis); Pitch (rotation around x-axis), Roll (rotation around y-axis) // m_sOrient = Float.toString(m_arrfOrientValues[0]) + "," + // Float.toString(m_arrfOrientValues[1]) + "," + // Float.toString(m_arrfOrientValues[2]) + ","; // // if (nSensorReadingType != SENSOR_EVENT_MAGNET) { // nSensorReadingType = SENSOR_EVENT_ORIENT; // } // } // } break; case Sensor.TYPE_ROTATION_VECTOR: //Added on 20150910 if (m_blnOrientEnabled) { float[] arrfRotVal = new float[3]; float[] arrfR = new float[9]; float[] arrfValues = new float[3]; try { System.arraycopy(event.values, 0, arrfRotVal, 0, event.values.length); } catch (IllegalArgumentException e) { //Hardcode the size to handle a bug on Samsung devices System.arraycopy(event.values, 0, arrfRotVal, 0, 3); } SensorManager.getRotationMatrixFromVector(arrfR, arrfRotVal); SensorManager.getOrientation(arrfR, arrfValues); m_arrfOrientValues[0] = (float) Math.toDegrees(arrfValues[0]); m_arrfOrientValues[1] = (float) Math.toDegrees(arrfValues[1]); m_arrfOrientValues[2] = (float) Math.toDegrees(arrfValues[2]); if (m_arrfOrientValues[0] < 0) { m_arrfOrientValues[0] = m_arrfOrientValues[0] + 360; // Make Azimuth 0 ~ 360 } // //Azimuth (rotation around z-axis); Pitch (rotation around x-axis), Roll (rotation around y-axis) m_sOrient = Float.toString(m_arrfOrientValues[0]) + "," + Float.toString(m_arrfOrientValues[1]) + "," + Float.toString(m_arrfOrientValues[2]) + ","; //m_tvGpsUp.setText(m_sOrient); //Show orientation nSensorReadingType = SENSOR_EVENT_ORIENT; } break; case Sensor.TYPE_LIGHT: // Ambient light level in SI lux units m_sLight = Float.toString(event.values[0]) + ","; nSensorReadingType = SENSOR_EVENT_LIGHT; break; case Sensor.TYPE_PRESSURE: // Atmospheric pressure in hPa (millibar) m_sBarometer = Float.toString(event.values[0]) + ","; nSensorReadingType = SENSOR_EVENT_BAROMETER; break; } } } else if (nSensorDataType == DATA_TYPE_GPS) { Location locationGps; locationGps = senData.getGpsLocation(); if (locationGps != null) { m_location = new Location(locationGps); //Change from double to float m_sGPS = Float.valueOf((float) (locationGps.getLatitude())).toString() + "," + Float.valueOf((float) (locationGps.getLongitude())).toString() + ","; if (locationGps.hasAltitude()) { m_sGPS = m_sGPS + Float.valueOf((float) (locationGps.getAltitude())).toString() + ","; GeomagneticField geoField = new GeomagneticField( Double.valueOf(locationGps.getLatitude()).floatValue(), Double.valueOf(locationGps.getLongitude()).floatValue(), Double.valueOf(locationGps.getAltitude()).floatValue(), System.currentTimeMillis()); // Append Declination, in Degree m_sGPS = m_sGPS + Float.valueOf((float) (geoField.getDeclination())).toString() + "," + Float.valueOf((float) (geoField.getInclination())).toString() + ","; } else { m_sGPS = m_sGPS + ",,,"; //m_sGPS = m_sGPS + ","; } //New add 201408270009 if (locationGps.hasSpeed()) { m_sGPS = m_sGPS + Float.valueOf((float) (locationGps.getSpeed())).toString() + ","; } else { m_sGPS = m_sGPS + ","; } if (locationGps.hasBearing()) { m_sGPS = m_sGPS + Float.valueOf((float) (locationGps.getBearing())).toString() + ","; } else { m_sGPS = m_sGPS + ","; } nSensorReadingType = SENSOR_EVENT_GPS; m_blnGpsUp = true; show_screen5_GpsUp(); } else { m_blnGpsUp = false; show_screen5_GpsUp(); } } else if (nSensorDataType == DATA_TYPE_MIC) { double fSoundLevelDb; fSoundLevelDb = senData.getSoundLevelDb(); m_sSouldLevel = new BigDecimal(fSoundLevelDb).setScale(0, BigDecimal.ROUND_HALF_UP) + ","; nSensorReadingType = SENSOR_EVENT_MIC; } else if (nSensorDataType == DATA_TYPE_CELLULAR) { int nCellId; nCellId = senData.getCellId(); m_sCellId = Integer.valueOf(nCellId).toString() + ","; nSensorReadingType = SENSOR_EVENT_CELLULAR; } else if (nSensorDataType == DATA_TYPE_WIFI) { List<WifiData> lstWifiData = senData.getListWifiData(); int nWifiCnt = Math.min(WIFI_COUNT, lstWifiData.size()); m_sWifi = ""; for (i = 0; i < nWifiCnt; i++) { //m_sWifi = m_sWifi + lstWifiData.get(i).getSSID() + "," + lstWifiData.get(i).getBSSID() + "," + lstWifiData.get(i).getSignalLevel() + ","; m_sWifi = m_sWifi + lstWifiData.get(i).getBSSID() + "," + lstWifiData.get(i).getSignalLevel() + ","; } for (i = 1; i <= WIFI_COUNT - nWifiCnt; i++) { //m_sWifi = m_sWifi + ",,,"; m_sWifi = m_sWifi + ",,"; } nSensorReadingType = SENSOR_EVENT_WIFI; } if (nSensorReadingType == SENSOR_EVENT_NULL) { return; } sRecordLine = sTimeField + ","; if (m_blnNoLabel == false) { sRecordLine = sRecordLine + m_sCurrentLabel + ","; } sRecordLine = sRecordLine + Integer.valueOf(nSensorReadingType) + ","; //New: Every field always there //Field in each line: /* * 1) Timestamp * 2) Label * 3) SensingEventType * 4-6) Accl * 7-9) Linear Accl * 10-12) Gravity * 13-15) Gyro * 16-18) Orientation * 19-21) Magnet * 22) Light * 23) Barometer * 24) Sould Level (Decibel) * 25) Cell ID * 26-32) GPS (Lat, Long, Alt, Declination, Inclination, Speed, Bearing) * 33-72) WiFi (<BSSID, Level>) */ // sRecordLine = sRecordLine + m_sAccl + m_sGyro + m_sOrient + m_sMagnet + // m_sLight + m_sBarometer + // m_sSouldLevel + m_sCellId + // m_sGPS + m_sWifi; sRecordLine = sRecordLine + m_sAccl + m_sLinearAccl + m_sGravity + m_sGyro + m_sOrient + m_sMagnet + m_sLight + m_sBarometer + m_sSouldLevel + m_sCellId + m_sGPS + m_sWifi; //////////////////////////// // String sAngle = calculateRot(m_sAccl, m_sGravity); // String sarrAngle[] = sAngle.split(","); // String sShow = sarrAngle[0] + "\n" + sarrAngle[1]; // String sShow = ""; // if (m_sGravity.length() > 3) { // String sarrAngle[] = m_sGravity.split(","); // double fX = Double.valueOf(sarrAngle[0]).doubleValue(); // double fY = Double.valueOf(sarrAngle[1]).doubleValue(); // double fZ = Double.valueOf(sarrAngle[2]).doubleValue(); // // double fTotal = Math.sqrt(fX*fX + fY*fY + fZ*fZ); // // double fAngleZ = Math.acos(fZ/fTotal)/Math.PI*180; // double fAngleY = 90 - Math.acos(fY/fTotal)/Math.PI*180; // double fAngleX = 90 - Math.acos(fX/fTotal)/Math.PI*180; // // sShow = "X: " + fAngleX + "\n"; // sShow = sShow + "Y: " + fAngleY + "\n"; // sShow = sShow + "Z: " + fAngleZ; // // // } // if (m_sGravity.length() > 3) { // String sarrAngle[] = m_sGravity.split(","); // double fX = Double.valueOf(sarrAngle[0]).doubleValue(); // double fY = Double.valueOf(sarrAngle[1]).doubleValue(); // double fZ = Double.valueOf(sarrAngle[2]).doubleValue(); // // int nSymbol = 0; // if (fX < 0) { // sShow = sShow + "- X" + "\n"; // } else if (fX > 0) { // sShow = sShow + "+ X" + "\n"; // } // // if (fY < 0) { // sShow = sShow + "- Y" + "\n"; // } else if (fY > 0) { // sShow = sShow + "+ Y" + "\n"; // } // // if (fZ < 0) { // sShow = sShow + "- Z"; // } else if (fZ > 0) { // sShow = sShow + "+ Z"; // } // // } // // if (m_sGyro.length() > 3) { // String sarrAngle[] = m_sGyro.split(","); // double fX = Double.valueOf(sarrAngle[0]).doubleValue(); // double fY = Double.valueOf(sarrAngle[1]).doubleValue(); // double fZ = Double.valueOf(sarrAngle[2]).doubleValue(); // // int nSymbol = 0; // if (fX < 0) { // nSymbol = -1; // } else if (fX > 0) { // nSymbol = 1; // } // // if (fY < 0) { // nSymbol = nSymbol + (-1); // } else if (fY > 0) { // nSymbol = nSymbol + 1; // } // // if (fZ < 0) { // nSymbol = nSymbol + (-1); // } else if (fZ > 0) { // nSymbol = nSymbol + 1; // } // // if (nSymbol < 0) { // nSymbol = -1; // } else if (nSymbol > 0) { // nSymbol = 1; // } // // sShow = sShow + "\n\n" + nSymbol + ""; // } // m_tvSensingInfo.setText(sShow); //////////////////////////// sRecordLine = sRecordLine + System.getProperty("line.separator"); if (m_fwSensorRecord != null) { //Write information into file //Compose information into recordLine try { m_fwSensorRecord.write(sRecordLine); } catch (IOException e) { } } }