Created
January 28, 2014 03:20
-
-
Save marcoonroad/8661780 to your computer and use it in GitHub Desktop.
Tenha os valores dos sensores de seu Android (Requer: SL4A + BeanShell interpreter).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source("/sdcard/com.googlecode.bshforandroid/extras/bsh/android.bsh"); | |
droid = Android(); | |
print ("Please wait 5 seconds..."); | |
droid.call("startSensingTimed", 1, 250); | |
exec("sleep 5"); | |
read = droid.call("readSensors").get("result"); | |
accu = droid.call("sensorsGetAccuracy").get("result"); | |
/* | |
light = droid.call("sensorsGetLight").get("result"); | |
*/ | |
accel = droid.call("sensorsReadAccelerometer").get("result"); | |
magne = droid.call("sensorsReadMagnetometer").get("result"); | |
orient = droid.call("sensorsReadOrientation").get("result"); | |
droid.call("stopSensing"); | |
print ("----- Catched Sensor Values -----"); | |
print ("Accuracy Level (1-3): " + accu + "\n"); | |
// print ("Light Sensor Result: " + light); | |
print ("•• Accelerometer: ••"); | |
print ("X axis: " + accel.get(0)); | |
print ("Y axis: " + accel.get(1)); | |
print ("Z axis: " + accel.get(2) + "\n"); | |
print ("•• Magnetometer: ••"); | |
print ("X magnetic axis: " + magne.get(0)); | |
print ("Y magnetic axis: " + magne.get(1)); | |
print ("Z magnetic axis: " + magne.get(2) + "\n"); | |
print ("•• Orientation Sensor: ••"); | |
print ("X axis: " + orient.get(0)); | |
print ("Y axis: " + orient.get(1)); | |
print ("Z axis: " + orient.get(2)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment