Skip to content

Commit

Permalink
Merge pull request vlachoudis#239 from Effer/master-buffer-fill
Browse files Browse the repository at this point in the history
Buffer fill indicator
  • Loading branch information
vlachoudis committed Feb 16, 2016
2 parents 04f6459 + 585fa70 commit 521e15e
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def __init__(self):
self._pause = False # machine is on Hold
self._alarm = True # Display alarm message if true
self._msg = None
self._sumcline = 0

#----------------------------------------------------------------------
def quit(self, event=None):
Expand Down Expand Up @@ -639,6 +640,10 @@ def stopProbe(self):
if self.gcode.probe.start:
self.gcode.probe.clear()

#----------------------------------------------------------------------
def getBufferFill(self):
return self._sumcline * 100. / RX_BUFFER_SIZE

#----------------------------------------------------------------------
def initRun(self):
self._quit = 0
Expand Down Expand Up @@ -879,6 +884,7 @@ def serialIO(self):

#print "tosend='%s'"%(repr(tosend)),"stack=",sline,"sum=",sum(cline),"wait=",wait,"pause=",self._pause
if tosend is not None and sum(cline) < RX_BUFFER_SIZE:
self._sumcline = sum(cline)
# if isinstance(tosend, list):
# self.serial.write(str(tosend.pop(0)))
# if not tosend: tosend = None
Expand Down
7 changes: 7 additions & 0 deletions bCNC.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ def __init__(self, master, **kw):
self.statusx = Label(frame, foreground="DarkRed", relief=SUNKEN, anchor=W, width=10)
self.statusx.pack(side=RIGHT)

# Buffer gauge
self.bufferGauge = tkExtra.Gauge(frame,height=20, width=20, relief=SUNKEN)
self.bufferGauge.pack(side=RIGHT, fill=X, expand=NO)

# --- Left side ---
frame = Frame(self.paned)
self.paned.add(frame) #, minsize=340)
Expand Down Expand Up @@ -412,6 +416,7 @@ def setStatus(self, msg, force_update=False):
self.statusbar.configText(text=msg, fill="DarkBlue")
if force_update:
self.statusbar.update_idletasks()
self.bufferGauge.update_idletasks()

#-----------------------------------------------------------------------
# Set a status message from an event
Expand Down Expand Up @@ -1954,6 +1959,7 @@ def runEnded(self):
self.statusbar.clear()
self.statusbar.config(background="LightGray")
self.setStatus(_("Run ended"))
self.bufferGauge.setFill(0)

#-----------------------------------------------------------------------
# Send enabled gcode file to the CNC machine
Expand Down Expand Up @@ -2146,6 +2152,7 @@ def _monitorSerial(self):
self.statusbar.setProgress(self._runLines-self.queue.qsize(),
self._gcount)
CNC.vars["msg"] = self.statusbar.msg
self.bufferGauge.setFill(Sender.getBufferFill(self))
if self._selectI>=0 and self._paths:
while self._selectI < self._gcount and self._selectI<len(self._paths):
#print
Expand Down
31 changes: 31 additions & 0 deletions lib/tkExtra.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,7 @@ def draw(self, event=None):

wn = int(width * (self.now - self.low) / self.length)
wd = int(width * (self.done - self.low) / self.length)

if wd >= wn: wd = wn - 1

self.coords(self.currBox, 0, 0, wn, height)
Expand Down Expand Up @@ -4441,6 +4442,36 @@ def updateScrollRegion(self, *args):
self.yscrollcommand(0.0,1.0)
self.client.place_forget()

#===============================================================================
# Gauge Canvas. Pie chart as guage meter
#===============================================================================
class Gauge(Canvas):
def __init__(self, master=None, **kw):
Canvas.__init__(self, master, **kw)

self.gaugeArc = self.create_arc(0, 0, 0, 0,
fill='Green',
width=0,
start = 90)
self.gaugeBorder = self.create_oval(0, 0, 0, 0,
width = 1)
self.Fill = 0.
self.bind('<Configure>', self.draw)

def setFill(self, Fill=0.):
self.Fill = Fill
self.draw()

# ----------------------------------------------------------------------
def draw(self, event=None):
width = self.winfo_width()
height = self.winfo_height()

self.coords(self.gaugeBorder, 2, 2, width-4, height-4)

self.coords(self.gaugeArc, 2, 2, width-4, height-4)
self.itemconfig(self.gaugeArc, extent = self.Fill * 3.6)

#================================================================================
# The following is from idlelib (tabpage.py)
#================================================================================
Expand Down

0 comments on commit 521e15e

Please sign in to comment.