My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

Marlin.pde 36KB

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