Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- eeimport ui
- import location
- import time
- import motion
- from math import *
- cardinales = (
- 'N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE',
- 'S', 'SSO', 'SO', 'OSO', 'O', 'ONO', 'NO', 'NNO'
- )
- v = ui.load_view()
- v.present('sheet', hide_title_bar = True)
- motion.start_updates()
- while True:
- location.start_updates()
- gps = location.get_location()
- location.stop_updates()
- v['latitud'].text = f"{gps['latitude']:12.7f}N"
- v['longitud'].text = f"{gps['longitude']:12.7f}E"
- v['altura'].text = f"{round(gps['altitude']):4d} m."
- v['speed'].text = f"{round(gps['speed'] * 3.6):^4d}" if gps['speed'] != -1 \
- else "N/D"
- rumbo = gps['course']
- i = round(rumbo / 22.5)
- v['course'].text = f"{round(rumbo):3d}° {cardinales[i % 16]}" \
- if rumbo != -1 else "N/D"
- direcciones = ''
- for direccion in location.reverse_geocode(gps):
- direcciones += f"{direccion.get('Street')}\n"
- v['direccion'].text = direcciones[:-1]
- mag_vec = motion.get_magnetic_field()
- if mag_vec[0] < 0:
- compas = pi / 2 + atan(mag_vec[1] / min(mag_vec[0], -1e-14))
- else:
- compas = pi + pi / 2 + atan(mag_vec[1] / max(mag_vec[0], 1e-14))
- compas = compas / (2 * pi) * 359
- i = round(compas / 22.5)
- v['compas'].text = f"{round(compas):3d}° {cardinales[i % 16]}"
- time.sleep(1)
Add Comment
Please, Sign In to add comment