예제 #1
0
def set_gps_state(state):
    global gps_state

    prev_state = gps_state

    if state and (not gps_state):
        gps.on(0, 1 | 2)
    else:
        if not state and gps_state:
            print("Switchng off gps!")
            gps.off()

    gps_state = state
    return prev_state
예제 #2
0
async def upload_gps():
    global c
    while True:
        gps.on()
        location = None
        while location is None:
            location = get_gps()
            await uasyncio.sleep(10)
        gps.off()
        # G0纬度,G1经度
        location_str0 = 'G0\t' + str(location[0]) 
        location_str1 = 'G1\t' + str(location[1])
        c.publish(b'gps_node',location_str0)
        c.publish(b'gps_node',location_str1)
        await uasyncio.sleep(3600)
예제 #3
0
# Micropython a9g example
# Source: https://github.com/pulkin/micropython
# Author: pulkin
# Demonstrates how to retrieve GPS coordinates from the built-in GPS module
import gps
gps.on()
print("Location", gps.get_location())
print("Satellites (tracked, visible)", gps.get_satellites())
gps.off()