Esempio n. 1
0
class GPS(Sensor):
    def __init__(self, sensor_id, uart_bus, timer_num, baud_rate=9600,
                 update_rate=5):
        super(GPS, self).__init__(sensor_id, ['f'] * 7 + ['b'])
        self.gps_ref = AdafruitGPS(uart_bus, timer_num, baud_rate, update_rate)

        add_timer(timer_num, self.gps_ref.timer.freq())

        self.stop()

    def stop(self):
        self.gps_ref.standby()

    def reset(self):
        self.gps_ref.wakeup()


    def recved_data(self):
        return self.gps_ref.received_sentence()

    def update_data(self):
        return (self.gps_ref.latitude, self.gps_ref.longitude,
                self.gps_ref.altitude, self.gps_ref.geoid_height,
                self.gps_ref.pdop, self.gps_ref.hdop, self.gps_ref.vdop,
                self.gps_ref.fix)
Esempio n. 2
0
class GPS(Sensor):
    def __init__(self,
                 sensor_id,
                 uart_bus,
                 timer_num,
                 baud_rate=9600,
                 update_rate=5):
        super(GPS, self).__init__(sensor_id, ['f'] * 7 + ['b'])
        self.gps_ref = AdafruitGPS(uart_bus, timer_num, baud_rate, update_rate)

        add_timer(timer_num, self.gps_ref.timer.freq())

    def stop(self):
        print("GPS entering standby... ", end="")
        self.gps_ref.standby()
        print("done!")

    def reset(self):
        print("GPS waking up... ", end="")
        self.gps_ref.wakeup()
        print("done!")

    def recved_data(self):
        return self.gps_ref.received_sentence()

    def update_data(self):
        return (self.gps_ref.latitude, self.gps_ref.longitude,
                self.gps_ref.altitude, self.gps_ref.geoid_height,
                self.gps_ref.pdop, self.gps_ref.hdop, self.gps_ref.vdop,
                self.gps_ref.fix)
Esempio n. 3
0
from libraries.adafruit_gps import AdafruitGPS

gps = AdafruitGPS(2, 4, 9600, 5)

while True:
    pyb.delay(1)
    if gps.received_sentence():
        print(gps.sentence)
        gps.sentence = ""