Created
April 29, 2011 22:19
-
-
Save thedod/949143 to your computer and use it in GitHub Desktop.
Eyes-free clock in Python-for-Android
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
# Eyes-free clock script in Python for Android | |
# ( http://code.google.com/p/python-for-android/ ) by @TheRealDod. | |
# Shake phone to hear time. Handy when playing a full screen game ;) | |
SHAKE_THRESHOLD = 12 | |
CLOCK_VOL = 13 | |
import android,time | |
droid = android.Android() | |
def efclock(): | |
droid.eventClearBuffer() | |
droid.startSensingThreshold(2, SHAKE_THRESHOLD , 2) | |
try: | |
e = droid.eventWaitFor('sensors',100) | |
shaken = e.result is not None | |
except: | |
shaken = False | |
finally: | |
droid.stopSensing() | |
if shaken: | |
droid.makeToast(time.strftime("%H:%M:%S")) | |
origvol = droid.getMediaVolume().result | |
droid.setMediaVolume(CLOCK_VOL) | |
droid.ttsSpeak(time.strftime("%H %M")) | |
while droid.ttsIsSpeaking().result: | |
time.sleep(.1) | |
droid.setMediaVolume(origvol) | |
if __name__=='__main__': | |
while True: | |
efclock() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment