diff --git a/gui/__pycache__/labrobot.cpython-37.pyc b/gui/__pycache__/labrobot.cpython-37.pyc new file mode 100644 index 0000000..d339a03 Binary files /dev/null and b/gui/__pycache__/labrobot.cpython-37.pyc differ diff --git a/gui/ser_one.py b/gui/ser_one.py index 61b34d6..93345d1 100644 --- a/gui/ser_one.py +++ b/gui/ser_one.py @@ -1,5 +1,5 @@ import tkinter as tk -from tkinter.constants import W +from tkinter.constants import W, X import serial.tools.list_ports import functools import tkinter.ttk as ttk @@ -68,53 +68,131 @@ scb.config(command=txt.yview) txt.config(yscrollcommand=scb.set) txt.tag_configure('small',font=('Verdana',8),foreground='black') +b1 = ttk.Button(uprightframe,text='Home All',width=12) +b1.grid(row=0,column=0,sticky='nw') +b2 = ttk.Button(uprightframe,text='Home X',width=12) +b2.grid(row=0,column=1,sticky='ne') +b3 = ttk.Button(uprightframe,text='Home Y',width=12) +b3.grid(row=1,column=0,sticky='nw') +b4 = ttk.Button(uprightframe,text='Home Z',width=12) +b4.grid(row=1,column=1,sticky='ne') +b6 = ttk.Button(uprightframe,text='Home P',width=12) +b6.grid(row=2,column=0,sticky='nw') +b7 = ttk.Button(uprightframe,text='Get Position',width=12) +b7.grid(row=2,column=1,sticky='ne') +l1 = ttk.Label(uprightframe,text="Enter G-Code").grid(row=3,column=0) +e1 = ttk.Entry(uprightframe).grid(row=3,column=1) +b5 = ttk.Button(uprightframe,text='Send Code') +b5.grid(row=4,column=1,sticky="ne") +b8 = ttk.Button(downrightframe,text='Next Tip') +b8.grid(row=0,column=0,sticky='ne') +b9 = ttk.Button(downrightframe,text='Up') +b9.grid(row=0,column=1,sticky='ne') +b10 = ttk.Button(downrightframe,text='Down') +b10.grid(row=0,column=2,sticky='ne') + +### Parts ## init Labrobot -lpb = lrb.LabPipBlock(15,1,70,50,5,108,86) + pip = lrb.LabPip(vol=1000,top=22) pip.fe =5000 +xoffset = tk.DoubleVar() +xoffset.set(15) +yoffset = tk.DoubleVar() +yoffset.set(1.6) +rows = tk.IntVar() +rows.set(5) +cols = tk.IntVar() +cols.set(10) +xspace = tk.DoubleVar() +xspace.set(10.8) +yspace = tk.DoubleVar() +yspace.set(18.3) +tipvol = tk.IntVar() +tipvol.set(1000) + +lpb = lrb.LabPipBlock(xoffset.get(),1,70,50,5,108,86) + +partframe = ttk.Frame(notebook) +#partframe.rowconfigure(0,weight=1) +partframe.columnconfigure(0,weight=1) +notebook.add(partframe,text='parts',underline=0) + +pipblockframe =ttk.LabelFrame(partframe,text='Tip Block') +pipblockframe.grid(column=0,row=0,sticky='wns',padx=5,pady=5) +pl1 = ttk.Label(pipblockframe,text='X offset').grid(column=0,row=0,padx=5) +pe1 = ttk.Entry(pipblockframe,textvariable=xoffset) +pe1.grid(column=1,row=0,sticky='e') +pl2 = ttk.Label(pipblockframe,text='rows').grid(column=0,row=2,padx=5) +pe2 = ttk.Entry(pipblockframe,textvariable=rows) +pe2.grid(column=1,row=2,sticky='e') +pl3 = ttk.Label(pipblockframe,text='columns').grid(column=0,row=3,padx=5) +pe3 = ttk.Entry(pipblockframe,textvariable=cols) +pe3.grid(column=1,row=3,sticky='e') +pl4 = ttk.Label(pipblockframe,text='x space').grid(column=0,row=4,padx=5) +pe4 = ttk.Entry(pipblockframe,textvariable=xspace) +pe4.grid(column=1,row=4,sticky='e') +pl5 = ttk.Label(pipblockframe,text='y space').grid(column=0,row=5,padx=5) +pe5 = ttk.Entry(pipblockframe,textvariable=yspace) +pe5.grid(column=1,row=5,sticky='e') +pl6 = ttk.Label(pipblockframe,text='Y offset').grid(column=0,row=1,padx=5) +pe6 = ttk.Entry(pipblockframe,textvariable=yoffset) +pe6.grid(column=1,row=1,sticky='e') +ttk.Separator(pipblockframe, orient=tk.HORIZONTAL).grid(row=6,sticky='ew') +pl7 = ttk.Label(pipblockframe,text='Tip Volume').grid(column=0,row=7,padx=5) +pe7 = ttk.Entry(pipblockframe,textvariable=tipvol) +pe7.grid(column=1,row=7,sticky='e') + +### commands and bindings + def homeAll(): serialObj.write(b'\n') + +b1.configure(command=homeAll) + def homeX(): serialObj.write(b'\n') +b2.configure(command=homeX) + def homeY(): serialObj.write(b'\n') +b3.configure(command=homeY) + def homeZ(): serialObj.write(b'\n') +b4.configure(command=homeZ) + def homeP(): serialObj.write(b'\n') +b6.configure(command=homeP) + def getPos(): serialObj.write(b'\n') +b7.configure(command=getPos) + def do_gcode(): s = e1.get() s = s + '\n' print(s) serialObj.write(s.encode('utf-8')) +b5.configure(command=do_gcode) def upTip(): serialObj.write(pip.up().encode('utf-8')) +b9.configure(command=upTip) def downTip(): serialObj.write(pip.down().encode('utf-8')) +b10.configure(command=downTip) def nextTip(): upTip() serialObj.write(pip.get_tip(lpb.next()).encode('utf-8')) downTip() - - -b1 = tk.Button(uprightframe,text='Home All',width=12,command=homeAll).grid(row=0,column=0,sticky='nw') -b2 = tk.Button(uprightframe,text='Home X',width=12,command=homeX).grid(row=0,column=1,sticky='ne') -b3 = tk.Button(uprightframe,text='Home Y',width=12,command=homeY).grid(row=1,column=0,sticky='nw') -b4 = tk.Button(uprightframe,text='Home Z',width=12,command=homeZ).grid(row=1,column=1,sticky='ne') -b6 = tk.Button(uprightframe,text='Home P',width=12,command=homeP).grid(row=2,column=0,sticky='nw') -b7 = tk.Button(uprightframe,text='Get Position',width=12,command=getPos).grid(row=2,column=1,sticky='ne') -l1 = tk.Label(uprightframe,text="Enter G-Code").grid(row=3,column=0) -e1 = tk.Entry(uprightframe).grid(row=3,column=1) -b5 = tk.Button(uprightframe,text='Send Code',command=do_gcode).grid(row=4,column=1,sticky="ne") - -b8 = tk.Button(downrightframe,text='Next Tip',command=nextTip).grid(row=0,column=0,sticky='ne') + +b8.configure(command=nextTip) def checkSerialPort(): if serialObj.isOpen() and serialObj.in_waiting: