mmu.cpp 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183
  1. //mmu.cpp
  2. #include "mmu.h"
  3. #include "planner.h"
  4. #include "language.h"
  5. #include "lcd.h"
  6. #include "uart2.h"
  7. #include "temperature.h"
  8. #include "Configuration_prusa.h"
  9. #include "fsensor.h"
  10. #include "cardreader.h"
  11. #include "ultralcd.h"
  12. #include "sound.h"
  13. #include "printers.h"
  14. #include <avr/pgmspace.h>
  15. #include "io_atmega2560.h"
  16. #ifdef TMC2130
  17. #include "tmc2130.h"
  18. #endif //TMC2130
  19. #define CHECK_FINDA ((IS_SD_PRINTING || is_usb_printing) && (mcode_in_progress != 600) && !saved_printing && e_active())
  20. #define MMU_TODELAY 100
  21. #define MMU_TIMEOUT 10
  22. #define MMU_CMD_TIMEOUT 300000ul //5min timeout for mmu commands (except P0)
  23. #define MMU_P0_TIMEOUT 3000ul //timeout for P0 command: 3seconds
  24. #ifdef MMU_HWRESET
  25. #define MMU_RST_PIN 76
  26. #endif //MMU_HWRESET
  27. bool mmu_enabled = false;
  28. bool mmu_ready = false;
  29. static int8_t mmu_state = 0;
  30. uint8_t mmu_cmd = 0;
  31. #ifdef MMU_IDLER_SENSOR_PIN
  32. uint8_t mmu_idl_sens = 0;
  33. #endif //MMU_IDLER_SENSOR_PIN
  34. uint8_t mmu_extruder = 0;
  35. //! This variable probably has no meaning and is planed to be removed
  36. uint8_t tmp_extruder = 0;
  37. int8_t mmu_finda = -1;
  38. int16_t mmu_version = -1;
  39. int16_t mmu_buildnr = -1;
  40. uint32_t mmu_last_request = 0;
  41. uint32_t mmu_last_response = 0;
  42. //clear rx buffer
  43. void mmu_clr_rx_buf(void)
  44. {
  45. while (fgetc(uart2io) >= 0);
  46. }
  47. //send command - puts
  48. int mmu_puts_P(const char* str)
  49. {
  50. mmu_clr_rx_buf(); //clear rx buffer
  51. int r = fputs_P(str, uart2io); //send command
  52. mmu_last_request = millis();
  53. return r;
  54. }
  55. //send command - printf
  56. int mmu_printf_P(const char* format, ...)
  57. {
  58. va_list args;
  59. va_start(args, format);
  60. mmu_clr_rx_buf(); //clear rx buffer
  61. int r = vfprintf_P(uart2io, format, args); //send command
  62. va_end(args);
  63. mmu_last_request = millis();
  64. return r;
  65. }
  66. //check 'ok' response
  67. int8_t mmu_rx_ok(void)
  68. {
  69. int8_t res = uart2_rx_str_P(PSTR("ok\n"));
  70. if (res == 1) mmu_last_response = millis();
  71. return res;
  72. }
  73. //check 'start' response
  74. int8_t mmu_rx_start(void)
  75. {
  76. int8_t res = uart2_rx_str_P(PSTR("start\n"));
  77. if (res == 1) mmu_last_response = millis();
  78. return res;
  79. }
  80. //initialize mmu2 unit - first part - should be done at begining of startup process
  81. void mmu_init(void)
  82. {
  83. #ifdef MMU_HWRESET
  84. digitalWrite(MMU_RST_PIN, HIGH);
  85. pinMode(MMU_RST_PIN, OUTPUT); //setup reset pin
  86. #endif //MMU_HWRESET
  87. uart2_init(); //init uart2
  88. _delay_ms(10); //wait 10ms for sure
  89. mmu_reset(); //reset mmu (HW or SW), do not wait for response
  90. mmu_state = -1;
  91. #ifdef MMU_IDLER_SENSOR_PIN
  92. PIN_INP(MMU_IDLER_SENSOR_PIN); //input mode
  93. PIN_SET(MMU_IDLER_SENSOR_PIN); //pullup
  94. #endif //MMU_IDLER_SENSOR_PIN
  95. }
  96. //mmu main loop - state machine processing
  97. void mmu_loop(void)
  98. {
  99. int filament = 0;
  100. // printf_P(PSTR("MMU loop, state=%d\n"), mmu_state);
  101. switch (mmu_state)
  102. {
  103. case 0:
  104. return;
  105. case -1:
  106. if (mmu_rx_start() > 0)
  107. {
  108. #ifdef MMU_DEBUG
  109. puts_P(PSTR("MMU => 'start'"));
  110. puts_P(PSTR("MMU <= 'S1'"));
  111. #endif //MMU_DEBUG
  112. mmu_puts_P(PSTR("S1\n")); //send 'read version' request
  113. mmu_state = -2;
  114. }
  115. else if (millis() > 30000) //30sec after reset disable mmu
  116. {
  117. puts_P(PSTR("MMU not responding - DISABLED"));
  118. mmu_state = 0;
  119. }
  120. return;
  121. case -2:
  122. if (mmu_rx_ok() > 0)
  123. {
  124. fscanf_P(uart2io, PSTR("%u"), &mmu_version); //scan version from buffer
  125. #ifdef MMU_DEBUG
  126. printf_P(PSTR("MMU => '%dok'\n"), mmu_version);
  127. puts_P(PSTR("MMU <= 'S2'"));
  128. #endif //MMU_DEBUG
  129. mmu_puts_P(PSTR("S2\n")); //send 'read buildnr' request
  130. mmu_state = -3;
  131. }
  132. return;
  133. case -3:
  134. if (mmu_rx_ok() > 0)
  135. {
  136. fscanf_P(uart2io, PSTR("%u"), &mmu_buildnr); //scan buildnr from buffer
  137. #ifdef MMU_DEBUG
  138. printf_P(PSTR("MMU => '%dok'\n"), mmu_buildnr);
  139. #endif //MMU_DEBUG
  140. bool version_valid = mmu_check_version();
  141. if (!version_valid) mmu_show_warning();
  142. else puts_P(PSTR("MMU version valid"));
  143. if ((PRINTER_TYPE == PRINTER_MK3) || (PRINTER_TYPE == PRINTER_MK3_SNMM))
  144. {
  145. #ifdef MMU_DEBUG
  146. puts_P(PSTR("MMU <= 'P0'"));
  147. #endif //MMU_DEBUG
  148. mmu_puts_P(PSTR("P0\n")); //send 'read finda' request
  149. mmu_state = -4;
  150. }
  151. else
  152. {
  153. #ifdef MMU_DEBUG
  154. puts_P(PSTR("MMU <= 'M1'"));
  155. #endif //MMU_DEBUG
  156. mmu_puts_P(PSTR("M1\n")); //set mmu mode to stealth
  157. mmu_state = -5;
  158. }
  159. }
  160. return;
  161. case -5:
  162. if (mmu_rx_ok() > 0)
  163. {
  164. #ifdef MMU_DEBUG
  165. puts_P(PSTR("MMU <= 'P0'"));
  166. #endif //MMU_DEBUG
  167. mmu_puts_P(PSTR("P0\n")); //send 'read finda' request
  168. mmu_state = -4;
  169. }
  170. return;
  171. case -4:
  172. if (mmu_rx_ok() > 0)
  173. {
  174. fscanf_P(uart2io, PSTR("%hhu"), &mmu_finda); //scan finda from buffer
  175. #ifdef MMU_DEBUG
  176. printf_P(PSTR("MMU => '%dok'\n"), mmu_finda);
  177. #endif //MMU_DEBUG
  178. puts_P(PSTR("MMU - ENABLED"));
  179. mmu_enabled = true;
  180. mmu_state = 1;
  181. }
  182. return;
  183. case 1:
  184. if (mmu_cmd) //command request ?
  185. {
  186. if ((mmu_cmd >= MMU_CMD_T0) && (mmu_cmd <= MMU_CMD_T4))
  187. {
  188. filament = mmu_cmd - MMU_CMD_T0;
  189. #ifdef MMU_DEBUG
  190. printf_P(PSTR("MMU <= 'T%d'\n"), filament);
  191. #endif //MMU_DEBUG
  192. mmu_printf_P(PSTR("T%d\n"), filament);
  193. mmu_state = 3; // wait for response
  194. #ifdef MMU_IDLER_SENSOR_PIN
  195. mmu_idl_sens = 1; //enable idler sensor
  196. #endif //MMU_IDLER_SENSOR_PIN
  197. }
  198. else if ((mmu_cmd >= MMU_CMD_L0) && (mmu_cmd <= MMU_CMD_L4))
  199. {
  200. filament = mmu_cmd - MMU_CMD_L0;
  201. #ifdef MMU_DEBUG
  202. printf_P(PSTR("MMU <= 'L%d'\n"), filament);
  203. #endif //MMU_DEBUG
  204. mmu_printf_P(PSTR("L%d\n"), filament);
  205. mmu_state = 3; // wait for response
  206. }
  207. else if (mmu_cmd == MMU_CMD_C0)
  208. {
  209. #ifdef MMU_DEBUG
  210. printf_P(PSTR("MMU <= 'C0'\n"));
  211. #endif //MMU_DEBUG
  212. mmu_puts_P(PSTR("C0\n")); //send 'continue loading'
  213. mmu_state = 3;
  214. #ifdef MMU_IDLER_SENSOR_PIN
  215. mmu_idl_sens = 1; //enable idler sensor
  216. #endif //MMU_IDLER_SENSOR_PIN
  217. }
  218. else if (mmu_cmd == MMU_CMD_U0)
  219. {
  220. #ifdef MMU_DEBUG
  221. printf_P(PSTR("MMU <= 'U0'\n"));
  222. #endif //MMU_DEBUG
  223. mmu_puts_P(PSTR("U0\n")); //send 'unload current filament'
  224. mmu_state = 3;
  225. }
  226. else if ((mmu_cmd >= MMU_CMD_E0) && (mmu_cmd <= MMU_CMD_E4))
  227. {
  228. int filament = mmu_cmd - MMU_CMD_E0;
  229. #ifdef MMU_DEBUG
  230. printf_P(PSTR("MMU <= 'E%d'\n"), filament);
  231. #endif //MMU_DEBUG
  232. mmu_printf_P(PSTR("E%d\n"), filament); //send eject filament
  233. mmu_state = 3; // wait for response
  234. }
  235. else if (mmu_cmd == MMU_CMD_R0)
  236. {
  237. #ifdef MMU_DEBUG
  238. printf_P(PSTR("MMU <= 'R0'\n"));
  239. #endif //MMU_DEBUG
  240. mmu_puts_P(PSTR("R0\n")); //send recover after eject
  241. mmu_state = 3; // wait for response
  242. }
  243. mmu_cmd = 0;
  244. }
  245. else if ((mmu_last_response + 300) < millis()) //request every 300ms
  246. {
  247. #ifdef MMU_DEBUG
  248. puts_P(PSTR("MMU <= 'P0'"));
  249. #endif //MMU_DEBUG
  250. mmu_puts_P(PSTR("P0\n")); //send 'read finda' request
  251. mmu_state = 2;
  252. }
  253. return;
  254. case 2: //response to command P0
  255. if (mmu_rx_ok() > 0)
  256. {
  257. fscanf_P(uart2io, PSTR("%hhu"), &mmu_finda); //scan finda from buffer
  258. #ifdef MMU_DEBUG
  259. printf_P(PSTR("MMU => '%dok'\n"), mmu_finda);
  260. #endif //MMU_DEBUG
  261. //printf_P(PSTR("Eact: %d\n"), int(e_active()));
  262. if (!mmu_finda && CHECK_FINDA && fsensor_enabled) {
  263. fsensor_stop_and_save_print();
  264. enquecommand_front_P(PSTR("FSENSOR_RECOVER")); //then recover
  265. if (lcd_autoDepleteEnabled()) enquecommand_front_P(PSTR("M600 AUTO")); //save print and run M600 command
  266. else enquecommand_front_P(PSTR("M600")); //save print and run M600 command
  267. }
  268. mmu_state = 1;
  269. if (mmu_cmd == 0)
  270. mmu_ready = true;
  271. }
  272. else if ((mmu_last_request + MMU_P0_TIMEOUT) < millis())
  273. { //resend request after timeout (30s)
  274. mmu_state = 1;
  275. }
  276. return;
  277. case 3: //response to mmu commands
  278. #ifdef MMU_IDLER_SENSOR_PIN
  279. if (mmu_idl_sens)
  280. {
  281. if (PIN_GET(MMU_IDLER_SENSOR_PIN) == 0)
  282. {
  283. #ifdef MMU_DEBUG
  284. printf_P(PSTR("MMU <= 'A'\n"), mmu_finda);
  285. #endif //MMU_DEBUG
  286. mmu_puts_P(PSTR("A\n")); //send 'abort' request
  287. mmu_idl_sens = 0;
  288. //printf_P(PSTR("MMU IDLER_SENSOR = 0 - ABORT\n"));
  289. }
  290. //else
  291. //printf_P(PSTR("MMU IDLER_SENSOR = 1 - WAIT\n"));
  292. }
  293. #endif //MMU_IDLER_SENSOR_PIN
  294. if (mmu_rx_ok() > 0)
  295. {
  296. #ifdef MMU_DEBUG
  297. printf_P(PSTR("MMU => 'ok'\n"));
  298. #endif //MMU_DEBUG
  299. mmu_ready = true;
  300. mmu_state = 1;
  301. }
  302. else if ((mmu_last_request + MMU_CMD_TIMEOUT) < millis())
  303. { //resend request after timeout (5 min)
  304. mmu_state = 1;
  305. }
  306. return;
  307. }
  308. }
  309. void mmu_reset(void)
  310. {
  311. #ifdef MMU_HWRESET //HW - pulse reset pin
  312. digitalWrite(MMU_RST_PIN, LOW);
  313. _delay_us(100);
  314. digitalWrite(MMU_RST_PIN, HIGH);
  315. #else //SW - send X0 command
  316. mmu_puts_P(PSTR("X0\n"));
  317. #endif
  318. }
  319. int8_t mmu_set_filament_type(uint8_t extruder, uint8_t filament)
  320. {
  321. printf_P(PSTR("MMU <= 'F%d %d'\n"), extruder, filament);
  322. mmu_printf_P(PSTR("F%d %d\n"), extruder, filament);
  323. unsigned char timeout = MMU_TIMEOUT; //10x100ms
  324. while ((mmu_rx_ok() <= 0) && (--timeout))
  325. delay_keep_alive(MMU_TODELAY);
  326. return timeout?1:0;
  327. }
  328. void mmu_command(uint8_t cmd)
  329. {
  330. #ifdef TMC2130
  331. if ((cmd >= MMU_CMD_T0) && (cmd <= MMU_CMD_T4))
  332. {
  333. //disable extruder motor
  334. tmc2130_set_pwr(E_AXIS, 0);
  335. //printf_P(PSTR("E-axis disabled\n"));
  336. }
  337. #endif //TMC2130
  338. mmu_cmd = cmd;
  339. mmu_ready = false;
  340. }
  341. bool mmu_get_response(void)
  342. {
  343. // printf_P(PSTR("mmu_get_response - begin\n"));
  344. KEEPALIVE_STATE(IN_PROCESS);
  345. while (mmu_cmd != 0)
  346. {
  347. // mmu_loop();
  348. delay_keep_alive(100);
  349. }
  350. while (!mmu_ready)
  351. {
  352. // mmu_loop();
  353. if (mmu_state != 3)
  354. break;
  355. delay_keep_alive(100);
  356. }
  357. bool ret = mmu_ready;
  358. mmu_ready = false;
  359. // printf_P(PSTR("mmu_get_response - end %d\n"), ret?1:0);
  360. return ret;
  361. /* //waits for "ok" from mmu
  362. //function returns true if "ok" was received
  363. //if timeout is set to true function return false if there is no "ok" received before timeout
  364. bool response = true;
  365. LongTimer mmu_get_reponse_timeout;
  366. KEEPALIVE_STATE(IN_PROCESS);
  367. mmu_get_reponse_timeout.start();
  368. while (mmu_rx_ok() <= 0)
  369. {
  370. delay_keep_alive(100);
  371. if (timeout && mmu_get_reponse_timeout.expired(5 * 60 * 1000ul))
  372. { //5 minutes timeout
  373. response = false;
  374. break;
  375. }
  376. }
  377. printf_P(PSTR("mmu_get_response - end %d\n"), response?1:0);
  378. return response;*/
  379. }
  380. void manage_response(bool move_axes, bool turn_off_nozzle)
  381. {
  382. bool response = false;
  383. mmu_print_saved = false;
  384. bool lcd_update_was_enabled = false;
  385. float hotend_temp_bckp = degTargetHotend(active_extruder);
  386. float z_position_bckp = current_position[Z_AXIS];
  387. float x_position_bckp = current_position[X_AXIS];
  388. float y_position_bckp = current_position[Y_AXIS];
  389. uint8_t screen = 0; //used for showing multiscreen messages
  390. while(!response)
  391. {
  392. response = mmu_get_response(); //wait for "ok" from mmu
  393. if (!response) { //no "ok" was received in reserved time frame, user will fix the issue on mmu unit
  394. if (!mmu_print_saved) { //first occurence, we are saving current position, park print head in certain position and disable nozzle heater
  395. if (lcd_update_enabled) {
  396. lcd_update_was_enabled = true;
  397. lcd_update_enable(false);
  398. }
  399. st_synchronize();
  400. mmu_print_saved = true;
  401. printf_P(PSTR("MMU not responding\n"));
  402. hotend_temp_bckp = degTargetHotend(active_extruder);
  403. if (move_axes) {
  404. z_position_bckp = current_position[Z_AXIS];
  405. x_position_bckp = current_position[X_AXIS];
  406. y_position_bckp = current_position[Y_AXIS];
  407. //lift z
  408. current_position[Z_AXIS] += Z_PAUSE_LIFT;
  409. if (current_position[Z_AXIS] > Z_MAX_POS) current_position[Z_AXIS] = Z_MAX_POS;
  410. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 15, active_extruder);
  411. st_synchronize();
  412. //Move XY to side
  413. current_position[X_AXIS] = X_PAUSE_POS;
  414. current_position[Y_AXIS] = Y_PAUSE_POS;
  415. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 50, active_extruder);
  416. st_synchronize();
  417. }
  418. if (turn_off_nozzle) {
  419. //set nozzle target temperature to 0
  420. setAllTargetHotends(0);
  421. }
  422. }
  423. //first three lines are used for printing multiscreen message; last line contains measured and target nozzle temperature
  424. if (screen == 0) { //screen 0
  425. lcd_display_message_fullscreen_P(_i("MMU needs user attention."));
  426. screen++;
  427. }
  428. else { //screen 1
  429. if((degTargetHotend(active_extruder) == 0) && turn_off_nozzle) lcd_display_message_fullscreen_P(_i("Press the knob to resume nozzle temperature."));
  430. else lcd_display_message_fullscreen_P(_i("Fix the issue and then press button on MMU unit."));
  431. screen=0;
  432. }
  433. lcd_set_degree();
  434. lcd_set_cursor(0, 4); //line 4
  435. //Print the hotend temperature (9 chars total) and fill rest of the line with space
  436. int chars = lcd_printf_P(_N("%c%3d/%d%c"), LCD_STR_THERMOMETER[0],(int)(degHotend(active_extruder) + 0.5), (int)(degTargetHotend(active_extruder) + 0.5), LCD_STR_DEGREE[0]);
  437. lcd_space(9 - chars);
  438. //5 seconds delay
  439. for (uint8_t i = 0; i < 50; i++) {
  440. if (lcd_clicked()) {
  441. setTargetHotend(hotend_temp_bckp, active_extruder);
  442. break;
  443. }
  444. delay_keep_alive(100);
  445. }
  446. }
  447. else if (mmu_print_saved) {
  448. printf_P(PSTR("MMU starts responding\n"));
  449. if (turn_off_nozzle)
  450. {
  451. lcd_clear();
  452. setTargetHotend(hotend_temp_bckp, active_extruder);
  453. if (((degTargetHotend(active_extruder) - degHotend(active_extruder)) > 5)) {
  454. lcd_display_message_fullscreen_P(_i("MMU OK. Resuming temperature..."));
  455. delay_keep_alive(3000);
  456. }
  457. while ((degTargetHotend(active_extruder) - degHotend(active_extruder)) > 5)
  458. {
  459. delay_keep_alive(1000);
  460. lcd_wait_for_heater();
  461. }
  462. }
  463. if (move_axes) {
  464. lcd_clear();
  465. lcd_display_message_fullscreen_P(_i("MMU OK. Resuming position..."));
  466. current_position[X_AXIS] = x_position_bckp;
  467. current_position[Y_AXIS] = y_position_bckp;
  468. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 50, active_extruder);
  469. st_synchronize();
  470. current_position[Z_AXIS] = z_position_bckp;
  471. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 15, active_extruder);
  472. st_synchronize();
  473. }
  474. else {
  475. lcd_clear();
  476. lcd_display_message_fullscreen_P(_i("MMU OK. Resuming..."));
  477. delay_keep_alive(1000); //delay just for showing MMU OK message for a while in case that there are no xyz movements
  478. }
  479. }
  480. }
  481. if (lcd_update_was_enabled) lcd_update_enable(true);
  482. #ifdef TMC2130
  483. //enable extruder motor (disabled in mmu_command, start of T-code processing)
  484. tmc2130_set_pwr(E_AXIS, 1);
  485. //printf_P(PSTR("E-axis enabled\n"));
  486. #endif //TMC2130
  487. }
  488. //! @brief load filament to nozzle of multimaterial printer
  489. //!
  490. //! This function is used only only after T? (user select filament) and M600 (change filament).
  491. //! It is not used after T0 .. T4 command (select filament), in such case, gcode is responsible for loading
  492. //! filament to nozzle.
  493. //!
  494. void mmu_load_to_nozzle()
  495. {
  496. st_synchronize();
  497. bool saved_e_relative_mode = axis_relative_modes[E_AXIS];
  498. if (!saved_e_relative_mode) axis_relative_modes[E_AXIS] = true;
  499. current_position[E_AXIS] += 7.2f;
  500. float feedrate = 562;
  501. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate / 60, active_extruder);
  502. st_synchronize();
  503. current_position[E_AXIS] += 14.4f;
  504. feedrate = 871;
  505. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate / 60, active_extruder);
  506. st_synchronize();
  507. current_position[E_AXIS] += 36.0f;
  508. feedrate = 1393;
  509. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate / 60, active_extruder);
  510. st_synchronize();
  511. current_position[E_AXIS] += 14.4f;
  512. feedrate = 871;
  513. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate / 60, active_extruder);
  514. st_synchronize();
  515. if (!saved_e_relative_mode) axis_relative_modes[E_AXIS] = false;
  516. }
  517. void mmu_M600_wait_and_beep() {
  518. //Beep and wait for user to remove old filament and prepare new filament for load
  519. KEEPALIVE_STATE(PAUSED_FOR_USER);
  520. int counterBeep = 0;
  521. lcd_display_message_fullscreen_P(_i("Remove old filament and press the knob to start loading new filament."));
  522. bool bFirst=true;
  523. while (!lcd_clicked()){
  524. manage_heater();
  525. manage_inactivity(true);
  526. #if BEEPER > 0
  527. if (counterBeep == 500) {
  528. counterBeep = 0;
  529. }
  530. SET_OUTPUT(BEEPER);
  531. if (counterBeep == 0) {
  532. if((eSoundMode==e_SOUND_MODE_LOUD)||((eSoundMode==e_SOUND_MODE_ONCE)&&bFirst))
  533. {
  534. bFirst=false;
  535. WRITE(BEEPER, HIGH);
  536. }
  537. }
  538. if (counterBeep == 20) {
  539. WRITE(BEEPER, LOW);
  540. }
  541. counterBeep++;
  542. #endif //BEEPER > 0
  543. delay_keep_alive(4);
  544. }
  545. WRITE(BEEPER, LOW);
  546. }
  547. void mmu_M600_load_filament(bool automatic)
  548. {
  549. //load filament for mmu v2
  550. tmp_extruder = mmu_extruder;
  551. if (!automatic) {
  552. #ifdef MMU_M600_SWITCH_EXTRUDER
  553. bool yes = lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Do you want to switch extruder?"), false);
  554. if(yes) tmp_extruder = choose_extruder_menu();
  555. #endif //MMU_M600_SWITCH_EXTRUDER
  556. }
  557. else {
  558. tmp_extruder = (tmp_extruder+1)%5;
  559. }
  560. lcd_update_enable(false);
  561. lcd_clear();
  562. lcd_set_cursor(0, 1); lcd_puts_P(_T(MSG_LOADING_FILAMENT));
  563. lcd_print(" ");
  564. lcd_print(tmp_extruder + 1);
  565. snmm_filaments_used |= (1 << tmp_extruder); //for stop print
  566. // printf_P(PSTR("T code: %d \n"), tmp_extruder);
  567. // mmu_printf_P(PSTR("T%d\n"), tmp_extruder);
  568. mmu_command(MMU_CMD_T0 + tmp_extruder);
  569. manage_response(false, true);
  570. mmu_command(MMU_CMD_C0);
  571. mmu_extruder = tmp_extruder; //filament change is finished
  572. mmu_load_to_nozzle();
  573. load_filament_final_feed();
  574. st_synchronize();
  575. }
  576. #ifdef SNMM
  577. void extr_mov(float shift, float feed_rate)
  578. { //move extruder no matter what the current heater temperature is
  579. set_extrude_min_temp(.0);
  580. current_position[E_AXIS] += shift;
  581. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feed_rate, active_extruder);
  582. set_extrude_min_temp(EXTRUDE_MINTEMP);
  583. }
  584. #endif //SNMM
  585. void change_extr(int
  586. #ifdef SNMM
  587. extr
  588. #endif //SNMM
  589. ) { //switches multiplexer for extruders
  590. #ifdef SNMM
  591. st_synchronize();
  592. delay(100);
  593. disable_e0();
  594. disable_e1();
  595. disable_e2();
  596. mmu_extruder = extr;
  597. pinMode(E_MUX0_PIN, OUTPUT);
  598. pinMode(E_MUX1_PIN, OUTPUT);
  599. switch (extr) {
  600. case 1:
  601. WRITE(E_MUX0_PIN, HIGH);
  602. WRITE(E_MUX1_PIN, LOW);
  603. break;
  604. case 2:
  605. WRITE(E_MUX0_PIN, LOW);
  606. WRITE(E_MUX1_PIN, HIGH);
  607. break;
  608. case 3:
  609. WRITE(E_MUX0_PIN, HIGH);
  610. WRITE(E_MUX1_PIN, HIGH);
  611. break;
  612. default:
  613. WRITE(E_MUX0_PIN, LOW);
  614. WRITE(E_MUX1_PIN, LOW);
  615. break;
  616. }
  617. delay(100);
  618. #endif
  619. }
  620. int get_ext_nr()
  621. { //reads multiplexer input pins and return current extruder number (counted from 0)
  622. #ifndef SNMM
  623. return(mmu_extruder); //update needed
  624. #else
  625. return(2 * READ(E_MUX1_PIN) + READ(E_MUX0_PIN));
  626. #endif
  627. }
  628. void display_loading()
  629. {
  630. switch (mmu_extruder)
  631. {
  632. case 1: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T1)); break;
  633. case 2: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T2)); break;
  634. case 3: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T3)); break;
  635. default: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T0)); break;
  636. }
  637. }
  638. void extr_adj(int extruder) //loading filament for SNMM
  639. {
  640. #ifndef SNMM
  641. uint8_t cmd = MMU_CMD_L0 + extruder;
  642. if (cmd > MMU_CMD_L4)
  643. {
  644. printf_P(PSTR("Filament out of range %d \n"),extruder);
  645. return;
  646. }
  647. mmu_command(cmd);
  648. //show which filament is currently loaded
  649. lcd_update_enable(false);
  650. lcd_clear();
  651. lcd_set_cursor(0, 1); lcd_puts_P(_T(MSG_LOADING_FILAMENT));
  652. //if(strlen(_T(MSG_LOADING_FILAMENT))>18) lcd.setCursor(0, 1);
  653. //else lcd.print(" ");
  654. lcd_print(" ");
  655. lcd_print(extruder + 1);
  656. // get response
  657. manage_response(false, false);
  658. lcd_update_enable(true);
  659. //lcd_return_to_status();
  660. #else
  661. bool correct;
  662. max_feedrate[E_AXIS] =80;
  663. //max_feedrate[E_AXIS] = 50;
  664. START:
  665. lcd_clear();
  666. lcd_set_cursor(0, 0);
  667. switch (extruder) {
  668. case 1: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T1)); break;
  669. case 2: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T2)); break;
  670. case 3: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T3)); break;
  671. default: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T0)); break;
  672. }
  673. KEEPALIVE_STATE(PAUSED_FOR_USER);
  674. do{
  675. extr_mov(0.001,1000);
  676. delay_keep_alive(2);
  677. } while (!lcd_clicked());
  678. //delay_keep_alive(500);
  679. KEEPALIVE_STATE(IN_HANDLER);
  680. st_synchronize();
  681. //correct = lcd_show_fullscreen_message_yes_no_and_wait_P(MSG_FIL_LOADED_CHECK, false);
  682. //if (!correct) goto START;
  683. //extr_mov(BOWDEN_LENGTH/2.f, 500); //dividing by 2 is there because of max. extrusion length limitation (x_max + y_max)
  684. //extr_mov(BOWDEN_LENGTH/2.f, 500);
  685. extr_mov(bowden_length[extruder], 500);
  686. lcd_clear();
  687. lcd_set_cursor(0, 0); lcd_puts_P(_T(MSG_LOADING_FILAMENT));
  688. if(strlen(_T(MSG_LOADING_FILAMENT))>18) lcd_set_cursor(0, 1);
  689. else lcd_print(" ");
  690. lcd_print(mmu_extruder + 1);
  691. lcd_set_cursor(0, 2); lcd_puts_P(_T(MSG_PLEASE_WAIT));
  692. st_synchronize();
  693. max_feedrate[E_AXIS] = 50;
  694. lcd_update_enable(true);
  695. lcd_return_to_status();
  696. lcdDrawUpdate = 2;
  697. #endif
  698. }
  699. struct E_step
  700. {
  701. float extrude; //!< extrude distance in mm
  702. float feed_rate; //!< feed rate in mm/s
  703. };
  704. static const E_step ramming_sequence[] PROGMEM =
  705. {
  706. {1.0, 1000.0/60},
  707. {1.0, 1500.0/60},
  708. {2.0, 2000.0/60},
  709. {1.5, 3000.0/60},
  710. {2.5, 4000.0/60},
  711. {-15.0, 5000.0/60},
  712. {-14.0, 1200.0/60},
  713. {-6.0, 600.0/60},
  714. {10.0, 700.0/60},
  715. {-10.0, 400.0/60},
  716. {-50.0, 2000.0/60},
  717. };
  718. //! @brief Unload sequence to optimize shape of the tip of the unloaded filament
  719. static void filament_ramming()
  720. {
  721. for(uint8_t i = 0; i < (sizeof(ramming_sequence)/sizeof(E_step));++i)
  722. {
  723. current_position[E_AXIS] += pgm_read_float(&(ramming_sequence[i].extrude));
  724. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS],
  725. current_position[E_AXIS], pgm_read_float(&(ramming_sequence[i].feed_rate)), active_extruder);
  726. st_synchronize();
  727. }
  728. }
  729. void extr_unload()
  730. { //unload just current filament for multimaterial printers
  731. #ifdef SNMM
  732. float tmp_motor[3] = DEFAULT_PWM_MOTOR_CURRENT;
  733. float tmp_motor_loud[3] = DEFAULT_PWM_MOTOR_CURRENT_LOUD;
  734. uint8_t SilentMode = eeprom_read_byte((uint8_t*)EEPROM_SILENT);
  735. #endif
  736. if (degHotend0() > EXTRUDE_MINTEMP)
  737. {
  738. #ifndef SNMM
  739. st_synchronize();
  740. //show which filament is currently unloaded
  741. lcd_update_enable(false);
  742. lcd_clear();
  743. lcd_set_cursor(0, 1); lcd_puts_P(_T(MSG_UNLOADING_FILAMENT));
  744. lcd_print(" ");
  745. lcd_print(mmu_extruder + 1);
  746. filament_ramming();
  747. mmu_command(MMU_CMD_U0);
  748. // get response
  749. manage_response(false, true);
  750. lcd_update_enable(true);
  751. #else //SNMM
  752. lcd_clear();
  753. lcd_display_message_fullscreen_P(PSTR(""));
  754. max_feedrate[E_AXIS] = 50;
  755. lcd_set_cursor(0, 0); lcd_puts_P(_T(MSG_UNLOADING_FILAMENT));
  756. lcd_print(" ");
  757. lcd_print(mmu_extruder + 1);
  758. lcd_set_cursor(0, 2); lcd_puts_P(_T(MSG_PLEASE_WAIT));
  759. if (current_position[Z_AXIS] < 15) {
  760. current_position[Z_AXIS] += 15; //lifting in Z direction to make space for extrusion
  761. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 25, active_extruder);
  762. }
  763. current_position[E_AXIS] += 10; //extrusion
  764. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 10, active_extruder);
  765. st_current_set(2, E_MOTOR_HIGH_CURRENT);
  766. if (current_temperature[0] < 230) { //PLA & all other filaments
  767. current_position[E_AXIS] += 5.4;
  768. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2800 / 60, active_extruder);
  769. current_position[E_AXIS] += 3.2;
  770. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
  771. current_position[E_AXIS] += 3;
  772. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3400 / 60, active_extruder);
  773. }
  774. else { //ABS
  775. current_position[E_AXIS] += 3.1;
  776. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2000 / 60, active_extruder);
  777. current_position[E_AXIS] += 3.1;
  778. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2500 / 60, active_extruder);
  779. current_position[E_AXIS] += 4;
  780. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
  781. /*current_position[X_AXIS] += 23; //delay
  782. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 600 / 60, active_extruder); //delay
  783. current_position[X_AXIS] -= 23; //delay
  784. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 600 / 60, active_extruder); //delay*/
  785. delay_keep_alive(4700);
  786. }
  787. max_feedrate[E_AXIS] = 80;
  788. current_position[E_AXIS] -= (bowden_length[mmu_extruder] + 60 + FIL_LOAD_LENGTH) / 2;
  789. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 500, active_extruder);
  790. current_position[E_AXIS] -= (bowden_length[mmu_extruder] + 60 + FIL_LOAD_LENGTH) / 2;
  791. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 500, active_extruder);
  792. st_synchronize();
  793. //st_current_init();
  794. if (SilentMode != SILENT_MODE_OFF) st_current_set(2, tmp_motor[2]); //set back to normal operation currents
  795. else st_current_set(2, tmp_motor_loud[2]);
  796. lcd_update_enable(true);
  797. lcd_return_to_status();
  798. max_feedrate[E_AXIS] = 50;
  799. #endif //SNMM
  800. }
  801. else
  802. {
  803. show_preheat_nozzle_warning();
  804. }
  805. //lcd_return_to_status();
  806. }
  807. //wrapper functions for loading filament
  808. void extr_adj_0()
  809. {
  810. #ifndef SNMM
  811. enquecommand_P(PSTR("M701 E0"));
  812. #else
  813. change_extr(0);
  814. extr_adj(0);
  815. #endif
  816. }
  817. void extr_adj_1()
  818. {
  819. #ifndef SNMM
  820. enquecommand_P(PSTR("M701 E1"));
  821. #else
  822. change_extr(1);
  823. extr_adj(1);
  824. #endif
  825. }
  826. void extr_adj_2()
  827. {
  828. #ifndef SNMM
  829. enquecommand_P(PSTR("M701 E2"));
  830. #else
  831. change_extr(2);
  832. extr_adj(2);
  833. #endif
  834. }
  835. void extr_adj_3()
  836. {
  837. #ifndef SNMM
  838. enquecommand_P(PSTR("M701 E3"));
  839. #else
  840. change_extr(3);
  841. extr_adj(3);
  842. #endif
  843. }
  844. void extr_adj_4()
  845. {
  846. #ifndef SNMM
  847. enquecommand_P(PSTR("M701 E4"));
  848. #else
  849. change_extr(4);
  850. extr_adj(4);
  851. #endif
  852. }
  853. void mmu_load_to_nozzle_0()
  854. {
  855. lcd_mmu_load_to_nozzle(0);
  856. }
  857. void mmu_load_to_nozzle_1()
  858. {
  859. lcd_mmu_load_to_nozzle(1);
  860. }
  861. void mmu_load_to_nozzle_2()
  862. {
  863. lcd_mmu_load_to_nozzle(2);
  864. }
  865. void mmu_load_to_nozzle_3()
  866. {
  867. lcd_mmu_load_to_nozzle(3);
  868. }
  869. void mmu_load_to_nozzle_4()
  870. {
  871. lcd_mmu_load_to_nozzle(4);
  872. }
  873. void mmu_eject_fil_0()
  874. {
  875. mmu_eject_filament(0, true);
  876. }
  877. void mmu_eject_fil_1()
  878. {
  879. mmu_eject_filament(1, true);
  880. }
  881. void mmu_eject_fil_2()
  882. {
  883. mmu_eject_filament(2, true);
  884. }
  885. void mmu_eject_fil_3()
  886. {
  887. mmu_eject_filament(3, true);
  888. }
  889. void mmu_eject_fil_4()
  890. {
  891. mmu_eject_filament(4, true);
  892. }
  893. void load_all()
  894. {
  895. #ifndef SNMM
  896. enquecommand_P(PSTR("M701 E0"));
  897. enquecommand_P(PSTR("M701 E1"));
  898. enquecommand_P(PSTR("M701 E2"));
  899. enquecommand_P(PSTR("M701 E3"));
  900. enquecommand_P(PSTR("M701 E4"));
  901. #else
  902. for (int i = 0; i < 4; i++)
  903. {
  904. change_extr(i);
  905. extr_adj(i);
  906. }
  907. #endif
  908. }
  909. //wrapper functions for changing extruders
  910. void extr_change_0()
  911. {
  912. change_extr(0);
  913. lcd_return_to_status();
  914. }
  915. void extr_change_1()
  916. {
  917. change_extr(1);
  918. lcd_return_to_status();
  919. }
  920. void extr_change_2()
  921. {
  922. change_extr(2);
  923. lcd_return_to_status();
  924. }
  925. void extr_change_3()
  926. {
  927. change_extr(3);
  928. lcd_return_to_status();
  929. }
  930. #ifdef SNMM
  931. //wrapper functions for unloading filament
  932. void extr_unload_all()
  933. {
  934. if (degHotend0() > EXTRUDE_MINTEMP)
  935. {
  936. for (int i = 0; i < 4; i++)
  937. {
  938. change_extr(i);
  939. extr_unload();
  940. }
  941. }
  942. else
  943. {
  944. show_preheat_nozzle_warning();
  945. lcd_return_to_status();
  946. }
  947. }
  948. //unloading just used filament (for snmm)
  949. void extr_unload_used()
  950. {
  951. if (degHotend0() > EXTRUDE_MINTEMP) {
  952. for (int i = 0; i < 4; i++) {
  953. if (snmm_filaments_used & (1 << i)) {
  954. change_extr(i);
  955. extr_unload();
  956. }
  957. }
  958. snmm_filaments_used = 0;
  959. }
  960. else {
  961. show_preheat_nozzle_warning();
  962. lcd_return_to_status();
  963. }
  964. }
  965. #endif //SNMM
  966. void extr_unload_0()
  967. {
  968. change_extr(0);
  969. extr_unload();
  970. }
  971. void extr_unload_1()
  972. {
  973. change_extr(1);
  974. extr_unload();
  975. }
  976. void extr_unload_2()
  977. {
  978. change_extr(2);
  979. extr_unload();
  980. }
  981. void extr_unload_3()
  982. {
  983. change_extr(3);
  984. extr_unload();
  985. }
  986. void extr_unload_4()
  987. {
  988. change_extr(4);
  989. extr_unload();
  990. }
  991. bool mmu_check_version()
  992. {
  993. return (mmu_buildnr >= MMU_REQUIRED_FW_BUILDNR);
  994. }
  995. void mmu_show_warning()
  996. {
  997. printf_P(PSTR("MMU2 firmware version invalid. Required version: build number %d or higher."), MMU_REQUIRED_FW_BUILDNR);
  998. kill(_i("Please update firmware in your MMU2. Waiting for reset."));
  999. }
  1000. void lcd_mmu_load_to_nozzle(uint8_t filament_nr)
  1001. {
  1002. if (degHotend0() > EXTRUDE_MINTEMP)
  1003. {
  1004. tmp_extruder = filament_nr;
  1005. lcd_update_enable(false);
  1006. lcd_clear();
  1007. lcd_set_cursor(0, 1); lcd_puts_P(_T(MSG_LOADING_FILAMENT));
  1008. lcd_print(" ");
  1009. lcd_print(tmp_extruder + 1);
  1010. mmu_command(MMU_CMD_T0 + tmp_extruder);
  1011. manage_response(true, true);
  1012. mmu_command(MMU_CMD_C0);
  1013. mmu_extruder = tmp_extruder; //filament change is finished
  1014. mmu_load_to_nozzle();
  1015. load_filament_final_feed();
  1016. st_synchronize();
  1017. custom_message_type = CUSTOM_MSG_TYPE_F_LOAD;
  1018. lcd_setstatuspgm(_T(MSG_LOADING_FILAMENT));
  1019. lcd_return_to_status();
  1020. lcd_update_enable(true);
  1021. lcd_load_filament_color_check();
  1022. lcd_setstatuspgm(_T(WELCOME_MSG));
  1023. custom_message_type = CUSTOM_MSG_TYPE_STATUS;
  1024. }
  1025. else
  1026. {
  1027. show_preheat_nozzle_warning();
  1028. }
  1029. }
  1030. void mmu_eject_filament(uint8_t filament, bool recover)
  1031. {
  1032. if (filament < 5)
  1033. {
  1034. if (degHotend0() > EXTRUDE_MINTEMP)
  1035. {
  1036. st_synchronize();
  1037. {
  1038. LcdUpdateDisabler disableLcdUpdate;
  1039. lcd_clear();
  1040. lcd_set_cursor(0, 1); lcd_puts_P(_i("Ejecting filament"));
  1041. current_position[E_AXIS] -= 80;
  1042. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2500 / 60, active_extruder);
  1043. st_synchronize();
  1044. mmu_command(MMU_CMD_E0 + filament);
  1045. manage_response(false, false);
  1046. if (recover)
  1047. {
  1048. lcd_show_fullscreen_message_and_wait_P(_i("Please remove filament and then press the knob."));
  1049. mmu_command(MMU_CMD_R0);
  1050. manage_response(false, false);
  1051. }
  1052. }
  1053. }
  1054. else
  1055. {
  1056. show_preheat_nozzle_warning();
  1057. }
  1058. }
  1059. else
  1060. {
  1061. puts_P(PSTR("Filament nr out of range!"));
  1062. }
  1063. }