Skip to content

Instantly share code, notes, and snippets.

@riverfor
Last active January 31, 2020 10:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save riverfor/60c6353e2ed45292f4bc632aca06f874 to your computer and use it in GitHub Desktop.
Save riverfor/60c6353e2ed45292f4bc632aca06f874 to your computer and use it in GitHub Desktop.
# -*- 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