daily pastebin goal
66%
SHARE
TWEET

Untitled

a guest Dec 16th, 2018 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. eeimport ui
  2. import location
  3. import time
  4. import motion
  5. from math import *
  6.  
  7. cardinales = (
  8.     'N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE',
  9.     'S', 'SSO', 'SO', 'OSO', 'O', 'ONO', 'NO', 'NNO'
  10. )
  11.  
  12. v = ui.load_view()
  13.  
  14. v.present('sheet', hide_title_bar = True)
  15.  
  16. motion.start_updates()
  17.  
  18. while True:
  19.    
  20.     location.start_updates()
  21.     gps = location.get_location()
  22.     location.stop_updates()
  23.  
  24.     v['latitud'].text = f"{gps['latitude']:12.7f}N"
  25.     v['longitud'].text = f"{gps['longitude']:12.7f}E"
  26.     v['altura'].text = f"{round(gps['altitude']):4d} m."
  27.     v['speed'].text = f"{round(gps['speed'] * 3.6):^4d}" if gps['speed'] != -1 \
  28.         else "N/D"
  29.    
  30.     rumbo = gps['course']
  31.     i = round(rumbo / 22.5)
  32.     v['course'].text = f"{round(rumbo):3d}° {cardinales[i % 16]}" \
  33.         if rumbo != -1 else "N/D"
  34.    
  35.     direcciones = ''
  36.     for direccion in location.reverse_geocode(gps):
  37.         direcciones += f"{direccion.get('Street')}\n"
  38.     v['direccion'].text = direcciones[:-1]
  39.    
  40.     mag_vec = motion.get_magnetic_field()
  41.    
  42.     if mag_vec[0] < 0:
  43.         compas = pi / 2 + atan(mag_vec[1] / min(mag_vec[0], -1e-14))
  44.     else:
  45.         compas = pi + pi / 2 + atan(mag_vec[1] / max(mag_vec[0], 1e-14))
  46.     compas = compas / (2 * pi) * 359
  47.     i = round(compas / 22.5)
  48.     v['compas'].text = f"{round(compas):3d}° {cardinales[i % 16]}"
  49.    
  50.     time.sleep(1)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top