mmu.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  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. extern const char* lcd_display_message_fullscreen_P(const char *msg);
  10. extern void lcd_show_fullscreen_message_and_wait_P(const char *msg);
  11. extern int8_t lcd_show_fullscreen_message_yes_no_and_wait_P(const char *msg, bool allow_timeouting = true, bool default_yes = false);
  12. extern void lcd_return_to_status();
  13. extern void lcd_wait_for_heater();
  14. extern char choose_extruder_menu();
  15. #define MMU_TODELAY 100
  16. #define MMU_TIMEOUT 10
  17. #define MMU_HWRESET
  18. #define MMU_RST_PIN 76
  19. bool mmu_enabled = false;
  20. uint8_t mmu_extruder = 0;
  21. uint8_t tmp_extruder = 0;
  22. int8_t mmu_finda = -1;
  23. int16_t mmu_version = -1;
  24. int16_t mmu_build = -1;
  25. //clear rx buffer
  26. void mmu_clr_rx_buf(void)
  27. {
  28. while (fgetc(uart2io) >= 0);
  29. }
  30. //send command - puts
  31. int mmu_puts_P(const char* str)
  32. {
  33. mmu_clr_rx_buf(); //clear rx buffer
  34. return fputs_P(str, uart2io); //send command
  35. }
  36. //send command - printf
  37. int mmu_printf_P(const char* format, ...)
  38. {
  39. va_list args;
  40. va_start(args, format);
  41. mmu_clr_rx_buf(); //clear rx buffer
  42. int r = vfprintf_P(uart2io, format, args); //send command
  43. va_end(args);
  44. return r;
  45. }
  46. //check 'ok' response
  47. int8_t mmu_rx_ok(void)
  48. {
  49. return uart2_rx_str_P(PSTR("ok\n"));
  50. }
  51. //check 'start' response
  52. int8_t mmu_rx_start(void)
  53. {
  54. return uart2_rx_str_P(PSTR("start\n"));
  55. }
  56. //initialize mmu_unit
  57. bool mmu_init(void)
  58. {
  59. digitalWrite(MMU_RST_PIN, HIGH);
  60. pinMode(MMU_RST_PIN, OUTPUT); //setup reset pin
  61. uart2_init(); //init uart2
  62. _delay_ms(10); //wait 10ms for sure
  63. if (mmu_reset()) //reset mmu
  64. {
  65. mmu_read_finda();
  66. mmu_read_version();
  67. return true;
  68. }
  69. return false;
  70. }
  71. bool mmu_reset(void)
  72. {
  73. #ifdef MMU_HWRESET
  74. digitalWrite(MMU_RST_PIN, LOW);
  75. _delay_us(100);
  76. digitalWrite(MMU_RST_PIN, HIGH);
  77. #else
  78. mmu_puts_P(PSTR("X0\n")); //send command
  79. #endif
  80. unsigned char timeout = MMU_TIMEOUT; //timeout = 10x100ms
  81. while ((mmu_rx_start() <= 0) && (--timeout))
  82. delay_keep_alive(MMU_TODELAY);
  83. mmu_enabled = timeout?true:false;
  84. mmu_enabled = true;
  85. return mmu_enabled;
  86. }
  87. int8_t mmu_read_finda(void)
  88. {
  89. mmu_puts_P(PSTR("P0\n"));
  90. unsigned char timeout = MMU_TIMEOUT; //10x100ms
  91. while ((mmu_rx_ok() <= 0) && (--timeout))
  92. delay_keep_alive(MMU_TODELAY);
  93. mmu_finda = -1;
  94. if (timeout)
  95. fscanf_P(uart2io, PSTR("%hhu"), &mmu_finda);
  96. return mmu_finda;
  97. }
  98. int16_t mmu_read_version(void)
  99. {
  100. mmu_puts_P(PSTR("S1\n"));
  101. unsigned char timeout = MMU_TIMEOUT; //10x100ms
  102. while ((mmu_rx_ok() <= 0) && (--timeout))
  103. delay_keep_alive(MMU_TODELAY);
  104. if (timeout)
  105. fscanf_P(uart2io, PSTR("%u"), &mmu_version);
  106. return mmu_version;
  107. }
  108. int8_t mmu_set_filament_type(uint8_t extruder, uint8_t filament)
  109. {
  110. printf_P(PSTR("MMU <= 'F%d %d'\n"), extruder, filament);
  111. mmu_printf_P(PSTR("F%d %d\n"), extruder, filament);
  112. unsigned char timeout = MMU_TIMEOUT; //10x100ms
  113. while ((mmu_rx_ok() <= 0) && (--timeout))
  114. delay_keep_alive(MMU_TODELAY);
  115. return timeout?1:0;
  116. }
  117. bool mmu_get_response(bool timeout)
  118. {
  119. printf_P(PSTR("mmu_get_response - begin\n"));
  120. //waits for "ok" from mmu
  121. //function returns true if "ok" was received
  122. //if timeout is set to true function return false if there is no "ok" received before timeout
  123. bool response = true;
  124. LongTimer mmu_get_reponse_timeout;
  125. KEEPALIVE_STATE(IN_PROCESS);
  126. mmu_get_reponse_timeout.start();
  127. while (mmu_rx_ok() <= 0)
  128. {
  129. delay_keep_alive(100);
  130. if (timeout && mmu_get_reponse_timeout.expired(5 * 60 * 1000ul))
  131. { //5 minutes timeout
  132. response = false;
  133. break;
  134. }
  135. }
  136. printf_P(PSTR("mmu_get_response - end %d\n"), response?1:0);
  137. return response;
  138. }
  139. void manage_response(bool move_axes, bool turn_off_nozzle)
  140. {
  141. bool response = false;
  142. mmu_print_saved = false;
  143. bool lcd_update_was_enabled = false;
  144. float hotend_temp_bckp = degTargetHotend(active_extruder);
  145. float z_position_bckp = current_position[Z_AXIS];
  146. float x_position_bckp = current_position[X_AXIS];
  147. float y_position_bckp = current_position[Y_AXIS];
  148. while(!response)
  149. {
  150. response = mmu_get_response(true); //wait for "ok" from mmu
  151. if (!response) { //no "ok" was received in reserved time frame, user will fix the issue on mmu unit
  152. if (!mmu_print_saved) { //first occurence, we are saving current position, park print head in certain position and disable nozzle heater
  153. if (lcd_update_enabled) {
  154. lcd_update_was_enabled = true;
  155. lcd_update_enable(false);
  156. }
  157. st_synchronize();
  158. mmu_print_saved = true;
  159. hotend_temp_bckp = degTargetHotend(active_extruder);
  160. if (move_axes) {
  161. z_position_bckp = current_position[Z_AXIS];
  162. x_position_bckp = current_position[X_AXIS];
  163. y_position_bckp = current_position[Y_AXIS];
  164. //lift z
  165. current_position[Z_AXIS] += Z_PAUSE_LIFT;
  166. if (current_position[Z_AXIS] > Z_MAX_POS) current_position[Z_AXIS] = Z_MAX_POS;
  167. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 15, active_extruder);
  168. st_synchronize();
  169. //Move XY to side
  170. current_position[X_AXIS] = X_PAUSE_POS;
  171. current_position[Y_AXIS] = Y_PAUSE_POS;
  172. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 50, active_extruder);
  173. st_synchronize();
  174. }
  175. if (turn_off_nozzle) {
  176. //set nozzle target temperature to 0
  177. setAllTargetHotends(0);
  178. printf_P(PSTR("MMU not responding\n"));
  179. lcd_show_fullscreen_message_and_wait_P(_i("MMU needs user attention. Please press knob to resume nozzle target temperature."));
  180. setTargetHotend(hotend_temp_bckp, active_extruder);
  181. while ((degTargetHotend(active_extruder) - degHotend(active_extruder)) > 5) {
  182. delay_keep_alive(1000);
  183. lcd_wait_for_heater();
  184. }
  185. }
  186. }
  187. lcd_display_message_fullscreen_P(_i("Check MMU. Fix the issue and then press button on MMU unit."));
  188. }
  189. else if (mmu_print_saved) {
  190. printf_P(PSTR("MMU start responding\n"));
  191. lcd_clear();
  192. lcd_display_message_fullscreen_P(_i("MMU OK. Resuming..."));
  193. if (move_axes) {
  194. current_position[X_AXIS] = x_position_bckp;
  195. current_position[Y_AXIS] = y_position_bckp;
  196. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 50, active_extruder);
  197. st_synchronize();
  198. current_position[Z_AXIS] = z_position_bckp;
  199. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 15, active_extruder);
  200. st_synchronize();
  201. }
  202. else {
  203. delay_keep_alive(1000); //delay just for showing MMU OK message for a while in case that there are no xyz movements
  204. }
  205. }
  206. }
  207. if (lcd_update_was_enabled) lcd_update_enable(true);
  208. }
  209. void mmu_load_to_nozzle()
  210. {
  211. st_synchronize();
  212. bool saved_e_relative_mode = axis_relative_modes[E_AXIS];
  213. if (!saved_e_relative_mode) axis_relative_modes[E_AXIS] = true;
  214. current_position[E_AXIS] += 7.2f;
  215. float feedrate = 562;
  216. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate / 60, active_extruder);
  217. st_synchronize();
  218. current_position[E_AXIS] += 14.4f;
  219. feedrate = 871;
  220. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate / 60, active_extruder);
  221. st_synchronize();
  222. current_position[E_AXIS] += 36.0f;
  223. feedrate = 1393;
  224. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate / 60, active_extruder);
  225. st_synchronize();
  226. current_position[E_AXIS] += 14.4f;
  227. feedrate = 871;
  228. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate / 60, active_extruder);
  229. st_synchronize();
  230. if (!saved_e_relative_mode) axis_relative_modes[E_AXIS] = false;
  231. }
  232. void mmu_M600_load_filament(bool automatic)
  233. {
  234. //load filament for mmu v2
  235. bool response = false;
  236. bool yes = false;
  237. if (!automatic) {
  238. yes = lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Do you want to switch extruder?"), false);
  239. if(yes) tmp_extruder = choose_extruder_menu();
  240. else tmp_extruder = mmu_extruder;
  241. }
  242. else {
  243. tmp_extruder = (tmp_extruder+1)%5;
  244. }
  245. lcd_update_enable(false);
  246. lcd_clear();
  247. lcd_set_cursor(0, 1); lcd_puts_P(_T(MSG_LOADING_FILAMENT));
  248. lcd_print(" ");
  249. lcd_print(tmp_extruder + 1);
  250. snmm_filaments_used |= (1 << tmp_extruder); //for stop print
  251. printf_P(PSTR("T code: %d \n"), tmp_extruder);
  252. mmu_printf_P(PSTR("T%d\n"), tmp_extruder);
  253. manage_response(false, true);
  254. mmu_extruder = tmp_extruder; //filament change is finished
  255. mmu_load_to_nozzle();
  256. st_synchronize();
  257. current_position[E_AXIS]+= FILAMENTCHANGE_FINALFEED ;
  258. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2, active_extruder);
  259. }
  260. void extr_mov(float shift, float feed_rate)
  261. { //move extruder no matter what the current heater temperature is
  262. set_extrude_min_temp(.0);
  263. current_position[E_AXIS] += shift;
  264. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feed_rate, active_extruder);
  265. set_extrude_min_temp(EXTRUDE_MINTEMP);
  266. }
  267. void change_extr(int extr) { //switches multiplexer for extruders
  268. #ifdef SNMM
  269. st_synchronize();
  270. delay(100);
  271. disable_e0();
  272. disable_e1();
  273. disable_e2();
  274. mmu_extruder = extr;
  275. pinMode(E_MUX0_PIN, OUTPUT);
  276. pinMode(E_MUX1_PIN, OUTPUT);
  277. switch (extr) {
  278. case 1:
  279. WRITE(E_MUX0_PIN, HIGH);
  280. WRITE(E_MUX1_PIN, LOW);
  281. break;
  282. case 2:
  283. WRITE(E_MUX0_PIN, LOW);
  284. WRITE(E_MUX1_PIN, HIGH);
  285. break;
  286. case 3:
  287. WRITE(E_MUX0_PIN, HIGH);
  288. WRITE(E_MUX1_PIN, HIGH);
  289. break;
  290. default:
  291. WRITE(E_MUX0_PIN, LOW);
  292. WRITE(E_MUX1_PIN, LOW);
  293. break;
  294. }
  295. delay(100);
  296. #endif
  297. }
  298. int get_ext_nr()
  299. { //reads multiplexer input pins and return current extruder number (counted from 0)
  300. #ifndef SNMM
  301. return(mmu_extruder); //update needed
  302. #else
  303. return(2 * READ(E_MUX1_PIN) + READ(E_MUX0_PIN));
  304. #endif
  305. }
  306. void display_loading()
  307. {
  308. switch (mmu_extruder)
  309. {
  310. case 1: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T1)); break;
  311. case 2: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T2)); break;
  312. case 3: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T3)); break;
  313. default: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T0)); break;
  314. }
  315. }
  316. void extr_adj(int extruder) //loading filament for SNMM
  317. {
  318. #ifndef SNMM
  319. printf_P(PSTR("L%d \n"),extruder);
  320. fprintf_P(uart2io, PSTR("L%d\n"), extruder);
  321. //show which filament is currently loaded
  322. lcd_update_enable(false);
  323. lcd_clear();
  324. lcd_set_cursor(0, 1); lcd_puts_P(_T(MSG_LOADING_FILAMENT));
  325. //if(strlen(_T(MSG_LOADING_FILAMENT))>18) lcd.setCursor(0, 1);
  326. //else lcd.print(" ");
  327. lcd_print(" ");
  328. lcd_print(mmu_extruder + 1);
  329. // get response
  330. manage_response(false, false);
  331. lcd_update_enable(true);
  332. //lcd_return_to_status();
  333. #else
  334. bool correct;
  335. max_feedrate[E_AXIS] =80;
  336. //max_feedrate[E_AXIS] = 50;
  337. START:
  338. lcd_clear();
  339. lcd_set_cursor(0, 0);
  340. switch (extruder) {
  341. case 1: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T1)); break;
  342. case 2: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T2)); break;
  343. case 3: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T3)); break;
  344. default: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T0)); break;
  345. }
  346. KEEPALIVE_STATE(PAUSED_FOR_USER);
  347. do{
  348. extr_mov(0.001,1000);
  349. delay_keep_alive(2);
  350. } while (!lcd_clicked());
  351. //delay_keep_alive(500);
  352. KEEPALIVE_STATE(IN_HANDLER);
  353. st_synchronize();
  354. //correct = lcd_show_fullscreen_message_yes_no_and_wait_P(MSG_FIL_LOADED_CHECK, false);
  355. //if (!correct) goto START;
  356. //extr_mov(BOWDEN_LENGTH/2.f, 500); //dividing by 2 is there because of max. extrusion length limitation (x_max + y_max)
  357. //extr_mov(BOWDEN_LENGTH/2.f, 500);
  358. extr_mov(bowden_length[extruder], 500);
  359. lcd_clear();
  360. lcd_set_cursor(0, 0); lcd_puts_P(_T(MSG_LOADING_FILAMENT));
  361. if(strlen(_T(MSG_LOADING_FILAMENT))>18) lcd_set_cursor(0, 1);
  362. else lcd_print(" ");
  363. lcd_print(mmu_extruder + 1);
  364. lcd_set_cursor(0, 2); lcd_puts_P(_T(MSG_PLEASE_WAIT));
  365. st_synchronize();
  366. max_feedrate[E_AXIS] = 50;
  367. lcd_update_enable(true);
  368. lcd_return_to_status();
  369. lcdDrawUpdate = 2;
  370. #endif
  371. }
  372. void extr_unload()
  373. { //unload just current filament for multimaterial printers
  374. #ifdef SNMM
  375. float tmp_motor[3] = DEFAULT_PWM_MOTOR_CURRENT;
  376. float tmp_motor_loud[3] = DEFAULT_PWM_MOTOR_CURRENT_LOUD;
  377. uint8_t SilentMode = eeprom_read_byte((uint8_t*)EEPROM_SILENT);
  378. #endif
  379. if (degHotend0() > EXTRUDE_MINTEMP)
  380. {
  381. #ifndef SNMM
  382. st_synchronize();
  383. //show which filament is currently unloaded
  384. lcd_update_enable(false);
  385. lcd_clear();
  386. lcd_set_cursor(0, 1); lcd_puts_P(_T(MSG_UNLOADING_FILAMENT));
  387. lcd_print(" ");
  388. lcd_print(mmu_extruder + 1);
  389. current_position[E_AXIS] -= 80;
  390. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2500 / 60, active_extruder);
  391. st_synchronize();
  392. printf_P(PSTR("U0\n"));
  393. fprintf_P(uart2io, PSTR("U0\n"));
  394. // get response
  395. manage_response(false, true);
  396. lcd_update_enable(true);
  397. #else //SNMM
  398. lcd_clear();
  399. lcd_display_message_fullscreen_P(PSTR(""));
  400. max_feedrate[E_AXIS] = 50;
  401. lcd_set_cursor(0, 0); lcd_puts_P(_T(MSG_UNLOADING_FILAMENT));
  402. lcd_print(" ");
  403. lcd_print(mmu_extruder + 1);
  404. lcd_set_cursor(0, 2); lcd_puts_P(_T(MSG_PLEASE_WAIT));
  405. if (current_position[Z_AXIS] < 15) {
  406. current_position[Z_AXIS] += 15; //lifting in Z direction to make space for extrusion
  407. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 25, active_extruder);
  408. }
  409. current_position[E_AXIS] += 10; //extrusion
  410. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 10, active_extruder);
  411. st_current_set(2, E_MOTOR_HIGH_CURRENT);
  412. if (current_temperature[0] < 230) { //PLA & all other filaments
  413. current_position[E_AXIS] += 5.4;
  414. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2800 / 60, active_extruder);
  415. current_position[E_AXIS] += 3.2;
  416. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
  417. current_position[E_AXIS] += 3;
  418. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3400 / 60, active_extruder);
  419. }
  420. else { //ABS
  421. current_position[E_AXIS] += 3.1;
  422. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2000 / 60, active_extruder);
  423. current_position[E_AXIS] += 3.1;
  424. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2500 / 60, active_extruder);
  425. current_position[E_AXIS] += 4;
  426. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
  427. /*current_position[X_AXIS] += 23; //delay
  428. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 600 / 60, active_extruder); //delay
  429. current_position[X_AXIS] -= 23; //delay
  430. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 600 / 60, active_extruder); //delay*/
  431. delay_keep_alive(4700);
  432. }
  433. max_feedrate[E_AXIS] = 80;
  434. current_position[E_AXIS] -= (bowden_length[mmu_extruder] + 60 + FIL_LOAD_LENGTH) / 2;
  435. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 500, active_extruder);
  436. current_position[E_AXIS] -= (bowden_length[mmu_extruder] + 60 + FIL_LOAD_LENGTH) / 2;
  437. plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 500, active_extruder);
  438. st_synchronize();
  439. //st_current_init();
  440. if (SilentMode != SILENT_MODE_OFF) st_current_set(2, tmp_motor[2]); //set back to normal operation currents
  441. else st_current_set(2, tmp_motor_loud[2]);
  442. lcd_update_enable(true);
  443. lcd_return_to_status();
  444. max_feedrate[E_AXIS] = 50;
  445. #endif //SNMM
  446. }
  447. else
  448. {
  449. lcd_clear();
  450. lcd_set_cursor(0, 0);
  451. lcd_puts_P(_T(MSG_ERROR));
  452. lcd_set_cursor(0, 2);
  453. lcd_puts_P(_T(MSG_PREHEAT_NOZZLE));
  454. delay(2000);
  455. lcd_clear();
  456. }
  457. //lcd_return_to_status();
  458. }
  459. //wrapper functions for loading filament
  460. void extr_adj_0()
  461. {
  462. #ifndef SNMM
  463. enquecommand_P(PSTR("M701 E0"));
  464. #else
  465. change_extr(0);
  466. extr_adj(0);
  467. #endif
  468. }
  469. void extr_adj_1()
  470. {
  471. #ifndef SNMM
  472. enquecommand_P(PSTR("M701 E1"));
  473. #else
  474. change_extr(1);
  475. extr_adj(1);
  476. #endif
  477. }
  478. void extr_adj_2()
  479. {
  480. #ifndef SNMM
  481. enquecommand_P(PSTR("M701 E2"));
  482. #else
  483. change_extr(2);
  484. extr_adj(2);
  485. #endif
  486. }
  487. void extr_adj_3()
  488. {
  489. #ifndef SNMM
  490. enquecommand_P(PSTR("M701 E3"));
  491. #else
  492. change_extr(3);
  493. extr_adj(3);
  494. #endif
  495. }
  496. void extr_adj_4()
  497. {
  498. #ifndef SNMM
  499. enquecommand_P(PSTR("M701 E4"));
  500. #else
  501. change_extr(4);
  502. extr_adj(4);
  503. #endif
  504. }
  505. void load_all()
  506. {
  507. #ifndef SNMM
  508. enquecommand_P(PSTR("M701 E0"));
  509. enquecommand_P(PSTR("M701 E1"));
  510. enquecommand_P(PSTR("M701 E2"));
  511. enquecommand_P(PSTR("M701 E3"));
  512. enquecommand_P(PSTR("M701 E4"));
  513. #else
  514. for (int i = 0; i < 4; i++)
  515. {
  516. change_extr(i);
  517. extr_adj(i);
  518. }
  519. #endif
  520. }
  521. //wrapper functions for changing extruders
  522. void extr_change_0()
  523. {
  524. change_extr(0);
  525. lcd_return_to_status();
  526. }
  527. void extr_change_1()
  528. {
  529. change_extr(1);
  530. lcd_return_to_status();
  531. }
  532. void extr_change_2()
  533. {
  534. change_extr(2);
  535. lcd_return_to_status();
  536. }
  537. void extr_change_3()
  538. {
  539. change_extr(3);
  540. lcd_return_to_status();
  541. }
  542. //wrapper functions for unloading filament
  543. void extr_unload_all()
  544. {
  545. if (degHotend0() > EXTRUDE_MINTEMP)
  546. {
  547. for (int i = 0; i < 4; i++)
  548. {
  549. change_extr(i);
  550. extr_unload();
  551. }
  552. }
  553. else
  554. {
  555. lcd_clear();
  556. lcd_set_cursor(0, 0);
  557. lcd_puts_P(_T(MSG_ERROR));
  558. lcd_set_cursor(0, 2);
  559. lcd_puts_P(_T(MSG_PREHEAT_NOZZLE));
  560. delay(2000);
  561. lcd_clear();
  562. lcd_return_to_status();
  563. }
  564. }
  565. //unloading just used filament (for snmm)
  566. void extr_unload_used()
  567. {
  568. if (degHotend0() > EXTRUDE_MINTEMP) {
  569. for (int i = 0; i < 4; i++) {
  570. if (snmm_filaments_used & (1 << i)) {
  571. change_extr(i);
  572. extr_unload();
  573. }
  574. }
  575. snmm_filaments_used = 0;
  576. }
  577. else {
  578. lcd_clear();
  579. lcd_set_cursor(0, 0);
  580. lcd_puts_P(_T(MSG_ERROR));
  581. lcd_set_cursor(0, 2);
  582. lcd_puts_P(_T(MSG_PREHEAT_NOZZLE));
  583. delay(2000);
  584. lcd_clear();
  585. lcd_return_to_status();
  586. }
  587. }
  588. void extr_unload_0()
  589. {
  590. change_extr(0);
  591. extr_unload();
  592. }
  593. void extr_unload_1()
  594. {
  595. change_extr(1);
  596. extr_unload();
  597. }
  598. void extr_unload_2()
  599. {
  600. change_extr(2);
  601. extr_unload();
  602. }
  603. void extr_unload_3()
  604. {
  605. change_extr(3);
  606. extr_unload();
  607. }
  608. void extr_unload_4()
  609. {
  610. change_extr(4);
  611. extr_unload();
  612. }