Last active
January 31, 2020 10:06
-
-
Save riverfor/60c6353e2ed45292f4bc632aca06f874 to your computer and use it in GitHub Desktop.
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
# -*- coding: utf-8 -*- | |
import androidhelper | |
import time | |
from math import radians | |
droid = androidhelper.Android() | |
droid.startSensingTimed(1, 250) | |
droid.startLocating() | |
i=0 | |
while i<20: | |
gpsdata = droid.readLocation().result | |
s6data = droid.sensorsReadOrientation().result | |
if len(gpsdata)>0: | |
if 'gps' in gpsdata: | |
print("gps bearing") | |
print(gpsdata['gps']['bearing']) #Get Gps bearing | |
else: | |
print("network bearing") | |
print(gpsdata['network']['bearing']) #Get network bearing | |
if len(s6data)>0: | |
print("azimuth") | |
print(s6data[0]) #Get O-sensor's azimuth | |
time.sleep(0.5) | |
i=i+1 | |
droid.stopLocating() | |
droid.stopSensing() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment