Updated print window with statistics about the print. Filament used, and estimated print time.

master
daid 2012-04-03 12:06:02 +02:00
parent e999faf08a
commit c2ce7b9c24
4 changed files with 26 additions and 7 deletions

View File

@ -25,6 +25,10 @@ class preferencesDialog(configBase.configWindowBase):
c = configBase.SettingRow(left, 'Machine height (mm)', 'machine_height', '200', 'Size of the machine in mm', type = 'preference')
validators.validFloat(c, 10.0)
configBase.TitleRow(left, 'Filament settings')
c = configBase.SettingRow(left, 'Filament density (kg/m3)', 'filament_density', '1300', 'Weight of the filament per m3. Around 1300 for PLA. And around 1040 for ABS. This value is used to estimate the weight if the filament used for the print.', type = 'preference')
validators.validFloat(c, 500.0, 3000.0)
configBase.TitleRow(left, 'Communication settings')
c = configBase.SettingRow(left, 'Serial port', 'serial_port', ['AUTO'] + machineCom.serialList(), 'Serial port to use for communication with the printer', type = 'preference')
c = configBase.SettingRow(left, 'Baudrate', 'serial_baud', '250000', 'Speed of the serial port communication\nNeeds to match your firmware settings\nCommon values are 250000, 115200, 57600', type = 'preference')

View File

@ -24,6 +24,7 @@ class printWindow(wx.Frame):
self.machineCom = None
self.machineConnected = False
self.thread = None
self.gcode = None
self.gcodeList = None
self.printIdx = None
self.bufferLineCount = 4
@ -78,8 +79,13 @@ class printWindow(wx.Frame):
def UpdateProgress(self):
status = ""
if self.gcode != None:
status += "Filament: %.2fm %.2fg\n" % (self.gcode.extrusionAmount / 1000, self.gcode.calculateWeight() * 1000)
status += "Print time: %02d:%02d\n" % (int(self.gcode.totalMoveTimeMinute / 60), int(self.gcode.totalMoveTimeMinute % 60))
if self.printIdx == None:
self.progress.SetValue(0)
if self.gcodeList != None:
status += 'Line: -/%d\n' % (len(self.gcodeList))
else:
self.progress.SetValue(self.printIdx)
status += 'Line: %d/%d\n' % (self.printIdx, len(self.gcodeList))
@ -131,19 +137,19 @@ class printWindow(wx.Frame):
gcodeList.append(line)
gcode = gcodeInterpreter.gcode()
gcode.loadList(gcodeList)
print gcode.extrusionAmount
print gcode.totalMoveTimeMinute
print "Loaded: %s (%d)" % (filename, len(gcodeList))
self.progress.SetRange(len(gcodeList))
self.gcode = gcode
self.gcodeList = gcodeList
self.UpdateButtonStates()
self.UpdateProgress()
def sendLine(self, lineNr):
if lineNr >= len(self.gcodeList):
return
return False
checksum = reduce(lambda x,y:x^y, map(ord, "N%d%s" % (lineNr, self.gcodeList[lineNr])))
self.machineCom.sendCommand("N%d%s*%d" % (lineNr, self.gcodeList[lineNr], checksum))
return True
def PrinterMonitor(self):
skipCount = 0
@ -151,7 +157,7 @@ class printWindow(wx.Frame):
line = self.machineCom.readline()
if line == None:
self.machineConnected = False
wx.CallAfter(self.UpdateButtonState)
wx.CallAfter(self.UpdateButtonStates)
return
if self.machineConnected:
while self.sendCnt > 0:
@ -160,14 +166,14 @@ class printWindow(wx.Frame):
self.sendCnt -= 1
elif line.startswith("start"):
self.machineConnected = True
wx.CallAfter(self.UpdateButtonState)
wx.CallAfter(self.UpdateButtonStates)
if self.printIdx != None:
if line.startswith("ok"):
if skipCount > 0:
skipCount -= 1
else:
self.sendLine(self.printIdx)
self.printIdx += 1
if self.sendLine(self.printIdx):
self.printIdx += 1
wx.CallAfter(self.UpdateProgress)
elif "resend" in line.lower() or "rs" in line:
try:
@ -177,3 +183,4 @@ class printWindow(wx.Frame):
lineNr=int(line.split()[1])
self.printIdx = lineNr
#we should actually resend the line here, but we also get an "ok" for each error from Marlin. And thus we'll resend on the OK.

View File

@ -7,6 +7,7 @@ import re
import os
from util import util3d
from util import profile
class gcodePath():
def __init__(self, newType, pathType, startPoint):
@ -31,6 +32,12 @@ class gcode():
def loadList(self, l):
self._load(l)
def calculateWeight(self):
#Calculates the weight of the filament in kg
radius = float(profile.getProfileSetting('filament_diameter')) / 2
volumeM3 = (self.extrusionAmount * (math.pi * radius * radius)) / (1000*1000*1000)
return volumeM3 * float(profile.getPreference('filament_density'))
def _load(self, gcodeFile):
filePos = 0
pos = util3d.Vector3()

View File

@ -69,6 +69,7 @@ preferencesDefaultSettings = {
'machine_width': '205',
'machine_depth': '205',
'machine_height': '200',
'filament_density': '1300',
'steps_per_e': '0',
'serial_port': 'AUTO',
'serial_baud': '250000',