Fixed bugs
check_last_update now uses time instead of nmea. The time update now updates at first run. Map is now initiated correctly
This commit is contained in:
		
							parent
							
								
									88754840f2
								
							
						
					
					
						commit
						1fda91253b
					
				| 
						 | 
					@ -3,13 +3,13 @@ import pynmea2
 | 
				
			||||||
import serial
 | 
					import serial
 | 
				
			||||||
import io
 | 
					import io
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ser = serial.Serial('/dev/ttyS1', 9600, timeout=5.0)
 | 
					ser = serial.Serial('/dev/ttyACM0', 9600, timeout=5.0)
 | 
				
			||||||
sio = io.TextIOWrapper(io.BufferedRWPair(ser, ser))
 | 
					sio = io.TextIOWrapper(io.BufferedRWPair(ser, ser))
 | 
				
			||||||
last_time=00
 | 
					last_time=00
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def check_last_update(time,last_time):
 | 
					def check_last_update(time,last_time):
 | 
				
			||||||
    if nmea==last_nmea:
 | 
					    if time==last_time:
 | 
				
			||||||
        return False
 | 
					        return False
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        return True
 | 
					        return True
 | 
				
			||||||
| 
						 | 
					@ -27,10 +27,12 @@ while 1:
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        if check_last_update(time=msg.timestamp,last_time=last_time)==True:
 | 
					        if check_last_update(time=msg.timestamp,last_time=last_time)==True:
 | 
				
			||||||
            if last_time==00:
 | 
					            if last_time==00:
 | 
				
			||||||
                m = Map(center=msg.latitude, msg.longitude, zoom=15)
 | 
					                center = (msg.latitude, msg.longitude,)
 | 
				
			||||||
 | 
					                m = Map(center=center, zoom=15)
 | 
				
			||||||
                marker = Marker(location=center, draggable=False)
 | 
					                marker = Marker(location=center, draggable=False)
 | 
				
			||||||
                m.add_layer(marker);
 | 
					                m.add_layer(marker);
 | 
				
			||||||
                display(m)
 | 
					                display(m)
 | 
				
			||||||
 | 
					                last_time=msg.timestamp
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                marker.location=(msg.latitude, msg.longitude)
 | 
					                marker.location=(msg.latitude, msg.longitude)
 | 
				
			||||||
                last_time=msg.timestamp
 | 
					                last_time=msg.timestamp
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue