Skip to content

Instantly share code, notes, and snippets.

@bazub
bazub / gist:3756086
Created September 20, 2012 13:57
Serial connection
ser = serial.Serial(
port='COM3',
baudrate=38400,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS
)
ser.close()
ser.open()
@bazub
bazub / gist:3756099
Created September 20, 2012 13:59
GPGGA translated
while 1:
a=ser.readline()
pos=[]
k=0
STR=[]
for i in range (0,len(a)):
if a[i]==',':
pos.append(i)
k=k+1
for i in range(1,k):
@bazub
bazub / gist:3756109
Created September 20, 2012 14:01
Main window
root=Tk()
root.geometry("420x420+400+100")
root.title("Where am I? by Bazub")
root.bind("<Escape>", lambda e: e.widget.quit())
root.resizable(FALSE,FALSE)
root.mainloop()
@bazub
bazub / gist:3756115
Created September 20, 2012 14:02
Adding an Image
photo=PhotoImage(file="worldlg.gif")
ca=Canvas(root)
ca.create_image(200,123,image=photo)
ca.grid(row=0,column=0,columnspan=2,sticky=N+S+E+W)
@bazub
bazub / gist:3756128
Created September 20, 2012 14:03
Button linked to the function that "translates" GPGGA
butGC=Button(root, text="Get coordinates", command=getcoord)
butGC.grid(row=1,column=0, sticky=N+S+E+W)
var=StringVar()
lab =Label(root, bg='white',width=50,height=2,textvariable=var,justify=CENTER)
lab.grid(row=1, column=1,sticky=N+S+E)
lab2=Label(root)
lab2.grid(row=2,column=0)
@bazub
bazub / gist:3756136
Created September 20, 2012 14:04
Button that takes the user to Google Maps
butG2S=Button(root, text="Go to Maps", command=gomaps)
butG2S.grid(row=3,column=0,columnspan=2, sticky=N+S+E+W)
@bazub
bazub / gist:3756143
Created September 20, 2012 14:05
Button that opens the Database
def golog():
os.system("notepad.exe "+"C:/Users/Bogdan/git/GPS2PC/GPS2PC/log.txt")
butWHIB=Button(root,text="Where have I been?",command=golog)
butWHIB.grid(row=5,column=0,columnspan=2,sticky=N+S+E+W)
@bazub
bazub / gist:3877920
Created October 12, 2012 08:09
Includes
import tesseract
from PIL import Image
@bazub
bazub / gist:3877955
Created October 12, 2012 08:14
Initialize the Tessaract API
api = tesseract.TessBaseAPI()
api.SetOutputName("outputName");
api.Init(".","eng",tesseract.OEM_DEFAULT)
api.SetPageSegMode(tesseract.PSM_AUTO)
@bazub
bazub / gist:4247344
Created December 9, 2012 22:49
Pseudo-code for searching for end-point of ship
Get Start_point(x,y)
if x-3 >=1
mark endpoint (x-3,y) //north
if x+3 <=10
mark endpoint (x+3,y) //south
if y-3 >=1
mark endpoint (x,y-3) //west
if y+3 <=10
mark endpoint (x,y+3) //east
update map