My Marlin configs for Fabrikator Mini and CTC i3 Pro B
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

menu.cpp 76KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #include "../../inc/MarlinConfigPre.h"
  23. #if ENABLED(ULTIPANEL)
  24. #include "menu.h"
  25. #include "../ultralcd.h"
  26. #include "../../sd/cardreader.h"
  27. #include "../../module/temperature.h"
  28. #include "../../module/planner.h"
  29. #include "../../module/motion.h"
  30. #include "../../module/probe.h"
  31. #include "../../module/printcounter.h"
  32. #include "../../gcode/gcode.h"
  33. #include "../../gcode/queue.h"
  34. #include "../../module/configuration_store.h"
  35. #include "../../module/tool_change.h"
  36. #include "../../Marlin.h"
  37. #include <stdarg.h>
  38. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  39. #include "../../feature/pause.h"
  40. #endif
  41. #if ENABLED(POWER_LOSS_RECOVERY)
  42. #include "../../feature/power_loss_recovery.h"
  43. #endif
  44. #if ENABLED(PRINTCOUNTER) && ENABLED(LCD_INFO_MENU)
  45. #include "../../libs/duration_t.h"
  46. #endif
  47. #if ENABLED(BLTOUCH)
  48. #include "../../module/endstops.h"
  49. #endif
  50. #if HAS_LEVELING
  51. #include "../../feature/bedlevel/bedlevel.h"
  52. #endif
  53. #if ENABLED(LED_CONTROL_MENU)
  54. #include "../../feature/leds/leds.h"
  55. #endif
  56. ////////////////////////////////////////////
  57. ///////////// Global Variables /////////////
  58. ////////////////////////////////////////////
  59. // Buttons
  60. volatile uint8_t buttons;
  61. #if ENABLED(REPRAPWORLD_KEYPAD)
  62. volatile uint8_t buttons_reprapworld_keypad;
  63. #endif
  64. // Menu Navigation
  65. int8_t encoderTopLine;
  66. typedef struct {
  67. screenFunc_t menu_function;
  68. uint32_t encoder_position;
  69. } menuPosition;
  70. menuPosition screen_history[6];
  71. uint8_t screen_history_depth = 0;
  72. bool screen_changed, defer_return_to_status;
  73. // Value Editing
  74. PGM_P editLabel;
  75. void *editValue;
  76. int32_t minEditValue, maxEditValue;
  77. screenFunc_t callbackFunc;
  78. bool liveEdit;
  79. #if ENABLED(PIDTEMP)
  80. float raw_Ki, raw_Kd; // place-holders for Ki and Kd edits
  81. #endif
  82. bool no_reentry = false;
  83. // Initialized by settings.load()
  84. int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2];
  85. uint8_t lcd_preheat_fan_speed[2];
  86. ////////////////////////////////////////////
  87. //////// Menu Navigation & History /////////
  88. ////////////////////////////////////////////
  89. void lcd_status_screen();
  90. void lcd_return_to_status() { lcd_goto_screen(lcd_status_screen); }
  91. void lcd_save_previous_screen() {
  92. if (screen_history_depth < COUNT(screen_history)) {
  93. screen_history[screen_history_depth].menu_function = currentScreen;
  94. screen_history[screen_history_depth].encoder_position = encoderPosition;
  95. ++screen_history_depth;
  96. }
  97. }
  98. void lcd_goto_previous_menu() {
  99. if (screen_history_depth > 0) {
  100. --screen_history_depth;
  101. lcd_goto_screen(
  102. screen_history[screen_history_depth].menu_function,
  103. screen_history[screen_history_depth].encoder_position
  104. );
  105. }
  106. else
  107. lcd_return_to_status();
  108. }
  109. void lcd_goto_previous_menu_no_defer() {
  110. defer_return_to_status = false;
  111. lcd_goto_previous_menu();
  112. }
  113. ////////////////////////////////////////////
  114. /////////////// Menu Actions ///////////////
  115. ////////////////////////////////////////////
  116. void _menu_action_back() { lcd_goto_previous_menu(); }
  117. void menu_action_submenu(screenFunc_t func) { lcd_save_previous_screen(); lcd_goto_screen(func); }
  118. void menu_action_gcode(PGM_P pgcode) { enqueue_and_echo_commands_P(pgcode); }
  119. void menu_action_function(screenFunc_t func) { (*func)(); }
  120. #if ENABLED(SDSUPPORT)
  121. void menu_action_sdfile(CardReader &theCard) {
  122. #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
  123. last_sdfile_encoderPosition = encoderPosition; // Save which file was selected for later use
  124. #endif
  125. card.openAndPrintFile(theCard.filename);
  126. lcd_return_to_status();
  127. lcd_reset_status();
  128. }
  129. void menu_action_sddirectory(CardReader &theCard) {
  130. card.chdir(theCard.filename);
  131. encoderTopLine = 0;
  132. encoderPosition = 2 * ENCODER_STEPS_PER_MENU_ITEM;
  133. screen_changed = true;
  134. #if HAS_GRAPHICAL_LCD
  135. drawing_screen = false;
  136. #endif
  137. lcd_refresh();
  138. }
  139. #endif // SDSUPPORT
  140. ////////////////////////////////////////////
  141. /////////// Menu Editing Actions ///////////
  142. ////////////////////////////////////////////
  143. /**
  144. * Functions for editing single values
  145. *
  146. * The "DEFINE_MENU_EDIT_TYPE" macro generates the functions needed to edit a numerical value.
  147. *
  148. * For example, DEFINE_MENU_EDIT_TYPE(int16_t, int3, itostr3, 1) expands into these functions:
  149. *
  150. * bool _menu_edit_int3();
  151. * void menu_edit_int3(); // edit int16_t (interactively)
  152. * void menu_edit_callback_int3(); // edit int16_t (interactively) with callback on completion
  153. * void _menu_action_setting_edit_int3(PGM_P const pstr, int16_t * const ptr, const int16_t minValue, const int16_t maxValue);
  154. * void menu_action_setting_edit_int3(PGM_P const pstr, int16_t * const ptr, const int16_t minValue, const int16_t maxValue);
  155. * void menu_action_setting_edit_callback_int3(PGM_P const pstr, int16_t * const ptr, const int16_t minValue, const int16_t maxValue, const screenFunc_t callback, const bool live); // edit int16_t with callback
  156. *
  157. * You can then use one of the menu macros to present the edit interface:
  158. * MENU_ITEM_EDIT(int3, MSG_SPEED, &feedrate_percentage, 10, 999)
  159. *
  160. * This expands into a more primitive menu item:
  161. * MENU_ITEM(setting_edit_int3, MSG_SPEED, PSTR(MSG_SPEED), &feedrate_percentage, 10, 999)
  162. *
  163. * ...which calls:
  164. * menu_action_setting_edit_int3(PSTR(MSG_SPEED), &feedrate_percentage, 10, 999)
  165. */
  166. #define DEFINE_MENU_EDIT_TYPE(TYPE, NAME, STRFUNC, SCALE) \
  167. bool _menu_edit_ ## NAME() { \
  168. ENCODER_DIRECTION_NORMAL(); \
  169. if ((int32_t)encoderPosition < 0) encoderPosition = 0; \
  170. if ((int32_t)encoderPosition > maxEditValue) encoderPosition = maxEditValue; \
  171. if (lcdDrawUpdate) \
  172. lcd_implementation_drawedit(editLabel, STRFUNC(((TYPE)((int32_t)encoderPosition + minEditValue)) * (1.0f / SCALE))); \
  173. if (lcd_clicked || (liveEdit && lcdDrawUpdate)) { \
  174. TYPE value = ((TYPE)((int32_t)encoderPosition + minEditValue)) * (1.0f / SCALE); \
  175. if (editValue != NULL) *((TYPE*)editValue) = value; \
  176. if (callbackFunc && (liveEdit || lcd_clicked)) (*callbackFunc)(); \
  177. if (lcd_clicked) lcd_goto_previous_menu(); \
  178. } \
  179. return use_click(); \
  180. } \
  181. void menu_edit_ ## NAME() { _menu_edit_ ## NAME(); } \
  182. void _menu_action_setting_edit_ ## NAME(PGM_P const pstr, TYPE* const ptr, const TYPE minValue, const TYPE maxValue) { \
  183. lcd_save_previous_screen(); \
  184. lcd_refresh(); \
  185. \
  186. editLabel = pstr; \
  187. editValue = ptr; \
  188. minEditValue = minValue * SCALE; \
  189. maxEditValue = maxValue * SCALE - minEditValue; \
  190. encoderPosition = (*ptr) * SCALE - minEditValue; \
  191. } \
  192. void menu_action_setting_edit_callback_ ## NAME(PGM_P const pstr, TYPE * const ptr, const TYPE minValue, const TYPE maxValue, const screenFunc_t callback/*=NULL*/, const bool live/*=false*/) { \
  193. _menu_action_setting_edit_ ## NAME(pstr, ptr, minValue, maxValue); \
  194. currentScreen = menu_edit_ ## NAME; \
  195. callbackFunc = callback; \
  196. liveEdit = live; \
  197. } \
  198. typedef void NAME##_void
  199. DEFINE_MENU_EDIT_TYPE(int16_t, int3, itostr3, 1);
  200. DEFINE_MENU_EDIT_TYPE(int16_t, int4, itostr4sign, 1);
  201. DEFINE_MENU_EDIT_TYPE(uint8_t, int8, i8tostr3, 1);
  202. DEFINE_MENU_EDIT_TYPE(float, float3, ftostr3, 1);
  203. DEFINE_MENU_EDIT_TYPE(float, float52, ftostr52, 100);
  204. DEFINE_MENU_EDIT_TYPE(float, float43, ftostr43sign, 1000);
  205. DEFINE_MENU_EDIT_TYPE(float, float5, ftostr5rj, 0.01f);
  206. DEFINE_MENU_EDIT_TYPE(float, float51, ftostr51sign, 10);
  207. DEFINE_MENU_EDIT_TYPE(float, float52sign, ftostr52sign, 100);
  208. DEFINE_MENU_EDIT_TYPE(float, float62, ftostr62rj, 100);
  209. DEFINE_MENU_EDIT_TYPE(uint32_t, long5, ftostr5rj, 0.01f);
  210. void menu_action_setting_edit_bool(PGM_P pstr, bool* ptr) { UNUSED(pstr); *ptr ^= true; lcd_refresh(); }
  211. void menu_action_setting_edit_callback_bool(PGM_P pstr, bool* ptr, screenFunc_t callback) {
  212. menu_action_setting_edit_bool(pstr, ptr);
  213. (*callback)();
  214. }
  215. ////////////////////////////////////////////
  216. ///////////////// Menu Tree ////////////////
  217. ////////////////////////////////////////////
  218. #if DISABLED(NO_VOLUMETRICS) || ENABLED(ADVANCED_PAUSE_FEATURE)
  219. void menu_advanced_filament();
  220. #endif
  221. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  222. #if E_STEPPERS > 1 || ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
  223. void menu_change_filament();
  224. #else
  225. void menu_temp_e0_filament_change();
  226. #endif
  227. #endif
  228. #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
  229. float lcd_z_fade_height;
  230. void _lcd_set_z_fade_height() { set_z_fade_height(lcd_z_fade_height); }
  231. #endif
  232. bool printer_busy() { return planner.movesplanned() || IS_SD_PRINTING(); }
  233. #if HAS_CHARACTER_LCD && (ENABLED(LCD_PROGRESS_BAR) || ENABLED(LCD_PROGRESS_BAR_TEST) || ENABLED(AUTO_BED_LEVELING_UBL))
  234. void lcd_set_custom_characters(
  235. #if ENABLED(LCD_PROGRESS_BAR) || ENABLED(SHOW_BOOTSCREEN)
  236. const uint8_t screen_charset=CHARSET_INFO
  237. #endif
  238. );
  239. #endif
  240. /**
  241. * General function to go directly to a screen
  242. */
  243. void lcd_goto_screen(screenFunc_t screen, const uint32_t encoder/*=0*/) {
  244. if (currentScreen != screen) {
  245. #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
  246. // Shadow for editing the fade height
  247. lcd_z_fade_height = planner.z_fade_height;
  248. #endif
  249. #if ENABLED(DOUBLECLICK_FOR_Z_BABYSTEPPING) && ENABLED(BABYSTEPPING)
  250. static millis_t doubleclick_expire_ms = 0;
  251. // Going to menu_main from status screen? Remember first click time.
  252. // Going back to status screen within a very short time? Go to Z babystepping.
  253. if (screen == menu_main) {
  254. if (currentScreen == lcd_status_screen)
  255. doubleclick_expire_ms = millis() + DOUBLECLICK_MAX_INTERVAL;
  256. }
  257. else if (screen == lcd_status_screen && currentScreen == menu_main && PENDING(millis(), doubleclick_expire_ms)) {
  258. if (printer_busy()) {
  259. screen =
  260. #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
  261. lcd_babystep_zoffset
  262. #else
  263. lcd_babystep_z
  264. #endif
  265. ;
  266. }
  267. #if ENABLED(MOVE_Z_WHEN_IDLE)
  268. else {
  269. move_menu_scale = MOVE_Z_IDLE_MULTIPLICATOR;
  270. screen = lcd_move_z;
  271. }
  272. #endif
  273. }
  274. #endif
  275. currentScreen = screen;
  276. encoderPosition = encoder;
  277. if (screen == lcd_status_screen) {
  278. defer_return_to_status = false;
  279. #if ENABLED(AUTO_BED_LEVELING_UBL)
  280. ubl.lcd_map_control = false;
  281. #endif
  282. screen_history_depth = 0;
  283. }
  284. lcd_implementation_clear();
  285. // Re-initialize custom characters that may be re-used
  286. #if HAS_CHARACTER_LCD && ENABLED(AUTO_BED_LEVELING_UBL)
  287. if (!ubl.lcd_map_control) {
  288. lcd_set_custom_characters(
  289. #if ENABLED(LCD_PROGRESS_BAR)
  290. screen == lcd_status_screen ? CHARSET_INFO : CHARSET_MENU
  291. #endif
  292. );
  293. }
  294. #elif ENABLED(LCD_PROGRESS_BAR)
  295. lcd_set_custom_characters(screen == lcd_status_screen ? CHARSET_INFO : CHARSET_MENU);
  296. #endif
  297. lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
  298. screen_changed = true;
  299. #if HAS_GRAPHICAL_LCD
  300. drawing_screen = false;
  301. #endif
  302. }
  303. }
  304. ////////////////////////////////////////////
  305. ///////////// Manual Movement //////////////
  306. ////////////////////////////////////////////
  307. //
  308. // Display the synchronize screen until moves are
  309. // finished, and don't return to the caller until
  310. // done. ** This blocks the command queue! **
  311. //
  312. static PGM_P sync_message;
  313. void _lcd_synchronize() {
  314. if (lcdDrawUpdate) lcd_implementation_drawmenu_static(LCD_HEIGHT >= 4 ? 1 : 0, sync_message);
  315. if (no_reentry) return;
  316. // Make this the current handler till all moves are done
  317. no_reentry = true;
  318. const screenFunc_t old_screen = currentScreen;
  319. lcd_goto_screen(_lcd_synchronize);
  320. planner.synchronize(); // idle() is called until moves complete
  321. no_reentry = false;
  322. lcd_goto_screen(old_screen);
  323. }
  324. // Display the synchronize screen with a custom message
  325. // ** This blocks the command queue! **
  326. void lcd_synchronize(PGM_P const msg/*=NULL*/) {
  327. static const char moving[] PROGMEM = MSG_MOVING;
  328. sync_message = msg ? msg : moving;
  329. _lcd_synchronize();
  330. }
  331. /**
  332. * Scrolling for menus and other line-based screens
  333. *
  334. * encoderLine is the position based on the encoder
  335. * encoderTopLine is the top menu line to display
  336. * _lcdLineNr is the index of the LCD line (e.g., 0-3)
  337. * _menuLineNr is the menu item to draw and process
  338. * _thisItemNr is the index of each MENU_ITEM or STATIC_ITEM
  339. * screen_items is the total number of items in the menu (after one call)
  340. */
  341. int8_t encoderLine, screen_items;
  342. void scroll_screen(const uint8_t limit, const bool is_menu) {
  343. ENCODER_DIRECTION_MENUS();
  344. ENCODER_RATE_MULTIPLY(false);
  345. if (encoderPosition > 0x8000) encoderPosition = 0;
  346. if (first_page) {
  347. encoderLine = encoderPosition / (ENCODER_STEPS_PER_MENU_ITEM);
  348. screen_changed = false;
  349. }
  350. if (screen_items > 0 && encoderLine >= screen_items - limit) {
  351. encoderLine = MAX(0, screen_items - limit);
  352. encoderPosition = encoderLine * (ENCODER_STEPS_PER_MENU_ITEM);
  353. }
  354. if (is_menu) {
  355. NOMORE(encoderTopLine, encoderLine);
  356. if (encoderLine >= encoderTopLine + LCD_HEIGHT)
  357. encoderTopLine = encoderLine - LCD_HEIGHT + 1;
  358. }
  359. else
  360. encoderTopLine = encoderLine;
  361. }
  362. void lcd_completion_feedback(const bool good/*=true*/) {
  363. if (good) {
  364. lcd_buzz(100, 659);
  365. lcd_buzz(100, 698);
  366. }
  367. else lcd_buzz(20, 440);
  368. }
  369. inline void line_to_current_z() {
  370. planner.buffer_line(current_position, MMM_TO_MMS(manual_feedrate_mm_m[Z_AXIS]), active_extruder);
  371. }
  372. void line_to_z(const float &z) {
  373. current_position[Z_AXIS] = z;
  374. line_to_current_z();
  375. }
  376. #if ENABLED(POWER_LOSS_RECOVERY)
  377. static void lcd_power_loss_recovery_resume() {
  378. char cmd[20];
  379. // Return to status now
  380. lcd_return_to_status();
  381. // Turn leveling off and home
  382. enqueue_and_echo_commands_P(PSTR("M420 S0\nG28 R0"
  383. #if ENABLED(MARLIN_DEV_MODE)
  384. " S"
  385. #elif !IS_KINEMATIC
  386. " X Y"
  387. #endif
  388. ));
  389. #if HAS_HEATED_BED
  390. const int16_t bt = job_recovery_info.target_temperature_bed;
  391. if (bt) {
  392. // Restore the bed temperature
  393. sprintf_P(cmd, PSTR("M190 S%i"), bt);
  394. enqueue_and_echo_command(cmd);
  395. }
  396. #endif
  397. // Restore all hotend temperatures
  398. HOTEND_LOOP() {
  399. const int16_t et = job_recovery_info.target_temperature[e];
  400. if (et) {
  401. #if HOTENDS > 1
  402. sprintf_P(cmd, PSTR("T%i"), e);
  403. enqueue_and_echo_command(cmd);
  404. #endif
  405. sprintf_P(cmd, PSTR("M109 S%i"), et);
  406. enqueue_and_echo_command(cmd);
  407. }
  408. }
  409. #if HOTENDS > 1
  410. sprintf_P(cmd, PSTR("T%i"), job_recovery_info.active_hotend);
  411. enqueue_and_echo_command(cmd);
  412. #endif
  413. // Restore print cooling fan speeds
  414. for (uint8_t i = 0; i < FAN_COUNT; i++) {
  415. uint8_t f = job_recovery_info.fan_speed[i];
  416. if (f) {
  417. sprintf_P(cmd, PSTR("M106 P%i S%i"), i, f);
  418. enqueue_and_echo_command(cmd);
  419. }
  420. }
  421. // Start draining the job recovery command queue
  422. job_recovery_phase = JOB_RECOVERY_YES;
  423. }
  424. static void lcd_power_loss_recovery_cancel() {
  425. card.removeJobRecoveryFile();
  426. card.autostart_index = 0;
  427. lcd_return_to_status();
  428. }
  429. void menu_job_recovery() {
  430. defer_return_to_status = true;
  431. START_MENU();
  432. STATIC_ITEM(MSG_POWER_LOSS_RECOVERY);
  433. MENU_ITEM(function, MSG_RESUME_PRINT, lcd_power_loss_recovery_resume);
  434. MENU_ITEM(function, MSG_STOP_PRINT, lcd_power_loss_recovery_cancel);
  435. END_MENU();
  436. }
  437. #endif // POWER_LOSS_RECOVERY
  438. #if ENABLED(CUSTOM_USER_MENUS)
  439. #ifdef USER_SCRIPT_DONE
  440. #define _DONE_SCRIPT "\n" USER_SCRIPT_DONE
  441. #else
  442. #define _DONE_SCRIPT ""
  443. #endif
  444. void _lcd_user_gcode(PGM_P const cmd) {
  445. enqueue_and_echo_commands_P(cmd);
  446. #if ENABLED(USER_SCRIPT_AUDIBLE_FEEDBACK)
  447. lcd_completion_feedback();
  448. #endif
  449. #if ENABLED(USER_SCRIPT_RETURN)
  450. lcd_return_to_status();
  451. #endif
  452. }
  453. #if defined(USER_DESC_1) && defined(USER_GCODE_1)
  454. void lcd_user_gcode_1() { _lcd_user_gcode(PSTR(USER_GCODE_1 _DONE_SCRIPT)); }
  455. #endif
  456. #if defined(USER_DESC_2) && defined(USER_GCODE_2)
  457. void lcd_user_gcode_2() { _lcd_user_gcode(PSTR(USER_GCODE_2 _DONE_SCRIPT)); }
  458. #endif
  459. #if defined(USER_DESC_3) && defined(USER_GCODE_3)
  460. void lcd_user_gcode_3() { _lcd_user_gcode(PSTR(USER_GCODE_3 _DONE_SCRIPT)); }
  461. #endif
  462. #if defined(USER_DESC_4) && defined(USER_GCODE_4)
  463. void lcd_user_gcode_4() { _lcd_user_gcode(PSTR(USER_GCODE_4 _DONE_SCRIPT)); }
  464. #endif
  465. #if defined(USER_DESC_5) && defined(USER_GCODE_5)
  466. void lcd_user_gcode_5() { _lcd_user_gcode(PSTR(USER_GCODE_5 _DONE_SCRIPT)); }
  467. #endif
  468. void _menu_user() {
  469. START_MENU();
  470. MENU_BACK(MSG_MAIN);
  471. #if defined(USER_DESC_1) && defined(USER_GCODE_1)
  472. MENU_ITEM(function, USER_DESC_1, lcd_user_gcode_1);
  473. #endif
  474. #if defined(USER_DESC_2) && defined(USER_GCODE_2)
  475. MENU_ITEM(function, USER_DESC_2, lcd_user_gcode_2);
  476. #endif
  477. #if defined(USER_DESC_3) && defined(USER_GCODE_3)
  478. MENU_ITEM(function, USER_DESC_3, lcd_user_gcode_3);
  479. #endif
  480. #if defined(USER_DESC_4) && defined(USER_GCODE_4)
  481. MENU_ITEM(function, USER_DESC_4, lcd_user_gcode_4);
  482. #endif
  483. #if defined(USER_DESC_5) && defined(USER_GCODE_5)
  484. MENU_ITEM(function, USER_DESC_5, lcd_user_gcode_5);
  485. #endif
  486. END_MENU();
  487. }
  488. #endif
  489. #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
  490. void lcd_babystep_zoffset() {
  491. if (use_click()) { return lcd_goto_previous_menu_no_defer(); }
  492. defer_return_to_status = true;
  493. #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
  494. const bool do_probe = (active_extruder == 0);
  495. #else
  496. constexpr bool do_probe = true;
  497. #endif
  498. ENCODER_DIRECTION_NORMAL();
  499. if (encoderPosition) {
  500. const int16_t babystep_increment = (int32_t)encoderPosition * (BABYSTEP_MULTIPLICATOR);
  501. encoderPosition = 0;
  502. const float diff = planner.steps_to_mm[Z_AXIS] * babystep_increment,
  503. new_probe_offset = zprobe_zoffset + diff,
  504. new_offs =
  505. #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
  506. do_probe ? new_probe_offset : hotend_offset[Z_AXIS][active_extruder] - diff
  507. #else
  508. new_probe_offset
  509. #endif
  510. ;
  511. if (WITHIN(new_offs, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) {
  512. thermalManager.babystep_axis(Z_AXIS, babystep_increment);
  513. if (do_probe) zprobe_zoffset = new_offs;
  514. #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
  515. else hotend_offset[Z_AXIS][active_extruder] = new_offs;
  516. #endif
  517. lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
  518. }
  519. }
  520. if (lcdDrawUpdate) {
  521. #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
  522. if (!do_probe)
  523. lcd_implementation_drawedit(PSTR(MSG_IDEX_Z_OFFSET), ftostr43sign(hotend_offset[Z_AXIS][active_extruder]));
  524. else
  525. #endif
  526. lcd_implementation_drawedit(PSTR(MSG_ZPROBE_ZOFFSET), ftostr43sign(zprobe_zoffset));
  527. #if ENABLED(BABYSTEP_ZPROBE_GFX_OVERLAY)
  528. if (do_probe) _lcd_zoffset_overlay_gfx(zprobe_zoffset);
  529. #endif
  530. }
  531. }
  532. #endif // BABYSTEP_ZPROBE_OFFSET
  533. /**
  534. * Watch temperature callbacks
  535. */
  536. #if HAS_TEMP_HOTEND
  537. #if WATCH_HOTENDS
  538. #define _WATCH_FUNC(N) thermalManager.start_watching_heater(N)
  539. #else
  540. #define _WATCH_FUNC(N) NOOP
  541. #endif
  542. void watch_temp_callback_E0() { _WATCH_FUNC(0); }
  543. #if HOTENDS > 1
  544. void watch_temp_callback_E1() { _WATCH_FUNC(1); }
  545. #if HOTENDS > 2
  546. void watch_temp_callback_E2() { _WATCH_FUNC(2); }
  547. #if HOTENDS > 3
  548. void watch_temp_callback_E3() { _WATCH_FUNC(3); }
  549. #if HOTENDS > 4
  550. void watch_temp_callback_E4() { _WATCH_FUNC(4); }
  551. #if HOTENDS > 5
  552. void watch_temp_callback_E5() { _WATCH_FUNC(5); }
  553. #endif // HOTENDS > 5
  554. #endif // HOTENDS > 4
  555. #endif // HOTENDS > 3
  556. #endif // HOTENDS > 2
  557. #endif // HOTENDS > 1
  558. #endif // HAS_TEMP_HOTEND
  559. void watch_temp_callback_bed() {
  560. #if WATCH_THE_BED
  561. thermalManager.start_watching_bed();
  562. #endif
  563. }
  564. #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(PID_AUTOTUNE_MENU) || ENABLED(ADVANCED_PAUSE_FEATURE)
  565. void lcd_enqueue_command(const char * const cmd) {
  566. no_reentry = true;
  567. enqueue_and_echo_command_now(cmd);
  568. no_reentry = false;
  569. }
  570. void lcd_enqueue_commands_P(PGM_P const cmd) {
  571. no_reentry = true;
  572. enqueue_and_echo_commands_now_P(cmd);
  573. no_reentry = false;
  574. }
  575. #endif
  576. #if ENABLED(EEPROM_SETTINGS)
  577. void lcd_store_settings() { lcd_completion_feedback(settings.save()); }
  578. void lcd_load_settings() { lcd_completion_feedback(settings.load()); }
  579. #if DISABLED(SLIM_LCD_MENUS)
  580. static void lcd_init_eeprom() {
  581. lcd_completion_feedback(settings.init_eeprom());
  582. lcd_goto_previous_menu();
  583. }
  584. static void lcd_init_eeprom_confirm() {
  585. START_MENU();
  586. MENU_BACK(MSG_ADVANCED_SETTINGS);
  587. MENU_ITEM(function, MSG_INIT_EEPROM, lcd_init_eeprom);
  588. END_MENU();
  589. }
  590. #endif
  591. #endif
  592. void _lcd_draw_homing() {
  593. constexpr uint8_t line = (LCD_HEIGHT - 1) / 2;
  594. if (lcdDrawUpdate) lcd_implementation_drawmenu_static(line, PSTR(MSG_LEVEL_BED_HOMING));
  595. lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
  596. }
  597. #if ENABLED(LCD_BED_LEVELING) || (HAS_LEVELING && DISABLED(SLIM_LCD_MENUS))
  598. void _lcd_toggle_bed_leveling() { set_bed_leveling_enabled(!planner.leveling_active); }
  599. #endif
  600. #if ENABLED(DELTA_CALIBRATION_MENU) || ENABLED(DELTA_AUTO_CALIBRATION)
  601. void _man_probe_pt(const float &rx, const float &ry) {
  602. do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
  603. do_blocking_move_to_xy(rx, ry);
  604. lcd_synchronize();
  605. move_menu_scale = MAX(PROBE_MANUALLY_STEP, MIN_STEPS_PER_SEGMENT / float(DEFAULT_XYZ_STEPS_PER_UNIT));
  606. lcd_goto_screen(lcd_move_z);
  607. }
  608. #endif // DELTA_CALIBRATION_MENU || DELTA_AUTO_CALIBRATION
  609. #if ENABLED(DELTA_AUTO_CALIBRATION)
  610. float lcd_probe_pt(const float &rx, const float &ry) {
  611. _man_probe_pt(rx, ry);
  612. KEEPALIVE_STATE(PAUSED_FOR_USER);
  613. defer_return_to_status = true;
  614. wait_for_user = true;
  615. while (wait_for_user) idle();
  616. KEEPALIVE_STATE(IN_HANDLER);
  617. lcd_goto_previous_menu_no_defer();
  618. return current_position[Z_AXIS];
  619. }
  620. #endif // DELTA_AUTO_CALIBRATION
  621. #if ENABLED(DELTA_CALIBRATION_MENU)
  622. void _lcd_calibrate_homing() {
  623. _lcd_draw_homing();
  624. if (all_axes_homed()) lcd_goto_previous_menu();
  625. }
  626. void _lcd_delta_calibrate_home() {
  627. enqueue_and_echo_commands_P(PSTR("G28"));
  628. lcd_goto_screen(_lcd_calibrate_homing);
  629. }
  630. void _goto_tower_x() { _man_probe_pt(cos(RADIANS(210)) * delta_calibration_radius, sin(RADIANS(210)) * delta_calibration_radius); }
  631. void _goto_tower_y() { _man_probe_pt(cos(RADIANS(330)) * delta_calibration_radius, sin(RADIANS(330)) * delta_calibration_radius); }
  632. void _goto_tower_z() { _man_probe_pt(cos(RADIANS( 90)) * delta_calibration_radius, sin(RADIANS( 90)) * delta_calibration_radius); }
  633. void _goto_center() { _man_probe_pt(0,0); }
  634. #endif // DELTA_CALIBRATION_MENU
  635. #if ENABLED(DELTA_CALIBRATION_MENU) || ENABLED(DELTA_AUTO_CALIBRATION)
  636. void _recalc_delta_settings() {
  637. #if HAS_LEVELING
  638. reset_bed_level(); // After changing kinematics bed-level data is no longer valid
  639. #endif
  640. recalc_delta_settings();
  641. }
  642. void lcd_delta_settings() {
  643. START_MENU();
  644. MENU_BACK(MSG_DELTA_CALIBRATE);
  645. MENU_ITEM_EDIT_CALLBACK(float52sign, MSG_DELTA_HEIGHT, &delta_height, delta_height - 10, delta_height + 10, _recalc_delta_settings);
  646. MENU_ITEM_EDIT_CALLBACK(float43, "Ex", &delta_endstop_adj[A_AXIS], -5, 5, _recalc_delta_settings);
  647. MENU_ITEM_EDIT_CALLBACK(float43, "Ey", &delta_endstop_adj[B_AXIS], -5, 5, _recalc_delta_settings);
  648. MENU_ITEM_EDIT_CALLBACK(float43, "Ez", &delta_endstop_adj[C_AXIS], -5, 5, _recalc_delta_settings);
  649. MENU_ITEM_EDIT_CALLBACK(float52sign, MSG_DELTA_RADIUS, &delta_radius, delta_radius - 5, delta_radius + 5, _recalc_delta_settings);
  650. MENU_ITEM_EDIT_CALLBACK(float43, "Tx", &delta_tower_angle_trim[A_AXIS], -5, 5, _recalc_delta_settings);
  651. MENU_ITEM_EDIT_CALLBACK(float43, "Ty", &delta_tower_angle_trim[B_AXIS], -5, 5, _recalc_delta_settings);
  652. MENU_ITEM_EDIT_CALLBACK(float43, "Tz", &delta_tower_angle_trim[C_AXIS], -5, 5, _recalc_delta_settings);
  653. MENU_ITEM_EDIT_CALLBACK(float52sign, MSG_DELTA_DIAG_ROD, &delta_diagonal_rod, delta_diagonal_rod - 5, delta_diagonal_rod + 5, _recalc_delta_settings);
  654. END_MENU();
  655. }
  656. void menu_delta_calibrate() {
  657. START_MENU();
  658. MENU_BACK(MSG_MAIN);
  659. #if ENABLED(DELTA_AUTO_CALIBRATION)
  660. MENU_ITEM(gcode, MSG_DELTA_AUTO_CALIBRATE, PSTR("G33"));
  661. MENU_ITEM(gcode, MSG_DELTA_HEIGHT_CALIBRATE, PSTR("G33 S P1"));
  662. MENU_ITEM(gcode, MSG_DELTA_Z_OFFSET_CALIBRATE, PSTR("G33 P-1"));
  663. #if ENABLED(EEPROM_SETTINGS)
  664. MENU_ITEM(function, MSG_STORE_EEPROM, lcd_store_settings);
  665. MENU_ITEM(function, MSG_LOAD_EEPROM, lcd_load_settings);
  666. #endif
  667. #endif
  668. MENU_ITEM(submenu, MSG_DELTA_SETTINGS, lcd_delta_settings);
  669. #if ENABLED(DELTA_CALIBRATION_MENU)
  670. MENU_ITEM(submenu, MSG_AUTO_HOME, _lcd_delta_calibrate_home);
  671. if (all_axes_homed()) {
  672. MENU_ITEM(submenu, MSG_DELTA_CALIBRATE_X, _goto_tower_x);
  673. MENU_ITEM(submenu, MSG_DELTA_CALIBRATE_Y, _goto_tower_y);
  674. MENU_ITEM(submenu, MSG_DELTA_CALIBRATE_Z, _goto_tower_z);
  675. MENU_ITEM(submenu, MSG_DELTA_CALIBRATE_CENTER, _goto_center);
  676. }
  677. #endif
  678. END_MENU();
  679. }
  680. #endif // DELTA_CALIBRATION_MENU || DELTA_AUTO_CALIBRATION
  681. /**
  682. *
  683. * "Temperature" submenu
  684. *
  685. */
  686. #if ENABLED(PID_AUTOTUNE_MENU)
  687. #if ENABLED(PIDTEMP)
  688. int16_t autotune_temp[HOTENDS] = ARRAY_BY_HOTENDS1(150);
  689. #endif
  690. #if ENABLED(PIDTEMPBED)
  691. int16_t autotune_temp_bed = 70;
  692. #endif
  693. void _lcd_autotune(int16_t e) {
  694. char cmd[30];
  695. sprintf_P(cmd, PSTR("M303 U1 E%i S%i"), e,
  696. #if HAS_PID_FOR_BOTH
  697. e < 0 ? autotune_temp_bed : autotune_temp[e]
  698. #elif ENABLED(PIDTEMPBED)
  699. autotune_temp_bed
  700. #else
  701. autotune_temp[e]
  702. #endif
  703. );
  704. lcd_enqueue_command(cmd);
  705. }
  706. #endif // PID_AUTOTUNE_MENU
  707. #if ENABLED(PIDTEMP)
  708. // Helpers for editing PID Ki & Kd values
  709. // grab the PID value out of the temp variable; scale it; then update the PID driver
  710. void copy_and_scalePID_i(int16_t e) {
  711. #if DISABLED(PID_PARAMS_PER_HOTEND) || HOTENDS == 1
  712. UNUSED(e);
  713. #endif
  714. PID_PARAM(Ki, e) = scalePID_i(raw_Ki);
  715. thermalManager.updatePID();
  716. }
  717. void copy_and_scalePID_d(int16_t e) {
  718. #if DISABLED(PID_PARAMS_PER_HOTEND) || HOTENDS == 1
  719. UNUSED(e);
  720. #endif
  721. PID_PARAM(Kd, e) = scalePID_d(raw_Kd);
  722. thermalManager.updatePID();
  723. }
  724. #define _DEFINE_PIDTEMP_BASE_FUNCS(N) \
  725. void copy_and_scalePID_i_E ## N() { copy_and_scalePID_i(N); } \
  726. void copy_and_scalePID_d_E ## N() { copy_and_scalePID_d(N); }
  727. #if ENABLED(PID_AUTOTUNE_MENU)
  728. #define DEFINE_PIDTEMP_FUNCS(N) \
  729. _DEFINE_PIDTEMP_BASE_FUNCS(N); \
  730. void lcd_autotune_callback_E ## N() { _lcd_autotune(N); } typedef void _pid_##N##_void
  731. #else
  732. #define DEFINE_PIDTEMP_FUNCS(N) _DEFINE_PIDTEMP_BASE_FUNCS(N) typedef void _pid_##N##_void
  733. #endif
  734. DEFINE_PIDTEMP_FUNCS(0);
  735. #if ENABLED(PID_PARAMS_PER_HOTEND)
  736. #if HOTENDS > 1
  737. DEFINE_PIDTEMP_FUNCS(1);
  738. #if HOTENDS > 2
  739. DEFINE_PIDTEMP_FUNCS(2);
  740. #if HOTENDS > 3
  741. DEFINE_PIDTEMP_FUNCS(3);
  742. #if HOTENDS > 4
  743. DEFINE_PIDTEMP_FUNCS(4);
  744. #if HOTENDS > 5
  745. DEFINE_PIDTEMP_FUNCS(5);
  746. #endif // HOTENDS > 5
  747. #endif // HOTENDS > 4
  748. #endif // HOTENDS > 3
  749. #endif // HOTENDS > 2
  750. #endif // HOTENDS > 1
  751. #endif // PID_PARAMS_PER_HOTEND
  752. #endif // PIDTEMP
  753. /**
  754. *
  755. * "Advanced Settings" -> "Temperature" submenu
  756. *
  757. */
  758. void menu_advanced_temperature() {
  759. START_MENU();
  760. MENU_BACK(MSG_ADVANCED_SETTINGS);
  761. //
  762. // Autotemp, Min, Max, Fact
  763. //
  764. #if ENABLED(AUTOTEMP) && HAS_TEMP_HOTEND
  765. MENU_ITEM_EDIT(bool, MSG_AUTOTEMP, &planner.autotemp_enabled);
  766. MENU_ITEM_EDIT(float3, MSG_MIN, &planner.autotemp_min, 0, float(HEATER_0_MAXTEMP) - 15);
  767. MENU_ITEM_EDIT(float3, MSG_MAX, &planner.autotemp_max, 0, float(HEATER_0_MAXTEMP) - 15);
  768. MENU_ITEM_EDIT(float52, MSG_FACTOR, &planner.autotemp_factor, 0, 1);
  769. #endif
  770. //
  771. // PID-P, PID-I, PID-D, PID-C, PID Autotune
  772. // PID-P E1, PID-I E1, PID-D E1, PID-C E1, PID Autotune E1
  773. // PID-P E2, PID-I E2, PID-D E2, PID-C E2, PID Autotune E2
  774. // PID-P E3, PID-I E3, PID-D E3, PID-C E3, PID Autotune E3
  775. // PID-P E4, PID-I E4, PID-D E4, PID-C E4, PID Autotune E4
  776. // PID-P E5, PID-I E5, PID-D E5, PID-C E5, PID Autotune E5
  777. //
  778. #if ENABLED(PIDTEMP)
  779. #define _PID_BASE_MENU_ITEMS(ELABEL, eindex) \
  780. raw_Ki = unscalePID_i(PID_PARAM(Ki, eindex)); \
  781. raw_Kd = unscalePID_d(PID_PARAM(Kd, eindex)); \
  782. MENU_ITEM_EDIT(float52sign, MSG_PID_P ELABEL, &PID_PARAM(Kp, eindex), 1, 9990); \
  783. MENU_ITEM_EDIT_CALLBACK(float52sign, MSG_PID_I ELABEL, &raw_Ki, 0.01f, 9990, copy_and_scalePID_i_E ## eindex); \
  784. MENU_ITEM_EDIT_CALLBACK(float52sign, MSG_PID_D ELABEL, &raw_Kd, 1, 9990, copy_and_scalePID_d_E ## eindex)
  785. #if ENABLED(PID_EXTRUSION_SCALING)
  786. #define _PID_MENU_ITEMS(ELABEL, eindex) \
  787. _PID_BASE_MENU_ITEMS(ELABEL, eindex); \
  788. MENU_ITEM_EDIT(float3, MSG_PID_C ELABEL, &PID_PARAM(Kc, eindex), 1, 9990)
  789. #else
  790. #define _PID_MENU_ITEMS(ELABEL, eindex) _PID_BASE_MENU_ITEMS(ELABEL, eindex)
  791. #endif
  792. #if ENABLED(PID_AUTOTUNE_MENU)
  793. #define PID_MENU_ITEMS(ELABEL, eindex) \
  794. _PID_MENU_ITEMS(ELABEL, eindex); \
  795. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_PID_AUTOTUNE ELABEL, &autotune_temp[eindex], 150, heater_maxtemp[eindex] - 15, lcd_autotune_callback_E ## eindex)
  796. #else
  797. #define PID_MENU_ITEMS(ELABEL, eindex) _PID_MENU_ITEMS(ELABEL, eindex)
  798. #endif
  799. #if ENABLED(PID_PARAMS_PER_HOTEND) && HOTENDS > 1
  800. PID_MENU_ITEMS(" " MSG_E1, 0);
  801. PID_MENU_ITEMS(" " MSG_E2, 1);
  802. #if HOTENDS > 2
  803. PID_MENU_ITEMS(" " MSG_E3, 2);
  804. #if HOTENDS > 3
  805. PID_MENU_ITEMS(" " MSG_E4, 3);
  806. #if HOTENDS > 4
  807. PID_MENU_ITEMS(" " MSG_E5, 4);
  808. #if HOTENDS > 5
  809. PID_MENU_ITEMS(" " MSG_E6, 5);
  810. #endif // HOTENDS > 5
  811. #endif // HOTENDS > 4
  812. #endif // HOTENDS > 3
  813. #endif // HOTENDS > 2
  814. #else // !PID_PARAMS_PER_HOTEND || HOTENDS == 1
  815. PID_MENU_ITEMS("", 0);
  816. #endif // !PID_PARAMS_PER_HOTEND || HOTENDS == 1
  817. #endif // PIDTEMP
  818. END_MENU();
  819. }
  820. #if DISABLED(SLIM_LCD_MENUS)
  821. void _reset_acceleration_rates() { planner.reset_acceleration_rates(); }
  822. #if ENABLED(DISTINCT_E_FACTORS)
  823. void _reset_e_acceleration_rate(const uint8_t e) { if (e == active_extruder) _reset_acceleration_rates(); }
  824. void _reset_e0_acceleration_rate() { _reset_e_acceleration_rate(0); }
  825. void _reset_e1_acceleration_rate() { _reset_e_acceleration_rate(1); }
  826. #if E_STEPPERS > 2
  827. void _reset_e2_acceleration_rate() { _reset_e_acceleration_rate(2); }
  828. #if E_STEPPERS > 3
  829. void _reset_e3_acceleration_rate() { _reset_e_acceleration_rate(3); }
  830. #if E_STEPPERS > 4
  831. void _reset_e4_acceleration_rate() { _reset_e_acceleration_rate(4); }
  832. #if E_STEPPERS > 5
  833. void _reset_e5_acceleration_rate() { _reset_e_acceleration_rate(5); }
  834. #endif // E_STEPPERS > 5
  835. #endif // E_STEPPERS > 4
  836. #endif // E_STEPPERS > 3
  837. #endif // E_STEPPERS > 2
  838. #endif
  839. void _planner_refresh_positioning() { planner.refresh_positioning(); }
  840. #if ENABLED(DISTINCT_E_FACTORS)
  841. void _planner_refresh_e_positioning(const uint8_t e) {
  842. if (e == active_extruder)
  843. _planner_refresh_positioning();
  844. else
  845. planner.steps_to_mm[E_AXIS + e] = 1.0f / planner.settings.axis_steps_per_mm[E_AXIS + e];
  846. }
  847. void _planner_refresh_e0_positioning() { _planner_refresh_e_positioning(0); }
  848. void _planner_refresh_e1_positioning() { _planner_refresh_e_positioning(1); }
  849. #if E_STEPPERS > 2
  850. void _planner_refresh_e2_positioning() { _planner_refresh_e_positioning(2); }
  851. #if E_STEPPERS > 3
  852. void _planner_refresh_e3_positioning() { _planner_refresh_e_positioning(3); }
  853. #if E_STEPPERS > 4
  854. void _planner_refresh_e4_positioning() { _planner_refresh_e_positioning(4); }
  855. #if E_STEPPERS > 5
  856. void _planner_refresh_e5_positioning() { _planner_refresh_e_positioning(5); }
  857. #endif // E_STEPPERS > 5
  858. #endif // E_STEPPERS > 4
  859. #endif // E_STEPPERS > 3
  860. #endif // E_STEPPERS > 2
  861. #endif
  862. // M203 / M205 Velocity options
  863. void menu_advanced_velocity() {
  864. START_MENU();
  865. MENU_BACK(MSG_ADVANCED_SETTINGS);
  866. // M203 Max Feedrate
  867. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_A, &planner.settings.max_feedrate_mm_s[A_AXIS], 1, 999);
  868. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_B, &planner.settings.max_feedrate_mm_s[B_AXIS], 1, 999);
  869. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_C, &planner.settings.max_feedrate_mm_s[C_AXIS], 1, 999);
  870. #if ENABLED(DISTINCT_E_FACTORS)
  871. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_E, &planner.settings.max_feedrate_mm_s[E_AXIS + active_extruder], 1, 999);
  872. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_E1, &planner.settings.max_feedrate_mm_s[E_AXIS], 1, 999);
  873. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_E2, &planner.settings.max_feedrate_mm_s[E_AXIS + 1], 1, 999);
  874. #if E_STEPPERS > 2
  875. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_E3, &planner.settings.max_feedrate_mm_s[E_AXIS + 2], 1, 999);
  876. #if E_STEPPERS > 3
  877. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_E4, &planner.settings.max_feedrate_mm_s[E_AXIS + 3], 1, 999);
  878. #if E_STEPPERS > 4
  879. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_E5, &planner.settings.max_feedrate_mm_s[E_AXIS + 4], 1, 999);
  880. #if E_STEPPERS > 5
  881. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_E6, &planner.settings.max_feedrate_mm_s[E_AXIS + 5], 1, 999);
  882. #endif // E_STEPPERS > 5
  883. #endif // E_STEPPERS > 4
  884. #endif // E_STEPPERS > 3
  885. #endif // E_STEPPERS > 2
  886. #else
  887. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_E, &planner.settings.max_feedrate_mm_s[E_AXIS], 1, 999);
  888. #endif
  889. // M205 S Min Feedrate
  890. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMIN, &planner.settings.min_feedrate_mm_s, 0, 999);
  891. // M205 T Min Travel Feedrate
  892. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VTRAV_MIN, &planner.settings.min_travel_feedrate_mm_s, 0, 999);
  893. END_MENU();
  894. }
  895. // M201 / M204 Accelerations
  896. void menu_advanced_acceleration() {
  897. START_MENU();
  898. MENU_BACK(MSG_ADVANCED_SETTINGS);
  899. // M204 P Acceleration
  900. MENU_MULTIPLIER_ITEM_EDIT(float5, MSG_ACC, &planner.settings.acceleration, 10, 99000);
  901. // M204 R Retract Acceleration
  902. MENU_MULTIPLIER_ITEM_EDIT(float5, MSG_A_RETRACT, &planner.settings.retract_acceleration, 100, 99000);
  903. // M204 T Travel Acceleration
  904. MENU_MULTIPLIER_ITEM_EDIT(float5, MSG_A_TRAVEL, &planner.settings.travel_acceleration, 100, 99000);
  905. // M201 settings
  906. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_A, &planner.settings.max_acceleration_mm_per_s2[A_AXIS], 100, 99000, _reset_acceleration_rates);
  907. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_B, &planner.settings.max_acceleration_mm_per_s2[B_AXIS], 100, 99000, _reset_acceleration_rates);
  908. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_C, &planner.settings.max_acceleration_mm_per_s2[C_AXIS], 10, 99000, _reset_acceleration_rates);
  909. #if ENABLED(DISTINCT_E_FACTORS)
  910. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_E, &planner.settings.max_acceleration_mm_per_s2[E_AXIS + active_extruder], 100, 99000, _reset_acceleration_rates);
  911. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_E1, &planner.settings.max_acceleration_mm_per_s2[E_AXIS], 100, 99000, _reset_e0_acceleration_rate);
  912. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_E2, &planner.settings.max_acceleration_mm_per_s2[E_AXIS + 1], 100, 99000, _reset_e1_acceleration_rate);
  913. #if E_STEPPERS > 2
  914. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_E3, &planner.settings.max_acceleration_mm_per_s2[E_AXIS + 2], 100, 99000, _reset_e2_acceleration_rate);
  915. #if E_STEPPERS > 3
  916. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_E4, &planner.settings.max_acceleration_mm_per_s2[E_AXIS + 3], 100, 99000, _reset_e3_acceleration_rate);
  917. #if E_STEPPERS > 4
  918. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_E5, &planner.settings.max_acceleration_mm_per_s2[E_AXIS + 4], 100, 99000, _reset_e4_acceleration_rate);
  919. #if E_STEPPERS > 5
  920. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_E6, &planner.settings.max_acceleration_mm_per_s2[E_AXIS + 5], 100, 99000, _reset_e5_acceleration_rate);
  921. #endif // E_STEPPERS > 5
  922. #endif // E_STEPPERS > 4
  923. #endif // E_STEPPERS > 3
  924. #endif // E_STEPPERS > 2
  925. #else
  926. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_E, &planner.settings.max_acceleration_mm_per_s2[E_AXIS], 100, 99000, _reset_acceleration_rates);
  927. #endif
  928. END_MENU();
  929. }
  930. // M205 Jerk
  931. void menu_advanced_jerk() {
  932. START_MENU();
  933. MENU_BACK(MSG_ADVANCED_SETTINGS);
  934. #if ENABLED(JUNCTION_DEVIATION)
  935. #if ENABLED(LIN_ADVANCE)
  936. MENU_ITEM_EDIT_CALLBACK(float43, MSG_JUNCTION_DEVIATION, &planner.junction_deviation_mm, 0.01f, 0.3f, planner.recalculate_max_e_jerk);
  937. #else
  938. MENU_ITEM_EDIT(float43, MSG_JUNCTION_DEVIATION, &planner.junction_deviation_mm, 0.01f, 0.3f);
  939. #endif
  940. #endif
  941. #if HAS_CLASSIC_JERK
  942. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VA_JERK, &planner.max_jerk[A_AXIS], 1, 990);
  943. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VB_JERK, &planner.max_jerk[B_AXIS], 1, 990);
  944. #if ENABLED(DELTA)
  945. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VC_JERK, &planner.max_jerk[C_AXIS], 1, 990);
  946. #else
  947. MENU_MULTIPLIER_ITEM_EDIT(float52sign, MSG_VC_JERK, &planner.max_jerk[C_AXIS], 0.1f, 990);
  948. #endif
  949. #if DISABLED(JUNCTION_DEVIATION) || DISABLED(LIN_ADVANCE)
  950. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VE_JERK, &planner.max_jerk[E_AXIS], 1, 990);
  951. #endif
  952. #endif
  953. END_MENU();
  954. }
  955. // M92 Steps-per-mm
  956. void menu_advanced_steps_per_mm() {
  957. START_MENU();
  958. MENU_BACK(MSG_ADVANCED_SETTINGS);
  959. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_ASTEPS, &planner.settings.axis_steps_per_mm[A_AXIS], 5, 9999, _planner_refresh_positioning);
  960. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_BSTEPS, &planner.settings.axis_steps_per_mm[B_AXIS], 5, 9999, _planner_refresh_positioning);
  961. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_CSTEPS, &planner.settings.axis_steps_per_mm[C_AXIS], 5, 9999, _planner_refresh_positioning);
  962. #if ENABLED(DISTINCT_E_FACTORS)
  963. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_ESTEPS, &planner.settings.axis_steps_per_mm[E_AXIS + active_extruder], 5, 9999, _planner_refresh_positioning);
  964. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_E1STEPS, &planner.settings.axis_steps_per_mm[E_AXIS], 5, 9999, _planner_refresh_e0_positioning);
  965. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_E2STEPS, &planner.settings.axis_steps_per_mm[E_AXIS + 1], 5, 9999, _planner_refresh_e1_positioning);
  966. #if E_STEPPERS > 2
  967. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_E3STEPS, &planner.settings.axis_steps_per_mm[E_AXIS + 2], 5, 9999, _planner_refresh_e2_positioning);
  968. #if E_STEPPERS > 3
  969. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_E4STEPS, &planner.settings.axis_steps_per_mm[E_AXIS + 3], 5, 9999, _planner_refresh_e3_positioning);
  970. #if E_STEPPERS > 4
  971. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_E5STEPS, &planner.settings.axis_steps_per_mm[E_AXIS + 4], 5, 9999, _planner_refresh_e4_positioning);
  972. #if E_STEPPERS > 5
  973. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_E6STEPS, &planner.settings.axis_steps_per_mm[E_AXIS + 5], 5, 9999, _planner_refresh_e5_positioning);
  974. #endif // E_STEPPERS > 5
  975. #endif // E_STEPPERS > 4
  976. #endif // E_STEPPERS > 3
  977. #endif // E_STEPPERS > 2
  978. #else
  979. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_ESTEPS, &planner.settings.axis_steps_per_mm[E_AXIS], 5, 9999, _planner_refresh_positioning);
  980. #endif
  981. END_MENU();
  982. }
  983. #endif // !SLIM_LCD_MENUS
  984. /**
  985. *
  986. * "Advanced Settings" submenu
  987. *
  988. */
  989. #if HAS_M206_COMMAND
  990. /**
  991. * Set the home offset based on the current_position
  992. */
  993. void lcd_set_home_offsets() {
  994. // M428 Command
  995. enqueue_and_echo_commands_P(PSTR("M428"));
  996. lcd_return_to_status();
  997. }
  998. #endif
  999. #if ENABLED(SD_FIRMWARE_UPDATE)
  1000. /**
  1001. * Toggle the SD Firmware Update state in EEPROM
  1002. */
  1003. static void _lcd_toggle_sd_update() {
  1004. const bool new_state = !settings.sd_update_status();
  1005. lcd_completion_feedback(settings.set_sd_update_status(new_state));
  1006. lcd_return_to_status();
  1007. if (new_state) LCD_MESSAGEPGM(MSG_RESET_PRINTER); else lcd_reset_status();
  1008. }
  1009. #endif
  1010. void menu_advanced_settings() {
  1011. START_MENU();
  1012. MENU_BACK(MSG_CONFIGURATION);
  1013. #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
  1014. MENU_ITEM(submenu, MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset);
  1015. #elif HAS_BED_PROBE
  1016. MENU_ITEM_EDIT(float52, MSG_ZPROBE_ZOFFSET, &zprobe_zoffset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
  1017. #endif
  1018. #if DISABLED(SLIM_LCD_MENUS)
  1019. #if HAS_M206_COMMAND
  1020. //
  1021. // Set Home Offsets
  1022. //
  1023. MENU_ITEM(function, MSG_SET_HOME_OFFSETS, lcd_set_home_offsets);
  1024. #endif
  1025. // M203 / M205 - Feedrate items
  1026. MENU_ITEM(submenu, MSG_VELOCITY, menu_advanced_velocity);
  1027. // M201 - Acceleration items
  1028. MENU_ITEM(submenu, MSG_ACCELERATION, menu_advanced_acceleration);
  1029. // M205 - Max Jerk
  1030. MENU_ITEM(submenu, MSG_JERK, menu_advanced_jerk);
  1031. if (!printer_busy()) {
  1032. // M92 - Steps Per mm
  1033. MENU_ITEM(submenu, MSG_STEPS_PER_MM, menu_advanced_steps_per_mm);
  1034. }
  1035. #endif // !SLIM_LCD_MENUS
  1036. MENU_ITEM(submenu, MSG_TEMPERATURE, menu_advanced_temperature);
  1037. #if DISABLED(NO_VOLUMETRICS) || ENABLED(ADVANCED_PAUSE_FEATURE)
  1038. MENU_ITEM(submenu, MSG_FILAMENT, menu_advanced_filament);
  1039. #elif ENABLED(LIN_ADVANCE)
  1040. #if EXTRUDERS == 1
  1041. MENU_ITEM_EDIT(float52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 999);
  1042. #elif EXTRUDERS > 1
  1043. MENU_ITEM_EDIT(float52, MSG_ADVANCE_K MSG_E1, &planner.extruder_advance_K[0], 0, 999);
  1044. MENU_ITEM_EDIT(float52, MSG_ADVANCE_K MSG_E2, &planner.extruder_advance_K[1], 0, 999);
  1045. #if EXTRUDERS > 2
  1046. MENU_ITEM_EDIT(float52, MSG_ADVANCE_K MSG_E3, &planner.extruder_advance_K[2], 0, 999);
  1047. #if EXTRUDERS > 3
  1048. MENU_ITEM_EDIT(float52, MSG_ADVANCE_K MSG_E4, &planner.extruder_advance_K[3], 0, 999);
  1049. #if EXTRUDERS > 4
  1050. MENU_ITEM_EDIT(float52, MSG_ADVANCE_K MSG_E5, &planner.extruder_advance_K[4], 0, 999);
  1051. #if EXTRUDERS > 5
  1052. MENU_ITEM_EDIT(float52, MSG_ADVANCE_K MSG_E6, &planner.extruder_advance_K[5], 0, 999);
  1053. #endif // EXTRUDERS > 5
  1054. #endif // EXTRUDERS > 4
  1055. #endif // EXTRUDERS > 3
  1056. #endif // EXTRUDERS > 2
  1057. #endif // EXTRUDERS > 1
  1058. #endif
  1059. // M540 S - Abort on endstop hit when SD printing
  1060. #if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
  1061. MENU_ITEM_EDIT(bool, MSG_ENDSTOP_ABORT, &planner.abort_on_endstop_hit);
  1062. #endif
  1063. //
  1064. // BLTouch Self-Test and Reset
  1065. //
  1066. #if ENABLED(BLTOUCH)
  1067. MENU_ITEM(gcode, MSG_BLTOUCH_SELFTEST, PSTR("M280 P" STRINGIFY(Z_PROBE_SERVO_NR) " S" STRINGIFY(BLTOUCH_SELFTEST)));
  1068. if (!endstops.z_probe_enabled && TEST_BLTOUCH())
  1069. MENU_ITEM(gcode, MSG_BLTOUCH_RESET, PSTR("M280 P" STRINGIFY(Z_PROBE_SERVO_NR) " S" STRINGIFY(BLTOUCH_RESET)));
  1070. #endif
  1071. #if ENABLED(SD_FIRMWARE_UPDATE)
  1072. bool sd_update_state = settings.sd_update_status();
  1073. MENU_ITEM_EDIT_CALLBACK(bool, MSG_SD_UPDATE, &sd_update_state, _lcd_toggle_sd_update);
  1074. #endif
  1075. #if ENABLED(EEPROM_SETTINGS) && DISABLED(SLIM_LCD_MENUS)
  1076. MENU_ITEM(submenu, MSG_INIT_EEPROM, lcd_init_eeprom_confirm);
  1077. #endif
  1078. END_MENU();
  1079. }
  1080. #if DISABLED(NO_VOLUMETRICS) || ENABLED(ADVANCED_PAUSE_FEATURE)
  1081. /**
  1082. *
  1083. * "Advanced Settings" > "Filament" submenu
  1084. *
  1085. */
  1086. void menu_advanced_filament() {
  1087. START_MENU();
  1088. MENU_BACK(MSG_ADVANCED_SETTINGS);
  1089. #if ENABLED(LIN_ADVANCE)
  1090. #if EXTRUDERS == 1
  1091. MENU_ITEM_EDIT(float52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 999);
  1092. #elif EXTRUDERS > 1
  1093. MENU_ITEM_EDIT(float52, MSG_ADVANCE_K MSG_E1, &planner.extruder_advance_K[0], 0, 999);
  1094. MENU_ITEM_EDIT(float52, MSG_ADVANCE_K MSG_E2, &planner.extruder_advance_K[1], 0, 999);
  1095. #if EXTRUDERS > 2
  1096. MENU_ITEM_EDIT(float52, MSG_ADVANCE_K MSG_E3, &planner.extruder_advance_K[2], 0, 999);
  1097. #if EXTRUDERS > 3
  1098. MENU_ITEM_EDIT(float52, MSG_ADVANCE_K MSG_E4, &planner.extruder_advance_K[3], 0, 999);
  1099. #if EXTRUDERS > 4
  1100. MENU_ITEM_EDIT(float52, MSG_ADVANCE_K MSG_E5, &planner.extruder_advance_K[4], 0, 999);
  1101. #if EXTRUDERS > 5
  1102. MENU_ITEM_EDIT(float52, MSG_ADVANCE_K MSG_E6, &planner.extruder_advance_K[5], 0, 999);
  1103. #endif // EXTRUDERS > 5
  1104. #endif // EXTRUDERS > 4
  1105. #endif // EXTRUDERS > 3
  1106. #endif // EXTRUDERS > 2
  1107. #endif // EXTRUDERS > 1
  1108. #endif
  1109. #if DISABLED(NO_VOLUMETRICS)
  1110. MENU_ITEM_EDIT_CALLBACK(bool, MSG_VOLUMETRIC_ENABLED, &parser.volumetric_enabled, planner.calculate_volumetric_multipliers);
  1111. if (parser.volumetric_enabled) {
  1112. #if EXTRUDERS == 1
  1113. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM, &planner.filament_size[0], 1.5f, 3.25f, planner.calculate_volumetric_multipliers);
  1114. #else // EXTRUDERS > 1
  1115. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM, &planner.filament_size[active_extruder], 1.5f, 3.25f, planner.calculate_volumetric_multipliers);
  1116. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E1, &planner.filament_size[0], 1.5f, 3.25f, planner.calculate_volumetric_multipliers);
  1117. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E2, &planner.filament_size[1], 1.5f, 3.25f, planner.calculate_volumetric_multipliers);
  1118. #if EXTRUDERS > 2
  1119. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E3, &planner.filament_size[2], 1.5f, 3.25f, planner.calculate_volumetric_multipliers);
  1120. #if EXTRUDERS > 3
  1121. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E4, &planner.filament_size[3], 1.5f, 3.25f, planner.calculate_volumetric_multipliers);
  1122. #if EXTRUDERS > 4
  1123. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E5, &planner.filament_size[4], 1.5f, 3.25f, planner.calculate_volumetric_multipliers);
  1124. #if EXTRUDERS > 5
  1125. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E6, &planner.filament_size[5], 1.5f, 3.25f, planner.calculate_volumetric_multipliers);
  1126. #endif // EXTRUDERS > 5
  1127. #endif // EXTRUDERS > 4
  1128. #endif // EXTRUDERS > 3
  1129. #endif // EXTRUDERS > 2
  1130. #endif // EXTRUDERS > 1
  1131. }
  1132. #endif
  1133. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  1134. constexpr float extrude_maxlength =
  1135. #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
  1136. EXTRUDE_MAXLENGTH
  1137. #else
  1138. 999
  1139. #endif
  1140. ;
  1141. #if EXTRUDERS == 1
  1142. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD, &fc_settings[0].unload_length, 0, extrude_maxlength);
  1143. #else // EXTRUDERS > 1
  1144. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD, &fc_settings[active_extruder].unload_length, 0, extrude_maxlength);
  1145. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD MSG_DIAM_E1, &fc_settings[0].unload_length, 0, extrude_maxlength);
  1146. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD MSG_DIAM_E2, &fc_settings[1].unload_length, 0, extrude_maxlength);
  1147. #if EXTRUDERS > 2
  1148. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD MSG_DIAM_E3, &fc_settings[2].unload_length, 0, extrude_maxlength);
  1149. #if EXTRUDERS > 3
  1150. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD MSG_DIAM_E4, &fc_settings[3].unload_length, 0, extrude_maxlength);
  1151. #if EXTRUDERS > 4
  1152. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD MSG_DIAM_E5, &fc_settings[4].unload_length, 0, extrude_maxlength);
  1153. #if EXTRUDERS > 5
  1154. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD MSG_DIAM_E6, &fc_settings[5].unload_length, 0, extrude_maxlength);
  1155. #endif // EXTRUDERS > 5
  1156. #endif // EXTRUDERS > 4
  1157. #endif // EXTRUDERS > 3
  1158. #endif // EXTRUDERS > 2
  1159. #endif // EXTRUDERS > 1
  1160. #if EXTRUDERS == 1
  1161. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD, &fc_settings[0].load_length, 0, extrude_maxlength);
  1162. #else // EXTRUDERS > 1
  1163. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD, &fc_settings[active_extruder].load_length, 0, extrude_maxlength);
  1164. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD MSG_DIAM_E1, &fc_settings[0].load_length, 0, extrude_maxlength);
  1165. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD MSG_DIAM_E2, &fc_settings[1].load_length, 0, extrude_maxlength);
  1166. #if EXTRUDERS > 2
  1167. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD MSG_DIAM_E3, &fc_settings[2].load_length, 0, extrude_maxlength);
  1168. #if EXTRUDERS > 3
  1169. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD MSG_DIAM_E4, &fc_settings[3].load_length, 0, extrude_maxlength);
  1170. #if EXTRUDERS > 4
  1171. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD MSG_DIAM_E5, &fc_settings[4].load_length, 0, extrude_maxlength);
  1172. #if EXTRUDERS > 5
  1173. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD MSG_DIAM_E6, &fc_settings[5].load_length, 0, extrude_maxlength);
  1174. #endif // EXTRUDERS > 5
  1175. #endif // EXTRUDERS > 4
  1176. #endif // EXTRUDERS > 3
  1177. #endif // EXTRUDERS > 2
  1178. #endif // EXTRUDERS > 1
  1179. #endif
  1180. END_MENU();
  1181. }
  1182. #endif // !NO_VOLUMETRICS || ADVANCED_PAUSE_FEATURE
  1183. #if ENABLED(SDSUPPORT)
  1184. #if !PIN_EXISTS(SD_DETECT)
  1185. void lcd_sd_refresh() {
  1186. card.initsd();
  1187. encoderTopLine = 0;
  1188. }
  1189. #endif
  1190. void lcd_sd_updir() {
  1191. encoderPosition = card.updir() ? ENCODER_STEPS_PER_MENU_ITEM : 0;
  1192. encoderTopLine = 0;
  1193. screen_changed = true;
  1194. lcd_refresh();
  1195. }
  1196. /**
  1197. *
  1198. * "Print from SD" submenu
  1199. *
  1200. */
  1201. #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
  1202. uint32_t last_sdfile_encoderPosition = 0xFFFF;
  1203. void lcd_reselect_last_file() {
  1204. if (last_sdfile_encoderPosition == 0xFFFF) return;
  1205. #if HAS_GRAPHICAL_LCD
  1206. // Some of this is a hack to force the screen update to work.
  1207. // TODO: Fix the real issue that causes this!
  1208. lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
  1209. lcd_synchronize();
  1210. safe_delay(50);
  1211. lcd_synchronize();
  1212. lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
  1213. drawing_screen = screen_changed = true;
  1214. #endif
  1215. lcd_goto_screen(menu_sdcard, last_sdfile_encoderPosition);
  1216. defer_return_to_status = true;
  1217. last_sdfile_encoderPosition = 0xFFFF;
  1218. #if HAS_GRAPHICAL_LCD
  1219. lcd_update();
  1220. #endif
  1221. }
  1222. #endif
  1223. void menu_sdcard() {
  1224. ENCODER_DIRECTION_MENUS();
  1225. const uint16_t fileCnt = card.get_num_Files();
  1226. START_MENU();
  1227. MENU_BACK(MSG_MAIN);
  1228. card.getWorkDirName();
  1229. if (card.filename[0] == '/') {
  1230. #if !PIN_EXISTS(SD_DETECT)
  1231. MENU_ITEM(function, LCD_STR_REFRESH MSG_REFRESH, lcd_sd_refresh);
  1232. #endif
  1233. }
  1234. else {
  1235. MENU_ITEM(function, LCD_STR_FOLDER "..", lcd_sd_updir);
  1236. }
  1237. for (uint16_t i = 0; i < fileCnt; i++) {
  1238. if (_menuLineNr == _thisItemNr) {
  1239. const uint16_t nr =
  1240. #if ENABLED(SDCARD_RATHERRECENTFIRST) && DISABLED(SDCARD_SORT_ALPHA)
  1241. fileCnt - 1 -
  1242. #endif
  1243. i;
  1244. #if ENABLED(SDCARD_SORT_ALPHA)
  1245. card.getfilename_sorted(nr);
  1246. #else
  1247. card.getfilename(nr);
  1248. #endif
  1249. if (card.filenameIsDir)
  1250. MENU_ITEM(sddirectory, MSG_CARD_MENU, card);
  1251. else
  1252. MENU_ITEM(sdfile, MSG_CARD_MENU, card);
  1253. }
  1254. else {
  1255. MENU_ITEM_DUMMY();
  1256. }
  1257. }
  1258. END_MENU();
  1259. }
  1260. #endif // SDSUPPORT
  1261. /**
  1262. *
  1263. * LED Menu
  1264. *
  1265. */
  1266. #if ENABLED(LED_CONTROL_MENU)
  1267. #if ENABLED(LED_COLOR_PRESETS)
  1268. void menu_led_presets() {
  1269. START_MENU();
  1270. #if LCD_HEIGHT > 2
  1271. STATIC_ITEM(MSG_LED_PRESETS, true, true);
  1272. #endif
  1273. MENU_BACK(MSG_LED_CONTROL);
  1274. MENU_ITEM(function, MSG_SET_LEDS_WHITE, leds.set_white);
  1275. MENU_ITEM(function, MSG_SET_LEDS_RED, leds.set_red);
  1276. MENU_ITEM(function, MSG_SET_LEDS_ORANGE, leds.set_orange);
  1277. MENU_ITEM(function, MSG_SET_LEDS_YELLOW,leds.set_yellow);
  1278. MENU_ITEM(function, MSG_SET_LEDS_GREEN, leds.set_green);
  1279. MENU_ITEM(function, MSG_SET_LEDS_BLUE, leds.set_blue);
  1280. MENU_ITEM(function, MSG_SET_LEDS_INDIGO, leds.set_indigo);
  1281. MENU_ITEM(function, MSG_SET_LEDS_VIOLET, leds.set_violet);
  1282. END_MENU();
  1283. }
  1284. #endif // LED_COLOR_PRESETS
  1285. void menu_led_custom() {
  1286. START_MENU();
  1287. MENU_BACK(MSG_LED_CONTROL);
  1288. MENU_ITEM_EDIT_CALLBACK(int8, MSG_INTENSITY_R, &leds.color.r, 0, 255, leds.update, true);
  1289. MENU_ITEM_EDIT_CALLBACK(int8, MSG_INTENSITY_G, &leds.color.g, 0, 255, leds.update, true);
  1290. MENU_ITEM_EDIT_CALLBACK(int8, MSG_INTENSITY_B, &leds.color.b, 0, 255, leds.update, true);
  1291. #if ENABLED(RGBW_LED) || ENABLED(NEOPIXEL_LED)
  1292. MENU_ITEM_EDIT_CALLBACK(int8, MSG_INTENSITY_W, &leds.color.w, 0, 255, leds.update, true);
  1293. #if ENABLED(NEOPIXEL_LED)
  1294. MENU_ITEM_EDIT_CALLBACK(int8, MSG_LED_BRIGHTNESS, &leds.color.i, 0, 255, leds.update, true);
  1295. #endif
  1296. #endif
  1297. END_MENU();
  1298. }
  1299. void menu_led() {
  1300. START_MENU();
  1301. MENU_BACK(MSG_MAIN);
  1302. bool led_on = leds.lights_on;
  1303. MENU_ITEM_EDIT_CALLBACK(bool, MSG_LEDS, &led_on, leds.toggle);
  1304. MENU_ITEM(function, MSG_SET_LEDS_DEFAULT, leds.set_default);
  1305. #if ENABLED(LED_COLOR_PRESETS)
  1306. MENU_ITEM(submenu, MSG_LED_PRESETS, menu_led_presets);
  1307. #endif
  1308. MENU_ITEM(submenu, MSG_CUSTOM_LEDS, menu_led_custom);
  1309. END_MENU();
  1310. }
  1311. #endif // LED_CONTROL_MENU
  1312. /**
  1313. *
  1314. * Filament Change Feature Screens
  1315. *
  1316. */
  1317. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  1318. /**
  1319. *
  1320. * "Change Filament" > "Change/Unload/Load Filament" submenu
  1321. *
  1322. */
  1323. static AdvancedPauseMode _change_filament_temp_mode; // =ADVANCED_PAUSE_MODE_PAUSE_PRINT
  1324. static int8_t _change_filament_temp_extruder; // =0
  1325. static PGM_P _change_filament_temp_command() {
  1326. switch (_change_filament_temp_mode) {
  1327. case ADVANCED_PAUSE_MODE_LOAD_FILAMENT:
  1328. return PSTR("M701 T%d");
  1329. case ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT:
  1330. return _change_filament_temp_extruder >= 0 ? PSTR("M702 T%d") : PSTR("M702 ;%d");
  1331. case ADVANCED_PAUSE_MODE_PAUSE_PRINT:
  1332. default:
  1333. return PSTR("M600 B0 T%d");
  1334. }
  1335. return PSTR(MSG_FILAMENTCHANGE);
  1336. }
  1337. void _change_filament_temp(const uint16_t temperature) {
  1338. char cmd[11];
  1339. sprintf_P(cmd, _change_filament_temp_command(), _change_filament_temp_extruder);
  1340. thermalManager.setTargetHotend(temperature, _change_filament_temp_extruder);
  1341. lcd_enqueue_command(cmd);
  1342. }
  1343. void _menu_change_filament_temp_1() { _change_filament_temp(PREHEAT_1_TEMP_HOTEND); }
  1344. void _menu_change_filament_temp_2() { _change_filament_temp(PREHEAT_2_TEMP_HOTEND); }
  1345. void _menu_change_filament_temp_custom() { _change_filament_temp(thermalManager.target_temperature[_change_filament_temp_extruder]); }
  1346. static PGM_P change_filament_header(const AdvancedPauseMode mode) {
  1347. switch (mode) {
  1348. case ADVANCED_PAUSE_MODE_LOAD_FILAMENT:
  1349. return PSTR(MSG_FILAMENTLOAD);
  1350. case ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT:
  1351. return PSTR(MSG_FILAMENTUNLOAD);
  1352. default: break;
  1353. }
  1354. return PSTR(MSG_FILAMENTCHANGE);
  1355. }
  1356. void _menu_temp_filament_op(const AdvancedPauseMode mode, const int8_t extruder) {
  1357. _change_filament_temp_mode = mode;
  1358. _change_filament_temp_extruder = extruder;
  1359. START_MENU();
  1360. if (LCD_HEIGHT >= 4) STATIC_ITEM_P(change_filament_header(mode), true, true);
  1361. MENU_BACK(MSG_BACK);
  1362. MENU_ITEM(submenu, MSG_PREHEAT_1, _menu_change_filament_temp_1);
  1363. MENU_ITEM(submenu, MSG_PREHEAT_2, _menu_change_filament_temp_2);
  1364. uint16_t max_temp;
  1365. switch (extruder) {
  1366. default: max_temp = HEATER_0_MAXTEMP;
  1367. #if HOTENDS > 1
  1368. case 1: max_temp = HEATER_1_MAXTEMP; break;
  1369. #if HOTENDS > 2
  1370. case 2: max_temp = HEATER_2_MAXTEMP; break;
  1371. #if HOTENDS > 3
  1372. case 3: max_temp = HEATER_3_MAXTEMP; break;
  1373. #if HOTENDS > 4
  1374. case 4: max_temp = HEATER_4_MAXTEMP; break;
  1375. #if HOTENDS > 5
  1376. case 5: max_temp = HEATER_5_MAXTEMP; break;
  1377. #endif
  1378. #endif
  1379. #endif
  1380. #endif
  1381. #endif
  1382. }
  1383. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_PREHEAT_CUSTOM, &thermalManager.target_temperature[_change_filament_temp_extruder], EXTRUDE_MINTEMP, max_temp - 15, _menu_change_filament_temp_custom);
  1384. END_MENU();
  1385. }
  1386. void menu_temp_e0_filament_change() { _menu_temp_filament_op(ADVANCED_PAUSE_MODE_PAUSE_PRINT, 0); }
  1387. void menu_temp_e0_filament_load() { _menu_temp_filament_op(ADVANCED_PAUSE_MODE_LOAD_FILAMENT, 0); }
  1388. void menu_temp_e0_filament_unload() { _menu_temp_filament_op(ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT, 0); }
  1389. #if E_STEPPERS > 1
  1390. void menu_temp_e1_filament_change() { _menu_temp_filament_op(ADVANCED_PAUSE_MODE_PAUSE_PRINT, 1); }
  1391. void menu_temp_e1_filament_load() { _menu_temp_filament_op(ADVANCED_PAUSE_MODE_LOAD_FILAMENT, 1); }
  1392. void menu_temp_e1_filament_unload() { _menu_temp_filament_op(ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT, 1); }
  1393. #if ENABLED(FILAMENT_UNLOAD_ALL_EXTRUDERS)
  1394. void menu_unload_filament_all_temp() { _menu_temp_filament_op(ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT, -1); }
  1395. #endif
  1396. #if E_STEPPERS > 2
  1397. void menu_temp_e2_filament_change() { _menu_temp_filament_op(ADVANCED_PAUSE_MODE_PAUSE_PRINT, 2); }
  1398. void menu_temp_e2_filament_load() { _menu_temp_filament_op(ADVANCED_PAUSE_MODE_LOAD_FILAMENT, 2); }
  1399. void menu_temp_e2_filament_unload() { _menu_temp_filament_op(ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT, 2); }
  1400. #if E_STEPPERS > 3
  1401. void menu_temp_e3_filament_change() { _menu_temp_filament_op(ADVANCED_PAUSE_MODE_PAUSE_PRINT, 3); }
  1402. void menu_temp_e3_filament_load() { _menu_temp_filament_op(ADVANCED_PAUSE_MODE_LOAD_FILAMENT, 3); }
  1403. void menu_temp_e3_filament_unload() { _menu_temp_filament_op(ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT, 3); }
  1404. #if E_STEPPERS > 4
  1405. void menu_temp_e4_filament_change() { _menu_temp_filament_op(ADVANCED_PAUSE_MODE_PAUSE_PRINT, 4); }
  1406. void menu_temp_e4_filament_load() { _menu_temp_filament_op(ADVANCED_PAUSE_MODE_LOAD_FILAMENT, 4); }
  1407. void menu_temp_e4_filament_unload() { _menu_temp_filament_op(ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT, 4); }
  1408. #endif // E_STEPPERS > 4
  1409. #endif // E_STEPPERS > 3
  1410. #endif // E_STEPPERS > 2
  1411. #endif // E_STEPPERS > 1
  1412. /**
  1413. *
  1414. * "Change Filament" submenu
  1415. *
  1416. */
  1417. #if E_STEPPERS > 1 || ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
  1418. void menu_change_filament() {
  1419. START_MENU();
  1420. MENU_BACK(MSG_MAIN);
  1421. // Change filament
  1422. #if E_STEPPERS == 1
  1423. PGM_P msg0 = PSTR(MSG_FILAMENTCHANGE);
  1424. if (thermalManager.targetTooColdToExtrude(active_extruder))
  1425. MENU_ITEM_P(submenu, msg0, menu_temp_e0_filament_change);
  1426. else
  1427. MENU_ITEM_P(gcode, msg0, PSTR("M600 B0"));
  1428. #else
  1429. PGM_P msg0 = PSTR(MSG_FILAMENTCHANGE " " MSG_E1);
  1430. PGM_P msg1 = PSTR(MSG_FILAMENTCHANGE " " MSG_E2);
  1431. if (thermalManager.targetTooColdToExtrude(0))
  1432. MENU_ITEM_P(submenu, msg0, menu_temp_e0_filament_change);
  1433. else
  1434. MENU_ITEM_P(gcode, msg0, PSTR("M600 B0 T0"));
  1435. if (thermalManager.targetTooColdToExtrude(1))
  1436. MENU_ITEM_P(submenu, msg1, menu_temp_e1_filament_change);
  1437. else
  1438. MENU_ITEM_P(gcode, msg1, PSTR("M600 B0 T1"));
  1439. #if E_STEPPERS > 2
  1440. PGM_P msg2 = PSTR(MSG_FILAMENTCHANGE " " MSG_E3);
  1441. if (thermalManager.targetTooColdToExtrude(2))
  1442. MENU_ITEM_P(submenu, msg2, menu_temp_e2_filament_change);
  1443. else
  1444. MENU_ITEM_P(gcode, msg2, PSTR("M600 B0 T2"));
  1445. #if E_STEPPERS > 3
  1446. PGM_P msg3 = PSTR(MSG_FILAMENTCHANGE " " MSG_E4);
  1447. if (thermalManager.targetTooColdToExtrude(3))
  1448. MENU_ITEM_P(submenu, msg3, menu_temp_e3_filament_change);
  1449. else
  1450. MENU_ITEM_P(gcode, msg3, PSTR("M600 B0 T3"));
  1451. #if E_STEPPERS > 4
  1452. PGM_P msg4 = PSTR(MSG_FILAMENTCHANGE " " MSG_E5);
  1453. if (thermalManager.targetTooColdToExtrude(4))
  1454. MENU_ITEM_P(submenu, msg4, menu_temp_e4_filament_change);
  1455. else
  1456. MENU_ITEM_P(gcode, msg4, PSTR("M600 B0 T4"));
  1457. #if E_STEPPERS > 5
  1458. PGM_P msg5 = PSTR(MSG_FILAMENTCHANGE " " MSG_E6);
  1459. if (thermalManager.targetTooColdToExtrude(5))
  1460. MENU_ITEM_P(submenu, msg5, menu_temp_e5_filament_change);
  1461. else
  1462. MENU_ITEM_P(gcode, msg5, PSTR("M600 B0 T5"));
  1463. #endif // E_STEPPERS > 5
  1464. #endif // E_STEPPERS > 4
  1465. #endif // E_STEPPERS > 3
  1466. #endif // E_STEPPERS > 2
  1467. #endif // E_STEPPERS == 1
  1468. #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
  1469. if (!printer_busy()) {
  1470. // Load filament
  1471. #if E_STEPPERS == 1
  1472. PGM_P msg0 = PSTR(MSG_FILAMENTLOAD);
  1473. if (thermalManager.targetTooColdToExtrude(active_extruder))
  1474. MENU_ITEM_P(submenu, msg0, menu_temp_e0_filament_load);
  1475. else
  1476. MENU_ITEM_P(gcode, msg0, PSTR("M701"));
  1477. #else
  1478. PGM_P msg0 = PSTR(MSG_FILAMENTLOAD " " MSG_E1);
  1479. PGM_P msg1 = PSTR(MSG_FILAMENTLOAD " " MSG_E2);
  1480. if (thermalManager.targetTooColdToExtrude(0))
  1481. MENU_ITEM_P(submenu, msg0, menu_temp_e0_filament_load);
  1482. else
  1483. MENU_ITEM_P(gcode, msg0, PSTR("M701 T0"));
  1484. if (thermalManager.targetTooColdToExtrude(1))
  1485. MENU_ITEM_P(submenu, msg1, menu_temp_e1_filament_load);
  1486. else
  1487. MENU_ITEM_P(gcode, msg1, PSTR("M701 T1"));
  1488. #if E_STEPPERS > 2
  1489. PGM_P msg2 = PSTR(MSG_FILAMENTLOAD " " MSG_E3);
  1490. if (thermalManager.targetTooColdToExtrude(2))
  1491. MENU_ITEM_P(submenu, msg2, menu_temp_e2_filament_load);
  1492. else
  1493. MENU_ITEM_P(gcode, msg2, PSTR("M701 T2"));
  1494. #if E_STEPPERS > 3
  1495. PGM_P msg3 = PSTR(MSG_FILAMENTLOAD " " MSG_E4);
  1496. if (thermalManager.targetTooColdToExtrude(3))
  1497. MENU_ITEM_P(submenu, msg3, menu_temp_e3_filament_load);
  1498. else
  1499. MENU_ITEM_P(gcode, msg3, PSTR("M701 T3"));
  1500. #if E_STEPPERS > 4
  1501. PGM_P msg4 = PSTR(MSG_FILAMENTLOAD " " MSG_E5);
  1502. if (thermalManager.targetTooColdToExtrude(4))
  1503. MENU_ITEM_P(submenu, msg4, menu_temp_e4_filament_load);
  1504. else
  1505. MENU_ITEM_P(gcode, msg4, PSTR("M701 T4"));
  1506. #if E_STEPPERS > 5
  1507. PGM_P msg5 = PSTR(MSG_FILAMENTLOAD " " MSG_E6);
  1508. if (thermalManager.targetTooColdToExtrude(5))
  1509. MENU_ITEM_P(submenu, msg5, menu_temp_e5_filament_load);
  1510. else
  1511. MENU_ITEM_P(gcode, msg5, PSTR("M701 T5"));
  1512. #endif // E_STEPPERS > 5
  1513. #endif // E_STEPPERS > 4
  1514. #endif // E_STEPPERS > 3
  1515. #endif // E_STEPPERS > 2
  1516. #endif // E_STEPPERS == 1
  1517. // Unload filament
  1518. #if E_STEPPERS == 1
  1519. if (thermalManager.targetHotEnoughToExtrude(active_extruder))
  1520. MENU_ITEM(gcode, MSG_FILAMENTUNLOAD, PSTR("M702"));
  1521. else
  1522. MENU_ITEM(submenu, MSG_FILAMENTUNLOAD, menu_temp_e0_filament_unload);
  1523. #else
  1524. #if ENABLED(FILAMENT_UNLOAD_ALL_EXTRUDERS)
  1525. if (thermalManager.targetHotEnoughToExtrude(0)
  1526. #if E_STEPPERS > 1
  1527. && thermalManager.targetHotEnoughToExtrude(1)
  1528. #if E_STEPPERS > 2
  1529. && thermalManager.targetHotEnoughToExtrude(2)
  1530. #if E_STEPPERS > 3
  1531. && thermalManager.targetHotEnoughToExtrude(3)
  1532. #if E_STEPPERS > 4
  1533. && thermalManager.targetHotEnoughToExtrude(4)
  1534. #if E_STEPPERS > 5
  1535. && thermalManager.targetHotEnoughToExtrude(5)
  1536. #endif // E_STEPPERS > 5
  1537. #endif // E_STEPPERS > 4
  1538. #endif // E_STEPPERS > 3
  1539. #endif // E_STEPPERS > 2
  1540. #endif // E_STEPPERS > 1
  1541. )
  1542. MENU_ITEM(gcode, MSG_FILAMENTUNLOAD_ALL, PSTR("M702"));
  1543. else
  1544. MENU_ITEM(submenu, MSG_FILAMENTUNLOAD_ALL, menu_unload_filament_all_temp);
  1545. #endif
  1546. if (thermalManager.targetHotEnoughToExtrude(0))
  1547. MENU_ITEM(gcode, MSG_FILAMENTUNLOAD " " MSG_E1, PSTR("M702 T0"));
  1548. else
  1549. MENU_ITEM(submenu, MSG_FILAMENTUNLOAD " " MSG_E1, menu_temp_e0_filament_unload);
  1550. if (thermalManager.targetHotEnoughToExtrude(1))
  1551. MENU_ITEM(gcode, MSG_FILAMENTUNLOAD " " MSG_E2, PSTR("M702 T1"));
  1552. else
  1553. MENU_ITEM(submenu, MSG_FILAMENTUNLOAD " " MSG_E2, menu_temp_e1_filament_unload);
  1554. #if E_STEPPERS > 2
  1555. if (thermalManager.targetHotEnoughToExtrude(2))
  1556. MENU_ITEM(gcode, MSG_FILAMENTUNLOAD " " MSG_E3, PSTR("M702 T2"));
  1557. else
  1558. MENU_ITEM(submenu, MSG_FILAMENTUNLOAD " " MSG_E3, menu_temp_e2_filament_unload);
  1559. #if E_STEPPERS > 3
  1560. if (thermalManager.targetHotEnoughToExtrude(3))
  1561. MENU_ITEM(gcode, MSG_FILAMENTUNLOAD " " MSG_E4, PSTR("M702 T3"));
  1562. else
  1563. MENU_ITEM(submenu, MSG_FILAMENTUNLOAD " " MSG_E4, menu_temp_e3_filament_unload);
  1564. #if E_STEPPERS > 4
  1565. if (thermalManager.targetHotEnoughToExtrude(4))
  1566. MENU_ITEM(gcode, MSG_FILAMENTUNLOAD " " MSG_E5, PSTR("M702 T4"));
  1567. else
  1568. MENU_ITEM(submenu, MSG_FILAMENTUNLOAD " " MSG_E5, menu_temp_e4_filament_unload);
  1569. #if E_STEPPERS > 5
  1570. if (thermalManager.targetHotEnoughToExtrude(5))
  1571. MENU_ITEM(gcode, MSG_FILAMENTUNLOAD " " MSG_E6, PSTR("M702 T5"));
  1572. else
  1573. MENU_ITEM(submenu, MSG_FILAMENTUNLOAD " " MSG_E6, menu_temp_e5_filament_unload);
  1574. #endif // E_STEPPERS > 5
  1575. #endif // E_STEPPERS > 4
  1576. #endif // E_STEPPERS > 3
  1577. #endif // E_STEPPERS > 2
  1578. #endif // E_STEPPERS == 1
  1579. }
  1580. #endif
  1581. END_MENU();
  1582. }
  1583. #endif
  1584. static AdvancedPauseMode advanced_pause_mode = ADVANCED_PAUSE_MODE_PAUSE_PRINT;
  1585. static uint8_t hotend_status_extruder = 0;
  1586. static PGM_P advanced_pause_header() {
  1587. switch (advanced_pause_mode) {
  1588. case ADVANCED_PAUSE_MODE_LOAD_FILAMENT:
  1589. return PSTR(MSG_FILAMENT_CHANGE_HEADER_LOAD);
  1590. case ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT:
  1591. return PSTR(MSG_FILAMENT_CHANGE_HEADER_UNLOAD);
  1592. default: break;
  1593. }
  1594. return PSTR(MSG_FILAMENT_CHANGE_HEADER_PAUSE);
  1595. }
  1596. // Portions from STATIC_ITEM...
  1597. #define HOTEND_STATUS_ITEM() do { \
  1598. if (_menuLineNr == _thisItemNr) { \
  1599. if (lcdDrawUpdate) { \
  1600. lcd_implementation_drawmenu_static(_lcdLineNr, PSTR(MSG_FILAMENT_CHANGE_NOZZLE), false, true); \
  1601. lcd_implementation_hotend_status(_lcdLineNr, hotend_status_extruder); \
  1602. } \
  1603. if (_skipStatic && encoderLine <= _thisItemNr) { \
  1604. encoderPosition += ENCODER_STEPS_PER_MENU_ITEM; \
  1605. ++encoderLine; \
  1606. } \
  1607. lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT; \
  1608. } \
  1609. ++_thisItemNr; \
  1610. }while(0)
  1611. void lcd_advanced_pause_resume_print() {
  1612. advanced_pause_menu_response = ADVANCED_PAUSE_RESPONSE_RESUME_PRINT;
  1613. }
  1614. void lcd_advanced_pause_extrude_more() {
  1615. advanced_pause_menu_response = ADVANCED_PAUSE_RESPONSE_EXTRUDE_MORE;
  1616. }
  1617. void menu_advanced_pause_option() {
  1618. START_MENU();
  1619. #if LCD_HEIGHT > 2
  1620. STATIC_ITEM(MSG_FILAMENT_CHANGE_OPTION_HEADER, true, false);
  1621. #endif
  1622. MENU_ITEM(function, MSG_FILAMENT_CHANGE_OPTION_RESUME, lcd_advanced_pause_resume_print);
  1623. MENU_ITEM(function, MSG_FILAMENT_CHANGE_OPTION_PURGE, lcd_advanced_pause_extrude_more);
  1624. END_MENU();
  1625. }
  1626. void lcd_advanced_pause_init_message() {
  1627. START_SCREEN();
  1628. STATIC_ITEM_P(advanced_pause_header(), true, true);
  1629. STATIC_ITEM(MSG_FILAMENT_CHANGE_INIT_1);
  1630. #ifdef MSG_FILAMENT_CHANGE_INIT_2
  1631. STATIC_ITEM(MSG_FILAMENT_CHANGE_INIT_2);
  1632. #define __FC_LINES_A 3
  1633. #else
  1634. #define __FC_LINES_A 2
  1635. #endif
  1636. #ifdef MSG_FILAMENT_CHANGE_INIT_3
  1637. STATIC_ITEM(MSG_FILAMENT_CHANGE_INIT_3);
  1638. #define _FC_LINES_A (__FC_LINES_A + 1)
  1639. #else
  1640. #define _FC_LINES_A __FC_LINES_A
  1641. #endif
  1642. #if LCD_HEIGHT > _FC_LINES_A + 1
  1643. STATIC_ITEM(" ");
  1644. #endif
  1645. HOTEND_STATUS_ITEM();
  1646. END_SCREEN();
  1647. }
  1648. void lcd_advanced_pause_unload_message() {
  1649. START_SCREEN();
  1650. STATIC_ITEM_P(advanced_pause_header(), true, true);
  1651. STATIC_ITEM(MSG_FILAMENT_CHANGE_UNLOAD_1);
  1652. #ifdef MSG_FILAMENT_CHANGE_UNLOAD_2
  1653. STATIC_ITEM(MSG_FILAMENT_CHANGE_UNLOAD_2);
  1654. #define __FC_LINES_B 3
  1655. #else
  1656. #define __FC_LINES_B 2
  1657. #endif
  1658. #ifdef MSG_FILAMENT_CHANGE_UNLOAD_3
  1659. STATIC_ITEM(MSG_FILAMENT_CHANGE_UNLOAD_3);
  1660. #define _FC_LINES_B (__FC_LINES_B + 1)
  1661. #else
  1662. #define _FC_LINES_B __FC_LINES_B
  1663. #endif
  1664. #if LCD_HEIGHT > _FC_LINES_B + 1
  1665. STATIC_ITEM(" ");
  1666. #endif
  1667. HOTEND_STATUS_ITEM();
  1668. END_SCREEN();
  1669. }
  1670. void lcd_advanced_pause_wait_for_nozzles_to_heat() {
  1671. START_SCREEN();
  1672. STATIC_ITEM_P(advanced_pause_header(), true, true);
  1673. STATIC_ITEM(MSG_FILAMENT_CHANGE_HEATING_1);
  1674. #ifdef MSG_FILAMENT_CHANGE_HEATING_2
  1675. STATIC_ITEM(MSG_FILAMENT_CHANGE_HEATING_2);
  1676. #define _FC_LINES_C 3
  1677. #else
  1678. #define _FC_LINES_C 2
  1679. #endif
  1680. #if LCD_HEIGHT > _FC_LINES_C + 1
  1681. STATIC_ITEM(" ");
  1682. #endif
  1683. HOTEND_STATUS_ITEM();
  1684. END_SCREEN();
  1685. }
  1686. void lcd_advanced_pause_heat_nozzle() {
  1687. START_SCREEN();
  1688. STATIC_ITEM_P(advanced_pause_header(), true, true);
  1689. STATIC_ITEM(MSG_FILAMENT_CHANGE_HEAT_1);
  1690. #ifdef MSG_FILAMENT_CHANGE_INSERT_2
  1691. STATIC_ITEM(MSG_FILAMENT_CHANGE_HEAT_2);
  1692. #define _FC_LINES_D 3
  1693. #else
  1694. #define _FC_LINES_D 2
  1695. #endif
  1696. #if LCD_HEIGHT > _FC_LINES_D + 1
  1697. STATIC_ITEM(" ");
  1698. #endif
  1699. HOTEND_STATUS_ITEM();
  1700. END_SCREEN();
  1701. }
  1702. void lcd_advanced_pause_insert_message() {
  1703. START_SCREEN();
  1704. STATIC_ITEM_P(advanced_pause_header(), true, true);
  1705. STATIC_ITEM(MSG_FILAMENT_CHANGE_INSERT_1);
  1706. #ifdef MSG_FILAMENT_CHANGE_INSERT_2
  1707. STATIC_ITEM(MSG_FILAMENT_CHANGE_INSERT_2);
  1708. #define __FC_LINES_E 3
  1709. #else
  1710. #define __FC_LINES_E 2
  1711. #endif
  1712. #ifdef MSG_FILAMENT_CHANGE_INSERT_3
  1713. STATIC_ITEM(MSG_FILAMENT_CHANGE_INSERT_3);
  1714. #define _FC_LINES_E (__FC_LINES_E + 1)
  1715. #else
  1716. #define _FC_LINES_E __FC_LINES_E
  1717. #endif
  1718. #if LCD_HEIGHT > _FC_LINES_E + 1
  1719. STATIC_ITEM(" ");
  1720. #endif
  1721. HOTEND_STATUS_ITEM();
  1722. END_SCREEN();
  1723. }
  1724. void lcd_advanced_pause_load_message() {
  1725. START_SCREEN();
  1726. STATIC_ITEM_P(advanced_pause_header(), true, true);
  1727. STATIC_ITEM(MSG_FILAMENT_CHANGE_LOAD_1);
  1728. #ifdef MSG_FILAMENT_CHANGE_LOAD_2
  1729. STATIC_ITEM(MSG_FILAMENT_CHANGE_LOAD_2);
  1730. #define __FC_LINES_F 3
  1731. #else
  1732. #define __FC_LINES_F 2
  1733. #endif
  1734. #ifdef MSG_FILAMENT_CHANGE_LOAD_3
  1735. STATIC_ITEM(MSG_FILAMENT_CHANGE_LOAD_3);
  1736. #define _FC_LINES_F (__FC_LINES_F + 1)
  1737. #else
  1738. #define _FC_LINES_F __FC_LINES_F
  1739. #endif
  1740. #if LCD_HEIGHT > _FC_LINES_F + 1
  1741. STATIC_ITEM(" ");
  1742. #endif
  1743. HOTEND_STATUS_ITEM();
  1744. END_SCREEN();
  1745. }
  1746. void lcd_advanced_pause_purge_message() {
  1747. START_SCREEN();
  1748. STATIC_ITEM_P(advanced_pause_header(), true, true);
  1749. STATIC_ITEM(MSG_FILAMENT_CHANGE_PURGE_1);
  1750. #ifdef MSG_FILAMENT_CHANGE_PURGE_2
  1751. STATIC_ITEM(MSG_FILAMENT_CHANGE_PURGE_2);
  1752. #define __FC_LINES_G 3
  1753. #else
  1754. #define __FC_LINES_G 2
  1755. #endif
  1756. #ifdef MSG_FILAMENT_CHANGE_PURGE_3
  1757. STATIC_ITEM(MSG_FILAMENT_CHANGE_PURGE_3);
  1758. #define _FC_LINES_G (__FC_LINES_G + 1)
  1759. #else
  1760. #define _FC_LINES_G __FC_LINES_G
  1761. #endif
  1762. #if LCD_HEIGHT > _FC_LINES_G + 1
  1763. STATIC_ITEM(" ");
  1764. #endif
  1765. HOTEND_STATUS_ITEM();
  1766. END_SCREEN();
  1767. }
  1768. #if ENABLED(ADVANCED_PAUSE_CONTINUOUS_PURGE)
  1769. void menu_advanced_pause_continuous_purge() {
  1770. START_SCREEN();
  1771. STATIC_ITEM(MSG_FILAMENT_CHANGE_PURGE_1);
  1772. #ifdef MSG_FILAMENT_CHANGE_PURGE_2
  1773. STATIC_ITEM(MSG_FILAMENT_CHANGE_PURGE_2);
  1774. #define __FC_LINES_G 3
  1775. #else
  1776. #define __FC_LINES_G 2
  1777. #endif
  1778. #ifdef MSG_FILAMENT_CHANGE_PURGE_3
  1779. STATIC_ITEM(MSG_FILAMENT_CHANGE_PURGE_3);
  1780. #define _FC_LINES_G (__FC_LINES_G + 1)
  1781. #else
  1782. #define _FC_LINES_G __FC_LINES_G
  1783. #endif
  1784. #if LCD_HEIGHT > _FC_LINES_G + 1
  1785. STATIC_ITEM(" ");
  1786. #endif
  1787. HOTEND_STATUS_ITEM();
  1788. STATIC_ITEM(MSG_USERWAIT);
  1789. END_SCREEN();
  1790. }
  1791. #endif
  1792. void lcd_advanced_pause_resume_message() {
  1793. START_SCREEN();
  1794. STATIC_ITEM_P(advanced_pause_header(), true, true);
  1795. STATIC_ITEM(MSG_FILAMENT_CHANGE_RESUME_1);
  1796. #ifdef MSG_FILAMENT_CHANGE_RESUME_2
  1797. STATIC_ITEM(MSG_FILAMENT_CHANGE_RESUME_2);
  1798. #endif
  1799. #ifdef MSG_FILAMENT_CHANGE_RESUME_3
  1800. STATIC_ITEM(MSG_FILAMENT_CHANGE_RESUME_3);
  1801. #endif
  1802. END_SCREEN();
  1803. }
  1804. FORCE_INLINE screenFunc_t ap_message_screen(const AdvancedPauseMessage message) {
  1805. switch (message) {
  1806. case ADVANCED_PAUSE_MESSAGE_INIT: return lcd_advanced_pause_init_message;
  1807. case ADVANCED_PAUSE_MESSAGE_UNLOAD: return lcd_advanced_pause_unload_message;
  1808. case ADVANCED_PAUSE_MESSAGE_INSERT: return lcd_advanced_pause_insert_message;
  1809. case ADVANCED_PAUSE_MESSAGE_LOAD: return lcd_advanced_pause_load_message;
  1810. case ADVANCED_PAUSE_MESSAGE_PURGE: return lcd_advanced_pause_purge_message;
  1811. case ADVANCED_PAUSE_MESSAGE_RESUME: return lcd_advanced_pause_resume_message;
  1812. case ADVANCED_PAUSE_MESSAGE_CLICK_TO_HEAT_NOZZLE: return lcd_advanced_pause_heat_nozzle;
  1813. case ADVANCED_PAUSE_MESSAGE_WAIT_FOR_NOZZLES_TO_HEAT: return lcd_advanced_pause_wait_for_nozzles_to_heat;
  1814. case ADVANCED_PAUSE_MESSAGE_OPTION: advanced_pause_menu_response = ADVANCED_PAUSE_RESPONSE_WAIT_FOR;
  1815. return menu_advanced_pause_option;
  1816. #if ENABLED(ADVANCED_PAUSE_CONTINUOUS_PURGE)
  1817. case ADVANCED_PAUSE_MESSAGE_CONTINUOUS_PURGE: return menu_advanced_pause_continuous_purge;
  1818. #endif
  1819. case ADVANCED_PAUSE_MESSAGE_STATUS:
  1820. default: break;
  1821. }
  1822. return NULL;
  1823. }
  1824. void lcd_advanced_pause_show_message(
  1825. const AdvancedPauseMessage message,
  1826. const AdvancedPauseMode mode/*=ADVANCED_PAUSE_MODE_PAUSE_PRINT*/,
  1827. const uint8_t extruder/*=active_extruder*/
  1828. ) {
  1829. advanced_pause_mode = mode;
  1830. hotend_status_extruder = extruder;
  1831. const screenFunc_t next_screen = ap_message_screen(message);
  1832. if (next_screen) {
  1833. defer_return_to_status = true;
  1834. lcd_goto_screen(next_screen);
  1835. }
  1836. else
  1837. lcd_return_to_status();
  1838. }
  1839. #endif // ADVANCED_PAUSE_FEATURE
  1840. #endif // ULTIPANEL