Sat, 04 Jun 2016 13:06:30 +0200
Remove empty lines output on bitmap plotter
15 | 1 | Printrun consists of printcore, pronsole and pronterface, and a small collection of helpful scripts. |
2 | ||
3 | * printcore.py is a library that makes writing reprap hosts easy | |
4 | * pronsole.py is an interactive command-line host software with tabcompletion goodness | |
5 | * pronterface.py is a graphical host software with the same functionality as pronsole | |
6 | ||
7 | # GETTING PRINTRUN | |
8 | ||
9 | This section suggests using precompiled binaries, this way you get everything bundled into one single package for an easy installation. | |
10 | ||
11 | If you want the newest, shiniest features, you can run Printrun from source using the instructions further down this README. | |
12 | ||
13 | ## Windows | |
14 | ||
15 | A precompiled version is available at http://koti.kapsi.fi/~kliment/printrun/ | |
16 | ||
17 | ## Mac OS X | |
18 | ||
19 | A precompiled version is available at http://koti.kapsi.fi/~kliment/printrun/ | |
20 | ||
21 | ## Linux | |
22 | ### Ubuntu/Debian | |
23 | ||
24 | You can run Printrun directly from source. Fetch and install the dependencies using | |
25 | ||
26 | 1. `sudo apt-get install python-serial python-wxgtk2.8 python-pyglet python-numpy cython python-libxml2 python-gobject python-dbus python-psutil python-cairosvg git` | |
27 | ||
28 | Clone the repository | |
29 | ||
30 | `git clone https://github.com/kliment/Printrun.git` | |
31 | ||
32 | and you can start using Printrun from the Printrun directory created by the git clone command. | |
33 | ||
34 | Users of Ubuntu Xenial Xerus or later and Debian Jessie or later won't find the package "python-wxgtk2.8" available, having been replaced by "python-wxgtk3.0". Running Printrun with "python-wxgtk3.0" instead, is possible but it is known to be affected by issue #615. | |
35 | ||
36 | A Printrun preliminary package is already available in Ubuntu Yakkety Yak and Debian Stretch/Sid repositories. Please be aware that this initial package is also known to be affected by issue #615. | |
37 | ||
38 | ### Chrome OS | |
39 | ||
40 | You can use Printrun via crouton ( https://github.com/dnschneid/crouton ). Assuming you want Ubuntu Trusty, you used probably `sudo sh -e ~/Downloads/crouton -r trusty -t xfce` to install Ubuntu. Fetch and install dependencies with the line given above for Ubuntu/Debian, and obtain the source via git clone. | |
41 | ||
42 | By default you have no access to the serial port under Chrome OS crouton, so you cannot connect to your 3D printer. Add yourself to the serial group within the linux environment to fix this | |
43 | ||
44 | `sudo usermod -G serial -a <username>` | |
45 | ||
46 | where `<username>` should be your username. Log out and in to make this group change active and allow communication with your printer. | |
47 | ||
48 | ### Fedora | |
49 | ||
50 | You can install Printrun from official packages. Install the whole package using | |
51 | ||
52 | `sudo yum install printrun` | |
53 | ||
54 | Or get only apps you need by | |
55 | ||
56 | `sudo yum install pronsole` or `pronterface` or `plater` | |
57 | ||
58 | Adding `--enablerepo updates-testing` option to `yum` might give you newer packages (but also not very tested). | |
59 | ||
60 | You can also run Printrun directly from source, if the packages are too old for you. Fetch and install the dependencies using | |
61 | ||
62 | 1. `sudo yum install pyserial wxPython python-pyglet python-cairosvg` | |
63 | ||
64 | Optional: `sudo yum install skeinforge simarrange` | |
65 | ||
66 | ### Archlinux | |
67 | ||
68 | Packages are available in AUR. Just run | |
69 | ||
70 | `yaourt printrun` | |
71 | ||
72 | and enjoy the `pronterface`, `pronsole`, ... commands directly. | |
73 | ||
74 | ## RUNNING FROM SOURCE | |
75 | ||
76 | Run Printrun for source if you want to test out the latest features. | |
77 | ||
78 | ### Dependencies | |
79 | ||
80 | To use pronterface, you need: | |
81 | ||
82 | * python (ideally 2.6.x or 2.7.x), | |
83 | * pyserial (or python-serial on ubuntu/debian) | |
84 | * pyreadline (not needed on Linux) and | |
85 | * argparse (installed by default with python >= 2.7) | |
86 | * wxPython (some features such as Tabbed mode work better with wx 2.9) | |
87 | * pyglet | |
88 | * numpy (for 3D view) | |
89 | * pycairo (to use Projector feature) | |
90 | * cairosvg (to use Projector feature) | |
91 | * dbus (to inhibit sleep on some Linux systems) | |
92 | ||
93 | Please see specific instructions for Windows and Mac OS X below. Under Linux, you should use your package manager directly (see the "GETTING PRINTRUN" section), or pip: | |
94 | ||
95 | ```pip install -r requirements.txt``` | |
96 | ||
97 | ### Cython-based G-Code parser | |
98 | ||
99 | Printrun default G-Code parser is quite memory hungry, but we also provide a much lighter one which just needs an extra build-time dependency (Cython), plus compiling the extension with: | |
100 | ||
101 | python setup.py build_ext --inplace | |
102 | ||
103 | The warning message | |
104 | ||
105 | WARNING:root:Memory-efficient GCoder implementation unavailable: No module named gcoder_line | |
106 | ||
107 | means that this optimized G-Code parser hasn't been compiled. To get rid of it and benefit from the better implementation, please install Cython and run the command above. | |
108 | ||
109 | ### Windows | |
110 | ||
111 | Download the following, and install in this order: | |
112 | ||
113 | 1. http://python.org/ftp/python/2.7.2/python-2.7.2.msi | |
114 | 2. http://pypi.python.org/packages/any/p/pyserial/pyserial-2.5.win32.exe | |
115 | 3. http://downloads.sourceforge.net/wxpython/wxPython2.8-win32-unicode-2.8.12.0-py27.exe | |
116 | 4. https://pypi.python.org/packages/any/p/pyreadline/pyreadline-1.7.1.win32.exe | |
117 | 5. http://pyglet.googlecode.com/files/pyglet-1.1.4.zip | |
118 | ||
119 | For the last one, you will need to unpack it, open a command terminal, | |
120 | go into the the directory you unpacked it in and run | |
121 | `python setup.py install` | |
122 | ||
123 | ### Mac OS X Lion | |
124 | ||
125 | 1. Ensure that the active Python is the system version. (`brew uninstall python` or other appropriate incantations) | |
126 | 2. Download an install [wxPython2.8-osx-unicode] matching to your python version (most likely 2.7 on Lion, | |
127 | check with: python --version) from: http://wxpython.org/download.php#stable | |
128 | Known to work PythonWX: http://superb-sea2.dl.sourceforge.net/project/wxpython/wxPython/2.8.12.1/wxPython2.8-osx-unicode-2.8.12.1-universal-py2.7.dmg | |
129 | 3. Download and unpack pyserial from http://pypi.python.org/packages/source/p/pyserial/pyserial-2.5.tar.gz | |
130 | 4. In a terminal, change to the folder you unzipped to, then type in: `sudo python setup.py install` | |
131 | 5. Repeat 4. with http://http://pyglet.googlecode.com/files/pyglet-1.1.4.zip | |
132 | ||
133 | The tools will probably run just fine in 64bit on Lion, you don't need to mess | |
134 | with any of the 32bit settings. In case they don't, try | |
135 | 5. export VERSIONER_PYTHON_PREFER_32_BIT=yes | |
136 | in a terminal before running Pronterface | |
137 | ||
138 | ### Mac OS X (pre Lion) | |
139 | ||
140 | A precompiled version is available at http://koti.kapsi.fi/~kliment/printrun/ | |
141 | ||
142 | 1. Download and install http://downloads.sourceforge.net/wxpython/wxPython2.8-osx-unicode-2.8.12.0-universal-py2.6.dmg | |
143 | 2. Grab the source for pyserial from http://pypi.python.org/packages/source/p/pyserial/pyserial-2.5.tar.gz | |
144 | 3. Unzip pyserial to a folder. Then, in a terminal, change to the folder you unzipped to, then type in: | |
145 | ||
146 | `defaults write com.apple.versioner.python Prefer-32-Bit -bool yes` | |
147 | ||
148 | `sudo python setup.py install` | |
149 | ||
150 | Alternatively, you can run python in 32 bit mode by setting the following environment variable before running the setup.py command: | |
151 | ||
152 | This alternative approach is confirmed to work on Mac OS X 10.6.8. | |
153 | ||
154 | `export VERSIONER_PYTHON_PREFER_32_BIT=yes` | |
155 | ||
156 | `sudo python setup.py install` | |
157 | ||
158 | Then repeat the same with http://http://pyglet.googlecode.com/files/pyglet-1.1.4.zip | |
159 | ||
160 | # USING PRINTRUN | |
161 | ||
162 | ## USING PRONTERFACE | |
163 | ||
164 | When you're done setting up Printrun, you can start pronterface.py in the directory you unpacked it. | |
165 | Select the port name you are using from the first drop-down, select your baud rate, and hit connect. | |
166 | Load an STL (see the note on skeinforge below) or GCODE file, and you can upload it to SD or print it directly. | |
167 | The "monitor printer" function, when enabled, checks the printer state (temperatures, SD print progress) every 3 seconds. | |
168 | The command box recognizes all pronsole commands, but has no tabcompletion. | |
169 | ||
170 | If you want to load stl files, you need to install a slicing program such as Slic3r and add its path to the settings. | |
171 | See the Slic3r readme for more details on integration. | |
172 | ||
173 | ||
174 | ## USING PRONSOLE | |
175 | ||
176 | To use pronsole, you need: | |
177 | ||
178 | * python (ideally 2.6.x or 2.7.x), | |
179 | * pyserial (or python-serial on ubuntu/debian) and | |
180 | * pyreadline (not needed on Linux) | |
181 | ||
182 | Start pronsole and you will be greeted with a command prompt. Type help to view the available commands. | |
183 | All commands have internal help, which you can access by typing "help commandname", for example "help connect" | |
184 | ||
185 | If you want to load stl files, you need to put a version of skeinforge (doesn't matter which one) in a folder called "skeinforge". | |
186 | The "skeinforge" folder must be in the same folder as pronsole.py | |
187 | ||
188 | ## USING PRINTCORE | |
189 | ||
190 | To use printcore you need python (ideally 2.6.x or 2.7.x) and pyserial (or python-serial on ubuntu/debian) | |
191 | See pronsole for an example of a full-featured host, the bottom of printcore.py for a simple command-line | |
192 | sender, or the following code example: | |
193 | ||
194 | ```python | |
195 | #to send a file of gcode to the printer | |
196 | from printrun.printcore import printcore | |
197 | from printrun import gcoder | |
198 | p=printcore('/dev/ttyUSB0',115200) # or p.printcore('COM3',115200) on Windows | |
199 | gcode=[i.strip() for i in open('filename.gcode')] # or pass in your own array of gcode lines instead of reading from a file | |
200 | gcode = gcoder.LightGCode(gcode) | |
201 | p.startprint(gcode) # this will start a print | |
202 | ||
203 | #If you need to interact with the printer: | |
204 | p.send_now("M105") # this will send M105 immediately, ahead of the rest of the print | |
205 | p.pause() # use these to pause/resume the current print | |
206 | p.resume() | |
207 | p.disconnect() # this is how you disconnect from the printer once you are done. This will also stop running prints. | |
208 | ``` | |
209 | ||
210 | ## PLATERS | |
211 | ||
212 | Printrun provides two platers: a STL plater (```plater.py```) and a G-Code plater (```gcodeplater.py```). | |
213 | ||
214 | ## 3D VIEWER CONTROLS | |
215 | ||
216 | When the 3D viewer is enabled, the controls are the following: | |
217 | - Mousewheel: zoom (Control reduces the zoom change steps) | |
218 | - Shift+mousewheel: explore layers (in print gcode view ; Control key makes layer change by increments of 10 instead of 1) or rotate object (in platers) | |
219 | - Left-click dragging: rotate view | |
220 | - Right-click dragging: pan view | |
221 | - Shift + left-click dragging: move object (in platers) | |
222 | - Page up/down keys: zoom (Control reduces the zoom change steps) | |
223 | - Up/down keys: explore layers | |
224 | - R key: reset view | |
225 | - F key: fit view to display entire print | |
226 | - C key: toggle "display current layer only" mode (in print gcode view) | |
227 | ||
228 | ## RPC SERVER | |
229 | ||
230 | ```pronterface``` and ```pronsole``` start a RPC server, which runs by default | |
231 | on localhost port 7978, which provides print progress information. | |
232 | Here is a sample Python script querying the print status: | |
233 | ||
234 | ```python | |
235 | import xmlrpclib | |
236 | ||
237 | rpc = xmlrpclib.ServerProxy('http://localhost:7978') | |
238 | print rpc.status() | |
239 | ``` | |
240 | ||
241 | ## CONFIGURATION | |
242 | ||
243 | ### Build dimensions | |
244 | ||
245 | Build dimensions can be specified using the build_dimensions option (which can | |
246 | be graphically edited in Pronterface settings). This option is formed of 9 parameters: | |
247 | 3 for the build volume dimensions, 3 for the build volume coordinate system | |
248 | offset minimum, 3 for the endstop positions. | |
249 | ||
250 | The default value is `200x200x100+0+0+0+0+0+0`, which corresponds to a | |
251 | 200x200mm (width x height) bed with 100mm travel in Z (there are the first | |
252 | three numbers) and no offset. The absolute coordinates system origin (0,0,0) is | |
253 | at the bottom left corner on the bed surface, and the top right corner on the | |
254 | bed surface is (200,200,0). | |
255 | ||
256 | A common practice is to have the origin of the coordinate system (0,0,0) at the | |
257 | center of the bed surface. This is achieved by using the next three parameters, | |
258 | for instance with `200x200x100-100-100+0+0+0+0`. | |
259 | In this case, the bottom left corner of the bed will be at (-100,-100,0) and | |
260 | the top right one at (100,100,0). | |
261 | ||
262 | These two sets of settings should be sufficient for most people. However, for | |
263 | some specific complicated setups and GCodes and some features, we might also | |
264 | need the endstops positions for perfect display. These positions (which are | |
265 | usually 0,0,0, so if you don't know you probably have a standard setup) are | |
266 | specified in absolute coordinates, so if you have your bed starting at | |
267 | (-100,-100,0) and your endstops are 10mm away from the bed left and right and | |
268 | the Z endstop 5mm above the bed, you'll want to set the endstops positions to | |
269 | (-110,-110,5) for this option. | |
270 | ||
271 | ## USING MACROS AND CUSTOM BUTTONS | |
272 | ||
273 | ### Macros in pronsole and pronterface | |
274 | ||
275 | To send simple G-code (or pronsole command) sequence is as simple as entering them one by one in macro definition. | |
276 | If you want to use parameters for your macros, substitute them with {0} {1} {2} ... etc. | |
277 | ||
278 | All macros are saved automatically immediately after being entered. | |
279 | ||
280 | Example 1, simple one-line alias: | |
281 | ||
282 | ```python | |
283 | PC> macro where M114 | |
284 | ``` | |
285 | ||
286 | Instead of having to remember the code to query position, you can query the position: | |
287 | ||
288 | ```python | |
289 | PC> where | |
290 | X:25.00Y:11.43Z:5.11E:0.00 | |
291 | ``` | |
292 | ||
293 | Example 2 - macros to switch between different slicer programs, using "set" command to change options: | |
294 | ||
295 | ```python | |
296 | PC> macro use_slicer | |
297 | Enter macro using indented lines, end with empty line | |
298 | ..> set sliceoptscommand Slic3r/slic3r.exe --load slic3r.ini | |
299 | ..> set slicecommand Slic3r/slic3r.exe $s --load slic3r.ini --output $o | |
300 | Macro 'use_slicer' defined | |
301 | PC> macro use_sfact | |
302 | ..> set sliceoptscommand python skeinforge/skeinforge_application/skeinforge.py | |
303 | ..> set slicecommand python skeinforge/skeinforge_application/skeinforge_utilities/skeinforge_craft.py $s | |
304 | Macro 'use_sfact' defined | |
305 | ``` | |
306 | ||
307 | Example 3, simple parametric macro: | |
308 | ||
309 | ```python | |
310 | PC> macro move_down_by | |
311 | Enter macro using indented lines, end with empty line | |
312 | ..> G91 | |
313 | ..> G1 Z-{0} | |
314 | ..> G92 | |
315 | ..> | |
316 | ``` | |
317 | ||
318 | Invoke the macro to move the printhead down by 5 millimeters: | |
319 | ||
320 | ```python | |
321 | PC> move_down_by 5 | |
322 | ``` | |
323 | ||
324 | For more powerful macro programming, it is possible to use python code escaping using ! symbol in front of macro commands. | |
325 | Note that this python code invocation also works in interactive prompt: | |
326 | ||
327 | ```python | |
328 | PC> !print "Hello, printer!" | |
329 | Hello printer! | |
330 | ||
331 | PC> macro debug_on !self.p.loud = 1 | |
332 | Macro 'debug_on' defined | |
333 | PC> debug_on | |
334 | PC> M114 | |
335 | SENT: M114 | |
336 | X:0.00Y:0.00Z:0.00E:0.00 Count X:0.00Y:0.00Z:0.00 | |
337 | RECV: X:0.00Y:0.00Z:0.00E:0.00 Count X:0.00Y:0.00Z:0.00 | |
338 | RECV: ok | |
339 | ``` | |
340 | ||
341 | You can use macro command itself to create simple self-modify or toggle functionality: | |
342 | ||
343 | Example: swapping two macros to implement toggle: | |
344 | ||
345 | ```python | |
346 | PC> macro toggle_debug_on | |
347 | Enter macro using indented lines, end with empty line | |
348 | ..> !self.p.loud = 1 | |
349 | ..> !print "Diagnostic information ON" | |
350 | ..> macro toggle_debug toggle_debug_off | |
351 | ..> | |
352 | Macro 'toggle_debug_on' defined | |
353 | PC> macro toggle_debug_off | |
354 | Enter macro using indented lines, end with empty line | |
355 | ..> !self.p.loud = 0 | |
356 | ..> !print "Diagnostic information OFF" | |
357 | ..> macro toggle_debug toggle_debug_on | |
358 | ..> | |
359 | Macro 'toggle_debug_off' defined | |
360 | PC> macro toggle_debug toggle_debug_on | |
361 | Macro 'toggle_debug' defined | |
362 | ``` | |
363 | ||
364 | Now, each time we invoke "toggle_debug" macro, it toggles debug information on and off: | |
365 | ||
366 | ```python | |
367 | PC> toggle_debug | |
368 | Diagnostic information ON | |
369 | ||
370 | PC> toggle_debug | |
371 | Diagnostic information OFF | |
372 | ``` | |
373 | ||
374 | When python code (using ! symbol) is used in macros, it is even possible to use blocks/conditionals/loops. | |
375 | It is okay to mix python code with pronsole commands, just keep the python indentation. | |
376 | For example, following macro toggles the diagnostic information similarily to the previous example: | |
377 | ||
378 | ```python | |
379 | !if self.p.loud: | |
380 | !self.p.loud = 0 | |
381 | !print "Diagnostic information OFF" | |
382 | !else: | |
383 | !self.p.loud = 1 | |
384 | !print "Diagnostic information ON" | |
385 | ``` | |
386 | ||
387 | Macro parameters are available in '!'-escaped python code as locally defined list variable: arg[0] arg[1] ... arg[N] | |
388 | ||
389 | All python code is executed in the context of the pronsole (or PronterWindow) object, | |
390 | so it is possible to use all internal variables and methods, which provide great deal of functionality. | |
391 | However the internal variables and methods are not very well documented and may be subject of change, as the program is developed. | |
392 | Therefore it is best to use pronsole commands, which easily contain majority of the functionality that might be needed. | |
393 | ||
394 | Some useful python-mode-only variables: | |
395 | ||
396 | ```python | |
397 | !self.settings - contains all settings, e.g. | |
398 | port (!self.settings.port), baudrate, xy_feedrate, e_feedrate, slicecommand, final_command, build_dimensions | |
399 | You can set them also via pronsole command "set", but you can query the values only via python code. | |
400 | !self.p - printcore object (see USING PRINTCORE section for using printcore object) | |
401 | !self.cur_button - if macro was invoked via custom button, the number of the custom button, e.g. for usage in "button" command | |
402 | !self.gwindow - wx graphical interface object for pronterface (highly risky to use because the GUI implementation details may change a lot between versions) | |
403 | ``` | |
404 | ||
405 | Some useful methods: | |
406 | ||
407 | ```python | |
408 | !self.onecmd - invokes raw command, e.g. | |
409 | !self.onecmd("move x 10") | |
410 | !self.onecmd("!print self.p.loud") | |
411 | !self.onecmd("button "+self.cur_button+" fanOFF /C cyan M107") | |
412 | !self.project - invoke Projector | |
413 | ``` | |
414 | ||
415 | ## USING HOST COMMANDS | |
416 | ||
417 | Pronsole and the console interface in Pronterface accept a number of commands | |
418 | which you can either use directly or inside your G-Code. To run a host command | |
419 | from inside a G-Code, simply prefix it with `;@`. | |
420 | ||
421 | List of available commands: | |
422 | ||
423 | - `pause`: pauses the print until the user resumes it | |
424 | - `run_script scriptname [arg1 ...]`: runs a custom script or program on the | |
425 | host computer. This can for instance be used to produce a sound to warn the | |
426 | user (e.g. `run_script beep -r 2` on machines were the `beep` util is | |
427 | available), or to send an email or text message at the end of a print. The $s | |
428 | token can be used in the arguments to get the current gcode file name | |
429 | - `run_gcode_script scripname [arg1 ...]`: same as `run_script`, except that | |
430 | all lines displayed by the script will be interpreted in turn (so that G-Code | |
431 | lines will be immediately sent to the printer) | |
432 | - `shell pythoncommand`: run a python command (can also be achieved by doing | |
433 | `!pythoncommand`) | |
434 | - `set option value`: sets the value of an option, e.g. `set mainviz 3D` | |
435 | - `connect` | |
436 | - `block_until_online`: wait for the printer to be online. For instance you can | |
437 | do `python pronsole.py -e "connect" -e "block_until_online" -e "upload | |
438 | object.gcode"` to start pronsole, connect for the printer, wait for it to be | |
439 | online to start uploading the `object.gcode` file. | |
440 | - `disconnect` | |
441 | - `load gcodefile` | |
442 | - `upload gcodefile target.g`: upload `gcodefile` to `target.g` on the SD card | |
443 | - `slice stlfile`: slice `stlfile` and load the produced G-Code | |
444 | - `print`: print the currently loaded file | |
445 | - `sdprint target.g`: start a SD print | |
446 | - `ls`: list files on SD card | |
447 | - `eta`: display remaining print time | |
448 | - `gettemp`: get current printer temperatures | |
449 | - `settemp`: set hotend target temperature | |
450 | - `bedtemp`: set bed target temperature | |
451 | - `monitor`: monitor printer progress during a print | |
452 | - `tool K`: switch to tool K | |
453 | - `move xK`: move along `x` axis (works with other axes too) | |
454 | - `extrude length [speed]` | |
455 | - `reverse length [speed]` | |
456 | - `home [axis]` | |
457 | - `off`: turns off fans, motors, extruder, heatbed, power supply | |
458 | - `exit` | |
459 | ||
460 | # LICENSE | |
461 | ||
462 | ``` | |
463 | Printrun is free software: you can redistribute it and/or modify | |
464 | it under the terms of the GNU General Public License as published by | |
465 | the Free Software Foundation, either version 3 of the License, or | |
466 | (at your option) any later version. | |
467 | ||
468 | Printrun is distributed in the hope that it will be useful, | |
469 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
470 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
471 | GNU General Public License for more details. | |
472 | ||
473 | You should have received a copy of the GNU General Public License | |
474 | along with Printrun. If not, see <http://www.gnu.org/licenses/>. | |
475 | ``` | |
476 | ||
477 | All scripts should contain this license note, if not, feel free to ask us. Please note that files where it is difficult to state this license note (such as images) are distributed under the same terms. |