Marlin.ino

Sat, 07 Nov 2015 13:24:46 +0100

author
mbayer
date
Sat, 07 Nov 2015 13:24:46 +0100
changeset 1
b584642d4f58
parent 0
2c8ba1964db7
child 3
770b218a4931
permissions
-rw-r--r--

several modifications to support laser enable - still needs cleanup

0
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1 /*
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
2 Reprap firmware based on Sprinter and grbl.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
3 Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
4
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
5 This program is free software: you can redistribute it and/or modify
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
6 it under the terms of the GNU General Public License as published by
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
7 the Free Software Foundation, either version 3 of the License, or
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
8 (at your option) any later version.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
9
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
13 GNU General Public License for more details.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
14
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
15 You should have received a copy of the GNU General Public License
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
17 */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
18
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
19 /*
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
20 This firmware is a mashup between Sprinter and grbl.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
21 (https://github.com/kliment/Sprinter)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
22 (https://github.com/simen/grbl/tree)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
23
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
24 It has preliminary support for Matthew Roberts advance algorithm
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
25 http://reprap.org/pipermail/reprap-dev/2011-May/003323.html
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
26 */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
27
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
28 /*
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
29 RepRapPro ammendations, deletions and additions
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
30
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
31 G10, M0, M1, M112 and T commands added/modified by AB 18/7/12
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
32 Much conditional-compiled code for old/unused hardware removed - AB 29/7/12
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
33
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
34 */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
35
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
36 /*
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
37 NeoSoft modifications:
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
38
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
39 Implement:
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
40 - M571 to enable PWM on extruder Movement (laser modulation support), second E parameter to disable real E drive
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
41 - MXXX to enable Emergency Stop button (if disabled the button can be used to programmatically pause the lasercut for user interaction. For example:
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
42 move to bottom left of print rectangle, ask user to align workpiece (wait for button press), then move to bottom right and ask user to align the other workpiece end, wait for button press to start engraving...
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
43
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
44 EXT PINS:
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
45 30, 29,28 = EXT1-3, 27=EXT4=LED
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
46
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
47 M571 pin default to EXT3 (PIN 28) in pins.h
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
48
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
49 Emergency Stop (PAUSE) button on EXT2 (PIN 29):
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
50 If not stopped: call stop()
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
51 If stopped: execute code from M999 Command (do not inject M999, execute the code!)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
52 // bool x_min_endstop=(READ(X_MIN_PIN) != X_ENDSTOPS_INVERTING);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
53 //pinMode(inPin, INPUT);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
54
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
55 alternative approach (better?):
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
56 make copy of "void enquecommand(const char *cmd)" with following behaviour:
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
57 - pause serial receiver enqueueing (the irq should respond like "buffer full")
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
58 - call alternative of stop() which memorizes the last PROCESSED line?
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
59 */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
60
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
61 #include "Marlin.h"
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
62
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
63 #include "ultralcd.h"
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
64 #include "led.h"
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
65 #include "z_probe.h"
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
66 #include "FPUTransform.h"
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
67 #include "planner.h"
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
68 #include "stepper.h"
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
69 #include "temperature.h"
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
70 #include "motion_control.h"
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
71 #include "cardreader.h"
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
72 #include "EEPROMwrite.h"
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
73 #include "language.h"
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
74 #include "pins_arduino.h"
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
75 #include "slave_comms.h"
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
76
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
77 #define VERSION_STRING "1.0.2 RRP/NeoSoft"
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
78
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
79 // look here for descriptions of gcodes: http://linuxcnc.org/handbook/gcode/g-code.html
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
80 // http://objects.reprap.org/wiki/Mendel_User_Manual:_RepRapGCodes
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
81
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
82 //Implemented Codes
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
83 //-------------------
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
84 // G0 -> G1
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
85 // G1 - Coordinated Movement X Y Z E
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
86 // G2 - CW ARC
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
87 // G3 - CCW ARC
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
88 // G4 - Dwell S<seconds> or P<milliseconds>
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
89 // G10 - set head offset and temps
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
90 // G28 - Home all Axis
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
91 // G29 - Detailed Z-Probe (3 location test)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
92 // G30 - Single Z Probe (probe current location)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
93 // G31 - Report Curent Probe status
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
94 // G32 - Probe Z and calibrate with FPU
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
95 // G90 - Use Absolute Coordinates
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
96 // G91 - Use Relative Coordinates
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
97 // G92 - Set current position to cordinates given
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
98
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
99 //RepRap M Codes
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
100 // M104 - Set extruder target temp (deprecated)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
101 // M105 - Read current temp
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
102 // M106 - Fan on
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
103 // M107 - Fan off
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
104 // M109 - Wait for extruder current temp to reach target temp. (deprecated)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
105 // M114 - Display current position
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
106
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
107 //Custom M Codes
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
108 // M17 - Enable/Power all stepper motors
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
109 // M18 - Disable all stepper motors; same as M84
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
110 // M20 - List SD card
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
111 // M21 - Init SD card
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
112 // M22 - Release SD card
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
113 // M23 - Select SD file (M23 filename.g)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
114 // M24 - Start/resume SD print
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
115 // M25 - Pause SD print
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
116 // M26 - Set SD position in bytes (M26 S12345)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
117 // M27 - Report SD print status
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
118 // M28 - Start SD write (M28 filename.g)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
119 // M29 - Stop SD write
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
120 // M30 - Fast SD transfer
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
121 // M31 - high speed xfer capabilities
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
122 // M35 - Output time since last M109 or SD card start to serial
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
123
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
124 // M42 - Change pin status via gcode
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
125 // M82 - Set E codes absolute (default)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
126 // M83 - Set E codes relative while in Absolute Coordinates (G90) mode
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
127 // M84 - Disable steppers until next move,
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
128 // or use S<seconds> to specify an inactivity timeout, after which the steppers will be disabled. S0 to disable the timeout.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
129 // M85 - Set inactivity shutdown timer with parameter S<seconds>. To disable set zero (default)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
130 // M92 - Set axis_steps_per_unit - same syntax as G92
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
131 // M114 - Output current position to serial port
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
132 // M115 - Capabilities string
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
133 // M117 - display message
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
134 // M119 - Output Endstop status to serial port
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
135 // M140 - Set bed target temp
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
136 // M190 - Wait for bed current temp to reach target temp.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
137 // M200 - Set filament diameter
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
138 // M201 - Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
139 // M202 - Set max acceleration in units/s^2 for travel moves (M202 X1000 Y1000) Unused in Marlin!!
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
140 // M203 - Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in mm/sec
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
141 // M204 - Set default acceleration: S normal moves T filament only moves (M204 S3000 T7000) im mm/sec^2 also sets minimum segment time in ms (B20000) to prevent buffer underruns and M20 minimum feedrate
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
142 // M205 - advanced settings: minimum travel speed S=while printing T=travel only, B=minimum segment time X= maximum xy jerk, Z=maximum Z jerk, E=maximum E jerk
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
143 // M206 - set additional homeing offset
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
144 // M208 - set axis max length
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
145 // M220 S<factor in percent>- set speed factor override percentage
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
146 // M221 S<factor in percent>- set extrude factor override percentage
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
147 // M240 - Trigger a camera to take a photograph
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
148 // M301 - Set PID parameters P I D and W
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
149 // M302 - S1 Allow cold extrudes, S0 cold extrues not allowed (default)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
150 // M303 - PID relay autotune S<temperature> sets the target temperature. (default target temperature = 150C)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
151 // M304 - Set thermistor parameters
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
152 // M400 - Finish all moves
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
153 // M500 - stores paramters in EEPROM
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
154 // M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
155 // M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
156 // M503 - print the current settings (from memory not from eeprom)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
157 // M510 - FPU Enable
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
158 // M511 - FPU Reset
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
159 // M512 - FPU Disable
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
160 // M999 - Restart after being stopped by error
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
161
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
162 // M555 - Temporary: master/slave comms test
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
163
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
164 // TN - Select extruder N
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
165
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
166 //Stepper Movement Variables
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
167
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
168 //===========================================================================
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
169 //=============================imported variables============================
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
170 //===========================================================================
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
171
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
172
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
173 //===========================================================================
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
174 //=============================public variables=============================
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
175 //===========================================================================
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
176 #ifdef SDSUPPORT
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
177 CardReader card;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
178 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
179 float homing_feedrate[] = HOMING_FEEDRATE;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
180 float fast_home_feedrate[] = FAST_HOME_FEEDRATE;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
181 bool axis_relative_modes[] = AXIS_RELATIVE_MODES;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
182 volatile int feedmultiply=100; //100->1 200->2
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
183 int saved_feedmultiply;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
184 volatile bool feedmultiplychanged=false;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
185 volatile int extrudemultiply=100; //100->1 200->2
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
186 float current_position[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0 };
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
187 float add_homeing[3]={0,0,0};
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
188 float max_length[] = AXES_MAX_LENGTHS;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
189 #ifdef ADVANCE
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
190 float advance_k = EXTRUDER_ADVANCE_K;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
191 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
192 uint8_t active_extruder = 0;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
193 float extruder_x_off[EXTRUDERS];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
194 float extruder_y_off[EXTRUDERS];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
195 float extruder_z_off[EXTRUDERS];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
196 float extruder_standby[EXTRUDERS];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
197 float extruder_temperature[EXTRUDERS];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
198 float x_off_d;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
199 float y_off_d;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
200 float z_off_d;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
201 float temp_position[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0 };
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
202 bool extruder_selected=false;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
203
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
204
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
205 unsigned char FanSpeed=0;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
206 bool m571_enabled = 0;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
207 bool n571_enabled = 0;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
208
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
209 float destination[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0};
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
210 float offset[3] = {0.0, 0.0, 0.0};
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
211 float feedrate = 1500.0, next_feedrate, saved_feedrate;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
212
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
213 // used by FPU transform code
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
214 float modified_destination[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0};
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
215
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
216 //===========================================================================
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
217 //=============================private variables=============================
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
218 //===========================================================================
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
219 const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'};
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
220 static bool home_all_axis = true;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
221 static long gcode_N, gcode_LastN, Stopped_gcode_LastN = 0;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
222
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
223 static bool relative_mode = false; //Determines Absolute or Relative Coordinates
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
224 static bool relative_mode_e = false; //Determines Absolute or Relative E Codes while in Absolute Coordinates mode. E is always relative in Relative Coordinates mode.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
225
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
226 static char cmdbuffer[BUFSIZE][MAX_CMD_SIZE];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
227 static bool fromsd[BUFSIZE];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
228 static int bufindr = 0;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
229 static int bufindw = 0;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
230 static int buflen = 0;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
231 //static int i = 0;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
232 static char serial_char;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
233 static int serial_count = 0;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
234 static boolean comment_mode = false;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
235 static char *strchr_pointer; // just a pointer to find chars in the cmd string like X, Y, Z, E, etc
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
236
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
237 const int sensitive_pins[] = SENSITIVE_PINS; // Sensitive pin list for M42
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
238
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
239 //static float tt = 0;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
240 //static float bt = 0;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
241
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
242 //Inactivity shutdown variables
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
243 static unsigned long previous_millis_cmd = 0;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
244 static unsigned long max_inactive_time = 0;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
245 static unsigned long stepper_inactive_time = DEFAULT_STEPPER_DEACTIVE_TIME*1000l;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
246
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
247 static unsigned long starttime=0;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
248 static unsigned long stoptime=0;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
249
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
250 static uint8_t tmp_extruder;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
251
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
252
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
253 bool Stopped=false;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
254
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
255 //===========================================================================
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
256 //=============================ROUTINES=============================
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
257 //===========================================================================
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
258
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
259 void get_arc_coordinates();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
260
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
261 extern "C"{
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
262 extern unsigned int __bss_end;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
263 extern unsigned int __heap_start;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
264 extern void *__brkval;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
265
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
266 int freeMemory() {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
267 int free_memory;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
268
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
269 if((int)__brkval == 0)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
270 free_memory = ((int)&free_memory) - ((int)&__bss_end);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
271 else
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
272 free_memory = ((int)&free_memory) - ((int)__brkval);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
273
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
274 return free_memory;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
275 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
276 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
277
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
278 //adds an command to the main command buffer
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
279 //thats really done in a non-safe way.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
280 //needs overworking someday
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
281 void enquecommand(const char *cmd)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
282 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
283 if(buflen < BUFSIZE)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
284 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
285 //this is dangerous if a mixing of serial and this happsens
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
286 strcpy(&(cmdbuffer[bufindw][0]),cmd);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
287 SERIAL_ECHO_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
288 SERIAL_ECHOPGM("enqueing \"");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
289 SERIAL_ECHO(cmdbuffer[bufindw]);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
290 SERIAL_ECHOLNPGM("\"");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
291 bufindw= (bufindw + 1)%BUFSIZE;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
292 buflen += 1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
293 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
294 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
295
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
296 void setup_photpin()
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
297 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
298 #ifdef PHOTOGRAPH_PIN
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
299 #if (PHOTOGRAPH_PIN > -1)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
300 SET_OUTPUT(PHOTOGRAPH_PIN);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
301 WRITE(PHOTOGRAPH_PIN, LOW);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
302 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
303 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
304 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
305
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
306 void setup_powerhold()
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
307 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
308 #ifdef SUICIDE_PIN
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
309 #if (SUICIDE_PIN> -1)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
310 SET_OUTPUT(SUICIDE_PIN);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
311 WRITE(SUICIDE_PIN, HIGH);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
312 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
313 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
314 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
315
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
316 void suicide()
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
317 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
318 #ifdef SUICIDE_PIN
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
319 #if (SUICIDE_PIN> -1)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
320 SET_OUTPUT(SUICIDE_PIN);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
321 WRITE(SUICIDE_PIN, LOW);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
322 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
323 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
324 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
325
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
326 void setup()
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
327 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
328 setup_powerhold();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
329 MYSERIAL.begin(BAUDRATE);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
330 SERIAL_PROTOCOLLNPGM("start");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
331 SERIAL_ECHO_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
332
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
333 for(int8_t i = 0; i < EXTRUDERS; i++)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
334 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
335 extruder_x_off[i] = X_EXTRUDER_OFFSET;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
336 extruder_y_off[i] = Y_EXTRUDER_OFFSET;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
337 extruder_z_off[i] = Z_EXTRUDER_OFFSET;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
338 extruder_standby[i] = STANDBY_TEMP;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
339 extruder_temperature[i] = DEFAULT_TEMP;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
340 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
341
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
342
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
343 // Check startup - does nothing if bootloader sets MCUSR to 0
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
344 byte mcu = MCUSR;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
345 if(mcu & 1) SERIAL_ECHOLNPGM(MSG_POWERUP);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
346 if(mcu & 2) SERIAL_ECHOLNPGM(MSG_EXTERNAL_RESET);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
347 if(mcu & 4) SERIAL_ECHOLNPGM(MSG_BROWNOUT_RESET);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
348 if(mcu & 8) SERIAL_ECHOLNPGM(MSG_WATCHDOG_RESET);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
349 if(mcu & 32) SERIAL_ECHOLNPGM(MSG_SOFTWARE_RESET);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
350 MCUSR=0;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
351
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
352 SERIAL_ECHOPGM(MSG_MARLIN);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
353 SERIAL_ECHOLNPGM(VERSION_STRING);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
354 #ifdef STRING_VERSION_CONFIG_H
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
355 #ifdef STRING_CONFIG_H_AUTHOR
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
356 SERIAL_ECHO_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
357 SERIAL_ECHOPGM(MSG_CONFIGURATION_VER);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
358 SERIAL_ECHOPGM(STRING_VERSION_CONFIG_H);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
359 SERIAL_ECHOPGM(MSG_AUTHOR);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
360 SERIAL_ECHOLNPGM(STRING_CONFIG_H_AUTHOR);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
361 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
362 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
363 SERIAL_ECHO_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
364 SERIAL_ECHOPGM(MSG_FREE_MEMORY);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
365 SERIAL_ECHO(freeMemory());
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
366 SERIAL_ECHOPGM(MSG_PLANNER_BUFFER_BYTES);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
367 SERIAL_ECHOLN((int)sizeof(block_t)*BLOCK_BUFFER_SIZE);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
368 for(int8_t i = 0; i < BUFSIZE; i++)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
369 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
370 fromsd[i] = false;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
371 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
372
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
373 EEPROM_RetrieveSettings(); // loads data from EEPROM if available
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
374
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
375 for(int8_t i=0; i < NUM_AXIS; i++)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
376 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
377 axis_steps_per_sqr_second[i] = max_acceleration_units_per_sq_second[i] * axis_steps_per_unit[i];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
378 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
379
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
380
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
381 tp_init(); // Initialize temperature loop
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
382 plan_init(); // Initialize planner;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
383 st_init(); // Initialize stepper;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
384 #if (LED_PIN > -1)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
385 led_init();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
386 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
387 probe_init(); //Initializes probe if PROBE_PIN is defined
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
388 FPUTransform_init(); //Initializes FPU when UMFPUSUPPORT defined
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
389 setup_photpin();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
390
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
391 #ifdef REPRAPPRO_MULTIMATERIALS
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
392 setup_slave();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
393 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
394
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
395 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
396
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
397
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
398 void loop()
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
399 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
400 if(buflen < (BUFSIZE-1))
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
401 get_command();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
402 #ifdef SDSUPPORT
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
403 card.checkautostart(false);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
404 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
405 if(buflen)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
406 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
407 #ifdef SDSUPPORT
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
408 if(card.saving)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
409 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
410 if(strstr(cmdbuffer[bufindr],"M29") == NULL)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
411 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
412 card.write_command(cmdbuffer[bufindr]);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
413 SERIAL_PROTOCOLLNPGM(MSG_OK);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
414 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
415 else
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
416 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
417 card.closefile();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
418 SERIAL_PROTOCOLLNPGM(MSG_FILE_SAVED);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
419 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
420 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
421 else
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
422 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
423 process_commands();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
424 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
425 #else
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
426 process_commands();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
427 #endif //SDSUPPORT
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
428 buflen = (buflen-1);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
429 bufindr = (bufindr + 1)%BUFSIZE;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
430 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
431 //check heater every n milliseconds
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
432 manage_heater();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
433 manage_inactivity(1);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
434 checkHitEndstops();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
435 LCD_STATUS;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
436 LED_STATUS;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
437 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
438
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
439 void get_command()
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
440 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
441 while( MYSERIAL.available() > 0 && buflen < BUFSIZE) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
442 serial_char = MYSERIAL.read();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
443 if(serial_char == '\n' ||
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
444 serial_char == '\r' ||
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
445 (serial_char == ':' && comment_mode == false) ||
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
446 serial_count >= (MAX_CMD_SIZE - 1) )
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
447 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
448 if(!serial_count) { //if empty line
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
449 comment_mode = false; //for new command
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
450 return;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
451 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
452 cmdbuffer[bufindw][serial_count] = 0; //terminate string
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
453 if(!comment_mode){
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
454 comment_mode = false; //for new command
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
455 fromsd[bufindw] = false;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
456 if(strstr(cmdbuffer[bufindw], "N") != NULL)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
457 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
458 strchr_pointer = strchr(cmdbuffer[bufindw], 'N');
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
459 gcode_N = (strtol(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL, 10));
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
460 if(gcode_N != gcode_LastN+1 && (strstr(cmdbuffer[bufindw], "M110") == NULL) ) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
461 SERIAL_ERROR_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
462 SERIAL_ERRORPGM(MSG_ERR_LINE_NO);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
463 SERIAL_ERRORLN(gcode_LastN);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
464 //Serial.println(gcode_N);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
465 FlushSerialRequestResend();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
466 serial_count = 0;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
467 return;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
468 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
469
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
470 if(strstr(cmdbuffer[bufindw], "*") != NULL)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
471 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
472 byte checksum = 0;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
473 byte count = 0;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
474 while(cmdbuffer[bufindw][count] != '*') checksum = checksum^cmdbuffer[bufindw][count++];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
475 strchr_pointer = strchr(cmdbuffer[bufindw], '*');
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
476
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
477 if( (int)(strtod(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL)) != checksum) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
478 SERIAL_ERROR_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
479 SERIAL_ERRORPGM(MSG_ERR_CHECKSUM_MISMATCH);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
480 SERIAL_ERRORLN(gcode_LastN);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
481 FlushSerialRequestResend();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
482 serial_count = 0;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
483 return;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
484 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
485 //if no errors, continue parsing
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
486 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
487 else
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
488 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
489 SERIAL_ERROR_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
490 SERIAL_ERRORPGM(MSG_ERR_NO_CHECKSUM);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
491 SERIAL_ERRORLN(gcode_LastN);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
492 FlushSerialRequestResend();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
493 serial_count = 0;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
494 return;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
495 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
496
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
497 gcode_LastN = gcode_N;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
498 //if no errors, continue parsing
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
499 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
500 else // if we don't receive 'N' but still see '*'
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
501 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
502 if((strstr(cmdbuffer[bufindw], "*") != NULL))
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
503 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
504 SERIAL_ERROR_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
505 SERIAL_ERRORPGM(MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
506 SERIAL_ERRORLN(gcode_LastN);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
507 serial_count = 0;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
508 return;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
509 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
510 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
511 if((strstr(cmdbuffer[bufindw], "G") != NULL)){
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
512 strchr_pointer = strchr(cmdbuffer[bufindw], 'G');
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
513 switch((int)((strtod(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL)))){
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
514 case 0:
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
515 case 1:
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
516 case 2:
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
517 case 3:
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
518 if(Stopped == false) { // If printer is stopped by an error the G[0-3] codes are ignored.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
519 #ifdef SDSUPPORT
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
520 if(card.saving)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
521 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
522 #endif //SDSUPPORT
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
523 SERIAL_PROTOCOLLNPGM(MSG_OK);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
524 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
525 else {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
526 SERIAL_ERRORLNPGM(MSG_ERR_STOPPED);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
527 LCD_MESSAGEPGM(MSG_STOPPED);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
528 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
529 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
530 default:
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
531 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
532 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
533
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
534 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
535 bufindw = (bufindw + 1)%BUFSIZE;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
536 buflen += 1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
537 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
538 serial_count = 0; //clear buffer
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
539 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
540 else
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
541 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
542 if(serial_char == ';') comment_mode = true;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
543 if(!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
544 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
545 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
546 #ifdef SDSUPPORT
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
547 if(!card.sdprinting || serial_count!=0){
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
548 return;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
549 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
550 while( !card.eof() && buflen < BUFSIZE) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
551 int16_t n=card.get();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
552 serial_char = (char)n;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
553 if(serial_char == '\n' ||
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
554 serial_char == '\r' ||
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
555 (serial_char == ':' && comment_mode == false) ||
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
556 serial_count >= (MAX_CMD_SIZE - 1)||n==-1)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
557 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
558 if(card.eof()){
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
559 SERIAL_PROTOCOLLNPGM(MSG_FILE_PRINTED);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
560 stoptime=millis();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
561 char time[30];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
562 unsigned long t=(stoptime-starttime)/1000;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
563 int sec,min;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
564 min=t/60;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
565 sec=t%60;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
566 sprintf(time,"%i min, %i sec",min,sec);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
567 SERIAL_ECHO_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
568 SERIAL_ECHOLN(time);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
569 LCD_MESSAGE(time);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
570 card.printingHasFinished();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
571 card.checkautostart(true);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
572
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
573 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
574 if(!serial_count)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
575 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
576 comment_mode = false; //for new command
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
577 return; //if empty line
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
578 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
579 cmdbuffer[bufindw][serial_count] = 0; //terminate string
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
580 // if(!comment_mode){
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
581 fromsd[bufindw] = true;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
582 buflen += 1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
583 bufindw = (bufindw + 1)%BUFSIZE;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
584 // }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
585 comment_mode = false; //for new command
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
586 serial_count = 0; //clear buffer
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
587 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
588 else
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
589 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
590 if(serial_char == ';') comment_mode = true;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
591 if(!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
592 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
593 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
594
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
595 #endif //SDSUPPORT
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
596
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
597 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
598
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
599
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
600 float code_value()
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
601 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
602 return (strtod(&cmdbuffer[bufindr][strchr_pointer - cmdbuffer[bufindr] + 1], NULL));
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
603 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
604
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
605 long code_value_long()
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
606 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
607 return (strtol(&cmdbuffer[bufindr][strchr_pointer - cmdbuffer[bufindr] + 1], NULL, 10));
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
608 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
609
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
610 bool code_seen(char code_string[]) //Return True if the string was found
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
611 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
612 return (strstr(cmdbuffer[bufindr], code_string) != NULL);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
613 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
614
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
615 bool code_seen(char code)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
616 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
617 strchr_pointer = strchr(cmdbuffer[bufindr], code);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
618 return (strchr_pointer != NULL); //Return True if a character was found
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
619 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
620
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
621 #define HOMEAXIS(LETTER) \
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
622 if ((LETTER##_MIN_PIN > -1 && LETTER##_HOME_DIR==-1) || (LETTER##_MAX_PIN > -1 && LETTER##_HOME_DIR==1))\
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
623 { \
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
624 current_position[LETTER##_AXIS] = 0; \
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
625 plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); \
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
626 destination[LETTER##_AXIS] = 1.1 * max_length[LETTER##_AXIS] * LETTER##_HOME_DIR; \
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
627 feedrate = fast_home_feedrate[LETTER##_AXIS]; \
1
b584642d4f58 several modifications to support laser enable - still needs cleanup
mbayer
parents: 0
diff changeset
628 plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder, false); \
0
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
629 st_synchronize();\
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
630 \
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
631 current_position[LETTER##_AXIS] = 0;\
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
632 plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);\
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
633 destination[LETTER##_AXIS] = -LETTER##_HOME_RETRACT_MM * LETTER##_HOME_DIR;\
1
b584642d4f58 several modifications to support laser enable - still needs cleanup
mbayer
parents: 0
diff changeset
634 plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder, false); \
0
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
635 st_synchronize();\
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
636 \
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
637 destination[LETTER##_AXIS] = 2*LETTER##_HOME_RETRACT_MM * LETTER##_HOME_DIR;\
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
638 feedrate = homing_feedrate[LETTER##_AXIS] ; \
1
b584642d4f58 several modifications to support laser enable - still needs cleanup
mbayer
parents: 0
diff changeset
639 plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder, false); \
0
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
640 st_synchronize();\
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
641 \
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
642 current_position[LETTER##_AXIS] = LETTER##_HOME_POS;\
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
643 destination[LETTER##_AXIS] = current_position[LETTER##_AXIS];\
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
644 feedrate = 0.0;\
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
645 endstops_hit_on_purpose();\
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
646 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
647
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
648 void wait_for_temp(uint8_t& t_ext, unsigned long& codenum)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
649 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
650 /* See if we are heating up or cooling down */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
651 bool target_direction = isHeatingHotend(t_ext); // true if heating, false if cooling
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
652
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
653 #ifdef TEMP_RESIDENCY_TIME
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
654 long residencyStart;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
655 residencyStart = -1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
656 /* continue to loop until we have reached the target temp
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
657 _and_ until TEMP_RESIDENCY_TIME hasn't passed since we reached it */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
658 while((residencyStart == -1) ||
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
659 (residencyStart >= 0 && (((unsigned int) (millis() - residencyStart)) < (TEMP_RESIDENCY_TIME * 1000UL))) )
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
660 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
661 #else
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
662 while ( target_direction ? (isHeatingHotend(t_ext)) : (isCoolingHotend(tmp_extruder)&&(CooldownNoWait==false)) )
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
663 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
664 #endif //TEMP_RESIDENCY_TIME
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
665 if( (millis() - codenum) > 1000UL )
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
666 { //Print Temp Reading and remaining time every 1 second while heating up/cooling down
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
667 SERIAL_PROTOCOLPGM("T:");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
668 SERIAL_PROTOCOL_F(degHotend(t_ext),1);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
669 SERIAL_PROTOCOLPGM(" E:");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
670 SERIAL_PROTOCOL( (int)t_ext );
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
671 #ifdef TEMP_RESIDENCY_TIME
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
672 SERIAL_PROTOCOLPGM(" W:");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
673 if(residencyStart > -1)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
674 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
675 codenum = ((TEMP_RESIDENCY_TIME * 1000UL) - (millis() - residencyStart)) / 1000UL;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
676 SERIAL_PROTOCOLLN( codenum );
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
677 } else
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
678 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
679 SERIAL_PROTOCOLLN( "?" );
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
680 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
681 #else
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
682 SERIAL_PROTOCOLLN("");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
683 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
684 codenum = millis();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
685 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
686 manage_heater();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
687 manage_inactivity(1);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
688 lcd_status();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
689 led_status();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
690 #ifdef TEMP_RESIDENCY_TIME
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
691 /* start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first time
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
692 or when current temp falls outside the hysteresis after target temp was reached */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
693 if ((residencyStart == -1 && target_direction && (degHotend(t_ext) >= (degTargetHotend(t_ext)-TEMP_WINDOW))) ||
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
694 (residencyStart == -1 && !target_direction && (degHotend(t_ext) <= (degTargetHotend(t_ext)+TEMP_WINDOW))) ||
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
695 (residencyStart > -1 && labs(degHotend(t_ext) - degTargetHotend(t_ext)) > TEMP_HYSTERESIS) )
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
696 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
697 residencyStart = millis();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
698 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
699 #endif //TEMP_RESIDENCY_TIME
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
700 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
701 LCD_MESSAGEPGM(MSG_HEATING_COMPLETE);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
702 starttime=millis();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
703 previous_millis_cmd = millis();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
704 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
705
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
706
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
707 void process_commands()
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
708 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
709 unsigned long codenum; //throw away variable
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
710 char *starpos = NULL;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
711
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
712 if(code_seen('G'))
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
713 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
714 switch((int)code_value())
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
715 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
716 case 0: // G0 -> G1
1
b584642d4f58 several modifications to support laser enable - still needs cleanup
mbayer
parents: 0
diff changeset
717 if(Stopped == false) {
b584642d4f58 several modifications to support laser enable - still needs cleanup
mbayer
parents: 0
diff changeset
718 get_coordinates(); // For X Y Z E F
b584642d4f58 several modifications to support laser enable - still needs cleanup
mbayer
parents: 0
diff changeset
719 prepare_move(false);
b584642d4f58 several modifications to support laser enable - still needs cleanup
mbayer
parents: 0
diff changeset
720 //ClearToSend();
b584642d4f58 several modifications to support laser enable - still needs cleanup
mbayer
parents: 0
diff changeset
721 return;
b584642d4f58 several modifications to support laser enable - still needs cleanup
mbayer
parents: 0
diff changeset
722 }
0
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
723 case 1: // G1
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
724 if(Stopped == false) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
725 get_coordinates(); // For X Y Z E F
1
b584642d4f58 several modifications to support laser enable - still needs cleanup
mbayer
parents: 0
diff changeset
726 prepare_move(true);
0
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
727 //ClearToSend();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
728 return;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
729 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
730 //break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
731 case 2: // G2 - CW ARC
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
732 if(Stopped == false) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
733 get_arc_coordinates();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
734 prepare_arc_move(true);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
735 return;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
736 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
737 case 3: // G3 - CCW ARC
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
738 if(Stopped == false) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
739 get_arc_coordinates();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
740 prepare_arc_move(false);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
741 return;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
742 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
743 case 4: // G4 dwell
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
744 LCD_MESSAGEPGM(MSG_DWELL);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
745 codenum = 0;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
746 if(code_seen('P')) codenum = code_value(); // milliseconds to wait
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
747 if(code_seen('S')) codenum = code_value() * 1000; // seconds to wait
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
748
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
749 st_synchronize();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
750 codenum += millis(); // keep track of when we started waiting
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
751 previous_millis_cmd = millis();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
752 while(millis() < codenum ){
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
753 manage_heater();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
754 manage_inactivity(1);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
755 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
756 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
757
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
758 case 10: // Set offsets
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
759 if(code_seen('P'))
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
760 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
761 tmp_extruder = code_value();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
762 get_coordinates();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
763 extruder_x_off[tmp_extruder] = destination[0]; // X
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
764 extruder_y_off[tmp_extruder] = destination[1]; // Y
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
765 extruder_z_off[tmp_extruder] = destination[2]; // Z
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
766 if(code_seen('R'))
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
767 extruder_standby[tmp_extruder] = code_value();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
768 if(code_seen('S'))
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
769 extruder_temperature[tmp_extruder] = code_value();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
770 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
771 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
772
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
773 case 28: //G28 Home all Axis one at a time
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
774 saved_feedrate = feedrate;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
775 saved_feedmultiply = feedmultiply;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
776 feedmultiply = 100;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
777 previous_millis_cmd = millis();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
778
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
779 enable_endstops(true);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
780
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
781 for(int8_t i=0; i < NUM_AXIS; i++) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
782 destination[i] = current_position[i];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
783 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
784 feedrate = 0.0;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
785 home_all_axis = !((code_seen(axis_codes[0])) || (code_seen(axis_codes[1])) || (code_seen(axis_codes[2])));
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
786
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
787 if((home_all_axis) || (code_seen(axis_codes[X_AXIS])))
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
788 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
789 HOMEAXIS(X);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
790 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
791
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
792 if((home_all_axis) || (code_seen(axis_codes[Y_AXIS]))) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
793 HOMEAXIS(Y);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
794 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
795
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
796 if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
797 HOMEAXIS(Z);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
798 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
799
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
800 if((home_all_axis) || code_seen(axis_codes[X_AXIS]))
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
801 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
802 if(code_value_long() != 0) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
803 current_position[X_AXIS]=code_value();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
804 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
805 current_position[X_AXIS]+=add_homeing[0];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
806 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
807
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
808 if((home_all_axis) || code_seen(axis_codes[Y_AXIS])) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
809 if(code_value_long() != 0) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
810 current_position[Y_AXIS]=code_value();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
811 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
812 current_position[Y_AXIS]+=add_homeing[1];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
813 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
814
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
815 if((home_all_axis) || code_seen(axis_codes[Z_AXIS])) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
816 if(code_value_long() != 0) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
817 current_position[Z_AXIS]=code_value();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
818 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
819 current_position[Z_AXIS]+=add_homeing[2];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
820 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
821 plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
822
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
823 #ifdef ENDSTOPS_ONLY_FOR_HOMING
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
824 enable_endstops(false);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
825 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
826
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
827 feedrate = saved_feedrate;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
828 feedmultiply = saved_feedmultiply;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
829 previous_millis_cmd = millis();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
830 endstops_hit_on_purpose();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
831 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
832 case 29:
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
833 probe_3points();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
834 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
835 case 30:
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
836 probe_1point();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
837 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
838 case 31:
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
839 probe_status();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
840 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
841 case 32:
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
842 FPUTransform_determineBedOrientation();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
843 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
844 case 90: // G90
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
845 relative_mode = false;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
846 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
847 case 91: // G91
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
848 relative_mode = true;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
849 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
850 case 92: // G92
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
851 if(!code_seen(axis_codes[E_AXIS]))
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
852 st_synchronize();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
853 for(int8_t i=0; i < NUM_AXIS; i++) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
854 if(code_seen(axis_codes[i])) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
855 current_position[i] = code_value()+add_homeing[i];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
856 if(i == E_AXIS) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
857 current_position[i] = code_value();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
858 plan_set_e_position(current_position[E_AXIS]);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
859 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
860 else {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
861 current_position[i] = code_value()+add_homeing[i];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
862 plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
863 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
864 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
865 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
866 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
867 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
868 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
869
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
870 else if(code_seen('M'))
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
871 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
872 switch( (int)code_value() )
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
873 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
874 case 0: // Stops - add me...
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
875 case 1:
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
876 case 112:
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
877 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
878
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
879 case 17:
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
880 LCD_MESSAGEPGM(MSG_NO_MOVE);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
881 enable_x();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
882 enable_y();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
883 enable_z();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
884 // N571 disables real E drive! (ie. on laser operations)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
885 if (!n571_enabled) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
886 enable_e0();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
887 enable_e1();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
888 enable_e2();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
889 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
890 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
891
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
892 #ifdef SDSUPPORT
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
893 case 20: // M20 - list SD card
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
894 SERIAL_PROTOCOLLNPGM(MSG_BEGIN_FILE_LIST);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
895 card.ls();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
896 SERIAL_PROTOCOLLNPGM(MSG_END_FILE_LIST);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
897 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
898 case 21: // M21 - init SD card
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
899
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
900 card.initsd();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
901
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
902 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
903 case 22: //M22 - release SD card
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
904 card.release();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
905
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
906 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
907 case 23: //M23 - Select file
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
908 starpos = (strchr(strchr_pointer + 4,'*'));
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
909 if(starpos!=NULL)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
910 *(starpos-1)='\0';
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
911 card.openFile(strchr_pointer + 4,true);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
912 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
913 case 24: //M24 - Start SD print
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
914 card.startFileprint();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
915 starttime=millis();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
916 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
917 case 25: //M25 - Pause SD print
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
918 card.pauseSDPrint();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
919 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
920 case 26: //M26 - Set SD index
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
921 if(card.cardOK && code_seen('S')) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
922 card.setIndex(code_value_long());
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
923 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
924 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
925 case 27: //M27 - Get SD status
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
926 card.getStatus();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
927 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
928 case 28: //M28 - Start SD write
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
929 starpos = (strchr(strchr_pointer + 4,'*'));
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
930 if(starpos != NULL){
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
931 char* npos = strchr(cmdbuffer[bufindr], 'N');
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
932 strchr_pointer = strchr(npos,' ') + 1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
933 *(starpos-1) = '\0';
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
934 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
935 card.openFile(strchr_pointer+4,false);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
936 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
937 case 29: //M29 - Stop SD write
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
938 //processed in write to file routine above
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
939 //card,saving = false;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
940 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
941 case 30: //M30 <filename> Delete File
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
942 if (card.cardOK){
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
943 card.closefile();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
944 starpos = (strchr(strchr_pointer + 4,'*'));
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
945 if(starpos != NULL){
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
946 char* npos = strchr(cmdbuffer[bufindr], 'N');
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
947 strchr_pointer = strchr(npos,' ') + 1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
948 *(starpos-1) = '\0';
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
949 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
950 card.removeFile(strchr_pointer + 4);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
951 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
952 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
953
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
954 case 32: //M32 - fast SD transfer
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
955 card.fast_xfer(strchr_pointer+4);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
956 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
957 case 33: //M31 - high speed xfer capabilities
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
958 SERIAL_ECHOPGM("RAW:");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
959 SERIAL_ECHOLN(SD_FAST_XFER_CHUNK_SIZE);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
960 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
961 #endif //SDSUPPORT
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
962
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
963 case 35: //M35 take time since the start of the SD print or an M109 command
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
964 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
965 stoptime=millis();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
966 char time[30];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
967 unsigned long t=(stoptime-starttime)/1000;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
968 int sec,min;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
969 min=t/60;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
970 sec=t%60;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
971 sprintf(time,"%i min, %i sec",min,sec);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
972 SERIAL_ECHO_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
973 SERIAL_ECHOLN(time);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
974 LCD_MESSAGE(time);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
975 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
976 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
977 case 42: //M42 -Change pin status via gcode
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
978 if (code_seen('S'))
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
979 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
980 int pin_status = code_value();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
981 if (code_seen('P') && pin_status >= 0 && pin_status <= 255)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
982 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
983 int pin_number = code_value();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
984 for(int8_t i = 0; i < (int8_t)sizeof(sensitive_pins); i++)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
985 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
986 if (sensitive_pins[i] == pin_number)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
987 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
988 pin_number = -1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
989 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
990 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
991 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
992
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
993 if (pin_number > -1)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
994 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
995 pinMode(pin_number, OUTPUT);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
996 digitalWrite(pin_number, pin_status);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
997 analogWrite(pin_number, pin_status);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
998 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
999 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1000 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1001 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1002 case 104: // M104
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1003 tmp_extruder = active_extruder;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1004 if(code_seen('T')) { // Why is this T and not S? - AB
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1005 tmp_extruder = code_value();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1006 if(tmp_extruder >= EXTRUDERS) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1007 SERIAL_ECHO_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1008 SERIAL_ECHO(MSG_M104_INVALID_EXTRUDER);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1009 SERIAL_ECHOLN(tmp_extruder);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1010 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1011 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1012 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1013 if (code_seen('S'))
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1014 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1015 extruder_temperature[tmp_extruder] = code_value();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1016 setTargetHotend(code_value(), tmp_extruder);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1017 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1018
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1019 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1020 case 140: // M140 set bed temp
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1021 if (code_seen('S')) setTargetBed(code_value());
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1022 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1023 case 1105:
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1024 #if (TEMP_0_PIN > -1)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1025 SERIAL_PROTOCOLPGM("ok T0 raw:");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1026 SERIAL_PROTOCOL(rawHotend(tmp_extruder));
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1027 SERIAL_PROTOCOLPGM(", min:");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1028 SERIAL_PROTOCOL(minHotend(tmp_extruder));
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1029 SERIAL_PROTOCOLPGM(", max:");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1030 SERIAL_PROTOCOL(maxHotend(tmp_extruder));
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1031 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1032 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1033 case 105 : // M105
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1034 tmp_extruder = active_extruder;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1035 if(code_seen('T')) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1036 tmp_extruder = code_value();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1037 if(tmp_extruder >= EXTRUDERS) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1038 SERIAL_ECHO_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1039 SERIAL_ECHO(MSG_M105_INVALID_EXTRUDER);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1040 SERIAL_ECHOLN(tmp_extruder);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1041 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1042 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1043 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1044 #if (TEMP_0_PIN > -1)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1045 SERIAL_PROTOCOLPGM("ok T:");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1046 SERIAL_PROTOCOL_F(degHotend(tmp_extruder),1);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1047 SERIAL_PROTOCOLPGM(" /");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1048 SERIAL_PROTOCOL_F(degTargetHotend(tmp_extruder),1);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1049 #if TEMP_BED_PIN > -1
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1050 SERIAL_PROTOCOLPGM(" B:");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1051 SERIAL_PROTOCOL_F(degBed(),1);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1052 SERIAL_PROTOCOLPGM(" /");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1053 SERIAL_PROTOCOL_F(degTargetBed(),1);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1054 #endif //TEMP_BED_PIN
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1055 #else
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1056 SERIAL_ERROR_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1057 SERIAL_ERRORLNPGM(MSG_ERR_NO_THERMISTORS);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1058 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1059 #ifdef PIDTEMP
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1060 SERIAL_PROTOCOLPGM(" @:");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1061 SERIAL_PROTOCOL(getHeaterPower(tmp_extruder));
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1062 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1063 SERIAL_PROTOCOLLN("");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1064 return;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1065 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1066 case 109:
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1067 // M109 - Wait for extruder heater to reach target.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1068 tmp_extruder = active_extruder;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1069 if(code_seen('T')) { // Why is this T and not S? - AB
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1070 tmp_extruder = code_value();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1071 if(tmp_extruder >= EXTRUDERS) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1072 SERIAL_ECHO_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1073 SERIAL_ECHO(MSG_M109_INVALID_EXTRUDER);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1074 SERIAL_ECHOLN(tmp_extruder);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1075 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1076 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1077 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1078 LCD_MESSAGEPGM(MSG_HEATING);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1079
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1080 if (code_seen('S'))
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1081 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1082 extruder_temperature[tmp_extruder] = code_value();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1083 setTargetHotend(code_value(), tmp_extruder);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1084 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1085
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1086
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1087 codenum = millis();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1088 wait_for_temp(tmp_extruder, codenum);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1089 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1090 case 190: // M190 - Wait for bed heater to reach target.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1091 #if TEMP_BED_PIN > -1
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1092 LCD_MESSAGEPGM(MSG_BED_HEATING);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1093 if (code_seen('S')) setTargetBed(code_value());
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1094 codenum = millis();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1095 while(isHeatingBed())
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1096 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1097 if(( millis() - codenum) > 1000 ) //Print Temp Reading every 1 second while heating up.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1098 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1099 float tt=degHotend(active_extruder);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1100 SERIAL_PROTOCOLPGM("T:");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1101 SERIAL_PROTOCOL(tt);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1102 SERIAL_PROTOCOLPGM(" E:");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1103 SERIAL_PROTOCOL((int)active_extruder);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1104 SERIAL_PROTOCOLPGM(" B:");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1105 SERIAL_PROTOCOL_F(degBed(),1);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1106 SERIAL_PROTOCOLLN("");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1107 codenum = millis();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1108 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1109 manage_heater();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1110 manage_inactivity(1);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1111 LCD_STATUS;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1112 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1113 LCD_MESSAGEPGM(MSG_BED_DONE);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1114 previous_millis_cmd = millis();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1115 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1116 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1117
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1118 #if FAN_PIN > -1
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1119 case 106: //M106 Fan On
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1120 if (code_seen('S')){
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1121 FanSpeed=constrain(code_value(),0,255);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1122 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1123 else {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1124 FanSpeed=255;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1125 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1126 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1127 case 107: //M107 Fan Off
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1128 FanSpeed = 0;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1129 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1130 #endif //FAN_PIN
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1131
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1132
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1133 case 82:
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1134 axis_relative_modes[3] = false;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1135 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1136 case 83:
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1137 axis_relative_modes[3] = true;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1138 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1139 case 18: //compatibility
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1140 case 84: // M84
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1141 if(code_seen('S')){
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1142 stepper_inactive_time = code_value() * 1000;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1143 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1144 else
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1145 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1146 bool all_axis = !((code_seen(axis_codes[0])) || (code_seen(axis_codes[1])) || (code_seen(axis_codes[2]))|| (code_seen(axis_codes[3])));
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1147 if(all_axis)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1148 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1149 st_synchronize();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1150 disable_e0();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1151 disable_e1();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1152 disable_e2();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1153 finishAndDisableSteppers();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1154
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1155 if (m571_enabled) WRITE(M571_PIN, LOW);// M571 disable
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1156 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1157 else
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1158 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1159 st_synchronize();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1160 if(code_seen('X')) disable_x();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1161 if(code_seen('Y')) disable_y();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1162 if(code_seen('Z')) disable_z();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1163 #if ((E0_ENABLE_PIN != X_ENABLE_PIN) && (E1_ENABLE_PIN != Y_ENABLE_PIN)) // Only enable on boards that have seperate ENABLE_PINS
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1164 if(code_seen('E')) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1165 disable_e0();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1166 disable_e1();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1167 disable_e2();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1168 if (m571_enabled) WRITE(M571_PIN, LOW);// M571 disable
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1169 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1170 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1171 LCD_MESSAGEPGM(MSG_PART_RELEASE);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1172 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1173 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1174 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1175 case 85: // M85
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1176 code_seen('S');
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1177 max_inactive_time = code_value() * 1000;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1178 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1179 case 92: // M92
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1180 for(int8_t i=0; i < NUM_AXIS; i++)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1181 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1182 if(code_seen(axis_codes[i]))
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1183 axis_steps_per_unit[i] = code_value();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1184 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1185 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1186 case 115: // M115
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1187 SerialprintPGM(MSG_M115_REPORT);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1188 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1189 case 117: // M117 display message
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1190 LCD_MESSAGE(cmdbuffer[bufindr]+5);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1191 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1192 case 114: // M114
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1193 SERIAL_PROTOCOLPGM("X:");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1194 SERIAL_PROTOCOL(current_position[X_AXIS]);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1195 SERIAL_PROTOCOLPGM("Y:");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1196 SERIAL_PROTOCOL(current_position[Y_AXIS]);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1197 SERIAL_PROTOCOLPGM("Z:");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1198 SERIAL_PROTOCOL(current_position[Z_AXIS]);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1199 SERIAL_PROTOCOLPGM("E:");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1200 SERIAL_PROTOCOL(current_position[E_AXIS]);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1201
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1202 SERIAL_PROTOCOLPGM(MSG_COUNT_X);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1203 SERIAL_PROTOCOL(float(st_get_position(X_AXIS))/axis_steps_per_unit[X_AXIS]);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1204 SERIAL_PROTOCOLPGM("Y:");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1205 SERIAL_PROTOCOL(float(st_get_position(Y_AXIS))/axis_steps_per_unit[Y_AXIS]);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1206 SERIAL_PROTOCOLPGM("Z:");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1207 SERIAL_PROTOCOL(float(st_get_position(Z_AXIS))/axis_steps_per_unit[Z_AXIS]);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1208
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1209 SERIAL_PROTOCOLLN("");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1210 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1211 case 120: // M120
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1212 enable_endstops(false) ;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1213 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1214 case 121: // M121
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1215 enable_endstops(true) ;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1216 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1217 case 119: // M119
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1218 #if (X_MIN_PIN > -1)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1219 SERIAL_PROTOCOLPGM(MSG_X_MIN);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1220 SERIAL_PROTOCOL(((READ(X_MIN_PIN)^X_ENDSTOPS_INVERTING)?"H ":"L "));
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1221 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1222 #if (X_MAX_PIN > -1)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1223 SERIAL_PROTOCOLPGM(MSG_X_MAX);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1224 SERIAL_PROTOCOL(((READ(X_MAX_PIN)^X_ENDSTOPS_INVERTING)?"H ":"L "));
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1225 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1226 #if (Y_MIN_PIN > -1)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1227 SERIAL_PROTOCOLPGM(MSG_Y_MIN);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1228 SERIAL_PROTOCOL(((READ(Y_MIN_PIN)^Y_ENDSTOPS_INVERTING)?"H ":"L "));
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1229 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1230 #if (Y_MAX_PIN > -1)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1231 SERIAL_PROTOCOLPGM(MSG_Y_MAX);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1232 SERIAL_PROTOCOL(((READ(Y_MAX_PIN)^Y_ENDSTOPS_INVERTING)?"H ":"L "));
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1233 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1234 #if (Z_MIN_PIN > -1)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1235 SERIAL_PROTOCOLPGM(MSG_Z_MIN);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1236 SERIAL_PROTOCOL(((READ(Z_MIN_PIN)^Z_ENDSTOPS_INVERTING)?"H ":"L "));
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1237 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1238 #if (Z_MAX_PIN > -1)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1239 SERIAL_PROTOCOLPGM(MSG_Z_MAX);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1240 SERIAL_PROTOCOL(((READ(Z_MAX_PIN)^Z_ENDSTOPS_INVERTING)?"H ":"L "));
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1241 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1242 SERIAL_PROTOCOLLN("");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1243 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1244 case 201: // M201
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1245 for(int8_t i=0; i < NUM_AXIS; i++)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1246 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1247 if(code_seen(axis_codes[i]))
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1248 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1249 max_acceleration_units_per_sq_second[i] = code_value();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1250 axis_steps_per_sqr_second[i] = code_value() * axis_steps_per_unit[i];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1251 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1252 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1253 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1254 #if 0 // Not used for Sprinter/grbl gen6
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1255 case 202: // M202
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1256 for(int8_t i=0; i < NUM_AXIS; i++) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1257 if(code_seen(axis_codes[i])) axis_travel_steps_per_sqr_second[i] = code_value() * axis_steps_per_unit[i];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1258 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1259 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1260 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1261 case 203: // M203 max feedrate mm/sec
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1262 for(int8_t i=0; i < NUM_AXIS; i++) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1263 if(code_seen(axis_codes[i])) max_feedrate[i] = code_value();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1264 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1265 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1266 case 204: // M204 acclereration S normal moves T filmanent only moves
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1267 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1268 if(code_seen('S')) acceleration = code_value() ;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1269 if(code_seen('T')) retract_acceleration = code_value() ;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1270 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1271 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1272 case 205: //M205 advanced settings: minimum travel speed S=while printing T=travel only, B=minimum segment time X= maximum xy jerk, Z=maximum Z jerk
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1273 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1274 if(code_seen('S')) minimumfeedrate = code_value();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1275 if(code_seen('T')) mintravelfeedrate = code_value();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1276 if(code_seen('B')) minsegmenttime = code_value() ;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1277 if(code_seen('X')) max_xy_jerk = code_value() ;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1278 if(code_seen('Z')) max_z_jerk = code_value() ;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1279 if(code_seen('E')) max_e_jerk = code_value() ;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1280 #ifdef ADVANCE
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1281 if(code_seen('K')) advance_k = code_value() ;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1282 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1283 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1284 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1285 case 206: // M206 additional homeing offset
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1286 for(int8_t i=0; i < 3; i++)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1287 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1288 if(code_seen(axis_codes[i])) add_homeing[i] = code_value();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1289 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1290 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1291 case 208: // M208 set axis max length
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1292 for(int8_t i=0; i < 3; i++)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1293 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1294 if(code_seen(axis_codes[i])) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1295 max_length[i] = code_value();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1296 SERIAL_PROTOCOL(axis_codes[i]);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1297 SERIAL_PROTOCOL(" Axis max length: ");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1298 SERIAL_PROTOCOL(max_length[i]);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1299 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1300 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1301 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1302 case 220: // M220 S<factor in percent>- set speed factor override percentage
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1303 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1304 if(code_seen('S'))
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1305 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1306 feedmultiply = code_value() ;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1307 feedmultiplychanged=true;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1308 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1309 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1310 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1311 case 221: // M221 S<factor in percent>- set extrude factor override percentage
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1312 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1313 if(code_seen('S'))
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1314 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1315 extrudemultiply = code_value() ;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1316 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1317 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1318 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1319
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1320 #ifdef PIDTEMP
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1321 case 301: // M301
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1322 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1323 if(code_seen('P')) Kp = code_value();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1324 if(code_seen('I')) Ki = code_value()*PID_dT;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1325 if(code_seen('D')) Kd = code_value()/PID_dT;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1326 if(code_seen('W')) Ki_Max = constrain(code_value(),0,255);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1327
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1328 updatePID();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1329 SERIAL_PROTOCOL(MSG_OK);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1330 SERIAL_PROTOCOL(" p:");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1331 SERIAL_PROTOCOL(Kp);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1332 SERIAL_PROTOCOL(" i:");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1333 SERIAL_PROTOCOL(Ki/PID_dT);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1334 SERIAL_PROTOCOL(" d:");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1335 SERIAL_PROTOCOL(Kd*PID_dT);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1336 SERIAL_PROTOCOL(" w:");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1337 SERIAL_PROTOCOL(Ki_Max);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1338
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1339 SERIAL_PROTOCOLLN("");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1340 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1341 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1342 #endif //PIDTEMP
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1343 case 240: // M240 Triggers a camera by emulating a Canon RC-1 : http://www.doc-diy.net/photo/rc-1_hacked/
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1344 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1345 #ifdef PHOTOGRAPH_PIN
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1346 #if (PHOTOGRAPH_PIN > -1)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1347 const uint8_t NUM_PULSES=16;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1348 const float PULSE_LENGTH=0.01524;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1349 for(int i=0; i < NUM_PULSES; i++) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1350 WRITE(PHOTOGRAPH_PIN, HIGH);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1351 _delay_ms(PULSE_LENGTH);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1352 WRITE(PHOTOGRAPH_PIN, LOW);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1353 _delay_ms(PULSE_LENGTH);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1354 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1355 delay(7.33);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1356 for(int i=0; i < NUM_PULSES; i++) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1357 WRITE(PHOTOGRAPH_PIN, HIGH);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1358 _delay_ms(PULSE_LENGTH);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1359 WRITE(PHOTOGRAPH_PIN, LOW);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1360 _delay_ms(PULSE_LENGTH);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1361 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1362 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1363 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1364 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1365 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1366
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1367 case 302: // allow cold extrudes
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1368 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1369 if (code_seen('S'))
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1370 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1371 allow_cold_extrudes(code_value());
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1372 }else{
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1373 allow_cold_extrudes(true);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1374 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1375 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1376 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1377 case 303: // M303 PID autotune
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1378 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1379 float temp = 150.0;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1380 if (code_seen('S')) temp=code_value();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1381 PID_autotune(temp);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1382 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1383 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1384 case 304: // Set thermistor parameters
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1385 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1386 // M304 H0 B3960 R4700
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1387 // M304 H1 Bb Rr
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1388 if (code_seen('H'))
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1389 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1390 if(!code_value()){
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1391 //set BED thermistor
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1392 if(code_seen('B')) b_beta = code_value();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1393 if(code_seen('R')) b_resistor = code_value();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1394 if(code_seen('T')) b_thermistor = code_value();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1395 b_inf = ( b_thermistor*exp(-b_beta/298.15) );
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1396 SERIAL_PROTOCOL(MSG_OK);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1397 SERIAL_PROTOCOL(" M304 H0 B");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1398 SERIAL_PROTOCOL(b_beta);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1399 SERIAL_PROTOCOL(" R");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1400 SERIAL_PROTOCOL(b_resistor);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1401 SERIAL_PROTOCOL(" T");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1402 SERIAL_PROTOCOL(b_thermistor);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1403 SERIAL_PROTOCOLLN("");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1404 }else{
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1405 //set active Nozzle thermistor
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1406 if(code_seen('B')) n_beta = code_value();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1407 if(code_seen('R')) n_resistor = code_value();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1408 if(code_seen('T')) n_thermistor = code_value();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1409 n_inf = ( n_thermistor*exp(-n_beta/298.15) );
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1410 SERIAL_PROTOCOL(MSG_OK);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1411 SERIAL_PROTOCOL(" M304 H1 B");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1412 SERIAL_PROTOCOL(n_beta);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1413 SERIAL_PROTOCOL(" R");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1414 SERIAL_PROTOCOL(n_resistor);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1415 SERIAL_PROTOCOL(" T");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1416 SERIAL_PROTOCOL(n_thermistor);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1417 SERIAL_PROTOCOLLN("");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1418 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1419 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1420 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1421 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1422 case 400: // M400 finish all moves
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1423 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1424 st_synchronize();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1425 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1426 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1427 case 500: // Store settings in EEPROM
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1428 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1429 EEPROM_StoreSettings();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1430 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1431 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1432 case 501: // Read settings from EEPROM
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1433 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1434 EEPROM_RetrieveSettings();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1435 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1436 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1437 case 502: // Revert to default settings
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1438 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1439 EEPROM_RetrieveSettings(true);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1440 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1441 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1442 case 503: // print settings currently in memory
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1443 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1444 EEPROM_printSettings();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1445 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1446 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1447 case 504: // print free memory
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1448 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1449 SERIAL_ECHO_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1450 SERIAL_ECHOPGM("Free Memory:");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1451 SERIAL_ECHO(freeMemory());
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1452 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1453 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1454 case 999: // Restart after being stopped
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1455 Stopped = false;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1456 gcode_LastN = Stopped_gcode_LastN;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1457 FlushSerialRequestResend();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1458 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1459 case 510: // FPU Enable
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1460 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1461 FPUEnable();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1462 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1463 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1464 case 511: // FPU Reset
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1465 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1466 FPUReset();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1467 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1468 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1469 case 512: // FPU Disable
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1470 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1471 FPUDisable();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1472 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1473 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1474 #ifdef REPRAPPRO_MULTIMATERIALS
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1475 case 555: // Slave comms test
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1476 talkToSlave("t 0");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1477 SERIAL_ECHO_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1478 SERIAL_ECHOPGM("Slave response:");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1479 SERIAL_ECHO(listenToSlave());
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1480 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1481 case 556: // Set temp
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1482 talkToSlave("T 0 100");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1483 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1484 case 557: // Call stepper test
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1485 talkToSlave("A");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1486 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1487 case 558: // Send interrupt
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1488 for(int ii=0; ii < 1000; ii++)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1489 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1490 toggleSlaveClock();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1491 delay(1);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1492 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1493 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1494 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1495
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1496 case 571: // enable extruder active pin
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1497 if (code_seen('S'))
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1498 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1499 m571_enabled = (int)code_value();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1500 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1501
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1502 if (code_seen('E'))
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1503 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1504 n571_enabled = (int)code_value();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1505 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1506
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1507 WRITE(M571_PIN, LOW);// M571 disable in any case!
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1508
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1509 SERIAL_ECHO_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1510 SERIAL_ECHO("Parameters: S<0|1> enable extruder active pin, E<0|1> if enabled prevent real drive movement");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1511
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1512 SERIAL_ECHO_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1513 SERIAL_ECHO("Extruder active pin: ");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1514 if (m571_enabled) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1515 SERIAL_ECHOLN("enabled");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1516 } else {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1517 SERIAL_ECHOLN("disabled");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1518 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1519
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1520 SERIAL_ECHO_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1521 SERIAL_ECHO("Extruder motor move: ");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1522 if (!n571_enabled) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1523 SERIAL_ECHOLN("enabled");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1524 } else {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1525 SERIAL_ECHOLN("disabled");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1526 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1527
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1528 break;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1529
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1530
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1531
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1532 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1533 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1534
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1535 else if(code_seen('T'))
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1536 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1537 tmp_extruder = code_value();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1538 if(tmp_extruder >= EXTRUDERS)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1539 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1540 SERIAL_ECHO_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1541 SERIAL_ECHO(MSG_STANDBY_TEMP);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1542 SERIAL_ECHO(active_extruder);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1543 setTargetHotend(extruder_standby[active_extruder], active_extruder);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1544 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1545 else
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1546 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1547 if((tmp_extruder != active_extruder) || !extruder_selected)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1548 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1549 setTargetHotend(extruder_standby[active_extruder], active_extruder);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1550 extruder_selected = true;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1551
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1552 // Deal with offsets here: record current pos as temp_position;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1553 // move to temp_position + tmp_extruder - active_extruder;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1554 // Set current pos to be temp_position
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1555 // TOTHINKABOUT: What about cumulative errors with a LOT of extruder changes?
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1556
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1557 for(int8_t i=0; i < NUM_AXIS; i++)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1558 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1559 temp_position[i] = current_position[i];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1560 destination[i] = current_position[i];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1561 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1562 next_feedrate = feedrate;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1563 x_off_d = extruder_x_off[tmp_extruder] - extruder_x_off[active_extruder];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1564 y_off_d = extruder_y_off[tmp_extruder] - extruder_y_off[active_extruder];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1565 z_off_d = extruder_z_off[tmp_extruder] - extruder_z_off[active_extruder];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1566
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1567 if(z_off_d > 0)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1568 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1569 destination[Z_AXIS] += z_off_d;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1570 feedrate = fast_home_feedrate[Z_AXIS];
1
b584642d4f58 several modifications to support laser enable - still needs cleanup
mbayer
parents: 0
diff changeset
1571 prepare_move(false);
0
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1572 destination[X_AXIS] = temp_position[X_AXIS] + x_off_d;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1573 destination[Y_AXIS] = temp_position[Y_AXIS] + y_off_d;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1574 feedrate = fast_home_feedrate[X_AXIS];
1
b584642d4f58 several modifications to support laser enable - still needs cleanup
mbayer
parents: 0
diff changeset
1575 prepare_move(false);
0
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1576 } else
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1577 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1578 destination[X_AXIS] += x_off_d;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1579 destination[Y_AXIS] += y_off_d;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1580 feedrate = fast_home_feedrate[X_AXIS];
1
b584642d4f58 several modifications to support laser enable - still needs cleanup
mbayer
parents: 0
diff changeset
1581 prepare_move(false);
0
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1582 destination[Z_AXIS] = temp_position[Z_AXIS] + z_off_d;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1583 feedrate = fast_home_feedrate[Z_AXIS];
1
b584642d4f58 several modifications to support laser enable - still needs cleanup
mbayer
parents: 0
diff changeset
1584 prepare_move(false);
0
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1585 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1586
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1587 for(int8_t i=0; i < NUM_AXIS; i++)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1588 current_position[i] = temp_position[i];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1589 feedrate = next_feedrate;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1590 active_extruder = tmp_extruder;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1591
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1592 SERIAL_ECHO_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1593 SERIAL_ECHO(MSG_ACTIVE_EXTRUDER);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1594 SERIAL_PROTOCOLLN((int)active_extruder);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1595
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1596 setTargetHotend(extruder_temperature[active_extruder], active_extruder);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1597
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1598
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1599 codenum = millis();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1600 wait_for_temp(active_extruder, codenum);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1601 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1602 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1603 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1604
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1605
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1606 else
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1607 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1608 SERIAL_ECHO_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1609 SERIAL_ECHOPGM(MSG_UNKNOWN_COMMAND);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1610 SERIAL_ECHO(cmdbuffer[bufindr]);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1611 SERIAL_ECHOLNPGM("\"");
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1612 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1613
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1614 ClearToSend();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1615 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1616
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1617 void FlushSerialRequestResend()
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1618 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1619 //char cmdbuffer[bufindr][100]="Resend:";
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1620 MYSERIAL.flush();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1621 SERIAL_PROTOCOLPGM(MSG_RESEND);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1622 SERIAL_PROTOCOLLN(gcode_LastN + 1);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1623 ClearToSend();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1624 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1625
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1626 void ClearToSend()
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1627 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1628 previous_millis_cmd = millis();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1629 #ifdef SDSUPPORT
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1630 if(fromsd[bufindr])
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1631 return;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1632 #endif //SDSUPPORT
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1633 SERIAL_PROTOCOLLNPGM(MSG_OK);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1634 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1635
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1636 void get_coordinates()
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1637 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1638 for(int8_t i=0; i < NUM_AXIS; i++) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1639 if(code_seen(axis_codes[i])) destination[i] = (float)code_value() + (axis_relative_modes[i] || relative_mode)*current_position[i];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1640 else destination[i] = current_position[i]; //Are these else lines really needed?
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1641 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1642 if(code_seen('F')) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1643 next_feedrate = code_value();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1644 if(next_feedrate > 0.0) feedrate = next_feedrate;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1645 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1646 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1647
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1648 void get_arc_coordinates()
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1649 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1650 get_coordinates();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1651 if(code_seen('I')) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1652 offset[0] = code_value();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1653 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1654 else {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1655 offset[0] = 0.0;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1656 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1657 if(code_seen('J')) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1658 offset[1] = code_value();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1659 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1660 else {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1661 offset[1] = 0.0;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1662 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1663 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1664
1
b584642d4f58 several modifications to support laser enable - still needs cleanup
mbayer
parents: 0
diff changeset
1665 void prepare_move(bool laser_on)
0
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1666 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1667
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1668 // transform destination *********************************************
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1669
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1670 FPUTransform_transformDestination();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1671
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1672 if (min_software_endstops) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1673 if (modified_destination[X_AXIS] < X_HOME_POS) modified_destination[X_AXIS] = X_HOME_POS;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1674 if (modified_destination[Y_AXIS] < Y_HOME_POS) modified_destination[Y_AXIS] = Y_HOME_POS;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1675 if (modified_destination[Z_AXIS] < Z_HOME_POS) modified_destination[Z_AXIS] = Z_HOME_POS;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1676 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1677
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1678 if (max_software_endstops) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1679 if (modified_destination[X_AXIS] > max_length[X_AXIS]) modified_destination[X_AXIS] = max_length[X_AXIS];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1680 if (modified_destination[Y_AXIS] > max_length[Y_AXIS]) modified_destination[Y_AXIS] = max_length[Y_AXIS];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1681 if (modified_destination[Z_AXIS] > max_length[Z_AXIS]) modified_destination[Z_AXIS] = max_length[Z_AXIS];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1682 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1683 previous_millis_cmd = millis();
1
b584642d4f58 several modifications to support laser enable - still needs cleanup
mbayer
parents: 0
diff changeset
1684 plan_buffer_line(modified_destination[X_AXIS], modified_destination[Y_AXIS], modified_destination[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder, laser_on);
0
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1685 for(int8_t i=0; i < NUM_AXIS; i++) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1686 current_position[i] = destination[i];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1687 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1688 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1689
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1690 void prepare_arc_move(char isclockwise) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1691 float r = hypot(offset[X_AXIS], offset[Y_AXIS]); // Compute arc radius for mc_arc
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1692
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1693 // transform destination *********************************************
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1694 FPUTransform_transformDestination();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1695
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1696 // Trace the arc
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1697 mc_arc(current_position, modified_destination, offset, X_AXIS, Y_AXIS, Z_AXIS, feedrate*feedmultiply/60/100.0, r, isclockwise, active_extruder);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1698
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1699 // As far as the parser is concerned, the position is now == target. In reality the
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1700 // motion control system might still be processing the action and the real tool position
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1701 // in any intermediate location.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1702 for(int8_t i=0; i < NUM_AXIS; i++) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1703 current_position[i] = destination[i];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1704 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1705 previous_millis_cmd = millis();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1706 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1707
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1708 #ifdef CONTROLLERFAN_PIN
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1709 unsigned long lastMotor = 0; //Save the time for when a motor was turned on last
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1710 unsigned long lastMotorCheck = 0;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1711
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1712 void controllerFan()
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1713 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1714 if ((millis() - lastMotorCheck) >= 2500) //Not a time critical function, so we only check every 2500ms
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1715 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1716 lastMotorCheck = millis();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1717
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1718 if(!READ(X_ENABLE_PIN) || !READ(Y_ENABLE_PIN) || !READ(Z_ENABLE_PIN)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1719 #if EXTRUDERS > 2
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1720 || !READ(E2_ENABLE_PIN)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1721 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1722 #if EXTRUDER > 1
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1723 || !READ(E2_ENABLE_PIN)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1724 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1725 || !READ(E0_ENABLE_PIN)) //If any of the drivers are enabled...
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1726 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1727 lastMotor = millis(); //... set time to NOW so the fan will turn on
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1728 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1729
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1730 if ((millis() - lastMotor) >= (CONTROLLERFAN_SEC*1000UL) || lastMotor == 0) //If the last time any driver was enabled, is longer since than CONTROLLERSEC...
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1731 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1732 WRITE(CONTROLLERFAN_PIN, LOW); //... turn the fan off
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1733 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1734 else
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1735 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1736 WRITE(CONTROLLERFAN_PIN, HIGH); //... turn the fan on
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1737 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1738 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1739 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1740 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1741
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1742 void manage_inactivity(byte debug)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1743 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1744 if( (millis() - previous_millis_cmd) > max_inactive_time )
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1745 if(max_inactive_time)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1746 kill();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1747 if(stepper_inactive_time) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1748 if( (millis() - previous_millis_cmd) > stepper_inactive_time )
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1749 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1750 if(blocks_queued() == false) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1751 disable_x();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1752 disable_y();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1753 disable_z();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1754 disable_e0();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1755 disable_e1();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1756 disable_e2();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1757 if (m571_enabled) WRITE(M571_PIN, LOW);// M571 disable
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1758 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1759 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1760 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1761 #ifdef CONTROLLERFAN_PIN
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1762 controllerFan(); //Check if fan should be turned on to cool stepper drivers down
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1763 #endif
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1764 check_axes_activity();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1765 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1766
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1767 void kill()
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1768 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1769 cli(); // Stop interrupts
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1770 disable_heater();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1771
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1772 disable_x();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1773 disable_y();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1774 disable_z();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1775 disable_e0();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1776 disable_e1();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1777 disable_e2();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1778 if (m571_enabled) WRITE(M571_PIN, LOW);// M571 disable
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1779
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1780 SERIAL_ERROR_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1781 SERIAL_ERRORLNPGM(MSG_ERR_KILLED);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1782 LCD_MESSAGEPGM(MSG_KILLED);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1783 suicide();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1784 while(1); // Wait for reset
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1785 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1786
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1787 void Stop()
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1788 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1789 disable_heater();
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1790 if(Stopped == false) {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1791 Stopped = true;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1792 Stopped_gcode_LastN = gcode_LastN; // Save last g_code for restart
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1793 if (m571_enabled) WRITE(M571_PIN, LOW);// M571 disable
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1794 SERIAL_ERROR_START;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1795 SERIAL_ERRORLNPGM(MSG_ERR_STOPPED);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1796 LCD_MESSAGEPGM(MSG_STOPPED);
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1797 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1798 }
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1799
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1800 bool IsStopped() { return Stopped; };
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1801
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1802

mercurial