Commit 05058c5b authored by kliment's avatar kliment

Merge pull request #201 from kliment/experimental

Merge experimental back into master
parents 65e01214 2a15576a
...@@ -25,6 +25,10 @@ now there is only one, for German. New ones can be created: ...@@ -25,6 +25,10 @@ now there is only one, for German. New ones can be created:
# Edit the .po file to add messages for newlang # Edit the .po file to add messages for newlang
msgfmt -o ${newlang}.mo ${newlang}.po msgfmt -o ${newlang}.mo ${newlang}.po
To update a previously created message catalog from the template, use :
msgmerge -U locale/fr/LC_MESSAGES/${lang}.po locale/pronterface.pot
As currently coded, the default location for these message catalogs is As currently coded, the default location for these message catalogs is
/usr/share/pronterface/locale/ /usr/share/pronterface/locale/
......
This diff is collapsed.
#!/usr/bin/python
# This file is part of the Printrun suite.
#
# Printrun is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Printrun is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
import wx, random
from bufferedcanvas import *
class Graph(BufferedCanvas):
'''A class to show a Graph with Pronterface.'''
def __init__(self, parent, id, pos=wx.DefaultPosition,
size=wx.DefaultSize, style=0):
# Forcing a no full repaint to stop flickering
style = style | wx.NO_FULL_REPAINT_ON_RESIZE
#call super function
#super(Graph, self).__init__(parent, id, pos, size, style)
BufferedCanvas.__init__(self, parent, id)
self.SetSize(wx.Size(170, 100))
self.extruder0temps = [0]
self.extruder0targettemps = [0]
self.extruder1temps = [0]
self.extruder1targettemps = [0]
self.bedtemps = [0]
self.bedtargettemps = [0]
self.timer = wx.Timer(self)
self.Bind(wx.EVT_TIMER, self.updateTemperatures, self.timer)
self.maxyvalue = 250
self.ybars = 5
self.xbars = 6 # One bar per 10 second
self.xsteps = 60 # Covering 1 minute in the graph
self.y_offset = 1 # This is to show the line even when value is 0 and maxyvalue
self._lastyvalue = 0
#self.sizer = wx.BoxSizer(wx.HORIZONTAL)
#self.sizer.Add(wx.Button(self, -1, "Button1", (0,0)))
#self.SetSizer(self.sizer)
def OnPaint(self, evt):
dc = wx.PaintDC(self)
gc = wx.GraphicsContext.Create(dc)
def Destroy(self):
#call the super method
super(wx.Panel, self).Destroy()
def updateTemperatures(self, event):
self.AddBedTemperature(self.bedtemps[-1])
self.AddBedTargetTemperature(self.bedtargettemps[-1])
self.AddExtruder0Temperature(self.extruder0temps[-1])
self.AddExtruder0TargetTemperature(self.extruder0targettemps[-1])
#self.AddExtruder1Temperature(self.extruder1temps[-1])
#self.AddExtruder1TargetTemperature(self.extruder1targettemps[-1])
self.Refresh()
def drawgrid(self, dc, gc):
#cold,medium,hot = wx.Colour(0,167,223),wx.Colour(239,233,119),wx.Colour(210,50.100)
#col1 = wx.Colour(255,0,0, 255)
#col2 = wx.Colour(255,255,255, 128)
#b = gc.CreateLinearGradientBrush(0, 0, w, h, col1, col2)
gc.SetPen(wx.Pen(wx.Colour(255,0,0,0), 4))
#gc.SetBrush(gc.CreateBrush(wx.Brush(wx.Colour(245,245,255,252))))
#gc.SetBrush(b)
gc.DrawRectangle(0, 0, self.width, self.height)
#gc.SetBrush(wx.Brush(wx.Colour(245,245,255,52)))
#gc.SetBrush(gc.CreateBrush(wx.Brush(wx.Colour(0,0,0,255))))
#gc.SetPen(wx.Pen(wx.Colour(255,0,0,0), 4))
#gc.DrawLines(wx.Point(0,0), wx.Point(50,10))
#path = gc.CreatePath()
#path.MoveToPoint(0.0, 0.0)
#path.AddLineToPoint(0.0, 100.0)
#path.AddLineToPoint(100.0, 0.0)
#path.AddCircle( 50.0, 50.0, 50.0 )
#path.CloseSubpath()
#gc.DrawPath(path)
#gc.StrokePath(path)
font = wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD)
gc.SetFont(font, wx.Colour(23,44,44))
dc.SetPen(wx.Pen(wx.Colour(225,225,225), 1))
for x in range(self.xbars):
dc.DrawLine(x*(float(self.width)/self.xbars), 0, x*(float(self.width)/self.xbars), self.height)
dc.SetPen(wx.Pen(wx.Colour(225,225,225), 1))
for y in range(self.ybars):
y_pos = y*(float(self.height)/self.ybars)
dc.DrawLine(0,y_pos, self.width,y_pos)
gc.DrawText(unicode(int(self.maxyvalue - (y * (self.maxyvalue/self.ybars)))), 1, y_pos - (font.GetPointSize() / 2))
if self.timer.IsRunning() == False:
font = wx.Font(14, wx.DEFAULT, wx.NORMAL, wx.BOLD)
gc.SetFont(font, wx.Colour(3,4,4))
gc.DrawText("Graph offline", self.width/2 - (font.GetPointSize() * 3), self.height/2 - (font.GetPointSize() * 1))
#dc.DrawCircle(50,50, 1)
#gc.SetPen(wx.Pen(wx.Colour(255,0,0,0), 1))
#gc.DrawLines([[20,30], [10,53]])
#dc.SetPen(wx.Pen(wx.Colour(255,0,0,0), 1))
def drawtemperature(self, dc, gc, temperature_list, text, text_xoffset, r, g, b, a):
if self.timer.IsRunning() == False:
dc.SetPen(wx.Pen(wx.Colour(128,128,128,128), 1))
else:
dc.SetPen(wx.Pen(wx.Colour(r,g,b,a), 1))
x_add = float(self.width)/self.xsteps
x_pos = float(0.0)
lastxvalue = float(0.0)
for temperature in (temperature_list):
y_pos = int((float(self.height-self.y_offset)/self.maxyvalue)*temperature) + self.y_offset
if (x_pos > 0.0): # One need 2 points to draw a line.
dc.DrawLine(lastxvalue,self.height-self._lastyvalue, x_pos, self.height-y_pos)
lastxvalue = x_pos
x_pos = float(x_pos) + x_add
self._lastyvalue = y_pos
if len(text) > 0:
font = wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.BOLD)
#font = wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL)
if self.timer.IsRunning() == False:
gc.SetFont(font, wx.Colour(128,128,128))
else:
gc.SetFont(font, wx.Colour(r,g,b))
#gc.DrawText(text, self.width - (font.GetPointSize() * ((len(text) * text_xoffset + 1))), self.height - self._lastyvalue - (font.GetPointSize() / 2))
gc.DrawText(text, x_pos - x_add - (font.GetPointSize() * ((len(text) * text_xoffset + 1))), self.height - self._lastyvalue - (font.GetPointSize() / 2))
#gc.DrawText(text, self.width - (font.GetPixelSize().GetWidth() * ((len(text) * text_xoffset + 1) + 1)), self.height - self._lastyvalue - (font.GetPointSize() / 2))
def drawbedtemp(self, dc, gc):
self.drawtemperature(dc, gc, self.bedtemps, "Bed",2, 255,0,0, 128)
def drawbedtargettemp(self, dc, gc):
self.drawtemperature(dc, gc, self.bedtargettemps, "Bed Target",2, 255,120,0, 128)
def drawextruder0temp(self, dc, gc):
self.drawtemperature(dc, gc, self.extruder0temps, "Ex0",1, 0,155,255, 128)
def drawextruder0targettemp(self, dc, gc):
self.drawtemperature(dc, gc, self.extruder0targettemps, "Ex0 Target",2, 0,5,255, 128)
def drawextruder1temp(self, dc, gc):
self.drawtemperature(dc, gc, self.extruder1temps, "Ex1",3, 55,55,0, 128)
def drawextruder1targettemp(self, dc, gc):
self.drawtemperature(dc, gc, self.extruder1targettemps, "Ex1 Target",2, 55,55,0, 128)
def SetBedTemperature(self, value):
self.bedtemps.pop()
self.bedtemps.append(value)
def AddBedTemperature(self, value):
self.bedtemps.append(value)
if (len(self.bedtemps)-1) * float(self.width)/self.xsteps > self.width:
self.bedtemps.pop(0)
def SetBedTargetTemperature(self, value):
self.bedtargettemps.pop()
self.bedtargettemps.append(value)
def AddBedTargetTemperature(self, value):
self.bedtargettemps.append(value)
if (len(self.bedtargettemps)-1) * float(self.width)/self.xsteps > self.width:
self.bedtargettemps.pop(0)
def SetExtruder0Temperature(self, value):
self.extruder0temps.pop()
self.extruder0temps.append(value)
def AddExtruder0Temperature(self, value):
self.extruder0temps.append(value)
if (len(self.extruder0temps)-1) * float(self.width)/self.xsteps > self.width:
self.extruder0temps.pop(0)
def SetExtruder0TargetTemperature(self, value):
self.extruder0targettemps.pop()
self.extruder0targettemps.append(value)
def AddExtruder0TargetTemperature(self, value):
self.extruder0targettemps.append(value)
if (len(self.extruder0targettemps)-1) * float(self.width)/self.xsteps > self.width:
self.extruder0targettemps.pop(0)
def SetExtruder1Temperature(self, value):
self.extruder1temps.pop()
self.extruder1temps.append(value)
def AddExtruder1Temperature(self, value):
self.extruder1temps.append(value)
if (len(self.extruder1temps)-1) * float(self.width)/self.xsteps > self.width:
self.extruder1temps.pop(0)
def SetExtruder1TargetTemperature(self, value):
self.extruder1targettemps.pop()
self.extruder1targettemps.append(value)
def AddExtruder1TargetTemperature(self, value):
self.extruder1targettemps.append(value)
if (len(self.extruder1targettemps)-1) * float(self.width)/self.xsteps > self.width:
self.extruder1targettemps.pop(0)
def StartPlotting(self, time):
self.Refresh()
self.timer.Start(time)
def StopPlotting(self):
self.timer.Stop()
self.Refresh()
def draw(self, dc, w, h):
dc.Clear()
gc = wx.GraphicsContext.Create(dc)
self.width = w
self.height = h
self.drawgrid(dc, gc)
self.drawbedtargettemp(dc, gc)
self.drawbedtemp(dc, gc)
self.drawextruder0targettemp(dc, gc)
self.drawextruder0temp(dc, gc)
self.drawextruder1targettemp(dc, gc)
self.drawextruder1temp(dc, gc)
...@@ -47,13 +47,21 @@ class window(wx.Frame): ...@@ -47,13 +47,21 @@ class window(wx.Frame):
else: else:
event.Skip() event.Skip()
def key(self, event): def key(self, event):
x=event.GetKeyCode() x=event.GetKeyCode()
#print x if event.ShiftDown():
cx,cy=self.p.translate
if x==wx.WXK_UP:
self.p.zoom(cx,cy,1.2)
if x==wx.WXK_DOWN:
self.p.zoom(cx,cy,1/1.2)
else:
if x==wx.WXK_UP: if x==wx.WXK_UP:
self.p.layerup() self.p.layerup()
if x==wx.WXK_DOWN: if x==wx.WXK_DOWN:
self.p.layerdown() self.p.layerdown()
#print x
#print p.lines.keys() #print p.lines.keys()
def zoom(self, event): def zoom(self, event):
......
This diff is collapsed.
# French Plater Message Catalog
# Copyright (C) 2012 Guillaume Seguin
# Guillaume Seguin <guillaume@segu.in>, 2012.
#
msgid ""
msgstr ""
"Project-Id-Version: Plater\n"
"POT-Creation-Date: 2012-02-26 02:40+CET\n"
"PO-Revision-Date: 2012-02-26 02:41+0100\n"
"Last-Translator: Guillaume Seguin <guillaume@segu.in>\n"
"Language-Team: FR <guillaume@segu.in>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"
#: plater.py:247
msgid "Plate building tool"
msgstr "Outil d'assemblage de plateau"
#: plater.py:253
msgid "Clear"
msgstr "Vider"
#: plater.py:254
msgid "Load"
msgstr "Charger"
#: plater.py:256
msgid "Export"
msgstr "Exporter"
#: plater.py:259
msgid "Done"
msgstr "Terminé"
#: plater.py:261
msgid "Cancel"
msgstr "Annuler"
#: plater.py:263
msgid "Snap to Z = 0"
msgstr "Poser en Z = 0"
#: plater.py:264
msgid "Put at 100, 100"
msgstr "Placer en 100, 100"
#: plater.py:265
msgid "Delete"
msgstr "Supprimer"
#: plater.py:266
msgid "Auto"
msgstr "Auto"
#: plater.py:290
msgid "Autoplating"
msgstr "Placement auto"
#: plater.py:318
msgid "Bed full, sorry sir :("
msgstr "Le lit est plein, désolé :("
#: plater.py:328
msgid ""
"Are you sure you want to clear the grid? All unsaved changes will be lost."
msgstr ""
"Êtes vous sur de vouloir vider la grille ? Toutes les modifications non "
"enregistrées seront perdues."
#: plater.py:328
msgid "Clear the grid?"
msgstr "Vider la grille ?"
#: plater.py:370
msgid "Pick file to save to"
msgstr "Choisir le fichier dans lequel enregistrer"
#: plater.py:371
msgid "STL files (;*.stl;*.STL;)"
msgstr "Fichiers STL (;*.stl;*.STL;)"
#: plater.py:391
msgid "wrote %s"
msgstr "%s écrit"
#: plater.py:394
msgid "Pick file to load"
msgstr "Choisir le fichier à charger"
#: plater.py:395
msgid "STL files (;*.stl;*.STL;)|*.stl|OpenSCAD files (;*.scad;)|*.scad"
msgstr "Fichiers STL (;*.stl;*.STL;)|*.stl|Fichiers OpenSCAD (;*.scad;)|*.scad"
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2012-01-09 15:07+CET\n" "POT-Creation-Date: 2012-02-26 02:40+CET\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
...@@ -15,79 +15,79 @@ msgstr "" ...@@ -15,79 +15,79 @@ msgstr ""
"Generated-By: pygettext.py 1.5\n" "Generated-By: pygettext.py 1.5\n"
#: plater.py:223 #: plater.py:247
msgid "Plate building tool" msgid "Plate building tool"
msgstr "" msgstr ""
#: plater.py:229 #: plater.py:253
msgid "Clear" msgid "Clear"
msgstr "" msgstr ""
#: plater.py:230 #: plater.py:254
msgid "Load" msgid "Load"
msgstr "" msgstr ""
#: plater.py:232 #: plater.py:256
msgid "Export" msgid "Export"
msgstr "" msgstr ""
#: plater.py:235 #: plater.py:259
msgid "Done" msgid "Done"
msgstr "" msgstr ""
#: plater.py:237 #: plater.py:261
msgid "Cancel" msgid "Cancel"
msgstr "" msgstr ""
#: plater.py:239 #: plater.py:263
msgid "Snap to Z = 0" msgid "Snap to Z = 0"
msgstr "" msgstr ""
#: plater.py:240 #: plater.py:264
msgid "Put at 100, 100" msgid "Put at 100, 100"
msgstr "" msgstr ""
#: plater.py:241 #: plater.py:265
msgid "Delete" msgid "Delete"
msgstr "" msgstr ""
#: plater.py:242 #: plater.py:266
msgid "Auto" msgid "Auto"
msgstr "" msgstr ""
#: plater.py:266 #: plater.py:290
msgid "Autoplating" msgid "Autoplating"
msgstr "" msgstr ""
#: plater.py:294 #: plater.py:318
msgid "Bed full, sorry sir :(" msgid "Bed full, sorry sir :("
msgstr "" msgstr ""
#: plater.py:304 #: plater.py:328
msgid "Are you sure you want to clear the grid? All unsaved changes will be lost." msgid "Are you sure you want to clear the grid? All unsaved changes will be lost."
msgstr "" msgstr ""
#: plater.py:304 #: plater.py:328
msgid "Clear the grid?" msgid "Clear the grid?"
msgstr "" msgstr ""
#: plater.py:346 #: plater.py:370
msgid "Pick file to save to" msgid "Pick file to save to"
msgstr "" msgstr ""
#: plater.py:347 #: plater.py:371
msgid "STL files (;*.stl;)" msgid "STL files (;*.stl;*.STL;)"
msgstr "" msgstr ""
#: plater.py:367 #: plater.py:391
msgid "wrote " msgid "wrote %s"
msgstr "" msgstr ""
#: plater.py:370 #: plater.py:394
msgid "Pick file to load" msgid "Pick file to load"
msgstr "" msgstr ""
#: plater.py:371 #: plater.py:395
msgid "STL files (;*.stl;)|*.stl|OpenSCAD files (;*.scad;)|*.scad" msgid "STL files (;*.stl;*.STL;)|*.stl|OpenSCAD files (;*.scad;)|*.scad"
msgstr "" msgstr ""
This diff is collapsed.
...@@ -256,8 +256,10 @@ class stlwin(wx.Frame): ...@@ -256,8 +256,10 @@ class stlwin(wx.Frame):
self.eb = wx.Button(self.panel, label=_("Export"), pos=(100, 0)) self.eb = wx.Button(self.panel, label=_("Export"), pos=(100, 0))
self.eb.Bind(wx.EVT_BUTTON, self.export) self.eb.Bind(wx.EVT_BUTTON, self.export)
else: else:
self.eb = wx.Button(self.panel, label=_("Done"), pos=(100, 0)) self.eb = wx.Button(self.panel, label=_("Export"), pos=(200, 205))
self.eb.Bind(wx.EVT_BUTTON, lambda e: self.done(e, callback)) self.eb.Bind(wx.EVT_BUTTON, self.export)
self.edb = wx.Button(self.panel, label=_("Done"), pos=(100, 0))
self.edb.Bind(wx.EVT_BUTTON, lambda e: self.done(e, callback))
self.eb = wx.Button(self.panel, label=_("Cancel"), pos=(200, 0)) self.eb = wx.Button(self.panel, label=_("Cancel"), pos=(200, 0))
self.eb.Bind(wx.EVT_BUTTON, lambda e: self.Destroy()) self.eb.Bind(wx.EVT_BUTTON, lambda e: self.Destroy())
self.sb = wx.Button(self.panel, label=_("Snap to Z = 0"), pos=(00, 255)) self.sb = wx.Button(self.panel, label=_("Snap to Z = 0"), pos=(00, 255))
...@@ -388,7 +390,7 @@ class stlwin(wx.Frame): ...@@ -388,7 +390,7 @@ class stlwin(wx.Frame):
facets += i.facets facets += i.facets
sf.close() sf.close()
stltool.emitstl(name, facets, "plater_export") stltool.emitstl(name, facets, "plater_export")
print _("wrote "), name print _("wrote %s") % name
def right(self, event): def right(self, event):
dlg = wx.FileDialog(self, _("Pick file to load"), self.basedir, style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) dlg = wx.FileDialog(self, _("Pick file to load"), self.basedir, style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with Printrun. If not, see <http://www.gnu.org/licenses/>. # along with Printrun. If not, see <http://www.gnu.org/licenses/>.
from serial import Serial from serial import Serial, SerialException
from threading import Thread from threading import Thread
from select import error as SelectError from select import error as SelectError
import time, getopt, sys import time, getopt, sys
...@@ -47,6 +47,7 @@ class printcore(): ...@@ -47,6 +47,7 @@ class printcore():
self.endcb=None#impl () self.endcb=None#impl ()
self.onlinecb=None#impl () self.onlinecb=None#impl ()
self.loud=False#emit sent and received lines to terminal self.loud=False#emit sent and received lines to terminal
self.greetings=['start','Grbl ']
if port is not None and baud is not None: if port is not None and baud is not None:
#print port, baud #print port, baud
self.connect(port, baud) self.connect(port, baud)
...@@ -100,6 +101,12 @@ class printcore(): ...@@ -100,6 +101,12 @@ class printcore():
break break
else: else:
raise raise
except SerialException, e:
print "Can't read from printer (disconnected?)."
break
except OSError, e:
print "Can't read from printer (disconnected?)."
break
if(len(line)>1): if(len(line)>1):
self.log+=[line] self.log+=[line]
...@@ -112,10 +119,10 @@ class printcore(): ...@@ -112,10 +119,10 @@ class printcore():
print "RECV: ",line.rstrip() print "RECV: ",line.rstrip()
if(line.startswith('DEBUG_')): if(line.startswith('DEBUG_')):
continue continue
if(line.startswith('start') or line.startswith('ok')): if(line.startswith(tuple(self.greetings)) or line.startswith('ok')):
self.clear=True self.clear=True
if(line.startswith('start') or line.startswith('ok') or "T:" in line): if(line.startswith(tuple(self.greetings)) or line.startswith('ok') or "T:" in line):
if (not self.online or line.startswith('start')) and self.onlinecb is not None: if (not self.online or line.startswith(tuple(self.greetings))) and self.onlinecb is not None:
try: try:
self.onlinecb() self.onlinecb()
except: except:
...@@ -279,7 +286,10 @@ class printcore(): ...@@ -279,7 +286,10 @@ class printcore():
self.sendcb(command) self.sendcb(command)
except: except:
pass pass
try:
self.printer.write(str(command+"\n")) self.printer.write(str(command+"\n"))
except SerialException, e:
print "Can't write to printer (disconnected?)."
if __name__ == '__main__': if __name__ == '__main__':
baud = 115200 baud = 115200
......
...@@ -37,6 +37,13 @@ class dispframe(wx.Frame): ...@@ -37,6 +37,13 @@ class dispframe(wx.Frame):
self.p=printer self.p=printer
self.pic=wx.StaticBitmap(self) self.pic=wx.StaticBitmap(self)
self.bitmap=wx.EmptyBitmap(*res) self.bitmap=wx.EmptyBitmap(*res)
self.bbitmap=wx.EmptyBitmap(*res)
dc=wx.MemoryDC()
dc.SelectObject(self.bbitmap)
dc.SetBackground(wx.Brush("black"))
dc.Clear()
dc.SelectObject(wx.NullBitmap)
self.SetBackgroundColour("black") self.SetBackgroundColour("black")
self.pic.Hide() self.pic.Hide()
self.pen=wx.Pen("white") self.pen=wx.Pen("white")
...@@ -61,20 +68,33 @@ class dispframe(wx.Frame): ...@@ -61,20 +68,33 @@ class dispframe(wx.Frame):
self.pic.SetBitmap(self.bitmap) self.pic.SetBitmap(self.bitmap)
self.pic.Show() self.pic.Show()
self.Refresh() self.Refresh()
#self.pic.SetBitmap(self.bitmap)
except: except:
raise
pass pass
def showimgdelay(self,image):
self.drawlayer(image)
self.pic.Show()
self.Refresh()
# time.sleep(self.interval)
#self.pic.Hide()
self.Refresh()
if self.p!=None and self.p.online:
self.p.send_now("G91")
self.p.send_now("G1 Z%f F300"%(self.thickness,))
self.p.send_now("G90")
def nextimg(self,event): def nextimg(self,event):
#print "b"
if self.index<len(self.layers): if self.index<len(self.layers):
i=self.index i=self.index
#print self.layers[i] #print self.layers[i]
print i print i
wx.CallAfter(self.drawlayer,self.layers[i]) wx.CallAfter(self.showimgdelay,self.layers[i])
if self.p!=None: wx.FutureCall(1000*self.interval,self.pic.Hide)
self.p.send_now("G91")
self.p.send_now("G1 Z%f F300"%(self.thickness,))
self.p.send_now("G90")
self.index+=1 self.index+=1
else: else:
print "end" print "end"
...@@ -84,7 +104,7 @@ class dispframe(wx.Frame): ...@@ -84,7 +104,7 @@ class dispframe(wx.Frame):
wx.CallAfter(self.timer.Stop) wx.CallAfter(self.timer.Stop)
def present(self,layers,interval=0.5,thickness=0.4,scale=20,size=(800,600)): def present(self,layers,interval=0.5,pause=0.2,thickness=0.4,scale=20,size=(800,600)):
wx.CallAfter(self.pic.Hide) wx.CallAfter(self.pic.Hide)
wx.CallAfter(self.Refresh) wx.CallAfter(self.Refresh)
self.layers=layers self.layers=layers
...@@ -92,10 +112,11 @@ class dispframe(wx.Frame): ...@@ -92,10 +112,11 @@ class dispframe(wx.Frame):
self.thickness=thickness self.thickness=thickness
self.index=0 self.index=0
self.size=size self.size=size
self.interval=interval
self.timer=wx.Timer(self,1) self.timer=wx.Timer(self,1)
self.timer.Bind(wx.EVT_TIMER,self.nextimg) self.timer.Bind(wx.EVT_TIMER,self.nextimg)
self.Bind(wx.EVT_TIMER,self.nextimg) self.Bind(wx.EVT_TIMER,self.nextimg)
self.timer.Start(1000*interval) self.timer.Start(1000*interval+1000*pause)
#print "x" #print "x"
...@@ -111,16 +132,19 @@ class setframe(wx.Frame): ...@@ -111,16 +132,19 @@ class setframe(wx.Frame):
wx.StaticText(self.panel,-1,"Layer:",pos=(0,30)) wx.StaticText(self.panel,-1,"Layer:",pos=(0,30))
wx.StaticText(self.panel,-1,"mm",pos=(130,30)) wx.StaticText(self.panel,-1,"mm",pos=(130,30))
self.thickness=wx.TextCtrl(self.panel,-1,"0.5",pos=(50,30)) self.thickness=wx.TextCtrl(self.panel,-1,"0.5",pos=(50,30))
wx.StaticText(self.panel,-1,"Interval:",pos=(0,60)) wx.StaticText(self.panel,-1,"Exposure:",pos=(0,60))
wx.StaticText(self.panel,-1,"s",pos=(130,60)) wx.StaticText(self.panel,-1,"s",pos=(130,60))
self.interval=wx.TextCtrl(self.panel,-1,"0.5",pos=(50,60)) self.interval=wx.TextCtrl(self.panel,-1,"0.5",pos=(50,60))
wx.StaticText(self.panel,-1,"Scale:",pos=(0,90)) wx.StaticText(self.panel,-1,"Blank:",pos=(0,90))
wx.StaticText(self.panel,-1,"x",pos=(130,90)) wx.StaticText(self.panel,-1,"s",pos=(130,90))
self.scale=wx.TextCtrl(self.panel,-1,"10",pos=(50,90)) self.delay=wx.TextCtrl(self.panel,-1,"0.5",pos=(50,90))
wx.StaticText(self.panel,-1,"Scale:",pos=(0,120))
wx.StaticText(self.panel,-1,"x",pos=(130,120))
self.scale=wx.TextCtrl(self.panel,-1,"5",pos=(50,120))
wx.StaticText(self.panel,-1,"X:",pos=(160,30)) wx.StaticText(self.panel,-1,"X:",pos=(160,30))
self.X=wx.TextCtrl(self.panel,-1,"800",pos=(180,30)) self.X=wx.TextCtrl(self.panel,-1,"1024",pos=(180,30))
wx.StaticText(self.panel,-1,"Y:",pos=(160,60)) wx.StaticText(self.panel,-1,"Y:",pos=(160,60))
self.Y=wx.TextCtrl(self.panel,-1,"600",pos=(180,60)) self.Y=wx.TextCtrl(self.panel,-1,"768",pos=(180,60))
self.bload=wx.Button(self.panel,-1,"Present",pos=(0,150)) self.bload=wx.Button(self.panel,-1,"Present",pos=(0,150))
self.bload.Bind(wx.EVT_BUTTON,self.startdisplay) self.bload.Bind(wx.EVT_BUTTON,self.startdisplay)
self.Show() self.Show()
...@@ -146,7 +170,7 @@ class setframe(wx.Frame): ...@@ -146,7 +170,7 @@ class setframe(wx.Frame):
self.f.ShowFullScreen(1) self.f.ShowFullScreen(1)
l=self.layers[0][:] l=self.layers[0][:]
#l=list(reversed(l)) #l=list(reversed(l))
self.f.present(l,thickness=float(self.thickness.GetValue()),interval=float(self.interval.GetValue()),scale=float(self.scale.GetValue()), size=(float(self.X.GetValue()),float(self.Y.GetValue()))) self.f.present(l,thickness=float(self.thickness.GetValue()),interval=float(self.interval.GetValue()),scale=float(self.scale.GetValue()),pause=float(self.delay.GetValue()), size=(float(self.X.GetValue()),float(self.Y.GetValue())))
if __name__=="__main__": if __name__=="__main__":
a=wx.App() a=wx.App()
......
...@@ -274,7 +274,7 @@ class pronsole(cmd.Cmd): ...@@ -274,7 +274,7 @@ class pronsole(cmd.Cmd):
self.helpdict["temperature_pla"] = _("Extruder temp for PLA (default: 185 deg C)") self.helpdict["temperature_pla"] = _("Extruder temp for PLA (default: 185 deg C)")
self.helpdict["xy_feedrate"] = _("Feedrate for Control Panel Moves in X and Y (default: 3000mm/min)") self.helpdict["xy_feedrate"] = _("Feedrate for Control Panel Moves in X and Y (default: 3000mm/min)")
self.helpdict["z_feedrate"] = _("Feedrate for Control Panel Moves in Z (default: 200mm/min)") self.helpdict["z_feedrate"] = _("Feedrate for Control Panel Moves in Z (default: 200mm/min)")
self.commandprefixes='MGT$'
def set_temp_preset(self,key,value): def set_temp_preset(self,key,value):
if not key.startswith("bed"): if not key.startswith("bed"):
...@@ -529,9 +529,12 @@ class pronsole(cmd.Cmd): ...@@ -529,9 +529,12 @@ class pronsole(cmd.Cmd):
definition += "\n" definition += "\n"
try: try:
written = False written = False
rco=open(self.rc_filename+"~new","w")
if os.path.exists(self.rc_filename): if os.path.exists(self.rc_filename):
rci=open(self.rc_filename,"r") import shutil
shutil.copy(self.rc_filename,self.rc_filename+"~bak")
rci=open(self.rc_filename+"~bak","r")
rco=open(self.rc_filename,"w")
if rci is not None:
overwriting = False overwriting = False
for rc_cmd in rci: for rc_cmd in rci:
l = rc_cmd.rstrip() l = rc_cmd.rstrip()
...@@ -550,11 +553,7 @@ class pronsole(cmd.Cmd): ...@@ -550,11 +553,7 @@ class pronsole(cmd.Cmd):
rco.write(definition) rco.write(definition)
if rci is not None: if rci is not None:
rci.close() rci.close()
if os.path.exists(self.rc_filename+"~old"):
os.remove(rci.name+"~old")
os.rename(rci.name,rci.name+"~old")
rco.close() rco.close()
os.rename(rco.name,self.rc_filename)
#if definition != "": #if definition != "":
# print "Saved '"+key+"' to '"+self.rc_filename+"'" # print "Saved '"+key+"' to '"+self.rc_filename+"'"
#else: #else:
...@@ -871,14 +870,14 @@ class pronsole(cmd.Cmd): ...@@ -871,14 +870,14 @@ class pronsole(cmd.Cmd):
print "! os.listdir('.')" print "! os.listdir('.')"
def default(self,l): def default(self,l):
if(l[0]=='M' or l[0]=="G" or l[0]=='T'): if(l[0] in self.commandprefixes.upper()):
if(self.p and self.p.online): if(self.p and self.p.online):
print "SENDING:"+l print "SENDING:"+l
self.p.send_now(l) self.p.send_now(l)
else: else:
print "Printer is not online." print "Printer is not online."
return return
if(l[0]=='m' or l[0]=="g" or l[0]=='t'): elif(l[0] in self.commandprefixes.lower()):
if(self.p and self.p.online): if(self.p and self.p.online):
print "SENDING:"+l.upper() print "SENDING:"+l.upper()
self.p.send_now(l.upper()) self.p.send_now(l.upper())
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment