My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Marlin.pde 36KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176
  1. /*
  2. Reprap firmware based on Sprinter and grbl.
  3. Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. /*
  16. This firmware is a mashup between Sprinter and grbl.
  17. (https://github.com/kliment/Sprinter)
  18. (https://github.com/simen/grbl/tree)
  19. It has preliminary support for Matthew Roberts advance algorithm
  20. http://reprap.org/pipermail/reprap-dev/2011-May/003323.html
  21. */
  22. #include <EEPROM.h>
  23. #include "EEPROMwrite.h"
  24. #include "fastio.h"
  25. #include "Configuration.h"
  26. #include "pins.h"
  27. #include "Marlin.h"
  28. #include "ultralcd.h"
  29. #include "planner.h"
  30. #include "stepper.h"
  31. #include "temperature.h"
  32. #include "motion_control.h"
  33. #include "cardreader.h"
  34. #include "watchdog.h"
  35. #define VERSION_STRING "1.0.0 Beta 1"
  36. // look here for descriptions of gcodes: http://linuxcnc.org/handbook/gcode/g-code.html
  37. // http://objects.reprap.org/wiki/Mendel_User_Manual:_RepRapGCodes
  38. //Implemented Codes
  39. //-------------------
  40. // G0 -> G1
  41. // G1 - Coordinated Movement X Y Z E
  42. // G2 - CW ARC
  43. // G3 - CCW ARC
  44. // G4 - Dwell S<seconds> or P<milliseconds>
  45. // G28 - Home all Axis
  46. // G90 - Use Absolute Coordinates
  47. // G91 - Use Relative Coordinates
  48. // G92 - Set current position to cordinates given
  49. //RepRap M Codes
  50. // M104 - Set extruder target temp
  51. // M105 - Read current temp
  52. // M106 - Fan on
  53. // M107 - Fan off
  54. // M109 - Wait for extruder current temp to reach target temp.
  55. // M114 - Display current position
  56. //Custom M Codes
  57. // M17 - Enable/Power all stepper motors
  58. // M18 - Disable all stepper motors; same as M84
  59. // M20 - List SD card
  60. // M21 - Init SD card
  61. // M22 - Release SD card
  62. // M23 - Select SD file (M23 filename.g)
  63. // M24 - Start/resume SD print
  64. // M25 - Pause SD print
  65. // M26 - Set SD position in bytes (M26 S12345)
  66. // M27 - Report SD print status
  67. // M28 - Start SD write (M28 filename.g)
  68. // M29 - Stop SD write
  69. // M30 - Output time since last M109 or SD card start to serial
  70. // M42 - Change pin status via gcode
  71. // M80 - Turn on Power Supply
  72. // M81 - Turn off Power Supply
  73. // M82 - Set E codes absolute (default)
  74. // M83 - Set E codes relative while in Absolute Coordinates (G90) mode
  75. // M84 - Disable steppers until next move,
  76. // or use S<seconds> to specify an inactivity timeout, after which the steppers will be disabled. S0 to disable the timeout.
  77. // M85 - Set inactivity shutdown timer with parameter S<seconds>. To disable set zero (default)
  78. // M92 - Set axis_steps_per_unit - same syntax as G92
  79. // M114 - Output current position to serial port
  80. // M115 - Capabilities string
  81. // M117 - display message
  82. // M119 - Output Endstop status to serial port
  83. // M140 - Set bed target temp
  84. // M190 - Wait for bed current temp to reach target temp.
  85. // M200 - Set filament diameter
  86. // M201 - Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000)
  87. // M202 - Set max acceleration in units/s^2 for travel moves (M202 X1000 Y1000) Unused in Marlin!!
  88. // M203 - Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in mm/sec
  89. // 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
  90. // M205 - advanced settings: minimum travel speed S=while printing T=travel only, B=minimum segment time X= maximum xy jerk, Z=maximum Z jerk
  91. // M206 - set additional homeing offset
  92. // M220 - set speed factor override percentage S:factor in percent
  93. // M301 - Set PID parameters P I and D
  94. // M400 - Finish all moves
  95. // M500 - stores paramters in EEPROM
  96. // M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).
  97. // M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to.
  98. //Stepper Movement Variables
  99. //===========================================================================
  100. //=============================imported variables============================
  101. //===========================================================================
  102. extern float HeaterPower;
  103. //===========================================================================
  104. //=============================public variables=============================
  105. //===========================================================================
  106. #ifdef SDSUPPORT
  107. CardReader card;
  108. #endif
  109. float homing_feedrate[] = HOMING_FEEDRATE;
  110. bool axis_relative_modes[] = AXIS_RELATIVE_MODES;
  111. volatile int feedmultiply=100; //100->1 200->2
  112. int saved_feedmultiply;
  113. volatile bool feedmultiplychanged=false;
  114. float current_position[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0};
  115. float add_homeing[3]={0,0,0};
  116. //===========================================================================
  117. //=============================private variables=============================
  118. //===========================================================================
  119. const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'};
  120. static float destination[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0};
  121. static float offset[3] = {0.0, 0.0, 0.0};
  122. static bool home_all_axis = true;
  123. static float feedrate = 1500.0, next_feedrate, saved_feedrate;
  124. static long gcode_N, gcode_LastN;
  125. static bool relative_mode = false; //Determines Absolute or Relative Coordinates
  126. 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.
  127. static uint8_t fanpwm=0;
  128. static char cmdbuffer[BUFSIZE][MAX_CMD_SIZE];
  129. static bool fromsd[BUFSIZE];
  130. static int bufindr = 0;
  131. static int bufindw = 0;
  132. static int buflen = 0;
  133. static int i = 0;
  134. static char serial_char;
  135. static int serial_count = 0;
  136. static boolean comment_mode = false;
  137. static char *strchr_pointer; // just a pointer to find chars in the cmd string like X, Y, Z, E, etc
  138. const int sensitive_pins[] = SENSITIVE_PINS; // Sensitive pin list for M42
  139. static float tt = 0, bt = 0;
  140. //Inactivity shutdown variables
  141. static unsigned long previous_millis_cmd = 0;
  142. static unsigned long max_inactive_time = 0;
  143. static unsigned long stepper_inactive_time = 0;
  144. static unsigned long starttime=0;
  145. static unsigned long stoptime=0;
  146. static uint8_t tmp_extruder;
  147. //===========================================================================
  148. //=============================ROUTINES=============================
  149. //===========================================================================
  150. void get_arc_coordinates();
  151. extern "C"{
  152. extern unsigned int __bss_end;
  153. extern unsigned int __heap_start;
  154. extern void *__brkval;
  155. int freeMemory() {
  156. int free_memory;
  157. if((int)__brkval == 0)
  158. free_memory = ((int)&free_memory) - ((int)&__bss_end);
  159. else
  160. free_memory = ((int)&free_memory) - ((int)__brkval);
  161. return free_memory;
  162. }
  163. }
  164. //adds an command to the main command buffer
  165. //thats really done in a non-safe way.
  166. //needs overworking someday
  167. void enquecommand(const char *cmd)
  168. {
  169. if(buflen < BUFSIZE)
  170. {
  171. //this is dangerous if a mixing of serial and this happsens
  172. strcpy(&(cmdbuffer[bufindw][0]),cmd);
  173. SERIAL_ECHO_START;
  174. SERIAL_ECHOPGM("enqueing \"");
  175. SERIAL_ECHO(cmdbuffer[bufindw]);
  176. SERIAL_ECHOLNPGM("\"");
  177. bufindw= (bufindw + 1)%BUFSIZE;
  178. buflen += 1;
  179. }
  180. }
  181. void setup()
  182. {
  183. MSerial.begin(BAUDRATE);
  184. SERIAL_ECHO_START;
  185. SERIAL_ECHOLNPGM(VERSION_STRING);
  186. SERIAL_PROTOCOLLNPGM("start");
  187. SERIAL_ECHO_START;
  188. SERIAL_ECHOPGM("Free Memory:");
  189. SERIAL_ECHOLN(freeMemory());
  190. for(int8_t i = 0; i < BUFSIZE; i++)
  191. {
  192. fromsd[i] = false;
  193. }
  194. RetrieveSettings(); // loads data from EEPROM if available
  195. for(int8_t i=0; i < NUM_AXIS; i++)
  196. {
  197. axis_steps_per_sqr_second[i] = max_acceleration_units_per_sq_second[i] * axis_steps_per_unit[i];
  198. }
  199. tp_init(); // Initialize temperature loop
  200. plan_init(); // Initialize planner;
  201. st_init(); // Initialize stepper;
  202. wd_init();
  203. }
  204. void loop()
  205. {
  206. if(buflen<3)
  207. get_command();
  208. #ifdef SDSUPPORT
  209. card.checkautostart(false);
  210. #endif
  211. if(buflen)
  212. {
  213. #ifdef SDSUPPORT
  214. if(card.saving)
  215. {
  216. if(strstr(cmdbuffer[bufindr],"M29") == NULL)
  217. {
  218. card.write_command(cmdbuffer[bufindr]);
  219. SERIAL_PROTOCOLLNPGM("ok");
  220. }
  221. else
  222. {
  223. card.closefile();
  224. SERIAL_PROTOCOLLNPGM("Done saving file.");
  225. }
  226. }
  227. else
  228. {
  229. process_commands();
  230. }
  231. #else
  232. process_commands();
  233. #endif //SDSUPPORT
  234. buflen = (buflen-1);
  235. bufindr = (bufindr + 1)%BUFSIZE;
  236. }
  237. //check heater every n milliseconds
  238. manage_heater();
  239. manage_inactivity(1);
  240. checkHitEndstops();
  241. LCD_STATUS;
  242. }
  243. FORCE_INLINE void get_command()
  244. {
  245. while( MSerial.available() > 0 && buflen < BUFSIZE) {
  246. serial_char = MSerial.read();
  247. if(serial_char == '\n' || serial_char == '\r' || serial_char == ':' || serial_count >= (MAX_CMD_SIZE - 1) )
  248. {
  249. if(!serial_count) return; //if empty line
  250. cmdbuffer[bufindw][serial_count] = 0; //terminate string
  251. if(!comment_mode){
  252. fromsd[bufindw] = false;
  253. if(strstr(cmdbuffer[bufindw], "N") != NULL)
  254. {
  255. strchr_pointer = strchr(cmdbuffer[bufindw], 'N');
  256. gcode_N = (strtol(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL, 10));
  257. if(gcode_N != gcode_LastN+1 && (strstr(cmdbuffer[bufindw], "M110") == NULL) ) {
  258. SERIAL_ERROR_START;
  259. SERIAL_ERRORPGM("Line Number is not Last Line Number+1, Last Line:");
  260. SERIAL_ERRORLN(gcode_LastN);
  261. //Serial.println(gcode_N);
  262. FlushSerialRequestResend();
  263. serial_count = 0;
  264. return;
  265. }
  266. if(strstr(cmdbuffer[bufindw], "*") != NULL)
  267. {
  268. byte checksum = 0;
  269. byte count = 0;
  270. while(cmdbuffer[bufindw][count] != '*') checksum = checksum^cmdbuffer[bufindw][count++];
  271. strchr_pointer = strchr(cmdbuffer[bufindw], '*');
  272. if( (int)(strtod(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL)) != checksum) {
  273. SERIAL_ERROR_START;
  274. SERIAL_ERRORPGM("checksum mismatch, Last Line:");
  275. SERIAL_ERRORLN(gcode_LastN);
  276. FlushSerialRequestResend();
  277. serial_count = 0;
  278. return;
  279. }
  280. //if no errors, continue parsing
  281. }
  282. else
  283. {
  284. SERIAL_ERROR_START;
  285. SERIAL_ERRORPGM("No Checksum with line number, Last Line:");
  286. SERIAL_ERRORLN(gcode_LastN);
  287. FlushSerialRequestResend();
  288. serial_count = 0;
  289. return;
  290. }
  291. gcode_LastN = gcode_N;
  292. //if no errors, continue parsing
  293. }
  294. else // if we don't receive 'N' but still see '*'
  295. {
  296. if((strstr(cmdbuffer[bufindw], "*") != NULL))
  297. {
  298. SERIAL_ERROR_START;
  299. SERIAL_ERRORPGM("No Line Number with checksum, Last Line:");
  300. SERIAL_ERRORLN(gcode_LastN);
  301. serial_count = 0;
  302. return;
  303. }
  304. }
  305. if((strstr(cmdbuffer[bufindw], "G") != NULL)){
  306. strchr_pointer = strchr(cmdbuffer[bufindw], 'G');
  307. switch((int)((strtod(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL)))){
  308. case 0:
  309. case 1:
  310. case 2:
  311. case 3:
  312. #ifdef SDSUPPORT
  313. if(card.saving)
  314. break;
  315. #endif //SDSUPPORT
  316. SERIAL_PROTOCOLLNPGM("ok");
  317. break;
  318. default:
  319. break;
  320. }
  321. }
  322. bufindw = (bufindw + 1)%BUFSIZE;
  323. buflen += 1;
  324. }
  325. comment_mode = false; //for new command
  326. serial_count = 0; //clear buffer
  327. }
  328. else
  329. {
  330. if(serial_char == ';') comment_mode = true;
  331. if(!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char;
  332. }
  333. }
  334. #ifdef SDSUPPORT
  335. if(!card.sdprinting || serial_count!=0){
  336. return;
  337. }
  338. while( !card.eof() && buflen < BUFSIZE) {
  339. int16_t n=card.get();
  340. serial_char = (char)n;
  341. if(serial_char == '\n' || serial_char == '\r' || serial_char == ':' || serial_count >= (MAX_CMD_SIZE - 1)||n==-1)
  342. {
  343. if(card.eof()){
  344. SERIAL_PROTOCOLLNPGM("Done printing file");
  345. stoptime=millis();
  346. char time[30];
  347. unsigned long t=(stoptime-starttime)/1000;
  348. int sec,min;
  349. min=t/60;
  350. sec=t%60;
  351. sprintf(time,"%i min, %i sec",min,sec);
  352. SERIAL_ECHO_START;
  353. SERIAL_ECHOLN(time);
  354. LCD_MESSAGE(time);
  355. card.printingHasFinished();
  356. card.checkautostart(true);
  357. }
  358. if(serial_char=='\n')
  359. comment_mode = false; //for new command
  360. if(!serial_count)
  361. {
  362. return; //if empty line
  363. }
  364. cmdbuffer[bufindw][serial_count] = 0; //terminate string
  365. if(!comment_mode){
  366. fromsd[bufindw] = true;
  367. buflen += 1;
  368. bufindw = (bufindw + 1)%BUFSIZE;
  369. }
  370. serial_count = 0; //clear buffer
  371. }
  372. else
  373. {
  374. if(serial_char == ';') comment_mode = true;
  375. if(!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char;
  376. }
  377. }
  378. #endif //SDSUPPORT
  379. }
  380. FORCE_INLINE float code_value()
  381. {
  382. return (strtod(&cmdbuffer[bufindr][strchr_pointer - cmdbuffer[bufindr] + 1], NULL));
  383. }
  384. FORCE_INLINE long code_value_long()
  385. {
  386. return (strtol(&cmdbuffer[bufindr][strchr_pointer - cmdbuffer[bufindr] + 1], NULL, 10));
  387. }
  388. FORCE_INLINE bool code_seen(char code_string[]) //Return True if the string was found
  389. {
  390. return (strstr(cmdbuffer[bufindr], code_string) != NULL);
  391. }
  392. FORCE_INLINE bool code_seen(char code)
  393. {
  394. strchr_pointer = strchr(cmdbuffer[bufindr], code);
  395. return (strchr_pointer != NULL); //Return True if a character was found
  396. }
  397. #define HOMEAXIS(LETTER) \
  398. if ((LETTER##_MIN_PIN > -1 && LETTER##_HOME_DIR==-1) || (LETTER##_MAX_PIN > -1 && LETTER##_HOME_DIR==1))\
  399. { \
  400. current_position[LETTER##_AXIS] = 0; \
  401. plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); \
  402. destination[LETTER##_AXIS] = 1.5 * LETTER##_MAX_LENGTH * LETTER##_HOME_DIR; \
  403. feedrate = homing_feedrate[LETTER##_AXIS]; \
  404. prepare_move(); \
  405. \
  406. current_position[LETTER##_AXIS] = 0;\
  407. plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);\
  408. destination[LETTER##_AXIS] = -LETTER##_HOME_RETRACT_MM * LETTER##_HOME_DIR;\
  409. prepare_move(); \
  410. \
  411. destination[LETTER##_AXIS] = 2*LETTER##_HOME_RETRACT_MM * LETTER##_HOME_DIR;\
  412. feedrate = homing_feedrate[LETTER##_AXIS]/2 ; \
  413. prepare_move(); \
  414. \
  415. current_position[LETTER##_AXIS] = (LETTER##_HOME_DIR == -1) ? 0 : LETTER##_MAX_LENGTH;\
  416. plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);\
  417. destination[LETTER##_AXIS] = current_position[LETTER##_AXIS];\
  418. feedrate = 0.0;\
  419. st_synchronize();\
  420. plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);\
  421. endstops_hit_on_purpose();\
  422. }
  423. FORCE_INLINE void process_commands()
  424. {
  425. unsigned long codenum; //throw away variable
  426. char *starpos = NULL;
  427. if(code_seen('G'))
  428. {
  429. switch((int)code_value())
  430. {
  431. case 0: // G0 -> G1
  432. case 1: // G1
  433. get_coordinates(); // For X Y Z E F
  434. prepare_move();
  435. previous_millis_cmd = millis();
  436. //ClearToSend();
  437. return;
  438. //break;
  439. case 2: // G2 - CW ARC
  440. get_arc_coordinates();
  441. prepare_arc_move(true);
  442. previous_millis_cmd = millis();
  443. return;
  444. case 3: // G3 - CCW ARC
  445. get_arc_coordinates();
  446. prepare_arc_move(false);
  447. previous_millis_cmd = millis();
  448. return;
  449. case 4: // G4 dwell
  450. LCD_MESSAGEPGM("DWELL...");
  451. codenum = 0;
  452. if(code_seen('P')) codenum = code_value(); // milliseconds to wait
  453. if(code_seen('S')) codenum = code_value() * 1000; // seconds to wait
  454. st_synchronize();
  455. codenum += millis(); // keep track of when we started waiting
  456. while(millis() < codenum ){
  457. manage_heater();
  458. }
  459. break;
  460. case 28: //G28 Home all Axis one at a time
  461. saved_feedrate = feedrate;
  462. saved_feedmultiply = feedmultiply;
  463. feedmultiply = 100;
  464. for(int8_t i=0; i < NUM_AXIS; i++) {
  465. destination[i] = current_position[i];
  466. }
  467. feedrate = 0.0;
  468. home_all_axis = !((code_seen(axis_codes[0])) || (code_seen(axis_codes[1])) || (code_seen(axis_codes[2])));
  469. if( code_seen(axis_codes[0]) && code_seen(axis_codes[1]) ) //first diagonal move
  470. {
  471. current_position[X_AXIS] = 0; current_position[Y_AXIS] = 0;
  472. plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
  473. destination[X_AXIS] = 1.5 * X_MAX_LENGTH * X_HOME_DIR;
  474. destination[Y_AXIS] = 1.5 * Y_MAX_LENGTH * Y_HOME_DIR;
  475. feedrate =homing_feedrate[X_AXIS];
  476. if(homing_feedrate[Y_AXIS]<feedrate)
  477. feedrate =homing_feedrate[Y_AXIS];
  478. prepare_move();
  479. current_position[X_AXIS] = 0; current_position[Y_AXIS] = 0;
  480. }
  481. if((home_all_axis) || (code_seen(axis_codes[X_AXIS])))
  482. {
  483. HOMEAXIS(X);
  484. current_position[0]=code_value()+add_homeing[0];
  485. }
  486. if((home_all_axis) || (code_seen(axis_codes[Y_AXIS]))) {
  487. HOMEAXIS(Y);
  488. current_position[1]=code_value()+add_homeing[1];
  489. }
  490. if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) {
  491. HOMEAXIS(Z);
  492. current_position[2]=code_value()+add_homeing[2];
  493. }
  494. feedrate = saved_feedrate;
  495. feedmultiply = saved_feedmultiply;
  496. previous_millis_cmd = millis();
  497. endstops_hit_on_purpose();
  498. break;
  499. case 90: // G90
  500. relative_mode = false;
  501. break;
  502. case 91: // G91
  503. relative_mode = true;
  504. break;
  505. case 92: // G92
  506. if(!code_seen(axis_codes[E_AXIS]))
  507. st_synchronize();
  508. for(int8_t i=0; i < NUM_AXIS; i++) {
  509. if(code_seen(axis_codes[i])) {
  510. current_position[i] = code_value()+add_homeing[i];
  511. if(i == E_AXIS) {
  512. plan_set_e_position(current_position[E_AXIS]);
  513. }
  514. else {
  515. plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
  516. }
  517. }
  518. }
  519. break;
  520. }
  521. }
  522. else if(code_seen('M'))
  523. {
  524. switch( (int)code_value() )
  525. {
  526. case 17:
  527. LCD_MESSAGEPGM("No move.");
  528. enable_x();
  529. enable_y();
  530. enable_z();
  531. enable_e();
  532. break;
  533. #ifdef SDSUPPORT
  534. case 20: // M20 - list SD card
  535. SERIAL_PROTOCOLLNPGM("Begin file list");
  536. card.ls();
  537. SERIAL_PROTOCOLLNPGM("End file list");
  538. break;
  539. case 21: // M21 - init SD card
  540. card.initsd();
  541. break;
  542. case 22: //M22 - release SD card
  543. card.release();
  544. break;
  545. case 23: //M23 - Select file
  546. starpos = (strchr(strchr_pointer + 4,'*'));
  547. if(starpos!=NULL)
  548. *(starpos-1)='\0';
  549. card.openFile(strchr_pointer + 4,true);
  550. break;
  551. case 24: //M24 - Start SD print
  552. card.startFileprint();
  553. starttime=millis();
  554. break;
  555. case 25: //M25 - Pause SD print
  556. card.pauseSDPrint();
  557. break;
  558. case 26: //M26 - Set SD index
  559. if(card.cardOK && code_seen('S')){
  560. card.setIndex(code_value_long());
  561. }
  562. break;
  563. case 27: //M27 - Get SD status
  564. card.getStatus();
  565. break;
  566. case 28: //M28 - Start SD write
  567. starpos = (strchr(strchr_pointer + 4,'*'));
  568. if(starpos != NULL){
  569. char* npos = strchr(cmdbuffer[bufindr], 'N');
  570. strchr_pointer = strchr(npos,' ') + 1;
  571. *(starpos-1) = '\0';
  572. }
  573. card.openFile(strchr_pointer+4,false);
  574. break;
  575. case 29: //M29 - Stop SD write
  576. //processed in write to file routine above
  577. //card,saving = false;
  578. break;
  579. #endif //SDSUPPORT
  580. case 30: //M30 take time since the start of the SD print or an M109 command
  581. {
  582. stoptime=millis();
  583. char time[30];
  584. unsigned long t=(stoptime-starttime)/1000;
  585. int sec,min;
  586. min=t/60;
  587. sec=t%60;
  588. sprintf(time,"%i min, %i sec",min,sec);
  589. SERIAL_ECHO_START;
  590. SERIAL_ECHOLN(time);
  591. LCD_MESSAGE(time);
  592. }
  593. break;
  594. case 42: //M42 -Change pin status via gcode
  595. if (code_seen('S'))
  596. {
  597. int pin_status = code_value();
  598. if (code_seen('P') && pin_status >= 0 && pin_status <= 255)
  599. {
  600. int pin_number = code_value();
  601. for(int8_t i = 0; i < (int8_t)sizeof(sensitive_pins); i++)
  602. {
  603. if (sensitive_pins[i] == pin_number)
  604. {
  605. pin_number = -1;
  606. break;
  607. }
  608. }
  609. if (pin_number > -1)
  610. {
  611. pinMode(pin_number, OUTPUT);
  612. digitalWrite(pin_number, pin_status);
  613. analogWrite(pin_number, pin_status);
  614. }
  615. }
  616. }
  617. break;
  618. case 104: // M104
  619. tmp_extruder = active_extruder;
  620. if(code_seen('T')) {
  621. tmp_extruder = code_value();
  622. if(tmp_extruder >= EXTRUDERS) {
  623. SERIAL_ECHO_START;
  624. SERIAL_ECHO("M104 Invalid extruder ");
  625. SERIAL_ECHOLN(tmp_extruder);
  626. break;
  627. }
  628. }
  629. if (code_seen('S')) setTargetHotend(code_value(), tmp_extruder);
  630. setWatch();
  631. break;
  632. case 140: // M140 set bed temp
  633. if (code_seen('S')) setTargetBed(code_value());
  634. break;
  635. case 105 : // M105
  636. tmp_extruder = active_extruder;
  637. if(code_seen('T')) {
  638. tmp_extruder = code_value();
  639. if(tmp_extruder >= EXTRUDERS) {
  640. SERIAL_ECHO_START;
  641. SERIAL_ECHO("M105 Invalid extruder ");
  642. SERIAL_ECHOLN(tmp_extruder);
  643. break;
  644. }
  645. }
  646. #if (TEMP_0_PIN > -1) || (TEMP_2_PIN > -1)
  647. SERIAL_PROTOCOLPGM("ok T:");
  648. SERIAL_PROTOCOL( degHotend(tmp_extruder));
  649. #if TEMP_1_PIN > -1
  650. SERIAL_PROTOCOLPGM(" B:");
  651. SERIAL_PROTOCOL(degBed());
  652. #endif //TEMP_1_PIN
  653. #else
  654. SERIAL_ERROR_START;
  655. SERIAL_ERRORLNPGM("No thermistors - no temp");
  656. #endif
  657. #ifdef PIDTEMP
  658. SERIAL_PROTOCOLPGM(" @:");
  659. SERIAL_PROTOCOL( HeaterPower);
  660. #endif
  661. SERIAL_PROTOCOLLN("");
  662. return;
  663. break;
  664. case 109:
  665. {// M109 - Wait for extruder heater to reach target.
  666. tmp_extruder = active_extruder;
  667. if(code_seen('T')) {
  668. tmp_extruder = code_value();
  669. if(tmp_extruder >= EXTRUDERS) {
  670. SERIAL_ECHO_START;
  671. SERIAL_ECHO("M109 Invalid extruder ");
  672. SERIAL_ECHOLN(tmp_extruder);
  673. break;
  674. }
  675. }
  676. LCD_MESSAGEPGM("Heating...");
  677. #ifdef AUTOTEMP
  678. autotemp_enabled=false;
  679. #endif
  680. if (code_seen('S')) setTargetHotend(code_value(), tmp_extruder);
  681. #ifdef AUTOTEMP
  682. if (code_seen('S')) autotemp_min=code_value();
  683. if (code_seen('G')) autotemp_max=code_value();
  684. if (code_seen('F'))
  685. {
  686. autotemp_factor=code_value();
  687. autotemp_enabled=true;
  688. }
  689. #endif
  690. setWatch();
  691. codenum = millis();
  692. /* See if we are heating up or cooling down */
  693. bool target_direction = isHeatingHotend(tmp_extruder); // true if heating, false if cooling
  694. #ifdef TEMP_RESIDENCY_TIME
  695. long residencyStart;
  696. residencyStart = -1;
  697. /* continue to loop until we have reached the target temp
  698. _and_ until TEMP_RESIDENCY_TIME hasn't passed since we reached it */
  699. while((target_direction ? (isHeatingHotend(tmp_extruder)) : (isCoolingHotend(tmp_extruder))) ||
  700. (residencyStart > -1 && (millis() - residencyStart) < TEMP_RESIDENCY_TIME*1000) ) {
  701. #else
  702. while ( target_direction ? (isHeatingHotend(tmp_extruder)) : (isCoolingHotend(tmp_extruder)&&(CooldownNoWait==false)) ) {
  703. #endif //TEMP_RESIDENCY_TIME
  704. if( (millis() - codenum) > 1000 )
  705. { //Print Temp Reading every 1 second while heating up/cooling down
  706. SERIAL_PROTOCOLPGM("T:");
  707. SERIAL_PROTOCOLLN( degHotend(tmp_extruder) );
  708. codenum = millis();
  709. }
  710. manage_heater();
  711. LCD_STATUS;
  712. #ifdef TEMP_RESIDENCY_TIME
  713. /* start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first time
  714. or when current temp falls outside the hysteresis after target temp was reached */
  715. if ((residencyStart == -1 && target_direction && !isHeatingHotend(tmp_extruder)) ||
  716. (residencyStart == -1 && !target_direction && !isCoolingHotend(tmp_extruder)) ||
  717. (residencyStart > -1 && labs(degHotend(tmp_extruder) - degTargetHotend(tmp_extruder)) > TEMP_HYSTERESIS) )
  718. {
  719. residencyStart = millis();
  720. }
  721. #endif //TEMP_RESIDENCY_TIME
  722. }
  723. LCD_MESSAGEPGM("Heating done.");
  724. starttime=millis();
  725. }
  726. break;
  727. case 190: // M190 - Wait bed for heater to reach target.
  728. #if TEMP_1_PIN > -1
  729. LCD_MESSAGEPGM("Bed Heating.");
  730. if (code_seen('S')) setTargetBed(code_value());
  731. codenum = millis();
  732. while(isHeatingBed())
  733. {
  734. if( (millis()-codenum) > 1000 ) //Print Temp Reading every 1 second while heating up.
  735. {
  736. float tt=degHotend0();
  737. SERIAL_PROTOCOLPGM("T:");
  738. SERIAL_PROTOCOLLN(tt );
  739. SERIAL_PROTOCOLPGM("ok T:");
  740. SERIAL_PROTOCOL(tt );
  741. SERIAL_PROTOCOLPGM(" B:");
  742. SERIAL_PROTOCOLLN(degBed() );
  743. codenum = millis();
  744. }
  745. manage_heater();
  746. }
  747. LCD_MESSAGEPGM("Bed done.");
  748. #endif
  749. break;
  750. #if FAN_PIN > -1
  751. case 106: //M106 Fan On
  752. if (code_seen('S')){
  753. WRITE(FAN_PIN,HIGH);
  754. fanpwm=constrain(code_value(),0,255);
  755. analogWrite(FAN_PIN, fanpwm);
  756. }
  757. else {
  758. WRITE(FAN_PIN,HIGH);
  759. fanpwm=255;
  760. analogWrite(FAN_PIN, fanpwm);
  761. }
  762. break;
  763. case 107: //M107 Fan Off
  764. WRITE(FAN_PIN,LOW);
  765. analogWrite(FAN_PIN, 0);
  766. break;
  767. #endif //FAN_PIN
  768. #if (PS_ON_PIN > -1)
  769. case 80: // M80 - ATX Power On
  770. SET_OUTPUT(PS_ON_PIN); //GND
  771. break;
  772. case 81: // M81 - ATX Power Off
  773. SET_INPUT(PS_ON_PIN); //Floating
  774. break;
  775. #endif
  776. case 82:
  777. axis_relative_modes[3] = false;
  778. break;
  779. case 83:
  780. axis_relative_modes[3] = true;
  781. break;
  782. case 18: //compatibility
  783. case 84: // M84
  784. if(code_seen('S')){
  785. stepper_inactive_time = code_value() * 1000;
  786. }
  787. else
  788. {
  789. #if ((E_ENABLE_PIN != X_ENABLE_PIN) && (E_ENABLE_PIN != Y_ENABLE_PIN)) // Only enable on boards that have seperate ENABLE_PINS
  790. if(code_seen('E')) {
  791. st_synchronize();
  792. LCD_MESSAGEPGM("Free Move");
  793. disable_e();
  794. }
  795. else {
  796. finishAndDisableSteppers();
  797. }
  798. #else
  799. finishAndDisableSteppers();
  800. #endif
  801. }
  802. break;
  803. case 85: // M85
  804. code_seen('S');
  805. max_inactive_time = code_value() * 1000;
  806. break;
  807. case 92: // M92
  808. for(int8_t i=0; i < NUM_AXIS; i++)
  809. {
  810. if(code_seen(axis_codes[i]))
  811. axis_steps_per_unit[i] = code_value();
  812. }
  813. break;
  814. case 115: // M115
  815. SerialprintPGM("FIRMWARE_NAME:Marlin; Sprinter/grbl mashup for gen6 FIRMWARE_URL:http://www.mendel-parts.com PROTOCOL_VERSION:1.0 MACHINE_TYPE:Mendel EXTRUDER_COUNT:1");
  816. break;
  817. case 117: // M117 display message
  818. LCD_MESSAGE(cmdbuffer[bufindr]+5);
  819. break;
  820. case 114: // M114
  821. SERIAL_PROTOCOLPGM("X:");
  822. SERIAL_PROTOCOL(current_position[X_AXIS]);
  823. SERIAL_PROTOCOLPGM("Y:");
  824. SERIAL_PROTOCOL(current_position[Y_AXIS]);
  825. SERIAL_PROTOCOLPGM("Z:");
  826. SERIAL_PROTOCOL(current_position[Z_AXIS]);
  827. SERIAL_PROTOCOLPGM("E:");
  828. SERIAL_PROTOCOL(current_position[E_AXIS]);
  829. SERIAL_PROTOCOLPGM(" Count X:");
  830. SERIAL_PROTOCOL(float(st_get_position(X_AXIS))/axis_steps_per_unit[X_AXIS]);
  831. SERIAL_PROTOCOLPGM("Y:");
  832. SERIAL_PROTOCOL(float(st_get_position(Y_AXIS))/axis_steps_per_unit[Y_AXIS]);
  833. SERIAL_PROTOCOLPGM("Z:");
  834. SERIAL_PROTOCOL(float(st_get_position(Z_AXIS))/axis_steps_per_unit[Z_AXIS]);
  835. SERIAL_PROTOCOLLN("");
  836. break;
  837. case 119: // M119
  838. #if (X_MIN_PIN > -1)
  839. SERIAL_PROTOCOLPGM("x_min:");
  840. SERIAL_PROTOCOL(((READ(X_MIN_PIN)^X_ENDSTOPS_INVERTING)?"H ":"L "));
  841. #endif
  842. #if (X_MAX_PIN > -1)
  843. SERIAL_PROTOCOLPGM("x_max:");
  844. SERIAL_PROTOCOL(((READ(X_MAX_PIN)^X_ENDSTOPS_INVERTING)?"H ":"L "));
  845. #endif
  846. #if (Y_MIN_PIN > -1)
  847. SERIAL_PROTOCOLPGM("y_min:");
  848. SERIAL_PROTOCOL(((READ(Y_MIN_PIN)^Y_ENDSTOPS_INVERTING)?"H ":"L "));
  849. #endif
  850. #if (Y_MAX_PIN > -1)
  851. SERIAL_PROTOCOLPGM("y_max:");
  852. SERIAL_PROTOCOL(((READ(Y_MAX_PIN)^Y_ENDSTOPS_INVERTING)?"H ":"L "));
  853. #endif
  854. #if (Z_MIN_PIN > -1)
  855. SERIAL_PROTOCOLPGM("z_min:");
  856. SERIAL_PROTOCOL(((READ(Z_MIN_PIN)^Z_ENDSTOPS_INVERTING)?"H ":"L "));
  857. #endif
  858. #if (Z_MAX_PIN > -1)
  859. SERIAL_PROTOCOLPGM("z_max:");
  860. SERIAL_PROTOCOL(((READ(Z_MAX_PIN)^Z_ENDSTOPS_INVERTING)?"H ":"L "));
  861. #endif
  862. SERIAL_PROTOCOLLN("");
  863. break;
  864. //TODO: update for all axis, use for loop
  865. case 201: // M201
  866. for(int8_t i=0; i < NUM_AXIS; i++)
  867. {
  868. if(code_seen(axis_codes[i])) axis_steps_per_sqr_second[i] = code_value() * axis_steps_per_unit[i];
  869. }
  870. break;
  871. #if 0 // Not used for Sprinter/grbl gen6
  872. case 202: // M202
  873. for(int8_t i=0; i < NUM_AXIS; i++) {
  874. if(code_seen(axis_codes[i])) axis_travel_steps_per_sqr_second[i] = code_value() * axis_steps_per_unit[i];
  875. }
  876. break;
  877. #endif
  878. case 203: // M203 max feedrate mm/sec
  879. for(int8_t i=0; i < NUM_AXIS; i++) {
  880. if(code_seen(axis_codes[i])) max_feedrate[i] = code_value();
  881. }
  882. break;
  883. case 204: // M204 acclereration S normal moves T filmanent only moves
  884. {
  885. if(code_seen('S')) acceleration = code_value() ;
  886. if(code_seen('T')) retract_acceleration = code_value() ;
  887. }
  888. break;
  889. 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
  890. {
  891. if(code_seen('S')) minimumfeedrate = code_value();
  892. if(code_seen('T')) mintravelfeedrate = code_value();
  893. if(code_seen('B')) minsegmenttime = code_value() ;
  894. if(code_seen('X')) max_xy_jerk = code_value() ;
  895. if(code_seen('Z')) max_z_jerk = code_value() ;
  896. }
  897. break;
  898. case 206: // M206 additional homeing offset
  899. for(int8_t i=0; i < 3; i++)
  900. {
  901. if(code_seen(axis_codes[i])) add_homeing[i] = code_value();
  902. }
  903. break;
  904. case 220: // M220 S<factor in percent>- set speed factor override percentage
  905. {
  906. if(code_seen('S'))
  907. {
  908. feedmultiply = code_value() ;
  909. feedmultiplychanged=true;
  910. }
  911. }
  912. break;
  913. #ifdef PIDTEMP
  914. case 301: // M301
  915. {
  916. if(code_seen('P')) Kp = code_value();
  917. if(code_seen('I')) Ki = code_value()*PID_dT;
  918. if(code_seen('D')) Kd = code_value()/PID_dT;
  919. #ifdef PID_ADD_EXTRUSION_RATE
  920. if(code_seen('C')) Kc = code_value();
  921. #endif
  922. updatePID();
  923. SERIAL_PROTOCOL("ok p:");
  924. SERIAL_PROTOCOL(Kp);
  925. SERIAL_PROTOCOL(" i:");
  926. SERIAL_PROTOCOL(Ki/PID_dT);
  927. SERIAL_PROTOCOL(" d:");
  928. SERIAL_PROTOCOL(Kd*PID_dT);
  929. #ifdef PID_ADD_EXTRUSION_RATE
  930. SERIAL_PROTOCOL(" c:");
  931. SERIAL_PROTOCOL(Kc*PID_dT);
  932. #endif
  933. SERIAL_PROTOCOLLN("");
  934. }
  935. break;
  936. #endif //PIDTEMP
  937. case 400: // finish all moves
  938. {
  939. st_synchronize();
  940. }
  941. break;
  942. case 500: // Store settings in EEPROM
  943. {
  944. StoreSettings();
  945. }
  946. break;
  947. case 501: // Read settings from EEPROM
  948. {
  949. RetrieveSettings();
  950. }
  951. break;
  952. case 502: // Revert to default settings
  953. {
  954. RetrieveSettings(true);
  955. }
  956. break;
  957. }
  958. }
  959. else if(code_seen('T')) {
  960. tmp_extruder = code_value();
  961. if(tmp_extruder >= EXTRUDERS) {
  962. SERIAL_ECHO_START;
  963. SERIAL_ECHO("T");
  964. SERIAL_ECHO(tmp_extruder);
  965. SERIAL_ECHOLN("Invalid extruder");
  966. }
  967. else {
  968. active_extruder = tmp_extruder;
  969. }
  970. }
  971. else
  972. {
  973. SERIAL_ECHO_START;
  974. SERIAL_ECHOPGM("Unknown command:\"");
  975. SERIAL_ECHO(cmdbuffer[bufindr]);
  976. SERIAL_ECHOLNPGM("\"");
  977. }
  978. ClearToSend();
  979. }
  980. void FlushSerialRequestResend()
  981. {
  982. //char cmdbuffer[bufindr][100]="Resend:";
  983. MSerial.flush();
  984. SERIAL_PROTOCOLPGM("Resend:");
  985. SERIAL_PROTOCOLLN(gcode_LastN + 1);
  986. ClearToSend();
  987. }
  988. void ClearToSend()
  989. {
  990. previous_millis_cmd = millis();
  991. #ifdef SDSUPPORT
  992. if(fromsd[bufindr])
  993. return;
  994. #endif //SDSUPPORT
  995. SERIAL_PROTOCOLLNPGM("ok");
  996. }
  997. FORCE_INLINE void get_coordinates()
  998. {
  999. for(int8_t i=0; i < NUM_AXIS; i++) {
  1000. if(code_seen(axis_codes[i])) destination[i] = (float)code_value() + (axis_relative_modes[i] || relative_mode)*current_position[i];
  1001. else destination[i] = current_position[i]; //Are these else lines really needed?
  1002. }
  1003. if(code_seen('F')) {
  1004. next_feedrate = code_value();
  1005. if(next_feedrate > 0.0) feedrate = next_feedrate;
  1006. }
  1007. }
  1008. FORCE_INLINE void get_arc_coordinates()
  1009. {
  1010. get_coordinates();
  1011. if(code_seen('I')) offset[0] = code_value();
  1012. if(code_seen('J')) offset[1] = code_value();
  1013. }
  1014. void prepare_move()
  1015. {
  1016. if (min_software_endstops) {
  1017. if (destination[X_AXIS] < 0) destination[X_AXIS] = 0.0;
  1018. if (destination[Y_AXIS] < 0) destination[Y_AXIS] = 0.0;
  1019. if (destination[Z_AXIS] < 0) destination[Z_AXIS] = 0.0;
  1020. }
  1021. if (max_software_endstops) {
  1022. if (destination[X_AXIS] > X_MAX_LENGTH) destination[X_AXIS] = X_MAX_LENGTH;
  1023. if (destination[Y_AXIS] > Y_MAX_LENGTH) destination[Y_AXIS] = Y_MAX_LENGTH;
  1024. if (destination[Z_AXIS] > Z_MAX_LENGTH) destination[Z_AXIS] = Z_MAX_LENGTH;
  1025. }
  1026. plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder);
  1027. for(int8_t i=0; i < NUM_AXIS; i++) {
  1028. current_position[i] = destination[i];
  1029. }
  1030. }
  1031. void prepare_arc_move(char isclockwise) {
  1032. float r = hypot(offset[X_AXIS], offset[Y_AXIS]); // Compute arc radius for mc_arc
  1033. // Trace the arc
  1034. mc_arc(current_position, destination, offset, X_AXIS, Y_AXIS, Z_AXIS, feedrate*feedmultiply/60/100.0, r, isclockwise, active_extruder);
  1035. // As far as the parser is concerned, the position is now == target. In reality the
  1036. // motion control system might still be processing the action and the real tool position
  1037. // in any intermediate location.
  1038. for(int8_t i=0; i < NUM_AXIS; i++) {
  1039. current_position[i] = destination[i];
  1040. }
  1041. }
  1042. void manage_inactivity(byte debug)
  1043. {
  1044. if( (millis()-previous_millis_cmd) > max_inactive_time )
  1045. if(max_inactive_time)
  1046. kill();
  1047. if( (millis()-previous_millis_cmd) > stepper_inactive_time )
  1048. if(stepper_inactive_time)
  1049. {
  1050. disable_x();
  1051. disable_y();
  1052. disable_z();
  1053. disable_e();
  1054. }
  1055. check_axes_activity();
  1056. }
  1057. void kill()
  1058. {
  1059. disable_heater();
  1060. disable_x();
  1061. disable_y();
  1062. disable_z();
  1063. disable_e();
  1064. if(PS_ON_PIN > -1) pinMode(PS_ON_PIN,INPUT);
  1065. SERIAL_ERROR_START;
  1066. SERIAL_ERRORLNPGM("Printer halted. kill() called !!");
  1067. LCD_MESSAGEPGM("KILLED. ");
  1068. while(1); // Wait for reset
  1069. }