def gps(self): # required to be initialized when using gpsd_control stuff gobject.threads_init() # create a gps device object (which is a full pythonic gobject) gps = liblocation.gps_device_get_new() # connect its gobject 'changed' signal to our callback function gps.connect('changed', self.notify_gps_update) # create a gpsd_control object (which is a full pythonic gobject) gpsd_control = liblocation.gpsd_control_get_default() # are we the first one to grab gpsd? If so, we can and must # start it running. If we didn't grab it first, then we cannot # control it. if gpsd_control.struct().can_control: liblocation.gpsd_control_start(gpsd_control) # wait for 'changed' event callbacks mainloop = gobject.MainLoop() try: mainloop.run() except KeyboardInterrupt: print "k."
def __init__(self): print "GPS Maemo4 init" gps = liblocation.gps_device_get_new() gps.connect("changed", self.on_changed) # create a gpsd_control object (which is a full pythonic gobject) self.gpsd_control = liblocation.gpsd_control_get_default() self.stop_on_exit = False
def __init__(self, parent=None): # Set up variables and gui elements global gpsd_control global gpson global lastlat global lastlong global lastalt global doingtrack global logtrack global ft self.gpson=0 self.lastlat=0 self.lastlong=0 self.lastalt=0 self.doingtrack=0 self.logtrack=0 self.ft=0 QtGui.QWidget.__init__(self, parent) self.setWindowTitle('QtGps') # ----------------------------------- self.gpsb = QtGui.QPushButton('Connect to the\nGPS device', self) self.gpsb.setCheckable(False) self.gpsb.setGeometry(20, 5, 310, 115) self.connect(self.gpsb, QtCore.SIGNAL('clicked()'), self.setgps) # ----------------------------------- self.swpb = QtGui.QPushButton('Save KML waypoint', self) self.swpb.setCheckable(False) self.swpb.setGeometry(350, 5, 350, 115) self.connect(self.swpb, QtCore.SIGNAL('clicked()'), self.savewaypoint) # ----------------------------------- self.label1 = QtGui.QLabel(self) self.label1.setGeometry(350, 150, 65, 30) self.label1.setText('Name:') # ----------------------------------- self.lognamebox = QtGui.QLineEdit(self) self.lognamebox.setGeometry(425, 150, 275, 30) self.lognamebox.setText('GPS log') # ----------------------------------- self.tstb = QtGui.QPushButton('Stop\nlogging', self) self.tstb.setCheckable(False) self.tstb.setGeometry(530, 210, 170, 170) self.connect(self.tstb, QtCore.SIGNAL('clicked()'), self.stoptrack) # ----------------------------------- self.tgob = QtGui.QPushButton('Start\nlogging', self) self.tgob.setCheckable(False) self.tgob.setGeometry(350, 210, 170, 170) self.connect(self.tgob, QtCore.SIGNAL('clicked()'), self.starttrack) # ----------------------------------- self.statuslabel = QtGui.QLabel(self) self.statuslabel.setGeometry(20, 150, 310, 30) self.statuslabel.setText('Status: Disconnected') # ----------------------------------- self.satsusedlabel = QtGui.QLabel(self) self.satsusedlabel.setGeometry(20, 210, 310, 30) self.satsusedlabel.setText('No satellites') # ----------------------------------- self.longitudelabel = QtGui.QLabel(self) self.longitudelabel.setGeometry(20, 250, 310, 30) self.longitudelabel.setText('No longitude') # ----------------------------------- self.latitudelabel = QtGui.QLabel(self) self.latitudelabel.setGeometry(20, 290, 310, 30) self.latitudelabel.setText('No latitude') # ----------------------------------- self.altitudelabel = QtGui.QLabel(self) self.altitudelabel.setGeometry(20, 330, 310, 30) self.altitudelabel.setText('No altitude') # ----------------------------------- gobject.threads_init() gps = liblocation.gps_device_get_new() gps.connect('changed', self.notify_gps_update) gpsd_control = liblocation.gpsd_control_get_default()