My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

menu.cpp 136KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950
  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(LCD_INFO_MENU)
  222. #if ENABLED(PRINTCOUNTER)
  223. void menu_info_stats();
  224. #endif
  225. void menu_info_thermistors();
  226. void menu_info_board();
  227. #endif
  228. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  229. #if E_STEPPERS > 1 || ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
  230. void menu_change_filament();
  231. #else
  232. void menu_temp_e0_filament_change();
  233. #endif
  234. #endif
  235. #if ENABLED(MESH_BED_LEVELING) && ENABLED(LCD_BED_LEVELING)
  236. #include "../../feature/bedlevel/mbl/mesh_bed_leveling.h"
  237. #endif
  238. #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
  239. float lcd_z_fade_height;
  240. void _lcd_set_z_fade_height() { set_z_fade_height(lcd_z_fade_height); }
  241. #endif
  242. bool printer_busy() { return planner.movesplanned() || IS_SD_PRINTING(); }
  243. float move_menu_scale;
  244. #if HAS_CHARACTER_LCD && (ENABLED(LCD_PROGRESS_BAR) || ENABLED(LCD_PROGRESS_BAR_TEST) || ENABLED(AUTO_BED_LEVELING_UBL))
  245. void lcd_set_custom_characters(
  246. #if ENABLED(LCD_PROGRESS_BAR) || ENABLED(SHOW_BOOTSCREEN)
  247. const uint8_t screen_charset=CHARSET_INFO
  248. #endif
  249. );
  250. #endif
  251. /**
  252. * General function to go directly to a screen
  253. */
  254. void lcd_goto_screen(screenFunc_t screen, const uint32_t encoder/*=0*/) {
  255. if (currentScreen != screen) {
  256. #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
  257. // Shadow for editing the fade height
  258. lcd_z_fade_height = planner.z_fade_height;
  259. #endif
  260. #if ENABLED(DOUBLECLICK_FOR_Z_BABYSTEPPING) && ENABLED(BABYSTEPPING)
  261. static millis_t doubleclick_expire_ms = 0;
  262. // Going to menu_main from status screen? Remember first click time.
  263. // Going back to status screen within a very short time? Go to Z babystepping.
  264. if (screen == menu_main) {
  265. if (currentScreen == lcd_status_screen)
  266. doubleclick_expire_ms = millis() + DOUBLECLICK_MAX_INTERVAL;
  267. }
  268. else if (screen == lcd_status_screen && currentScreen == menu_main && PENDING(millis(), doubleclick_expire_ms)) {
  269. if (printer_busy()) {
  270. screen =
  271. #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
  272. lcd_babystep_zoffset
  273. #else
  274. lcd_babystep_z
  275. #endif
  276. ;
  277. }
  278. #if ENABLED(MOVE_Z_WHEN_IDLE)
  279. else {
  280. move_menu_scale = MOVE_Z_IDLE_MULTIPLICATOR;
  281. screen = lcd_move_z;
  282. }
  283. #endif
  284. }
  285. #endif
  286. currentScreen = screen;
  287. encoderPosition = encoder;
  288. if (screen == lcd_status_screen) {
  289. defer_return_to_status = false;
  290. #if ENABLED(AUTO_BED_LEVELING_UBL)
  291. ubl.lcd_map_control = false;
  292. #endif
  293. screen_history_depth = 0;
  294. }
  295. lcd_implementation_clear();
  296. // Re-initialize custom characters that may be re-used
  297. #if HAS_CHARACTER_LCD && ENABLED(AUTO_BED_LEVELING_UBL)
  298. if (!ubl.lcd_map_control) {
  299. lcd_set_custom_characters(
  300. #if ENABLED(LCD_PROGRESS_BAR)
  301. screen == lcd_status_screen ? CHARSET_INFO : CHARSET_MENU
  302. #endif
  303. );
  304. }
  305. #elif ENABLED(LCD_PROGRESS_BAR)
  306. lcd_set_custom_characters(screen == lcd_status_screen ? CHARSET_INFO : CHARSET_MENU);
  307. #endif
  308. lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
  309. screen_changed = true;
  310. #if HAS_GRAPHICAL_LCD
  311. drawing_screen = false;
  312. #endif
  313. }
  314. }
  315. ////////////////////////////////////////////
  316. ///////////// Manual Movement //////////////
  317. ////////////////////////////////////////////
  318. extern millis_t manual_move_start_time;
  319. extern int8_t manual_move_axis;
  320. #if IS_KINEMATIC
  321. extern float manual_move_offset;
  322. #endif
  323. #if ENABLED(DUAL_X_CARRIAGE) || E_MANUAL > 1
  324. extern int8_t manual_move_e_index;
  325. #endif
  326. #if ENABLED(MANUAL_E_MOVES_RELATIVE)
  327. float manual_move_e_origin = 0;
  328. #endif
  329. //
  330. // Display the synchronize screen until moves are
  331. // finished, and don't return to the caller until
  332. // done. ** This blocks the command queue! **
  333. //
  334. static PGM_P sync_message;
  335. void _lcd_synchronize() {
  336. if (lcdDrawUpdate) lcd_implementation_drawmenu_static(LCD_HEIGHT >= 4 ? 1 : 0, sync_message);
  337. if (no_reentry) return;
  338. // Make this the current handler till all moves are done
  339. no_reentry = true;
  340. const screenFunc_t old_screen = currentScreen;
  341. lcd_goto_screen(_lcd_synchronize);
  342. planner.synchronize(); // idle() is called until moves complete
  343. no_reentry = false;
  344. lcd_goto_screen(old_screen);
  345. }
  346. // Display the synchronize screen with a custom message
  347. // ** This blocks the command queue! **
  348. void lcd_synchronize(PGM_P const msg/*=NULL*/) {
  349. static const char moving[] PROGMEM = MSG_MOVING;
  350. sync_message = msg ? msg : moving;
  351. _lcd_synchronize();
  352. }
  353. /**
  354. * Scrolling for menus and other line-based screens
  355. *
  356. * encoderLine is the position based on the encoder
  357. * encoderTopLine is the top menu line to display
  358. * _lcdLineNr is the index of the LCD line (e.g., 0-3)
  359. * _menuLineNr is the menu item to draw and process
  360. * _thisItemNr is the index of each MENU_ITEM or STATIC_ITEM
  361. * screen_items is the total number of items in the menu (after one call)
  362. */
  363. int8_t encoderLine, screen_items;
  364. void scroll_screen(const uint8_t limit, const bool is_menu) {
  365. ENCODER_DIRECTION_MENUS();
  366. ENCODER_RATE_MULTIPLY(false);
  367. if (encoderPosition > 0x8000) encoderPosition = 0;
  368. if (first_page) {
  369. encoderLine = encoderPosition / (ENCODER_STEPS_PER_MENU_ITEM);
  370. screen_changed = false;
  371. }
  372. if (screen_items > 0 && encoderLine >= screen_items - limit) {
  373. encoderLine = MAX(0, screen_items - limit);
  374. encoderPosition = encoderLine * (ENCODER_STEPS_PER_MENU_ITEM);
  375. }
  376. if (is_menu) {
  377. NOMORE(encoderTopLine, encoderLine);
  378. if (encoderLine >= encoderTopLine + LCD_HEIGHT)
  379. encoderTopLine = encoderLine - LCD_HEIGHT + 1;
  380. }
  381. else
  382. encoderTopLine = encoderLine;
  383. }
  384. void lcd_completion_feedback(const bool good/*=true*/) {
  385. if (good) {
  386. lcd_buzz(100, 659);
  387. lcd_buzz(100, 698);
  388. }
  389. else lcd_buzz(20, 440);
  390. }
  391. inline void line_to_current_z() {
  392. planner.buffer_line(current_position, MMM_TO_MMS(manual_feedrate_mm_m[Z_AXIS]), active_extruder);
  393. }
  394. void line_to_z(const float &z) {
  395. current_position[Z_AXIS] = z;
  396. line_to_current_z();
  397. }
  398. #if ENABLED(POWER_LOSS_RECOVERY)
  399. static void lcd_power_loss_recovery_resume() {
  400. char cmd[20];
  401. // Return to status now
  402. lcd_return_to_status();
  403. // Turn leveling off and home
  404. enqueue_and_echo_commands_P(PSTR("M420 S0\nG28 R0"
  405. #if ENABLED(MARLIN_DEV_MODE)
  406. " S"
  407. #elif !IS_KINEMATIC
  408. " X Y"
  409. #endif
  410. ));
  411. #if HAS_HEATED_BED
  412. const int16_t bt = job_recovery_info.target_temperature_bed;
  413. if (bt) {
  414. // Restore the bed temperature
  415. sprintf_P(cmd, PSTR("M190 S%i"), bt);
  416. enqueue_and_echo_command(cmd);
  417. }
  418. #endif
  419. // Restore all hotend temperatures
  420. HOTEND_LOOP() {
  421. const int16_t et = job_recovery_info.target_temperature[e];
  422. if (et) {
  423. #if HOTENDS > 1
  424. sprintf_P(cmd, PSTR("T%i"), e);
  425. enqueue_and_echo_command(cmd);
  426. #endif
  427. sprintf_P(cmd, PSTR("M109 S%i"), et);
  428. enqueue_and_echo_command(cmd);
  429. }
  430. }
  431. #if HOTENDS > 1
  432. sprintf_P(cmd, PSTR("T%i"), job_recovery_info.active_hotend);
  433. enqueue_and_echo_command(cmd);
  434. #endif
  435. // Restore print cooling fan speeds
  436. for (uint8_t i = 0; i < FAN_COUNT; i++) {
  437. uint8_t f = job_recovery_info.fan_speed[i];
  438. if (f) {
  439. sprintf_P(cmd, PSTR("M106 P%i S%i"), i, f);
  440. enqueue_and_echo_command(cmd);
  441. }
  442. }
  443. // Start draining the job recovery command queue
  444. job_recovery_phase = JOB_RECOVERY_YES;
  445. }
  446. static void lcd_power_loss_recovery_cancel() {
  447. card.removeJobRecoveryFile();
  448. card.autostart_index = 0;
  449. lcd_return_to_status();
  450. }
  451. void menu_job_recovery() {
  452. defer_return_to_status = true;
  453. START_MENU();
  454. STATIC_ITEM(MSG_POWER_LOSS_RECOVERY);
  455. MENU_ITEM(function, MSG_RESUME_PRINT, lcd_power_loss_recovery_resume);
  456. MENU_ITEM(function, MSG_STOP_PRINT, lcd_power_loss_recovery_cancel);
  457. END_MENU();
  458. }
  459. #endif // POWER_LOSS_RECOVERY
  460. #if ENABLED(CUSTOM_USER_MENUS)
  461. #ifdef USER_SCRIPT_DONE
  462. #define _DONE_SCRIPT "\n" USER_SCRIPT_DONE
  463. #else
  464. #define _DONE_SCRIPT ""
  465. #endif
  466. void _lcd_user_gcode(PGM_P const cmd) {
  467. enqueue_and_echo_commands_P(cmd);
  468. #if ENABLED(USER_SCRIPT_AUDIBLE_FEEDBACK)
  469. lcd_completion_feedback();
  470. #endif
  471. #if ENABLED(USER_SCRIPT_RETURN)
  472. lcd_return_to_status();
  473. #endif
  474. }
  475. #if defined(USER_DESC_1) && defined(USER_GCODE_1)
  476. void lcd_user_gcode_1() { _lcd_user_gcode(PSTR(USER_GCODE_1 _DONE_SCRIPT)); }
  477. #endif
  478. #if defined(USER_DESC_2) && defined(USER_GCODE_2)
  479. void lcd_user_gcode_2() { _lcd_user_gcode(PSTR(USER_GCODE_2 _DONE_SCRIPT)); }
  480. #endif
  481. #if defined(USER_DESC_3) && defined(USER_GCODE_3)
  482. void lcd_user_gcode_3() { _lcd_user_gcode(PSTR(USER_GCODE_3 _DONE_SCRIPT)); }
  483. #endif
  484. #if defined(USER_DESC_4) && defined(USER_GCODE_4)
  485. void lcd_user_gcode_4() { _lcd_user_gcode(PSTR(USER_GCODE_4 _DONE_SCRIPT)); }
  486. #endif
  487. #if defined(USER_DESC_5) && defined(USER_GCODE_5)
  488. void lcd_user_gcode_5() { _lcd_user_gcode(PSTR(USER_GCODE_5 _DONE_SCRIPT)); }
  489. #endif
  490. void _menu_user() {
  491. START_MENU();
  492. MENU_BACK(MSG_MAIN);
  493. #if defined(USER_DESC_1) && defined(USER_GCODE_1)
  494. MENU_ITEM(function, USER_DESC_1, lcd_user_gcode_1);
  495. #endif
  496. #if defined(USER_DESC_2) && defined(USER_GCODE_2)
  497. MENU_ITEM(function, USER_DESC_2, lcd_user_gcode_2);
  498. #endif
  499. #if defined(USER_DESC_3) && defined(USER_GCODE_3)
  500. MENU_ITEM(function, USER_DESC_3, lcd_user_gcode_3);
  501. #endif
  502. #if defined(USER_DESC_4) && defined(USER_GCODE_4)
  503. MENU_ITEM(function, USER_DESC_4, lcd_user_gcode_4);
  504. #endif
  505. #if defined(USER_DESC_5) && defined(USER_GCODE_5)
  506. MENU_ITEM(function, USER_DESC_5, lcd_user_gcode_5);
  507. #endif
  508. END_MENU();
  509. }
  510. #endif
  511. #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
  512. void lcd_babystep_zoffset() {
  513. if (use_click()) { return lcd_goto_previous_menu_no_defer(); }
  514. defer_return_to_status = true;
  515. #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
  516. const bool do_probe = (active_extruder == 0);
  517. #else
  518. constexpr bool do_probe = true;
  519. #endif
  520. ENCODER_DIRECTION_NORMAL();
  521. if (encoderPosition) {
  522. const int16_t babystep_increment = (int32_t)encoderPosition * (BABYSTEP_MULTIPLICATOR);
  523. encoderPosition = 0;
  524. const float diff = planner.steps_to_mm[Z_AXIS] * babystep_increment,
  525. new_probe_offset = zprobe_zoffset + diff,
  526. new_offs =
  527. #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
  528. do_probe ? new_probe_offset : hotend_offset[Z_AXIS][active_extruder] - diff
  529. #else
  530. new_probe_offset
  531. #endif
  532. ;
  533. if (WITHIN(new_offs, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) {
  534. thermalManager.babystep_axis(Z_AXIS, babystep_increment);
  535. if (do_probe) zprobe_zoffset = new_offs;
  536. #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
  537. else hotend_offset[Z_AXIS][active_extruder] = new_offs;
  538. #endif
  539. lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
  540. }
  541. }
  542. if (lcdDrawUpdate) {
  543. #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
  544. if (!do_probe)
  545. lcd_implementation_drawedit(PSTR(MSG_IDEX_Z_OFFSET), ftostr43sign(hotend_offset[Z_AXIS][active_extruder]));
  546. else
  547. #endif
  548. lcd_implementation_drawedit(PSTR(MSG_ZPROBE_ZOFFSET), ftostr43sign(zprobe_zoffset));
  549. #if ENABLED(BABYSTEP_ZPROBE_GFX_OVERLAY)
  550. if (do_probe) _lcd_zoffset_overlay_gfx(zprobe_zoffset);
  551. #endif
  552. }
  553. }
  554. #endif // BABYSTEP_ZPROBE_OFFSET
  555. #if ENABLED(AUTO_BED_LEVELING_UBL)
  556. float mesh_edit_value, mesh_edit_accumulator; // We round mesh_edit_value to 2.5 decimal places. So we keep a
  557. // separate value that doesn't lose precision.
  558. static int16_t ubl_encoderPosition = 0;
  559. static void _lcd_mesh_fine_tune(PGM_P msg) {
  560. defer_return_to_status = true;
  561. if (ubl.encoder_diff) {
  562. ubl_encoderPosition = (ubl.encoder_diff > 0) ? 1 : -1;
  563. ubl.encoder_diff = 0;
  564. mesh_edit_accumulator += float(ubl_encoderPosition) * 0.005f * 0.5f;
  565. mesh_edit_value = mesh_edit_accumulator;
  566. encoderPosition = 0;
  567. lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
  568. const int32_t rounded = (int32_t)(mesh_edit_value * 1000);
  569. mesh_edit_value = float(rounded - (rounded % 5L)) / 1000;
  570. }
  571. if (lcdDrawUpdate) {
  572. lcd_implementation_drawedit(msg, ftostr43sign(mesh_edit_value));
  573. #if ENABLED(MESH_EDIT_GFX_OVERLAY)
  574. _lcd_zoffset_overlay_gfx(mesh_edit_value);
  575. #endif
  576. }
  577. }
  578. void _lcd_mesh_edit_NOP() {
  579. defer_return_to_status = true;
  580. }
  581. float lcd_mesh_edit() {
  582. lcd_goto_screen(_lcd_mesh_edit_NOP);
  583. lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
  584. _lcd_mesh_fine_tune(PSTR("Mesh Editor"));
  585. return mesh_edit_value;
  586. }
  587. void lcd_mesh_edit_setup(const float &initial) {
  588. mesh_edit_value = mesh_edit_accumulator = initial;
  589. lcd_goto_screen(_lcd_mesh_edit_NOP);
  590. }
  591. void _lcd_z_offset_edit() {
  592. _lcd_mesh_fine_tune(PSTR("Z-Offset: "));
  593. }
  594. float lcd_z_offset_edit() {
  595. lcd_goto_screen(_lcd_z_offset_edit);
  596. return mesh_edit_value;
  597. }
  598. void lcd_z_offset_edit_setup(const float &initial) {
  599. mesh_edit_value = mesh_edit_accumulator = initial;
  600. lcd_goto_screen(_lcd_z_offset_edit);
  601. }
  602. #endif // AUTO_BED_LEVELING_UBL
  603. /**
  604. * Watch temperature callbacks
  605. */
  606. #if HAS_TEMP_HOTEND
  607. #if WATCH_HOTENDS
  608. #define _WATCH_FUNC(N) thermalManager.start_watching_heater(N)
  609. #else
  610. #define _WATCH_FUNC(N) NOOP
  611. #endif
  612. void watch_temp_callback_E0() { _WATCH_FUNC(0); }
  613. #if HOTENDS > 1
  614. void watch_temp_callback_E1() { _WATCH_FUNC(1); }
  615. #if HOTENDS > 2
  616. void watch_temp_callback_E2() { _WATCH_FUNC(2); }
  617. #if HOTENDS > 3
  618. void watch_temp_callback_E3() { _WATCH_FUNC(3); }
  619. #if HOTENDS > 4
  620. void watch_temp_callback_E4() { _WATCH_FUNC(4); }
  621. #if HOTENDS > 5
  622. void watch_temp_callback_E5() { _WATCH_FUNC(5); }
  623. #endif // HOTENDS > 5
  624. #endif // HOTENDS > 4
  625. #endif // HOTENDS > 3
  626. #endif // HOTENDS > 2
  627. #endif // HOTENDS > 1
  628. #endif // HAS_TEMP_HOTEND
  629. void watch_temp_callback_bed() {
  630. #if WATCH_THE_BED
  631. thermalManager.start_watching_bed();
  632. #endif
  633. }
  634. /**
  635. *
  636. * "Temperature" submenu items
  637. *
  638. */
  639. void _lcd_preheat(const int16_t endnum, const int16_t temph, const int16_t tempb, const uint8_t fan) {
  640. if (temph > 0) thermalManager.setTargetHotend(MIN(heater_maxtemp[endnum], temph), endnum);
  641. #if HAS_HEATED_BED
  642. if (tempb >= 0) thermalManager.setTargetBed(tempb);
  643. #else
  644. UNUSED(tempb);
  645. #endif
  646. #if FAN_COUNT > 0
  647. #if FAN_COUNT > 1
  648. fan_speed[active_extruder < FAN_COUNT ? active_extruder : 0] = fan;
  649. #else
  650. fan_speed[0] = fan;
  651. #endif
  652. #else
  653. UNUSED(fan);
  654. #endif
  655. lcd_return_to_status();
  656. }
  657. #if HAS_TEMP_HOTEND
  658. void lcd_preheat_m1_e0_only() { _lcd_preheat(0, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); }
  659. void lcd_preheat_m2_e0_only() { _lcd_preheat(0, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); }
  660. #if HAS_HEATED_BED
  661. void lcd_preheat_m1_e0() { _lcd_preheat(0, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
  662. void lcd_preheat_m2_e0() { _lcd_preheat(0, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
  663. #endif
  664. #endif
  665. #if HOTENDS > 1
  666. void lcd_preheat_m1_e1_only() { _lcd_preheat(1, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); }
  667. void lcd_preheat_m2_e1_only() { _lcd_preheat(1, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); }
  668. #if HAS_HEATED_BED
  669. void lcd_preheat_m1_e1() { _lcd_preheat(1, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
  670. void lcd_preheat_m2_e1() { _lcd_preheat(1, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
  671. #endif
  672. #if HOTENDS > 2
  673. void lcd_preheat_m1_e2_only() { _lcd_preheat(2, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); }
  674. void lcd_preheat_m2_e2_only() { _lcd_preheat(2, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); }
  675. #if HAS_HEATED_BED
  676. void lcd_preheat_m1_e2() { _lcd_preheat(2, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
  677. void lcd_preheat_m2_e2() { _lcd_preheat(2, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
  678. #endif
  679. #if HOTENDS > 3
  680. void lcd_preheat_m1_e3_only() { _lcd_preheat(3, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); }
  681. void lcd_preheat_m2_e3_only() { _lcd_preheat(3, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); }
  682. #if HAS_HEATED_BED
  683. void lcd_preheat_m1_e3() { _lcd_preheat(3, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
  684. void lcd_preheat_m2_e3() { _lcd_preheat(3, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
  685. #endif
  686. #if HOTENDS > 4
  687. void lcd_preheat_m1_e4_only() { _lcd_preheat(4, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); }
  688. void lcd_preheat_m2_e4_only() { _lcd_preheat(4, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); }
  689. #if HAS_HEATED_BED
  690. void lcd_preheat_m1_e4() { _lcd_preheat(4, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
  691. void lcd_preheat_m2_e4() { _lcd_preheat(4, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
  692. #endif
  693. #if HOTENDS > 5
  694. void lcd_preheat_m1_e5_only() { _lcd_preheat(5, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); }
  695. void lcd_preheat_m2_e5_only() { _lcd_preheat(5, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); }
  696. #if HAS_HEATED_BED
  697. void lcd_preheat_m1_e5() { _lcd_preheat(5, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
  698. void lcd_preheat_m2_e5() { _lcd_preheat(5, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
  699. #endif
  700. #endif // HOTENDS > 5
  701. #endif // HOTENDS > 4
  702. #endif // HOTENDS > 3
  703. #endif // HOTENDS > 2
  704. void lcd_preheat_m1_all() {
  705. #if HOTENDS > 1
  706. thermalManager.setTargetHotend(lcd_preheat_hotend_temp[0], 1);
  707. #if HOTENDS > 2
  708. thermalManager.setTargetHotend(lcd_preheat_hotend_temp[0], 2);
  709. #if HOTENDS > 3
  710. thermalManager.setTargetHotend(lcd_preheat_hotend_temp[0], 3);
  711. #if HOTENDS > 4
  712. thermalManager.setTargetHotend(lcd_preheat_hotend_temp[0], 4);
  713. #if HOTENDS > 5
  714. thermalManager.setTargetHotend(lcd_preheat_hotend_temp[0], 5);
  715. #endif // HOTENDS > 5
  716. #endif // HOTENDS > 4
  717. #endif // HOTENDS > 3
  718. #endif // HOTENDS > 2
  719. #endif // HOTENDS > 1
  720. #if HAS_HEATED_BED
  721. lcd_preheat_m1_e0();
  722. #else
  723. lcd_preheat_m1_e0_only();
  724. #endif
  725. }
  726. void lcd_preheat_m2_all() {
  727. #if HOTENDS > 1
  728. thermalManager.setTargetHotend(lcd_preheat_hotend_temp[1], 1);
  729. #if HOTENDS > 2
  730. thermalManager.setTargetHotend(lcd_preheat_hotend_temp[1], 2);
  731. #if HOTENDS > 3
  732. thermalManager.setTargetHotend(lcd_preheat_hotend_temp[1], 3);
  733. #if HOTENDS > 4
  734. thermalManager.setTargetHotend(lcd_preheat_hotend_temp[1], 4);
  735. #if HOTENDS > 5
  736. thermalManager.setTargetHotend(lcd_preheat_hotend_temp[1], 5);
  737. #endif // HOTENDS > 5
  738. #endif // HOTENDS > 4
  739. #endif // HOTENDS > 3
  740. #endif // HOTENDS > 2
  741. #endif // HOTENDS > 1
  742. #if HAS_HEATED_BED
  743. lcd_preheat_m2_e0();
  744. #else
  745. lcd_preheat_m2_e0_only();
  746. #endif
  747. }
  748. #endif // HOTENDS > 1
  749. #if HAS_HEATED_BED
  750. void lcd_preheat_m1_bedonly() { _lcd_preheat(0, 0, lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
  751. void lcd_preheat_m2_bedonly() { _lcd_preheat(0, 0, lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
  752. #endif
  753. #if HAS_TEMP_HOTEND || HAS_HEATED_BED
  754. void menu_preheat_m1() {
  755. START_MENU();
  756. MENU_BACK(MSG_TEMPERATURE);
  757. #if HOTENDS == 1
  758. #if HAS_HEATED_BED
  759. MENU_ITEM(function, MSG_PREHEAT_1, lcd_preheat_m1_e0);
  760. MENU_ITEM(function, MSG_PREHEAT_1_END, lcd_preheat_m1_e0_only);
  761. #else
  762. MENU_ITEM(function, MSG_PREHEAT_1, lcd_preheat_m1_e0_only);
  763. #endif
  764. #elif HOTENDS > 1
  765. #if HAS_HEATED_BED
  766. MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H1, lcd_preheat_m1_e0);
  767. MENU_ITEM(function, MSG_PREHEAT_1_END " " MSG_E1, lcd_preheat_m1_e0_only);
  768. MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H2, lcd_preheat_m1_e1);
  769. MENU_ITEM(function, MSG_PREHEAT_1_END " " MSG_E2, lcd_preheat_m1_e1_only);
  770. #else
  771. MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H1, lcd_preheat_m1_e0_only);
  772. MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H2, lcd_preheat_m1_e1_only);
  773. #endif
  774. #if HOTENDS > 2
  775. #if HAS_HEATED_BED
  776. MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H3, lcd_preheat_m1_e2);
  777. MENU_ITEM(function, MSG_PREHEAT_1_END " " MSG_E3, lcd_preheat_m1_e2_only);
  778. #else
  779. MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H3, lcd_preheat_m1_e2_only);
  780. #endif
  781. #if HOTENDS > 3
  782. #if HAS_HEATED_BED
  783. MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H4, lcd_preheat_m1_e3);
  784. MENU_ITEM(function, MSG_PREHEAT_1_END " " MSG_E4, lcd_preheat_m1_e3_only);
  785. #else
  786. MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H4, lcd_preheat_m1_e3_only);
  787. #endif
  788. #if HOTENDS > 4
  789. #if HAS_HEATED_BED
  790. MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H5, lcd_preheat_m1_e4);
  791. MENU_ITEM(function, MSG_PREHEAT_1_END " " MSG_E5, lcd_preheat_m1_e4_only);
  792. #else
  793. MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H5, lcd_preheat_m1_e4_only);
  794. #endif
  795. #if HOTENDS > 5
  796. #if HAS_HEATED_BED
  797. MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H6, lcd_preheat_m1_e5);
  798. MENU_ITEM(function, MSG_PREHEAT_1_END " " MSG_E6, lcd_preheat_m1_e5_only);
  799. #else
  800. MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H6, lcd_preheat_m1_e5_only);
  801. #endif
  802. #endif // HOTENDS > 5
  803. #endif // HOTENDS > 4
  804. #endif // HOTENDS > 3
  805. #endif // HOTENDS > 2
  806. MENU_ITEM(function, MSG_PREHEAT_1_ALL, lcd_preheat_m1_all);
  807. #endif // HOTENDS > 1
  808. #if HAS_HEATED_BED
  809. MENU_ITEM(function, MSG_PREHEAT_1_BEDONLY, lcd_preheat_m1_bedonly);
  810. #endif
  811. END_MENU();
  812. }
  813. void menu_preheat_m2() {
  814. START_MENU();
  815. MENU_BACK(MSG_TEMPERATURE);
  816. #if HOTENDS == 1
  817. #if HAS_HEATED_BED
  818. MENU_ITEM(function, MSG_PREHEAT_2, lcd_preheat_m2_e0);
  819. MENU_ITEM(function, MSG_PREHEAT_2_END, lcd_preheat_m2_e0_only);
  820. #else
  821. MENU_ITEM(function, MSG_PREHEAT_2, lcd_preheat_m2_e0_only);
  822. #endif
  823. #elif HOTENDS > 1
  824. #if HAS_HEATED_BED
  825. MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H1, lcd_preheat_m2_e0);
  826. MENU_ITEM(function, MSG_PREHEAT_2_END " " MSG_E1, lcd_preheat_m2_e0_only);
  827. MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H2, lcd_preheat_m2_e1);
  828. MENU_ITEM(function, MSG_PREHEAT_2_END " " MSG_E2, lcd_preheat_m2_e1_only);
  829. #else
  830. MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H1, lcd_preheat_m2_e0_only);
  831. MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H2, lcd_preheat_m2_e1_only);
  832. #endif
  833. #if HOTENDS > 2
  834. #if HAS_HEATED_BED
  835. MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H3, lcd_preheat_m2_e2);
  836. MENU_ITEM(function, MSG_PREHEAT_2_END " " MSG_E3, lcd_preheat_m2_e2_only);
  837. #else
  838. MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H3, lcd_preheat_m2_e2_only);
  839. #endif
  840. #if HOTENDS > 3
  841. #if HAS_HEATED_BED
  842. MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H4, lcd_preheat_m2_e3);
  843. MENU_ITEM(function, MSG_PREHEAT_2_END " " MSG_E4, lcd_preheat_m2_e3_only);
  844. #else
  845. MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H4, lcd_preheat_m2_e3_only);
  846. #endif
  847. #if HOTENDS > 4
  848. #if HAS_HEATED_BED
  849. MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H5, lcd_preheat_m2_e4);
  850. MENU_ITEM(function, MSG_PREHEAT_2_END " " MSG_E5, lcd_preheat_m2_e4_only);
  851. #else
  852. MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H5, lcd_preheat_m2_e4_only);
  853. #endif
  854. #if HOTENDS > 5
  855. #if HAS_HEATED_BED
  856. MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H6, lcd_preheat_m2_e5);
  857. MENU_ITEM(function, MSG_PREHEAT_2_END " " MSG_E6, lcd_preheat_m2_e5_only);
  858. #else
  859. MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H6, lcd_preheat_m2_e5_only);
  860. #endif
  861. #endif // HOTENDS > 5
  862. #endif // HOTENDS > 4
  863. #endif // HOTENDS > 3
  864. #endif // HOTENDS > 2
  865. MENU_ITEM(function, MSG_PREHEAT_2_ALL, lcd_preheat_m2_all);
  866. #endif // HOTENDS > 1
  867. #if HAS_HEATED_BED
  868. MENU_ITEM(function, MSG_PREHEAT_2_BEDONLY, lcd_preheat_m2_bedonly);
  869. #endif
  870. END_MENU();
  871. }
  872. #endif // HAS_TEMP_HOTEND || HAS_HEATED_BED
  873. void lcd_cooldown() {
  874. zero_fan_speeds();
  875. thermalManager.disable_all_heaters();
  876. lcd_return_to_status();
  877. }
  878. #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(PID_AUTOTUNE_MENU) || ENABLED(ADVANCED_PAUSE_FEATURE)
  879. void lcd_enqueue_command(const char * const cmd) {
  880. no_reentry = true;
  881. enqueue_and_echo_command_now(cmd);
  882. no_reentry = false;
  883. }
  884. void lcd_enqueue_commands_P(PGM_P const cmd) {
  885. no_reentry = true;
  886. enqueue_and_echo_commands_now_P(cmd);
  887. no_reentry = false;
  888. }
  889. #endif
  890. #if ENABLED(EEPROM_SETTINGS)
  891. void lcd_store_settings() { lcd_completion_feedback(settings.save()); }
  892. void lcd_load_settings() { lcd_completion_feedback(settings.load()); }
  893. #if DISABLED(SLIM_LCD_MENUS)
  894. static void lcd_init_eeprom() {
  895. lcd_completion_feedback(settings.init_eeprom());
  896. lcd_goto_previous_menu();
  897. }
  898. static void lcd_init_eeprom_confirm() {
  899. START_MENU();
  900. MENU_BACK(MSG_ADVANCED_SETTINGS);
  901. MENU_ITEM(function, MSG_INIT_EEPROM, lcd_init_eeprom);
  902. END_MENU();
  903. }
  904. #endif
  905. #endif
  906. void _lcd_draw_homing() {
  907. constexpr uint8_t line = (LCD_HEIGHT - 1) / 2;
  908. if (lcdDrawUpdate) lcd_implementation_drawmenu_static(line, PSTR(MSG_LEVEL_BED_HOMING));
  909. lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
  910. }
  911. #if ENABLED(LEVEL_BED_CORNERS)
  912. /**
  913. * Level corners, starting in the front-left corner.
  914. */
  915. static int8_t bed_corner;
  916. void _lcd_goto_next_corner() {
  917. line_to_z(4.0);
  918. switch (bed_corner) {
  919. case 0:
  920. current_position[X_AXIS] = X_MIN_BED + LEVEL_CORNERS_INSET;
  921. current_position[Y_AXIS] = Y_MIN_BED + LEVEL_CORNERS_INSET;
  922. break;
  923. case 1:
  924. current_position[X_AXIS] = X_MAX_BED - LEVEL_CORNERS_INSET;
  925. break;
  926. case 2:
  927. current_position[Y_AXIS] = Y_MAX_BED - LEVEL_CORNERS_INSET;
  928. break;
  929. case 3:
  930. current_position[X_AXIS] = X_MIN_BED + LEVEL_CORNERS_INSET;
  931. break;
  932. #if ENABLED(LEVEL_CENTER_TOO)
  933. case 4:
  934. current_position[X_AXIS] = X_CENTER;
  935. current_position[Y_AXIS] = Y_CENTER;
  936. break;
  937. #endif
  938. }
  939. planner.buffer_line(current_position, MMM_TO_MMS(manual_feedrate_mm_m[X_AXIS]), active_extruder);
  940. line_to_z(0.0);
  941. if (++bed_corner > 3
  942. #if ENABLED(LEVEL_CENTER_TOO)
  943. + 1
  944. #endif
  945. ) bed_corner = 0;
  946. }
  947. void _lcd_corner_submenu() {
  948. START_MENU();
  949. MENU_ITEM(function,
  950. #if ENABLED(LEVEL_CENTER_TOO)
  951. MSG_LEVEL_BED_NEXT_POINT
  952. #else
  953. MSG_NEXT_CORNER
  954. #endif
  955. , _lcd_goto_next_corner);
  956. MENU_ITEM(function, MSG_BACK, lcd_goto_previous_menu_no_defer);
  957. END_MENU();
  958. }
  959. void _lcd_level_bed_corners_homing() {
  960. _lcd_draw_homing();
  961. if (all_axes_homed()) {
  962. bed_corner = 0;
  963. lcd_goto_screen(_lcd_corner_submenu);
  964. _lcd_goto_next_corner();
  965. }
  966. }
  967. void _lcd_level_bed_corners() {
  968. defer_return_to_status = true;
  969. if (!all_axes_known()) {
  970. axis_homed = 0;
  971. enqueue_and_echo_commands_P(PSTR("G28"));
  972. }
  973. lcd_goto_screen(_lcd_level_bed_corners_homing);
  974. }
  975. #endif // LEVEL_BED_CORNERS
  976. #if ENABLED(LCD_BED_LEVELING) && (ENABLED(PROBE_MANUALLY) || ENABLED(MESH_BED_LEVELING))
  977. /**
  978. *
  979. * "Motion" > "Level Bed" handlers
  980. *
  981. */
  982. static uint8_t manual_probe_index;
  983. // LCD probed points are from defaults
  984. constexpr uint8_t total_probe_points = (
  985. #if ENABLED(AUTO_BED_LEVELING_3POINT)
  986. 3
  987. #elif ABL_GRID || ENABLED(MESH_BED_LEVELING)
  988. GRID_MAX_POINTS
  989. #endif
  990. );
  991. bool lcd_wait_for_move;
  992. //
  993. // Bed leveling is done. Wait for G29 to complete.
  994. // A flag is used so that this can release control
  995. // and allow the command queue to be processed.
  996. //
  997. // When G29 finishes the last move:
  998. // - Raise Z to the "manual probe height"
  999. // - Don't return until done.
  1000. //
  1001. // ** This blocks the command queue! **
  1002. //
  1003. void _lcd_level_bed_done() {
  1004. if (!lcd_wait_for_move) {
  1005. #if MANUAL_PROBE_HEIGHT > 0 && DISABLED(MESH_BED_LEVELING)
  1006. // Display "Done" screen and wait for moves to complete
  1007. line_to_z(MANUAL_PROBE_HEIGHT);
  1008. lcd_synchronize(PSTR(MSG_LEVEL_BED_DONE));
  1009. #endif
  1010. lcd_goto_previous_menu_no_defer();
  1011. lcd_completion_feedback();
  1012. }
  1013. if (lcdDrawUpdate) lcd_implementation_drawmenu_static(LCD_HEIGHT >= 4 ? 1 : 0, PSTR(MSG_LEVEL_BED_DONE));
  1014. lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
  1015. }
  1016. void _lcd_level_goto_next_point();
  1017. /**
  1018. * Step 7: Get the Z coordinate, click goes to the next point or exits
  1019. */
  1020. void _lcd_level_bed_get_z() {
  1021. ENCODER_DIRECTION_NORMAL();
  1022. if (use_click()) {
  1023. //
  1024. // Save the current Z position and move
  1025. //
  1026. // If done...
  1027. if (++manual_probe_index >= total_probe_points) {
  1028. //
  1029. // The last G29 records the point and enables bed leveling
  1030. //
  1031. lcd_wait_for_move = true;
  1032. lcd_goto_screen(_lcd_level_bed_done);
  1033. #if ENABLED(MESH_BED_LEVELING)
  1034. enqueue_and_echo_commands_P(PSTR("G29 S2"));
  1035. #elif ENABLED(PROBE_MANUALLY)
  1036. enqueue_and_echo_commands_P(PSTR("G29 V1"));
  1037. #endif
  1038. }
  1039. else
  1040. _lcd_level_goto_next_point();
  1041. return;
  1042. }
  1043. //
  1044. // Encoder knob or keypad buttons adjust the Z position
  1045. //
  1046. if (encoderPosition) {
  1047. const float z = current_position[Z_AXIS] + float((int32_t)encoderPosition) * (MBL_Z_STEP);
  1048. line_to_z(constrain(z, -(LCD_PROBE_Z_RANGE) * 0.5f, (LCD_PROBE_Z_RANGE) * 0.5f));
  1049. lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
  1050. encoderPosition = 0;
  1051. }
  1052. //
  1053. // Draw on first display, then only on Z change
  1054. //
  1055. if (lcdDrawUpdate) {
  1056. const float v = current_position[Z_AXIS];
  1057. lcd_implementation_drawedit(PSTR(MSG_MOVE_Z), ftostr43sign(v + (v < 0 ? -0.0001f : 0.0001f), '+'));
  1058. }
  1059. }
  1060. /**
  1061. * Step 6: Display "Next point: 1 / 9" while waiting for move to finish
  1062. */
  1063. void _lcd_level_bed_moving() {
  1064. if (lcdDrawUpdate) {
  1065. char msg[10];
  1066. sprintf_P(msg, PSTR("%i / %u"), (int)(manual_probe_index + 1), total_probe_points);
  1067. lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_NEXT_POINT), msg);
  1068. }
  1069. lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
  1070. if (!lcd_wait_for_move) lcd_goto_screen(_lcd_level_bed_get_z);
  1071. }
  1072. /**
  1073. * Step 5: Initiate a move to the next point
  1074. */
  1075. void _lcd_level_goto_next_point() {
  1076. lcd_goto_screen(_lcd_level_bed_moving);
  1077. // G29 Records Z, moves, and signals when it pauses
  1078. lcd_wait_for_move = true;
  1079. #if ENABLED(MESH_BED_LEVELING)
  1080. enqueue_and_echo_commands_P(manual_probe_index ? PSTR("G29 S2") : PSTR("G29 S1"));
  1081. #elif ENABLED(PROBE_MANUALLY)
  1082. enqueue_and_echo_commands_P(PSTR("G29 V1"));
  1083. #endif
  1084. }
  1085. /**
  1086. * Step 4: Display "Click to Begin", wait for click
  1087. * Move to the first probe position
  1088. */
  1089. void _lcd_level_bed_homing_done() {
  1090. if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_WAITING));
  1091. if (use_click()) {
  1092. manual_probe_index = 0;
  1093. _lcd_level_goto_next_point();
  1094. }
  1095. }
  1096. /**
  1097. * Step 3: Display "Homing XYZ" - Wait for homing to finish
  1098. */
  1099. void _lcd_level_bed_homing() {
  1100. _lcd_draw_homing();
  1101. if (all_axes_homed()) lcd_goto_screen(_lcd_level_bed_homing_done);
  1102. }
  1103. #if ENABLED(PROBE_MANUALLY)
  1104. extern bool g29_in_progress;
  1105. #endif
  1106. /**
  1107. * Step 2: Continue Bed Leveling...
  1108. */
  1109. void _lcd_level_bed_continue() {
  1110. defer_return_to_status = true;
  1111. axis_homed = 0;
  1112. lcd_goto_screen(_lcd_level_bed_homing);
  1113. enqueue_and_echo_commands_P(PSTR("G28"));
  1114. }
  1115. #elif ENABLED(AUTO_BED_LEVELING_UBL)
  1116. void _lcd_ubl_level_bed();
  1117. static int16_t ubl_storage_slot = 0,
  1118. custom_hotend_temp = 190,
  1119. side_points = 3,
  1120. ubl_fillin_amount = 5,
  1121. ubl_height_amount = 1,
  1122. n_edit_pts = 1,
  1123. x_plot = 0,
  1124. y_plot = 0;
  1125. #if HAS_HEATED_BED
  1126. static int16_t custom_bed_temp = 50;
  1127. #endif
  1128. /**
  1129. * UBL Build Custom Mesh Command
  1130. */
  1131. void _lcd_ubl_build_custom_mesh() {
  1132. char UBL_LCD_GCODE[20];
  1133. enqueue_and_echo_commands_P(PSTR("G28"));
  1134. #if HAS_HEATED_BED
  1135. sprintf_P(UBL_LCD_GCODE, PSTR("M190 S%i"), custom_bed_temp);
  1136. lcd_enqueue_command(UBL_LCD_GCODE);
  1137. #endif
  1138. sprintf_P(UBL_LCD_GCODE, PSTR("M109 S%i"), custom_hotend_temp);
  1139. lcd_enqueue_command(UBL_LCD_GCODE);
  1140. enqueue_and_echo_commands_P(PSTR("G29 P1"));
  1141. }
  1142. /**
  1143. * UBL Custom Mesh submenu
  1144. *
  1145. * << Build Mesh
  1146. * Hotend Temp: ---
  1147. * Bed Temp: ---
  1148. * Build Custom Mesh
  1149. */
  1150. void _lcd_ubl_custom_mesh() {
  1151. START_MENU();
  1152. MENU_BACK(MSG_UBL_BUILD_MESH_MENU);
  1153. MENU_ITEM_EDIT(int3, MSG_UBL_HOTEND_TEMP_CUSTOM, &custom_hotend_temp, EXTRUDE_MINTEMP, (HEATER_0_MAXTEMP - 10));
  1154. #if HAS_HEATED_BED
  1155. MENU_ITEM_EDIT(int3, MSG_UBL_BED_TEMP_CUSTOM, &custom_bed_temp, BED_MINTEMP, (BED_MAXTEMP - 15));
  1156. #endif
  1157. MENU_ITEM(function, MSG_UBL_BUILD_CUSTOM_MESH, _lcd_ubl_build_custom_mesh);
  1158. END_MENU();
  1159. }
  1160. /**
  1161. * UBL Adjust Mesh Height Command
  1162. */
  1163. void _lcd_ubl_adjust_height_cmd() {
  1164. char UBL_LCD_GCODE[16];
  1165. const int ind = ubl_height_amount > 0 ? 9 : 10;
  1166. strcpy_P(UBL_LCD_GCODE, PSTR("G29 P6 C -"));
  1167. sprintf_P(&UBL_LCD_GCODE[ind], PSTR(".%i"), ABS(ubl_height_amount));
  1168. lcd_enqueue_command(UBL_LCD_GCODE);
  1169. }
  1170. /**
  1171. * UBL Adjust Mesh Height submenu
  1172. *
  1173. * << Edit Mesh
  1174. * Height Amount: ---
  1175. * Adjust Mesh Height
  1176. * << Info Screen
  1177. */
  1178. void _menu_ubl_height_adjust() {
  1179. START_MENU();
  1180. MENU_BACK(MSG_UBL_EDIT_MESH_MENU);
  1181. MENU_ITEM_EDIT_CALLBACK(int3, MSG_UBL_MESH_HEIGHT_AMOUNT, &ubl_height_amount, -9, 9, _lcd_ubl_adjust_height_cmd);
  1182. MENU_ITEM(function, MSG_WATCH, lcd_return_to_status);
  1183. END_MENU();
  1184. }
  1185. /**
  1186. * UBL Edit Mesh submenu
  1187. *
  1188. * << UBL Tools
  1189. * Fine Tune All
  1190. * Fine Tune Closest
  1191. * - Adjust Mesh Height >>
  1192. * << Info Screen
  1193. */
  1194. void _lcd_ubl_edit_mesh() {
  1195. START_MENU();
  1196. MENU_BACK(MSG_UBL_TOOLS);
  1197. MENU_ITEM(gcode, MSG_UBL_FINE_TUNE_ALL, PSTR("G29 P4 R999 T"));
  1198. MENU_ITEM(gcode, MSG_UBL_FINE_TUNE_CLOSEST, PSTR("G29 P4 T"));
  1199. MENU_ITEM(submenu, MSG_UBL_MESH_HEIGHT_ADJUST, _menu_ubl_height_adjust);
  1200. MENU_ITEM(function, MSG_WATCH, lcd_return_to_status);
  1201. END_MENU();
  1202. }
  1203. /**
  1204. * UBL Validate Custom Mesh Command
  1205. */
  1206. void _lcd_ubl_validate_custom_mesh() {
  1207. char UBL_LCD_GCODE[24];
  1208. const int temp =
  1209. #if HAS_HEATED_BED
  1210. custom_bed_temp
  1211. #else
  1212. 0
  1213. #endif
  1214. ;
  1215. sprintf_P(UBL_LCD_GCODE, PSTR("G26 C B%i H%i P"), temp, custom_hotend_temp);
  1216. lcd_enqueue_commands_P(PSTR("G28"));
  1217. lcd_enqueue_command(UBL_LCD_GCODE);
  1218. }
  1219. /**
  1220. * UBL Validate Mesh submenu
  1221. *
  1222. * << UBL Tools
  1223. * Mesh Validation with Material 1
  1224. * Mesh Validation with Material 2
  1225. * Validate Custom Mesh
  1226. * << Info Screen
  1227. */
  1228. void _lcd_ubl_validate_mesh() {
  1229. START_MENU();
  1230. MENU_BACK(MSG_UBL_TOOLS);
  1231. #if HAS_HEATED_BED
  1232. MENU_ITEM(gcode, MSG_UBL_VALIDATE_MESH_M1, PSTR("G28\nG26 C B" STRINGIFY(PREHEAT_1_TEMP_BED) " H" STRINGIFY(PREHEAT_1_TEMP_HOTEND) " P"));
  1233. MENU_ITEM(gcode, MSG_UBL_VALIDATE_MESH_M2, PSTR("G28\nG26 C B" STRINGIFY(PREHEAT_2_TEMP_BED) " H" STRINGIFY(PREHEAT_2_TEMP_HOTEND) " P"));
  1234. #else
  1235. MENU_ITEM(gcode, MSG_UBL_VALIDATE_MESH_M1, PSTR("G28\nG26 C B0 H" STRINGIFY(PREHEAT_1_TEMP_HOTEND) " P"));
  1236. MENU_ITEM(gcode, MSG_UBL_VALIDATE_MESH_M2, PSTR("G28\nG26 C B0 H" STRINGIFY(PREHEAT_2_TEMP_HOTEND) " P"));
  1237. #endif
  1238. MENU_ITEM(function, MSG_UBL_VALIDATE_CUSTOM_MESH, _lcd_ubl_validate_custom_mesh);
  1239. MENU_ITEM(function, MSG_WATCH, lcd_return_to_status);
  1240. END_MENU();
  1241. }
  1242. /**
  1243. * UBL Grid Leveling Command
  1244. */
  1245. void _lcd_ubl_grid_level_cmd() {
  1246. char UBL_LCD_GCODE[10];
  1247. sprintf_P(UBL_LCD_GCODE, PSTR("G29 J%i"), side_points);
  1248. lcd_enqueue_command(UBL_LCD_GCODE);
  1249. }
  1250. /**
  1251. * UBL Grid Leveling submenu
  1252. *
  1253. * << UBL Tools
  1254. * Side points: ---
  1255. * Level Mesh
  1256. */
  1257. void _lcd_ubl_grid_level() {
  1258. START_MENU();
  1259. MENU_BACK(MSG_UBL_TOOLS);
  1260. MENU_ITEM_EDIT(int3, MSG_UBL_SIDE_POINTS, &side_points, 2, 6);
  1261. MENU_ITEM(function, MSG_UBL_MESH_LEVEL, _lcd_ubl_grid_level_cmd);
  1262. END_MENU();
  1263. }
  1264. /**
  1265. * UBL Mesh Leveling submenu
  1266. *
  1267. * << UBL Tools
  1268. * 3-Point Mesh Leveling
  1269. * - Grid Mesh Leveling >>
  1270. * << Info Screen
  1271. */
  1272. void _lcd_ubl_mesh_leveling() {
  1273. START_MENU();
  1274. MENU_BACK(MSG_UBL_TOOLS);
  1275. MENU_ITEM(gcode, MSG_UBL_3POINT_MESH_LEVELING, PSTR("G29 J0"));
  1276. MENU_ITEM(submenu, MSG_UBL_GRID_MESH_LEVELING, _lcd_ubl_grid_level);
  1277. MENU_ITEM(function, MSG_WATCH, lcd_return_to_status);
  1278. END_MENU();
  1279. }
  1280. /**
  1281. * UBL Fill-in Amount Mesh Command
  1282. */
  1283. void _lcd_ubl_fillin_amount_cmd() {
  1284. char UBL_LCD_GCODE[16];
  1285. sprintf_P(UBL_LCD_GCODE, PSTR("G29 P3 R C.%i"), ubl_fillin_amount);
  1286. lcd_enqueue_command(UBL_LCD_GCODE);
  1287. }
  1288. /**
  1289. * UBL Fill-in Mesh submenu
  1290. *
  1291. * << Build Mesh
  1292. * Fill-in Amount: ---
  1293. * Fill-in Mesh
  1294. * Smart Fill-in
  1295. * Manual Fill-in
  1296. * << Info Screen
  1297. */
  1298. void _menu_ubl_fillin() {
  1299. START_MENU();
  1300. MENU_BACK(MSG_UBL_BUILD_MESH_MENU);
  1301. MENU_ITEM_EDIT_CALLBACK(int3, MSG_UBL_FILLIN_AMOUNT, &ubl_fillin_amount, 0, 9, _lcd_ubl_fillin_amount_cmd);
  1302. MENU_ITEM(gcode, MSG_UBL_SMART_FILLIN, PSTR("G29 P3 T0"));
  1303. MENU_ITEM(gcode, MSG_UBL_MANUAL_FILLIN, PSTR("G29 P2 B T0"));
  1304. MENU_ITEM(function, MSG_WATCH, lcd_return_to_status);
  1305. END_MENU();
  1306. }
  1307. void _lcd_ubl_invalidate() {
  1308. ubl.invalidate();
  1309. SERIAL_PROTOCOLLNPGM("Mesh invalidated.");
  1310. }
  1311. /**
  1312. * UBL Build Mesh submenu
  1313. *
  1314. * << UBL Tools
  1315. * Build Mesh with Material 1
  1316. * Build Mesh with Material 2
  1317. * - Build Custom Mesh >>
  1318. * Build Cold Mesh
  1319. * - Fill-in Mesh >>
  1320. * Continue Bed Mesh
  1321. * Invalidate All
  1322. * Invalidate Closest
  1323. * << Info Screen
  1324. */
  1325. void _lcd_ubl_build_mesh() {
  1326. START_MENU();
  1327. MENU_BACK(MSG_UBL_TOOLS);
  1328. #if HAS_HEATED_BED
  1329. MENU_ITEM(gcode, MSG_UBL_BUILD_MESH_M1, PSTR(
  1330. "G28\n"
  1331. "M190 S" STRINGIFY(PREHEAT_1_TEMP_BED) "\n"
  1332. "M109 S" STRINGIFY(PREHEAT_1_TEMP_HOTEND) "\n"
  1333. "G29 P1\n"
  1334. "M104 S0\n"
  1335. "M140 S0"
  1336. ));
  1337. MENU_ITEM(gcode, MSG_UBL_BUILD_MESH_M2, PSTR(
  1338. "G28\n"
  1339. "M190 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\n"
  1340. "M109 S" STRINGIFY(PREHEAT_2_TEMP_HOTEND) "\n"
  1341. "G29 P1\n"
  1342. "M104 S0\n"
  1343. "M140 S0"
  1344. ));
  1345. #else
  1346. MENU_ITEM(gcode, MSG_UBL_BUILD_MESH_M1, PSTR(
  1347. "G28\n"
  1348. "M109 S" STRINGIFY(PREHEAT_1_TEMP_HOTEND) "\n"
  1349. "G29 P1\n"
  1350. "M104 S0"
  1351. ));
  1352. MENU_ITEM(gcode, MSG_UBL_BUILD_MESH_M2, PSTR(
  1353. "G28\n"
  1354. "M109 S" STRINGIFY(PREHEAT_2_TEMP_HOTEND) "\n"
  1355. "G29 P1\n"
  1356. "M104 S0"
  1357. ));
  1358. #endif
  1359. MENU_ITEM(submenu, MSG_UBL_BUILD_CUSTOM_MESH, _lcd_ubl_custom_mesh);
  1360. MENU_ITEM(gcode, MSG_UBL_BUILD_COLD_MESH, PSTR("G28\nG29 P1"));
  1361. MENU_ITEM(submenu, MSG_UBL_FILLIN_MESH, _menu_ubl_fillin);
  1362. MENU_ITEM(gcode, MSG_UBL_CONTINUE_MESH, PSTR("G29 P1 C"));
  1363. MENU_ITEM(function, MSG_UBL_INVALIDATE_ALL, _lcd_ubl_invalidate);
  1364. MENU_ITEM(gcode, MSG_UBL_INVALIDATE_CLOSEST, PSTR("G29 I"));
  1365. MENU_ITEM(function, MSG_WATCH, lcd_return_to_status);
  1366. END_MENU();
  1367. }
  1368. /**
  1369. * UBL Load Mesh Command
  1370. */
  1371. void _lcd_ubl_load_mesh_cmd() {
  1372. char UBL_LCD_GCODE[25];
  1373. sprintf_P(UBL_LCD_GCODE, PSTR("G29 L%i"), ubl_storage_slot);
  1374. lcd_enqueue_command(UBL_LCD_GCODE);
  1375. sprintf_P(UBL_LCD_GCODE, PSTR("M117 " MSG_MESH_LOADED), ubl_storage_slot);
  1376. lcd_enqueue_command(UBL_LCD_GCODE);
  1377. }
  1378. /**
  1379. * UBL Save Mesh Command
  1380. */
  1381. void _lcd_ubl_save_mesh_cmd() {
  1382. char UBL_LCD_GCODE[25];
  1383. sprintf_P(UBL_LCD_GCODE, PSTR("G29 S%i"), ubl_storage_slot);
  1384. lcd_enqueue_command(UBL_LCD_GCODE);
  1385. sprintf_P(UBL_LCD_GCODE, PSTR("M117 " MSG_MESH_SAVED), ubl_storage_slot);
  1386. lcd_enqueue_command(UBL_LCD_GCODE);
  1387. }
  1388. /**
  1389. * UBL Mesh Storage submenu
  1390. *
  1391. * << Unified Bed Leveling
  1392. * Memory Slot: ---
  1393. * Load Bed Mesh
  1394. * Save Bed Mesh
  1395. */
  1396. void _lcd_ubl_storage_mesh() {
  1397. int16_t a = settings.calc_num_meshes();
  1398. START_MENU();
  1399. MENU_BACK(MSG_UBL_LEVEL_BED);
  1400. if (!WITHIN(ubl_storage_slot, 0, a - 1)) {
  1401. STATIC_ITEM(MSG_NO_STORAGE);
  1402. }
  1403. else {
  1404. MENU_ITEM_EDIT(int3, MSG_UBL_STORAGE_SLOT, &ubl_storage_slot, 0, a - 1);
  1405. MENU_ITEM(function, MSG_UBL_LOAD_MESH, _lcd_ubl_load_mesh_cmd);
  1406. MENU_ITEM(function, MSG_UBL_SAVE_MESH, _lcd_ubl_save_mesh_cmd);
  1407. }
  1408. END_MENU();
  1409. }
  1410. /**
  1411. * UBL LCD "radar" map homing
  1412. */
  1413. void _lcd_ubl_output_map_lcd();
  1414. void _lcd_ubl_map_homing() {
  1415. defer_return_to_status = true;
  1416. _lcd_draw_homing();
  1417. if (all_axes_homed()) {
  1418. ubl.lcd_map_control = true; // Return to the map screen
  1419. lcd_goto_screen(_lcd_ubl_output_map_lcd);
  1420. }
  1421. }
  1422. /**
  1423. * UBL LCD "radar" map point editing
  1424. */
  1425. void _lcd_ubl_map_lcd_edit_cmd() {
  1426. char UBL_LCD_GCODE[50], str[10], str2[10];
  1427. dtostrf(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]), 0, 2, str);
  1428. dtostrf(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]), 0, 2, str2);
  1429. snprintf_P(UBL_LCD_GCODE, sizeof(UBL_LCD_GCODE), PSTR("G29 P4 X%s Y%s R%i"), str, str2, n_edit_pts);
  1430. lcd_enqueue_command(UBL_LCD_GCODE);
  1431. }
  1432. /**
  1433. * UBL LCD Map Movement
  1434. */
  1435. void ubl_map_move_to_xy() {
  1436. current_position[X_AXIS] = pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]);
  1437. current_position[Y_AXIS] = pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]);
  1438. planner.buffer_line(current_position, MMM_TO_MMS(XY_PROBE_SPEED), active_extruder);
  1439. }
  1440. /**
  1441. * UBL LCD "radar" map
  1442. */
  1443. void set_current_from_steppers_for_axis(const AxisEnum axis);
  1444. void sync_plan_position();
  1445. void _lcd_do_nothing() {}
  1446. void _lcd_hard_stop() {
  1447. const screenFunc_t old_screen = currentScreen;
  1448. currentScreen = _lcd_do_nothing;
  1449. planner.quick_stop();
  1450. currentScreen = old_screen;
  1451. set_current_from_steppers_for_axis(ALL_AXES);
  1452. sync_plan_position();
  1453. }
  1454. void _lcd_ubl_output_map_lcd() {
  1455. static int16_t step_scaler = 0;
  1456. if (use_click()) return _lcd_ubl_map_lcd_edit_cmd();
  1457. ENCODER_DIRECTION_NORMAL();
  1458. if (encoderPosition) {
  1459. step_scaler += (int32_t)encoderPosition;
  1460. x_plot += step_scaler / (ENCODER_STEPS_PER_MENU_ITEM);
  1461. if (ABS(step_scaler) >= ENCODER_STEPS_PER_MENU_ITEM) step_scaler = 0;
  1462. encoderPosition = 0;
  1463. lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
  1464. }
  1465. // Encoder to the right (++)
  1466. if (x_plot >= GRID_MAX_POINTS_X) { x_plot = 0; y_plot++; }
  1467. if (y_plot >= GRID_MAX_POINTS_Y) y_plot = 0;
  1468. // Encoder to the left (--)
  1469. if (x_plot <= GRID_MAX_POINTS_X - (GRID_MAX_POINTS_X + 1)) { x_plot = GRID_MAX_POINTS_X - 1; y_plot--; }
  1470. if (y_plot <= GRID_MAX_POINTS_Y - (GRID_MAX_POINTS_Y + 1)) y_plot = GRID_MAX_POINTS_Y - 1;
  1471. // Prevent underrun/overrun of plot numbers
  1472. x_plot = constrain(x_plot, GRID_MAX_POINTS_X - (GRID_MAX_POINTS_X + 1), GRID_MAX_POINTS_X + 1);
  1473. y_plot = constrain(y_plot, GRID_MAX_POINTS_Y - (GRID_MAX_POINTS_Y + 1), GRID_MAX_POINTS_Y + 1);
  1474. // Determine number of points to edit
  1475. #if IS_KINEMATIC
  1476. n_edit_pts = 9; //TODO: Delta accessible edit points
  1477. #else
  1478. const bool xc = WITHIN(x_plot, 1, GRID_MAX_POINTS_X - 2),
  1479. yc = WITHIN(y_plot, 1, GRID_MAX_POINTS_Y - 2);
  1480. n_edit_pts = yc ? (xc ? 9 : 6) : (xc ? 6 : 4); // Corners
  1481. #endif
  1482. if (lcdDrawUpdate) {
  1483. lcd_implementation_ubl_plot(x_plot, y_plot);
  1484. if (planner.movesplanned()) // If the nozzle is already moving, cancel the move.
  1485. _lcd_hard_stop();
  1486. ubl_map_move_to_xy(); // Move to new location
  1487. }
  1488. }
  1489. /**
  1490. * UBL Homing before LCD map
  1491. */
  1492. void _lcd_ubl_output_map_lcd_cmd() {
  1493. if (!all_axes_known()) {
  1494. axis_homed = 0;
  1495. enqueue_and_echo_commands_P(PSTR("G28"));
  1496. }
  1497. lcd_goto_screen(_lcd_ubl_map_homing);
  1498. }
  1499. /**
  1500. * UBL Output map submenu
  1501. *
  1502. * << Unified Bed Leveling
  1503. * Output for Host
  1504. * Output for CSV
  1505. * Off Printer Backup
  1506. * Output Mesh Map
  1507. */
  1508. void _lcd_ubl_output_map() {
  1509. START_MENU();
  1510. MENU_BACK(MSG_UBL_LEVEL_BED);
  1511. MENU_ITEM(gcode, MSG_UBL_OUTPUT_MAP_HOST, PSTR("G29 T0"));
  1512. MENU_ITEM(gcode, MSG_UBL_OUTPUT_MAP_CSV, PSTR("G29 T1"));
  1513. MENU_ITEM(gcode, MSG_UBL_OUTPUT_MAP_BACKUP, PSTR("G29 S-1"));
  1514. MENU_ITEM(function, MSG_UBL_OUTPUT_MAP, _lcd_ubl_output_map_lcd_cmd);
  1515. END_MENU();
  1516. }
  1517. /**
  1518. * UBL Tools submenu
  1519. *
  1520. * << Unified Bed Leveling
  1521. * - Build Mesh >>
  1522. * - Validate Mesh >>
  1523. * - Edit Mesh >>
  1524. * - Mesh Leveling >>
  1525. */
  1526. void _menu_ubl_tools() {
  1527. START_MENU();
  1528. MENU_BACK(MSG_UBL_LEVEL_BED);
  1529. MENU_ITEM(submenu, MSG_UBL_BUILD_MESH_MENU, _lcd_ubl_build_mesh);
  1530. MENU_ITEM(gcode, MSG_UBL_MANUAL_MESH, PSTR("G29 I999\nG29 P2 B T0"));
  1531. MENU_ITEM(submenu, MSG_UBL_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh);
  1532. MENU_ITEM(submenu, MSG_UBL_EDIT_MESH_MENU, _lcd_ubl_edit_mesh);
  1533. MENU_ITEM(submenu, MSG_UBL_MESH_LEVELING, _lcd_ubl_mesh_leveling);
  1534. END_MENU();
  1535. }
  1536. /**
  1537. * UBL Step-By-Step submenu
  1538. *
  1539. * << Unified Bed Leveling
  1540. * 1 Build Cold Mesh
  1541. * 2 Smart Fill-in
  1542. * - 3 Validate Mesh >>
  1543. * 4 Fine Tune All
  1544. * - 5 Validate Mesh >>
  1545. * 6 Fine Tune All
  1546. * 7 Save Bed Mesh
  1547. */
  1548. void _lcd_ubl_step_by_step() {
  1549. START_MENU();
  1550. MENU_BACK(MSG_UBL_LEVEL_BED);
  1551. MENU_ITEM(gcode, "1 " MSG_UBL_BUILD_COLD_MESH, PSTR("G28\nG29 P1"));
  1552. MENU_ITEM(gcode, "2 " MSG_UBL_SMART_FILLIN, PSTR("G29 P3 T0"));
  1553. MENU_ITEM(submenu, "3 " MSG_UBL_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh);
  1554. MENU_ITEM(gcode, "4 " MSG_UBL_FINE_TUNE_ALL, PSTR("G29 P4 R999 T"));
  1555. MENU_ITEM(submenu, "5 " MSG_UBL_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh);
  1556. MENU_ITEM(gcode, "6 " MSG_UBL_FINE_TUNE_ALL, PSTR("G29 P4 R999 T"));
  1557. MENU_ITEM(function, "7 " MSG_UBL_SAVE_MESH, _lcd_ubl_save_mesh_cmd);
  1558. END_MENU();
  1559. }
  1560. /**
  1561. * UBL System submenu
  1562. *
  1563. * << Motion
  1564. * - Manually Build Mesh >>
  1565. * - Activate UBL >>
  1566. * - Deactivate UBL >>
  1567. * - Step-By-Step UBL >>
  1568. * - Mesh Storage >>
  1569. * - Output Map >>
  1570. * - UBL Tools >>
  1571. * - Output UBL Info >>
  1572. */
  1573. void _lcd_ubl_level_bed() {
  1574. START_MENU();
  1575. MENU_BACK(MSG_MOTION);
  1576. MENU_ITEM(gcode, MSG_UBL_ACTIVATE_MESH, PSTR("G29 A"));
  1577. MENU_ITEM(gcode, MSG_UBL_DEACTIVATE_MESH, PSTR("G29 D"));
  1578. MENU_ITEM(submenu, MSG_UBL_STEP_BY_STEP_MENU, _lcd_ubl_step_by_step);
  1579. MENU_ITEM(function, MSG_UBL_MESH_EDIT, _lcd_ubl_output_map_lcd_cmd);
  1580. MENU_ITEM(submenu, MSG_UBL_STORAGE_MESH_MENU, _lcd_ubl_storage_mesh);
  1581. MENU_ITEM(submenu, MSG_UBL_OUTPUT_MAP, _lcd_ubl_output_map);
  1582. MENU_ITEM(submenu, MSG_UBL_TOOLS, _menu_ubl_tools);
  1583. MENU_ITEM(gcode, MSG_UBL_INFO_UBL, PSTR("G29 W"));
  1584. #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
  1585. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float3, MSG_Z_FADE_HEIGHT, &lcd_z_fade_height, 0, 100, _lcd_set_z_fade_height);
  1586. #endif
  1587. END_MENU();
  1588. }
  1589. #endif // AUTO_BED_LEVELING_UBL
  1590. #if ENABLED(LCD_BED_LEVELING) || (HAS_LEVELING && DISABLED(SLIM_LCD_MENUS))
  1591. void _lcd_toggle_bed_leveling() { set_bed_leveling_enabled(!planner.leveling_active); }
  1592. #endif
  1593. #if ENABLED(LCD_BED_LEVELING)
  1594. /**
  1595. * Step 1: Bed Level entry-point
  1596. *
  1597. * << Motion
  1598. * Auto Home (if homing needed)
  1599. * Leveling On/Off (if data exists, and homed)
  1600. * Fade Height: --- (Req: ENABLE_LEVELING_FADE_HEIGHT)
  1601. * Mesh Z Offset: --- (Req: MESH_BED_LEVELING)
  1602. * Z Probe Offset: --- (Req: HAS_BED_PROBE, Opt: BABYSTEP_ZPROBE_OFFSET)
  1603. * Level Bed >
  1604. * Level Corners > (if homed)
  1605. * Load Settings (Req: EEPROM_SETTINGS)
  1606. * Save Settings (Req: EEPROM_SETTINGS)
  1607. */
  1608. void menu_bed_leveling() {
  1609. START_MENU();
  1610. MENU_BACK(MSG_MOTION);
  1611. const bool is_homed = all_axes_known();
  1612. // Auto Home if not using manual probing
  1613. #if DISABLED(PROBE_MANUALLY) && DISABLED(MESH_BED_LEVELING)
  1614. if (!is_homed) MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28"));
  1615. #endif
  1616. // Level Bed
  1617. #if ENABLED(PROBE_MANUALLY) || ENABLED(MESH_BED_LEVELING)
  1618. // Manual leveling uses a guided procedure
  1619. MENU_ITEM(submenu, MSG_LEVEL_BED, _lcd_level_bed_continue);
  1620. #else
  1621. // Automatic leveling can just run the G-code
  1622. MENU_ITEM(gcode, MSG_LEVEL_BED, is_homed ? PSTR("G29") : PSTR("G28\nG29"));
  1623. #endif
  1624. // Homed and leveling is valid? Then leveling can be toggled.
  1625. if (is_homed && leveling_is_valid()) {
  1626. bool new_level_state = planner.leveling_active;
  1627. MENU_ITEM_EDIT_CALLBACK(bool, MSG_BED_LEVELING, &new_level_state, _lcd_toggle_bed_leveling);
  1628. }
  1629. // Z Fade Height
  1630. #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
  1631. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float3, MSG_Z_FADE_HEIGHT, &lcd_z_fade_height, 0, 100, _lcd_set_z_fade_height);
  1632. #endif
  1633. //
  1634. // MBL Z Offset
  1635. //
  1636. #if ENABLED(MESH_BED_LEVELING)
  1637. MENU_ITEM_EDIT(float43, MSG_BED_Z, &mbl.z_offset, -1, 1);
  1638. #endif
  1639. #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
  1640. MENU_ITEM(submenu, MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset);
  1641. #elif HAS_BED_PROBE
  1642. MENU_ITEM_EDIT(float52, MSG_ZPROBE_ZOFFSET, &zprobe_zoffset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
  1643. #endif
  1644. #if ENABLED(LEVEL_BED_CORNERS)
  1645. // Move to the next corner for leveling
  1646. MENU_ITEM(submenu, MSG_LEVEL_CORNERS, _lcd_level_bed_corners);
  1647. #endif
  1648. #if ENABLED(EEPROM_SETTINGS)
  1649. MENU_ITEM(function, MSG_LOAD_EEPROM, lcd_load_settings);
  1650. MENU_ITEM(function, MSG_STORE_EEPROM, lcd_store_settings);
  1651. #endif
  1652. END_MENU();
  1653. }
  1654. #endif // LCD_BED_LEVELING
  1655. /**
  1656. *
  1657. * "Movement" submenu
  1658. *
  1659. */
  1660. void menu_movement() {
  1661. START_MENU();
  1662. //
  1663. // ^ Main
  1664. //
  1665. MENU_BACK(MSG_MAIN);
  1666. //
  1667. // Move Axis
  1668. //
  1669. #if ENABLED(DELTA)
  1670. if (all_axes_homed())
  1671. #endif
  1672. MENU_ITEM(submenu, MSG_MOVE_AXIS, menu_move);
  1673. //
  1674. // Auto Home
  1675. //
  1676. MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28"));
  1677. #if ENABLED(INDIVIDUAL_AXIS_HOMING_MENU)
  1678. MENU_ITEM(gcode, MSG_AUTO_HOME_X, PSTR("G28 X"));
  1679. MENU_ITEM(gcode, MSG_AUTO_HOME_Y, PSTR("G28 Y"));
  1680. MENU_ITEM(gcode, MSG_AUTO_HOME_Z, PSTR("G28 Z"));
  1681. #endif
  1682. //
  1683. // TMC Z Calibration
  1684. //
  1685. #if ENABLED(TMC_Z_CALIBRATION)
  1686. MENU_ITEM(gcode, MSG_TMC_Z_CALIBRATION, PSTR("G28\nM915"));
  1687. #endif
  1688. //
  1689. // Level Bed
  1690. //
  1691. #if ENABLED(AUTO_BED_LEVELING_UBL)
  1692. MENU_ITEM(submenu, MSG_UBL_LEVEL_BED, _lcd_ubl_level_bed);
  1693. #elif ENABLED(LCD_BED_LEVELING)
  1694. #if ENABLED(PROBE_MANUALLY)
  1695. if (!g29_in_progress)
  1696. #endif
  1697. MENU_ITEM(submenu, MSG_BED_LEVELING, menu_bed_leveling);
  1698. #elif HAS_LEVELING && DISABLED(SLIM_LCD_MENUS)
  1699. #if DISABLED(PROBE_MANUALLY)
  1700. MENU_ITEM(gcode, MSG_LEVEL_BED, PSTR("G28\nG29"));
  1701. #endif
  1702. if (leveling_is_valid()) {
  1703. bool new_level_state = planner.leveling_active;
  1704. MENU_ITEM_EDIT_CALLBACK(bool, MSG_BED_LEVELING, &new_level_state, _lcd_toggle_bed_leveling);
  1705. }
  1706. #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
  1707. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float3, MSG_Z_FADE_HEIGHT, &lcd_z_fade_height, 0, 100, _lcd_set_z_fade_height);
  1708. #endif
  1709. #endif
  1710. #if ENABLED(LEVEL_BED_CORNERS) && DISABLED(LCD_BED_LEVELING)
  1711. MENU_ITEM(function, MSG_LEVEL_CORNERS, _lcd_level_bed_corners);
  1712. #endif
  1713. //
  1714. // Disable Steppers
  1715. //
  1716. MENU_ITEM(gcode, MSG_DISABLE_STEPPERS, PSTR("M84"));
  1717. END_MENU();
  1718. }
  1719. #if ENABLED(DELTA_CALIBRATION_MENU) || ENABLED(DELTA_AUTO_CALIBRATION)
  1720. void _man_probe_pt(const float &rx, const float &ry) {
  1721. do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
  1722. do_blocking_move_to_xy(rx, ry);
  1723. lcd_synchronize();
  1724. move_menu_scale = MAX(PROBE_MANUALLY_STEP, MIN_STEPS_PER_SEGMENT / float(DEFAULT_XYZ_STEPS_PER_UNIT));
  1725. lcd_goto_screen(lcd_move_z);
  1726. }
  1727. #endif // DELTA_CALIBRATION_MENU || DELTA_AUTO_CALIBRATION
  1728. #if ENABLED(DELTA_AUTO_CALIBRATION)
  1729. float lcd_probe_pt(const float &rx, const float &ry) {
  1730. _man_probe_pt(rx, ry);
  1731. KEEPALIVE_STATE(PAUSED_FOR_USER);
  1732. defer_return_to_status = true;
  1733. wait_for_user = true;
  1734. while (wait_for_user) idle();
  1735. KEEPALIVE_STATE(IN_HANDLER);
  1736. lcd_goto_previous_menu_no_defer();
  1737. return current_position[Z_AXIS];
  1738. }
  1739. #endif // DELTA_AUTO_CALIBRATION
  1740. #if ENABLED(DELTA_CALIBRATION_MENU)
  1741. void _lcd_calibrate_homing() {
  1742. _lcd_draw_homing();
  1743. if (all_axes_homed()) lcd_goto_previous_menu();
  1744. }
  1745. void _lcd_delta_calibrate_home() {
  1746. enqueue_and_echo_commands_P(PSTR("G28"));
  1747. lcd_goto_screen(_lcd_calibrate_homing);
  1748. }
  1749. void _goto_tower_x() { _man_probe_pt(cos(RADIANS(210)) * delta_calibration_radius, sin(RADIANS(210)) * delta_calibration_radius); }
  1750. void _goto_tower_y() { _man_probe_pt(cos(RADIANS(330)) * delta_calibration_radius, sin(RADIANS(330)) * delta_calibration_radius); }
  1751. void _goto_tower_z() { _man_probe_pt(cos(RADIANS( 90)) * delta_calibration_radius, sin(RADIANS( 90)) * delta_calibration_radius); }
  1752. void _goto_center() { _man_probe_pt(0,0); }
  1753. #endif // DELTA_CALIBRATION_MENU
  1754. #if ENABLED(DELTA_CALIBRATION_MENU) || ENABLED(DELTA_AUTO_CALIBRATION)
  1755. void _recalc_delta_settings() {
  1756. #if HAS_LEVELING
  1757. reset_bed_level(); // After changing kinematics bed-level data is no longer valid
  1758. #endif
  1759. recalc_delta_settings();
  1760. }
  1761. void lcd_delta_settings() {
  1762. START_MENU();
  1763. MENU_BACK(MSG_DELTA_CALIBRATE);
  1764. MENU_ITEM_EDIT_CALLBACK(float52sign, MSG_DELTA_HEIGHT, &delta_height, delta_height - 10, delta_height + 10, _recalc_delta_settings);
  1765. MENU_ITEM_EDIT_CALLBACK(float43, "Ex", &delta_endstop_adj[A_AXIS], -5, 5, _recalc_delta_settings);
  1766. MENU_ITEM_EDIT_CALLBACK(float43, "Ey", &delta_endstop_adj[B_AXIS], -5, 5, _recalc_delta_settings);
  1767. MENU_ITEM_EDIT_CALLBACK(float43, "Ez", &delta_endstop_adj[C_AXIS], -5, 5, _recalc_delta_settings);
  1768. MENU_ITEM_EDIT_CALLBACK(float52sign, MSG_DELTA_RADIUS, &delta_radius, delta_radius - 5, delta_radius + 5, _recalc_delta_settings);
  1769. MENU_ITEM_EDIT_CALLBACK(float43, "Tx", &delta_tower_angle_trim[A_AXIS], -5, 5, _recalc_delta_settings);
  1770. MENU_ITEM_EDIT_CALLBACK(float43, "Ty", &delta_tower_angle_trim[B_AXIS], -5, 5, _recalc_delta_settings);
  1771. MENU_ITEM_EDIT_CALLBACK(float43, "Tz", &delta_tower_angle_trim[C_AXIS], -5, 5, _recalc_delta_settings);
  1772. MENU_ITEM_EDIT_CALLBACK(float52sign, MSG_DELTA_DIAG_ROD, &delta_diagonal_rod, delta_diagonal_rod - 5, delta_diagonal_rod + 5, _recalc_delta_settings);
  1773. END_MENU();
  1774. }
  1775. void menu_delta_calibrate() {
  1776. START_MENU();
  1777. MENU_BACK(MSG_MAIN);
  1778. #if ENABLED(DELTA_AUTO_CALIBRATION)
  1779. MENU_ITEM(gcode, MSG_DELTA_AUTO_CALIBRATE, PSTR("G33"));
  1780. MENU_ITEM(gcode, MSG_DELTA_HEIGHT_CALIBRATE, PSTR("G33 S P1"));
  1781. MENU_ITEM(gcode, MSG_DELTA_Z_OFFSET_CALIBRATE, PSTR("G33 P-1"));
  1782. #if ENABLED(EEPROM_SETTINGS)
  1783. MENU_ITEM(function, MSG_STORE_EEPROM, lcd_store_settings);
  1784. MENU_ITEM(function, MSG_LOAD_EEPROM, lcd_load_settings);
  1785. #endif
  1786. #endif
  1787. MENU_ITEM(submenu, MSG_DELTA_SETTINGS, lcd_delta_settings);
  1788. #if ENABLED(DELTA_CALIBRATION_MENU)
  1789. MENU_ITEM(submenu, MSG_AUTO_HOME, _lcd_delta_calibrate_home);
  1790. if (all_axes_homed()) {
  1791. MENU_ITEM(submenu, MSG_DELTA_CALIBRATE_X, _goto_tower_x);
  1792. MENU_ITEM(submenu, MSG_DELTA_CALIBRATE_Y, _goto_tower_y);
  1793. MENU_ITEM(submenu, MSG_DELTA_CALIBRATE_Z, _goto_tower_z);
  1794. MENU_ITEM(submenu, MSG_DELTA_CALIBRATE_CENTER, _goto_center);
  1795. }
  1796. #endif
  1797. END_MENU();
  1798. }
  1799. #endif // DELTA_CALIBRATION_MENU || DELTA_AUTO_CALIBRATION
  1800. /**
  1801. * Set a flag that lcd_update() should start a move
  1802. * to "current_position" after a short delay.
  1803. */
  1804. inline void manual_move_to_current(AxisEnum axis
  1805. #if E_MANUAL > 1
  1806. , const int8_t eindex=-1
  1807. #endif
  1808. ) {
  1809. #if ENABLED(DUAL_X_CARRIAGE) || E_MANUAL > 1
  1810. #if E_MANUAL > 1
  1811. if (axis == E_AXIS)
  1812. #endif
  1813. manual_move_e_index = eindex >= 0 ? eindex : active_extruder;
  1814. #endif
  1815. manual_move_start_time = millis() + (move_menu_scale < 0.99f ? 0UL : 250UL); // delay for bigger moves
  1816. manual_move_axis = (int8_t)axis;
  1817. }
  1818. /**
  1819. *
  1820. * "Motion" > "Move Axis" submenu
  1821. *
  1822. */
  1823. void _lcd_move_xyz(PGM_P name, AxisEnum axis) {
  1824. if (use_click()) { return lcd_goto_previous_menu_no_defer(); }
  1825. ENCODER_DIRECTION_NORMAL();
  1826. if (encoderPosition && !processing_manual_move) {
  1827. // Start with no limits to movement
  1828. float min = current_position[axis] - 1000,
  1829. max = current_position[axis] + 1000;
  1830. // Limit to software endstops, if enabled
  1831. #if ENABLED(MIN_SOFTWARE_ENDSTOPS) || ENABLED(MAX_SOFTWARE_ENDSTOPS)
  1832. if (soft_endstops_enabled) switch (axis) {
  1833. case X_AXIS:
  1834. #if ENABLED(MIN_SOFTWARE_ENDSTOP_X)
  1835. min = soft_endstop_min[X_AXIS];
  1836. #endif
  1837. #if ENABLED(MAX_SOFTWARE_ENDSTOP_X)
  1838. max = soft_endstop_max[X_AXIS];
  1839. #endif
  1840. break;
  1841. case Y_AXIS:
  1842. #if ENABLED(MIN_SOFTWARE_ENDSTOP_Y)
  1843. min = soft_endstop_min[Y_AXIS];
  1844. #endif
  1845. #if ENABLED(MAX_SOFTWARE_ENDSTOP_Y)
  1846. max = soft_endstop_max[Y_AXIS];
  1847. #endif
  1848. break;
  1849. case Z_AXIS:
  1850. #if ENABLED(MIN_SOFTWARE_ENDSTOP_Z)
  1851. min = soft_endstop_min[Z_AXIS];
  1852. #endif
  1853. #if ENABLED(MAX_SOFTWARE_ENDSTOP_Z)
  1854. max = soft_endstop_max[Z_AXIS];
  1855. #endif
  1856. default: break;
  1857. }
  1858. #endif // MIN_SOFTWARE_ENDSTOPS || MAX_SOFTWARE_ENDSTOPS
  1859. // Delta limits XY based on the current offset from center
  1860. // This assumes the center is 0,0
  1861. #if ENABLED(DELTA)
  1862. if (axis != Z_AXIS) {
  1863. max = SQRT(sq((float)(DELTA_PRINTABLE_RADIUS)) - sq(current_position[Y_AXIS - axis])); // (Y_AXIS - axis) == the other axis
  1864. min = -max;
  1865. }
  1866. #endif
  1867. // Get the new position
  1868. const float diff = float((int32_t)encoderPosition) * move_menu_scale;
  1869. #if IS_KINEMATIC
  1870. manual_move_offset += diff;
  1871. if ((int32_t)encoderPosition < 0)
  1872. NOLESS(manual_move_offset, min - current_position[axis]);
  1873. else
  1874. NOMORE(manual_move_offset, max - current_position[axis]);
  1875. #else
  1876. current_position[axis] += diff;
  1877. if ((int32_t)encoderPosition < 0)
  1878. NOLESS(current_position[axis], min);
  1879. else
  1880. NOMORE(current_position[axis], max);
  1881. #endif
  1882. manual_move_to_current(axis);
  1883. lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
  1884. }
  1885. encoderPosition = 0;
  1886. if (lcdDrawUpdate) {
  1887. const float pos = NATIVE_TO_LOGICAL(processing_manual_move ? destination[axis] : current_position[axis]
  1888. #if IS_KINEMATIC
  1889. + manual_move_offset
  1890. #endif
  1891. , axis);
  1892. lcd_implementation_drawedit(name, move_menu_scale >= 0.1f ? ftostr41sign(pos) : ftostr43sign(pos));
  1893. }
  1894. }
  1895. void lcd_move_x() { _lcd_move_xyz(PSTR(MSG_MOVE_X), X_AXIS); }
  1896. void lcd_move_y() { _lcd_move_xyz(PSTR(MSG_MOVE_Y), Y_AXIS); }
  1897. void lcd_move_z() { _lcd_move_xyz(PSTR(MSG_MOVE_Z), Z_AXIS); }
  1898. void _lcd_move_e(
  1899. #if E_MANUAL > 1
  1900. const int8_t eindex=-1
  1901. #endif
  1902. ) {
  1903. if (use_click()) { return lcd_goto_previous_menu_no_defer(); }
  1904. ENCODER_DIRECTION_NORMAL();
  1905. if (encoderPosition) {
  1906. if (!processing_manual_move) {
  1907. const float diff = float((int32_t)encoderPosition) * move_menu_scale;
  1908. #if IS_KINEMATIC
  1909. manual_move_offset += diff;
  1910. #else
  1911. current_position[E_AXIS] += diff;
  1912. #endif
  1913. manual_move_to_current(E_AXIS
  1914. #if E_MANUAL > 1
  1915. , eindex
  1916. #endif
  1917. );
  1918. lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
  1919. }
  1920. encoderPosition = 0;
  1921. }
  1922. if (lcdDrawUpdate) {
  1923. PGM_P pos_label;
  1924. #if E_MANUAL == 1
  1925. pos_label = PSTR(MSG_MOVE_E);
  1926. #else
  1927. switch (eindex) {
  1928. default: pos_label = PSTR(MSG_MOVE_E MSG_MOVE_E1); break;
  1929. case 1: pos_label = PSTR(MSG_MOVE_E MSG_MOVE_E2); break;
  1930. #if E_MANUAL > 2
  1931. case 2: pos_label = PSTR(MSG_MOVE_E MSG_MOVE_E3); break;
  1932. #if E_MANUAL > 3
  1933. case 3: pos_label = PSTR(MSG_MOVE_E MSG_MOVE_E4); break;
  1934. #if E_MANUAL > 4
  1935. case 4: pos_label = PSTR(MSG_MOVE_E MSG_MOVE_E5); break;
  1936. #if E_MANUAL > 5
  1937. case 5: pos_label = PSTR(MSG_MOVE_E MSG_MOVE_E6); break;
  1938. #endif // E_MANUAL > 5
  1939. #endif // E_MANUAL > 4
  1940. #endif // E_MANUAL > 3
  1941. #endif // E_MANUAL > 2
  1942. }
  1943. #endif // E_MANUAL > 1
  1944. lcd_implementation_drawedit(pos_label, ftostr41sign(current_position[E_AXIS]
  1945. #if IS_KINEMATIC
  1946. + manual_move_offset
  1947. #endif
  1948. #if ENABLED(MANUAL_E_MOVES_RELATIVE)
  1949. - manual_move_e_origin
  1950. #endif
  1951. ));
  1952. }
  1953. }
  1954. void lcd_move_e() { _lcd_move_e(); }
  1955. #if E_MANUAL > 1
  1956. void lcd_move_e0() { _lcd_move_e(0); }
  1957. void lcd_move_e1() { _lcd_move_e(1); }
  1958. #if E_MANUAL > 2
  1959. void lcd_move_e2() { _lcd_move_e(2); }
  1960. #if E_MANUAL > 3
  1961. void lcd_move_e3() { _lcd_move_e(3); }
  1962. #if E_MANUAL > 4
  1963. void lcd_move_e4() { _lcd_move_e(4); }
  1964. #if E_MANUAL > 5
  1965. void lcd_move_e5() { _lcd_move_e(5); }
  1966. #endif // E_MANUAL > 5
  1967. #endif // E_MANUAL > 4
  1968. #endif // E_MANUAL > 3
  1969. #endif // E_MANUAL > 2
  1970. #endif // E_MANUAL > 1
  1971. /**
  1972. *
  1973. * "Motion" > "Move Xmm" > "Move XYZ" submenu
  1974. *
  1975. */
  1976. screenFunc_t _manual_move_func_ptr;
  1977. void _goto_manual_move(const float scale) {
  1978. defer_return_to_status = true;
  1979. move_menu_scale = scale;
  1980. lcd_goto_screen(_manual_move_func_ptr);
  1981. }
  1982. void menu_move_10mm() { _goto_manual_move(10); }
  1983. void menu_move_1mm() { _goto_manual_move( 1); }
  1984. void menu_move_01mm() { _goto_manual_move( 0.1f); }
  1985. void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int8_t eindex=-1) {
  1986. _manual_move_func_ptr = func;
  1987. START_MENU();
  1988. if (LCD_HEIGHT >= 4) {
  1989. switch (axis) {
  1990. case X_AXIS:
  1991. STATIC_ITEM(MSG_MOVE_X, true, true); break;
  1992. case Y_AXIS:
  1993. STATIC_ITEM(MSG_MOVE_Y, true, true); break;
  1994. case Z_AXIS:
  1995. STATIC_ITEM(MSG_MOVE_Z, true, true); break;
  1996. default:
  1997. #if ENABLED(MANUAL_E_MOVES_RELATIVE)
  1998. manual_move_e_origin = current_position[E_AXIS];
  1999. #endif
  2000. STATIC_ITEM(MSG_MOVE_E, true, true);
  2001. break;
  2002. }
  2003. }
  2004. #if ENABLED(PREVENT_COLD_EXTRUSION)
  2005. if (axis == E_AXIS && thermalManager.tooColdToExtrude(eindex >= 0 ? eindex : active_extruder))
  2006. MENU_BACK(MSG_HOTEND_TOO_COLD);
  2007. else
  2008. #endif
  2009. {
  2010. MENU_BACK(MSG_MOVE_AXIS);
  2011. MENU_ITEM(submenu, MSG_MOVE_10MM, menu_move_10mm);
  2012. MENU_ITEM(submenu, MSG_MOVE_1MM, menu_move_1mm);
  2013. MENU_ITEM(submenu, MSG_MOVE_01MM, menu_move_01mm);
  2014. }
  2015. END_MENU();
  2016. }
  2017. void lcd_move_get_x_amount() { _menu_move_distance(X_AXIS, lcd_move_x); }
  2018. void lcd_move_get_y_amount() { _menu_move_distance(Y_AXIS, lcd_move_y); }
  2019. void lcd_move_get_z_amount() { _menu_move_distance(Z_AXIS, lcd_move_z); }
  2020. void lcd_move_get_e_amount() { _menu_move_distance(E_AXIS, lcd_move_e, -1); }
  2021. #if E_MANUAL > 1
  2022. void lcd_move_get_e0_amount() { _menu_move_distance(E_AXIS, lcd_move_e0, 0); }
  2023. void lcd_move_get_e1_amount() { _menu_move_distance(E_AXIS, lcd_move_e1, 1); }
  2024. #if E_MANUAL > 2
  2025. void lcd_move_get_e2_amount() { _menu_move_distance(E_AXIS, lcd_move_e2, 2); }
  2026. #if E_MANUAL > 3
  2027. void lcd_move_get_e3_amount() { _menu_move_distance(E_AXIS, lcd_move_e3, 3); }
  2028. #if E_MANUAL > 4
  2029. void lcd_move_get_e4_amount() { _menu_move_distance(E_AXIS, lcd_move_e4, 4); }
  2030. #if E_MANUAL > 5
  2031. void lcd_move_get_e5_amount() { _menu_move_distance(E_AXIS, lcd_move_e5, 5); }
  2032. #endif // E_MANUAL > 5
  2033. #endif // E_MANUAL > 4
  2034. #endif // E_MANUAL > 3
  2035. #endif // E_MANUAL > 2
  2036. #endif // E_MANUAL > 1
  2037. /**
  2038. *
  2039. * "Motion" > "Move Axis" submenu
  2040. *
  2041. */
  2042. #if ENABLED(DELTA)
  2043. void lcd_lower_z_to_clip_height() {
  2044. line_to_z(delta_clip_start_height);
  2045. lcd_synchronize();
  2046. }
  2047. #endif
  2048. void menu_move() {
  2049. START_MENU();
  2050. MENU_BACK(MSG_MOTION);
  2051. #if HAS_SOFTWARE_ENDSTOPS && ENABLED(SOFT_ENDSTOPS_MENU_ITEM)
  2052. MENU_ITEM_EDIT(bool, MSG_LCD_SOFT_ENDSTOPS, &soft_endstops_enabled);
  2053. #endif
  2054. if (
  2055. #if IS_KINEMATIC || ENABLED(NO_MOTION_BEFORE_HOMING)
  2056. all_axes_homed()
  2057. #else
  2058. true
  2059. #endif
  2060. ) {
  2061. if (
  2062. #if ENABLED(DELTA)
  2063. current_position[Z_AXIS] <= delta_clip_start_height
  2064. #else
  2065. true
  2066. #endif
  2067. ) {
  2068. MENU_ITEM(submenu, MSG_MOVE_X, lcd_move_get_x_amount);
  2069. MENU_ITEM(submenu, MSG_MOVE_Y, lcd_move_get_y_amount);
  2070. }
  2071. #if ENABLED(DELTA)
  2072. else
  2073. MENU_ITEM(function, MSG_FREE_XY, lcd_lower_z_to_clip_height);
  2074. #endif
  2075. MENU_ITEM(submenu, MSG_MOVE_Z, lcd_move_get_z_amount);
  2076. }
  2077. else
  2078. MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28"));
  2079. #if ENABLED(SWITCHING_EXTRUDER) || ENABLED(SWITCHING_NOZZLE)
  2080. #if EXTRUDERS == 6
  2081. switch (active_extruder) {
  2082. case 0: MENU_ITEM(gcode, MSG_SELECT " " MSG_E2, PSTR("T1")); break;
  2083. case 1: MENU_ITEM(gcode, MSG_SELECT " " MSG_E1, PSTR("T0")); break;
  2084. case 2: MENU_ITEM(gcode, MSG_SELECT " " MSG_E4, PSTR("T3")); break;
  2085. case 3: MENU_ITEM(gcode, MSG_SELECT " " MSG_E3, PSTR("T2")); break;
  2086. case 4: MENU_ITEM(gcode, MSG_SELECT " " MSG_E6, PSTR("T5")); break;
  2087. case 5: MENU_ITEM(gcode, MSG_SELECT " " MSG_E5, PSTR("T4")); break;
  2088. }
  2089. #elif EXTRUDERS == 5 || EXTRUDERS == 4
  2090. switch (active_extruder) {
  2091. case 0: MENU_ITEM(gcode, MSG_SELECT " " MSG_E2, PSTR("T1")); break;
  2092. case 1: MENU_ITEM(gcode, MSG_SELECT " " MSG_E1, PSTR("T0")); break;
  2093. case 2: MENU_ITEM(gcode, MSG_SELECT " " MSG_E4, PSTR("T3")); break;
  2094. case 3: MENU_ITEM(gcode, MSG_SELECT " " MSG_E3, PSTR("T2")); break;
  2095. }
  2096. #elif EXTRUDERS == 3
  2097. if (active_extruder < 2) {
  2098. if (active_extruder)
  2099. MENU_ITEM(gcode, MSG_SELECT " " MSG_E1, PSTR("T0"));
  2100. else
  2101. MENU_ITEM(gcode, MSG_SELECT " " MSG_E2, PSTR("T1"));
  2102. }
  2103. #else
  2104. if (active_extruder)
  2105. MENU_ITEM(gcode, MSG_SELECT " " MSG_E1, PSTR("T0"));
  2106. else
  2107. MENU_ITEM(gcode, MSG_SELECT " " MSG_E2, PSTR("T1"));
  2108. #endif
  2109. #elif ENABLED(DUAL_X_CARRIAGE)
  2110. if (active_extruder)
  2111. MENU_ITEM(gcode, MSG_SELECT " " MSG_E1, PSTR("T0"));
  2112. else
  2113. MENU_ITEM(gcode, MSG_SELECT " " MSG_E2, PSTR("T1"));
  2114. #endif
  2115. #if ENABLED(SWITCHING_EXTRUDER) || ENABLED(SWITCHING_NOZZLE)
  2116. // Only the current...
  2117. MENU_ITEM(submenu, MSG_MOVE_E, lcd_move_get_e_amount);
  2118. // ...and the non-switching
  2119. #if E_MANUAL == 5
  2120. MENU_ITEM(submenu, MSG_MOVE_E MSG_MOVE_E5, lcd_move_get_e4_amount);
  2121. #elif E_MANUAL == 3
  2122. MENU_ITEM(submenu, MSG_MOVE_E MSG_MOVE_E3, lcd_move_get_e2_amount);
  2123. #endif
  2124. #else
  2125. // Independent extruders with one E-stepper per hotend
  2126. MENU_ITEM(submenu, MSG_MOVE_E, lcd_move_get_e_amount);
  2127. #if E_MANUAL > 1
  2128. MENU_ITEM(submenu, MSG_MOVE_E MSG_MOVE_E1, lcd_move_get_e0_amount);
  2129. MENU_ITEM(submenu, MSG_MOVE_E MSG_MOVE_E2, lcd_move_get_e1_amount);
  2130. #if E_MANUAL > 2
  2131. MENU_ITEM(submenu, MSG_MOVE_E MSG_MOVE_E3, lcd_move_get_e2_amount);
  2132. #if E_MANUAL > 3
  2133. MENU_ITEM(submenu, MSG_MOVE_E MSG_MOVE_E4, lcd_move_get_e3_amount);
  2134. #if E_MANUAL > 4
  2135. MENU_ITEM(submenu, MSG_MOVE_E MSG_MOVE_E5, lcd_move_get_e4_amount);
  2136. #if E_MANUAL > 5
  2137. MENU_ITEM(submenu, MSG_MOVE_E MSG_MOVE_E6, lcd_move_get_e5_amount);
  2138. #endif // E_MANUAL > 5
  2139. #endif // E_MANUAL > 4
  2140. #endif // E_MANUAL > 3
  2141. #endif // E_MANUAL > 2
  2142. #endif // E_MANUAL > 1
  2143. #endif
  2144. END_MENU();
  2145. }
  2146. /**
  2147. *
  2148. * "Temperature" submenu
  2149. *
  2150. */
  2151. #if ENABLED(PID_AUTOTUNE_MENU)
  2152. #if ENABLED(PIDTEMP)
  2153. int16_t autotune_temp[HOTENDS] = ARRAY_BY_HOTENDS1(150);
  2154. #endif
  2155. #if ENABLED(PIDTEMPBED)
  2156. int16_t autotune_temp_bed = 70;
  2157. #endif
  2158. void _lcd_autotune(int16_t e) {
  2159. char cmd[30];
  2160. sprintf_P(cmd, PSTR("M303 U1 E%i S%i"), e,
  2161. #if HAS_PID_FOR_BOTH
  2162. e < 0 ? autotune_temp_bed : autotune_temp[e]
  2163. #elif ENABLED(PIDTEMPBED)
  2164. autotune_temp_bed
  2165. #else
  2166. autotune_temp[e]
  2167. #endif
  2168. );
  2169. lcd_enqueue_command(cmd);
  2170. }
  2171. #endif // PID_AUTOTUNE_MENU
  2172. #if ENABLED(PIDTEMP)
  2173. // Helpers for editing PID Ki & Kd values
  2174. // grab the PID value out of the temp variable; scale it; then update the PID driver
  2175. void copy_and_scalePID_i(int16_t e) {
  2176. #if DISABLED(PID_PARAMS_PER_HOTEND) || HOTENDS == 1
  2177. UNUSED(e);
  2178. #endif
  2179. PID_PARAM(Ki, e) = scalePID_i(raw_Ki);
  2180. thermalManager.updatePID();
  2181. }
  2182. void copy_and_scalePID_d(int16_t e) {
  2183. #if DISABLED(PID_PARAMS_PER_HOTEND) || HOTENDS == 1
  2184. UNUSED(e);
  2185. #endif
  2186. PID_PARAM(Kd, e) = scalePID_d(raw_Kd);
  2187. thermalManager.updatePID();
  2188. }
  2189. #define _DEFINE_PIDTEMP_BASE_FUNCS(N) \
  2190. void copy_and_scalePID_i_E ## N() { copy_and_scalePID_i(N); } \
  2191. void copy_and_scalePID_d_E ## N() { copy_and_scalePID_d(N); }
  2192. #if ENABLED(PID_AUTOTUNE_MENU)
  2193. #define DEFINE_PIDTEMP_FUNCS(N) \
  2194. _DEFINE_PIDTEMP_BASE_FUNCS(N); \
  2195. void lcd_autotune_callback_E ## N() { _lcd_autotune(N); } typedef void _pid_##N##_void
  2196. #else
  2197. #define DEFINE_PIDTEMP_FUNCS(N) _DEFINE_PIDTEMP_BASE_FUNCS(N) typedef void _pid_##N##_void
  2198. #endif
  2199. DEFINE_PIDTEMP_FUNCS(0);
  2200. #if ENABLED(PID_PARAMS_PER_HOTEND)
  2201. #if HOTENDS > 1
  2202. DEFINE_PIDTEMP_FUNCS(1);
  2203. #if HOTENDS > 2
  2204. DEFINE_PIDTEMP_FUNCS(2);
  2205. #if HOTENDS > 3
  2206. DEFINE_PIDTEMP_FUNCS(3);
  2207. #if HOTENDS > 4
  2208. DEFINE_PIDTEMP_FUNCS(4);
  2209. #if HOTENDS > 5
  2210. DEFINE_PIDTEMP_FUNCS(5);
  2211. #endif // HOTENDS > 5
  2212. #endif // HOTENDS > 4
  2213. #endif // HOTENDS > 3
  2214. #endif // HOTENDS > 2
  2215. #endif // HOTENDS > 1
  2216. #endif // PID_PARAMS_PER_HOTEND
  2217. #endif // PIDTEMP
  2218. /**
  2219. *
  2220. * "Temperature" submenu
  2221. *
  2222. */
  2223. void menu_temperature() {
  2224. START_MENU();
  2225. MENU_BACK(MSG_MAIN);
  2226. //
  2227. // Nozzle:
  2228. // Nozzle [1-5]:
  2229. //
  2230. #if HOTENDS == 1
  2231. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_NOZZLE, &thermalManager.target_temperature[0], 0, HEATER_0_MAXTEMP - 15, watch_temp_callback_E0);
  2232. #else // HOTENDS > 1
  2233. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_NOZZLE MSG_N1, &thermalManager.target_temperature[0], 0, HEATER_0_MAXTEMP - 15, watch_temp_callback_E0);
  2234. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_NOZZLE MSG_N2, &thermalManager.target_temperature[1], 0, HEATER_1_MAXTEMP - 15, watch_temp_callback_E1);
  2235. #if HOTENDS > 2
  2236. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_NOZZLE MSG_N3, &thermalManager.target_temperature[2], 0, HEATER_2_MAXTEMP - 15, watch_temp_callback_E2);
  2237. #if HOTENDS > 3
  2238. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_NOZZLE MSG_N4, &thermalManager.target_temperature[3], 0, HEATER_3_MAXTEMP - 15, watch_temp_callback_E3);
  2239. #if HOTENDS > 4
  2240. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_NOZZLE MSG_N5, &thermalManager.target_temperature[4], 0, HEATER_4_MAXTEMP - 15, watch_temp_callback_E4);
  2241. #if HOTENDS > 5
  2242. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_NOZZLE MSG_N6, &thermalManager.target_temperature[5], 0, HEATER_5_MAXTEMP - 15, watch_temp_callback_E5);
  2243. #endif // HOTENDS > 5
  2244. #endif // HOTENDS > 4
  2245. #endif // HOTENDS > 3
  2246. #endif // HOTENDS > 2
  2247. #endif // HOTENDS > 1
  2248. //
  2249. // Bed:
  2250. //
  2251. #if HAS_HEATED_BED
  2252. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_BED, &thermalManager.target_temperature_bed, 0, BED_MAXTEMP - 15, watch_temp_callback_bed);
  2253. #endif
  2254. //
  2255. // Fan Speed:
  2256. //
  2257. #if FAN_COUNT > 0
  2258. #if HAS_FAN0
  2259. MENU_MULTIPLIER_ITEM_EDIT(int8, MSG_FAN_SPEED FAN_SPEED_1_SUFFIX, &fan_speed[0], 0, 255);
  2260. #if ENABLED(EXTRA_FAN_SPEED)
  2261. MENU_MULTIPLIER_ITEM_EDIT(int8, MSG_EXTRA_FAN_SPEED FAN_SPEED_1_SUFFIX, &new_fan_speed[0], 3, 255);
  2262. #endif
  2263. #endif
  2264. #if HAS_FAN1
  2265. MENU_MULTIPLIER_ITEM_EDIT(int8, MSG_FAN_SPEED " 2", &fan_speed[1], 0, 255);
  2266. #if ENABLED(EXTRA_FAN_SPEED)
  2267. MENU_MULTIPLIER_ITEM_EDIT(int8, MSG_EXTRA_FAN_SPEED " 2", &new_fan_speed[1], 3, 255);
  2268. #endif
  2269. #endif
  2270. #if HAS_FAN2
  2271. MENU_MULTIPLIER_ITEM_EDIT(int8, MSG_FAN_SPEED " 3", &fan_speed[2], 0, 255);
  2272. #if ENABLED(EXTRA_FAN_SPEED)
  2273. MENU_MULTIPLIER_ITEM_EDIT(int8, MSG_EXTRA_FAN_SPEED " 3", &new_fan_speed[2], 3, 255);
  2274. #endif
  2275. #endif
  2276. #endif // FAN_COUNT > 0
  2277. #if HAS_TEMP_HOTEND
  2278. //
  2279. // Cooldown
  2280. //
  2281. bool has_heat = false;
  2282. HOTEND_LOOP() if (thermalManager.target_temperature[HOTEND_INDEX]) { has_heat = true; break; }
  2283. #if HAS_TEMP_BED
  2284. if (thermalManager.target_temperature_bed) has_heat = true;
  2285. #endif
  2286. if (has_heat) MENU_ITEM(function, MSG_COOLDOWN, lcd_cooldown);
  2287. //
  2288. // Preheat for Material 1 and 2
  2289. //
  2290. #if TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_3 != 0 || TEMP_SENSOR_4 != 0 || HAS_HEATED_BED
  2291. MENU_ITEM(submenu, MSG_PREHEAT_1, menu_preheat_m1);
  2292. MENU_ITEM(submenu, MSG_PREHEAT_2, menu_preheat_m2);
  2293. #else
  2294. MENU_ITEM(function, MSG_PREHEAT_1, lcd_preheat_m1_e0_only);
  2295. MENU_ITEM(function, MSG_PREHEAT_2, lcd_preheat_m2_e0_only);
  2296. #endif
  2297. #endif // HAS_TEMP_HOTEND
  2298. END_MENU();
  2299. }
  2300. /**
  2301. *
  2302. * "Advanced Settings" -> "Temperature" submenu
  2303. *
  2304. */
  2305. void menu_advanced_temperature() {
  2306. START_MENU();
  2307. MENU_BACK(MSG_ADVANCED_SETTINGS);
  2308. //
  2309. // Autotemp, Min, Max, Fact
  2310. //
  2311. #if ENABLED(AUTOTEMP) && HAS_TEMP_HOTEND
  2312. MENU_ITEM_EDIT(bool, MSG_AUTOTEMP, &planner.autotemp_enabled);
  2313. MENU_ITEM_EDIT(float3, MSG_MIN, &planner.autotemp_min, 0, float(HEATER_0_MAXTEMP) - 15);
  2314. MENU_ITEM_EDIT(float3, MSG_MAX, &planner.autotemp_max, 0, float(HEATER_0_MAXTEMP) - 15);
  2315. MENU_ITEM_EDIT(float52, MSG_FACTOR, &planner.autotemp_factor, 0, 1);
  2316. #endif
  2317. //
  2318. // PID-P, PID-I, PID-D, PID-C, PID Autotune
  2319. // PID-P E1, PID-I E1, PID-D E1, PID-C E1, PID Autotune E1
  2320. // PID-P E2, PID-I E2, PID-D E2, PID-C E2, PID Autotune E2
  2321. // PID-P E3, PID-I E3, PID-D E3, PID-C E3, PID Autotune E3
  2322. // PID-P E4, PID-I E4, PID-D E4, PID-C E4, PID Autotune E4
  2323. // PID-P E5, PID-I E5, PID-D E5, PID-C E5, PID Autotune E5
  2324. //
  2325. #if ENABLED(PIDTEMP)
  2326. #define _PID_BASE_MENU_ITEMS(ELABEL, eindex) \
  2327. raw_Ki = unscalePID_i(PID_PARAM(Ki, eindex)); \
  2328. raw_Kd = unscalePID_d(PID_PARAM(Kd, eindex)); \
  2329. MENU_ITEM_EDIT(float52sign, MSG_PID_P ELABEL, &PID_PARAM(Kp, eindex), 1, 9990); \
  2330. MENU_ITEM_EDIT_CALLBACK(float52sign, MSG_PID_I ELABEL, &raw_Ki, 0.01f, 9990, copy_and_scalePID_i_E ## eindex); \
  2331. MENU_ITEM_EDIT_CALLBACK(float52sign, MSG_PID_D ELABEL, &raw_Kd, 1, 9990, copy_and_scalePID_d_E ## eindex)
  2332. #if ENABLED(PID_EXTRUSION_SCALING)
  2333. #define _PID_MENU_ITEMS(ELABEL, eindex) \
  2334. _PID_BASE_MENU_ITEMS(ELABEL, eindex); \
  2335. MENU_ITEM_EDIT(float3, MSG_PID_C ELABEL, &PID_PARAM(Kc, eindex), 1, 9990)
  2336. #else
  2337. #define _PID_MENU_ITEMS(ELABEL, eindex) _PID_BASE_MENU_ITEMS(ELABEL, eindex)
  2338. #endif
  2339. #if ENABLED(PID_AUTOTUNE_MENU)
  2340. #define PID_MENU_ITEMS(ELABEL, eindex) \
  2341. _PID_MENU_ITEMS(ELABEL, eindex); \
  2342. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_PID_AUTOTUNE ELABEL, &autotune_temp[eindex], 150, heater_maxtemp[eindex] - 15, lcd_autotune_callback_E ## eindex)
  2343. #else
  2344. #define PID_MENU_ITEMS(ELABEL, eindex) _PID_MENU_ITEMS(ELABEL, eindex)
  2345. #endif
  2346. #if ENABLED(PID_PARAMS_PER_HOTEND) && HOTENDS > 1
  2347. PID_MENU_ITEMS(" " MSG_E1, 0);
  2348. PID_MENU_ITEMS(" " MSG_E2, 1);
  2349. #if HOTENDS > 2
  2350. PID_MENU_ITEMS(" " MSG_E3, 2);
  2351. #if HOTENDS > 3
  2352. PID_MENU_ITEMS(" " MSG_E4, 3);
  2353. #if HOTENDS > 4
  2354. PID_MENU_ITEMS(" " MSG_E5, 4);
  2355. #if HOTENDS > 5
  2356. PID_MENU_ITEMS(" " MSG_E6, 5);
  2357. #endif // HOTENDS > 5
  2358. #endif // HOTENDS > 4
  2359. #endif // HOTENDS > 3
  2360. #endif // HOTENDS > 2
  2361. #else // !PID_PARAMS_PER_HOTEND || HOTENDS == 1
  2362. PID_MENU_ITEMS("", 0);
  2363. #endif // !PID_PARAMS_PER_HOTEND || HOTENDS == 1
  2364. #endif // PIDTEMP
  2365. END_MENU();
  2366. }
  2367. #if DISABLED(SLIM_LCD_MENUS)
  2368. void _reset_acceleration_rates() { planner.reset_acceleration_rates(); }
  2369. #if ENABLED(DISTINCT_E_FACTORS)
  2370. void _reset_e_acceleration_rate(const uint8_t e) { if (e == active_extruder) _reset_acceleration_rates(); }
  2371. void _reset_e0_acceleration_rate() { _reset_e_acceleration_rate(0); }
  2372. void _reset_e1_acceleration_rate() { _reset_e_acceleration_rate(1); }
  2373. #if E_STEPPERS > 2
  2374. void _reset_e2_acceleration_rate() { _reset_e_acceleration_rate(2); }
  2375. #if E_STEPPERS > 3
  2376. void _reset_e3_acceleration_rate() { _reset_e_acceleration_rate(3); }
  2377. #if E_STEPPERS > 4
  2378. void _reset_e4_acceleration_rate() { _reset_e_acceleration_rate(4); }
  2379. #if E_STEPPERS > 5
  2380. void _reset_e5_acceleration_rate() { _reset_e_acceleration_rate(5); }
  2381. #endif // E_STEPPERS > 5
  2382. #endif // E_STEPPERS > 4
  2383. #endif // E_STEPPERS > 3
  2384. #endif // E_STEPPERS > 2
  2385. #endif
  2386. void _planner_refresh_positioning() { planner.refresh_positioning(); }
  2387. #if ENABLED(DISTINCT_E_FACTORS)
  2388. void _planner_refresh_e_positioning(const uint8_t e) {
  2389. if (e == active_extruder)
  2390. _planner_refresh_positioning();
  2391. else
  2392. planner.steps_to_mm[E_AXIS + e] = 1.0f / planner.settings.axis_steps_per_mm[E_AXIS + e];
  2393. }
  2394. void _planner_refresh_e0_positioning() { _planner_refresh_e_positioning(0); }
  2395. void _planner_refresh_e1_positioning() { _planner_refresh_e_positioning(1); }
  2396. #if E_STEPPERS > 2
  2397. void _planner_refresh_e2_positioning() { _planner_refresh_e_positioning(2); }
  2398. #if E_STEPPERS > 3
  2399. void _planner_refresh_e3_positioning() { _planner_refresh_e_positioning(3); }
  2400. #if E_STEPPERS > 4
  2401. void _planner_refresh_e4_positioning() { _planner_refresh_e_positioning(4); }
  2402. #if E_STEPPERS > 5
  2403. void _planner_refresh_e5_positioning() { _planner_refresh_e_positioning(5); }
  2404. #endif // E_STEPPERS > 5
  2405. #endif // E_STEPPERS > 4
  2406. #endif // E_STEPPERS > 3
  2407. #endif // E_STEPPERS > 2
  2408. #endif
  2409. // M203 / M205 Velocity options
  2410. void menu_advanced_velocity() {
  2411. START_MENU();
  2412. MENU_BACK(MSG_ADVANCED_SETTINGS);
  2413. // M203 Max Feedrate
  2414. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_A, &planner.settings.max_feedrate_mm_s[A_AXIS], 1, 999);
  2415. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_B, &planner.settings.max_feedrate_mm_s[B_AXIS], 1, 999);
  2416. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_C, &planner.settings.max_feedrate_mm_s[C_AXIS], 1, 999);
  2417. #if ENABLED(DISTINCT_E_FACTORS)
  2418. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_E, &planner.settings.max_feedrate_mm_s[E_AXIS + active_extruder], 1, 999);
  2419. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_E1, &planner.settings.max_feedrate_mm_s[E_AXIS], 1, 999);
  2420. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_E2, &planner.settings.max_feedrate_mm_s[E_AXIS + 1], 1, 999);
  2421. #if E_STEPPERS > 2
  2422. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_E3, &planner.settings.max_feedrate_mm_s[E_AXIS + 2], 1, 999);
  2423. #if E_STEPPERS > 3
  2424. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_E4, &planner.settings.max_feedrate_mm_s[E_AXIS + 3], 1, 999);
  2425. #if E_STEPPERS > 4
  2426. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_E5, &planner.settings.max_feedrate_mm_s[E_AXIS + 4], 1, 999);
  2427. #if E_STEPPERS > 5
  2428. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_E6, &planner.settings.max_feedrate_mm_s[E_AXIS + 5], 1, 999);
  2429. #endif // E_STEPPERS > 5
  2430. #endif // E_STEPPERS > 4
  2431. #endif // E_STEPPERS > 3
  2432. #endif // E_STEPPERS > 2
  2433. #else
  2434. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_E, &planner.settings.max_feedrate_mm_s[E_AXIS], 1, 999);
  2435. #endif
  2436. // M205 S Min Feedrate
  2437. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMIN, &planner.settings.min_feedrate_mm_s, 0, 999);
  2438. // M205 T Min Travel Feedrate
  2439. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VTRAV_MIN, &planner.settings.min_travel_feedrate_mm_s, 0, 999);
  2440. END_MENU();
  2441. }
  2442. // M201 / M204 Accelerations
  2443. void menu_advanced_acceleration() {
  2444. START_MENU();
  2445. MENU_BACK(MSG_ADVANCED_SETTINGS);
  2446. // M204 P Acceleration
  2447. MENU_MULTIPLIER_ITEM_EDIT(float5, MSG_ACC, &planner.settings.acceleration, 10, 99000);
  2448. // M204 R Retract Acceleration
  2449. MENU_MULTIPLIER_ITEM_EDIT(float5, MSG_A_RETRACT, &planner.settings.retract_acceleration, 100, 99000);
  2450. // M204 T Travel Acceleration
  2451. MENU_MULTIPLIER_ITEM_EDIT(float5, MSG_A_TRAVEL, &planner.settings.travel_acceleration, 100, 99000);
  2452. // M201 settings
  2453. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_A, &planner.settings.max_acceleration_mm_per_s2[A_AXIS], 100, 99000, _reset_acceleration_rates);
  2454. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_B, &planner.settings.max_acceleration_mm_per_s2[B_AXIS], 100, 99000, _reset_acceleration_rates);
  2455. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_C, &planner.settings.max_acceleration_mm_per_s2[C_AXIS], 10, 99000, _reset_acceleration_rates);
  2456. #if ENABLED(DISTINCT_E_FACTORS)
  2457. 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);
  2458. 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);
  2459. 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);
  2460. #if E_STEPPERS > 2
  2461. 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);
  2462. #if E_STEPPERS > 3
  2463. 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);
  2464. #if E_STEPPERS > 4
  2465. 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);
  2466. #if E_STEPPERS > 5
  2467. 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);
  2468. #endif // E_STEPPERS > 5
  2469. #endif // E_STEPPERS > 4
  2470. #endif // E_STEPPERS > 3
  2471. #endif // E_STEPPERS > 2
  2472. #else
  2473. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_E, &planner.settings.max_acceleration_mm_per_s2[E_AXIS], 100, 99000, _reset_acceleration_rates);
  2474. #endif
  2475. END_MENU();
  2476. }
  2477. // M205 Jerk
  2478. void menu_advanced_jerk() {
  2479. START_MENU();
  2480. MENU_BACK(MSG_ADVANCED_SETTINGS);
  2481. #if ENABLED(JUNCTION_DEVIATION)
  2482. #if ENABLED(LIN_ADVANCE)
  2483. MENU_ITEM_EDIT_CALLBACK(float43, MSG_JUNCTION_DEVIATION, &planner.junction_deviation_mm, 0.01f, 0.3f, planner.recalculate_max_e_jerk);
  2484. #else
  2485. MENU_ITEM_EDIT(float43, MSG_JUNCTION_DEVIATION, &planner.junction_deviation_mm, 0.01f, 0.3f);
  2486. #endif
  2487. #endif
  2488. #if HAS_CLASSIC_JERK
  2489. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VA_JERK, &planner.max_jerk[A_AXIS], 1, 990);
  2490. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VB_JERK, &planner.max_jerk[B_AXIS], 1, 990);
  2491. #if ENABLED(DELTA)
  2492. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VC_JERK, &planner.max_jerk[C_AXIS], 1, 990);
  2493. #else
  2494. MENU_MULTIPLIER_ITEM_EDIT(float52sign, MSG_VC_JERK, &planner.max_jerk[C_AXIS], 0.1f, 990);
  2495. #endif
  2496. #if DISABLED(JUNCTION_DEVIATION) || DISABLED(LIN_ADVANCE)
  2497. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VE_JERK, &planner.max_jerk[E_AXIS], 1, 990);
  2498. #endif
  2499. #endif
  2500. END_MENU();
  2501. }
  2502. // M92 Steps-per-mm
  2503. void menu_advanced_steps_per_mm() {
  2504. START_MENU();
  2505. MENU_BACK(MSG_ADVANCED_SETTINGS);
  2506. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_ASTEPS, &planner.settings.axis_steps_per_mm[A_AXIS], 5, 9999, _planner_refresh_positioning);
  2507. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_BSTEPS, &planner.settings.axis_steps_per_mm[B_AXIS], 5, 9999, _planner_refresh_positioning);
  2508. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_CSTEPS, &planner.settings.axis_steps_per_mm[C_AXIS], 5, 9999, _planner_refresh_positioning);
  2509. #if ENABLED(DISTINCT_E_FACTORS)
  2510. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_ESTEPS, &planner.settings.axis_steps_per_mm[E_AXIS + active_extruder], 5, 9999, _planner_refresh_positioning);
  2511. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_E1STEPS, &planner.settings.axis_steps_per_mm[E_AXIS], 5, 9999, _planner_refresh_e0_positioning);
  2512. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_E2STEPS, &planner.settings.axis_steps_per_mm[E_AXIS + 1], 5, 9999, _planner_refresh_e1_positioning);
  2513. #if E_STEPPERS > 2
  2514. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_E3STEPS, &planner.settings.axis_steps_per_mm[E_AXIS + 2], 5, 9999, _planner_refresh_e2_positioning);
  2515. #if E_STEPPERS > 3
  2516. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_E4STEPS, &planner.settings.axis_steps_per_mm[E_AXIS + 3], 5, 9999, _planner_refresh_e3_positioning);
  2517. #if E_STEPPERS > 4
  2518. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_E5STEPS, &planner.settings.axis_steps_per_mm[E_AXIS + 4], 5, 9999, _planner_refresh_e4_positioning);
  2519. #if E_STEPPERS > 5
  2520. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_E6STEPS, &planner.settings.axis_steps_per_mm[E_AXIS + 5], 5, 9999, _planner_refresh_e5_positioning);
  2521. #endif // E_STEPPERS > 5
  2522. #endif // E_STEPPERS > 4
  2523. #endif // E_STEPPERS > 3
  2524. #endif // E_STEPPERS > 2
  2525. #else
  2526. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_ESTEPS, &planner.settings.axis_steps_per_mm[E_AXIS], 5, 9999, _planner_refresh_positioning);
  2527. #endif
  2528. END_MENU();
  2529. }
  2530. #endif // !SLIM_LCD_MENUS
  2531. /**
  2532. *
  2533. * "Advanced Settings" submenu
  2534. *
  2535. */
  2536. #if HAS_M206_COMMAND
  2537. /**
  2538. * Set the home offset based on the current_position
  2539. */
  2540. void lcd_set_home_offsets() {
  2541. // M428 Command
  2542. enqueue_and_echo_commands_P(PSTR("M428"));
  2543. lcd_return_to_status();
  2544. }
  2545. #endif
  2546. #if ENABLED(SD_FIRMWARE_UPDATE)
  2547. /**
  2548. * Toggle the SD Firmware Update state in EEPROM
  2549. */
  2550. static void _lcd_toggle_sd_update() {
  2551. const bool new_state = !settings.sd_update_status();
  2552. lcd_completion_feedback(settings.set_sd_update_status(new_state));
  2553. lcd_return_to_status();
  2554. if (new_state) LCD_MESSAGEPGM(MSG_RESET_PRINTER); else lcd_reset_status();
  2555. }
  2556. #endif
  2557. void menu_advanced_settings() {
  2558. START_MENU();
  2559. MENU_BACK(MSG_CONFIGURATION);
  2560. #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
  2561. MENU_ITEM(submenu, MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset);
  2562. #elif HAS_BED_PROBE
  2563. MENU_ITEM_EDIT(float52, MSG_ZPROBE_ZOFFSET, &zprobe_zoffset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
  2564. #endif
  2565. #if DISABLED(SLIM_LCD_MENUS)
  2566. #if HAS_M206_COMMAND
  2567. //
  2568. // Set Home Offsets
  2569. //
  2570. MENU_ITEM(function, MSG_SET_HOME_OFFSETS, lcd_set_home_offsets);
  2571. #endif
  2572. // M203 / M205 - Feedrate items
  2573. MENU_ITEM(submenu, MSG_VELOCITY, menu_advanced_velocity);
  2574. // M201 - Acceleration items
  2575. MENU_ITEM(submenu, MSG_ACCELERATION, menu_advanced_acceleration);
  2576. // M205 - Max Jerk
  2577. MENU_ITEM(submenu, MSG_JERK, menu_advanced_jerk);
  2578. if (!printer_busy()) {
  2579. // M92 - Steps Per mm
  2580. MENU_ITEM(submenu, MSG_STEPS_PER_MM, menu_advanced_steps_per_mm);
  2581. }
  2582. #endif // !SLIM_LCD_MENUS
  2583. MENU_ITEM(submenu, MSG_TEMPERATURE, menu_advanced_temperature);
  2584. #if DISABLED(NO_VOLUMETRICS) || ENABLED(ADVANCED_PAUSE_FEATURE)
  2585. MENU_ITEM(submenu, MSG_FILAMENT, menu_advanced_filament);
  2586. #elif ENABLED(LIN_ADVANCE)
  2587. #if EXTRUDERS == 1
  2588. MENU_ITEM_EDIT(float52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 999);
  2589. #elif EXTRUDERS > 1
  2590. MENU_ITEM_EDIT(float52, MSG_ADVANCE_K MSG_E1, &planner.extruder_advance_K[0], 0, 999);
  2591. MENU_ITEM_EDIT(float52, MSG_ADVANCE_K MSG_E2, &planner.extruder_advance_K[1], 0, 999);
  2592. #if EXTRUDERS > 2
  2593. MENU_ITEM_EDIT(float52, MSG_ADVANCE_K MSG_E3, &planner.extruder_advance_K[2], 0, 999);
  2594. #if EXTRUDERS > 3
  2595. MENU_ITEM_EDIT(float52, MSG_ADVANCE_K MSG_E4, &planner.extruder_advance_K[3], 0, 999);
  2596. #if EXTRUDERS > 4
  2597. MENU_ITEM_EDIT(float52, MSG_ADVANCE_K MSG_E5, &planner.extruder_advance_K[4], 0, 999);
  2598. #if EXTRUDERS > 5
  2599. MENU_ITEM_EDIT(float52, MSG_ADVANCE_K MSG_E6, &planner.extruder_advance_K[5], 0, 999);
  2600. #endif // EXTRUDERS > 5
  2601. #endif // EXTRUDERS > 4
  2602. #endif // EXTRUDERS > 3
  2603. #endif // EXTRUDERS > 2
  2604. #endif // EXTRUDERS > 1
  2605. #endif
  2606. // M540 S - Abort on endstop hit when SD printing
  2607. #if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
  2608. MENU_ITEM_EDIT(bool, MSG_ENDSTOP_ABORT, &planner.abort_on_endstop_hit);
  2609. #endif
  2610. //
  2611. // BLTouch Self-Test and Reset
  2612. //
  2613. #if ENABLED(BLTOUCH)
  2614. MENU_ITEM(gcode, MSG_BLTOUCH_SELFTEST, PSTR("M280 P" STRINGIFY(Z_PROBE_SERVO_NR) " S" STRINGIFY(BLTOUCH_SELFTEST)));
  2615. if (!endstops.z_probe_enabled && TEST_BLTOUCH())
  2616. MENU_ITEM(gcode, MSG_BLTOUCH_RESET, PSTR("M280 P" STRINGIFY(Z_PROBE_SERVO_NR) " S" STRINGIFY(BLTOUCH_RESET)));
  2617. #endif
  2618. #if ENABLED(SD_FIRMWARE_UPDATE)
  2619. bool sd_update_state = settings.sd_update_status();
  2620. MENU_ITEM_EDIT_CALLBACK(bool, MSG_SD_UPDATE, &sd_update_state, _lcd_toggle_sd_update);
  2621. #endif
  2622. #if ENABLED(EEPROM_SETTINGS) && DISABLED(SLIM_LCD_MENUS)
  2623. MENU_ITEM(submenu, MSG_INIT_EEPROM, lcd_init_eeprom_confirm);
  2624. #endif
  2625. END_MENU();
  2626. }
  2627. #if DISABLED(NO_VOLUMETRICS) || ENABLED(ADVANCED_PAUSE_FEATURE)
  2628. /**
  2629. *
  2630. * "Advanced Settings" > "Filament" submenu
  2631. *
  2632. */
  2633. void menu_advanced_filament() {
  2634. START_MENU();
  2635. MENU_BACK(MSG_ADVANCED_SETTINGS);
  2636. #if ENABLED(LIN_ADVANCE)
  2637. #if EXTRUDERS == 1
  2638. MENU_ITEM_EDIT(float52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 999);
  2639. #elif EXTRUDERS > 1
  2640. MENU_ITEM_EDIT(float52, MSG_ADVANCE_K MSG_E1, &planner.extruder_advance_K[0], 0, 999);
  2641. MENU_ITEM_EDIT(float52, MSG_ADVANCE_K MSG_E2, &planner.extruder_advance_K[1], 0, 999);
  2642. #if EXTRUDERS > 2
  2643. MENU_ITEM_EDIT(float52, MSG_ADVANCE_K MSG_E3, &planner.extruder_advance_K[2], 0, 999);
  2644. #if EXTRUDERS > 3
  2645. MENU_ITEM_EDIT(float52, MSG_ADVANCE_K MSG_E4, &planner.extruder_advance_K[3], 0, 999);
  2646. #if EXTRUDERS > 4
  2647. MENU_ITEM_EDIT(float52, MSG_ADVANCE_K MSG_E5, &planner.extruder_advance_K[4], 0, 999);
  2648. #if EXTRUDERS > 5
  2649. MENU_ITEM_EDIT(float52, MSG_ADVANCE_K MSG_E6, &planner.extruder_advance_K[5], 0, 999);
  2650. #endif // EXTRUDERS > 5
  2651. #endif // EXTRUDERS > 4
  2652. #endif // EXTRUDERS > 3
  2653. #endif // EXTRUDERS > 2
  2654. #endif // EXTRUDERS > 1
  2655. #endif
  2656. #if DISABLED(NO_VOLUMETRICS)
  2657. MENU_ITEM_EDIT_CALLBACK(bool, MSG_VOLUMETRIC_ENABLED, &parser.volumetric_enabled, planner.calculate_volumetric_multipliers);
  2658. if (parser.volumetric_enabled) {
  2659. #if EXTRUDERS == 1
  2660. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM, &planner.filament_size[0], 1.5f, 3.25f, planner.calculate_volumetric_multipliers);
  2661. #else // EXTRUDERS > 1
  2662. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM, &planner.filament_size[active_extruder], 1.5f, 3.25f, planner.calculate_volumetric_multipliers);
  2663. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E1, &planner.filament_size[0], 1.5f, 3.25f, planner.calculate_volumetric_multipliers);
  2664. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E2, &planner.filament_size[1], 1.5f, 3.25f, planner.calculate_volumetric_multipliers);
  2665. #if EXTRUDERS > 2
  2666. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E3, &planner.filament_size[2], 1.5f, 3.25f, planner.calculate_volumetric_multipliers);
  2667. #if EXTRUDERS > 3
  2668. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E4, &planner.filament_size[3], 1.5f, 3.25f, planner.calculate_volumetric_multipliers);
  2669. #if EXTRUDERS > 4
  2670. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E5, &planner.filament_size[4], 1.5f, 3.25f, planner.calculate_volumetric_multipliers);
  2671. #if EXTRUDERS > 5
  2672. MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E6, &planner.filament_size[5], 1.5f, 3.25f, planner.calculate_volumetric_multipliers);
  2673. #endif // EXTRUDERS > 5
  2674. #endif // EXTRUDERS > 4
  2675. #endif // EXTRUDERS > 3
  2676. #endif // EXTRUDERS > 2
  2677. #endif // EXTRUDERS > 1
  2678. }
  2679. #endif
  2680. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  2681. constexpr float extrude_maxlength =
  2682. #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
  2683. EXTRUDE_MAXLENGTH
  2684. #else
  2685. 999
  2686. #endif
  2687. ;
  2688. #if EXTRUDERS == 1
  2689. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD, &fc_settings[0].unload_length, 0, extrude_maxlength);
  2690. #else // EXTRUDERS > 1
  2691. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD, &fc_settings[active_extruder].unload_length, 0, extrude_maxlength);
  2692. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD MSG_DIAM_E1, &fc_settings[0].unload_length, 0, extrude_maxlength);
  2693. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD MSG_DIAM_E2, &fc_settings[1].unload_length, 0, extrude_maxlength);
  2694. #if EXTRUDERS > 2
  2695. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD MSG_DIAM_E3, &fc_settings[2].unload_length, 0, extrude_maxlength);
  2696. #if EXTRUDERS > 3
  2697. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD MSG_DIAM_E4, &fc_settings[3].unload_length, 0, extrude_maxlength);
  2698. #if EXTRUDERS > 4
  2699. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD MSG_DIAM_E5, &fc_settings[4].unload_length, 0, extrude_maxlength);
  2700. #if EXTRUDERS > 5
  2701. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD MSG_DIAM_E6, &fc_settings[5].unload_length, 0, extrude_maxlength);
  2702. #endif // EXTRUDERS > 5
  2703. #endif // EXTRUDERS > 4
  2704. #endif // EXTRUDERS > 3
  2705. #endif // EXTRUDERS > 2
  2706. #endif // EXTRUDERS > 1
  2707. #if EXTRUDERS == 1
  2708. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD, &fc_settings[0].load_length, 0, extrude_maxlength);
  2709. #else // EXTRUDERS > 1
  2710. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD, &fc_settings[active_extruder].load_length, 0, extrude_maxlength);
  2711. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD MSG_DIAM_E1, &fc_settings[0].load_length, 0, extrude_maxlength);
  2712. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD MSG_DIAM_E2, &fc_settings[1].load_length, 0, extrude_maxlength);
  2713. #if EXTRUDERS > 2
  2714. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD MSG_DIAM_E3, &fc_settings[2].load_length, 0, extrude_maxlength);
  2715. #if EXTRUDERS > 3
  2716. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD MSG_DIAM_E4, &fc_settings[3].load_length, 0, extrude_maxlength);
  2717. #if EXTRUDERS > 4
  2718. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD MSG_DIAM_E5, &fc_settings[4].load_length, 0, extrude_maxlength);
  2719. #if EXTRUDERS > 5
  2720. MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD MSG_DIAM_E6, &fc_settings[5].load_length, 0, extrude_maxlength);
  2721. #endif // EXTRUDERS > 5
  2722. #endif // EXTRUDERS > 4
  2723. #endif // EXTRUDERS > 3
  2724. #endif // EXTRUDERS > 2
  2725. #endif // EXTRUDERS > 1
  2726. #endif
  2727. END_MENU();
  2728. }
  2729. #endif // !NO_VOLUMETRICS || ADVANCED_PAUSE_FEATURE
  2730. #if ENABLED(SDSUPPORT)
  2731. #if !PIN_EXISTS(SD_DETECT)
  2732. void lcd_sd_refresh() {
  2733. card.initsd();
  2734. encoderTopLine = 0;
  2735. }
  2736. #endif
  2737. void lcd_sd_updir() {
  2738. encoderPosition = card.updir() ? ENCODER_STEPS_PER_MENU_ITEM : 0;
  2739. encoderTopLine = 0;
  2740. screen_changed = true;
  2741. lcd_refresh();
  2742. }
  2743. /**
  2744. *
  2745. * "Print from SD" submenu
  2746. *
  2747. */
  2748. #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
  2749. uint32_t last_sdfile_encoderPosition = 0xFFFF;
  2750. void lcd_reselect_last_file() {
  2751. if (last_sdfile_encoderPosition == 0xFFFF) return;
  2752. #if HAS_GRAPHICAL_LCD
  2753. // Some of this is a hack to force the screen update to work.
  2754. // TODO: Fix the real issue that causes this!
  2755. lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
  2756. lcd_synchronize();
  2757. safe_delay(50);
  2758. lcd_synchronize();
  2759. lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
  2760. drawing_screen = screen_changed = true;
  2761. #endif
  2762. lcd_goto_screen(menu_sdcard, last_sdfile_encoderPosition);
  2763. defer_return_to_status = true;
  2764. last_sdfile_encoderPosition = 0xFFFF;
  2765. #if HAS_GRAPHICAL_LCD
  2766. lcd_update();
  2767. #endif
  2768. }
  2769. #endif
  2770. void menu_sdcard() {
  2771. ENCODER_DIRECTION_MENUS();
  2772. const uint16_t fileCnt = card.get_num_Files();
  2773. START_MENU();
  2774. MENU_BACK(MSG_MAIN);
  2775. card.getWorkDirName();
  2776. if (card.filename[0] == '/') {
  2777. #if !PIN_EXISTS(SD_DETECT)
  2778. MENU_ITEM(function, LCD_STR_REFRESH MSG_REFRESH, lcd_sd_refresh);
  2779. #endif
  2780. }
  2781. else {
  2782. MENU_ITEM(function, LCD_STR_FOLDER "..", lcd_sd_updir);
  2783. }
  2784. for (uint16_t i = 0; i < fileCnt; i++) {
  2785. if (_menuLineNr == _thisItemNr) {
  2786. const uint16_t nr =
  2787. #if ENABLED(SDCARD_RATHERRECENTFIRST) && DISABLED(SDCARD_SORT_ALPHA)
  2788. fileCnt - 1 -
  2789. #endif
  2790. i;
  2791. #if ENABLED(SDCARD_SORT_ALPHA)
  2792. card.getfilename_sorted(nr);
  2793. #else
  2794. card.getfilename(nr);
  2795. #endif
  2796. if (card.filenameIsDir)
  2797. MENU_ITEM(sddirectory, MSG_CARD_MENU, card);
  2798. else
  2799. MENU_ITEM(sdfile, MSG_CARD_MENU, card);
  2800. }
  2801. else {
  2802. MENU_ITEM_DUMMY();
  2803. }
  2804. }
  2805. END_MENU();
  2806. }
  2807. #endif // SDSUPPORT
  2808. #if ENABLED(LCD_INFO_MENU)
  2809. #if ENABLED(PRINTCOUNTER)
  2810. /**
  2811. *
  2812. * About Printer > Statistics submenu
  2813. *
  2814. */
  2815. void menu_info_stats() {
  2816. if (use_click()) { return lcd_goto_previous_menu(); }
  2817. char buffer[21];
  2818. printStatistics stats = print_job_timer.getStats();
  2819. START_SCREEN(); // 12345678901234567890
  2820. STATIC_ITEM(MSG_INFO_PRINT_COUNT ": ", false, false, itostr3left(stats.totalPrints)); // Print Count: 999
  2821. STATIC_ITEM(MSG_INFO_COMPLETED_PRINTS": ", false, false, itostr3left(stats.finishedPrints)); // Completed : 666
  2822. duration_t elapsed = stats.printTime;
  2823. elapsed.toString(buffer);
  2824. STATIC_ITEM(MSG_INFO_PRINT_TIME ": ", false, false); // Total print Time:
  2825. STATIC_ITEM("", false, false, buffer); // 99y 364d 23h 59m 59s
  2826. elapsed = stats.longestPrint;
  2827. elapsed.toString(buffer);
  2828. STATIC_ITEM(MSG_INFO_PRINT_LONGEST ": ", false, false); // Longest job time:
  2829. STATIC_ITEM("", false, false, buffer); // 99y 364d 23h 59m 59s
  2830. sprintf_P(buffer, PSTR("%ld.%im"), long(stats.filamentUsed / 1000), int16_t(stats.filamentUsed / 100) % 10);
  2831. STATIC_ITEM(MSG_INFO_PRINT_FILAMENT ": ", false, false); // Extruded total:
  2832. STATIC_ITEM("", false, false, buffer); // 125m
  2833. END_SCREEN();
  2834. }
  2835. #endif // PRINTCOUNTER
  2836. /**
  2837. *
  2838. * About Printer > Thermistors
  2839. *
  2840. */
  2841. void menu_info_thermistors() {
  2842. if (use_click()) { return lcd_goto_previous_menu(); }
  2843. START_SCREEN();
  2844. #define THERMISTOR_ID TEMP_SENSOR_0
  2845. #include "../thermistornames.h"
  2846. STATIC_ITEM("T0: " THERMISTOR_NAME, false, true);
  2847. STATIC_ITEM(MSG_INFO_MIN_TEMP ": " STRINGIFY(HEATER_0_MINTEMP), false);
  2848. STATIC_ITEM(MSG_INFO_MAX_TEMP ": " STRINGIFY(HEATER_0_MAXTEMP), false);
  2849. #if TEMP_SENSOR_1 != 0
  2850. #undef THERMISTOR_ID
  2851. #define THERMISTOR_ID TEMP_SENSOR_1
  2852. #include "../thermistornames.h"
  2853. STATIC_ITEM("T1: " THERMISTOR_NAME, false, true);
  2854. STATIC_ITEM(MSG_INFO_MIN_TEMP ": " STRINGIFY(HEATER_1_MINTEMP), false);
  2855. STATIC_ITEM(MSG_INFO_MAX_TEMP ": " STRINGIFY(HEATER_1_MAXTEMP), false);
  2856. #endif
  2857. #if TEMP_SENSOR_2 != 0
  2858. #undef THERMISTOR_ID
  2859. #define THERMISTOR_ID TEMP_SENSOR_2
  2860. #include "../thermistornames.h"
  2861. STATIC_ITEM("T2: " THERMISTOR_NAME, false, true);
  2862. STATIC_ITEM(MSG_INFO_MIN_TEMP ": " STRINGIFY(HEATER_2_MINTEMP), false);
  2863. STATIC_ITEM(MSG_INFO_MAX_TEMP ": " STRINGIFY(HEATER_2_MAXTEMP), false);
  2864. #endif
  2865. #if TEMP_SENSOR_3 != 0
  2866. #undef THERMISTOR_ID
  2867. #define THERMISTOR_ID TEMP_SENSOR_3
  2868. #include "../thermistornames.h"
  2869. STATIC_ITEM("T3: " THERMISTOR_NAME, false, true);
  2870. STATIC_ITEM(MSG_INFO_MIN_TEMP ": " STRINGIFY(HEATER_3_MINTEMP), false);
  2871. STATIC_ITEM(MSG_INFO_MAX_TEMP ": " STRINGIFY(HEATER_3_MAXTEMP), false);
  2872. #endif
  2873. #if TEMP_SENSOR_4 != 0
  2874. #undef THERMISTOR_ID
  2875. #define THERMISTOR_ID TEMP_SENSOR_4
  2876. #include "../thermistornames.h"
  2877. STATIC_ITEM("T4: " THERMISTOR_NAME, false, true);
  2878. STATIC_ITEM(MSG_INFO_MIN_TEMP ": " STRINGIFY(HEATER_4_MINTEMP), false);
  2879. STATIC_ITEM(MSG_INFO_MAX_TEMP ": " STRINGIFY(HEATER_4_MAXTEMP), false);
  2880. #endif
  2881. #if HAS_HEATED_BED
  2882. #undef THERMISTOR_ID
  2883. #define THERMISTOR_ID TEMP_SENSOR_BED
  2884. #include "../thermistornames.h"
  2885. STATIC_ITEM("TBed:" THERMISTOR_NAME, false, true);
  2886. STATIC_ITEM(MSG_INFO_MIN_TEMP ": " STRINGIFY(BED_MINTEMP), false);
  2887. STATIC_ITEM(MSG_INFO_MAX_TEMP ": " STRINGIFY(BED_MAXTEMP), false);
  2888. #endif
  2889. END_SCREEN();
  2890. }
  2891. /**
  2892. *
  2893. * About Printer > Board Info
  2894. *
  2895. */
  2896. void menu_info_board() {
  2897. if (use_click()) { return lcd_goto_previous_menu(); }
  2898. START_SCREEN();
  2899. STATIC_ITEM(BOARD_NAME, true, true); // MyPrinterController
  2900. STATIC_ITEM(MSG_INFO_BAUDRATE ": " STRINGIFY(BAUDRATE), true); // Baud: 250000
  2901. STATIC_ITEM(MSG_INFO_PROTOCOL ": " PROTOCOL_VERSION, true); // Protocol: 1.0
  2902. #if POWER_SUPPLY == 0
  2903. STATIC_ITEM(MSG_INFO_PSU ": Generic", true);
  2904. #elif POWER_SUPPLY == 1
  2905. STATIC_ITEM(MSG_INFO_PSU ": ATX", true); // Power Supply: ATX
  2906. #elif POWER_SUPPLY == 2
  2907. STATIC_ITEM(MSG_INFO_PSU ": XBox", true); // Power Supply: XBox
  2908. #endif
  2909. END_SCREEN();
  2910. }
  2911. /**
  2912. *
  2913. * About Printer > Printer Info
  2914. *
  2915. */
  2916. void menu_info_printer() {
  2917. if (use_click()) { return lcd_goto_previous_menu(); }
  2918. START_SCREEN();
  2919. STATIC_ITEM(MSG_MARLIN, true, true); // Marlin
  2920. STATIC_ITEM(SHORT_BUILD_VERSION, true); // x.x.x-Branch
  2921. STATIC_ITEM(STRING_DISTRIBUTION_DATE, true); // YYYY-MM-DD HH:MM
  2922. STATIC_ITEM(MACHINE_NAME, true); // My3DPrinter
  2923. STATIC_ITEM(WEBSITE_URL, true); // www.my3dprinter.com
  2924. STATIC_ITEM(MSG_INFO_EXTRUDERS ": " STRINGIFY(EXTRUDERS), true); // Extruders: 2
  2925. #if ENABLED(AUTO_BED_LEVELING_3POINT)
  2926. STATIC_ITEM(MSG_3POINT_LEVELING, true); // 3-Point Leveling
  2927. #elif ENABLED(AUTO_BED_LEVELING_LINEAR)
  2928. STATIC_ITEM(MSG_LINEAR_LEVELING, true); // Linear Leveling
  2929. #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
  2930. STATIC_ITEM(MSG_BILINEAR_LEVELING, true); // Bi-linear Leveling
  2931. #elif ENABLED(AUTO_BED_LEVELING_UBL)
  2932. STATIC_ITEM(MSG_UBL_LEVELING, true); // Unified Bed Leveling
  2933. #elif ENABLED(MESH_BED_LEVELING)
  2934. STATIC_ITEM(MSG_MESH_LEVELING, true); // Mesh Leveling
  2935. #endif
  2936. END_SCREEN();
  2937. }
  2938. /**
  2939. *
  2940. * "About Printer" submenu
  2941. *
  2942. */
  2943. void menu_info() {
  2944. START_MENU();
  2945. MENU_BACK(MSG_MAIN);
  2946. MENU_ITEM(submenu, MSG_INFO_PRINTER_MENU, menu_info_printer); // Printer Info >
  2947. MENU_ITEM(submenu, MSG_INFO_BOARD_MENU, menu_info_board); // Board Info >
  2948. MENU_ITEM(submenu, MSG_INFO_THERMISTOR_MENU, menu_info_thermistors); // Thermistors >
  2949. #if ENABLED(PRINTCOUNTER)
  2950. MENU_ITEM(submenu, MSG_INFO_STATS_MENU, menu_info_stats); // Printer Statistics >
  2951. #endif
  2952. END_MENU();
  2953. }
  2954. #endif // LCD_INFO_MENU
  2955. /**
  2956. *
  2957. * LED Menu
  2958. *
  2959. */
  2960. #if ENABLED(LED_CONTROL_MENU)
  2961. #if ENABLED(LED_COLOR_PRESETS)
  2962. void menu_led_presets() {
  2963. START_MENU();
  2964. #if LCD_HEIGHT > 2
  2965. STATIC_ITEM(MSG_LED_PRESETS, true, true);
  2966. #endif
  2967. MENU_BACK(MSG_LED_CONTROL);
  2968. MENU_ITEM(function, MSG_SET_LEDS_WHITE, leds.set_white);
  2969. MENU_ITEM(function, MSG_SET_LEDS_RED, leds.set_red);
  2970. MENU_ITEM(function, MSG_SET_LEDS_ORANGE, leds.set_orange);
  2971. MENU_ITEM(function, MSG_SET_LEDS_YELLOW,leds.set_yellow);
  2972. MENU_ITEM(function, MSG_SET_LEDS_GREEN, leds.set_green);
  2973. MENU_ITEM(function, MSG_SET_LEDS_BLUE, leds.set_blue);
  2974. MENU_ITEM(function, MSG_SET_LEDS_INDIGO, leds.set_indigo);
  2975. MENU_ITEM(function, MSG_SET_LEDS_VIOLET, leds.set_violet);
  2976. END_MENU();
  2977. }
  2978. #endif // LED_COLOR_PRESETS
  2979. void menu_led_custom() {
  2980. START_MENU();
  2981. MENU_BACK(MSG_LED_CONTROL);
  2982. MENU_ITEM_EDIT_CALLBACK(int8, MSG_INTENSITY_R, &leds.color.r, 0, 255, leds.update, true);
  2983. MENU_ITEM_EDIT_CALLBACK(int8, MSG_INTENSITY_G, &leds.color.g, 0, 255, leds.update, true);
  2984. MENU_ITEM_EDIT_CALLBACK(int8, MSG_INTENSITY_B, &leds.color.b, 0, 255, leds.update, true);
  2985. #if ENABLED(RGBW_LED) || ENABLED(NEOPIXEL_LED)
  2986. MENU_ITEM_EDIT_CALLBACK(int8, MSG_INTENSITY_W, &leds.color.w, 0, 255, leds.update, true);
  2987. #if ENABLED(NEOPIXEL_LED)
  2988. MENU_ITEM_EDIT_CALLBACK(int8, MSG_LED_BRIGHTNESS, &leds.color.i, 0, 255, leds.update, true);
  2989. #endif
  2990. #endif
  2991. END_MENU();
  2992. }
  2993. void menu_led() {
  2994. START_MENU();
  2995. MENU_BACK(MSG_MAIN);
  2996. bool led_on = leds.lights_on;
  2997. MENU_ITEM_EDIT_CALLBACK(bool, MSG_LEDS, &led_on, leds.toggle);
  2998. MENU_ITEM(function, MSG_SET_LEDS_DEFAULT, leds.set_default);
  2999. #if ENABLED(LED_COLOR_PRESETS)
  3000. MENU_ITEM(submenu, MSG_LED_PRESETS, menu_led_presets);
  3001. #endif
  3002. MENU_ITEM(submenu, MSG_CUSTOM_LEDS, menu_led_custom);
  3003. END_MENU();
  3004. }
  3005. #endif // LED_CONTROL_MENU
  3006. /**
  3007. *
  3008. * Filament Change Feature Screens
  3009. *
  3010. */
  3011. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  3012. /**
  3013. *
  3014. * "Change Filament" > "Change/Unload/Load Filament" submenu
  3015. *
  3016. */
  3017. static AdvancedPauseMode _change_filament_temp_mode; // =ADVANCED_PAUSE_MODE_PAUSE_PRINT
  3018. static int8_t _change_filament_temp_extruder; // =0
  3019. static PGM_P _change_filament_temp_command() {
  3020. switch (_change_filament_temp_mode) {
  3021. case ADVANCED_PAUSE_MODE_LOAD_FILAMENT:
  3022. return PSTR("M701 T%d");
  3023. case ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT:
  3024. return _change_filament_temp_extruder >= 0 ? PSTR("M702 T%d") : PSTR("M702 ;%d");
  3025. case ADVANCED_PAUSE_MODE_PAUSE_PRINT:
  3026. default:
  3027. return PSTR("M600 B0 T%d");
  3028. }
  3029. return PSTR(MSG_FILAMENTCHANGE);
  3030. }
  3031. void _change_filament_temp(const uint16_t temperature) {
  3032. char cmd[11];
  3033. sprintf_P(cmd, _change_filament_temp_command(), _change_filament_temp_extruder);
  3034. thermalManager.setTargetHotend(temperature, _change_filament_temp_extruder);
  3035. lcd_enqueue_command(cmd);
  3036. }
  3037. void _menu_change_filament_temp_1() { _change_filament_temp(PREHEAT_1_TEMP_HOTEND); }
  3038. void _menu_change_filament_temp_2() { _change_filament_temp(PREHEAT_2_TEMP_HOTEND); }
  3039. void _menu_change_filament_temp_custom() { _change_filament_temp(thermalManager.target_temperature[_change_filament_temp_extruder]); }
  3040. static PGM_P change_filament_header(const AdvancedPauseMode mode) {
  3041. switch (mode) {
  3042. case ADVANCED_PAUSE_MODE_LOAD_FILAMENT:
  3043. return PSTR(MSG_FILAMENTLOAD);
  3044. case ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT:
  3045. return PSTR(MSG_FILAMENTUNLOAD);
  3046. default: break;
  3047. }
  3048. return PSTR(MSG_FILAMENTCHANGE);
  3049. }
  3050. void _menu_temp_filament_op(const AdvancedPauseMode mode, const int8_t extruder) {
  3051. _change_filament_temp_mode = mode;
  3052. _change_filament_temp_extruder = extruder;
  3053. START_MENU();
  3054. if (LCD_HEIGHT >= 4) STATIC_ITEM_P(change_filament_header(mode), true, true);
  3055. MENU_BACK(MSG_BACK);
  3056. MENU_ITEM(submenu, MSG_PREHEAT_1, _menu_change_filament_temp_1);
  3057. MENU_ITEM(submenu, MSG_PREHEAT_2, _menu_change_filament_temp_2);
  3058. uint16_t max_temp;
  3059. switch (extruder) {
  3060. default: max_temp = HEATER_0_MAXTEMP;
  3061. #if HOTENDS > 1
  3062. case 1: max_temp = HEATER_1_MAXTEMP; break;
  3063. #if HOTENDS > 2
  3064. case 2: max_temp = HEATER_2_MAXTEMP; break;
  3065. #if HOTENDS > 3
  3066. case 3: max_temp = HEATER_3_MAXTEMP; break;
  3067. #if HOTENDS > 4
  3068. case 4: max_temp = HEATER_4_MAXTEMP; break;
  3069. #if HOTENDS > 5
  3070. case 5: max_temp = HEATER_5_MAXTEMP; break;
  3071. #endif
  3072. #endif
  3073. #endif
  3074. #endif
  3075. #endif
  3076. }
  3077. 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);
  3078. END_MENU();
  3079. }
  3080. void menu_temp_e0_filament_change() { _menu_temp_filament_op(ADVANCED_PAUSE_MODE_PAUSE_PRINT, 0); }
  3081. void menu_temp_e0_filament_load() { _menu_temp_filament_op(ADVANCED_PAUSE_MODE_LOAD_FILAMENT, 0); }
  3082. void menu_temp_e0_filament_unload() { _menu_temp_filament_op(ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT, 0); }
  3083. #if E_STEPPERS > 1
  3084. void menu_temp_e1_filament_change() { _menu_temp_filament_op(ADVANCED_PAUSE_MODE_PAUSE_PRINT, 1); }
  3085. void menu_temp_e1_filament_load() { _menu_temp_filament_op(ADVANCED_PAUSE_MODE_LOAD_FILAMENT, 1); }
  3086. void menu_temp_e1_filament_unload() { _menu_temp_filament_op(ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT, 1); }
  3087. #if ENABLED(FILAMENT_UNLOAD_ALL_EXTRUDERS)
  3088. void menu_unload_filament_all_temp() { _menu_temp_filament_op(ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT, -1); }
  3089. #endif
  3090. #if E_STEPPERS > 2
  3091. void menu_temp_e2_filament_change() { _menu_temp_filament_op(ADVANCED_PAUSE_MODE_PAUSE_PRINT, 2); }
  3092. void menu_temp_e2_filament_load() { _menu_temp_filament_op(ADVANCED_PAUSE_MODE_LOAD_FILAMENT, 2); }
  3093. void menu_temp_e2_filament_unload() { _menu_temp_filament_op(ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT, 2); }
  3094. #if E_STEPPERS > 3
  3095. void menu_temp_e3_filament_change() { _menu_temp_filament_op(ADVANCED_PAUSE_MODE_PAUSE_PRINT, 3); }
  3096. void menu_temp_e3_filament_load() { _menu_temp_filament_op(ADVANCED_PAUSE_MODE_LOAD_FILAMENT, 3); }
  3097. void menu_temp_e3_filament_unload() { _menu_temp_filament_op(ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT, 3); }
  3098. #if E_STEPPERS > 4
  3099. void menu_temp_e4_filament_change() { _menu_temp_filament_op(ADVANCED_PAUSE_MODE_PAUSE_PRINT, 4); }
  3100. void menu_temp_e4_filament_load() { _menu_temp_filament_op(ADVANCED_PAUSE_MODE_LOAD_FILAMENT, 4); }
  3101. void menu_temp_e4_filament_unload() { _menu_temp_filament_op(ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT, 4); }
  3102. #endif // E_STEPPERS > 4
  3103. #endif // E_STEPPERS > 3
  3104. #endif // E_STEPPERS > 2
  3105. #endif // E_STEPPERS > 1
  3106. /**
  3107. *
  3108. * "Change Filament" submenu
  3109. *
  3110. */
  3111. #if E_STEPPERS > 1 || ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
  3112. void menu_change_filament() {
  3113. START_MENU();
  3114. MENU_BACK(MSG_MAIN);
  3115. // Change filament
  3116. #if E_STEPPERS == 1
  3117. PGM_P msg0 = PSTR(MSG_FILAMENTCHANGE);
  3118. if (thermalManager.targetTooColdToExtrude(active_extruder))
  3119. MENU_ITEM_P(submenu, msg0, menu_temp_e0_filament_change);
  3120. else
  3121. MENU_ITEM_P(gcode, msg0, PSTR("M600 B0"));
  3122. #else
  3123. PGM_P msg0 = PSTR(MSG_FILAMENTCHANGE " " MSG_E1);
  3124. PGM_P msg1 = PSTR(MSG_FILAMENTCHANGE " " MSG_E2);
  3125. if (thermalManager.targetTooColdToExtrude(0))
  3126. MENU_ITEM_P(submenu, msg0, menu_temp_e0_filament_change);
  3127. else
  3128. MENU_ITEM_P(gcode, msg0, PSTR("M600 B0 T0"));
  3129. if (thermalManager.targetTooColdToExtrude(1))
  3130. MENU_ITEM_P(submenu, msg1, menu_temp_e1_filament_change);
  3131. else
  3132. MENU_ITEM_P(gcode, msg1, PSTR("M600 B0 T1"));
  3133. #if E_STEPPERS > 2
  3134. PGM_P msg2 = PSTR(MSG_FILAMENTCHANGE " " MSG_E3);
  3135. if (thermalManager.targetTooColdToExtrude(2))
  3136. MENU_ITEM_P(submenu, msg2, menu_temp_e2_filament_change);
  3137. else
  3138. MENU_ITEM_P(gcode, msg2, PSTR("M600 B0 T2"));
  3139. #if E_STEPPERS > 3
  3140. PGM_P msg3 = PSTR(MSG_FILAMENTCHANGE " " MSG_E4);
  3141. if (thermalManager.targetTooColdToExtrude(3))
  3142. MENU_ITEM_P(submenu, msg3, menu_temp_e3_filament_change);
  3143. else
  3144. MENU_ITEM_P(gcode, msg3, PSTR("M600 B0 T3"));
  3145. #if E_STEPPERS > 4
  3146. PGM_P msg4 = PSTR(MSG_FILAMENTCHANGE " " MSG_E5);
  3147. if (thermalManager.targetTooColdToExtrude(4))
  3148. MENU_ITEM_P(submenu, msg4, menu_temp_e4_filament_change);
  3149. else
  3150. MENU_ITEM_P(gcode, msg4, PSTR("M600 B0 T4"));
  3151. #if E_STEPPERS > 5
  3152. PGM_P msg5 = PSTR(MSG_FILAMENTCHANGE " " MSG_E6);
  3153. if (thermalManager.targetTooColdToExtrude(5))
  3154. MENU_ITEM_P(submenu, msg5, menu_temp_e5_filament_change);
  3155. else
  3156. MENU_ITEM_P(gcode, msg5, PSTR("M600 B0 T5"));
  3157. #endif // E_STEPPERS > 5
  3158. #endif // E_STEPPERS > 4
  3159. #endif // E_STEPPERS > 3
  3160. #endif // E_STEPPERS > 2
  3161. #endif // E_STEPPERS == 1
  3162. #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
  3163. if (!printer_busy()) {
  3164. // Load filament
  3165. #if E_STEPPERS == 1
  3166. PGM_P msg0 = PSTR(MSG_FILAMENTLOAD);
  3167. if (thermalManager.targetTooColdToExtrude(active_extruder))
  3168. MENU_ITEM_P(submenu, msg0, menu_temp_e0_filament_load);
  3169. else
  3170. MENU_ITEM_P(gcode, msg0, PSTR("M701"));
  3171. #else
  3172. PGM_P msg0 = PSTR(MSG_FILAMENTLOAD " " MSG_E1);
  3173. PGM_P msg1 = PSTR(MSG_FILAMENTLOAD " " MSG_E2);
  3174. if (thermalManager.targetTooColdToExtrude(0))
  3175. MENU_ITEM_P(submenu, msg0, menu_temp_e0_filament_load);
  3176. else
  3177. MENU_ITEM_P(gcode, msg0, PSTR("M701 T0"));
  3178. if (thermalManager.targetTooColdToExtrude(1))
  3179. MENU_ITEM_P(submenu, msg1, menu_temp_e1_filament_load);
  3180. else
  3181. MENU_ITEM_P(gcode, msg1, PSTR("M701 T1"));
  3182. #if E_STEPPERS > 2
  3183. PGM_P msg2 = PSTR(MSG_FILAMENTLOAD " " MSG_E3);
  3184. if (thermalManager.targetTooColdToExtrude(2))
  3185. MENU_ITEM_P(submenu, msg2, menu_temp_e2_filament_load);
  3186. else
  3187. MENU_ITEM_P(gcode, msg2, PSTR("M701 T2"));
  3188. #if E_STEPPERS > 3
  3189. PGM_P msg3 = PSTR(MSG_FILAMENTLOAD " " MSG_E4);
  3190. if (thermalManager.targetTooColdToExtrude(3))
  3191. MENU_ITEM_P(submenu, msg3, menu_temp_e3_filament_load);
  3192. else
  3193. MENU_ITEM_P(gcode, msg3, PSTR("M701 T3"));
  3194. #if E_STEPPERS > 4
  3195. PGM_P msg4 = PSTR(MSG_FILAMENTLOAD " " MSG_E5);
  3196. if (thermalManager.targetTooColdToExtrude(4))
  3197. MENU_ITEM_P(submenu, msg4, menu_temp_e4_filament_load);
  3198. else
  3199. MENU_ITEM_P(gcode, msg4, PSTR("M701 T4"));
  3200. #if E_STEPPERS > 5
  3201. PGM_P msg5 = PSTR(MSG_FILAMENTLOAD " " MSG_E6);
  3202. if (thermalManager.targetTooColdToExtrude(5))
  3203. MENU_ITEM_P(submenu, msg5, menu_temp_e5_filament_load);
  3204. else
  3205. MENU_ITEM_P(gcode, msg5, PSTR("M701 T5"));
  3206. #endif // E_STEPPERS > 5
  3207. #endif // E_STEPPERS > 4
  3208. #endif // E_STEPPERS > 3
  3209. #endif // E_STEPPERS > 2
  3210. #endif // E_STEPPERS == 1
  3211. // Unload filament
  3212. #if E_STEPPERS == 1
  3213. if (thermalManager.targetHotEnoughToExtrude(active_extruder))
  3214. MENU_ITEM(gcode, MSG_FILAMENTUNLOAD, PSTR("M702"));
  3215. else
  3216. MENU_ITEM(submenu, MSG_FILAMENTUNLOAD, menu_temp_e0_filament_unload);
  3217. #else
  3218. #if ENABLED(FILAMENT_UNLOAD_ALL_EXTRUDERS)
  3219. if (thermalManager.targetHotEnoughToExtrude(0)
  3220. #if E_STEPPERS > 1
  3221. && thermalManager.targetHotEnoughToExtrude(1)
  3222. #if E_STEPPERS > 2
  3223. && thermalManager.targetHotEnoughToExtrude(2)
  3224. #if E_STEPPERS > 3
  3225. && thermalManager.targetHotEnoughToExtrude(3)
  3226. #if E_STEPPERS > 4
  3227. && thermalManager.targetHotEnoughToExtrude(4)
  3228. #if E_STEPPERS > 5
  3229. && thermalManager.targetHotEnoughToExtrude(5)
  3230. #endif // E_STEPPERS > 5
  3231. #endif // E_STEPPERS > 4
  3232. #endif // E_STEPPERS > 3
  3233. #endif // E_STEPPERS > 2
  3234. #endif // E_STEPPERS > 1
  3235. )
  3236. MENU_ITEM(gcode, MSG_FILAMENTUNLOAD_ALL, PSTR("M702"));
  3237. else
  3238. MENU_ITEM(submenu, MSG_FILAMENTUNLOAD_ALL, menu_unload_filament_all_temp);
  3239. #endif
  3240. if (thermalManager.targetHotEnoughToExtrude(0))
  3241. MENU_ITEM(gcode, MSG_FILAMENTUNLOAD " " MSG_E1, PSTR("M702 T0"));
  3242. else
  3243. MENU_ITEM(submenu, MSG_FILAMENTUNLOAD " " MSG_E1, menu_temp_e0_filament_unload);
  3244. if (thermalManager.targetHotEnoughToExtrude(1))
  3245. MENU_ITEM(gcode, MSG_FILAMENTUNLOAD " " MSG_E2, PSTR("M702 T1"));
  3246. else
  3247. MENU_ITEM(submenu, MSG_FILAMENTUNLOAD " " MSG_E2, menu_temp_e1_filament_unload);
  3248. #if E_STEPPERS > 2
  3249. if (thermalManager.targetHotEnoughToExtrude(2))
  3250. MENU_ITEM(gcode, MSG_FILAMENTUNLOAD " " MSG_E3, PSTR("M702 T2"));
  3251. else
  3252. MENU_ITEM(submenu, MSG_FILAMENTUNLOAD " " MSG_E3, menu_temp_e2_filament_unload);
  3253. #if E_STEPPERS > 3
  3254. if (thermalManager.targetHotEnoughToExtrude(3))
  3255. MENU_ITEM(gcode, MSG_FILAMENTUNLOAD " " MSG_E4, PSTR("M702 T3"));
  3256. else
  3257. MENU_ITEM(submenu, MSG_FILAMENTUNLOAD " " MSG_E4, menu_temp_e3_filament_unload);
  3258. #if E_STEPPERS > 4
  3259. if (thermalManager.targetHotEnoughToExtrude(4))
  3260. MENU_ITEM(gcode, MSG_FILAMENTUNLOAD " " MSG_E5, PSTR("M702 T4"));
  3261. else
  3262. MENU_ITEM(submenu, MSG_FILAMENTUNLOAD " " MSG_E5, menu_temp_e4_filament_unload);
  3263. #if E_STEPPERS > 5
  3264. if (thermalManager.targetHotEnoughToExtrude(5))
  3265. MENU_ITEM(gcode, MSG_FILAMENTUNLOAD " " MSG_E6, PSTR("M702 T5"));
  3266. else
  3267. MENU_ITEM(submenu, MSG_FILAMENTUNLOAD " " MSG_E6, menu_temp_e5_filament_unload);
  3268. #endif // E_STEPPERS > 5
  3269. #endif // E_STEPPERS > 4
  3270. #endif // E_STEPPERS > 3
  3271. #endif // E_STEPPERS > 2
  3272. #endif // E_STEPPERS == 1
  3273. }
  3274. #endif
  3275. END_MENU();
  3276. }
  3277. #endif
  3278. static AdvancedPauseMode advanced_pause_mode = ADVANCED_PAUSE_MODE_PAUSE_PRINT;
  3279. static uint8_t hotend_status_extruder = 0;
  3280. static PGM_P advanced_pause_header() {
  3281. switch (advanced_pause_mode) {
  3282. case ADVANCED_PAUSE_MODE_LOAD_FILAMENT:
  3283. return PSTR(MSG_FILAMENT_CHANGE_HEADER_LOAD);
  3284. case ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT:
  3285. return PSTR(MSG_FILAMENT_CHANGE_HEADER_UNLOAD);
  3286. default: break;
  3287. }
  3288. return PSTR(MSG_FILAMENT_CHANGE_HEADER_PAUSE);
  3289. }
  3290. // Portions from STATIC_ITEM...
  3291. #define HOTEND_STATUS_ITEM() do { \
  3292. if (_menuLineNr == _thisItemNr) { \
  3293. if (lcdDrawUpdate) { \
  3294. lcd_implementation_drawmenu_static(_lcdLineNr, PSTR(MSG_FILAMENT_CHANGE_NOZZLE), false, true); \
  3295. lcd_implementation_hotend_status(_lcdLineNr, hotend_status_extruder); \
  3296. } \
  3297. if (_skipStatic && encoderLine <= _thisItemNr) { \
  3298. encoderPosition += ENCODER_STEPS_PER_MENU_ITEM; \
  3299. ++encoderLine; \
  3300. } \
  3301. lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT; \
  3302. } \
  3303. ++_thisItemNr; \
  3304. }while(0)
  3305. void lcd_advanced_pause_resume_print() {
  3306. advanced_pause_menu_response = ADVANCED_PAUSE_RESPONSE_RESUME_PRINT;
  3307. }
  3308. void lcd_advanced_pause_extrude_more() {
  3309. advanced_pause_menu_response = ADVANCED_PAUSE_RESPONSE_EXTRUDE_MORE;
  3310. }
  3311. void menu_advanced_pause_option() {
  3312. START_MENU();
  3313. #if LCD_HEIGHT > 2
  3314. STATIC_ITEM(MSG_FILAMENT_CHANGE_OPTION_HEADER, true, false);
  3315. #endif
  3316. MENU_ITEM(function, MSG_FILAMENT_CHANGE_OPTION_RESUME, lcd_advanced_pause_resume_print);
  3317. MENU_ITEM(function, MSG_FILAMENT_CHANGE_OPTION_PURGE, lcd_advanced_pause_extrude_more);
  3318. END_MENU();
  3319. }
  3320. void lcd_advanced_pause_init_message() {
  3321. START_SCREEN();
  3322. STATIC_ITEM_P(advanced_pause_header(), true, true);
  3323. STATIC_ITEM(MSG_FILAMENT_CHANGE_INIT_1);
  3324. #ifdef MSG_FILAMENT_CHANGE_INIT_2
  3325. STATIC_ITEM(MSG_FILAMENT_CHANGE_INIT_2);
  3326. #define __FC_LINES_A 3
  3327. #else
  3328. #define __FC_LINES_A 2
  3329. #endif
  3330. #ifdef MSG_FILAMENT_CHANGE_INIT_3
  3331. STATIC_ITEM(MSG_FILAMENT_CHANGE_INIT_3);
  3332. #define _FC_LINES_A (__FC_LINES_A + 1)
  3333. #else
  3334. #define _FC_LINES_A __FC_LINES_A
  3335. #endif
  3336. #if LCD_HEIGHT > _FC_LINES_A + 1
  3337. STATIC_ITEM(" ");
  3338. #endif
  3339. HOTEND_STATUS_ITEM();
  3340. END_SCREEN();
  3341. }
  3342. void lcd_advanced_pause_unload_message() {
  3343. START_SCREEN();
  3344. STATIC_ITEM_P(advanced_pause_header(), true, true);
  3345. STATIC_ITEM(MSG_FILAMENT_CHANGE_UNLOAD_1);
  3346. #ifdef MSG_FILAMENT_CHANGE_UNLOAD_2
  3347. STATIC_ITEM(MSG_FILAMENT_CHANGE_UNLOAD_2);
  3348. #define __FC_LINES_B 3
  3349. #else
  3350. #define __FC_LINES_B 2
  3351. #endif
  3352. #ifdef MSG_FILAMENT_CHANGE_UNLOAD_3
  3353. STATIC_ITEM(MSG_FILAMENT_CHANGE_UNLOAD_3);
  3354. #define _FC_LINES_B (__FC_LINES_B + 1)
  3355. #else
  3356. #define _FC_LINES_B __FC_LINES_B
  3357. #endif
  3358. #if LCD_HEIGHT > _FC_LINES_B + 1
  3359. STATIC_ITEM(" ");
  3360. #endif
  3361. HOTEND_STATUS_ITEM();
  3362. END_SCREEN();
  3363. }
  3364. void lcd_advanced_pause_wait_for_nozzles_to_heat() {
  3365. START_SCREEN();
  3366. STATIC_ITEM_P(advanced_pause_header(), true, true);
  3367. STATIC_ITEM(MSG_FILAMENT_CHANGE_HEATING_1);
  3368. #ifdef MSG_FILAMENT_CHANGE_HEATING_2
  3369. STATIC_ITEM(MSG_FILAMENT_CHANGE_HEATING_2);
  3370. #define _FC_LINES_C 3
  3371. #else
  3372. #define _FC_LINES_C 2
  3373. #endif
  3374. #if LCD_HEIGHT > _FC_LINES_C + 1
  3375. STATIC_ITEM(" ");
  3376. #endif
  3377. HOTEND_STATUS_ITEM();
  3378. END_SCREEN();
  3379. }
  3380. void lcd_advanced_pause_heat_nozzle() {
  3381. START_SCREEN();
  3382. STATIC_ITEM_P(advanced_pause_header(), true, true);
  3383. STATIC_ITEM(MSG_FILAMENT_CHANGE_HEAT_1);
  3384. #ifdef MSG_FILAMENT_CHANGE_INSERT_2
  3385. STATIC_ITEM(MSG_FILAMENT_CHANGE_HEAT_2);
  3386. #define _FC_LINES_D 3
  3387. #else
  3388. #define _FC_LINES_D 2
  3389. #endif
  3390. #if LCD_HEIGHT > _FC_LINES_D + 1
  3391. STATIC_ITEM(" ");
  3392. #endif
  3393. HOTEND_STATUS_ITEM();
  3394. END_SCREEN();
  3395. }
  3396. void lcd_advanced_pause_insert_message() {
  3397. START_SCREEN();
  3398. STATIC_ITEM_P(advanced_pause_header(), true, true);
  3399. STATIC_ITEM(MSG_FILAMENT_CHANGE_INSERT_1);
  3400. #ifdef MSG_FILAMENT_CHANGE_INSERT_2
  3401. STATIC_ITEM(MSG_FILAMENT_CHANGE_INSERT_2);
  3402. #define __FC_LINES_E 3
  3403. #else
  3404. #define __FC_LINES_E 2
  3405. #endif
  3406. #ifdef MSG_FILAMENT_CHANGE_INSERT_3
  3407. STATIC_ITEM(MSG_FILAMENT_CHANGE_INSERT_3);
  3408. #define _FC_LINES_E (__FC_LINES_E + 1)
  3409. #else
  3410. #define _FC_LINES_E __FC_LINES_E
  3411. #endif
  3412. #if LCD_HEIGHT > _FC_LINES_E + 1
  3413. STATIC_ITEM(" ");
  3414. #endif
  3415. HOTEND_STATUS_ITEM();
  3416. END_SCREEN();
  3417. }
  3418. void lcd_advanced_pause_load_message() {
  3419. START_SCREEN();
  3420. STATIC_ITEM_P(advanced_pause_header(), true, true);
  3421. STATIC_ITEM(MSG_FILAMENT_CHANGE_LOAD_1);
  3422. #ifdef MSG_FILAMENT_CHANGE_LOAD_2
  3423. STATIC_ITEM(MSG_FILAMENT_CHANGE_LOAD_2);
  3424. #define __FC_LINES_F 3
  3425. #else
  3426. #define __FC_LINES_F 2
  3427. #endif
  3428. #ifdef MSG_FILAMENT_CHANGE_LOAD_3
  3429. STATIC_ITEM(MSG_FILAMENT_CHANGE_LOAD_3);
  3430. #define _FC_LINES_F (__FC_LINES_F + 1)
  3431. #else
  3432. #define _FC_LINES_F __FC_LINES_F
  3433. #endif
  3434. #if LCD_HEIGHT > _FC_LINES_F + 1
  3435. STATIC_ITEM(" ");
  3436. #endif
  3437. HOTEND_STATUS_ITEM();
  3438. END_SCREEN();
  3439. }
  3440. void lcd_advanced_pause_purge_message() {
  3441. START_SCREEN();
  3442. STATIC_ITEM_P(advanced_pause_header(), true, true);
  3443. STATIC_ITEM(MSG_FILAMENT_CHANGE_PURGE_1);
  3444. #ifdef MSG_FILAMENT_CHANGE_PURGE_2
  3445. STATIC_ITEM(MSG_FILAMENT_CHANGE_PURGE_2);
  3446. #define __FC_LINES_G 3
  3447. #else
  3448. #define __FC_LINES_G 2
  3449. #endif
  3450. #ifdef MSG_FILAMENT_CHANGE_PURGE_3
  3451. STATIC_ITEM(MSG_FILAMENT_CHANGE_PURGE_3);
  3452. #define _FC_LINES_G (__FC_LINES_G + 1)
  3453. #else
  3454. #define _FC_LINES_G __FC_LINES_G
  3455. #endif
  3456. #if LCD_HEIGHT > _FC_LINES_G + 1
  3457. STATIC_ITEM(" ");
  3458. #endif
  3459. HOTEND_STATUS_ITEM();
  3460. END_SCREEN();
  3461. }
  3462. #if ENABLED(ADVANCED_PAUSE_CONTINUOUS_PURGE)
  3463. void menu_advanced_pause_continuous_purge() {
  3464. START_SCREEN();
  3465. STATIC_ITEM(MSG_FILAMENT_CHANGE_PURGE_1);
  3466. #ifdef MSG_FILAMENT_CHANGE_PURGE_2
  3467. STATIC_ITEM(MSG_FILAMENT_CHANGE_PURGE_2);
  3468. #define __FC_LINES_G 3
  3469. #else
  3470. #define __FC_LINES_G 2
  3471. #endif
  3472. #ifdef MSG_FILAMENT_CHANGE_PURGE_3
  3473. STATIC_ITEM(MSG_FILAMENT_CHANGE_PURGE_3);
  3474. #define _FC_LINES_G (__FC_LINES_G + 1)
  3475. #else
  3476. #define _FC_LINES_G __FC_LINES_G
  3477. #endif
  3478. #if LCD_HEIGHT > _FC_LINES_G + 1
  3479. STATIC_ITEM(" ");
  3480. #endif
  3481. HOTEND_STATUS_ITEM();
  3482. STATIC_ITEM(MSG_USERWAIT);
  3483. END_SCREEN();
  3484. }
  3485. #endif
  3486. void lcd_advanced_pause_resume_message() {
  3487. START_SCREEN();
  3488. STATIC_ITEM_P(advanced_pause_header(), true, true);
  3489. STATIC_ITEM(MSG_FILAMENT_CHANGE_RESUME_1);
  3490. #ifdef MSG_FILAMENT_CHANGE_RESUME_2
  3491. STATIC_ITEM(MSG_FILAMENT_CHANGE_RESUME_2);
  3492. #endif
  3493. #ifdef MSG_FILAMENT_CHANGE_RESUME_3
  3494. STATIC_ITEM(MSG_FILAMENT_CHANGE_RESUME_3);
  3495. #endif
  3496. END_SCREEN();
  3497. }
  3498. FORCE_INLINE screenFunc_t ap_message_screen(const AdvancedPauseMessage message) {
  3499. switch (message) {
  3500. case ADVANCED_PAUSE_MESSAGE_INIT: return lcd_advanced_pause_init_message;
  3501. case ADVANCED_PAUSE_MESSAGE_UNLOAD: return lcd_advanced_pause_unload_message;
  3502. case ADVANCED_PAUSE_MESSAGE_INSERT: return lcd_advanced_pause_insert_message;
  3503. case ADVANCED_PAUSE_MESSAGE_LOAD: return lcd_advanced_pause_load_message;
  3504. case ADVANCED_PAUSE_MESSAGE_PURGE: return lcd_advanced_pause_purge_message;
  3505. case ADVANCED_PAUSE_MESSAGE_RESUME: return lcd_advanced_pause_resume_message;
  3506. case ADVANCED_PAUSE_MESSAGE_CLICK_TO_HEAT_NOZZLE: return lcd_advanced_pause_heat_nozzle;
  3507. case ADVANCED_PAUSE_MESSAGE_WAIT_FOR_NOZZLES_TO_HEAT: return lcd_advanced_pause_wait_for_nozzles_to_heat;
  3508. case ADVANCED_PAUSE_MESSAGE_OPTION: advanced_pause_menu_response = ADVANCED_PAUSE_RESPONSE_WAIT_FOR;
  3509. return menu_advanced_pause_option;
  3510. #if ENABLED(ADVANCED_PAUSE_CONTINUOUS_PURGE)
  3511. case ADVANCED_PAUSE_MESSAGE_CONTINUOUS_PURGE: return menu_advanced_pause_continuous_purge;
  3512. #endif
  3513. case ADVANCED_PAUSE_MESSAGE_STATUS:
  3514. default: break;
  3515. }
  3516. return NULL;
  3517. }
  3518. void lcd_advanced_pause_show_message(
  3519. const AdvancedPauseMessage message,
  3520. const AdvancedPauseMode mode/*=ADVANCED_PAUSE_MODE_PAUSE_PRINT*/,
  3521. const uint8_t extruder/*=active_extruder*/
  3522. ) {
  3523. advanced_pause_mode = mode;
  3524. hotend_status_extruder = extruder;
  3525. const screenFunc_t next_screen = ap_message_screen(message);
  3526. if (next_screen) {
  3527. defer_return_to_status = true;
  3528. lcd_goto_screen(next_screen);
  3529. }
  3530. else
  3531. lcd_return_to_status();
  3532. }
  3533. #endif // ADVANCED_PAUSE_FEATURE
  3534. #endif // ULTIPANEL