Exemple #1
0
my_gps = MicropyGPS()


def print_out(string):
    print(string)
    #uart_bt.write(string)
    try:
        log = open('/sd/log.txt','a')
        log.write(string+'\n')
        log.close()
    except:
        print('SD Error')
        #uart_bt.write('SD Error\n')

# Continuous Tests for characters available in the UART buffer, any characters are feed into the GPS
# object. When enough char are feed to represent a whole, valid sentence, stat is set as the name of the
# sentence and printed
while True:
    pyb.wfi()
    if uart_gps.any():
        stat = my_gps.update(chr(uart_gps.readchar())) # Note the conversion to to chr, UART outputs ints normally
        if stat:
            ret = ('--------' + stat + '--------\n')
            ret += (my_gps.time_string() + '\n')
            ret += (my_gps.latitude_string()+ '\n')
            ret += (my_gps.longitude_string()+ '\n')
            ret += (my_gps.altitude_string()+ '\n')
            ret += (my_gps.speed_string()+ '\n')
            print_out(ret)
            stat = None