Created
August 29, 2012 09:23
-
-
Save mouuff/3508971 to your computer and use it in GitHub Desktop.
Learning android api: sensors
This file contains hidden or 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
import android | |
import time | |
droid = android.Android() | |
def readaccelerometer(read_time=1): | |
droid.startSensing(2) | |
time.sleep(read_time) | |
value = droid.sensorsReadAccelerometer().result | |
droid.stopSensing() | |
return value | |
def readlight(read_time=1): | |
droid.startSensing(4) | |
time.sleep(read_time) | |
value = droid.sensorsGetLight().result | |
droid.stopSensing() | |
return value | |
def isplate(): | |
data = readaccelerometer() | |
if not int(data[0]) and not int(data[1]): | |
return True | |
return False | |
def ishiden(): | |
if readlight() <= 160: | |
return True | |
return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment