readSensors

Data de postagem: 26/06/2012 00:03:17

readSensors()

Returns the most recently recorded sensor data.

Exemplo:

<?php

require_once("Android.php");

$droid = new Android();

// -----------------

$droid->startSensingTimed(1, 250);

sleep(5);

// Todos os sensores

echo "sensorsReadAccelerometer\n";

print_r($droid->readSensors());

//Posicao do celular

echo "sensorsReadAccelerometer\n";

print_r($droid->sensorsReadAccelerometer());

// Campo magnetico

echo "sensorsReadMagnetometer\n";

print_r($droid->sensorsReadMagnetometer());

// Bussola

echo "sensorsReadOrientation\n";

print_r($droid->sensorsReadOrientation());

$droid->stopSensing();

// --------------------

print_r($droid->startLocating());

sleep(15);

// GPS - Localizacao Atual

echo "readLocation\n";

$gps = $droid->readLocation();

print_r($gps);

// GPS - Ultima Localizacao

echo "getLastKnownLocation\n";

$gps1 = $droid->getLastKnownLocation();

print_r($gps1);

// GPS - Cidade, endereco

echo "geocode()\n";

print_r($droid->geocode($gps1['result']->gps->latitude,$gps1['result']->gps->longitude));

$droid->stopLocating();

// --------------------

/*

//Posicao do celular

sensorsReadAccelerometer

[0] readSensors[xforce] => -0.61291564

[1] readSensors[yforce] => 1.3790601

[2] readSensors[zforce] => 9.193734

// Campo magnetico

sensorsReadMagnetometer

[0] readSensors[xMag] => 8.0078125

[1] readSensors[yMag] => -16.015625

[2] readSensors[zMag] => 14.2578125

// Bussola

sensorsReadOrientation

[0] readSensors[azimuth] => -2.6777017116547

[1] readSensors[pitch] => -0.14856500923634

[2] readSensors[roll] => 0.066568158566952

http://developer.android.com/reference/android/hardware/SensorListener.html

values[0]: Azimuth, rotation around the Z axis (0<=azimuth<360). 0 = North, 90 = East, 180 = South, 270 = West

values[1]: Pitch, rotation around X axis (-180<=pitch<=180), with positive values when the z-axis moves toward the y-axis.

values[2]: Roll, rotation around Y axis (-90<=roll<=90), with positive values when the z-axis moves toward the x-axis.

*/

?>