My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2021 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 <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. /**
  23. * lcd/e3v2/jyersui/dwin.cpp
  24. */
  25. #include "../../../inc/MarlinConfigPre.h"
  26. #if ENABLED(DWIN_CREALITY_LCD_JYERSUI)
  27. #include "dwin.h"
  28. #include "../../marlinui.h"
  29. #include "../../../MarlinCore.h"
  30. #include "../../../module/temperature.h"
  31. #include "../../../module/planner.h"
  32. #include "../../../module/settings.h"
  33. #include "../../../libs/buzzer.h"
  34. #include "../../../inc/Conditionals_post.h"
  35. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  36. #include "../../../feature/pause.h"
  37. #endif
  38. #if ENABLED(FILAMENT_RUNOUT_SENSOR)
  39. #include "../../../feature/runout.h"
  40. #endif
  41. #if ENABLED(HOST_ACTION_COMMANDS)
  42. #include "../../../feature/host_actions.h"
  43. #endif
  44. #if ANY(BABYSTEPPING, HAS_BED_PROBE, HAS_WORKSPACE_OFFSET)
  45. #define HAS_ZOFFSET_ITEM 1
  46. #endif
  47. #ifndef strcasecmp_P
  48. #define strcasecmp_P(a, b) strcasecmp((a), (b))
  49. #endif
  50. #if HAS_LEVELING
  51. #include "../../../feature/bedlevel/bedlevel.h"
  52. #endif
  53. #if ENABLED(AUTO_BED_LEVELING_UBL)
  54. #include "../../../libs/least_squares_fit.h"
  55. #include "../../../libs/vector_3.h"
  56. #endif
  57. #if HAS_BED_PROBE
  58. #include "../../../module/probe.h"
  59. #endif
  60. #if ANY(HAS_HOTEND, HAS_HEATED_BED, HAS_FAN) && PREHEAT_COUNT
  61. #define HAS_PREHEAT 1
  62. #endif
  63. #if ENABLED(POWER_LOSS_RECOVERY)
  64. #include "../../../feature/powerloss.h"
  65. #endif
  66. #define MACHINE_SIZE STRINGIFY(X_BED_SIZE) "x" STRINGIFY(Y_BED_SIZE) "x" STRINGIFY(Z_MAX_POS)
  67. #ifndef CORP_WEBSITE
  68. #define CORP_WEBSITE WEBSITE_URL
  69. #endif
  70. #define DWIN_FONT_MENU font8x16
  71. #define DWIN_FONT_STAT font10x20
  72. #define DWIN_FONT_HEAD font10x20
  73. #define MENU_CHAR_LIMIT 24
  74. #define STATUS_Y 352
  75. #define MAX_PRINT_SPEED 500
  76. #define MIN_PRINT_SPEED 10
  77. #if HAS_FAN
  78. #define MAX_FAN_SPEED 255
  79. #define MIN_FAN_SPEED 0
  80. #endif
  81. #define MAX_XY_OFFSET 100
  82. #if HAS_ZOFFSET_ITEM
  83. #define MAX_Z_OFFSET 9.99
  84. #if HAS_BED_PROBE
  85. #define MIN_Z_OFFSET -9.99
  86. #else
  87. #define MIN_Z_OFFSET -1
  88. #endif
  89. #endif
  90. #if HAS_HOTEND
  91. #define MAX_FLOW_RATE 200
  92. #define MIN_FLOW_RATE 10
  93. #define MAX_E_TEMP (HEATER_0_MAXTEMP - HOTEND_OVERSHOOT)
  94. #define MIN_E_TEMP 0
  95. #endif
  96. #if HAS_HEATED_BED
  97. #define MAX_BED_TEMP BED_MAXTEMP
  98. #define MIN_BED_TEMP 0
  99. #endif
  100. constexpr uint16_t TROWS = 6, MROWS = TROWS - 1,
  101. TITLE_HEIGHT = 30,
  102. MLINE = 53,
  103. LBLX = 60,
  104. MENU_CHR_W = 8, MENU_CHR_H = 16, STAT_CHR_W = 10;
  105. #define MBASE(L) (49 + MLINE * (L))
  106. constexpr float default_max_feedrate[] = DEFAULT_MAX_FEEDRATE;
  107. constexpr float default_max_acceleration[] = DEFAULT_MAX_ACCELERATION;
  108. constexpr float default_steps[] = DEFAULT_AXIS_STEPS_PER_UNIT;
  109. #if HAS_CLASSIC_JERK
  110. constexpr float default_max_jerk[] = { DEFAULT_XJERK, DEFAULT_YJERK, DEFAULT_ZJERK, DEFAULT_EJERK };
  111. #endif
  112. uint8_t active_menu = MainMenu;
  113. uint8_t last_menu = MainMenu;
  114. uint8_t selection = 0;
  115. uint8_t last_selection = 0;
  116. uint8_t scrollpos = 0;
  117. uint8_t process = Main;
  118. uint8_t last_process = Main;
  119. PopupID popup;
  120. PopupID last_popup;
  121. void (*funcpointer)() = nullptr;
  122. void *valuepointer = nullptr;
  123. float tempvalue;
  124. float valuemin;
  125. float valuemax;
  126. uint8_t valueunit;
  127. uint8_t valuetype;
  128. char cmd[MAX_CMD_SIZE+16], str_1[16], str_2[16], str_3[16];
  129. char statusmsg[64];
  130. char filename[LONG_FILENAME_LENGTH];
  131. bool printing = false;
  132. bool paused = false;
  133. bool sdprint = false;
  134. int16_t pausetemp, pausebed, pausefan;
  135. bool livemove = false;
  136. bool liveadjust = false;
  137. uint8_t preheatmode = 0;
  138. float zoffsetvalue = 0;
  139. uint8_t gridpoint;
  140. float corner_avg;
  141. float corner_pos;
  142. bool probe_deployed = false;
  143. CrealityDWINClass CrealityDWIN;
  144. #if HAS_MESH
  145. struct Mesh_Settings {
  146. bool viewer_asymmetric_range = false;
  147. bool viewer_print_value = false;
  148. bool goto_mesh_value = false;
  149. bool drawing_mesh = false;
  150. uint8_t mesh_x = 0;
  151. uint8_t mesh_y = 0;
  152. #if ENABLED(AUTO_BED_LEVELING_UBL)
  153. bed_mesh_t &mesh_z_values = ubl.z_values;
  154. uint8_t tilt_grid = 1;
  155. void manual_value_update(bool undefined=false) {
  156. sprintf_P(cmd, PSTR("M421 I%i J%i Z%s %s"), mesh_x, mesh_y, dtostrf(current_position.z, 1, 3, str_1), undefined ? "N" : "");
  157. gcode.process_subcommands_now_P(cmd);
  158. planner.synchronize();
  159. }
  160. bool create_plane_from_mesh() {
  161. struct linear_fit_data lsf_results;
  162. incremental_LSF_reset(&lsf_results);
  163. GRID_LOOP(x, y) {
  164. if (!isnan(mesh_z_values[x][y])) {
  165. xy_pos_t rpos;
  166. rpos.x = ubl.mesh_index_to_xpos(x);
  167. rpos.y = ubl.mesh_index_to_ypos(y);
  168. incremental_LSF(&lsf_results, rpos, mesh_z_values[x][y]);
  169. }
  170. }
  171. if (finish_incremental_LSF(&lsf_results)) {
  172. SERIAL_ECHOPGM("Could not complete LSF!");
  173. return true;
  174. }
  175. ubl.set_all_mesh_points_to_value(0);
  176. matrix_3x3 rotation = matrix_3x3::create_look_at(vector_3(lsf_results.A, lsf_results.B, 1));
  177. GRID_LOOP(i, j) {
  178. float mx = ubl.mesh_index_to_xpos(i),
  179. my = ubl.mesh_index_to_ypos(j),
  180. mz = mesh_z_values[i][j];
  181. if (DEBUGGING(LEVELING)) {
  182. DEBUG_ECHOPAIR_F("before rotation = [", mx, 7);
  183. DEBUG_CHAR(',');
  184. DEBUG_ECHO_F(my, 7);
  185. DEBUG_CHAR(',');
  186. DEBUG_ECHO_F(mz, 7);
  187. DEBUG_ECHOPGM("] ---> ");
  188. DEBUG_DELAY(20);
  189. }
  190. rotation.apply_rotation_xyz(mx, my, mz);
  191. if (DEBUGGING(LEVELING)) {
  192. DEBUG_ECHOPAIR_F("after rotation = [", mx, 7);
  193. DEBUG_CHAR(',');
  194. DEBUG_ECHO_F(my, 7);
  195. DEBUG_CHAR(',');
  196. DEBUG_ECHO_F(mz, 7);
  197. DEBUG_ECHOLNPGM("]");
  198. DEBUG_DELAY(20);
  199. }
  200. mesh_z_values[i][j] = mz - lsf_results.D;
  201. }
  202. return false;
  203. }
  204. #else
  205. bed_mesh_t &mesh_z_values = z_values;
  206. void manual_value_update() {
  207. sprintf_P(cmd, PSTR("G29 I%i J%i Z%s"), mesh_x, mesh_y, dtostrf(current_position.z, 1, 3, str_1));
  208. gcode.process_subcommands_now_P(cmd);
  209. planner.synchronize();
  210. }
  211. #endif
  212. void manual_move(bool zmove=false) {
  213. if (zmove) {
  214. planner.synchronize();
  215. current_position.z = goto_mesh_value ? mesh_z_values[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES;
  216. planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder);
  217. planner.synchronize();
  218. }
  219. else {
  220. CrealityDWIN.Popup_Handler(MoveWait);
  221. sprintf_P(cmd, PSTR("G0 F300 Z%s"), dtostrf(Z_CLEARANCE_BETWEEN_PROBES, 1, 3, str_1));
  222. gcode.process_subcommands_now_P(cmd);
  223. sprintf_P(cmd, PSTR("G42 F4000 I%i J%i"), mesh_x, mesh_y);
  224. gcode.process_subcommands_now_P(cmd);
  225. planner.synchronize();
  226. current_position.z = goto_mesh_value ? mesh_z_values[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES;
  227. planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder);
  228. planner.synchronize();
  229. CrealityDWIN.Redraw_Menu();
  230. }
  231. }
  232. float get_max_value() {
  233. float max = __FLT_MIN__;
  234. GRID_LOOP(x, y) {
  235. if (!isnan(mesh_z_values[x][y]) && mesh_z_values[x][y] > max)
  236. max = mesh_z_values[x][y];
  237. }
  238. return max;
  239. }
  240. float get_min_value() {
  241. float min = __FLT_MAX__;
  242. GRID_LOOP(x, y) {
  243. if (!isnan(mesh_z_values[x][y]) && mesh_z_values[x][y] < min)
  244. min = mesh_z_values[x][y];
  245. }
  246. return min;
  247. }
  248. void Draw_Bed_Mesh(int16_t selected = -1, uint8_t gridline_width = 1, uint16_t padding_x = 8, uint16_t padding_y_top = 40 + 53 - 7) {
  249. drawing_mesh = true;
  250. const uint16_t total_width_px = DWIN_WIDTH - padding_x - padding_x;
  251. const uint16_t cell_width_px = total_width_px / GRID_MAX_POINTS_X;
  252. const uint16_t cell_height_px = total_width_px / GRID_MAX_POINTS_Y;
  253. const float v_max = abs(get_max_value()), v_min = abs(get_min_value()), range = max(v_min, v_max);
  254. // Clear background from previous selection and select new square
  255. DWIN_Draw_Rectangle(1, Color_Bg_Black, max(0, padding_x - gridline_width), max(0, padding_y_top - gridline_width), padding_x + total_width_px, padding_y_top + total_width_px);
  256. if (selected >= 0) {
  257. const auto selected_y = selected / GRID_MAX_POINTS_X;
  258. const auto selected_x = selected - (GRID_MAX_POINTS_X * selected_y);
  259. const auto start_y_px = padding_y_top + selected_y * cell_height_px;
  260. const auto start_x_px = padding_x + selected_x * cell_width_px;
  261. DWIN_Draw_Rectangle(1, Color_White, max(0, start_x_px - gridline_width), max(0, start_y_px - gridline_width), start_x_px + cell_width_px, start_y_px + cell_height_px);
  262. }
  263. // Draw value square grid
  264. char buf[8];
  265. GRID_LOOP(x, y) {
  266. const auto start_x_px = padding_x + x * cell_width_px;
  267. const auto end_x_px = start_x_px + cell_width_px - 1 - gridline_width;
  268. const auto start_y_px = padding_y_top + (GRID_MAX_POINTS_Y - y - 1) * cell_height_px;
  269. const auto end_y_px = start_y_px + cell_height_px - 1 - gridline_width;
  270. DWIN_Draw_Rectangle(1, // RGB565 colors: http://www.barth-dev.de/online/rgb565-color-picker/
  271. isnan(mesh_z_values[x][y]) ? Color_Grey : ( // gray if undefined
  272. (mesh_z_values[x][y] < 0 ?
  273. (uint16_t)round(0b11111 * -mesh_z_values[x][y] / (!viewer_asymmetric_range ? range : v_min)) << 11 : // red if mesh point value is negative
  274. (uint16_t)round(0b111111 * mesh_z_values[x][y] / (!viewer_asymmetric_range ? range : v_max)) << 5) | // green if mesh point value is positive
  275. min(0b11111, (((uint8_t)abs(mesh_z_values[x][y]) / 10) * 4))), // + blue stepping for every mm
  276. start_x_px, start_y_px, end_x_px, end_y_px);
  277. while (LCD_SERIAL.availableForWrite() < 32) { // wait for serial to be available without blocking and resetting the MCU
  278. gcode.process_subcommands_now_P("G4 P10");
  279. planner.synchronize();
  280. }
  281. // Draw value text on
  282. if (viewer_print_value) {
  283. gcode.process_subcommands_now_P("G4 P10"); // still fails without additional delay...
  284. planner.synchronize();
  285. int8_t offset_x, offset_y = cell_height_px / 2 - 6;
  286. if (isnan(mesh_z_values[x][y])) { // undefined
  287. DWIN_Draw_String(false, false, font6x12, Color_White, Color_Bg_Blue, start_x_px + cell_width_px / 2 - 5, start_y_px + offset_y, F("X"));
  288. }
  289. else { // has value
  290. if (GRID_MAX_POINTS_X < 10)
  291. sprintf_P(buf, PSTR("%s"), dtostrf(abs(mesh_z_values[x][y]), 1, 2, str_1));
  292. else
  293. sprintf_P(buf, PSTR("%02i"), (uint16_t)(abs(mesh_z_values[x][y] - (int16_t)mesh_z_values[x][y]) * 100));
  294. offset_x = cell_width_px / 2 - 3 * (strlen(buf)) - 2;
  295. if (!(GRID_MAX_POINTS_X < 10))
  296. DWIN_Draw_String(false, false, font6x12, Color_White, Color_Bg_Blue, start_x_px - 2 + offset_x, start_y_px + offset_y /*+ square / 2 - 6*/, F("."));
  297. DWIN_Draw_String(false, false, font6x12, Color_White, Color_Bg_Blue, start_x_px + 1 + offset_x, start_y_px + offset_y /*+ square / 2 - 6*/, buf);
  298. }
  299. }
  300. }
  301. }
  302. void Set_Mesh_Viewer_Status() { // TODO: draw gradient with values as a legend instead
  303. float v_max = abs(get_max_value()), v_min = abs(get_min_value()), range = max(v_min, v_max);
  304. if (v_min > 3e+10F) v_min = 0.0000001;
  305. if (v_max > 3e+10F) v_max = 0.0000001;
  306. if (range > 3e+10F) range = 0.0000001;
  307. char msg[32];
  308. if (viewer_asymmetric_range) {
  309. dtostrf(-v_min, 1, 3, str_1);
  310. dtostrf( v_max, 1, 3, str_2);
  311. }
  312. else {
  313. dtostrf(-range, 1, 3, str_1);
  314. dtostrf( range, 1, 3, str_2);
  315. }
  316. sprintf_P(msg, PSTR("Red %s..0..%s Green"), str_1, str_2);
  317. CrealityDWIN.Update_Status(msg);
  318. drawing_mesh = false;
  319. }
  320. };
  321. Mesh_Settings mesh_conf;
  322. #endif
  323. /* General Display Functions */
  324. struct CrealityDWINClass::EEPROM_Settings CrealityDWINClass::eeprom_settings{0};
  325. constexpr const char * const CrealityDWINClass::color_names[11];
  326. constexpr const char * const CrealityDWINClass::preheat_modes[3];
  327. // Clear a part of the screen
  328. // 4=Entire screen
  329. // 3=Title bar and Menu area (default)
  330. // 2=Menu area
  331. // 1=Title bar
  332. void CrealityDWINClass::Clear_Screen(uint8_t e/*=3*/) {
  333. if (e == 1 || e == 3 || e == 4) DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.menu_top_bg, Color_Bg_Blue, false), 0, 0, DWIN_WIDTH, TITLE_HEIGHT); // Clear Title Bar
  334. if (e == 2 || e == 3) DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, 31, DWIN_WIDTH, STATUS_Y); // Clear Menu Area
  335. if (e == 4) DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, 31, DWIN_WIDTH, DWIN_HEIGHT); // Clear Popup Area
  336. }
  337. void CrealityDWINClass::Draw_Float(float value, uint8_t row, bool selected/*=false*/, uint8_t minunit/*=10*/) {
  338. const uint8_t digits = (uint8_t)floor(log10(abs(value))) + log10(minunit) + (minunit > 1);
  339. const uint16_t bColor = (selected) ? Select_Color : Color_Bg_Black;
  340. const uint16_t xpos = 240 - (digits * 8);
  341. DWIN_Draw_Rectangle(1, Color_Bg_Black, 194, MBASE(row), 234 - (digits * 8), MBASE(row) + 16);
  342. if (isnan(value)) {
  343. DWIN_Draw_String(false, true, DWIN_FONT_MENU, Color_White, bColor, xpos - 8, MBASE(row), F(" NaN"));
  344. }
  345. else if (value < 0) {
  346. DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, Color_White, bColor, digits - log10(minunit) + 1, log10(minunit), xpos, MBASE(row), -value * minunit);
  347. DWIN_Draw_String(false, true, DWIN_FONT_MENU, Color_White, bColor, xpos - 8, MBASE(row), F("-"));
  348. }
  349. else {
  350. DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, Color_White, bColor, digits - log10(minunit) + 1, log10(minunit), xpos, MBASE(row), value * minunit);
  351. DWIN_Draw_String(false, true, DWIN_FONT_MENU, Color_White, bColor, xpos - 8, MBASE(row), F(" "));
  352. }
  353. }
  354. void CrealityDWINClass::Draw_Option(uint8_t value, const char * const * options, uint8_t row, bool selected/*=false*/, bool color/*=false*/) {
  355. uint16_t bColor = (selected) ? Select_Color : Color_Bg_Black;
  356. uint16_t tColor = (color) ? GetColor(value, Color_White, false) : Color_White;
  357. DWIN_Draw_Rectangle(1, bColor, 202, MBASE(row) + 14, 258, MBASE(row) - 2);
  358. DWIN_Draw_String(false, false, DWIN_FONT_MENU, tColor, bColor, 202, MBASE(row) - 1, options[value]);
  359. }
  360. uint16_t CrealityDWINClass::GetColor(uint8_t color, uint16_t original, bool light/*=false*/) {
  361. switch (color){
  362. case Default:
  363. return original;
  364. break;
  365. case White:
  366. return (light) ? Color_Light_White : Color_White;
  367. break;
  368. case Green:
  369. return (light) ? Color_Light_Green : Color_Green;
  370. break;
  371. case Cyan:
  372. return (light) ? Color_Light_Cyan : Color_Cyan;
  373. break;
  374. case Blue:
  375. return (light) ? Color_Light_Blue : Color_Blue;
  376. break;
  377. case Magenta:
  378. return (light) ? Color_Light_Magenta : Color_Magenta;
  379. break;
  380. case Red:
  381. return (light) ? Color_Light_Red : Color_Red;
  382. break;
  383. case Orange:
  384. return (light) ? Color_Light_Orange : Color_Orange;
  385. break;
  386. case Yellow:
  387. return (light) ? Color_Light_Yellow : Color_Yellow;
  388. break;
  389. case Brown:
  390. return (light) ? Color_Light_Brown : Color_Brown;
  391. break;
  392. case Black:
  393. return Color_Black;
  394. break;
  395. }
  396. return Color_White;
  397. }
  398. void CrealityDWINClass::Draw_Title(const char * title) {
  399. DWIN_Draw_String(false, false, DWIN_FONT_HEAD, GetColor(eeprom_settings.menu_top_txt, Color_White, false), Color_Bg_Blue, (DWIN_WIDTH - strlen(title) * STAT_CHR_W) / 2, 5, title);
  400. }
  401. void CrealityDWINClass::Draw_Menu_Item(uint8_t row, uint8_t icon/*=0*/, const char * label1, const char * label2, bool more/*=false*/, bool centered/*=false*/) {
  402. const uint8_t label_offset_y = !(label1 && label2) ? 0 : MENU_CHR_H * 3 / 5;
  403. const uint8_t label1_offset_x = !centered ? LBLX : LBLX * 4/5 + max(LBLX * 1U/5, (DWIN_WIDTH - LBLX - (label1 ? strlen(label1) : 0) * MENU_CHR_W) / 2);
  404. const uint8_t label2_offset_x = !centered ? LBLX : LBLX * 4/5 + max(LBLX * 1U/5, (DWIN_WIDTH - LBLX - (label2 ? strlen(label2) : 0) * MENU_CHR_W) / 2);
  405. if (label1) DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, label1_offset_x, MBASE(row) - 1 - label_offset_y, label1); // Draw Label
  406. if (label2) DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, label2_offset_x, MBASE(row) - 1 + label_offset_y, label2); // Draw Label
  407. if (icon) DWIN_ICON_Show(ICON, icon, 26, MBASE(row) - 3); //Draw Menu Icon
  408. if (more) DWIN_ICON_Show(ICON, ICON_More, 226, MBASE(row) - 3); // Draw More Arrow
  409. DWIN_Draw_Line(GetColor(eeprom_settings.menu_split_line, Line_Color, true), 16, MBASE(row) + 33, 256, MBASE(row) + 33); // Draw Menu Line
  410. }
  411. void CrealityDWINClass::Draw_Checkbox(uint8_t row, bool value) {
  412. #if ENABLED(DWIN_CREALITY_LCD_CUSTOM_ICONS) // Draw appropriate checkbox icon
  413. DWIN_ICON_Show(ICON, (value ? ICON_Checkbox_T : ICON_Checkbox_F), 226, MBASE(row) - 3);
  414. #else // Draw a basic checkbox using rectangles and lines
  415. DWIN_Draw_Rectangle(1, Color_Bg_Black, 226, MBASE(row) - 3, 226 + 20, MBASE(row) - 3 + 20);
  416. DWIN_Draw_Rectangle(0, Color_White, 226, MBASE(row) - 3, 226 + 20, MBASE(row) - 3 + 20);
  417. if (value) {
  418. DWIN_Draw_Line(Check_Color, 227, MBASE(row) - 3 + 11, 226 + 8, MBASE(row) - 3 + 17);
  419. DWIN_Draw_Line(Check_Color, 227 + 8, MBASE(row) - 3 + 17, 226 + 19, MBASE(row) - 3 + 1);
  420. DWIN_Draw_Line(Check_Color, 227, MBASE(row) - 3 + 12, 226 + 8, MBASE(row) - 3 + 18);
  421. DWIN_Draw_Line(Check_Color, 227 + 8, MBASE(row) - 3 + 18, 226 + 19, MBASE(row) - 3 + 2);
  422. DWIN_Draw_Line(Check_Color, 227, MBASE(row) - 3 + 13, 226 + 8, MBASE(row) - 3 + 19);
  423. DWIN_Draw_Line(Check_Color, 227 + 8, MBASE(row) - 3 + 19, 226 + 19, MBASE(row) - 3 + 3);
  424. }
  425. #endif
  426. }
  427. void CrealityDWINClass::Draw_Menu(uint8_t menu, uint8_t select/*=0*/, uint8_t scroll/*=0*/) {
  428. if (active_menu != menu) {
  429. last_menu = active_menu;
  430. if (process == Menu) last_selection = selection;
  431. }
  432. selection = min(select, Get_Menu_Size(menu));
  433. scrollpos = scroll;
  434. if (selection - scrollpos > MROWS)
  435. scrollpos = selection - MROWS;
  436. process = Menu;
  437. active_menu = menu;
  438. Clear_Screen();
  439. Draw_Title(Get_Menu_Title(menu));
  440. LOOP_L_N(i, TROWS) Menu_Item_Handler(menu, i + scrollpos);
  441. DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Rectangle_Color), 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33);
  442. }
  443. void CrealityDWINClass::Redraw_Menu(bool lastprocess/*=true*/, bool lastselection/*=false*/, bool lastmenu/*=false*/) {
  444. switch ((lastprocess) ? last_process : process) {
  445. case Menu:
  446. Draw_Menu((lastmenu) ? last_menu : active_menu, (lastselection) ? last_selection : selection, (lastmenu) ? 0 : scrollpos);
  447. break;
  448. case Main: Draw_Main_Menu((lastselection) ? last_selection : selection); break;
  449. case Print: Draw_Print_Screen(); break;
  450. case File: Draw_SD_List(); break;
  451. default: break;
  452. }
  453. }
  454. void CrealityDWINClass::Redraw_Screen() {
  455. Redraw_Menu(false);
  456. Draw_Status_Area(true);
  457. Update_Status_Bar(true);
  458. }
  459. /* Primary Menus and Screen Elements */
  460. void CrealityDWINClass::Main_Menu_Icons() {
  461. if (selection == 0) {
  462. DWIN_ICON_Show(ICON, ICON_Print_1, 17, 130);
  463. DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 17, 130, 126, 229);
  464. DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 52, 200, F("Print"));
  465. }
  466. else {
  467. DWIN_ICON_Show(ICON, ICON_Print_0, 17, 130);
  468. DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 52, 200, F("Print"));
  469. }
  470. if (selection == 1) {
  471. DWIN_ICON_Show(ICON, ICON_Prepare_1, 145, 130);
  472. DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 145, 130, 254, 229);
  473. DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 170, 200, F("Prepare"));
  474. }
  475. else {
  476. DWIN_ICON_Show(ICON, ICON_Prepare_0, 145, 130);
  477. DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 170, 200, F("Prepare"));
  478. }
  479. if (selection == 2) {
  480. DWIN_ICON_Show(ICON, ICON_Control_1, 17, 246);
  481. DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 17, 246, 126, 345);
  482. DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 43, 317, F("Control"));
  483. }
  484. else {
  485. DWIN_ICON_Show(ICON, ICON_Control_0, 17, 246);
  486. DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 43, 317, F("Control"));
  487. }
  488. #if HAS_ABL_OR_UBL
  489. if (selection == 3) {
  490. DWIN_ICON_Show(ICON, ICON_Leveling_1, 145, 246);
  491. DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 145, 246, 254, 345);
  492. DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 179, 317, F("Level"));
  493. }
  494. else {
  495. DWIN_ICON_Show(ICON, ICON_Leveling_0, 145, 246);
  496. DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 179, 317, F("Level"));
  497. }
  498. #else
  499. if (selection == 3) {
  500. DWIN_ICON_Show(ICON, ICON_Info_1, 145, 246);
  501. DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 145, 246, 254, 345);
  502. DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 181, 317, F("Info"));
  503. }
  504. else {
  505. DWIN_ICON_Show(ICON, ICON_Info_0, 145, 246);
  506. DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 181, 317, F("Info"));
  507. //DWIN_Frame_AreaCopy(1, 132, 423, 159, 435, 186, 318);
  508. }
  509. #endif
  510. }
  511. void CrealityDWINClass::Draw_Main_Menu(uint8_t select/*=0*/) {
  512. process = Main;
  513. active_menu = MainMenu;
  514. selection = select;
  515. Clear_Screen();
  516. Draw_Title(Get_Menu_Title(MainMenu));
  517. SERIAL_ECHOPGM("\nDWIN handshake ");
  518. DWIN_ICON_Show(ICON, ICON_LOGO, 71, 72);
  519. Main_Menu_Icons();
  520. }
  521. void CrealityDWINClass::Print_Screen_Icons() {
  522. if (selection == 0) {
  523. DWIN_ICON_Show(ICON, ICON_Setup_1, 8, 252);
  524. DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 8, 252, 87, 351);
  525. DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 30, 322, F("Tune"));
  526. }
  527. else {
  528. DWIN_ICON_Show(ICON, ICON_Setup_0, 8, 252);
  529. DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 30, 322, F("Tune"));
  530. }
  531. if (selection == 2) {
  532. DWIN_ICON_Show(ICON, ICON_Stop_1, 184, 252);
  533. DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 184, 252, 263, 351);
  534. DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 205, 322, F("Stop"));
  535. }
  536. else {
  537. DWIN_ICON_Show(ICON, ICON_Stop_0, 184, 252);
  538. DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 205, 322, F("Stop"));
  539. }
  540. if (paused) {
  541. if (selection == 1) {
  542. DWIN_ICON_Show(ICON, ICON_Continue_1, 96, 252);
  543. DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 96, 252, 175, 351);
  544. DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 114, 322, F("Print"));
  545. }
  546. else {
  547. DWIN_ICON_Show(ICON, ICON_Continue_0, 96, 252);
  548. DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 114, 322, F("Print"));
  549. }
  550. }
  551. else {
  552. if (selection == 1) {
  553. DWIN_ICON_Show(ICON, ICON_Pause_1, 96, 252);
  554. DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 96, 252, 175, 351);
  555. DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 114, 322, F("Pause"));
  556. }
  557. else {
  558. DWIN_ICON_Show(ICON, ICON_Pause_0, 96, 252);
  559. DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 114, 322, F("Pause"));
  560. }
  561. }
  562. }
  563. void CrealityDWINClass::Draw_Print_Screen() {
  564. process = Print;
  565. selection = 0;
  566. Clear_Screen();
  567. DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 352, DWIN_WIDTH - 8, 376);
  568. Draw_Title("Printing...");
  569. Print_Screen_Icons();
  570. DWIN_ICON_Show(ICON, ICON_PrintTime, 14, 171);
  571. DWIN_ICON_Show(ICON, ICON_RemainTime, 147, 169);
  572. DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, 41, 163, "Elapsed");
  573. DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, 176, 163, "Remaining");
  574. Update_Status_Bar(true);
  575. Draw_Print_ProgressBar();
  576. Draw_Print_ProgressElapsed();
  577. TERN_(USE_M73_REMAINING_TIME, Draw_Print_ProgressRemain());
  578. Draw_Print_Filename(true);
  579. }
  580. void CrealityDWINClass::Draw_Print_Filename(const bool reset/*=false*/) {
  581. static uint8_t namescrl = 0;
  582. if (reset) namescrl = 0;
  583. if (process == Print) {
  584. size_t len = strlen(filename);
  585. int8_t pos = len;
  586. if (pos > 30) {
  587. pos -= namescrl;
  588. len = _MIN(pos, 30);
  589. char dispname[len + 1];
  590. if (pos >= 0) {
  591. LOOP_L_N(i, len) dispname[i] = filename[i + namescrl];
  592. }
  593. else {
  594. LOOP_L_N(i, 30 + pos) dispname[i] = ' ';
  595. LOOP_S_L_N(i, 30 + pos, 30) dispname[i] = filename[i - (30 + pos)];
  596. }
  597. dispname[len] = '\0';
  598. DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 50, DWIN_WIDTH - 8, 80);
  599. const int8_t npos = (DWIN_WIDTH - 30 * MENU_CHR_W) / 2;
  600. DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, npos, 60, dispname);
  601. if (-pos >= 30) namescrl = 0;
  602. namescrl++;
  603. }
  604. else {
  605. DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 50, DWIN_WIDTH - 8, 80);
  606. const int8_t npos = (DWIN_WIDTH - strlen(filename) * MENU_CHR_W) / 2;
  607. DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, npos, 60, filename);
  608. }
  609. }
  610. }
  611. void CrealityDWINClass::Draw_Print_ProgressBar() {
  612. uint8_t printpercent = sdprint ? card.percentDone() : (ui._get_progress() / 100);
  613. DWIN_ICON_Show(ICON, ICON_Bar, 15, 93);
  614. DWIN_Draw_Rectangle(1, BarFill_Color, 16 + printpercent * 240 / 100, 93, 256, 113);
  615. DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_percent, Percent_Color), Color_Bg_Black, 3, 109, 133, printpercent);
  616. DWIN_Draw_String(false, false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_percent, Percent_Color), Color_Bg_Black, 133, 133, "%");
  617. }
  618. #if ENABLED(USE_M73_REMAINING_TIME)
  619. void CrealityDWINClass::Draw_Print_ProgressRemain() {
  620. uint16_t remainingtime = ui.get_remaining_time();
  621. DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 2, 176, 187, remainingtime / 3600);
  622. DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 2, 200, 187, (remainingtime % 3600) / 60);
  623. if (eeprom_settings.time_format_textual) {
  624. DWIN_Draw_String(false, false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 192, 187, "h");
  625. DWIN_Draw_String(false, false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 216, 187, "m");
  626. }
  627. else
  628. DWIN_Draw_String(false, false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 192, 187, ":");
  629. }
  630. #endif
  631. void CrealityDWINClass::Draw_Print_ProgressElapsed() {
  632. duration_t elapsed = print_job_timer.duration();
  633. DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 2, 42, 187, elapsed.value / 3600);
  634. DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 2, 66, 187, (elapsed.value % 3600) / 60);
  635. if (eeprom_settings.time_format_textual) {
  636. DWIN_Draw_String(false, false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 58, 187, "h");
  637. DWIN_Draw_String(false, false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 82, 187, "m");
  638. }
  639. else
  640. DWIN_Draw_String(false, false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 58, 187, ":");
  641. }
  642. void CrealityDWINClass::Draw_Print_confirm() {
  643. Draw_Print_Screen();
  644. process = Confirm;
  645. popup = Complete;
  646. DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 252, 263, 351);
  647. DWIN_ICON_Show(ICON, ICON_Confirm_E, 87, 283);
  648. DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 86, 282, 187, 321);
  649. DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 85, 281, 188, 322);
  650. }
  651. void CrealityDWINClass::Draw_SD_Item(uint8_t item, uint8_t row) {
  652. if (item == 0)
  653. Draw_Menu_Item(0, ICON_Back, card.flag.workDirIsRoot ? "Back" : "..");
  654. else {
  655. card.getfilename_sorted(SD_ORDER(item - 1, card.get_num_Files()));
  656. char * const filename = card.longest_filename();
  657. size_t max = MENU_CHAR_LIMIT;
  658. size_t pos = strlen(filename), len = pos;
  659. if (!card.flag.filenameIsDir)
  660. while (pos && filename[pos] != '.') pos--;
  661. len = pos;
  662. if (len > max) len = max;
  663. char name[len + 1];
  664. LOOP_L_N(i, len) name[i] = filename[i];
  665. if (pos > max)
  666. LOOP_S_L_N(i, len - 3, len) name[i] = '.';
  667. name[len] = '\0';
  668. Draw_Menu_Item(row, card.flag.filenameIsDir ? ICON_More : ICON_File, name);
  669. }
  670. }
  671. void CrealityDWINClass::Draw_SD_List(bool removed/*=false*/) {
  672. Clear_Screen();
  673. Draw_Title("Select File");
  674. selection = 0;
  675. scrollpos = 0;
  676. process = File;
  677. if (card.isMounted() && !removed) {
  678. LOOP_L_N(i, _MIN(card.get_num_Files() + 1, TROWS))
  679. Draw_SD_Item(i, i);
  680. }
  681. else {
  682. Draw_Menu_Item(0, ICON_Back, "Back");
  683. DWIN_Draw_Rectangle(1, Color_Bg_Red, 10, MBASE(3) - 10, DWIN_WIDTH - 10, MBASE(4));
  684. DWIN_Draw_String(false, false, font16x32, Color_Yellow, Color_Bg_Red, ((DWIN_WIDTH) - 8 * 16) / 2, MBASE(3), "No Media");
  685. }
  686. DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Rectangle_Color), 0, MBASE(0) - 18, 14, MBASE(0) + 33);
  687. }
  688. void CrealityDWINClass::Draw_Status_Area(bool icons/*=false*/) {
  689. if (icons) DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, STATUS_Y, DWIN_WIDTH, DWIN_HEIGHT - 1);
  690. #if HAS_HOTEND
  691. static float hotend = -1;
  692. static int16_t hotendtarget = -1, flow = -1;
  693. if (icons) {
  694. hotend = -1;
  695. hotendtarget = -1;
  696. DWIN_ICON_Show(ICON, ICON_HotendTemp, 10, 383);
  697. DWIN_Draw_String(false, false, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 25 + 3 * STAT_CHR_W + 5, 384, F("/"));
  698. }
  699. if (thermalManager.temp_hotend[0].celsius != hotend) {
  700. hotend = thermalManager.temp_hotend[0].celsius;
  701. DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 3, 28, 384, thermalManager.temp_hotend[0].celsius);
  702. DWIN_Draw_DegreeSymbol(GetColor(eeprom_settings.status_area_text, Color_White), 25 + 3 * STAT_CHR_W + 5, 386);
  703. }
  704. if (thermalManager.temp_hotend[0].target != hotendtarget) {
  705. hotendtarget = thermalManager.temp_hotend[0].target;
  706. DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 384, thermalManager.temp_hotend[0].target);
  707. DWIN_Draw_DegreeSymbol(GetColor(eeprom_settings.status_area_text, Color_White), 25 + 4 * STAT_CHR_W + 39, 386);
  708. }
  709. if (icons) {
  710. flow = -1;
  711. DWIN_ICON_Show(ICON, ICON_StepE, 112, 417);
  712. DWIN_Draw_String(false, false, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 116 + 5 * STAT_CHR_W + 2, 417, F("%"));
  713. }
  714. if (planner.flow_percentage[0] != flow) {
  715. flow = planner.flow_percentage[0];
  716. DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 3, 116 + 2 * STAT_CHR_W, 417, planner.flow_percentage[0]);
  717. }
  718. #endif
  719. #if HAS_HEATED_BED
  720. static float bed = -1;
  721. static int16_t bedtarget = -1;
  722. if (icons) {
  723. bed = -1;
  724. bedtarget = -1;
  725. DWIN_ICON_Show(ICON, ICON_BedTemp, 10, 416);
  726. DWIN_Draw_String(false, false, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 25 + 3 * STAT_CHR_W + 5, 417, F("/"));
  727. }
  728. if (thermalManager.temp_bed.celsius != bed) {
  729. bed = thermalManager.temp_bed.celsius;
  730. DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 3, 28, 417, thermalManager.temp_bed.celsius);
  731. DWIN_Draw_DegreeSymbol(GetColor(eeprom_settings.status_area_text, Color_White), 25 + 3 * STAT_CHR_W + 5, 419);
  732. }
  733. if (thermalManager.temp_bed.target != bedtarget) {
  734. bedtarget = thermalManager.temp_bed.target;
  735. DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 417, thermalManager.temp_bed.target);
  736. DWIN_Draw_DegreeSymbol(GetColor(eeprom_settings.status_area_text, Color_White), 25 + 4 * STAT_CHR_W + 39, 419);
  737. }
  738. #endif
  739. #if HAS_FAN
  740. static uint8_t fan = -1;
  741. if (icons) {
  742. fan = -1;
  743. DWIN_ICON_Show(ICON, ICON_FanSpeed, 187, 383);
  744. }
  745. if (thermalManager.fan_speed[0] != fan) {
  746. fan = thermalManager.fan_speed[0];
  747. DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 3, 195 + 2 * STAT_CHR_W, 384, thermalManager.fan_speed[0]);
  748. }
  749. #endif
  750. #if HAS_ZOFFSET_ITEM
  751. static float offset = -1;
  752. if (icons) {
  753. offset = -1;
  754. DWIN_ICON_Show(ICON, ICON_Zoffset, 187, 416);
  755. }
  756. if (zoffsetvalue != offset) {
  757. offset = zoffsetvalue;
  758. if (zoffsetvalue < 0) {
  759. DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 2, 2, 207, 417, -zoffsetvalue * 100);
  760. DWIN_Draw_String(false, true, DWIN_FONT_MENU, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 205, 419, "-");
  761. }
  762. else {
  763. DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 2, 2, 207, 417, zoffsetvalue* 100);
  764. DWIN_Draw_String(false, true, DWIN_FONT_MENU, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 205, 419, " ");
  765. }
  766. }
  767. #endif
  768. static int16_t feedrate = -1;
  769. if (icons) {
  770. feedrate = -1;
  771. DWIN_ICON_Show(ICON, ICON_Speed, 113, 383);
  772. DWIN_Draw_String(false, false, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 116 + 5 * STAT_CHR_W + 2, 384, F("%"));
  773. }
  774. if (feedrate_percentage != feedrate) {
  775. feedrate = feedrate_percentage;
  776. DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 3, 116 + 2 * STAT_CHR_W, 384, feedrate_percentage);
  777. }
  778. static float x = -1, y = -1, z = -1;
  779. static bool update_x = false, update_y = false, update_z = false;
  780. update_x = (current_position.x != x || axis_should_home(X_AXIS) || update_x);
  781. update_y = (current_position.y != y || axis_should_home(Y_AXIS) || update_y);
  782. update_z = (current_position.z != z || axis_should_home(Z_AXIS) || update_z);
  783. if (icons) {
  784. x = y = z = -1;
  785. DWIN_Draw_Line(GetColor(eeprom_settings.coordinates_split_line, Line_Color, true), 16, 450, 256, 450);
  786. DWIN_ICON_Show(ICON, ICON_MaxSpeedX, 10, 456);
  787. DWIN_ICON_Show(ICON, ICON_MaxSpeedY, 95, 456);
  788. DWIN_ICON_Show(ICON, ICON_MaxSpeedZ, 180, 456);
  789. }
  790. if (update_x) {
  791. x = current_position.x;
  792. if ((update_x = axis_should_home(X_AXIS) && ui.get_blink()))
  793. DWIN_Draw_String(false, true, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 35, 459, " -?- ");
  794. else
  795. DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 3, 1, 35, 459, current_position.x * 10);
  796. }
  797. if (update_y) {
  798. y = current_position.y;
  799. if ((update_y = axis_should_home(Y_AXIS) && ui.get_blink()))
  800. DWIN_Draw_String(false, true, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 120, 459, " -?- ");
  801. else
  802. DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 3, 1, 120, 459, current_position.y * 10);
  803. }
  804. if (update_z) {
  805. z = current_position.z;
  806. if ((update_z = axis_should_home(Z_AXIS) && ui.get_blink()))
  807. DWIN_Draw_String(false, true, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 205, 459, " -?- ");
  808. else
  809. DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 3, 2, 205, 459, (current_position.z>=0) ? current_position.z * 100 : 0);
  810. }
  811. DWIN_UpdateLCD();
  812. }
  813. void CrealityDWINClass::Draw_Popup(PGM_P const line1, PGM_P const line2, PGM_P const line3, uint8_t mode, uint8_t icon/*=0*/) {
  814. if (process != Confirm && process != Popup && process != Wait) last_process = process;
  815. if ((process == Menu || process == Wait) && mode == Popup) last_selection = selection;
  816. process = mode;
  817. Clear_Screen();
  818. DWIN_Draw_Rectangle(0, Color_White, 13, 59, 259, 351);
  819. DWIN_Draw_Rectangle(1, Color_Bg_Window, 14, 60, 258, 350);
  820. const uint8_t ypos = (mode == Popup || mode == Confirm) ? 150 : 230;
  821. if (icon > 0) DWIN_ICON_Show(ICON, icon, 101, 105);
  822. DWIN_Draw_String(false, true, DWIN_FONT_MENU, Popup_Text_Color, Color_Bg_Window, (272 - 8 * strlen_P(line1)) / 2, ypos, line1);
  823. DWIN_Draw_String(false, true, DWIN_FONT_MENU, Popup_Text_Color, Color_Bg_Window, (272 - 8 * strlen_P(line2)) / 2, ypos + 30, line2);
  824. DWIN_Draw_String(false, true, DWIN_FONT_MENU, Popup_Text_Color, Color_Bg_Window, (272 - 8 * strlen_P(line3)) / 2, ypos + 60, line3);
  825. if (mode == Popup) {
  826. selection = 0;
  827. DWIN_Draw_Rectangle(1, Confirm_Color, 26, 280, 125, 317);
  828. DWIN_Draw_Rectangle(1, Cancel_Color, 146, 280, 245, 317);
  829. DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Window, 39, 290, "Confirm");
  830. DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Window, 165, 290, "Cancel");
  831. Popup_Select();
  832. }
  833. else if (mode == Confirm) {
  834. DWIN_Draw_Rectangle(1, Confirm_Color, 87, 280, 186, 317);
  835. DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Window, 96, 290, "Continue");
  836. }
  837. }
  838. void MarlinUI::kill_screen(PGM_P const error, PGM_P const component) {
  839. CrealityDWIN.Draw_Popup(PSTR("Printer Kill Reason:"), error, PSTR("Restart Required"), Wait, ICON_BLTouch);
  840. }
  841. void CrealityDWINClass::Popup_Select() {
  842. const uint16_t c1 = (selection == 0) ? GetColor(eeprom_settings.highlight_box, Color_White) : Color_Bg_Window,
  843. c2 = (selection == 0) ? Color_Bg_Window : GetColor(eeprom_settings.highlight_box, Color_White);
  844. DWIN_Draw_Rectangle(0, c1, 25, 279, 126, 318);
  845. DWIN_Draw_Rectangle(0, c1, 24, 278, 127, 319);
  846. DWIN_Draw_Rectangle(0, c2, 145, 279, 246, 318);
  847. DWIN_Draw_Rectangle(0, c2, 144, 278, 247, 319);
  848. }
  849. void CrealityDWINClass::Update_Status_Bar(bool refresh/*=false*/) {
  850. static bool new_msg;
  851. static uint8_t msgscrl = 0;
  852. static char lastmsg[64];
  853. if (strcmp_P(lastmsg, statusmsg) != 0 || refresh) {
  854. strcpy_P(lastmsg, statusmsg);
  855. msgscrl = 0;
  856. new_msg = true;
  857. }
  858. size_t len = strlen(statusmsg);
  859. int8_t pos = len;
  860. if (pos > 30) {
  861. pos -= msgscrl;
  862. len = pos;
  863. if (len > 30)
  864. len = 30;
  865. char dispmsg[len + 1];
  866. if (pos >= 0) {
  867. LOOP_L_N(i, len) dispmsg[i] = statusmsg[i + msgscrl];
  868. }
  869. else {
  870. LOOP_L_N(i, 30 + pos) dispmsg[i] = ' ';
  871. LOOP_S_L_N(i, 30 + pos, 30) dispmsg[i] = statusmsg[i - (30 + pos)];
  872. }
  873. dispmsg[len] = '\0';
  874. if (process == Print) {
  875. DWIN_Draw_Rectangle(1, Color_Grey, 8, 214, DWIN_WIDTH - 8, 238);
  876. const int8_t npos = (DWIN_WIDTH - 30 * MENU_CHR_W) / 2;
  877. DWIN_Draw_String(false, false, DWIN_FONT_MENU, GetColor(eeprom_settings.status_bar_text, Color_White), Color_Bg_Black, npos, 219, dispmsg);
  878. }
  879. else {
  880. DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 352, DWIN_WIDTH - 8, 376);
  881. const int8_t npos = (DWIN_WIDTH - 30 * MENU_CHR_W) / 2;
  882. DWIN_Draw_String(false, false, DWIN_FONT_MENU, GetColor(eeprom_settings.status_bar_text, Color_White), Color_Bg_Black, npos, 357, dispmsg);
  883. }
  884. if (-pos >= 30) msgscrl = 0;
  885. msgscrl++;
  886. }
  887. else {
  888. if (new_msg) {
  889. new_msg = false;
  890. if (process == Print) {
  891. DWIN_Draw_Rectangle(1, Color_Grey, 8, 214, DWIN_WIDTH - 8, 238);
  892. const int8_t npos = (DWIN_WIDTH - strlen(statusmsg) * MENU_CHR_W) / 2;
  893. DWIN_Draw_String(false, false, DWIN_FONT_MENU, GetColor(eeprom_settings.status_bar_text, Color_White), Color_Bg_Black, npos, 219, statusmsg);
  894. }
  895. else {
  896. DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 352, DWIN_WIDTH - 8, 376);
  897. const int8_t npos = (DWIN_WIDTH - strlen(statusmsg) * MENU_CHR_W) / 2;
  898. DWIN_Draw_String(false, false, DWIN_FONT_MENU, GetColor(eeprom_settings.status_bar_text, Color_White), Color_Bg_Black, npos, 357, statusmsg);
  899. }
  900. }
  901. }
  902. }
  903. /* Menu Item Config */
  904. void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/*=true*/) {
  905. uint8_t row = item - scrollpos;
  906. #if HAS_LEVELING
  907. static bool level_state;
  908. #endif
  909. switch (menu) {
  910. case Prepare:
  911. #define PREPARE_BACK 0
  912. #define PREPARE_MOVE (PREPARE_BACK + 1)
  913. #define PREPARE_DISABLE (PREPARE_MOVE + 1)
  914. #define PREPARE_HOME (PREPARE_DISABLE + 1)
  915. #define PREPARE_MANUALLEVEL (PREPARE_HOME + 1)
  916. #define PREPARE_ZOFFSET (PREPARE_MANUALLEVEL + ENABLED(HAS_ZOFFSET_ITEM))
  917. #define PREPARE_PREHEAT (PREPARE_ZOFFSET + ENABLED(HAS_PREHEAT))
  918. #define PREPARE_COOLDOWN (PREPARE_PREHEAT + ENABLED(HAS_PREHEAT))
  919. #define PREPARE_CHANGEFIL (PREPARE_COOLDOWN + ENABLED(ADVANCED_PAUSE_FEATURE))
  920. #define PREPARE_TOTAL PREPARE_CHANGEFIL
  921. switch (item) {
  922. case PREPARE_BACK:
  923. if (draw)
  924. Draw_Menu_Item(row, ICON_Back, "Back");
  925. else
  926. Draw_Main_Menu(1);
  927. break;
  928. case PREPARE_MOVE:
  929. if (draw)
  930. Draw_Menu_Item(row, ICON_Axis, "Move", nullptr, true);
  931. else
  932. Draw_Menu(Move);
  933. break;
  934. case PREPARE_DISABLE:
  935. if (draw)
  936. Draw_Menu_Item(row, ICON_CloseMotor, "Disable Stepper");
  937. else
  938. queue.inject_P(PSTR("M84"));
  939. break;
  940. case PREPARE_HOME:
  941. if (draw)
  942. Draw_Menu_Item(row, ICON_SetHome, "Homing", nullptr, true);
  943. else
  944. Draw_Menu(HomeMenu);
  945. break;
  946. case PREPARE_MANUALLEVEL:
  947. if (draw)
  948. Draw_Menu_Item(row, ICON_PrintSize, "Manual Leveling", nullptr, true);
  949. else {
  950. if (axes_should_home()) {
  951. Popup_Handler(Home);
  952. gcode.home_all_axes(true);
  953. }
  954. #if HAS_LEVELING
  955. level_state = planner.leveling_active;
  956. set_bed_leveling_enabled(false);
  957. #endif
  958. Draw_Menu(ManualLevel);
  959. }
  960. break;
  961. #if HAS_ZOFFSET_ITEM
  962. case PREPARE_ZOFFSET:
  963. if (draw)
  964. Draw_Menu_Item(row, ICON_Zoffset, "Z-Offset", nullptr, true);
  965. else {
  966. #if HAS_LEVELING
  967. level_state = planner.leveling_active;
  968. set_bed_leveling_enabled(false);
  969. #endif
  970. Draw_Menu(ZOffset);
  971. }
  972. break;
  973. #endif
  974. #if HAS_PREHEAT
  975. case PREPARE_PREHEAT:
  976. if (draw)
  977. Draw_Menu_Item(row, ICON_Temperature, "Preheat", nullptr, true);
  978. else
  979. Draw_Menu(Preheat);
  980. break;
  981. case PREPARE_COOLDOWN:
  982. if (draw)
  983. Draw_Menu_Item(row, ICON_Cool, "Cooldown");
  984. else {
  985. TERN_(HAS_FAN, thermalManager.zero_fan_speeds());
  986. thermalManager.disable_all_heaters();
  987. }
  988. break;
  989. #endif
  990. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  991. case PREPARE_CHANGEFIL:
  992. if (draw) {
  993. Draw_Menu_Item(row, ICON_ResumeEEPROM, "Change Filament"
  994. #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
  995. , nullptr, true
  996. #endif
  997. );
  998. }
  999. else {
  1000. #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
  1001. Draw_Menu(ChangeFilament);
  1002. #else
  1003. if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp)
  1004. Popup_Handler(ETemp);
  1005. else {
  1006. if (thermalManager.temp_hotend[0].celsius < thermalManager.temp_hotend[0].target - 2) {
  1007. Popup_Handler(Heating);
  1008. thermalManager.wait_for_hotend(0);
  1009. }
  1010. Popup_Handler(FilChange);
  1011. sprintf_P(cmd, PSTR("M600 B1 R%i"), thermalManager.temp_hotend[0].target);
  1012. gcode.process_subcommands_now_P(cmd);
  1013. }
  1014. #endif
  1015. }
  1016. break;
  1017. #endif
  1018. }
  1019. break;
  1020. case HomeMenu:
  1021. #define HOME_BACK 0
  1022. #define HOME_ALL (HOME_BACK + 1)
  1023. #define HOME_X (HOME_ALL + 1)
  1024. #define HOME_Y (HOME_X + 1)
  1025. #define HOME_Z (HOME_Y + 1)
  1026. #define HOME_SET (HOME_Z + 1)
  1027. #define HOME_TOTAL HOME_SET
  1028. switch (item) {
  1029. case HOME_BACK:
  1030. if (draw)
  1031. Draw_Menu_Item(row, ICON_Back, "Back");
  1032. else
  1033. Draw_Menu(Prepare, PREPARE_HOME);
  1034. break;
  1035. case HOME_ALL:
  1036. if (draw)
  1037. Draw_Menu_Item(row, ICON_Homing, "Home All");
  1038. else {
  1039. Popup_Handler(Home);
  1040. gcode.home_all_axes(true);
  1041. Redraw_Menu();
  1042. }
  1043. break;
  1044. case HOME_X:
  1045. if (draw)
  1046. Draw_Menu_Item(row, ICON_MoveX, "Home X");
  1047. else {
  1048. Popup_Handler(Home);
  1049. gcode.process_subcommands_now_P(PSTR("G28 X"));
  1050. planner.synchronize();
  1051. Redraw_Menu();
  1052. }
  1053. break;
  1054. case HOME_Y:
  1055. if (draw)
  1056. Draw_Menu_Item(row, ICON_MoveY, "Home Y");
  1057. else {
  1058. Popup_Handler(Home);
  1059. gcode.process_subcommands_now_P(PSTR("G28 Y"));
  1060. planner.synchronize();
  1061. Redraw_Menu();
  1062. }
  1063. break;
  1064. case HOME_Z:
  1065. if (draw)
  1066. Draw_Menu_Item(row, ICON_MoveZ,"Home Z");
  1067. else {
  1068. Popup_Handler(Home);
  1069. gcode.process_subcommands_now_P(PSTR("G28 Z"));
  1070. planner.synchronize();
  1071. Redraw_Menu();
  1072. }
  1073. break;
  1074. case HOME_SET:
  1075. if (draw)
  1076. Draw_Menu_Item(row, ICON_SetHome, "Set Home Position");
  1077. else {
  1078. gcode.process_subcommands_now_P(PSTR("G92 X0 Y0 Z0"));
  1079. AudioFeedback();
  1080. }
  1081. break;
  1082. }
  1083. break;
  1084. case Move:
  1085. #define MOVE_BACK 0
  1086. #define MOVE_X (MOVE_BACK + 1)
  1087. #define MOVE_Y (MOVE_X + 1)
  1088. #define MOVE_Z (MOVE_Y + 1)
  1089. #define MOVE_E (MOVE_Z + ENABLED(HAS_HOTEND))
  1090. #define MOVE_P (MOVE_E + ENABLED(HAS_BED_PROBE))
  1091. #define MOVE_LIVE (MOVE_P + 1)
  1092. #define MOVE_TOTAL MOVE_LIVE
  1093. switch (item) {
  1094. case MOVE_BACK:
  1095. if (draw)
  1096. Draw_Menu_Item(row, ICON_Back, "Back");
  1097. else {
  1098. #if HAS_BED_PROBE
  1099. probe_deployed = false;
  1100. probe.set_deployed(probe_deployed);
  1101. #endif
  1102. Draw_Menu(Prepare, PREPARE_MOVE);
  1103. }
  1104. break;
  1105. case MOVE_X:
  1106. if (draw) {
  1107. Draw_Menu_Item(row, ICON_MoveX, "Move X");
  1108. Draw_Float(current_position.x, row, false);
  1109. }
  1110. else
  1111. Modify_Value(current_position.x, X_MIN_POS, X_MAX_POS, 10);
  1112. break;
  1113. case MOVE_Y:
  1114. if (draw) {
  1115. Draw_Menu_Item(row, ICON_MoveY, "Move Y");
  1116. Draw_Float(current_position.y, row);
  1117. }
  1118. else
  1119. Modify_Value(current_position.y, Y_MIN_POS, Y_MAX_POS, 10);
  1120. break;
  1121. case MOVE_Z:
  1122. if (draw) {
  1123. Draw_Menu_Item(row, ICON_MoveZ, "Move Z");
  1124. Draw_Float(current_position.z, row);
  1125. }
  1126. else
  1127. Modify_Value(current_position.z, Z_MIN_POS, Z_MAX_POS, 10);
  1128. break;
  1129. #if HAS_HOTEND
  1130. case MOVE_E:
  1131. if (draw) {
  1132. Draw_Menu_Item(row, ICON_Extruder, "Extruder");
  1133. current_position.e = 0;
  1134. sync_plan_position();
  1135. Draw_Float(current_position.e, row);
  1136. }
  1137. else {
  1138. if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) {
  1139. Popup_Handler(ETemp);
  1140. }
  1141. else {
  1142. if (thermalManager.temp_hotend[0].celsius < thermalManager.temp_hotend[0].target - 2) {
  1143. Popup_Handler(Heating);
  1144. thermalManager.wait_for_hotend(0);
  1145. Redraw_Menu();
  1146. }
  1147. current_position.e = 0;
  1148. sync_plan_position();
  1149. Modify_Value(current_position.e, -500, 500, 10);
  1150. }
  1151. }
  1152. break;
  1153. #endif // HAS_HOTEND
  1154. #if HAS_BED_PROBE
  1155. case MOVE_P:
  1156. if (draw) {
  1157. Draw_Menu_Item(row, ICON_StockConfiguraton, "Probe");
  1158. Draw_Checkbox(row, probe_deployed);
  1159. }
  1160. else {
  1161. probe_deployed = !probe_deployed;
  1162. probe.set_deployed(probe_deployed);
  1163. Draw_Checkbox(row, probe_deployed);
  1164. }
  1165. break;
  1166. #endif
  1167. case MOVE_LIVE:
  1168. if (draw) {
  1169. Draw_Menu_Item(row, ICON_Axis, "Live Movement");
  1170. Draw_Checkbox(row, livemove);
  1171. }
  1172. else {
  1173. livemove = !livemove;
  1174. Draw_Checkbox(row, livemove);
  1175. }
  1176. break;
  1177. }
  1178. break;
  1179. case ManualLevel:
  1180. #define MLEVEL_BACK 0
  1181. #define MLEVEL_PROBE (MLEVEL_BACK + ENABLED(HAS_BED_PROBE))
  1182. #define MLEVEL_BL (MLEVEL_PROBE + 1)
  1183. #define MLEVEL_TL (MLEVEL_BL + 1)
  1184. #define MLEVEL_TR (MLEVEL_TL + 1)
  1185. #define MLEVEL_BR (MLEVEL_TR + 1)
  1186. #define MLEVEL_C (MLEVEL_BR + 1)
  1187. #define MLEVEL_ZPOS (MLEVEL_C + 1)
  1188. #define MLEVEL_TOTAL MLEVEL_ZPOS
  1189. static float mlev_z_pos = 0;
  1190. static bool use_probe = false;
  1191. switch (item) {
  1192. case MLEVEL_BACK:
  1193. if (draw)
  1194. Draw_Menu_Item(row, ICON_Back, "Back");
  1195. else {
  1196. TERN_(HAS_LEVELING, set_bed_leveling_enabled(level_state));
  1197. Draw_Menu(Prepare, PREPARE_MANUALLEVEL);
  1198. }
  1199. break;
  1200. #if HAS_BED_PROBE
  1201. case MLEVEL_PROBE:
  1202. if (draw) {
  1203. Draw_Menu_Item(row, ICON_Zoffset, "Use Probe");
  1204. Draw_Checkbox(row, use_probe);
  1205. }
  1206. else {
  1207. use_probe = !use_probe;
  1208. Draw_Checkbox(row, use_probe);
  1209. if (use_probe) {
  1210. Popup_Handler(Level);
  1211. corner_avg = 0;
  1212. #define PROBE_X_MIN _MAX(0 + corner_pos, X_MIN_POS + probe.offset.x, X_MIN_POS + PROBING_MARGIN) - probe.offset.x
  1213. #define PROBE_X_MAX _MIN((X_BED_SIZE + X_MIN_POS) - corner_pos, X_MAX_POS + probe.offset.x, X_MAX_POS - PROBING_MARGIN) - probe.offset.x
  1214. #define PROBE_Y_MIN _MAX(0 + corner_pos, Y_MIN_POS + probe.offset.y, Y_MIN_POS + PROBING_MARGIN) - probe.offset.y
  1215. #define PROBE_Y_MAX _MIN((Y_BED_SIZE + Y_MIN_POS) - corner_pos, Y_MAX_POS + probe.offset.y, Y_MAX_POS - PROBING_MARGIN) - probe.offset.y
  1216. corner_avg += probe.probe_at_point(PROBE_X_MIN, PROBE_Y_MIN, PROBE_PT_RAISE, 0, false);
  1217. corner_avg += probe.probe_at_point(PROBE_X_MIN, PROBE_Y_MAX, PROBE_PT_RAISE, 0, false);
  1218. corner_avg += probe.probe_at_point(PROBE_X_MAX, PROBE_Y_MAX, PROBE_PT_RAISE, 0, false);
  1219. corner_avg += probe.probe_at_point(PROBE_X_MAX, PROBE_Y_MIN, PROBE_PT_STOW, 0, false);
  1220. corner_avg /= 4;
  1221. Redraw_Menu();
  1222. }
  1223. }
  1224. break;
  1225. #endif
  1226. case MLEVEL_BL:
  1227. if (draw)
  1228. Draw_Menu_Item(row, ICON_AxisBL, "Bottom Left");
  1229. else {
  1230. Popup_Handler(MoveWait);
  1231. if (use_probe) {
  1232. #if HAS_BED_PROBE
  1233. sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s"), dtostrf(PROBE_X_MIN, 1, 3, str_1), dtostrf(PROBE_Y_MIN, 1, 3, str_2));
  1234. gcode.process_subcommands_now_P(cmd);
  1235. planner.synchronize();
  1236. Popup_Handler(ManualProbing);
  1237. #endif
  1238. }
  1239. else {
  1240. sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s\nG0 F300 Z%s"), dtostrf(corner_pos, 1, 3, str_1), dtostrf(corner_pos, 1, 3, str_2), dtostrf(mlev_z_pos, 1, 3, str_3));
  1241. gcode.process_subcommands_now_P(cmd);
  1242. planner.synchronize();
  1243. Redraw_Menu();
  1244. }
  1245. }
  1246. break;
  1247. case MLEVEL_TL:
  1248. if (draw)
  1249. Draw_Menu_Item(row, ICON_AxisTL, "Top Left");
  1250. else {
  1251. Popup_Handler(MoveWait);
  1252. if (use_probe) {
  1253. #if HAS_BED_PROBE
  1254. sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s"), dtostrf(PROBE_X_MIN, 1, 3, str_1), dtostrf(PROBE_Y_MAX, 1, 3, str_2));
  1255. gcode.process_subcommands_now_P(cmd);
  1256. planner.synchronize();
  1257. Popup_Handler(ManualProbing);
  1258. #endif
  1259. }
  1260. else {
  1261. sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s\nG0 F300 Z%s"), dtostrf(corner_pos, 1, 3, str_1), dtostrf((Y_BED_SIZE + Y_MIN_POS) - corner_pos, 1, 3, str_2), dtostrf(mlev_z_pos, 1, 3, str_3));
  1262. gcode.process_subcommands_now_P(cmd);
  1263. planner.synchronize();
  1264. Redraw_Menu();
  1265. }
  1266. }
  1267. break;
  1268. case MLEVEL_TR:
  1269. if (draw)
  1270. Draw_Menu_Item(row, ICON_AxisTR, "Top Right");
  1271. else {
  1272. Popup_Handler(MoveWait);
  1273. if (use_probe) {
  1274. #if HAS_BED_PROBE
  1275. sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s"), dtostrf(PROBE_X_MAX, 1, 3, str_1), dtostrf(PROBE_Y_MAX, 1, 3, str_2));
  1276. gcode.process_subcommands_now_P(cmd);
  1277. planner.synchronize();
  1278. Popup_Handler(ManualProbing);
  1279. #endif
  1280. }
  1281. else {
  1282. sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s\nG0 F300 Z%s"), dtostrf((X_BED_SIZE + X_MIN_POS) - corner_pos, 1, 3, str_1), dtostrf((Y_BED_SIZE + Y_MIN_POS) - corner_pos, 1, 3, str_2), dtostrf(mlev_z_pos, 1, 3, str_3));
  1283. gcode.process_subcommands_now_P(cmd);
  1284. planner.synchronize();
  1285. Redraw_Menu();
  1286. }
  1287. }
  1288. break;
  1289. case MLEVEL_BR:
  1290. if (draw)
  1291. Draw_Menu_Item(row, ICON_AxisBR, "Bottom Right");
  1292. else {
  1293. Popup_Handler(MoveWait);
  1294. if (use_probe) {
  1295. #if HAS_BED_PROBE
  1296. sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s"), dtostrf(PROBE_X_MAX, 1, 3, str_1), dtostrf(PROBE_Y_MIN, 1, 3, str_2));
  1297. gcode.process_subcommands_now_P(cmd);
  1298. planner.synchronize();
  1299. Popup_Handler(ManualProbing);
  1300. #endif
  1301. }
  1302. else {
  1303. sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s\nG0 F300 Z%s"), dtostrf((X_BED_SIZE + X_MIN_POS) - corner_pos, 1, 3, str_1), dtostrf(corner_pos, 1, 3, str_2), dtostrf(mlev_z_pos, 1, 3, str_3));
  1304. gcode.process_subcommands_now_P(cmd);
  1305. planner.synchronize();
  1306. Redraw_Menu();
  1307. }
  1308. }
  1309. break;
  1310. case MLEVEL_C:
  1311. if (draw)
  1312. Draw_Menu_Item(row, ICON_AxisC, "Center");
  1313. else {
  1314. Popup_Handler(MoveWait);
  1315. if (use_probe) {
  1316. #if HAS_BED_PROBE
  1317. sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s"), dtostrf(X_MAX_POS / 2.0f - probe.offset.x, 1, 3, str_1), dtostrf(Y_MAX_POS / 2.0f - probe.offset.y, 1, 3, str_2));
  1318. gcode.process_subcommands_now_P(cmd);
  1319. planner.synchronize();
  1320. Popup_Handler(ManualProbing);
  1321. #endif
  1322. }
  1323. else {
  1324. sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s\nG0 F300 Z%s"), dtostrf((X_BED_SIZE + X_MIN_POS) / 2.0f, 1, 3, str_1), dtostrf((Y_BED_SIZE + Y_MIN_POS) / 2.0f, 1, 3, str_2), dtostrf(mlev_z_pos, 1, 3, str_3));
  1325. gcode.process_subcommands_now_P(cmd);
  1326. planner.synchronize();
  1327. Redraw_Menu();
  1328. }
  1329. }
  1330. break;
  1331. case MLEVEL_ZPOS:
  1332. if (draw) {
  1333. Draw_Menu_Item(row, ICON_SetZOffset, "Z Position");
  1334. Draw_Float(mlev_z_pos, row, false, 100);
  1335. }
  1336. else
  1337. Modify_Value(mlev_z_pos, 0, MAX_Z_OFFSET, 100);
  1338. break;
  1339. }
  1340. break;
  1341. #if HAS_ZOFFSET_ITEM
  1342. case ZOffset:
  1343. #define ZOFFSET_BACK 0
  1344. #define ZOFFSET_HOME (ZOFFSET_BACK + 1)
  1345. #define ZOFFSET_MODE (ZOFFSET_HOME + 1)
  1346. #define ZOFFSET_OFFSET (ZOFFSET_MODE + 1)
  1347. #define ZOFFSET_UP (ZOFFSET_OFFSET + 1)
  1348. #define ZOFFSET_DOWN (ZOFFSET_UP + 1)
  1349. #define ZOFFSET_SAVE (ZOFFSET_DOWN + ENABLED(EEPROM_SETTINGS))
  1350. #define ZOFFSET_TOTAL ZOFFSET_SAVE
  1351. switch (item) {
  1352. case ZOFFSET_BACK:
  1353. if (draw)
  1354. Draw_Menu_Item(row, ICON_Back, "Back");
  1355. else {
  1356. liveadjust = false;
  1357. TERN_(HAS_LEVELING, set_bed_leveling_enabled(level_state));
  1358. Draw_Menu(Prepare, PREPARE_ZOFFSET);
  1359. }
  1360. break;
  1361. case ZOFFSET_HOME:
  1362. if (draw)
  1363. Draw_Menu_Item(row, ICON_Homing, "Home Z Axis");
  1364. else {
  1365. Popup_Handler(Home);
  1366. gcode.process_subcommands_now_P(PSTR("G28 Z"));
  1367. Popup_Handler(MoveWait);
  1368. #if ENABLED(Z_SAFE_HOMING)
  1369. planner.synchronize();
  1370. sprintf_P(cmd, PSTR("G0 F4000 X%s Y%s"), dtostrf(Z_SAFE_HOMING_X_POINT, 1, 3, str_1), dtostrf(Z_SAFE_HOMING_Y_POINT, 1, 3, str_2));
  1371. gcode.process_subcommands_now_P(cmd);
  1372. #else
  1373. gcode.process_subcommands_now_P(PSTR("G0 F4000 X117.5 Y117.5"));
  1374. #endif
  1375. gcode.process_subcommands_now_P(PSTR("G0 F300 Z0"));
  1376. planner.synchronize();
  1377. Redraw_Menu();
  1378. }
  1379. break;
  1380. case ZOFFSET_MODE:
  1381. if (draw) {
  1382. Draw_Menu_Item(row, ICON_Zoffset, "Live Adjustment");
  1383. Draw_Checkbox(row, liveadjust);
  1384. }
  1385. else {
  1386. if (!liveadjust) {
  1387. if (axes_should_home()) {
  1388. Popup_Handler(Home);
  1389. gcode.home_all_axes(true);
  1390. }
  1391. Popup_Handler(MoveWait);
  1392. #if ENABLED(Z_SAFE_HOMING)
  1393. planner.synchronize();
  1394. sprintf_P(cmd, PSTR("G0 F4000 X%s Y%s"), dtostrf(Z_SAFE_HOMING_X_POINT, 1, 3, str_1), dtostrf(Z_SAFE_HOMING_Y_POINT, 1, 3, str_2));
  1395. gcode.process_subcommands_now_P(cmd);
  1396. #else
  1397. gcode.process_subcommands_now_P(PSTR("G0 F4000 X117.5 Y117.5"));
  1398. #endif
  1399. gcode.process_subcommands_now_P(PSTR("G0 F300 Z0"));
  1400. planner.synchronize();
  1401. Redraw_Menu();
  1402. }
  1403. liveadjust = !liveadjust;
  1404. Draw_Checkbox(row, liveadjust);
  1405. }
  1406. break;
  1407. case ZOFFSET_OFFSET:
  1408. if (draw) {
  1409. Draw_Menu_Item(row, ICON_SetZOffset, "Z Offset");
  1410. Draw_Float(zoffsetvalue, row, false, 100);
  1411. }
  1412. else
  1413. Modify_Value(zoffsetvalue, MIN_Z_OFFSET, MAX_Z_OFFSET, 100);
  1414. break;
  1415. case ZOFFSET_UP:
  1416. if (draw)
  1417. Draw_Menu_Item(row, ICON_Axis, "Microstep Up");
  1418. else {
  1419. if (zoffsetvalue < MAX_Z_OFFSET) {
  1420. if (liveadjust) {
  1421. gcode.process_subcommands_now_P(PSTR("M290 Z0.01"));
  1422. planner.synchronize();
  1423. }
  1424. zoffsetvalue += 0.01;
  1425. Draw_Float(zoffsetvalue, row - 1, false, 100);
  1426. }
  1427. }
  1428. break;
  1429. case ZOFFSET_DOWN:
  1430. if (draw)
  1431. Draw_Menu_Item(row, ICON_AxisD, "Microstep Down");
  1432. else {
  1433. if (zoffsetvalue > MIN_Z_OFFSET) {
  1434. if (liveadjust) {
  1435. gcode.process_subcommands_now_P(PSTR("M290 Z-0.01"));
  1436. planner.synchronize();
  1437. }
  1438. zoffsetvalue -= 0.01;
  1439. Draw_Float(zoffsetvalue, row - 2, false, 100);
  1440. }
  1441. }
  1442. break;
  1443. #if ENABLED(EEPROM_SETTINGS)
  1444. case ZOFFSET_SAVE:
  1445. if (draw)
  1446. Draw_Menu_Item(row, ICON_WriteEEPROM, "Save");
  1447. else
  1448. AudioFeedback(settings.save());
  1449. break;
  1450. #endif
  1451. }
  1452. break;
  1453. #endif
  1454. #if HAS_PREHEAT
  1455. case Preheat:
  1456. #define PREHEAT_BACK 0
  1457. #define PREHEAT_MODE (PREHEAT_BACK + 1)
  1458. #define PREHEAT_1 (PREHEAT_MODE + (PREHEAT_COUNT >= 1))
  1459. #define PREHEAT_2 (PREHEAT_1 + (PREHEAT_COUNT >= 2))
  1460. #define PREHEAT_3 (PREHEAT_2 + (PREHEAT_COUNT >= 3))
  1461. #define PREHEAT_4 (PREHEAT_3 + (PREHEAT_COUNT >= 4))
  1462. #define PREHEAT_5 (PREHEAT_4 + (PREHEAT_COUNT >= 5))
  1463. #define PREHEAT_TOTAL PREHEAT_5
  1464. switch (item) {
  1465. case PREHEAT_BACK:
  1466. if (draw)
  1467. Draw_Menu_Item(row, ICON_Back, "Back");
  1468. else
  1469. Draw_Menu(Prepare, PREPARE_PREHEAT);
  1470. break;
  1471. case PREHEAT_MODE:
  1472. if (draw) {
  1473. Draw_Menu_Item(row, ICON_Homing, "Preheat Mode");
  1474. Draw_Option(preheatmode, preheat_modes, row);
  1475. }
  1476. else
  1477. Modify_Option(preheatmode, preheat_modes, 2);
  1478. break;
  1479. #if PREHEAT_COUNT >= 1
  1480. case PREHEAT_1:
  1481. if (draw)
  1482. Draw_Menu_Item(row, ICON_Temperature, PREHEAT_1_LABEL);
  1483. else {
  1484. thermalManager.disable_all_heaters();
  1485. TERN_(HAS_FAN, thermalManager.zero_fan_speeds());
  1486. if (preheatmode == 0 || preheatmode == 1) {
  1487. TERN_(HAS_HOTEND, thermalManager.setTargetHotend(ui.material_preset[0].hotend_temp, 0));
  1488. TERN_(HAS_FAN, thermalManager.set_fan_speed(0, ui.material_preset[0].fan_speed));
  1489. }
  1490. #if HAS_HEATED_BED
  1491. if (preheatmode == 0 || preheatmode == 2) thermalManager.setTargetBed(ui.material_preset[0].bed_temp);
  1492. #endif
  1493. }
  1494. break;
  1495. #endif
  1496. #if PREHEAT_COUNT >= 2
  1497. case PREHEAT_2:
  1498. if (draw)
  1499. Draw_Menu_Item(row, ICON_Temperature, PREHEAT_2_LABEL);
  1500. else {
  1501. thermalManager.disable_all_heaters();
  1502. TERN_(HAS_FAN, thermalManager.zero_fan_speeds());
  1503. if (preheatmode == 0 || preheatmode == 1) {
  1504. TERN_(HAS_HOTEND, thermalManager.setTargetHotend(ui.material_preset[1].hotend_temp, 0));
  1505. TERN_(HAS_FAN, thermalManager.set_fan_speed(0, ui.material_preset[1].fan_speed));
  1506. }
  1507. #if HAS_HEATED_BED
  1508. if (preheatmode == 0 || preheatmode == 2) thermalManager.setTargetBed(ui.material_preset[1].bed_temp);
  1509. #endif
  1510. }
  1511. break;
  1512. #endif
  1513. #if PREHEAT_COUNT >= 3
  1514. case PREHEAT_3:
  1515. if (draw)
  1516. Draw_Menu_Item(row, ICON_Temperature, PREHEAT_3_LABEL);
  1517. else {
  1518. thermalManager.disable_all_heaters();
  1519. TERN_(HAS_FAN, thermalManager.zero_fan_speeds());
  1520. if (preheatmode == 0 || preheatmode == 1) {
  1521. TERN_(HAS_HOTEND, thermalManager.setTargetHotend(ui.material_preset[2].hotend_temp, 0));
  1522. TERN_(HAS_FAN, thermalManager.set_fan_speed(0, ui.material_preset[2].fan_speed));
  1523. }
  1524. #if HAS_HEATED_BED
  1525. if (preheatmode == 0 || preheatmode == 2) thermalManager.setTargetBed(ui.material_preset[2].bed_temp);
  1526. #endif
  1527. }
  1528. break;
  1529. #endif
  1530. #if PREHEAT_COUNT >= 4
  1531. case PREHEAT_4:
  1532. if (draw)
  1533. Draw_Menu_Item(row, ICON_Temperature, PREHEAT_4_LABEL);
  1534. else {
  1535. thermalManager.disable_all_heaters();
  1536. TERN_(HAS_FAN, thermalManager.zero_fan_speeds());
  1537. if (preheatmode == 0 || preheatmode == 1) {
  1538. TERN_(HAS_HOTEND, thermalManager.setTargetHotend(ui.material_preset[3].hotend_temp, 0));
  1539. TERN_(HAS_FAN, thermalManager.set_fan_speed(0, ui.material_preset[3].fan_speed));
  1540. }
  1541. #if HAS_HEATED_BED
  1542. if (preheatmode == 0 || preheatmode == 2) thermalManager.setTargetBed(ui.material_preset[3].bed_temp);
  1543. #endif
  1544. }
  1545. break;
  1546. #endif
  1547. #if PREHEAT_COUNT >= 5
  1548. case PREHEAT_5:
  1549. if (draw)
  1550. Draw_Menu_Item(row, ICON_Temperature, PREHEAT_5_LABEL);
  1551. else {
  1552. thermalManager.disable_all_heaters();
  1553. TERN_(HAS_FAN, thermalManager.zero_fan_speeds());
  1554. if (preheatmode == 0 || preheatmode == 1) {
  1555. TERN_(HAS_HOTEND, thermalManager.setTargetHotend(ui.material_preset[4].hotend_temp, 0));
  1556. TERN_(HAS_FAN, thermalManager.set_fan_speed(0, ui.material_preset[4].fan_speed));
  1557. }
  1558. #if HAS_HEATED_BED
  1559. if (preheatmode == 0 || preheatmode == 2) thermalManager.setTargetBed(ui.material_preset[4].bed_temp);
  1560. #endif
  1561. }
  1562. break;
  1563. #endif
  1564. }
  1565. break;
  1566. #endif
  1567. #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
  1568. case ChangeFilament:
  1569. #define CHANGEFIL_BACK 0
  1570. #define CHANGEFIL_LOAD (CHANGEFIL_BACK + 1)
  1571. #define CHANGEFIL_UNLOAD (CHANGEFIL_LOAD + 1)
  1572. #define CHANGEFIL_CHANGE (CHANGEFIL_UNLOAD + 1)
  1573. #define CHANGEFIL_TOTAL CHANGEFIL_CHANGE
  1574. switch (item) {
  1575. case CHANGEFIL_BACK:
  1576. if (draw)
  1577. Draw_Menu_Item(row, ICON_Back, "Back");
  1578. else
  1579. Draw_Menu(Prepare, PREPARE_CHANGEFIL);
  1580. break;
  1581. case CHANGEFIL_LOAD:
  1582. if (draw)
  1583. Draw_Menu_Item(row, ICON_WriteEEPROM, "Load Filament");
  1584. else {
  1585. if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp)
  1586. Popup_Handler(ETemp);
  1587. else {
  1588. if (thermalManager.temp_hotend[0].celsius < thermalManager.temp_hotend[0].target - 2) {
  1589. Popup_Handler(Heating);
  1590. thermalManager.wait_for_hotend(0);
  1591. }
  1592. Popup_Handler(FilLoad);
  1593. gcode.process_subcommands_now_P(PSTR("M701"));
  1594. planner.synchronize();
  1595. Redraw_Menu();
  1596. }
  1597. }
  1598. break;
  1599. case CHANGEFIL_UNLOAD:
  1600. if (draw)
  1601. Draw_Menu_Item(row, ICON_ReadEEPROM, "Unload Filament");
  1602. else {
  1603. if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) {
  1604. Popup_Handler(ETemp);
  1605. }
  1606. else {
  1607. if (thermalManager.temp_hotend[0].celsius < thermalManager.temp_hotend[0].target - 2) {
  1608. Popup_Handler(Heating);
  1609. thermalManager.wait_for_hotend(0);
  1610. }
  1611. Popup_Handler(FilLoad, true);
  1612. gcode.process_subcommands_now_P(PSTR("M702"));
  1613. planner.synchronize();
  1614. Redraw_Menu();
  1615. }
  1616. }
  1617. break;
  1618. case CHANGEFIL_CHANGE:
  1619. if (draw)
  1620. Draw_Menu_Item(row, ICON_ResumeEEPROM, "Change Filament");
  1621. else {
  1622. if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp)
  1623. Popup_Handler(ETemp);
  1624. else {
  1625. if (thermalManager.temp_hotend[0].celsius < thermalManager.temp_hotend[0].target - 2) {
  1626. Popup_Handler(Heating);
  1627. thermalManager.wait_for_hotend(0);
  1628. }
  1629. Popup_Handler(FilChange);
  1630. sprintf_P(cmd, PSTR("M600 B1 R%i"), thermalManager.temp_hotend[0].target);
  1631. gcode.process_subcommands_now_P(cmd);
  1632. }
  1633. }
  1634. break;
  1635. }
  1636. break;
  1637. #endif // FILAMENT_LOAD_UNLOAD_GCODES
  1638. case Control:
  1639. #define CONTROL_BACK 0
  1640. #define CONTROL_TEMP (CONTROL_BACK + 1)
  1641. #define CONTROL_MOTION (CONTROL_TEMP + 1)
  1642. #define CONTROL_VISUAL (CONTROL_MOTION + 1)
  1643. #define CONTROL_ADVANCED (CONTROL_VISUAL + 1)
  1644. #define CONTROL_SAVE (CONTROL_ADVANCED + ENABLED(EEPROM_SETTINGS))
  1645. #define CONTROL_RESTORE (CONTROL_SAVE + ENABLED(EEPROM_SETTINGS))
  1646. #define CONTROL_RESET (CONTROL_RESTORE + ENABLED(EEPROM_SETTINGS))
  1647. #define CONTROL_INFO (CONTROL_RESET + 1)
  1648. #define CONTROL_TOTAL CONTROL_INFO
  1649. switch (item) {
  1650. case CONTROL_BACK:
  1651. if (draw)
  1652. Draw_Menu_Item(row, ICON_Back, "Back");
  1653. else
  1654. Draw_Main_Menu(2);
  1655. break;
  1656. case CONTROL_TEMP:
  1657. if (draw)
  1658. Draw_Menu_Item(row, ICON_Temperature, "Temperature", nullptr, true);
  1659. else
  1660. Draw_Menu(TempMenu);
  1661. break;
  1662. case CONTROL_MOTION:
  1663. if (draw)
  1664. Draw_Menu_Item(row, ICON_Motion, "Motion", nullptr, true);
  1665. else
  1666. Draw_Menu(Motion);
  1667. break;
  1668. case CONTROL_VISUAL:
  1669. if (draw)
  1670. Draw_Menu_Item(row, ICON_PrintSize, "Visual", nullptr, true);
  1671. else
  1672. Draw_Menu(Visual);
  1673. break;
  1674. case CONTROL_ADVANCED:
  1675. if (draw)
  1676. Draw_Menu_Item(row, ICON_Version, "Advanced", nullptr, true);
  1677. else
  1678. Draw_Menu(Advanced);
  1679. break;
  1680. #if ENABLED(EEPROM_SETTINGS)
  1681. case CONTROL_SAVE:
  1682. if (draw)
  1683. Draw_Menu_Item(row, ICON_WriteEEPROM, "Store Settings");
  1684. else
  1685. AudioFeedback(settings.save());
  1686. break;
  1687. case CONTROL_RESTORE:
  1688. if (draw)
  1689. Draw_Menu_Item(row, ICON_ReadEEPROM, "Restore Settings");
  1690. else
  1691. AudioFeedback(settings.load());
  1692. break;
  1693. case CONTROL_RESET:
  1694. if (draw)
  1695. Draw_Menu_Item(row, ICON_Temperature, "Reset to Defaults");
  1696. else {
  1697. settings.reset();
  1698. AudioFeedback();
  1699. }
  1700. break;
  1701. #endif
  1702. case CONTROL_INFO:
  1703. if (draw)
  1704. Draw_Menu_Item(row, ICON_Info, "Info");
  1705. else
  1706. Draw_Menu(Info);
  1707. break;
  1708. }
  1709. break;
  1710. case TempMenu:
  1711. #define TEMP_BACK 0
  1712. #define TEMP_HOTEND (TEMP_BACK + ENABLED(HAS_HOTEND))
  1713. #define TEMP_BED (TEMP_HOTEND + ENABLED(HAS_HEATED_BED))
  1714. #define TEMP_FAN (TEMP_BED + ENABLED(HAS_FAN))
  1715. #define TEMP_PID (TEMP_FAN + ANY(HAS_HOTEND, HAS_HEATED_BED))
  1716. #define TEMP_PREHEAT1 (TEMP_PID + (PREHEAT_COUNT >= 1))
  1717. #define TEMP_PREHEAT2 (TEMP_PREHEAT1 + (PREHEAT_COUNT >= 2))
  1718. #define TEMP_PREHEAT3 (TEMP_PREHEAT2 + (PREHEAT_COUNT >= 3))
  1719. #define TEMP_PREHEAT4 (TEMP_PREHEAT3 + (PREHEAT_COUNT >= 4))
  1720. #define TEMP_PREHEAT5 (TEMP_PREHEAT4 + (PREHEAT_COUNT >= 5))
  1721. #define TEMP_TOTAL TEMP_PREHEAT5
  1722. switch (item) {
  1723. case TEMP_BACK:
  1724. if (draw)
  1725. Draw_Menu_Item(row, ICON_Back, "Back");
  1726. else
  1727. Draw_Menu(Control, CONTROL_TEMP);
  1728. break;
  1729. #if HAS_HOTEND
  1730. case TEMP_HOTEND:
  1731. if (draw) {
  1732. Draw_Menu_Item(row, ICON_SetEndTemp, "Hotend");
  1733. Draw_Float(thermalManager.temp_hotend[0].target, row, false, 1);
  1734. }
  1735. else
  1736. Modify_Value(thermalManager.temp_hotend[0].target, MIN_E_TEMP, MAX_E_TEMP, 1);
  1737. break;
  1738. #endif
  1739. #if HAS_HEATED_BED
  1740. case TEMP_BED:
  1741. if (draw) {
  1742. Draw_Menu_Item(row, ICON_SetBedTemp, "Bed");
  1743. Draw_Float(thermalManager.temp_bed.target, row, false, 1);
  1744. }
  1745. else
  1746. Modify_Value(thermalManager.temp_bed.target, MIN_BED_TEMP, MAX_BED_TEMP, 1);
  1747. break;
  1748. #endif
  1749. #if HAS_FAN
  1750. case TEMP_FAN:
  1751. if (draw) {
  1752. Draw_Menu_Item(row, ICON_FanSpeed, "Fan");
  1753. Draw_Float(thermalManager.fan_speed[0], row, false, 1);
  1754. }
  1755. else
  1756. Modify_Value(thermalManager.fan_speed[0], MIN_FAN_SPEED, MAX_FAN_SPEED, 1);
  1757. break;
  1758. #endif
  1759. #if HAS_HOTEND || HAS_HEATED_BED
  1760. case TEMP_PID:
  1761. if (draw)
  1762. Draw_Menu_Item(row, ICON_Step, "PID", nullptr, true);
  1763. else
  1764. Draw_Menu(PID);
  1765. break;
  1766. #endif
  1767. #if PREHEAT_COUNT >= 1
  1768. case TEMP_PREHEAT1:
  1769. if (draw)
  1770. Draw_Menu_Item(row, ICON_Step, PREHEAT_1_LABEL, nullptr, true);
  1771. else
  1772. Draw_Menu(Preheat1);
  1773. break;
  1774. #endif
  1775. #if PREHEAT_COUNT >= 2
  1776. case TEMP_PREHEAT2:
  1777. if (draw)
  1778. Draw_Menu_Item(row, ICON_Step, PREHEAT_2_LABEL, nullptr, true);
  1779. else
  1780. Draw_Menu(Preheat2);
  1781. break;
  1782. #endif
  1783. #if PREHEAT_COUNT >= 3
  1784. case TEMP_PREHEAT3:
  1785. if (draw)
  1786. Draw_Menu_Item(row, ICON_Step, PREHEAT_3_LABEL, nullptr, true);
  1787. else
  1788. Draw_Menu(Preheat3);
  1789. break;
  1790. #endif
  1791. #if PREHEAT_COUNT >= 4
  1792. case TEMP_PREHEAT4:
  1793. if (draw)
  1794. Draw_Menu_Item(row, ICON_Step, PREHEAT_4_LABEL, nullptr, true);
  1795. else
  1796. Draw_Menu(Preheat4);
  1797. break;
  1798. #endif
  1799. #if PREHEAT_COUNT >= 5
  1800. case TEMP_PREHEAT5:
  1801. if (draw)
  1802. Draw_Menu_Item(row, ICON_Step, PREHEAT_5_LABEL, nullptr, true);
  1803. else
  1804. Draw_Menu(Preheat5);
  1805. break;
  1806. #endif
  1807. }
  1808. break;
  1809. #if HAS_HOTEND || HAS_HEATED_BED
  1810. case PID:
  1811. #define PID_BACK 0
  1812. #define PID_HOTEND (PID_BACK + ENABLED(HAS_HOTEND))
  1813. #define PID_BED (PID_HOTEND + ENABLED(HAS_HEATED_BED))
  1814. #define PID_CYCLES (PID_BED + 1)
  1815. #define PID_TOTAL PID_CYCLES
  1816. static uint8_t PID_cycles = 5;
  1817. switch (item) {
  1818. case PID_BACK:
  1819. if (draw)
  1820. Draw_Menu_Item(row, ICON_Back, "Back");
  1821. else
  1822. Draw_Menu(TempMenu, TEMP_PID);
  1823. break;
  1824. #if HAS_HOTEND
  1825. case PID_HOTEND:
  1826. if (draw)
  1827. Draw_Menu_Item(row, ICON_HotendTemp, "Hotend", nullptr, true);
  1828. else
  1829. Draw_Menu(HotendPID);
  1830. break;
  1831. #endif
  1832. #if HAS_HEATED_BED
  1833. case PID_BED:
  1834. if (draw)
  1835. Draw_Menu_Item(row, ICON_BedTemp, "Bed", nullptr, true);
  1836. else
  1837. Draw_Menu(BedPID);
  1838. break;
  1839. #endif
  1840. case PID_CYCLES:
  1841. if (draw) {
  1842. Draw_Menu_Item(row, ICON_FanSpeed, "Cycles");
  1843. Draw_Float(PID_cycles, row, false, 1);
  1844. }
  1845. else
  1846. Modify_Value(PID_cycles, 3, 50, 1);
  1847. break;
  1848. }
  1849. break;
  1850. #endif // HAS_HOTEND || HAS_HEATED_BED
  1851. #if HAS_HOTEND
  1852. case HotendPID:
  1853. #define HOTENDPID_BACK 0
  1854. #define HOTENDPID_TUNE (HOTENDPID_BACK + 1)
  1855. #define HOTENDPID_TEMP (HOTENDPID_TUNE + 1)
  1856. #define HOTENDPID_KP (HOTENDPID_TEMP + 1)
  1857. #define HOTENDPID_KI (HOTENDPID_KP + 1)
  1858. #define HOTENDPID_KD (HOTENDPID_KI + 1)
  1859. #define HOTENDPID_TOTAL HOTENDPID_KD
  1860. static uint16_t PID_e_temp = 180;
  1861. switch (item) {
  1862. case HOTENDPID_BACK:
  1863. if (draw)
  1864. Draw_Menu_Item(row, ICON_Back, "Back");
  1865. else
  1866. Draw_Menu(PID, PID_HOTEND);
  1867. break;
  1868. case HOTENDPID_TUNE:
  1869. if (draw)
  1870. Draw_Menu_Item(row, ICON_HotendTemp, "Autotune");
  1871. else {
  1872. Popup_Handler(PIDWait);
  1873. sprintf_P(cmd, PSTR("M303 E0 C%i S%i U1"), PID_cycles, PID_e_temp);
  1874. gcode.process_subcommands_now_P(cmd);
  1875. planner.synchronize();
  1876. Redraw_Menu();
  1877. }
  1878. break;
  1879. case HOTENDPID_TEMP:
  1880. if (draw) {
  1881. Draw_Menu_Item(row, ICON_Temperature, "Temperature");
  1882. Draw_Float(PID_e_temp, row, false, 1);
  1883. }
  1884. else
  1885. Modify_Value(PID_e_temp, MIN_E_TEMP, MAX_E_TEMP, 1);
  1886. break;
  1887. case HOTENDPID_KP:
  1888. if (draw) {
  1889. Draw_Menu_Item(row, ICON_Version, "Kp Value");
  1890. Draw_Float(thermalManager.temp_hotend[0].pid.Kp, row, false, 100);
  1891. }
  1892. else
  1893. Modify_Value(thermalManager.temp_hotend[0].pid.Kp, 0, 5000, 100, thermalManager.updatePID);
  1894. break;
  1895. case HOTENDPID_KI:
  1896. if (draw) {
  1897. Draw_Menu_Item(row, ICON_Version, "Ki Value");
  1898. Draw_Float(unscalePID_i(thermalManager.temp_hotend[0].pid.Ki), row, false, 100);
  1899. }
  1900. else
  1901. Modify_Value(thermalManager.temp_hotend[0].pid.Ki, 0, 5000, 100, thermalManager.updatePID);
  1902. break;
  1903. case HOTENDPID_KD:
  1904. if (draw) {
  1905. Draw_Menu_Item(row, ICON_Version, "Kd Value");
  1906. Draw_Float(unscalePID_d(thermalManager.temp_hotend[0].pid.Kd), row, false, 100);
  1907. }
  1908. else
  1909. Modify_Value(thermalManager.temp_hotend[0].pid.Kd, 0, 5000, 100, thermalManager.updatePID);
  1910. break;
  1911. }
  1912. break;
  1913. #endif // HAS_HOTEND
  1914. #if HAS_HEATED_BED
  1915. case BedPID:
  1916. #define BEDPID_BACK 0
  1917. #define BEDPID_TUNE (BEDPID_BACK + 1)
  1918. #define BEDPID_TEMP (BEDPID_TUNE + 1)
  1919. #define BEDPID_KP (BEDPID_TEMP + 1)
  1920. #define BEDPID_KI (BEDPID_KP + 1)
  1921. #define BEDPID_KD (BEDPID_KI + 1)
  1922. #define BEDPID_TOTAL BEDPID_KD
  1923. static uint16_t PID_bed_temp = 60;
  1924. switch (item) {
  1925. case BEDPID_BACK:
  1926. if (draw)
  1927. Draw_Menu_Item(row, ICON_Back, "Back");
  1928. else
  1929. Draw_Menu(PID, PID_BED);
  1930. break;
  1931. case BEDPID_TUNE:
  1932. if (draw)
  1933. Draw_Menu_Item(row, ICON_HotendTemp, "Autotune");
  1934. else {
  1935. Popup_Handler(PIDWait);
  1936. sprintf_P(cmd, PSTR("M303 E-1 C%i S%i U1"), PID_cycles, PID_bed_temp);
  1937. gcode.process_subcommands_now_P(cmd);
  1938. planner.synchronize();
  1939. Redraw_Menu();
  1940. }
  1941. break;
  1942. case BEDPID_TEMP:
  1943. if (draw) {
  1944. Draw_Menu_Item(row, ICON_Temperature, "Temperature");
  1945. Draw_Float(PID_bed_temp, row, false, 1);
  1946. }
  1947. else
  1948. Modify_Value(PID_bed_temp, MIN_BED_TEMP, MAX_BED_TEMP, 1);
  1949. break;
  1950. case BEDPID_KP:
  1951. if (draw) {
  1952. Draw_Menu_Item(row, ICON_Version, "Kp Value");
  1953. Draw_Float(thermalManager.temp_bed.pid.Kp, row, false, 100);
  1954. }
  1955. else {
  1956. Modify_Value(thermalManager.temp_bed.pid.Kp, 0, 5000, 100, thermalManager.updatePID);
  1957. }
  1958. break;
  1959. case BEDPID_KI:
  1960. if (draw) {
  1961. Draw_Menu_Item(row, ICON_Version, "Ki Value");
  1962. Draw_Float(unscalePID_i(thermalManager.temp_bed.pid.Ki), row, false, 100);
  1963. }
  1964. else
  1965. Modify_Value(thermalManager.temp_bed.pid.Ki, 0, 5000, 100, thermalManager.updatePID);
  1966. break;
  1967. case BEDPID_KD:
  1968. if (draw) {
  1969. Draw_Menu_Item(row, ICON_Version, "Kd Value");
  1970. Draw_Float(unscalePID_d(thermalManager.temp_bed.pid.Kd), row, false, 100);
  1971. }
  1972. else
  1973. Modify_Value(thermalManager.temp_bed.pid.Kd, 0, 5000, 100, thermalManager.updatePID);
  1974. break;
  1975. }
  1976. break;
  1977. #endif // HAS_HEATED_BED
  1978. #if PREHEAT_COUNT >= 1
  1979. case Preheat1:
  1980. #define PREHEAT1_BACK 0
  1981. #define PREHEAT1_HOTEND (PREHEAT1_BACK + ENABLED(HAS_HOTEND))
  1982. #define PREHEAT1_BED (PREHEAT1_HOTEND + ENABLED(HAS_HEATED_BED))
  1983. #define PREHEAT1_FAN (PREHEAT1_BED + ENABLED(HAS_FAN))
  1984. #define PREHEAT1_TOTAL PREHEAT1_FAN
  1985. switch (item) {
  1986. case PREHEAT1_BACK:
  1987. if (draw)
  1988. Draw_Menu_Item(row, ICON_Back, "Back");
  1989. else
  1990. Draw_Menu(TempMenu, TEMP_PREHEAT1);
  1991. break;
  1992. #if HAS_HOTEND
  1993. case PREHEAT1_HOTEND:
  1994. if (draw) {
  1995. Draw_Menu_Item(row, ICON_SetEndTemp, "Hotend");
  1996. Draw_Float(ui.material_preset[0].hotend_temp, row, false, 1);
  1997. }
  1998. else
  1999. Modify_Value(ui.material_preset[0].hotend_temp, MIN_E_TEMP, MAX_E_TEMP, 1);
  2000. break;
  2001. #endif
  2002. #if HAS_HEATED_BED
  2003. case PREHEAT1_BED:
  2004. if (draw) {
  2005. Draw_Menu_Item(row, ICON_SetBedTemp, "Bed");
  2006. Draw_Float(ui.material_preset[0].bed_temp, row, false, 1);
  2007. }
  2008. else
  2009. Modify_Value(ui.material_preset[0].bed_temp, MIN_BED_TEMP, MAX_BED_TEMP, 1);
  2010. break;
  2011. #endif
  2012. #if HAS_FAN
  2013. case PREHEAT1_FAN:
  2014. if (draw) {
  2015. Draw_Menu_Item(row, ICON_FanSpeed, "Fan");
  2016. Draw_Float(ui.material_preset[0].fan_speed, row, false, 1);
  2017. }
  2018. else
  2019. Modify_Value(ui.material_preset[0].fan_speed, MIN_FAN_SPEED, MAX_FAN_SPEED, 1);
  2020. break;
  2021. #endif
  2022. }
  2023. break;
  2024. #endif // PREHEAT_COUNT >= 1
  2025. #if PREHEAT_COUNT >= 2
  2026. case Preheat2:
  2027. #define PREHEAT2_BACK 0
  2028. #define PREHEAT2_HOTEND (PREHEAT2_BACK + ENABLED(HAS_HOTEND))
  2029. #define PREHEAT2_BED (PREHEAT2_HOTEND + ENABLED(HAS_HEATED_BED))
  2030. #define PREHEAT2_FAN (PREHEAT2_BED + ENABLED(HAS_FAN))
  2031. #define PREHEAT2_TOTAL PREHEAT2_FAN
  2032. switch (item) {
  2033. case PREHEAT2_BACK:
  2034. if (draw)
  2035. Draw_Menu_Item(row, ICON_Back, "Back");
  2036. else
  2037. Draw_Menu(TempMenu, TEMP_PREHEAT2);
  2038. break;
  2039. #if HAS_HOTEND
  2040. case PREHEAT2_HOTEND:
  2041. if (draw) {
  2042. Draw_Menu_Item(row, ICON_SetEndTemp, "Hotend");
  2043. Draw_Float(ui.material_preset[1].hotend_temp, row, false, 1);
  2044. }
  2045. else
  2046. Modify_Value(ui.material_preset[1].hotend_temp, MIN_E_TEMP, MAX_E_TEMP, 1);
  2047. break;
  2048. #endif
  2049. #if HAS_HEATED_BED
  2050. case PREHEAT2_BED:
  2051. if (draw) {
  2052. Draw_Menu_Item(row, ICON_SetBedTemp, "Bed");
  2053. Draw_Float(ui.material_preset[1].bed_temp, row, false, 1);
  2054. }
  2055. else
  2056. Modify_Value(ui.material_preset[1].bed_temp, MIN_BED_TEMP, MAX_BED_TEMP, 1);
  2057. break;
  2058. #endif
  2059. #if HAS_FAN
  2060. case PREHEAT2_FAN:
  2061. if (draw) {
  2062. Draw_Menu_Item(row, ICON_FanSpeed, "Fan");
  2063. Draw_Float(ui.material_preset[1].fan_speed, row, false, 1);
  2064. }
  2065. else
  2066. Modify_Value(ui.material_preset[1].fan_speed, MIN_FAN_SPEED, MAX_FAN_SPEED, 1);
  2067. break;
  2068. #endif
  2069. }
  2070. break;
  2071. #endif // PREHEAT_COUNT >= 2
  2072. #if PREHEAT_COUNT >= 3
  2073. case Preheat3:
  2074. #define PREHEAT3_BACK 0
  2075. #define PREHEAT3_HOTEND (PREHEAT3_BACK + ENABLED(HAS_HOTEND))
  2076. #define PREHEAT3_BED (PREHEAT3_HOTEND + ENABLED(HAS_HEATED_BED))
  2077. #define PREHEAT3_FAN (PREHEAT3_BED + ENABLED(HAS_FAN))
  2078. #define PREHEAT3_TOTAL PREHEAT3_FAN
  2079. switch (item) {
  2080. case PREHEAT3_BACK:
  2081. if (draw)
  2082. Draw_Menu_Item(row, ICON_Back, "Back");
  2083. else
  2084. Draw_Menu(TempMenu, TEMP_PREHEAT3);
  2085. break;
  2086. #if HAS_HOTEND
  2087. case PREHEAT3_HOTEND:
  2088. if (draw) {
  2089. Draw_Menu_Item(row, ICON_SetEndTemp, "Hotend");
  2090. Draw_Float(ui.material_preset[2].hotend_temp, row, false, 1);
  2091. }
  2092. else
  2093. Modify_Value(ui.material_preset[2].hotend_temp, MIN_E_TEMP, MAX_E_TEMP, 1);
  2094. break;
  2095. #endif
  2096. #if HAS_HEATED_BED
  2097. case PREHEAT3_BED:
  2098. if (draw) {
  2099. Draw_Menu_Item(row, ICON_SetBedTemp, "Bed");
  2100. Draw_Float(ui.material_preset[2].bed_temp, row, false, 1);
  2101. }
  2102. else
  2103. Modify_Value(ui.material_preset[2].bed_temp, MIN_BED_TEMP, MAX_BED_TEMP, 1);
  2104. break;
  2105. #endif
  2106. #if HAS_FAN
  2107. case PREHEAT3_FAN:
  2108. if (draw) {
  2109. Draw_Menu_Item(row, ICON_FanSpeed, "Fan");
  2110. Draw_Float(ui.material_preset[2].fan_speed, row, false, 1);
  2111. }
  2112. else
  2113. Modify_Value(ui.material_preset[2].fan_speed, MIN_FAN_SPEED, MAX_FAN_SPEED, 1);
  2114. break;
  2115. #endif
  2116. }
  2117. break;
  2118. #endif // PREHEAT_COUNT >= 3
  2119. #if PREHEAT_COUNT >= 4
  2120. case Preheat4:
  2121. #define PREHEAT4_BACK 0
  2122. #define PREHEAT4_HOTEND (PREHEAT4_BACK + ENABLED(HAS_HOTEND))
  2123. #define PREHEAT4_BED (PREHEAT4_HOTEND + ENABLED(HAS_HEATED_BED))
  2124. #define PREHEAT4_FAN (PREHEAT4_BED + ENABLED(HAS_FAN))
  2125. #define PREHEAT4_TOTAL PREHEAT4_FAN
  2126. switch (item) {
  2127. case PREHEAT4_BACK:
  2128. if (draw)
  2129. Draw_Menu_Item(row, ICON_Back, "Back");
  2130. else
  2131. Draw_Menu(TempMenu, TEMP_PREHEAT4);
  2132. break;
  2133. #if HAS_HOTEND
  2134. case PREHEAT4_HOTEND:
  2135. if (draw) {
  2136. Draw_Menu_Item(row, ICON_SetEndTemp, "Hotend");
  2137. Draw_Float(ui.material_preset[3].hotend_temp, row, false, 1);
  2138. }
  2139. else
  2140. Modify_Value(ui.material_preset[3].hotend_temp, MIN_E_TEMP, MAX_E_TEMP, 1);
  2141. break;
  2142. #endif
  2143. #if HAS_HEATED_BED
  2144. case PREHEAT4_BED:
  2145. if (draw) {
  2146. Draw_Menu_Item(row, ICON_SetBedTemp, "Bed");
  2147. Draw_Float(ui.material_preset[3].bed_temp, row, false, 1);
  2148. }
  2149. else
  2150. Modify_Value(ui.material_preset[3].bed_temp, MIN_BED_TEMP, MAX_BED_TEMP, 1);
  2151. break;
  2152. #endif
  2153. #if HAS_FAN
  2154. case PREHEAT4_FAN:
  2155. if (draw) {
  2156. Draw_Menu_Item(row, ICON_FanSpeed, "Fan");
  2157. Draw_Float(ui.material_preset[3].fan_speed, row, false, 1);
  2158. }
  2159. else
  2160. Modify_Value(ui.material_preset[3].fan_speed, MIN_FAN_SPEED, MAX_FAN_SPEED, 1);
  2161. break;
  2162. #endif
  2163. }
  2164. break;
  2165. #endif // PREHEAT_COUNT >= 4
  2166. #if PREHEAT_COUNT >= 5
  2167. case Preheat5:
  2168. #define PREHEAT5_BACK 0
  2169. #define PREHEAT5_HOTEND (PREHEAT5_BACK + ENABLED(HAS_HOTEND))
  2170. #define PREHEAT5_BED (PREHEAT5_HOTEND + ENABLED(HAS_HEATED_BED))
  2171. #define PREHEAT5_FAN (PREHEAT5_BED + ENABLED(HAS_FAN))
  2172. #define PREHEAT5_TOTAL PREHEAT5_FAN
  2173. switch (item) {
  2174. case PREHEAT5_BACK:
  2175. if (draw)
  2176. Draw_Menu_Item(row, ICON_Back, "Back");
  2177. else
  2178. Draw_Menu(TempMenu, TEMP_PREHEAT5);
  2179. break;
  2180. #if HAS_HOTEND
  2181. case PREHEAT5_HOTEND:
  2182. if (draw) {
  2183. Draw_Menu_Item(row, ICON_SetEndTemp, "Hotend");
  2184. Draw_Float(ui.material_preset[4].hotend_temp, row, false, 1);
  2185. }
  2186. else
  2187. Modify_Value(ui.material_preset[4].hotend_temp, MIN_E_TEMP, MAX_E_TEMP, 1);
  2188. break;
  2189. #endif
  2190. #if HAS_HEATED_BED
  2191. case PREHEAT5_BED:
  2192. if (draw) {
  2193. Draw_Menu_Item(row, ICON_SetBedTemp, "Bed");
  2194. Draw_Float(ui.material_preset[4].bed_temp, row, false, 1);
  2195. }
  2196. else
  2197. Modify_Value(ui.material_preset[4].bed_temp, MIN_BED_TEMP, MAX_BED_TEMP, 1);
  2198. break;
  2199. #endif
  2200. #if HAS_FAN
  2201. case PREHEAT5_FAN:
  2202. if (draw) {
  2203. Draw_Menu_Item(row, ICON_FanSpeed, "Fan");
  2204. Draw_Float(ui.material_preset[4].fan_speed, row, false, 1);
  2205. }
  2206. else
  2207. Modify_Value(ui.material_preset[4].fan_speed, MIN_FAN_SPEED, MAX_FAN_SPEED, 1);
  2208. break;
  2209. #endif
  2210. }
  2211. break;
  2212. #endif // PREHEAT_COUNT >= 5
  2213. case Motion:
  2214. #define MOTION_BACK 0
  2215. #define MOTION_HOMEOFFSETS (MOTION_BACK + 1)
  2216. #define MOTION_SPEED (MOTION_HOMEOFFSETS + 1)
  2217. #define MOTION_ACCEL (MOTION_SPEED + 1)
  2218. #define MOTION_JERK (MOTION_ACCEL + ENABLED(HAS_CLASSIC_JERK))
  2219. #define MOTION_STEPS (MOTION_JERK + 1)
  2220. #define MOTION_FLOW (MOTION_STEPS + ENABLED(HAS_HOTEND))
  2221. #define MOTION_TOTAL MOTION_FLOW
  2222. switch (item) {
  2223. case MOTION_BACK:
  2224. if (draw)
  2225. Draw_Menu_Item(row, ICON_Back, "Back");
  2226. else
  2227. Draw_Menu(Control, CONTROL_MOTION);
  2228. break;
  2229. case MOTION_HOMEOFFSETS:
  2230. if (draw)
  2231. Draw_Menu_Item(row, ICON_SetHome, "Home Offsets", nullptr, true);
  2232. else
  2233. Draw_Menu(HomeOffsets);
  2234. break;
  2235. case MOTION_SPEED:
  2236. if (draw)
  2237. Draw_Menu_Item(row, ICON_MaxSpeed, "Max Speed", nullptr, true);
  2238. else
  2239. Draw_Menu(MaxSpeed);
  2240. break;
  2241. case MOTION_ACCEL:
  2242. if (draw)
  2243. Draw_Menu_Item(row, ICON_MaxAccelerated, "Max Acceleration", nullptr, true);
  2244. else
  2245. Draw_Menu(MaxAcceleration);
  2246. break;
  2247. #if HAS_CLASSIC_JERK
  2248. case MOTION_JERK:
  2249. if (draw)
  2250. Draw_Menu_Item(row, ICON_MaxJerk, "Max Jerk", nullptr, true);
  2251. else
  2252. Draw_Menu(MaxJerk);
  2253. break;
  2254. #endif
  2255. case MOTION_STEPS:
  2256. if (draw)
  2257. Draw_Menu_Item(row, ICON_Step, "Steps/mm", nullptr, true);
  2258. else
  2259. Draw_Menu(Steps);
  2260. break;
  2261. #if HAS_HOTEND
  2262. case MOTION_FLOW:
  2263. if (draw) {
  2264. Draw_Menu_Item(row, ICON_Speed, "Flow Rate");
  2265. Draw_Float(planner.flow_percentage[0], row, false, 1);
  2266. }
  2267. else
  2268. Modify_Value(planner.flow_percentage[0], MIN_FLOW_RATE, MAX_FLOW_RATE, 1);
  2269. break;
  2270. #endif
  2271. }
  2272. break;
  2273. case HomeOffsets:
  2274. #define HOMEOFFSETS_BACK 0
  2275. #define HOMEOFFSETS_XOFFSET (HOMEOFFSETS_BACK + 1)
  2276. #define HOMEOFFSETS_YOFFSET (HOMEOFFSETS_XOFFSET + 1)
  2277. #define HOMEOFFSETS_TOTAL HOMEOFFSETS_YOFFSET
  2278. switch (item) {
  2279. case HOMEOFFSETS_BACK:
  2280. if (draw)
  2281. Draw_Menu_Item(row, ICON_Back, "Back");
  2282. else
  2283. Draw_Menu(Motion, MOTION_HOMEOFFSETS);
  2284. break;
  2285. case HOMEOFFSETS_XOFFSET:
  2286. if (draw) {
  2287. Draw_Menu_Item(row, ICON_StepX, "X Offset");
  2288. Draw_Float(home_offset.x, row, false, 100);
  2289. }
  2290. else
  2291. Modify_Value(home_offset.x, -MAX_XY_OFFSET, MAX_XY_OFFSET, 100);
  2292. break;
  2293. case HOMEOFFSETS_YOFFSET:
  2294. if (draw) {
  2295. Draw_Menu_Item(row, ICON_StepY, "Y Offset");
  2296. Draw_Float(home_offset.y, row, false, 100);
  2297. }
  2298. else
  2299. Modify_Value(home_offset.y, -MAX_XY_OFFSET, MAX_XY_OFFSET, 100);
  2300. break;
  2301. }
  2302. break;
  2303. case MaxSpeed:
  2304. #define SPEED_BACK 0
  2305. #define SPEED_X (SPEED_BACK + 1)
  2306. #define SPEED_Y (SPEED_X + 1)
  2307. #define SPEED_Z (SPEED_Y + 1)
  2308. #define SPEED_E (SPEED_Z + ENABLED(HAS_HOTEND))
  2309. #define SPEED_TOTAL SPEED_E
  2310. switch (item) {
  2311. case SPEED_BACK:
  2312. if (draw)
  2313. Draw_Menu_Item(row, ICON_Back, "Back");
  2314. else
  2315. Draw_Menu(Motion, MOTION_SPEED);
  2316. break;
  2317. case SPEED_X:
  2318. if (draw) {
  2319. Draw_Menu_Item(row, ICON_MaxSpeedX, "X Axis");
  2320. Draw_Float(planner.settings.max_feedrate_mm_s[X_AXIS], row, false, 1);
  2321. }
  2322. else
  2323. Modify_Value(planner.settings.max_feedrate_mm_s[X_AXIS], 0, default_max_feedrate[X_AXIS] * 2, 1);
  2324. break;
  2325. #if HAS_Y_AXIS
  2326. case SPEED_Y:
  2327. if (draw) {
  2328. Draw_Menu_Item(row, ICON_MaxSpeedY, "Y Axis");
  2329. Draw_Float(planner.settings.max_feedrate_mm_s[Y_AXIS], row, false, 1);
  2330. }
  2331. else
  2332. Modify_Value(planner.settings.max_feedrate_mm_s[Y_AXIS], 0, default_max_feedrate[Y_AXIS] * 2, 1);
  2333. break;
  2334. #endif
  2335. #if HAS_Z_AXIS
  2336. case SPEED_Z:
  2337. if (draw) {
  2338. Draw_Menu_Item(row, ICON_MaxSpeedZ, "Z Axis");
  2339. Draw_Float(planner.settings.max_feedrate_mm_s[Z_AXIS], row, false, 1);
  2340. }
  2341. else
  2342. Modify_Value(planner.settings.max_feedrate_mm_s[Z_AXIS], 0, default_max_feedrate[Z_AXIS] * 2, 1);
  2343. break;
  2344. #endif
  2345. #if HAS_HOTEND
  2346. case SPEED_E:
  2347. if (draw) {
  2348. Draw_Menu_Item(row, ICON_MaxSpeedE, "Extruder");
  2349. Draw_Float(planner.settings.max_feedrate_mm_s[E_AXIS], row, false, 1);
  2350. }
  2351. else
  2352. Modify_Value(planner.settings.max_feedrate_mm_s[E_AXIS], 0, default_max_feedrate[E_AXIS] * 2, 1);
  2353. break;
  2354. #endif
  2355. }
  2356. break;
  2357. case MaxAcceleration:
  2358. #define ACCEL_BACK 0
  2359. #define ACCEL_X (ACCEL_BACK + 1)
  2360. #define ACCEL_Y (ACCEL_X + 1)
  2361. #define ACCEL_Z (ACCEL_Y + 1)
  2362. #define ACCEL_E (ACCEL_Z + ENABLED(HAS_HOTEND))
  2363. #define ACCEL_TOTAL ACCEL_E
  2364. switch (item) {
  2365. case ACCEL_BACK:
  2366. if (draw)
  2367. Draw_Menu_Item(row, ICON_Back, "Back");
  2368. else
  2369. Draw_Menu(Motion, MOTION_ACCEL);
  2370. break;
  2371. case ACCEL_X:
  2372. if (draw) {
  2373. Draw_Menu_Item(row, ICON_MaxAccX, "X Axis");
  2374. Draw_Float(planner.settings.max_acceleration_mm_per_s2[X_AXIS], row, false, 1);
  2375. }
  2376. else
  2377. Modify_Value(planner.settings.max_acceleration_mm_per_s2[X_AXIS], 0, default_max_acceleration[X_AXIS] * 2, 1);
  2378. break;
  2379. case ACCEL_Y:
  2380. if (draw) {
  2381. Draw_Menu_Item(row, ICON_MaxAccY, "Y Axis");
  2382. Draw_Float(planner.settings.max_acceleration_mm_per_s2[Y_AXIS], row, false, 1);
  2383. }
  2384. else
  2385. Modify_Value(planner.settings.max_acceleration_mm_per_s2[Y_AXIS], 0, default_max_acceleration[Y_AXIS] * 2, 1);
  2386. break;
  2387. case ACCEL_Z:
  2388. if (draw) {
  2389. Draw_Menu_Item(row, ICON_MaxAccZ, "Z Axis");
  2390. Draw_Float(planner.settings.max_acceleration_mm_per_s2[Z_AXIS], row, false, 1);
  2391. }
  2392. else
  2393. Modify_Value(planner.settings.max_acceleration_mm_per_s2[Z_AXIS], 0, default_max_acceleration[Z_AXIS] * 2, 1);
  2394. break;
  2395. #if HAS_HOTEND
  2396. case ACCEL_E:
  2397. if (draw) {
  2398. Draw_Menu_Item(row, ICON_MaxAccE, "Extruder");
  2399. Draw_Float(planner.settings.max_acceleration_mm_per_s2[E_AXIS], row, false, 1);
  2400. }
  2401. else
  2402. Modify_Value(planner.settings.max_acceleration_mm_per_s2[E_AXIS], 0, default_max_acceleration[E_AXIS] * 2, 1);
  2403. break;
  2404. #endif
  2405. }
  2406. break;
  2407. #if HAS_CLASSIC_JERK
  2408. case MaxJerk:
  2409. #define JERK_BACK 0
  2410. #define JERK_X (JERK_BACK + 1)
  2411. #define JERK_Y (JERK_X + 1)
  2412. #define JERK_Z (JERK_Y + 1)
  2413. #define JERK_E (JERK_Z + ENABLED(HAS_HOTEND))
  2414. #define JERK_TOTAL JERK_E
  2415. switch (item) {
  2416. case JERK_BACK:
  2417. if (draw)
  2418. Draw_Menu_Item(row, ICON_Back, "Back");
  2419. else
  2420. Draw_Menu(Motion, MOTION_JERK);
  2421. break;
  2422. case JERK_X:
  2423. if (draw) {
  2424. Draw_Menu_Item(row, ICON_MaxSpeedJerkX, "X Axis");
  2425. Draw_Float(planner.max_jerk[X_AXIS], row, false, 10);
  2426. }
  2427. else
  2428. Modify_Value(planner.max_jerk[X_AXIS], 0, default_max_jerk[X_AXIS] * 2, 10);
  2429. break;
  2430. case JERK_Y:
  2431. if (draw) {
  2432. Draw_Menu_Item(row, ICON_MaxSpeedJerkY, "Y Axis");
  2433. Draw_Float(planner.max_jerk[Y_AXIS], row, false, 10);
  2434. }
  2435. else
  2436. Modify_Value(planner.max_jerk[Y_AXIS], 0, default_max_jerk[Y_AXIS] * 2, 10);
  2437. break;
  2438. case JERK_Z:
  2439. if (draw) {
  2440. Draw_Menu_Item(row, ICON_MaxSpeedJerkZ, "Z Axis");
  2441. Draw_Float(planner.max_jerk[Z_AXIS], row, false, 10);
  2442. }
  2443. else
  2444. Modify_Value(planner.max_jerk[Z_AXIS], 0, default_max_jerk[Z_AXIS] * 2, 10);
  2445. break;
  2446. #if HAS_HOTEND
  2447. case JERK_E:
  2448. if (draw) {
  2449. Draw_Menu_Item(row, ICON_MaxSpeedJerkE, "Extruder");
  2450. Draw_Float(planner.max_jerk[E_AXIS], row, false, 10);
  2451. }
  2452. else
  2453. Modify_Value(planner.max_jerk[E_AXIS], 0, default_max_jerk[E_AXIS] * 2, 10);
  2454. break;
  2455. #endif
  2456. }
  2457. break;
  2458. #endif
  2459. case Steps:
  2460. #define STEPS_BACK 0
  2461. #define STEPS_X (STEPS_BACK + 1)
  2462. #define STEPS_Y (STEPS_X + 1)
  2463. #define STEPS_Z (STEPS_Y + 1)
  2464. #define STEPS_E (STEPS_Z + ENABLED(HAS_HOTEND))
  2465. #define STEPS_TOTAL STEPS_E
  2466. switch (item) {
  2467. case STEPS_BACK:
  2468. if (draw)
  2469. Draw_Menu_Item(row, ICON_Back, "Back");
  2470. else
  2471. Draw_Menu(Motion, MOTION_STEPS);
  2472. break;
  2473. case STEPS_X:
  2474. if (draw) {
  2475. Draw_Menu_Item(row, ICON_StepX, "X Axis");
  2476. Draw_Float(planner.settings.axis_steps_per_mm[X_AXIS], row, false, 10);
  2477. }
  2478. else
  2479. Modify_Value(planner.settings.axis_steps_per_mm[X_AXIS], 0, default_steps[X_AXIS] * 2, 10);
  2480. break;
  2481. case STEPS_Y:
  2482. if (draw) {
  2483. Draw_Menu_Item(row, ICON_StepY, "Y Axis");
  2484. Draw_Float(planner.settings.axis_steps_per_mm[Y_AXIS], row, false, 10);
  2485. }
  2486. else
  2487. Modify_Value(planner.settings.axis_steps_per_mm[Y_AXIS], 0, default_steps[Y_AXIS] * 2, 10);
  2488. break;
  2489. case STEPS_Z:
  2490. if (draw) {
  2491. Draw_Menu_Item(row, ICON_StepZ, "Z Axis");
  2492. Draw_Float(planner.settings.axis_steps_per_mm[Z_AXIS], row, false, 10);
  2493. }
  2494. else
  2495. Modify_Value(planner.settings.axis_steps_per_mm[Z_AXIS], 0, default_steps[Z_AXIS] * 2, 10);
  2496. break;
  2497. #if HAS_HOTEND
  2498. case STEPS_E:
  2499. if (draw) {
  2500. Draw_Menu_Item(row, ICON_StepE, "Extruder");
  2501. Draw_Float(planner.settings.axis_steps_per_mm[E_AXIS], row, false, 10);
  2502. }
  2503. else
  2504. Modify_Value(planner.settings.axis_steps_per_mm[E_AXIS], 0, 1000, 10);
  2505. break;
  2506. #endif
  2507. }
  2508. break;
  2509. case Visual:
  2510. #define VISUAL_BACK 0
  2511. #define VISUAL_BACKLIGHT (VISUAL_BACK + 1)
  2512. #define VISUAL_BRIGHTNESS (VISUAL_BACKLIGHT + 1)
  2513. #define VISUAL_TIME_FORMAT (VISUAL_BRIGHTNESS + 1)
  2514. #define VISUAL_COLOR_THEMES (VISUAL_TIME_FORMAT + 1)
  2515. #define VISUAL_TOTAL VISUAL_COLOR_THEMES
  2516. switch (item) {
  2517. case VISUAL_BACK:
  2518. if (draw)
  2519. Draw_Menu_Item(row, ICON_Back, "Back");
  2520. else
  2521. Draw_Menu(Control, CONTROL_VISUAL);
  2522. break;
  2523. case VISUAL_BACKLIGHT:
  2524. if (draw)
  2525. Draw_Menu_Item(row, ICON_Brightness, "Display Off");
  2526. else
  2527. ui.set_brightness(0);
  2528. break;
  2529. case VISUAL_BRIGHTNESS:
  2530. if (draw) {
  2531. Draw_Menu_Item(row, ICON_Brightness, "LCD Brightness");
  2532. Draw_Float(ui.brightness, row, false, 1);
  2533. }
  2534. else
  2535. Modify_Value(ui.brightness, MIN_LCD_BRIGHTNESS, MAX_LCD_BRIGHTNESS, 1, ui.refresh_brightness);
  2536. break;
  2537. case VISUAL_TIME_FORMAT:
  2538. if (draw) {
  2539. Draw_Menu_Item(row, ICON_PrintTime, "Progress as __h__m");
  2540. Draw_Checkbox(row, eeprom_settings.time_format_textual);
  2541. }
  2542. else {
  2543. eeprom_settings.time_format_textual = !eeprom_settings.time_format_textual;
  2544. Draw_Checkbox(row, eeprom_settings.time_format_textual);
  2545. }
  2546. break;
  2547. case VISUAL_COLOR_THEMES:
  2548. if (draw)
  2549. Draw_Menu_Item(row, ICON_MaxSpeed, "UI Color Settings", nullptr, true);
  2550. else
  2551. Draw_Menu(ColorSettings);
  2552. break;
  2553. }
  2554. break;
  2555. case ColorSettings:
  2556. #define COLORSETTINGS_BACK 0
  2557. #define COLORSETTINGS_CURSOR (COLORSETTINGS_BACK + 1)
  2558. #define COLORSETTINGS_SPLIT_LINE (COLORSETTINGS_CURSOR + 1)
  2559. #define COLORSETTINGS_MENU_TOP_TXT (COLORSETTINGS_SPLIT_LINE + 1)
  2560. #define COLORSETTINGS_MENU_TOP_BG (COLORSETTINGS_MENU_TOP_TXT + 1)
  2561. #define COLORSETTINGS_HIGHLIGHT_BORDER (COLORSETTINGS_MENU_TOP_BG + 1)
  2562. #define COLORSETTINGS_PROGRESS_PERCENT (COLORSETTINGS_HIGHLIGHT_BORDER + 1)
  2563. #define COLORSETTINGS_PROGRESS_TIME (COLORSETTINGS_PROGRESS_PERCENT + 1)
  2564. #define COLORSETTINGS_PROGRESS_STATUS_BAR (COLORSETTINGS_PROGRESS_TIME + 1)
  2565. #define COLORSETTINGS_PROGRESS_STATUS_AREA (COLORSETTINGS_PROGRESS_STATUS_BAR + 1)
  2566. #define COLORSETTINGS_PROGRESS_COORDINATES (COLORSETTINGS_PROGRESS_STATUS_AREA + 1)
  2567. #define COLORSETTINGS_PROGRESS_COORDINATES_LINE (COLORSETTINGS_PROGRESS_COORDINATES + 1)
  2568. #define COLORSETTINGS_TOTAL COLORSETTINGS_PROGRESS_COORDINATES_LINE
  2569. switch (item) {
  2570. case COLORSETTINGS_BACK:
  2571. if (draw)
  2572. Draw_Menu_Item(row, ICON_Back, "Back");
  2573. else
  2574. Draw_Menu(Visual, VISUAL_COLOR_THEMES);
  2575. break;
  2576. case COLORSETTINGS_CURSOR:
  2577. if (draw) {
  2578. Draw_Menu_Item(row, ICON_MaxSpeed, "Cursor");
  2579. Draw_Option(eeprom_settings.cursor_color, color_names, row, false, true);
  2580. }
  2581. else
  2582. Modify_Option(eeprom_settings.cursor_color, color_names, Custom_Colors);
  2583. break;
  2584. case COLORSETTINGS_SPLIT_LINE:
  2585. if (draw) {
  2586. Draw_Menu_Item(row, ICON_MaxSpeed, "Menu Split Line");
  2587. Draw_Option(eeprom_settings.menu_split_line, color_names, row, false, true);
  2588. }
  2589. else
  2590. Modify_Option(eeprom_settings.menu_split_line, color_names, Custom_Colors);
  2591. break;
  2592. case COLORSETTINGS_MENU_TOP_TXT:
  2593. if (draw) {
  2594. Draw_Menu_Item(row, ICON_MaxSpeed, "Menu Header Text");
  2595. Draw_Option(eeprom_settings.menu_top_txt, color_names, row, false, true);
  2596. }
  2597. else
  2598. Modify_Option(eeprom_settings.menu_top_txt, color_names, Custom_Colors);
  2599. break;
  2600. case COLORSETTINGS_MENU_TOP_BG:
  2601. if (draw) {
  2602. Draw_Menu_Item(row, ICON_MaxSpeed, "Menu Header Bg");
  2603. Draw_Option(eeprom_settings.menu_top_bg, color_names, row, false, true);
  2604. }
  2605. else
  2606. Modify_Option(eeprom_settings.menu_top_bg, color_names, Custom_Colors);
  2607. break;
  2608. case COLORSETTINGS_HIGHLIGHT_BORDER:
  2609. if (draw) {
  2610. Draw_Menu_Item(row, ICON_MaxSpeed, "Highlight Box");
  2611. Draw_Option(eeprom_settings.highlight_box, color_names, row, false, true);
  2612. }
  2613. else
  2614. Modify_Option(eeprom_settings.highlight_box, color_names, Custom_Colors);
  2615. break;
  2616. case COLORSETTINGS_PROGRESS_PERCENT:
  2617. if (draw) {
  2618. Draw_Menu_Item(row, ICON_MaxSpeed, "Progress Percent");
  2619. Draw_Option(eeprom_settings.progress_percent, color_names, row, false, true);
  2620. }
  2621. else
  2622. Modify_Option(eeprom_settings.progress_percent, color_names, Custom_Colors);
  2623. break;
  2624. case COLORSETTINGS_PROGRESS_TIME:
  2625. if (draw) {
  2626. Draw_Menu_Item(row, ICON_MaxSpeed, "Progress Time");
  2627. Draw_Option(eeprom_settings.progress_time, color_names, row, false, true);
  2628. }
  2629. else
  2630. Modify_Option(eeprom_settings.progress_time, color_names, Custom_Colors);
  2631. break;
  2632. case COLORSETTINGS_PROGRESS_STATUS_BAR:
  2633. if (draw) {
  2634. Draw_Menu_Item(row, ICON_MaxSpeed, "Status Bar Text");
  2635. Draw_Option(eeprom_settings.status_bar_text, color_names, row, false, true);
  2636. }
  2637. else
  2638. Modify_Option(eeprom_settings.status_bar_text, color_names, Custom_Colors);
  2639. break;
  2640. case COLORSETTINGS_PROGRESS_STATUS_AREA:
  2641. if (draw) {
  2642. Draw_Menu_Item(row, ICON_MaxSpeed, "Status Area Text");
  2643. Draw_Option(eeprom_settings.status_area_text, color_names, row, false, true);
  2644. }
  2645. else
  2646. Modify_Option(eeprom_settings.status_area_text, color_names, Custom_Colors);
  2647. break;
  2648. case COLORSETTINGS_PROGRESS_COORDINATES:
  2649. if (draw) {
  2650. Draw_Menu_Item(row, ICON_MaxSpeed, "Coordinates Text");
  2651. Draw_Option(eeprom_settings.coordinates_text, color_names, row, false, true);
  2652. }
  2653. else
  2654. Modify_Option(eeprom_settings.coordinates_text, color_names, Custom_Colors);
  2655. break;
  2656. case COLORSETTINGS_PROGRESS_COORDINATES_LINE:
  2657. if (draw) {
  2658. Draw_Menu_Item(row, ICON_MaxSpeed, "Coordinates Line");
  2659. Draw_Option(eeprom_settings.coordinates_split_line, color_names, row, false, true);
  2660. }
  2661. else
  2662. Modify_Option(eeprom_settings.coordinates_split_line, color_names, Custom_Colors);
  2663. break;
  2664. } // switch (item)
  2665. break;
  2666. case Advanced:
  2667. #define ADVANCED_BACK 0
  2668. #define ADVANCED_BEEPER (ADVANCED_BACK + 1)
  2669. #define ADVANCED_PROBE (ADVANCED_BEEPER + ENABLED(HAS_BED_PROBE))
  2670. #define ADVANCED_CORNER (ADVANCED_PROBE + 1)
  2671. #define ADVANCED_LA (ADVANCED_CORNER + ENABLED(LIN_ADVANCE))
  2672. #define ADVANCED_LOAD (ADVANCED_LA + ENABLED(ADVANCED_PAUSE_FEATURE))
  2673. #define ADVANCED_UNLOAD (ADVANCED_LOAD + ENABLED(ADVANCED_PAUSE_FEATURE))
  2674. #define ADVANCED_COLD_EXTRUDE (ADVANCED_UNLOAD + ENABLED(PREVENT_COLD_EXTRUSION))
  2675. #define ADVANCED_FILSENSORENABLED (ADVANCED_COLD_EXTRUDE + ENABLED(FILAMENT_RUNOUT_SENSOR))
  2676. #define ADVANCED_FILSENSORDISTANCE (ADVANCED_FILSENSORENABLED + ENABLED(HAS_FILAMENT_RUNOUT_DISTANCE))
  2677. #define ADVANCED_POWER_LOSS (ADVANCED_FILSENSORDISTANCE + ENABLED(POWER_LOSS_RECOVERY))
  2678. #define ADVANCED_TOTAL ADVANCED_POWER_LOSS
  2679. switch (item) {
  2680. case ADVANCED_BACK:
  2681. if (draw)
  2682. Draw_Menu_Item(row, ICON_Back, "Back");
  2683. else
  2684. Draw_Menu(Control, CONTROL_ADVANCED);
  2685. break;
  2686. case ADVANCED_BEEPER:
  2687. if (draw) {
  2688. Draw_Menu_Item(row, ICON_Version, "LCD Beeper");
  2689. Draw_Checkbox(row, eeprom_settings.beeperenable);
  2690. }
  2691. else {
  2692. eeprom_settings.beeperenable = !eeprom_settings.beeperenable;
  2693. Draw_Checkbox(row, eeprom_settings.beeperenable);
  2694. }
  2695. break;
  2696. #if HAS_BED_PROBE
  2697. case ADVANCED_PROBE:
  2698. if (draw)
  2699. Draw_Menu_Item(row, ICON_StepX, "Probe", nullptr, true);
  2700. else
  2701. Draw_Menu(ProbeMenu);
  2702. break;
  2703. #endif
  2704. case ADVANCED_CORNER:
  2705. if (draw) {
  2706. Draw_Menu_Item(row, ICON_MaxAccelerated, "Bed Screw Inset");
  2707. Draw_Float(corner_pos, row, false, 10);
  2708. }
  2709. else
  2710. Modify_Value(corner_pos, 1, 100, 10);
  2711. break;
  2712. #if ENABLED(LIN_ADVANCE)
  2713. case ADVANCED_LA:
  2714. if (draw) {
  2715. Draw_Menu_Item(row, ICON_MaxAccelerated, "Lin Advance Kp");
  2716. Draw_Float(planner.extruder_advance_K[0], row, false, 100);
  2717. }
  2718. else
  2719. Modify_Value(planner.extruder_advance_K[0], 0, 10, 100);
  2720. break;
  2721. #endif
  2722. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  2723. case ADVANCED_LOAD:
  2724. if (draw) {
  2725. Draw_Menu_Item(row, ICON_WriteEEPROM, "Load Length");
  2726. Draw_Float(fc_settings[0].load_length, row, false, 1);
  2727. }
  2728. else
  2729. Modify_Value(fc_settings[0].load_length, 0, EXTRUDE_MAXLENGTH, 1);
  2730. break;
  2731. case ADVANCED_UNLOAD:
  2732. if (draw) {
  2733. Draw_Menu_Item(row, ICON_ReadEEPROM, "Unload Length");
  2734. Draw_Float(fc_settings[0].unload_length, row, false, 1);
  2735. }
  2736. else
  2737. Modify_Value(fc_settings[0].unload_length, 0, EXTRUDE_MAXLENGTH, 1);
  2738. break;
  2739. #endif // ADVANCED_PAUSE_FEATURE
  2740. #if ENABLED(PREVENT_COLD_EXTRUSION)
  2741. case ADVANCED_COLD_EXTRUDE:
  2742. if (draw) {
  2743. Draw_Menu_Item(row, ICON_Cool, "Min Extrusion T");
  2744. Draw_Float(thermalManager.extrude_min_temp, row, false, 1);
  2745. }
  2746. else {
  2747. Modify_Value(thermalManager.extrude_min_temp, 0, MAX_E_TEMP, 1);
  2748. thermalManager.allow_cold_extrude = (thermalManager.extrude_min_temp == 0);
  2749. }
  2750. break;
  2751. #endif
  2752. #if ENABLED(FILAMENT_RUNOUT_SENSOR)
  2753. case ADVANCED_FILSENSORENABLED:
  2754. if (draw) {
  2755. Draw_Menu_Item(row, ICON_Extruder, "Filament Sensor");
  2756. Draw_Checkbox(row, runout.enabled);
  2757. }
  2758. else {
  2759. runout.enabled = !runout.enabled;
  2760. Draw_Checkbox(row, runout.enabled);
  2761. }
  2762. break;
  2763. #if ENABLED(HAS_FILAMENT_RUNOUT_DISTANCE)
  2764. case ADVANCED_FILSENSORDISTANCE:
  2765. if (draw) {
  2766. Draw_Menu_Item(row, ICON_MaxAccE, "Runout Distance");
  2767. Draw_Float(runout.runout_distance(), row, false, 10);
  2768. }
  2769. else
  2770. Modify_Value(runout.runout_distance(), 0, 999, 10);
  2771. break;
  2772. #endif
  2773. #endif // FILAMENT_RUNOUT_SENSOR
  2774. #if ENABLED(POWER_LOSS_RECOVERY)
  2775. case ADVANCED_POWER_LOSS:
  2776. if (draw) {
  2777. Draw_Menu_Item(row, ICON_Motion, "Power-loss recovery");
  2778. Draw_Checkbox(row, recovery.enabled);
  2779. }
  2780. else {
  2781. recovery.enable(!recovery.enabled);
  2782. Draw_Checkbox(row, recovery.enabled);
  2783. }
  2784. break;
  2785. #endif
  2786. }
  2787. break;
  2788. #if HAS_BED_PROBE
  2789. case ProbeMenu:
  2790. #define PROBE_BACK 0
  2791. #define PROBE_XOFFSET (PROBE_BACK + 1)
  2792. #define PROBE_YOFFSET (PROBE_XOFFSET + 1)
  2793. #define PROBE_TEST (PROBE_YOFFSET + 1)
  2794. #define PROBE_TEST_COUNT (PROBE_TEST + 1)
  2795. #define PROBE_TOTAL PROBE_TEST_COUNT
  2796. static uint8_t testcount = 4;
  2797. switch (item) {
  2798. case PROBE_BACK:
  2799. if (draw)
  2800. Draw_Menu_Item(row, ICON_Back, "Back");
  2801. else
  2802. Draw_Menu(Advanced, ADVANCED_PROBE);
  2803. break;
  2804. case PROBE_XOFFSET:
  2805. if (draw) {
  2806. Draw_Menu_Item(row, ICON_StepX, "Probe X Offset");
  2807. Draw_Float(probe.offset.x, row, false, 10);
  2808. }
  2809. else
  2810. Modify_Value(probe.offset.x, -MAX_XY_OFFSET, MAX_XY_OFFSET, 10);
  2811. break;
  2812. case PROBE_YOFFSET:
  2813. if (draw) {
  2814. Draw_Menu_Item(row, ICON_StepY, "Probe Y Offset");
  2815. Draw_Float(probe.offset.y, row, false, 10);
  2816. }
  2817. else
  2818. Modify_Value(probe.offset.y, -MAX_XY_OFFSET, MAX_XY_OFFSET, 10);
  2819. break;
  2820. case PROBE_TEST:
  2821. if (draw)
  2822. Draw_Menu_Item(row, ICON_StepY, "M48 Probe Test");
  2823. else {
  2824. sprintf_P(cmd, PSTR("G28O\nM48 X%s Y%s P%i"), dtostrf((X_BED_SIZE + X_MIN_POS) / 2.0f, 1, 3, str_1), dtostrf((Y_BED_SIZE + Y_MIN_POS) / 2.0f, 1, 3, str_2), testcount);
  2825. gcode.process_subcommands_now_P(cmd);
  2826. }
  2827. break;
  2828. case PROBE_TEST_COUNT:
  2829. if (draw) {
  2830. Draw_Menu_Item(row, ICON_StepY, "Probe Test Count");
  2831. Draw_Float(testcount, row, false, 1);
  2832. }
  2833. else
  2834. Modify_Value(testcount, 4, 50, 1);
  2835. break;
  2836. }
  2837. break;
  2838. #endif
  2839. case InfoMain:
  2840. case Info:
  2841. #define INFO_BACK 0
  2842. #define INFO_PRINTCOUNT (INFO_BACK + ENABLED(PRINTCOUNTER))
  2843. #define INFO_PRINTTIME (INFO_PRINTCOUNT + ENABLED(PRINTCOUNTER))
  2844. #define INFO_SIZE (INFO_PRINTTIME + 1)
  2845. #define INFO_VERSION (INFO_SIZE + 1)
  2846. #define INFO_CONTACT (INFO_VERSION + 1)
  2847. #define INFO_TOTAL INFO_BACK
  2848. switch (item) {
  2849. case INFO_BACK:
  2850. if (draw) {
  2851. Draw_Menu_Item(row, ICON_Back, "Back");
  2852. #if ENABLED(PRINTCOUNTER)
  2853. char row1[50], row2[50], buf[32];
  2854. printStatistics ps = print_job_timer.getStats();
  2855. sprintf_P(row1, PSTR("%i prints, %i finished"), ps.totalPrints, ps.finishedPrints);
  2856. sprintf_P(row2, PSTR("%s m filament used"), dtostrf(ps.filamentUsed / 1000, 1, 2, str_1));
  2857. Draw_Menu_Item(INFO_PRINTCOUNT, ICON_HotendTemp, row1, row2, false, true);
  2858. duration_t(print_job_timer.getStats().printTime).toString(buf);
  2859. sprintf_P(row1, PSTR("Printed: %s"), buf);
  2860. duration_t(print_job_timer.getStats().longestPrint).toString(buf);
  2861. sprintf_P(row2, PSTR("Longest: %s"), buf);
  2862. Draw_Menu_Item(INFO_PRINTTIME, ICON_PrintTime, row1, row2, false, true);
  2863. #endif
  2864. Draw_Menu_Item(INFO_SIZE, ICON_PrintSize, MACHINE_SIZE, nullptr, false, true);
  2865. Draw_Menu_Item(INFO_VERSION, ICON_Version, SHORT_BUILD_VERSION, nullptr, false, true);
  2866. Draw_Menu_Item(INFO_CONTACT, ICON_Contact, CORP_WEBSITE, nullptr, false, true);
  2867. }
  2868. else {
  2869. if (menu == Info)
  2870. Draw_Menu(Control, CONTROL_INFO);
  2871. else
  2872. Draw_Main_Menu(3);
  2873. }
  2874. break;
  2875. }
  2876. break;
  2877. #if HAS_MESH
  2878. case Leveling:
  2879. #define LEVELING_BACK 0
  2880. #define LEVELING_ACTIVE (LEVELING_BACK + 1)
  2881. #define LEVELING_GET_TILT (LEVELING_ACTIVE + BOTH(HAS_BED_PROBE, AUTO_BED_LEVELING_UBL))
  2882. #define LEVELING_GET_MESH (LEVELING_GET_TILT + 1)
  2883. #define LEVELING_MANUAL (LEVELING_GET_MESH + 1)
  2884. #define LEVELING_VIEW (LEVELING_MANUAL + 1)
  2885. #define LEVELING_SETTINGS (LEVELING_VIEW + 1)
  2886. #define LEVELING_SLOT (LEVELING_SETTINGS + ENABLED(AUTO_BED_LEVELING_UBL))
  2887. #define LEVELING_LOAD (LEVELING_SLOT + ENABLED(AUTO_BED_LEVELING_UBL))
  2888. #define LEVELING_SAVE (LEVELING_LOAD + ENABLED(AUTO_BED_LEVELING_UBL))
  2889. #define LEVELING_TOTAL LEVELING_SAVE
  2890. switch (item) {
  2891. case LEVELING_BACK:
  2892. if (draw)
  2893. Draw_Menu_Item(row, ICON_Back, "Back");
  2894. else
  2895. Draw_Main_Menu(3);
  2896. break;
  2897. case LEVELING_ACTIVE:
  2898. if (draw) {
  2899. Draw_Menu_Item(row, ICON_StockConfiguraton, "Leveling Active");
  2900. Draw_Checkbox(row, planner.leveling_active);
  2901. }
  2902. else {
  2903. if (!planner.leveling_active) {
  2904. set_bed_leveling_enabled(!planner.leveling_active);
  2905. if (!planner.leveling_active) {
  2906. Confirm_Handler(LevelError);
  2907. break;
  2908. }
  2909. }
  2910. else
  2911. set_bed_leveling_enabled(!planner.leveling_active);
  2912. Draw_Checkbox(row, planner.leveling_active);
  2913. }
  2914. break;
  2915. #if BOTH(HAS_BED_PROBE, AUTO_BED_LEVELING_UBL)
  2916. case LEVELING_GET_TILT:
  2917. if (draw)
  2918. Draw_Menu_Item(row, ICON_Tilt, "Autotilt Current Mesh");
  2919. else {
  2920. if (ubl.storage_slot < 0) {
  2921. Popup_Handler(MeshSlot);
  2922. break;
  2923. }
  2924. Popup_Handler(Home);
  2925. gcode.home_all_axes(true);
  2926. Popup_Handler(Level);
  2927. if (mesh_conf.tilt_grid > 1)
  2928. sprintf_P(cmd, PSTR("G29 J%i"), mesh_conf.tilt_grid);
  2929. else
  2930. sprintf_P(cmd, PSTR("G29 J"));
  2931. gcode.process_subcommands_now_P(cmd);
  2932. planner.synchronize();
  2933. Redraw_Menu();
  2934. }
  2935. break;
  2936. #endif
  2937. case LEVELING_GET_MESH:
  2938. if (draw)
  2939. Draw_Menu_Item(row, ICON_Mesh, "Create New Mesh");
  2940. else {
  2941. Popup_Handler(Home);
  2942. gcode.home_all_axes(true);
  2943. #if ENABLED(AUTO_BED_LEVELING_UBL)
  2944. #if ENABLED(PREHEAT_BEFORE_LEVELING)
  2945. Popup_Handler(Heating);
  2946. #if HAS_HOTEND
  2947. if (thermalManager.degTargetHotend(0) < LEVELING_NOZZLE_TEMP)
  2948. thermalManager.setTargetHotend(LEVELING_NOZZLE_TEMP, 0);
  2949. #endif
  2950. #if HAS_HEATED_BED
  2951. if (thermalManager.degTargetBed() < LEVELING_BED_TEMP)
  2952. thermalManager.setTargetBed(LEVELING_BED_TEMP);
  2953. #endif
  2954. thermalManager.wait_for_hotend(0);
  2955. TERN_(HAS_HEATED_BED, thermalManager.wait_for_bed_heating());
  2956. #endif
  2957. #if HAS_BED_PROBE
  2958. Popup_Handler(Level);
  2959. gcode.process_subcommands_now_P(PSTR("G29 P0\nG29 P1"));
  2960. gcode.process_subcommands_now_P(PSTR("G29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nG29 P3\nM420 S1"));
  2961. planner.synchronize();
  2962. Update_Status("Probed all reachable points");
  2963. Popup_Handler(SaveLevel);
  2964. #else
  2965. level_state = planner.leveling_active;
  2966. set_bed_leveling_enabled(false);
  2967. mesh_conf.goto_mesh_value = true;
  2968. mesh_conf.mesh_x = mesh_conf.mesh_y = 0;
  2969. Popup_Handler(MoveWait);
  2970. mesh_conf.manual_move();;
  2971. Draw_Menu(UBLMesh);
  2972. #endif
  2973. #elif HAS_BED_PROBE
  2974. Popup_Handler(Level);
  2975. gcode.process_subcommands_now_P(PSTR("G29"));
  2976. planner.synchronize();
  2977. Popup_Handler(SaveLevel);
  2978. #else
  2979. level_state = planner.leveling_active;
  2980. set_bed_leveling_enabled(false);
  2981. gridpoint = 1;
  2982. Popup_Handler(MoveWait);
  2983. gcode.process_subcommands_now_P(PSTR("G29"));
  2984. planner.synchronize();
  2985. Draw_Menu(ManualMesh);
  2986. #endif
  2987. }
  2988. break;
  2989. case LEVELING_MANUAL:
  2990. if (draw)
  2991. Draw_Menu_Item(row, ICON_Mesh, "Manual Tuning", nullptr, true);
  2992. else {
  2993. #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
  2994. if (!leveling_is_valid()) {
  2995. Confirm_Handler(InvalidMesh);
  2996. break;
  2997. }
  2998. #endif
  2999. #if ENABLED(AUTO_BED_LEVELING_UBL)
  3000. if (ubl.storage_slot < 0) {
  3001. Popup_Handler(MeshSlot);
  3002. break;
  3003. }
  3004. #endif
  3005. if (axes_should_home()) {
  3006. Popup_Handler(Home);
  3007. gcode.home_all_axes(true);
  3008. }
  3009. level_state = planner.leveling_active;
  3010. set_bed_leveling_enabled(false);
  3011. mesh_conf.goto_mesh_value = false;
  3012. #if ENABLED(PREHEAT_BEFORE_LEVELING)
  3013. Popup_Handler(Heating);
  3014. #if HAS_HOTEND
  3015. if (thermalManager.degTargetHotend(0) < LEVELING_NOZZLE_TEMP)
  3016. thermalManager.setTargetHotend(LEVELING_NOZZLE_TEMP, 0);
  3017. #endif
  3018. #if HAS_HEATED_BED
  3019. if (thermalManager.degTargetBed() < LEVELING_BED_TEMP)
  3020. thermalManager.setTargetBed(LEVELING_BED_TEMP);
  3021. #endif
  3022. TERN_(HAS_HOTEND, thermalManager.wait_for_hotend(0));
  3023. TERN_(HAS_HEATED_BED, thermalManager.wait_for_bed_heating());
  3024. #endif
  3025. Popup_Handler(MoveWait);
  3026. mesh_conf.manual_move();
  3027. Draw_Menu(LevelManual);
  3028. }
  3029. break;
  3030. case LEVELING_VIEW:
  3031. if (draw)
  3032. Draw_Menu_Item(row, ICON_Mesh, "Mesh Viewer", nullptr, true);
  3033. else {
  3034. #if ENABLED(AUTO_BED_LEVELING_UBL)
  3035. if (ubl.storage_slot < 0) {
  3036. Popup_Handler(MeshSlot);
  3037. break;
  3038. }
  3039. #endif
  3040. Draw_Menu(LevelView);
  3041. }
  3042. break;
  3043. case LEVELING_SETTINGS:
  3044. if (draw)
  3045. Draw_Menu_Item(row, ICON_Step, "Leveling Settings", nullptr, true);
  3046. else
  3047. Draw_Menu(LevelSettings);
  3048. break;
  3049. #if ENABLED(AUTO_BED_LEVELING_UBL)
  3050. case LEVELING_SLOT:
  3051. if (draw) {
  3052. Draw_Menu_Item(row, ICON_PrintSize, "Mesh Slot");
  3053. Draw_Float(ubl.storage_slot, row, false, 1);
  3054. }
  3055. else
  3056. Modify_Value(ubl.storage_slot, 0, settings.calc_num_meshes() - 1, 1);
  3057. break;
  3058. case LEVELING_LOAD:
  3059. if (draw)
  3060. Draw_Menu_Item(row, ICON_ReadEEPROM, "Load Mesh");
  3061. else {
  3062. if (ubl.storage_slot < 0) {
  3063. Popup_Handler(MeshSlot);
  3064. break;
  3065. }
  3066. gcode.process_subcommands_now_P(PSTR("G29 L"));
  3067. planner.synchronize();
  3068. AudioFeedback(true);
  3069. }
  3070. break;
  3071. case LEVELING_SAVE:
  3072. if (draw)
  3073. Draw_Menu_Item(row, ICON_WriteEEPROM, "Save Mesh");
  3074. else {
  3075. if (ubl.storage_slot < 0) {
  3076. Popup_Handler(MeshSlot);
  3077. break;
  3078. }
  3079. gcode.process_subcommands_now_P(PSTR("G29 S"));
  3080. planner.synchronize();
  3081. AudioFeedback(true);
  3082. }
  3083. break;
  3084. #endif
  3085. }
  3086. break;
  3087. case LevelView:
  3088. #define LEVELING_VIEW_BACK 0
  3089. #define LEVELING_VIEW_MESH (LEVELING_VIEW_BACK + 1)
  3090. #define LEVELING_VIEW_TEXT (LEVELING_VIEW_MESH + 1)
  3091. #define LEVELING_VIEW_ASYMMETRIC (LEVELING_VIEW_TEXT + 1)
  3092. #define LEVELING_VIEW_TOTAL LEVELING_VIEW_ASYMMETRIC
  3093. switch (item) {
  3094. case LEVELING_VIEW_BACK:
  3095. if (draw)
  3096. Draw_Menu_Item(row, ICON_Back, "Back");
  3097. else
  3098. Draw_Menu(Leveling, LEVELING_VIEW);
  3099. break;
  3100. case LEVELING_VIEW_MESH:
  3101. if (draw)
  3102. Draw_Menu_Item(row, ICON_PrintSize, "Mesh Viewer", nullptr, true);
  3103. else
  3104. Draw_Menu(MeshViewer);
  3105. break;
  3106. case LEVELING_VIEW_TEXT:
  3107. if (draw) {
  3108. Draw_Menu_Item(row, ICON_Contact, "Viewer Show Values");
  3109. Draw_Checkbox(row, mesh_conf.viewer_print_value);
  3110. }
  3111. else {
  3112. mesh_conf.viewer_print_value = !mesh_conf.viewer_print_value;
  3113. Draw_Checkbox(row, mesh_conf.viewer_print_value);
  3114. }
  3115. break;
  3116. case LEVELING_VIEW_ASYMMETRIC:
  3117. if (draw) {
  3118. Draw_Menu_Item(row, ICON_Axis, "Viewer Asymmetric");
  3119. Draw_Checkbox(row, mesh_conf.viewer_asymmetric_range);
  3120. }
  3121. else {
  3122. mesh_conf.viewer_asymmetric_range = !mesh_conf.viewer_asymmetric_range;
  3123. Draw_Checkbox(row, mesh_conf.viewer_asymmetric_range);
  3124. }
  3125. break;
  3126. }
  3127. break;
  3128. case LevelSettings:
  3129. #define LEVELING_SETTINGS_BACK 0
  3130. #define LEVELING_SETTINGS_FADE (LEVELING_SETTINGS_BACK + 1)
  3131. #define LEVELING_SETTINGS_TILT (LEVELING_SETTINGS_FADE + ENABLED(AUTO_BED_LEVELING_UBL))
  3132. #define LEVELING_SETTINGS_PLANE (LEVELING_SETTINGS_TILT + ENABLED(AUTO_BED_LEVELING_UBL))
  3133. #define LEVELING_SETTINGS_ZERO (LEVELING_SETTINGS_PLANE + ENABLED(AUTO_BED_LEVELING_UBL))
  3134. #define LEVELING_SETTINGS_UNDEF (LEVELING_SETTINGS_ZERO + ENABLED(AUTO_BED_LEVELING_UBL))
  3135. #define LEVELING_SETTINGS_TOTAL LEVELING_SETTINGS_UNDEF
  3136. switch (item) {
  3137. case LEVELING_SETTINGS_BACK:
  3138. if (draw)
  3139. Draw_Menu_Item(row, ICON_Back, "Back");
  3140. else
  3141. Draw_Menu(Leveling, LEVELING_SETTINGS);
  3142. break;
  3143. case LEVELING_SETTINGS_FADE:
  3144. if (draw) {
  3145. Draw_Menu_Item(row, ICON_Fade, "Fade Mesh within");
  3146. Draw_Float(planner.z_fade_height, row, false, 1);
  3147. }
  3148. else {
  3149. Modify_Value(planner.z_fade_height, 0, Z_MAX_POS, 1);
  3150. planner.z_fade_height = -1;
  3151. set_z_fade_height(planner.z_fade_height);
  3152. }
  3153. break;
  3154. #if ENABLED(AUTO_BED_LEVELING_UBL)
  3155. case LEVELING_SETTINGS_TILT:
  3156. if (draw) {
  3157. Draw_Menu_Item(row, ICON_Tilt, "Tilting Grid Size");
  3158. Draw_Float(mesh_conf.tilt_grid, row, false, 1);
  3159. }
  3160. else
  3161. Modify_Value(mesh_conf.tilt_grid, 1, 8, 1);
  3162. break;
  3163. case LEVELING_SETTINGS_PLANE:
  3164. if (draw)
  3165. Draw_Menu_Item(row, ICON_ResumeEEPROM, "Convert Mesh to Plane");
  3166. else {
  3167. if (mesh_conf.create_plane_from_mesh()) break;
  3168. gcode.process_subcommands_now_P(PSTR("M420 S1"));
  3169. planner.synchronize();
  3170. AudioFeedback(true);
  3171. }
  3172. break;
  3173. case LEVELING_SETTINGS_ZERO:
  3174. if (draw)
  3175. Draw_Menu_Item(row, ICON_Mesh, "Zero Current Mesh");
  3176. else
  3177. ZERO(mesh_conf.mesh_z_values);
  3178. break;
  3179. case LEVELING_SETTINGS_UNDEF:
  3180. if (draw)
  3181. Draw_Menu_Item(row, ICON_Mesh, "Clear Current Mesh");
  3182. else
  3183. ubl.invalidate();
  3184. break;
  3185. #endif // AUTO_BED_LEVELING_UBL
  3186. }
  3187. break;
  3188. case MeshViewer:
  3189. #define MESHVIEW_BACK 0
  3190. #define MESHVIEW_TOTAL MESHVIEW_BACK
  3191. if (item == MESHVIEW_BACK) {
  3192. if (draw) {
  3193. Draw_Menu_Item(0, ICON_Back, "Back");
  3194. mesh_conf.Draw_Bed_Mesh();
  3195. mesh_conf.Set_Mesh_Viewer_Status();
  3196. }
  3197. else if (!mesh_conf.drawing_mesh) {
  3198. Draw_Menu(LevelView, LEVELING_VIEW_MESH);
  3199. Update_Status("");
  3200. }
  3201. }
  3202. break;
  3203. case LevelManual:
  3204. #define LEVELING_M_BACK 0
  3205. #define LEVELING_M_X (LEVELING_M_BACK + 1)
  3206. #define LEVELING_M_Y (LEVELING_M_X + 1)
  3207. #define LEVELING_M_NEXT (LEVELING_M_Y + 1)
  3208. #define LEVELING_M_OFFSET (LEVELING_M_NEXT + 1)
  3209. #define LEVELING_M_UP (LEVELING_M_OFFSET + 1)
  3210. #define LEVELING_M_DOWN (LEVELING_M_UP + 1)
  3211. #define LEVELING_M_GOTO_VALUE (LEVELING_M_DOWN + 1)
  3212. #define LEVELING_M_UNDEF (LEVELING_M_GOTO_VALUE + ENABLED(AUTO_BED_LEVELING_UBL))
  3213. #define LEVELING_M_TOTAL LEVELING_M_UNDEF
  3214. switch (item) {
  3215. case LEVELING_M_BACK:
  3216. if (draw)
  3217. Draw_Menu_Item(row, ICON_Back, "Back");
  3218. else {
  3219. set_bed_leveling_enabled(level_state);
  3220. TERN_(AUTO_BED_LEVELING_BILINEAR, refresh_bed_level());
  3221. Draw_Menu(Leveling, LEVELING_MANUAL);
  3222. }
  3223. break;
  3224. case LEVELING_M_X:
  3225. if (draw) {
  3226. Draw_Menu_Item(row, ICON_MoveX, "Mesh Point X");
  3227. Draw_Float(mesh_conf.mesh_x, row, 0, 1);
  3228. }
  3229. else
  3230. Modify_Value(mesh_conf.mesh_x, 0, GRID_MAX_POINTS_X - 1, 1);
  3231. break;
  3232. case LEVELING_M_Y:
  3233. if (draw) {
  3234. Draw_Menu_Item(row, ICON_MoveY, "Mesh Point Y");
  3235. Draw_Float(mesh_conf.mesh_y, row, 0, 1);
  3236. }
  3237. else
  3238. Modify_Value(mesh_conf.mesh_y, 0, GRID_MAX_POINTS_Y - 1, 1);
  3239. break;
  3240. case LEVELING_M_NEXT:
  3241. if (draw)
  3242. Draw_Menu_Item(row, ICON_More, "Next Point");
  3243. else {
  3244. if (mesh_conf.mesh_x != (GRID_MAX_POINTS_X - 1) || mesh_conf.mesh_y != (GRID_MAX_POINTS_Y - 1)) {
  3245. if ((mesh_conf.mesh_x == (GRID_MAX_POINTS_X - 1) && mesh_conf.mesh_y % 2 == 0) || (mesh_conf.mesh_x == 0 && mesh_conf.mesh_y % 2 == 1))
  3246. mesh_conf.mesh_y++;
  3247. else if (mesh_conf.mesh_y % 2 == 0)
  3248. mesh_conf.mesh_x++;
  3249. else
  3250. mesh_conf.mesh_x--;
  3251. mesh_conf.manual_move();
  3252. }
  3253. }
  3254. break;
  3255. case LEVELING_M_OFFSET:
  3256. if (draw) {
  3257. Draw_Menu_Item(row, ICON_SetZOffset, "Point Z Offset");
  3258. Draw_Float(mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], row, false, 100);
  3259. }
  3260. else {
  3261. if (isnan(mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y]))
  3262. mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] = 0;
  3263. Modify_Value(mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], MIN_Z_OFFSET, MAX_Z_OFFSET, 100);
  3264. }
  3265. break;
  3266. case LEVELING_M_UP:
  3267. if (draw)
  3268. Draw_Menu_Item(row, ICON_Axis, "Microstep Up");
  3269. else if (mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] < MAX_Z_OFFSET) {
  3270. mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] += 0.01;
  3271. gcode.process_subcommands_now_P(PSTR("M290 Z0.01"));
  3272. planner.synchronize();
  3273. current_position.z += 0.01f;
  3274. sync_plan_position();
  3275. Draw_Float(mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 1, false, 100);
  3276. }
  3277. break;
  3278. case LEVELING_M_DOWN:
  3279. if (draw)
  3280. Draw_Menu_Item(row, ICON_AxisD, "Microstep Down");
  3281. else if (mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] > MIN_Z_OFFSET) {
  3282. mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] -= 0.01;
  3283. gcode.process_subcommands_now_P(PSTR("M290 Z-0.01"));
  3284. planner.synchronize();
  3285. current_position.z -= 0.01f;
  3286. sync_plan_position();
  3287. Draw_Float(mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 2, false, 100);
  3288. }
  3289. break;
  3290. case LEVELING_M_GOTO_VALUE:
  3291. if (draw) {
  3292. Draw_Menu_Item(row, ICON_StockConfiguraton, "Go to Mesh Z Value");
  3293. Draw_Checkbox(row, mesh_conf.goto_mesh_value);
  3294. }
  3295. else {
  3296. mesh_conf.goto_mesh_value = !mesh_conf.goto_mesh_value;
  3297. current_position.z = 0;
  3298. mesh_conf.manual_move(true);
  3299. Draw_Checkbox(row, mesh_conf.goto_mesh_value);
  3300. }
  3301. break;
  3302. #if ENABLED(AUTO_BED_LEVELING_UBL)
  3303. case LEVELING_M_UNDEF:
  3304. if (draw)
  3305. Draw_Menu_Item(row, ICON_ResumeEEPROM, "Clear Point Value");
  3306. else {
  3307. mesh_conf.manual_value_update(true);
  3308. Redraw_Menu(false);
  3309. }
  3310. break;
  3311. #endif
  3312. }
  3313. break;
  3314. #endif // HAS_MESH
  3315. #if ENABLED(AUTO_BED_LEVELING_UBL) && !HAS_BED_PROBE
  3316. case UBLMesh:
  3317. #define UBL_M_BACK 0
  3318. #define UBL_M_NEXT (UBL_M_BACK + 1)
  3319. #define UBL_M_PREV (UBL_M_NEXT + 1)
  3320. #define UBL_M_OFFSET (UBL_M_PREV + 1)
  3321. #define UBL_M_UP (UBL_M_OFFSET + 1)
  3322. #define UBL_M_DOWN (UBL_M_UP + 1)
  3323. #define UBL_M_TOTAL UBL_M_DOWN
  3324. switch (item) {
  3325. case UBL_M_BACK:
  3326. if (draw)
  3327. Draw_Menu_Item(row, ICON_Back, "Back");
  3328. else {
  3329. set_bed_leveling_enabled(level_state);
  3330. Draw_Menu(Leveling, LEVELING_GET_MESH);
  3331. }
  3332. break;
  3333. case UBL_M_NEXT:
  3334. if (draw) {
  3335. if (mesh_conf.mesh_x != (GRID_MAX_POINTS_X - 1) || mesh_conf.mesh_y != (GRID_MAX_POINTS_Y - 1))
  3336. Draw_Menu_Item(row, ICON_More, "Next Point");
  3337. else
  3338. Draw_Menu_Item(row, ICON_More, "Save Mesh");
  3339. }
  3340. else {
  3341. if (mesh_conf.mesh_x != (GRID_MAX_POINTS_X - 1) || mesh_conf.mesh_y != (GRID_MAX_POINTS_Y - 1)) {
  3342. if ((mesh_conf.mesh_x == (GRID_MAX_POINTS_X - 1) && mesh_conf.mesh_y % 2 == 0) || (mesh_conf.mesh_x == 0 && mesh_conf.mesh_y % 2 == 1))
  3343. mesh_conf.mesh_y++;
  3344. else if (mesh_conf.mesh_y % 2 == 0)
  3345. mesh_conf.mesh_x++;
  3346. else
  3347. mesh_conf.mesh_x--;
  3348. mesh_conf.manual_move();
  3349. }
  3350. else {
  3351. gcode.process_subcommands_now_P(PSTR("G29 S"));
  3352. planner.synchronize();
  3353. AudioFeedback(true);
  3354. Draw_Menu(Leveling, LEVELING_GET_MESH);
  3355. }
  3356. }
  3357. break;
  3358. case UBL_M_PREV:
  3359. if (draw)
  3360. Draw_Menu_Item(row, ICON_More, "Previous Point");
  3361. else {
  3362. if (mesh_conf.mesh_x != 0 || mesh_conf.mesh_y != 0) {
  3363. if ((mesh_conf.mesh_x == (GRID_MAX_POINTS_X - 1) && mesh_conf.mesh_y % 2 == 1) || (mesh_conf.mesh_x == 0 && mesh_conf.mesh_y % 2 == 0))
  3364. mesh_conf.mesh_y--;
  3365. else if (mesh_conf.mesh_y % 2 == 0)
  3366. mesh_conf.mesh_x--;
  3367. else
  3368. mesh_conf.mesh_x++;
  3369. mesh_conf.manual_move();
  3370. }
  3371. }
  3372. break;
  3373. case UBL_M_OFFSET:
  3374. if (draw) {
  3375. Draw_Menu_Item(row, ICON_SetZOffset, "Point Z Offset");
  3376. Draw_Float(mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], row, false, 100);
  3377. }
  3378. else {
  3379. if (isnan(mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y]))
  3380. mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] = 0;
  3381. Modify_Value(mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], MIN_Z_OFFSET, MAX_Z_OFFSET, 100);
  3382. }
  3383. break;
  3384. case UBL_M_UP:
  3385. if (draw)
  3386. Draw_Menu_Item(row, ICON_Axis, "Microstep Up");
  3387. else if (mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] < MAX_Z_OFFSET) {
  3388. mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] += 0.01;
  3389. gcode.process_subcommands_now_P(PSTR("M290 Z0.01"));
  3390. planner.synchronize();
  3391. current_position.z += 0.01f;
  3392. sync_plan_position();
  3393. Draw_Float(mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 1, false, 100);
  3394. }
  3395. break;
  3396. case UBL_M_DOWN:
  3397. if (draw)
  3398. Draw_Menu_Item(row, ICON_Axis, "Microstep Down");
  3399. else if (mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] > MIN_Z_OFFSET) {
  3400. mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] -= 0.01;
  3401. gcode.process_subcommands_now_P(PSTR("M290 Z-0.01"));
  3402. planner.synchronize();
  3403. current_position.z -= 0.01f;
  3404. sync_plan_position();
  3405. Draw_Float(mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 2, false, 100);
  3406. }
  3407. break;
  3408. }
  3409. break;
  3410. #endif // AUTO_BED_LEVELING_UBL && !HAS_BED_PROBE
  3411. #if ENABLED(PROBE_MANUALLY)
  3412. case ManualMesh:
  3413. #define MMESH_BACK 0
  3414. #define MMESH_NEXT (MMESH_BACK + 1)
  3415. #define MMESH_OFFSET (MMESH_NEXT + 1)
  3416. #define MMESH_UP (MMESH_OFFSET + 1)
  3417. #define MMESH_DOWN (MMESH_UP + 1)
  3418. #define MMESH_OLD (MMESH_DOWN + 1)
  3419. #define MMESH_TOTAL MMESH_OLD
  3420. switch (item) {
  3421. case MMESH_BACK:
  3422. if (draw)
  3423. Draw_Menu_Item(row, ICON_Back, "Cancel");
  3424. else {
  3425. gcode.process_subcommands_now_P(PSTR("G29 A"));
  3426. planner.synchronize();
  3427. set_bed_leveling_enabled(level_state);
  3428. Draw_Menu(Leveling, LEVELING_GET_MESH);
  3429. }
  3430. break;
  3431. case MMESH_NEXT:
  3432. if (draw) {
  3433. if (gridpoint < GRID_MAX_POINTS)
  3434. Draw_Menu_Item(row, ICON_More, "Next Point");
  3435. else
  3436. Draw_Menu_Item(row, ICON_More, "Save Mesh");
  3437. }
  3438. else if (gridpoint < GRID_MAX_POINTS) {
  3439. Popup_Handler(MoveWait);
  3440. gcode.process_subcommands_now_P(PSTR("G29"));
  3441. planner.synchronize();
  3442. gridpoint++;
  3443. Redraw_Menu();
  3444. }
  3445. else {
  3446. gcode.process_subcommands_now_P(PSTR("G29"));
  3447. planner.synchronize();
  3448. AudioFeedback(settings.save());
  3449. Draw_Menu(Leveling, LEVELING_GET_MESH);
  3450. }
  3451. break;
  3452. case MMESH_OFFSET:
  3453. if (draw) {
  3454. Draw_Menu_Item(row, ICON_SetZOffset, "Z Position");
  3455. current_position.z = MANUAL_PROBE_START_Z;
  3456. Draw_Float(current_position.z, row, false, 100);
  3457. }
  3458. else
  3459. Modify_Value(current_position.z, MIN_Z_OFFSET, MAX_Z_OFFSET, 100);
  3460. break;
  3461. case MMESH_UP:
  3462. if (draw)
  3463. Draw_Menu_Item(row, ICON_Axis, "Microstep Up");
  3464. else if (current_position.z < MAX_Z_OFFSET) {
  3465. gcode.process_subcommands_now_P(PSTR("M290 Z0.01"));
  3466. planner.synchronize();
  3467. current_position.z += 0.01f;
  3468. sync_plan_position();
  3469. Draw_Float(current_position.z, row - 1, false, 100);
  3470. }
  3471. break;
  3472. case MMESH_DOWN:
  3473. if (draw)
  3474. Draw_Menu_Item(row, ICON_AxisD, "Microstep Down");
  3475. else if (current_position.z > MIN_Z_OFFSET) {
  3476. gcode.process_subcommands_now_P(PSTR("M290 Z-0.01"));
  3477. planner.synchronize();
  3478. current_position.z -= 0.01f;
  3479. sync_plan_position();
  3480. Draw_Float(current_position.z, row - 2, false, 100);
  3481. }
  3482. break;
  3483. case MMESH_OLD:
  3484. uint8_t mesh_x, mesh_y;
  3485. // 0,0 -> 1,0 -> 2,0 -> 2,1 -> 1,1 -> 0,1 -> 0,2 -> 1,2 -> 2,2
  3486. mesh_y = (gridpoint - 1) / GRID_MAX_POINTS_Y;
  3487. mesh_x = (gridpoint - 1) % GRID_MAX_POINTS_X;
  3488. if (mesh_y % 2 == 1)
  3489. mesh_x = GRID_MAX_POINTS_X - mesh_x - 1;
  3490. const float currval = mesh_conf.mesh_z_values[mesh_x][mesh_y];
  3491. if (draw) {
  3492. Draw_Menu_Item(row, ICON_Zoffset, "Goto Mesh Value");
  3493. Draw_Float(currval, row, false, 100);
  3494. }
  3495. else if (!isnan(currval)) {
  3496. current_position.z = currval;
  3497. planner.synchronize();
  3498. planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder);
  3499. planner.synchronize();
  3500. Draw_Float(current_position.z, row - 3, false, 100);
  3501. }
  3502. break;
  3503. }
  3504. break;
  3505. #endif // PROBE_MANUALLY
  3506. case Tune:
  3507. #define TUNE_BACK 0
  3508. #define TUNE_SPEED (TUNE_BACK + 1)
  3509. #define TUNE_FLOW (TUNE_SPEED + ENABLED(HAS_HOTEND))
  3510. #define TUNE_HOTEND (TUNE_FLOW + ENABLED(HAS_HOTEND))
  3511. #define TUNE_BED (TUNE_HOTEND + ENABLED(HAS_HEATED_BED))
  3512. #define TUNE_FAN (TUNE_BED + ENABLED(HAS_FAN))
  3513. #define TUNE_ZOFFSET (TUNE_FAN + ENABLED(HAS_ZOFFSET_ITEM))
  3514. #define TUNE_ZUP (TUNE_ZOFFSET + ENABLED(HAS_ZOFFSET_ITEM))
  3515. #define TUNE_ZDOWN (TUNE_ZUP + ENABLED(HAS_ZOFFSET_ITEM))
  3516. #define TUNE_CHANGEFIL (TUNE_ZDOWN + ENABLED(FILAMENT_LOAD_UNLOAD_GCODES))
  3517. #define TUNE_FILSENSORENABLED (TUNE_CHANGEFIL + ENABLED(FILAMENT_RUNOUT_SENSOR))
  3518. #define TUNE_BACKLIGHT_OFF (TUNE_FILSENSORENABLED + 1)
  3519. #define TUNE_BACKLIGHT (TUNE_BACKLIGHT_OFF + 1)
  3520. #define TUNE_TOTAL TUNE_BACKLIGHT
  3521. switch (item) {
  3522. case TUNE_BACK:
  3523. if (draw)
  3524. Draw_Menu_Item(row, ICON_Back, "Back");
  3525. else
  3526. Draw_Print_Screen();
  3527. break;
  3528. case TUNE_SPEED:
  3529. if (draw) {
  3530. Draw_Menu_Item(row, ICON_Speed, "Print Speed");
  3531. Draw_Float(feedrate_percentage, row, false, 1);
  3532. }
  3533. else
  3534. Modify_Value(feedrate_percentage, MIN_PRINT_SPEED, MAX_PRINT_SPEED, 1);
  3535. break;
  3536. #if HAS_HOTEND
  3537. case TUNE_FLOW:
  3538. if (draw) {
  3539. Draw_Menu_Item(row, ICON_Speed, "Flow Rate");
  3540. Draw_Float(planner.flow_percentage[0], row, false, 1);
  3541. }
  3542. else
  3543. Modify_Value(planner.flow_percentage[0], MIN_FLOW_RATE, MAX_FLOW_RATE, 1);
  3544. break;
  3545. case TUNE_HOTEND:
  3546. if (draw) {
  3547. Draw_Menu_Item(row, ICON_SetEndTemp, "Hotend");
  3548. Draw_Float(thermalManager.temp_hotend[0].target, row, false, 1);
  3549. }
  3550. else
  3551. Modify_Value(thermalManager.temp_hotend[0].target, MIN_E_TEMP, MAX_E_TEMP, 1);
  3552. break;
  3553. #endif
  3554. #if HAS_HEATED_BED
  3555. case TUNE_BED:
  3556. if (draw) {
  3557. Draw_Menu_Item(row, ICON_SetBedTemp, "Bed");
  3558. Draw_Float(thermalManager.temp_bed.target, row, false, 1);
  3559. }
  3560. else
  3561. Modify_Value(thermalManager.temp_bed.target, MIN_BED_TEMP, MAX_BED_TEMP, 1);
  3562. break;
  3563. #endif
  3564. #if HAS_FAN
  3565. case TUNE_FAN:
  3566. if (draw) {
  3567. Draw_Menu_Item(row, ICON_FanSpeed, "Fan");
  3568. Draw_Float(thermalManager.fan_speed[0], row, false, 1);
  3569. }
  3570. else
  3571. Modify_Value(thermalManager.fan_speed[0], MIN_FAN_SPEED, MAX_FAN_SPEED, 1);
  3572. break;
  3573. #endif
  3574. #if HAS_ZOFFSET_ITEM
  3575. case TUNE_ZOFFSET:
  3576. if (draw) {
  3577. Draw_Menu_Item(row, ICON_FanSpeed, "Z-Offset");
  3578. Draw_Float(zoffsetvalue, row, false, 100);
  3579. }
  3580. else
  3581. Modify_Value(zoffsetvalue, MIN_Z_OFFSET, MAX_Z_OFFSET, 100);
  3582. break;
  3583. case TUNE_ZUP:
  3584. if (draw)
  3585. Draw_Menu_Item(row, ICON_Axis, "Z-Offset Up");
  3586. else if (zoffsetvalue < MAX_Z_OFFSET) {
  3587. gcode.process_subcommands_now_P(PSTR("M290 Z0.01"));
  3588. zoffsetvalue += 0.01;
  3589. Draw_Float(zoffsetvalue, row - 1, false, 100);
  3590. }
  3591. break;
  3592. case TUNE_ZDOWN:
  3593. if (draw)
  3594. Draw_Menu_Item(row, ICON_AxisD, "Z-Offset Down");
  3595. else if (zoffsetvalue > MIN_Z_OFFSET) {
  3596. gcode.process_subcommands_now_P(PSTR("M290 Z-0.01"));
  3597. zoffsetvalue -= 0.01;
  3598. Draw_Float(zoffsetvalue, row - 2, false, 100);
  3599. }
  3600. break;
  3601. #endif
  3602. #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
  3603. case TUNE_CHANGEFIL:
  3604. if (draw)
  3605. Draw_Menu_Item(row, ICON_ResumeEEPROM, "Change Filament");
  3606. else
  3607. Popup_Handler(ConfFilChange);
  3608. break;
  3609. #endif
  3610. #if ENABLED(FILAMENT_RUNOUT_SENSOR)
  3611. case TUNE_FILSENSORENABLED:
  3612. if (draw) {
  3613. Draw_Menu_Item(row, ICON_Extruder, "Filament Sensor");
  3614. Draw_Checkbox(row, runout.enabled);
  3615. }
  3616. else {
  3617. runout.enabled = !runout.enabled;
  3618. Draw_Checkbox(row, runout.enabled);
  3619. }
  3620. break;
  3621. #endif
  3622. case TUNE_BACKLIGHT_OFF:
  3623. if (draw)
  3624. Draw_Menu_Item(row, ICON_Brightness, "Display Off");
  3625. else
  3626. ui.set_brightness(0);
  3627. break;
  3628. case TUNE_BACKLIGHT:
  3629. if (draw) {
  3630. Draw_Menu_Item(row, ICON_Brightness, "LCD Brightness");
  3631. Draw_Float(ui.brightness, row, false, 1);
  3632. }
  3633. else
  3634. Modify_Value(ui.brightness, MIN_LCD_BRIGHTNESS, MAX_LCD_BRIGHTNESS, 1, ui.refresh_brightness);
  3635. break;
  3636. }
  3637. break;
  3638. case PreheatHotend:
  3639. #define PREHEATHOTEND_BACK 0
  3640. #define PREHEATHOTEND_CONTINUE (PREHEATHOTEND_BACK + 1)
  3641. #define PREHEATHOTEND_1 (PREHEATHOTEND_CONTINUE + (PREHEAT_COUNT >= 1))
  3642. #define PREHEATHOTEND_2 (PREHEATHOTEND_1 + (PREHEAT_COUNT >= 2))
  3643. #define PREHEATHOTEND_3 (PREHEATHOTEND_2 + (PREHEAT_COUNT >= 3))
  3644. #define PREHEATHOTEND_4 (PREHEATHOTEND_3 + (PREHEAT_COUNT >= 4))
  3645. #define PREHEATHOTEND_5 (PREHEATHOTEND_4 + (PREHEAT_COUNT >= 5))
  3646. #define PREHEATHOTEND_CUSTOM (PREHEATHOTEND_5 + 1)
  3647. #define PREHEATHOTEND_TOTAL PREHEATHOTEND_CUSTOM
  3648. switch (item) {
  3649. case PREHEATHOTEND_BACK:
  3650. if (draw)
  3651. Draw_Menu_Item(row, ICON_Back, "Cancel");
  3652. else {
  3653. thermalManager.setTargetHotend(0, 0);
  3654. thermalManager.set_fan_speed(0, 0);
  3655. Redraw_Menu(false, true, true);
  3656. }
  3657. break;
  3658. case PREHEATHOTEND_CONTINUE:
  3659. if (draw)
  3660. Draw_Menu_Item(row, ICON_SetEndTemp, "Continue");
  3661. else {
  3662. Popup_Handler(Heating);
  3663. thermalManager.wait_for_hotend(0);
  3664. switch (last_menu) {
  3665. case Prepare:
  3666. Popup_Handler(FilChange);
  3667. sprintf_P(cmd, PSTR("M600 B1 R%i"), thermalManager.temp_hotend[0].target);
  3668. gcode.process_subcommands_now_P(cmd);
  3669. break;
  3670. #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
  3671. case ChangeFilament:
  3672. switch (last_selection) {
  3673. case CHANGEFIL_LOAD:
  3674. Popup_Handler(FilLoad);
  3675. gcode.process_subcommands_now_P("M701");
  3676. planner.synchronize();
  3677. Redraw_Menu(true, true, true);
  3678. break;
  3679. case CHANGEFIL_UNLOAD:
  3680. Popup_Handler(FilLoad, true);
  3681. gcode.process_subcommands_now_P("M702");
  3682. planner.synchronize();
  3683. Redraw_Menu(true, true, true);
  3684. break;
  3685. case CHANGEFIL_CHANGE:
  3686. Popup_Handler(FilChange);
  3687. sprintf_P(cmd, PSTR("M600 B1 R%i"), thermalManager.temp_hotend[0].target);
  3688. gcode.process_subcommands_now_P(cmd);
  3689. break;
  3690. }
  3691. break;
  3692. #endif
  3693. default:
  3694. Redraw_Menu(true, true, true);
  3695. break;
  3696. }
  3697. }
  3698. break;
  3699. #if PREHEAT_COUNT >= 1
  3700. case PREHEATHOTEND_1:
  3701. if (draw)
  3702. Draw_Menu_Item(row, ICON_Temperature, PREHEAT_1_LABEL);
  3703. else {
  3704. thermalManager.setTargetHotend(ui.material_preset[0].hotend_temp, 0);
  3705. thermalManager.set_fan_speed(0, ui.material_preset[0].fan_speed);
  3706. }
  3707. break;
  3708. #endif
  3709. #if PREHEAT_COUNT >= 2
  3710. case PREHEATHOTEND_2:
  3711. if (draw)
  3712. Draw_Menu_Item(row, ICON_Temperature, PREHEAT_2_LABEL);
  3713. else {
  3714. thermalManager.setTargetHotend(ui.material_preset[1].hotend_temp, 0);
  3715. thermalManager.set_fan_speed(0, ui.material_preset[1].fan_speed);
  3716. }
  3717. break;
  3718. #endif
  3719. #if PREHEAT_COUNT >= 3
  3720. case PREHEATHOTEND_3:
  3721. if (draw)
  3722. Draw_Menu_Item(row, ICON_Temperature, PREHEAT_3_LABEL);
  3723. else {
  3724. thermalManager.setTargetHotend(ui.material_preset[2].hotend_temp, 0);
  3725. thermalManager.set_fan_speed(0, ui.material_preset[2].fan_speed);
  3726. }
  3727. break;
  3728. #endif
  3729. #if PREHEAT_COUNT >= 4
  3730. case PREHEATHOTEND_4:
  3731. if (draw)
  3732. Draw_Menu_Item(row, ICON_Temperature, PREHEAT_4_LABEL);
  3733. else {
  3734. thermalManager.setTargetHotend(ui.material_preset[3].hotend_temp, 0);
  3735. thermalManager.set_fan_speed(0, ui.material_preset[3].fan_speed);
  3736. }
  3737. break;
  3738. #endif
  3739. #if PREHEAT_COUNT >= 5
  3740. case PREHEATHOTEND_5:
  3741. if (draw)
  3742. Draw_Menu_Item(row, ICON_Temperature, PREHEAT_5_LABEL);
  3743. else {
  3744. thermalManager.setTargetHotend(ui.material_preset[4].hotend_temp, 0);
  3745. thermalManager.set_fan_speed(0, ui.material_preset[4].fan_speed);
  3746. }
  3747. break;
  3748. #endif
  3749. case PREHEATHOTEND_CUSTOM:
  3750. if (draw) {
  3751. Draw_Menu_Item(row, ICON_Temperature, "Custom");
  3752. Draw_Float(thermalManager.temp_hotend[0].target, row, false, 1);
  3753. }
  3754. else
  3755. Modify_Value(thermalManager.temp_hotend[0].target, EXTRUDE_MINTEMP, MAX_E_TEMP, 1);
  3756. break;
  3757. }
  3758. break;
  3759. }
  3760. }
  3761. const char * CrealityDWINClass::Get_Menu_Title(uint8_t menu) {
  3762. switch (menu) {
  3763. case MainMenu: return "Main Menu";
  3764. case Prepare: return "Prepare";
  3765. case HomeMenu: return "Homing Menu";
  3766. case Move: return "Move";
  3767. case ManualLevel: return "Manual Leveling";
  3768. #if HAS_ZOFFSET_ITEM
  3769. case ZOffset: return "Z Offset";
  3770. #endif
  3771. #if HAS_PREHEAT
  3772. case Preheat: return "Preheat";
  3773. #endif
  3774. #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
  3775. case ChangeFilament: return "Change Filament";
  3776. #endif
  3777. case Control: return "Control";
  3778. case TempMenu: return "Temperature";
  3779. #if HAS_HOTEND || HAS_HEATED_BED
  3780. case PID: return "PID Menu";
  3781. #endif
  3782. #if HAS_HOTEND
  3783. case HotendPID: return "Hotend PID Settings";
  3784. #endif
  3785. #if HAS_HEATED_BED
  3786. case BedPID: return "Bed PID Settings";
  3787. #endif
  3788. #if PREHEAT_COUNT >= 1
  3789. case Preheat1: return (PREHEAT_1_LABEL " Settings");
  3790. #endif
  3791. #if PREHEAT_COUNT >= 2
  3792. case Preheat2: return (PREHEAT_2_LABEL " Settings");
  3793. #endif
  3794. #if PREHEAT_COUNT >= 3
  3795. case Preheat3: return (PREHEAT_3_LABEL " Settings");
  3796. #endif
  3797. #if PREHEAT_COUNT >= 4
  3798. case Preheat4: return (PREHEAT_4_LABEL " Settings");
  3799. #endif
  3800. #if PREHEAT_COUNT >= 5
  3801. case Preheat5: return (PREHEAT_5_LABEL " Settings");
  3802. #endif
  3803. case Motion: return "Motion Settings";
  3804. case HomeOffsets: return "Home Offsets";
  3805. case MaxSpeed: return "Max Speed";
  3806. case MaxAcceleration: return "Max Acceleration";
  3807. #if HAS_CLASSIC_JERK
  3808. case MaxJerk: return "Max Jerk";
  3809. #endif
  3810. case Steps: return "Steps/mm";
  3811. case Visual: return "Visual Settings";
  3812. case Advanced: return "Advanced Settings";
  3813. #if HAS_BED_PROBE
  3814. case ProbeMenu: return "Probe Menu";
  3815. #endif
  3816. case ColorSettings: return "UI Color Settings";
  3817. case Info: return "Info";
  3818. case InfoMain: return "Info";
  3819. #if HAS_MESH
  3820. case Leveling: return "Leveling";
  3821. case LevelView: return "Mesh View";
  3822. case LevelSettings: return "Leveling Settings";
  3823. case MeshViewer: return "Mesh Viewer";
  3824. case LevelManual: return "Manual Tuning";
  3825. #endif
  3826. #if ENABLED(AUTO_BED_LEVELING_UBL) && !HAS_BED_PROBE
  3827. case UBLMesh: return "UBL Bed Leveling";
  3828. #endif
  3829. #if ENABLED(PROBE_MANUALLY)
  3830. case ManualMesh: return "Mesh Bed Leveling";
  3831. #endif
  3832. case Tune: return "Tune";
  3833. case PreheatHotend: return "Preheat Hotend";
  3834. }
  3835. return "";
  3836. }
  3837. uint8_t CrealityDWINClass::Get_Menu_Size(uint8_t menu) {
  3838. switch (menu) {
  3839. case Prepare: return PREPARE_TOTAL;
  3840. case HomeMenu: return HOME_TOTAL;
  3841. case Move: return MOVE_TOTAL;
  3842. case ManualLevel: return MLEVEL_TOTAL;
  3843. #if HAS_ZOFFSET_ITEM
  3844. case ZOffset: return ZOFFSET_TOTAL;
  3845. #endif
  3846. #if HAS_PREHEAT
  3847. case Preheat: return PREHEAT_TOTAL;
  3848. #endif
  3849. #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
  3850. case ChangeFilament: return CHANGEFIL_TOTAL;
  3851. #endif
  3852. case Control: return CONTROL_TOTAL;
  3853. case TempMenu: return TEMP_TOTAL;
  3854. #if HAS_HOTEND || HAS_HEATED_BED
  3855. case PID: return PID_TOTAL;
  3856. #endif
  3857. #if HAS_HOTEND
  3858. case HotendPID: return HOTENDPID_TOTAL;
  3859. #endif
  3860. #if HAS_HEATED_BED
  3861. case BedPID: return BEDPID_TOTAL;
  3862. #endif
  3863. #if PREHEAT_COUNT >= 1
  3864. case Preheat1: return PREHEAT1_TOTAL;
  3865. #endif
  3866. #if PREHEAT_COUNT >= 2
  3867. case Preheat2: return PREHEAT2_TOTAL;
  3868. #endif
  3869. #if PREHEAT_COUNT >= 3
  3870. case Preheat3: return PREHEAT3_TOTAL;
  3871. #endif
  3872. #if PREHEAT_COUNT >= 4
  3873. case Preheat4: return PREHEAT4_TOTAL;
  3874. #endif
  3875. #if PREHEAT_COUNT >= 5
  3876. case Preheat5: return PREHEAT5_TOTAL;
  3877. #endif
  3878. case Motion: return MOTION_TOTAL;
  3879. case HomeOffsets: return HOMEOFFSETS_TOTAL;
  3880. case MaxSpeed: return SPEED_TOTAL;
  3881. case MaxAcceleration: return ACCEL_TOTAL;
  3882. #if HAS_CLASSIC_JERK
  3883. case MaxJerk: return JERK_TOTAL;
  3884. #endif
  3885. case Steps: return STEPS_TOTAL;
  3886. case Visual: return VISUAL_TOTAL;
  3887. case Advanced: return ADVANCED_TOTAL;
  3888. #if HAS_BED_PROBE
  3889. case ProbeMenu: return PROBE_TOTAL;
  3890. #endif
  3891. case Info: return INFO_TOTAL;
  3892. case InfoMain: return INFO_TOTAL;
  3893. #if ENABLED(AUTO_BED_LEVELING_UBL) && !HAS_BED_PROBE
  3894. case UBLMesh: return UBL_M_TOTAL;
  3895. #endif
  3896. #if ENABLED(PROBE_MANUALLY)
  3897. case ManualMesh: return MMESH_TOTAL;
  3898. #endif
  3899. #if HAS_MESH
  3900. case Leveling: return LEVELING_TOTAL;
  3901. case LevelView: return LEVELING_VIEW_TOTAL;
  3902. case LevelSettings: return LEVELING_SETTINGS_TOTAL;
  3903. case MeshViewer: return MESHVIEW_TOTAL;
  3904. case LevelManual: return LEVELING_M_TOTAL;
  3905. #endif
  3906. case Tune: return TUNE_TOTAL;
  3907. case PreheatHotend: return PREHEATHOTEND_TOTAL;
  3908. case ColorSettings: return COLORSETTINGS_TOTAL;
  3909. }
  3910. return 0;
  3911. }
  3912. /* Popup Config */
  3913. void CrealityDWINClass::Popup_Handler(PopupID popupid, bool option/*=false*/) {
  3914. popup = last_popup = popupid;
  3915. switch (popupid) {
  3916. case Pause: Draw_Popup(PSTR("Pause Print"), PSTR(""), PSTR(""), Popup); break;
  3917. case Stop: Draw_Popup(PSTR("Stop Print"), PSTR(""), PSTR(""), Popup); break;
  3918. case Resume: Draw_Popup(PSTR("Resume Print?"), PSTR("Looks Like the last"), PSTR("print was interupted."), Popup); break;
  3919. case ConfFilChange: Draw_Popup(PSTR("Confirm Filament Change"), PSTR(""), PSTR(""), Popup); break;
  3920. case PurgeMore: Draw_Popup(PSTR("Purge more filament?"), PSTR("(Cancel to finish process)"), PSTR(""), Popup); break;
  3921. case SaveLevel: Draw_Popup(PSTR("Leveling Complete"), PSTR("Save to EEPROM?"), PSTR(""), Popup); break;
  3922. case MeshSlot: Draw_Popup(PSTR("Mesh slot not selected"), PSTR("(Confirm to select slot 0)"), PSTR(""), Popup); break;
  3923. case ETemp: Draw_Popup(PSTR("Nozzle is too cold"), PSTR("Open Preheat Menu?"), PSTR(""), Popup); break;
  3924. case ManualProbing: Draw_Popup(PSTR("Manual Probing"), PSTR("(Confirm to probe)"), PSTR("(cancel to exit)"), Popup); break;
  3925. case Level: Draw_Popup(PSTR("Auto Bed Leveling"), PSTR("Please wait until done."), PSTR(""), Wait, ICON_AutoLeveling); break;
  3926. case Home: Draw_Popup(option ? PSTR("Parking") : PSTR("Homing"), PSTR("Please wait until done."), PSTR(""), Wait, ICON_BLTouch); break;
  3927. case MoveWait: Draw_Popup(PSTR("Moving to Point"), PSTR("Please wait until done."), PSTR(""), Wait, ICON_BLTouch); break;
  3928. case Heating: Draw_Popup(PSTR("Heating"), PSTR("Please wait until done."), PSTR(""), Wait, ICON_BLTouch); break;
  3929. case FilLoad: Draw_Popup(option ? PSTR("Unloading Filament") : PSTR("Loading Filament"), PSTR("Please wait until done."), PSTR(""), Wait, ICON_BLTouch); break;
  3930. case FilChange: Draw_Popup(PSTR("Filament Change"), PSTR("Please wait for prompt."), PSTR(""), Wait, ICON_BLTouch); break;
  3931. case TempWarn: Draw_Popup(option ? PSTR("Nozzle temp too low!") : PSTR("Nozzle temp too high!"), PSTR(""), PSTR(""), Wait, option ? ICON_TempTooLow : ICON_TempTooHigh); break;
  3932. case Runout: Draw_Popup(PSTR("Filament Runout"), PSTR(""), PSTR(""), Wait, ICON_BLTouch); break;
  3933. case PIDWait: Draw_Popup(PSTR("PID Autotune"), PSTR("in process"), PSTR("Please wait until done."), Wait, ICON_BLTouch); break;
  3934. case Resuming: Draw_Popup(PSTR("Resuming Print"), PSTR("Please wait until done."), PSTR(""), Wait, ICON_BLTouch); break;
  3935. default: break;
  3936. }
  3937. }
  3938. void CrealityDWINClass::Confirm_Handler(PopupID popupid) {
  3939. popup = popupid;
  3940. switch (popupid) {
  3941. case FilInsert: Draw_Popup(PSTR("Insert Filament"), PSTR("Press to Continue"), PSTR(""), Confirm); break;
  3942. case HeaterTime: Draw_Popup(PSTR("Heater Timed Out"), PSTR("Press to Reheat"), PSTR(""), Confirm); break;
  3943. case UserInput: Draw_Popup(PSTR("Waiting for Input"), PSTR("Press to Continue"), PSTR(""), Confirm); break;
  3944. case LevelError: Draw_Popup(PSTR("Couldn't enable Leveling"), PSTR("(Valid mesh must exist)"), PSTR(""), Confirm); break;
  3945. case InvalidMesh: Draw_Popup(PSTR("Valid mesh must exist"), PSTR("before tuning can be"), PSTR("performed"), Confirm); break;
  3946. default: break;
  3947. }
  3948. }
  3949. /* Navigation and Control */
  3950. void CrealityDWINClass::Main_Menu_Control() {
  3951. ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
  3952. if (encoder_diffState == ENCODER_DIFF_NO) return;
  3953. if (encoder_diffState == ENCODER_DIFF_CW && selection < 3) {
  3954. selection++; // Select Down
  3955. Main_Menu_Icons();
  3956. }
  3957. else if (encoder_diffState == ENCODER_DIFF_CCW && selection > 0) {
  3958. selection--; // Select Up
  3959. Main_Menu_Icons();
  3960. }
  3961. else if (encoder_diffState == ENCODER_DIFF_ENTER)
  3962. switch (selection) {
  3963. case 0: card.mount(); Draw_SD_List(); break;
  3964. case 1: Draw_Menu(Prepare); break;
  3965. case 2: Draw_Menu(Control); break;
  3966. case 3: Draw_Menu(TERN(HAS_MESH, Leveling, InfoMain)); break;
  3967. }
  3968. DWIN_UpdateLCD();
  3969. }
  3970. void CrealityDWINClass::Menu_Control() {
  3971. ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
  3972. if (encoder_diffState == ENCODER_DIFF_NO) return;
  3973. if (encoder_diffState == ENCODER_DIFF_CW && selection < Get_Menu_Size(active_menu)) {
  3974. DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33);
  3975. selection++; // Select Down
  3976. if (selection > scrollpos+MROWS) {
  3977. scrollpos++;
  3978. DWIN_Frame_AreaMove(1, 2, MLINE, Color_Bg_Black, 0, 31, DWIN_WIDTH, 349);
  3979. Menu_Item_Handler(active_menu, selection);
  3980. }
  3981. DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Rectangle_Color), 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33);
  3982. }
  3983. else if (encoder_diffState == ENCODER_DIFF_CCW && selection > 0) {
  3984. DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33);
  3985. selection--; // Select Up
  3986. if (selection < scrollpos) {
  3987. scrollpos--;
  3988. DWIN_Frame_AreaMove(1, 3, MLINE, Color_Bg_Black, 0, 31, DWIN_WIDTH, 349);
  3989. Menu_Item_Handler(active_menu, selection);
  3990. }
  3991. DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Rectangle_Color), 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33);
  3992. }
  3993. else if (encoder_diffState == ENCODER_DIFF_ENTER)
  3994. Menu_Item_Handler(active_menu, selection, false);
  3995. DWIN_UpdateLCD();
  3996. }
  3997. void CrealityDWINClass::Value_Control() {
  3998. ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
  3999. if (encoder_diffState == ENCODER_DIFF_NO) return;
  4000. if (encoder_diffState == ENCODER_DIFF_CW)
  4001. tempvalue += EncoderRate.encoderMoveValue;
  4002. else if (encoder_diffState == ENCODER_DIFF_CCW)
  4003. tempvalue -= EncoderRate.encoderMoveValue;
  4004. else if (encoder_diffState == ENCODER_DIFF_ENTER) {
  4005. process = Menu;
  4006. EncoderRate.enabled = false;
  4007. Draw_Float(tempvalue / valueunit, selection - scrollpos, false, valueunit);
  4008. DWIN_UpdateLCD();
  4009. if (active_menu == ZOffset && liveadjust) {
  4010. planner.synchronize();
  4011. current_position.z += (tempvalue / valueunit - zoffsetvalue);
  4012. planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder);
  4013. current_position.z = 0;
  4014. sync_plan_position();
  4015. }
  4016. else if (active_menu == Tune && selection == TUNE_ZOFFSET) {
  4017. sprintf_P(cmd, PSTR("M290 Z%s"), dtostrf((tempvalue / valueunit - zoffsetvalue), 1, 3, str_1));
  4018. gcode.process_subcommands_now_P(cmd);
  4019. }
  4020. if (TERN0(HAS_HOTEND, valuepointer == &thermalManager.temp_hotend[0].pid.Ki) || TERN0(HAS_HEATED_BED, valuepointer == &thermalManager.temp_bed.pid.Ki))
  4021. tempvalue = scalePID_i(tempvalue);
  4022. if (TERN0(HAS_HOTEND, valuepointer == &thermalManager.temp_hotend[0].pid.Kd) || TERN0(HAS_HEATED_BED, valuepointer == &thermalManager.temp_bed.pid.Kd))
  4023. tempvalue = scalePID_d(tempvalue);
  4024. switch (valuetype) {
  4025. case 0: *(float*)valuepointer = tempvalue / valueunit; break;
  4026. case 1: *(uint8_t*)valuepointer = tempvalue / valueunit; break;
  4027. case 2: *(uint16_t*)valuepointer = tempvalue / valueunit; break;
  4028. case 3: *(int16_t*)valuepointer = tempvalue / valueunit; break;
  4029. case 4: *(uint32_t*)valuepointer = tempvalue / valueunit; break;
  4030. case 5: *(int8_t*)valuepointer = tempvalue / valueunit; break;
  4031. }
  4032. switch (active_menu) {
  4033. case Move:
  4034. planner.synchronize();
  4035. planner.buffer_line(current_position, manual_feedrate_mm_s[selection - 1], active_extruder);
  4036. break;
  4037. #if HAS_MESH
  4038. case ManualMesh:
  4039. planner.synchronize();
  4040. planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder);
  4041. planner.synchronize();
  4042. break;
  4043. case UBLMesh: mesh_conf.manual_move(true); break;
  4044. case LevelManual: mesh_conf.manual_move(selection == LEVELING_M_OFFSET); break;
  4045. #endif
  4046. }
  4047. if (valuepointer == &planner.flow_percentage[0])
  4048. planner.refresh_e_factor(0);
  4049. if (funcpointer) funcpointer();
  4050. return;
  4051. }
  4052. NOLESS(tempvalue, (valuemin * valueunit));
  4053. NOMORE(tempvalue, (valuemax * valueunit));
  4054. Draw_Float(tempvalue / valueunit, selection - scrollpos, true, valueunit);
  4055. DWIN_UpdateLCD();
  4056. if (active_menu == Move && livemove) {
  4057. *(float*)valuepointer = tempvalue / valueunit;
  4058. planner.buffer_line(current_position, manual_feedrate_mm_s[selection - 1], active_extruder);
  4059. }
  4060. }
  4061. void CrealityDWINClass::Option_Control() {
  4062. ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
  4063. if (encoder_diffState == ENCODER_DIFF_NO) return;
  4064. if (encoder_diffState == ENCODER_DIFF_CW)
  4065. tempvalue += EncoderRate.encoderMoveValue;
  4066. else if (encoder_diffState == ENCODER_DIFF_CCW)
  4067. tempvalue -= EncoderRate.encoderMoveValue;
  4068. else if (encoder_diffState == ENCODER_DIFF_ENTER) {
  4069. process = Menu;
  4070. EncoderRate.enabled = false;
  4071. if (valuepointer == &color_names) {
  4072. switch (selection) {
  4073. case COLORSETTINGS_CURSOR: eeprom_settings.cursor_color = tempvalue; break;
  4074. case COLORSETTINGS_SPLIT_LINE: eeprom_settings.menu_split_line = tempvalue; break;
  4075. case COLORSETTINGS_MENU_TOP_BG: eeprom_settings.menu_top_bg = tempvalue; break;
  4076. case COLORSETTINGS_MENU_TOP_TXT: eeprom_settings.menu_top_txt = tempvalue; break;
  4077. case COLORSETTINGS_HIGHLIGHT_BORDER: eeprom_settings.highlight_box = tempvalue; break;
  4078. case COLORSETTINGS_PROGRESS_PERCENT: eeprom_settings.progress_percent = tempvalue; break;
  4079. case COLORSETTINGS_PROGRESS_TIME: eeprom_settings.progress_time = tempvalue; break;
  4080. case COLORSETTINGS_PROGRESS_STATUS_BAR: eeprom_settings.status_bar_text = tempvalue; break;
  4081. case COLORSETTINGS_PROGRESS_STATUS_AREA: eeprom_settings.status_area_text = tempvalue; break;
  4082. case COLORSETTINGS_PROGRESS_COORDINATES: eeprom_settings.coordinates_text = tempvalue; break;
  4083. case COLORSETTINGS_PROGRESS_COORDINATES_LINE: eeprom_settings.coordinates_split_line = tempvalue; break;
  4084. }
  4085. Redraw_Screen();
  4086. }
  4087. else if (valuepointer == &preheat_modes)
  4088. preheatmode = tempvalue;
  4089. Draw_Option(tempvalue, static_cast<const char * const *>(valuepointer), selection - scrollpos, false, (valuepointer == &color_names));
  4090. DWIN_UpdateLCD();
  4091. return;
  4092. }
  4093. NOLESS(tempvalue, valuemin);
  4094. NOMORE(tempvalue, valuemax);
  4095. Draw_Option(tempvalue, static_cast<const char * const *>(valuepointer), selection - scrollpos, true);
  4096. DWIN_UpdateLCD();
  4097. }
  4098. void CrealityDWINClass::File_Control() {
  4099. ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
  4100. static uint8_t filescrl = 0;
  4101. if (encoder_diffState == ENCODER_DIFF_NO) {
  4102. if (selection > 0) {
  4103. card.getfilename_sorted(SD_ORDER(selection - 1, card.get_num_Files()));
  4104. char * const filename = card.longest_filename();
  4105. size_t len = strlen(filename);
  4106. int8_t pos = len;
  4107. if (!card.flag.filenameIsDir)
  4108. while (pos && filename[pos] != '.') pos--;
  4109. if (pos > MENU_CHAR_LIMIT) {
  4110. static millis_t time = 0;
  4111. if (PENDING(millis(), time)) return;
  4112. time = millis() + 200;
  4113. pos -= filescrl;
  4114. len = _MIN(pos, MENU_CHAR_LIMIT);
  4115. char name[len + 1];
  4116. if (pos >= 0) {
  4117. LOOP_L_N(i, len) name[i] = filename[i + filescrl];
  4118. }
  4119. else {
  4120. LOOP_L_N(i, MENU_CHAR_LIMIT + pos) name[i] = ' ';
  4121. LOOP_S_L_N(i, MENU_CHAR_LIMIT + pos, MENU_CHAR_LIMIT) name[i] = filename[i - (MENU_CHAR_LIMIT + pos)];
  4122. }
  4123. name[len] = '\0';
  4124. DWIN_Draw_Rectangle(1, Color_Bg_Black, LBLX, MBASE(selection - scrollpos) - 14, 271, MBASE(selection - scrollpos) + 28);
  4125. Draw_Menu_Item(selection - scrollpos, card.flag.filenameIsDir ? ICON_More : ICON_File, name);
  4126. if (-pos >= MENU_CHAR_LIMIT) filescrl = 0;
  4127. filescrl++;
  4128. DWIN_UpdateLCD();
  4129. }
  4130. }
  4131. return;
  4132. }
  4133. if (encoder_diffState == ENCODER_DIFF_CW && selection < card.get_num_Files()) {
  4134. DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33);
  4135. if (selection > 0) {
  4136. DWIN_Draw_Rectangle(1, Color_Bg_Black, LBLX, MBASE(selection - scrollpos) - 14, 271, MBASE(selection - scrollpos) + 28);
  4137. Draw_SD_Item(selection, selection - scrollpos);
  4138. }
  4139. filescrl = 0;
  4140. selection++; // Select Down
  4141. if (selection > scrollpos + MROWS) {
  4142. scrollpos++;
  4143. DWIN_Frame_AreaMove(1, 2, MLINE, Color_Bg_Black, 0, 31, DWIN_WIDTH, 349);
  4144. Draw_SD_Item(selection, selection - scrollpos);
  4145. }
  4146. DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Rectangle_Color), 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33);
  4147. }
  4148. else if (encoder_diffState == ENCODER_DIFF_CCW && selection > 0) {
  4149. DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33);
  4150. DWIN_Draw_Rectangle(1, Color_Bg_Black, LBLX, MBASE(selection - scrollpos) - 14, 271, MBASE(selection - scrollpos) + 28);
  4151. Draw_SD_Item(selection, selection - scrollpos);
  4152. filescrl = 0;
  4153. selection--; // Select Up
  4154. if (selection < scrollpos) {
  4155. scrollpos--;
  4156. DWIN_Frame_AreaMove(1, 3, MLINE, Color_Bg_Black, 0, 31, DWIN_WIDTH, 349);
  4157. Draw_SD_Item(selection, selection - scrollpos);
  4158. }
  4159. DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Rectangle_Color), 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33);
  4160. }
  4161. else if (encoder_diffState == ENCODER_DIFF_ENTER) {
  4162. if (selection == 0) {
  4163. if (card.flag.workDirIsRoot) {
  4164. process = Main;
  4165. Draw_Main_Menu();
  4166. }
  4167. else {
  4168. card.cdup();
  4169. Draw_SD_List();
  4170. }
  4171. }
  4172. else {
  4173. card.getfilename_sorted(SD_ORDER(selection - 1, card.get_num_Files()));
  4174. if (card.flag.filenameIsDir) {
  4175. card.cd(card.filename);
  4176. Draw_SD_List();
  4177. }
  4178. else {
  4179. card.openAndPrintFile(card.filename);
  4180. }
  4181. }
  4182. }
  4183. DWIN_UpdateLCD();
  4184. }
  4185. void CrealityDWINClass::Print_Screen_Control() {
  4186. ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
  4187. if (encoder_diffState == ENCODER_DIFF_NO) return;
  4188. if (encoder_diffState == ENCODER_DIFF_CW && selection < 2) {
  4189. selection++; // Select Down
  4190. Print_Screen_Icons();
  4191. }
  4192. else if (encoder_diffState == ENCODER_DIFF_CCW && selection > 0) {
  4193. selection--; // Select Up
  4194. Print_Screen_Icons();
  4195. }
  4196. else if (encoder_diffState == ENCODER_DIFF_ENTER) {
  4197. switch (selection) {
  4198. case 0:
  4199. Draw_Menu(Tune);
  4200. Update_Status_Bar(true);
  4201. break;
  4202. case 1:
  4203. if (paused) {
  4204. if (sdprint) {
  4205. wait_for_user = false;
  4206. #if ENABLED(PARK_HEAD_ON_PAUSE)
  4207. card.startOrResumeFilePrinting();
  4208. TERN_(POWER_LOSS_RECOVERY, recovery.prepare());
  4209. #else
  4210. char cmnd[20];
  4211. #if HAS_HEATED_BED
  4212. cmnd[sprintf_P(cmnd, PSTR("M140 S%i"), pausebed)] = '\0';
  4213. gcode.process_subcommands_now_P(PSTR(cmnd));
  4214. #endif
  4215. #if HAS_EXTRUDERS
  4216. cmnd[sprintf_P(cmnd, PSTR("M109 S%i"), pausetemp)] = '\0';
  4217. gcode.process_subcommands_now_P(PSTR(cmnd));
  4218. #endif
  4219. TERN_(HAS_FAN, thermalManager.fan_speed[0] = pausefan);
  4220. planner.synchronize();
  4221. TERN_(SDSUPPORT, queue.inject_P(PSTR("M24")));
  4222. #endif
  4223. }
  4224. else {
  4225. TERN_(HOST_ACTION_COMMANDS, host_action_resume());
  4226. }
  4227. Draw_Print_Screen();
  4228. }
  4229. else
  4230. Popup_Handler(Pause);
  4231. break;
  4232. case 2:
  4233. Popup_Handler(Stop);
  4234. break;
  4235. }
  4236. }
  4237. DWIN_UpdateLCD();
  4238. }
  4239. void CrealityDWINClass::Popup_Control() {
  4240. ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
  4241. if (encoder_diffState == ENCODER_DIFF_NO) return;
  4242. if (encoder_diffState == ENCODER_DIFF_CW && selection < 1) {
  4243. selection++;
  4244. Popup_Select();
  4245. }
  4246. else if (encoder_diffState == ENCODER_DIFF_CCW && selection > 0) {
  4247. selection--;
  4248. Popup_Select();
  4249. }
  4250. else if (encoder_diffState == ENCODER_DIFF_ENTER) {
  4251. switch (popup) {
  4252. case Pause:
  4253. if (selection == 0) {
  4254. if (sdprint) {
  4255. #if ENABLED(POWER_LOSS_RECOVERY)
  4256. if (recovery.enabled) recovery.save(true);
  4257. #endif
  4258. #if ENABLED(PARK_HEAD_ON_PAUSE)
  4259. Popup_Handler(Home, true);
  4260. #if ENABLED(SDSUPPORT)
  4261. if (IS_SD_PRINTING()) card.pauseSDPrint();
  4262. #endif
  4263. planner.synchronize();
  4264. queue.inject_P(PSTR("M125"));
  4265. planner.synchronize();
  4266. #else
  4267. queue.inject_P(PSTR("M25"));
  4268. TERN_(HAS_HOTEND, pausetemp = thermalManager.temp_hotend[0].target);
  4269. TERN_(HAS_HEATED_BED, pausebed = thermalManager.temp_bed.target);
  4270. TERN_(HAS_FAN, pausefan = thermalManager.fan_speed[0]);
  4271. thermalManager.disable_all_heaters();
  4272. TERN_(HAS_FAN, thermalManager.zero_fan_speeds());
  4273. #endif
  4274. }
  4275. else {
  4276. TERN_(HOST_ACTION_COMMANDS, host_action_pause());
  4277. }
  4278. }
  4279. Draw_Print_Screen();
  4280. break;
  4281. case Stop:
  4282. if (selection == 0) {
  4283. if (sdprint) {
  4284. ui.abort_print();
  4285. TERN_(HAS_FAN, thermalManager.zero_fan_speeds());
  4286. thermalManager.disable_all_heaters();
  4287. }
  4288. else {
  4289. TERN_(HOST_ACTION_COMMANDS, host_action_cancel());
  4290. }
  4291. }
  4292. else
  4293. Draw_Print_Screen();
  4294. break;
  4295. case Resume:
  4296. if (selection == 0)
  4297. queue.inject_P(PSTR("M1000"));
  4298. else {
  4299. queue.inject_P(PSTR("M1000 C"));
  4300. Draw_Main_Menu();
  4301. }
  4302. break;
  4303. #if HAS_HOTEND
  4304. case ETemp:
  4305. if (selection == 0) {
  4306. thermalManager.setTargetHotend(EXTRUDE_MINTEMP, 0);
  4307. thermalManager.set_fan_speed(0, MAX_FAN_SPEED);
  4308. Draw_Menu(PreheatHotend);
  4309. }
  4310. else
  4311. Redraw_Menu(true, true, false);
  4312. break;
  4313. #endif
  4314. #if HAS_BED_PROBE
  4315. case ManualProbing:
  4316. if (selection == 0) {
  4317. char buf[80];
  4318. const float dif = probe.probe_at_point(current_position.x, current_position.y, PROBE_PT_STOW, 0, false) - corner_avg;
  4319. sprintf_P(buf, dif > 0 ? PSTR("Corner is %smm high") : PSTR("Corner is %smm low"), dtostrf(abs(dif), 1, 3, str_1));
  4320. Update_Status(buf);
  4321. }
  4322. else {
  4323. Redraw_Menu(true, true, false);
  4324. Update_Status("");
  4325. }
  4326. break;
  4327. #endif
  4328. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  4329. case ConfFilChange:
  4330. if (selection == 0) {
  4331. if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp)
  4332. Popup_Handler(ETemp);
  4333. else {
  4334. if (thermalManager.temp_hotend[0].celsius < thermalManager.temp_hotend[0].target - 2) {
  4335. Popup_Handler(Heating);
  4336. thermalManager.wait_for_hotend(0);
  4337. }
  4338. Popup_Handler(FilChange);
  4339. sprintf_P(cmd, PSTR("M600 B1 R%i"), thermalManager.temp_hotend[0].target);
  4340. gcode.process_subcommands_now_P(cmd);
  4341. }
  4342. }
  4343. else
  4344. Redraw_Menu(true, true, false);
  4345. break;
  4346. case PurgeMore:
  4347. if (selection == 0) {
  4348. pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE;
  4349. Popup_Handler(FilChange);
  4350. }
  4351. else {
  4352. pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT;
  4353. if (printing) Popup_Handler(Resuming);
  4354. else Redraw_Menu(true, true, (active_menu==PreheatHotend));
  4355. }
  4356. break;
  4357. #endif // ADVANCED_PAUSE_FEATURE
  4358. #if HAS_MESH
  4359. case SaveLevel:
  4360. if (selection == 0) {
  4361. #if ENABLED(AUTO_BED_LEVELING_UBL)
  4362. gcode.process_subcommands_now_P(PSTR("G29 S"));
  4363. planner.synchronize();
  4364. AudioFeedback(true);
  4365. #else
  4366. AudioFeedback(settings.save());
  4367. #endif
  4368. }
  4369. Draw_Menu(Leveling, LEVELING_GET_MESH);
  4370. break;
  4371. #endif
  4372. #if ENABLED(AUTO_BED_LEVELING_UBL)
  4373. case MeshSlot:
  4374. if (selection == 0) ubl.storage_slot = 0;
  4375. Redraw_Menu(true, true);
  4376. break;
  4377. #endif
  4378. default: break;
  4379. }
  4380. }
  4381. DWIN_UpdateLCD();
  4382. }
  4383. void CrealityDWINClass::Confirm_Control() {
  4384. ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
  4385. if (encoder_diffState == ENCODER_DIFF_NO) return;
  4386. if (encoder_diffState == ENCODER_DIFF_ENTER) {
  4387. switch (popup) {
  4388. case Complete:
  4389. Draw_Main_Menu();
  4390. break;
  4391. case FilInsert:
  4392. Popup_Handler(FilChange);
  4393. wait_for_user = false;
  4394. break;
  4395. case HeaterTime:
  4396. Popup_Handler(Heating);
  4397. wait_for_user = false;
  4398. break;
  4399. default:
  4400. Redraw_Menu(true, true, false);
  4401. wait_for_user = false;
  4402. break;
  4403. }
  4404. }
  4405. DWIN_UpdateLCD();
  4406. }
  4407. /* In-Menu Value Modification */
  4408. void CrealityDWINClass::Setup_Value(float value, float min, float max, float unit, uint8_t type) {
  4409. if (TERN0(HAS_HOTEND, valuepointer == &thermalManager.temp_hotend[0].pid.Ki) || TERN0(HAS_HEATED_BED, valuepointer == &thermalManager.temp_bed.pid.Ki))
  4410. tempvalue = unscalePID_i(value) * unit;
  4411. else if (TERN0(HAS_HOTEND, valuepointer == &thermalManager.temp_hotend[0].pid.Kd) || TERN0(HAS_HEATED_BED, valuepointer == &thermalManager.temp_bed.pid.Kd))
  4412. tempvalue = unscalePID_d(value) * unit;
  4413. else
  4414. tempvalue = value * unit;
  4415. valuemin = min;
  4416. valuemax = max;
  4417. valueunit = unit;
  4418. valuetype = type;
  4419. process = Value;
  4420. EncoderRate.enabled = true;
  4421. Draw_Float(tempvalue / unit, selection - scrollpos, true, valueunit);
  4422. }
  4423. void CrealityDWINClass::Modify_Value(float &value, float min, float max, float unit, void (*f)()/*=nullptr*/) {
  4424. valuepointer = &value;
  4425. funcpointer = f;
  4426. Setup_Value((float)value, min, max, unit, 0);
  4427. }
  4428. void CrealityDWINClass::Modify_Value(uint8_t &value, float min, float max, float unit, void (*f)()/*=nullptr*/) {
  4429. valuepointer = &value;
  4430. funcpointer = f;
  4431. Setup_Value((float)value, min, max, unit, 1);
  4432. }
  4433. void CrealityDWINClass::Modify_Value(uint16_t &value, float min, float max, float unit, void (*f)()/*=nullptr*/) {
  4434. valuepointer = &value;
  4435. funcpointer = f;
  4436. Setup_Value((float)value, min, max, unit, 2);
  4437. }
  4438. void CrealityDWINClass::Modify_Value(int16_t &value, float min, float max, float unit, void (*f)()/*=nullptr*/) {
  4439. valuepointer = &value;
  4440. funcpointer = f;
  4441. Setup_Value((float)value, min, max, unit, 3);
  4442. }
  4443. void CrealityDWINClass::Modify_Value(uint32_t &value, float min, float max, float unit, void (*f)()/*=nullptr*/) {
  4444. valuepointer = &value;
  4445. funcpointer = f;
  4446. Setup_Value((float)value, min, max, unit, 4);
  4447. }
  4448. void CrealityDWINClass::Modify_Value(int8_t &value, float min, float max, float unit, void (*f)()/*=nullptr*/) {
  4449. valuepointer = &value;
  4450. funcpointer = f;
  4451. Setup_Value((float)value, min, max, unit, 5);
  4452. }
  4453. void CrealityDWINClass::Modify_Option(uint8_t value, const char * const * options, uint8_t max) {
  4454. tempvalue = value;
  4455. valuepointer = const_cast<const char * *>(options);
  4456. valuemin = 0;
  4457. valuemax = max;
  4458. process = Option;
  4459. EncoderRate.enabled = true;
  4460. Draw_Option(value, options, selection - scrollpos, true);
  4461. }
  4462. /* Main Functions */
  4463. void CrealityDWINClass::Update_Status(const char * const text) {
  4464. char header[4];
  4465. LOOP_L_N(i, 3) header[i] = text[i];
  4466. header[3] = '\0';
  4467. if (strcmp_P(header,"<F>") == 0) {
  4468. LOOP_L_N(i, _MIN((size_t)LONG_FILENAME_LENGTH, strlen(text))) filename[i] = text[i + 3];
  4469. filename[_MIN((size_t)LONG_FILENAME_LENGTH - 1, strlen(text))] = '\0';
  4470. Draw_Print_Filename(true);
  4471. }
  4472. else {
  4473. LOOP_L_N(i, _MIN((size_t)64, strlen(text))) statusmsg[i] = text[i];
  4474. statusmsg[_MIN((size_t)64, strlen(text))] = '\0';
  4475. }
  4476. }
  4477. void CrealityDWINClass::Start_Print(bool sd) {
  4478. sdprint = sd;
  4479. if (!printing) {
  4480. printing = true;
  4481. statusmsg[0] = '\0';
  4482. if (sd) {
  4483. if (recovery.valid()) {
  4484. SdFile *diveDir = nullptr;
  4485. const char * const fname = card.diveToFile(true, diveDir, recovery.info.sd_filename);
  4486. card.selectFileByName(fname);
  4487. }
  4488. strcpy_P(filename, card.longest_filename());
  4489. }
  4490. else
  4491. strcpy_P(filename, "Host Print");
  4492. TERN_(LCD_SET_PROGRESS_MANUALLY, ui.set_progress(0));
  4493. TERN_(USE_M73_REMAINING_TIME, ui.set_remaining_time(0));
  4494. Draw_Print_Screen();
  4495. }
  4496. }
  4497. void CrealityDWINClass::Stop_Print() {
  4498. printing = false;
  4499. sdprint = false;
  4500. TERN_(HAS_FAN, thermalManager.zero_fan_speeds());
  4501. thermalManager.disable_all_heaters();
  4502. TERN_(LCD_SET_PROGRESS_MANUALLY, ui.set_progress(100 * (PROGRESS_SCALE)));
  4503. TERN_(USE_M73_REMAINING_TIME, ui.set_remaining_time(0));
  4504. Draw_Print_confirm();
  4505. }
  4506. void CrealityDWINClass::Update() {
  4507. State_Update();
  4508. Screen_Update();
  4509. switch (process) {
  4510. case Main: Main_Menu_Control(); break;
  4511. case Menu: Menu_Control(); break;
  4512. case Value: Value_Control(); break;
  4513. case Option: Option_Control(); break;
  4514. case File: File_Control(); break;
  4515. case Print: Print_Screen_Control(); break;
  4516. case Popup: Popup_Control(); break;
  4517. case Confirm: Confirm_Control(); break;
  4518. }
  4519. }
  4520. void MarlinUI::update() { CrealityDWIN.Update(); }
  4521. void CrealityDWINClass::State_Update() {
  4522. if ((print_job_timer.isRunning() || print_job_timer.isPaused()) != printing) {
  4523. if (!printing) Start_Print((card.isFileOpen() || recovery.valid()));
  4524. else Stop_Print();
  4525. }
  4526. if (print_job_timer.isPaused() != paused) {
  4527. paused = print_job_timer.isPaused();
  4528. if (process == Print) Print_Screen_Icons();
  4529. if (process == Wait && !paused) Redraw_Menu(true, true);
  4530. }
  4531. if (wait_for_user && !(process == Confirm) && !print_job_timer.isPaused())
  4532. Confirm_Handler(UserInput);
  4533. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  4534. if (process == Popup && popup == PurgeMore) {
  4535. if (pause_menu_response == PAUSE_RESPONSE_EXTRUDE_MORE)
  4536. Popup_Handler(FilChange);
  4537. else if (pause_menu_response == PAUSE_RESPONSE_RESUME_PRINT) {
  4538. if (printing) Popup_Handler(Resuming);
  4539. else Redraw_Menu(true, true, (active_menu==PreheatHotend));
  4540. }
  4541. }
  4542. #endif
  4543. #if ENABLED(FILAMENT_RUNOUT_SENSOR)
  4544. static bool ranout = false;
  4545. if (runout.filament_ran_out != ranout) {
  4546. ranout = runout.filament_ran_out;
  4547. if (ranout) Popup_Handler(Runout);
  4548. }
  4549. #endif
  4550. }
  4551. void CrealityDWINClass::Screen_Update() {
  4552. static millis_t scrltime = 0;
  4553. if (ELAPSED(millis(), scrltime)) {
  4554. scrltime = millis() + 200;
  4555. Update_Status_Bar();
  4556. if (process == Print) Draw_Print_Filename();
  4557. }
  4558. static millis_t statustime = 0;
  4559. if (ELAPSED(millis(), statustime)) {
  4560. statustime = millis() + 500;
  4561. Draw_Status_Area();
  4562. }
  4563. static millis_t printtime = 0;
  4564. if (ELAPSED(millis(), printtime)) {
  4565. printtime = millis() + 1000;
  4566. if (process == Print) {
  4567. Draw_Print_ProgressBar();
  4568. Draw_Print_ProgressElapsed();
  4569. TERN_(USE_M73_REMAINING_TIME, Draw_Print_ProgressRemain());
  4570. }
  4571. }
  4572. static bool mounted = card.isMounted();
  4573. if (mounted != card.isMounted()) {
  4574. mounted = card.isMounted();
  4575. if (process == File)
  4576. Draw_SD_List();
  4577. }
  4578. #if HAS_HOTEND
  4579. static int16_t hotendtarget = -1;
  4580. #endif
  4581. #if HAS_HEATED_BED
  4582. static int16_t bedtarget = -1;
  4583. #endif
  4584. #if HAS_FAN
  4585. static int16_t fanspeed = -1;
  4586. #endif
  4587. #if HAS_ZOFFSET_ITEM
  4588. static float lastzoffset = zoffsetvalue;
  4589. if (zoffsetvalue != lastzoffset) {
  4590. lastzoffset = zoffsetvalue;
  4591. #if HAS_BED_PROBE
  4592. probe.offset.z = zoffsetvalue;
  4593. #else
  4594. set_home_offset(Z_AXIS, -zoffsetvalue);
  4595. #endif
  4596. }
  4597. #if HAS_BED_PROBE
  4598. if (probe.offset.z != lastzoffset)
  4599. zoffsetvalue = lastzoffset = probe.offset.z;
  4600. #else
  4601. if (-home_offset.z != lastzoffset)
  4602. zoffsetvalue = lastzoffset = -home_offset.z;
  4603. #endif
  4604. #endif // HAS_ZOFFSET_ITEM
  4605. if (process == Menu || process == Value) {
  4606. switch (active_menu) {
  4607. case TempMenu:
  4608. #if HAS_HOTEND
  4609. if (thermalManager.temp_hotend[0].target != hotendtarget) {
  4610. hotendtarget = thermalManager.temp_hotend[0].target;
  4611. if (scrollpos <= TEMP_HOTEND && TEMP_HOTEND <= scrollpos + MROWS) {
  4612. if (process != Value || selection != TEMP_HOTEND - scrollpos)
  4613. Draw_Float(thermalManager.temp_hotend[0].target, TEMP_HOTEND - scrollpos, false, 1);
  4614. }
  4615. }
  4616. #endif
  4617. #if HAS_HEATED_BED
  4618. if (thermalManager.temp_bed.target != bedtarget) {
  4619. bedtarget = thermalManager.temp_bed.target;
  4620. if (scrollpos <= TEMP_BED && TEMP_BED <= scrollpos + MROWS) {
  4621. if (process != Value || selection != TEMP_HOTEND - scrollpos)
  4622. Draw_Float(thermalManager.temp_bed.target, TEMP_BED - scrollpos, false, 1);
  4623. }
  4624. }
  4625. #endif
  4626. #if HAS_FAN
  4627. if (thermalManager.fan_speed[0] != fanspeed) {
  4628. fanspeed = thermalManager.fan_speed[0];
  4629. if (scrollpos <= TEMP_FAN && TEMP_FAN <= scrollpos + MROWS) {
  4630. if (process != Value || selection != TEMP_HOTEND - scrollpos)
  4631. Draw_Float(thermalManager.fan_speed[0], TEMP_FAN - scrollpos, false, 1);
  4632. }
  4633. }
  4634. #endif
  4635. break;
  4636. case Tune:
  4637. #if HAS_HOTEND
  4638. if (thermalManager.temp_hotend[0].target != hotendtarget) {
  4639. hotendtarget = thermalManager.temp_hotend[0].target;
  4640. if (scrollpos <= TUNE_HOTEND && TUNE_HOTEND <= scrollpos + MROWS) {
  4641. if (process != Value || selection != TEMP_HOTEND - scrollpos)
  4642. Draw_Float(thermalManager.temp_hotend[0].target, TUNE_HOTEND - scrollpos, false, 1);
  4643. }
  4644. }
  4645. #endif
  4646. #if HAS_HEATED_BED
  4647. if (thermalManager.temp_bed.target != bedtarget) {
  4648. bedtarget = thermalManager.temp_bed.target;
  4649. if (scrollpos <= TUNE_BED && TUNE_BED <= scrollpos + MROWS) {
  4650. if (process != Value || selection != TEMP_HOTEND - scrollpos)
  4651. Draw_Float(thermalManager.temp_bed.target, TUNE_BED - scrollpos, false, 1);
  4652. }
  4653. }
  4654. #endif
  4655. #if HAS_FAN
  4656. if (thermalManager.fan_speed[0] != fanspeed) {
  4657. fanspeed = thermalManager.fan_speed[0];
  4658. if (scrollpos <= TUNE_FAN && TUNE_FAN <= scrollpos + MROWS) {
  4659. if (process != Value || selection != TEMP_HOTEND - scrollpos)
  4660. Draw_Float(thermalManager.fan_speed[0], TUNE_FAN - scrollpos, false, 1);
  4661. }
  4662. }
  4663. #endif
  4664. break;
  4665. }
  4666. }
  4667. }
  4668. void CrealityDWINClass::AudioFeedback(const bool success/*=true*/) {
  4669. if (success) {
  4670. if (eeprom_settings.beeperenable) {
  4671. BUZZ(100, 659);
  4672. BUZZ( 10, 0);
  4673. BUZZ(100, 698);
  4674. }
  4675. else Update_Status("Success");
  4676. }
  4677. else if (eeprom_settings.beeperenable)
  4678. BUZZ(40, 440);
  4679. else
  4680. Update_Status("Failed");
  4681. }
  4682. void CrealityDWINClass::Save_Settings(char *buff) {
  4683. TERN_(AUTO_BED_LEVELING_UBL, eeprom_settings.tilt_grid_size = mesh_conf.tilt_grid - 1);
  4684. eeprom_settings.corner_pos = corner_pos * 10;
  4685. memcpy(buff, &eeprom_settings, min(sizeof(eeprom_settings), eeprom_data_size));
  4686. }
  4687. void CrealityDWINClass::Load_Settings(const char *buff) {
  4688. memcpy(&eeprom_settings, buff, min(sizeof(eeprom_settings), eeprom_data_size));
  4689. TERN_(AUTO_BED_LEVELING_UBL, mesh_conf.tilt_grid = eeprom_settings.tilt_grid_size + 1);
  4690. if (eeprom_settings.corner_pos == 0) eeprom_settings.corner_pos = 325;
  4691. corner_pos = eeprom_settings.corner_pos / 10.0f;
  4692. Redraw_Screen();
  4693. #if ENABLED(POWER_LOSS_RECOVERY)
  4694. static bool init = true;
  4695. if (init) {
  4696. init = false;
  4697. queue.inject_P(PSTR("M1000 S"));
  4698. }
  4699. #endif
  4700. }
  4701. void CrealityDWINClass::Reset_Settings() {
  4702. eeprom_settings.time_format_textual = false;
  4703. eeprom_settings.beeperenable = true;
  4704. TERN_(AUTO_BED_LEVELING_UBL, eeprom_settings.tilt_grid_size = 0);
  4705. eeprom_settings.corner_pos = 325;
  4706. eeprom_settings.cursor_color = 0;
  4707. eeprom_settings.menu_split_line = 0;
  4708. eeprom_settings.menu_top_bg = 0;
  4709. eeprom_settings.menu_top_txt = 0;
  4710. eeprom_settings.highlight_box = 0;
  4711. eeprom_settings.progress_percent = 0;
  4712. eeprom_settings.progress_time = 0;
  4713. eeprom_settings.status_bar_text = 0;
  4714. eeprom_settings.status_area_text = 0;
  4715. eeprom_settings.coordinates_text = 0;
  4716. eeprom_settings.coordinates_split_line = 0;
  4717. TERN_(AUTO_BED_LEVELING_UBL, mesh_conf.tilt_grid = eeprom_settings.tilt_grid_size + 1);
  4718. corner_pos = eeprom_settings.corner_pos / 10.0f;
  4719. Redraw_Screen();
  4720. }
  4721. void MarlinUI::init() {
  4722. delay(800);
  4723. SERIAL_ECHOPGM("\nDWIN handshake ");
  4724. if (DWIN_Handshake()) SERIAL_ECHOLNPGM("ok."); else SERIAL_ECHOLNPGM("error.");
  4725. DWIN_Frame_SetDir(1); // Orientation 90°
  4726. DWIN_UpdateLCD(); // Show bootscreen (first image)
  4727. Encoder_Configuration();
  4728. for (uint16_t t = 0; t <= 100; t += 2) {
  4729. DWIN_ICON_Show(ICON, ICON_Bar, 15, 260);
  4730. DWIN_Draw_Rectangle(1, Color_Bg_Black, 15 + t * 242 / 100, 260, 257, 280);
  4731. DWIN_UpdateLCD();
  4732. delay(20);
  4733. }
  4734. DWIN_JPG_CacheTo1(Language_English);
  4735. CrealityDWIN.Redraw_Screen();
  4736. }
  4737. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  4738. void MarlinUI::pause_show_message(const PauseMessage message, const PauseMode mode/*=PAUSE_MODE_SAME*/, const uint8_t extruder/*=active_extruder*/) {
  4739. switch (message) {
  4740. case PAUSE_MESSAGE_INSERT: CrealityDWIN.Confirm_Handler(FilInsert); break;
  4741. case PAUSE_MESSAGE_OPTION: CrealityDWIN.Popup_Handler(PurgeMore); break;
  4742. case PAUSE_MESSAGE_HEAT: CrealityDWIN.Confirm_Handler(HeaterTime); break;
  4743. case PAUSE_MESSAGE_WAITING: CrealityDWIN.Draw_Print_Screen(); break;
  4744. default: break;
  4745. }
  4746. }
  4747. #endif
  4748. #endif // DWIN_CREALITY_LCD_JYERSUI