My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

Marlin.pde 36KB

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