My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

dwin.cpp 143KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 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. * DWIN by Creality3D
  24. */
  25. #include "../../../inc/MarlinConfigPre.h"
  26. #if ENABLED(DWIN_CREALITY_LCD)
  27. #include "dwin.h"
  28. #if ANY(AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT) && DISABLED(PROBE_MANUALLY)
  29. #define HAS_ONESTEP_LEVELING 1
  30. #endif
  31. #if ANY(BABYSTEPPING, HAS_BED_PROBE, HAS_WORKSPACE_OFFSET)
  32. #define HAS_ZOFFSET_ITEM 1
  33. #endif
  34. #if !HAS_BED_PROBE && ENABLED(BABYSTEPPING)
  35. #define JUST_BABYSTEP 1
  36. #endif
  37. #include <WString.h>
  38. #include <stdio.h>
  39. #include <string.h>
  40. #include "../../fontutils.h"
  41. #include "../../ultralcd.h"
  42. #include "../../../sd/cardreader.h"
  43. #include "../../../MarlinCore.h"
  44. #include "../../../core/serial.h"
  45. #include "../../../core/macros.h"
  46. #include "../../../gcode/queue.h"
  47. #include "../../../module/temperature.h"
  48. #include "../../../module/printcounter.h"
  49. #include "../../../module/motion.h"
  50. #include "../../../module/planner.h"
  51. #if ENABLED(EEPROM_SETTINGS)
  52. #include "../../../module/settings.h"
  53. #endif
  54. #if ENABLED(HOST_ACTION_COMMANDS)
  55. #include "../../../feature/host_actions.h"
  56. #endif
  57. #if HAS_ONESTEP_LEVELING
  58. #include "../../../feature/bedlevel/bedlevel.h"
  59. #endif
  60. #if HAS_BED_PROBE
  61. #include "../../../module/probe.h"
  62. #endif
  63. #if EITHER(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP)
  64. #include "../../../feature/babystep.h"
  65. #endif
  66. #if ENABLED(POWER_LOSS_RECOVERY)
  67. #include "../../../feature/powerloss.h"
  68. #endif
  69. #ifndef MACHINE_SIZE
  70. #define MACHINE_SIZE "220x220x250"
  71. #endif
  72. #ifndef CORP_WEBSITE_C
  73. #define CORP_WEBSITE_C "www.cxsw3d.com"
  74. #endif
  75. #ifndef CORP_WEBSITE_E
  76. #define CORP_WEBSITE_E "www.creality.com"
  77. #endif
  78. #define PAUSE_HEAT
  79. #define USE_STRING_HEADINGS
  80. #define DWIN_FONT_MENU font8x16
  81. #define DWIN_FONT_STAT font10x20
  82. #define DWIN_FONT_HEAD font10x20
  83. #define MENU_CHAR_LIMIT 24
  84. #define STATUS_Y 360
  85. // Fan speed limit
  86. #define FANON 255
  87. #define FANOFF 0
  88. // Print speed limit
  89. #define MAX_PRINT_SPEED 999
  90. #define MIN_PRINT_SPEED 10
  91. // Temp limits
  92. #if HAS_HOTEND
  93. #define MAX_E_TEMP (HEATER_0_MAXTEMP - (HOTEND_OVERSHOOT))
  94. #define MIN_E_TEMP HEATER_0_MINTEMP
  95. #endif
  96. #if HAS_HEATED_BED
  97. #define MIN_BED_TEMP BED_MINTEMP
  98. #endif
  99. // Feedspeed limit (max feedspeed = DEFAULT_MAX_FEEDRATE * 2)
  100. #define MIN_MAXFEEDSPEED 1
  101. #define MIN_MAXACCELERATION 1
  102. #define MIN_MAXJERK 0.1
  103. #define MIN_STEP 1
  104. #define FEEDRATE_E (60)
  105. // Mininum unit (0.1) : multiple (10)
  106. #define MINUNITMULT 10
  107. #define ENCODER_WAIT 20
  108. #define DWIN_SCROLL_UPDATE_INTERVAL 2000
  109. #define DWIN_REMAIN_TIME_UPDATE_INTERVAL 20000
  110. constexpr uint16_t TROWS = 6, MROWS = TROWS - 1, // Total rows, and other-than-Back
  111. TITLE_HEIGHT = 30, // Title bar height
  112. MLINE = 53, // Menu line height
  113. LBLX = 60, // Menu item label X
  114. MENU_CHR_W = 8, STAT_CHR_W = 10;
  115. #define MBASE(L) (49 + MLINE * (L))
  116. #define BABY_Z_VAR TERN(HAS_BED_PROBE, probe.offset.z, dwin_zoffset)
  117. /* Value Init */
  118. HMI_value_t HMI_ValueStruct;
  119. HMI_Flag HMI_flag{0};
  120. millis_t dwin_heat_time = 0;
  121. uint8_t checkkey = 0;
  122. typedef struct {
  123. uint8_t now, last;
  124. void set(uint8_t v) { now = last = v; }
  125. void reset() { set(0); }
  126. bool changed() { bool c = (now != last); if (c) last = now; return c; }
  127. bool dec() { if (now) now--; return changed(); }
  128. bool inc(uint8_t v) { if (now < (v - 1)) now++; else now = (v - 1); return changed(); }
  129. } select_t;
  130. select_t select_page{0}, select_file{0}, select_print{0}, select_prepare{0}
  131. , select_control{0}, select_axis{0}, select_temp{0}, select_motion{0}, select_tune{0}
  132. , select_PLA{0}, select_ABS{0}
  133. , select_speed{0}
  134. , select_acc{0}
  135. , select_jerk{0}
  136. , select_step{0}
  137. // , select_leveling{0}
  138. ;
  139. uint8_t index_file = MROWS,
  140. index_prepare = MROWS,
  141. index_control = MROWS,
  142. index_leveling = MROWS,
  143. index_tune = MROWS;
  144. bool dwin_abort_flag = false;
  145. constexpr float default_max_feedrate[] = DEFAULT_MAX_FEEDRATE;
  146. constexpr float default_max_acceleration[] = DEFAULT_MAX_ACCELERATION;
  147. constexpr float default_max_jerk[] = { DEFAULT_XJERK, DEFAULT_YJERK, DEFAULT_ZJERK, DEFAULT_EJERK };
  148. constexpr float default_axis_steps_per_unit[] = DEFAULT_AXIS_STEPS_PER_UNIT;
  149. uint8_t Percentrecord = 0;
  150. uint16_t remain_time = 0;
  151. #if ENABLED(PAUSE_HEAT)
  152. #if HAS_HOTEND
  153. uint16_t temphot = 0;
  154. #endif
  155. #if HAS_HEATED_BED
  156. uint16_t tempbed = 0;
  157. #endif
  158. #endif
  159. #if HAS_ZOFFSET_ITEM
  160. float dwin_zoffset = 0, last_zoffset = 0;
  161. #endif
  162. #define DWIN_LANGUAGE_EEPROM_ADDRESS 0x01 // Between 0x01 and 0x63 (EEPROM_OFFSET-1)
  163. // BL24CXX::check() uses 0x00
  164. void HMI_SetLanguageCache() {
  165. DWIN_JPG_CacheTo1(HMI_flag.language_chinese ? Language_Chinese : Language_English);
  166. }
  167. void HMI_SetLanguage() {
  168. #if ENABLED(EEPROM_SETTINGS)
  169. BL24CXX::read(DWIN_LANGUAGE_EEPROM_ADDRESS, (uint8_t*)&HMI_flag.language_chinese, sizeof(HMI_flag.language_chinese));
  170. #endif
  171. HMI_SetLanguageCache();
  172. }
  173. void HMI_ToggleLanguage() {
  174. HMI_flag.language_chinese ^= true;
  175. HMI_SetLanguageCache();
  176. #if ENABLED(EEPROM_SETTINGS)
  177. BL24CXX::write(DWIN_LANGUAGE_EEPROM_ADDRESS, (uint8_t*)&HMI_flag.language_chinese, sizeof(HMI_flag.language_chinese));
  178. #endif
  179. }
  180. void DWIN_Draw_Signed_Float(uint8_t size, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) {
  181. if (value < 0) {
  182. DWIN_Draw_String(false, true, size, Color_White, bColor, x - 6, y, F("-"));
  183. DWIN_Draw_FloatValue(true, true, 0, size, Color_White, bColor, iNum, fNum, x, y, -value);
  184. }
  185. else {
  186. DWIN_Draw_String(false, true, size, Color_White, bColor, x - 6, y, F(" "));
  187. DWIN_Draw_FloatValue(true, true, 0, size, Color_White, bColor, iNum, fNum, x, y, value);
  188. }
  189. }
  190. void ICON_Print() {
  191. if (select_page.now == 0) {
  192. DWIN_ICON_Show(ICON, ICON_Print_1, 17, 130);
  193. DWIN_Draw_Rectangle(0, Color_White, 17, 130, 126, 229);
  194. if (HMI_flag.language_chinese)
  195. DWIN_Frame_AreaCopy(1, 1, 447, 28, 460, 58, 201);
  196. else
  197. DWIN_Frame_AreaCopy(1, 1, 451, 31, 463, 57, 201);
  198. }
  199. else {
  200. DWIN_ICON_Show(ICON, ICON_Print_0, 17, 130);
  201. if (HMI_flag.language_chinese)
  202. DWIN_Frame_AreaCopy(1, 1, 405, 28, 420, 58, 201);
  203. else
  204. DWIN_Frame_AreaCopy(1, 1, 423, 31, 435, 57, 201);
  205. }
  206. }
  207. void ICON_Prepare() {
  208. if (select_page.now == 1) {
  209. DWIN_ICON_Show(ICON, ICON_Prepare_1, 145, 130);
  210. DWIN_Draw_Rectangle(0, Color_White, 145, 130, 254, 229);
  211. if (HMI_flag.language_chinese)
  212. DWIN_Frame_AreaCopy(1, 31, 447, 58, 460, 186, 201);
  213. else
  214. DWIN_Frame_AreaCopy(1, 33, 451, 82, 466, 175, 201);
  215. }
  216. else {
  217. DWIN_ICON_Show(ICON, ICON_Prepare_0, 145, 130);
  218. if (HMI_flag.language_chinese)
  219. DWIN_Frame_AreaCopy(1, 31, 405, 58, 420, 186, 201);
  220. else
  221. DWIN_Frame_AreaCopy(1, 33, 423, 82, 438, 175, 201);
  222. }
  223. }
  224. void ICON_Control() {
  225. if (select_page.now == 2) {
  226. DWIN_ICON_Show(ICON, ICON_Control_1, 17, 246);
  227. DWIN_Draw_Rectangle(0, Color_White, 17, 246, 126, 345);
  228. if (HMI_flag.language_chinese)
  229. DWIN_Frame_AreaCopy(1, 61, 447, 88, 460, 58, 318);
  230. else
  231. DWIN_Frame_AreaCopy(1, 85, 451, 132, 463, 48, 318);
  232. }
  233. else {
  234. DWIN_ICON_Show(ICON, ICON_Control_0, 17, 246);
  235. if (HMI_flag.language_chinese)
  236. DWIN_Frame_AreaCopy(1, 61, 405, 88, 420, 58, 318);
  237. else
  238. DWIN_Frame_AreaCopy(1, 85, 423, 132, 434, 48, 318);
  239. }
  240. }
  241. void ICON_StartInfo(bool show) {
  242. if (show) {
  243. DWIN_ICON_Show(ICON, ICON_Info_1, 145, 246);
  244. DWIN_Draw_Rectangle(0, Color_White, 145, 246, 254, 345);
  245. if (HMI_flag.language_chinese)
  246. DWIN_Frame_AreaCopy(1, 91, 447, 118, 460, 186, 318);
  247. else
  248. DWIN_Frame_AreaCopy(1, 132, 451, 159, 466, 186, 318);
  249. }
  250. else {
  251. DWIN_ICON_Show(ICON, ICON_Info_0, 145, 246);
  252. if (HMI_flag.language_chinese)
  253. DWIN_Frame_AreaCopy(1, 91, 405, 118, 420, 186, 318);
  254. else
  255. DWIN_Frame_AreaCopy(1, 132, 423, 159, 435, 186, 318);
  256. }
  257. }
  258. void ICON_Leveling(bool show) {
  259. if (show) {
  260. DWIN_ICON_Show(ICON, ICON_Leveling_1, 145, 246);
  261. DWIN_Draw_Rectangle(0, Color_White, 145, 246, 254, 345);
  262. if (HMI_flag.language_chinese)
  263. DWIN_Frame_AreaCopy(1, 211, 447, 238, 460, 186, 318);
  264. else
  265. DWIN_Frame_AreaCopy(1, 84, 437, 120, 449, 182, 318);
  266. }
  267. else {
  268. DWIN_ICON_Show(ICON, ICON_Leveling_0, 145, 246);
  269. if (HMI_flag.language_chinese)
  270. DWIN_Frame_AreaCopy(1, 211, 405, 238, 420, 186, 318);
  271. else
  272. DWIN_Frame_AreaCopy(1, 84, 465, 120, 478, 182, 318);
  273. }
  274. }
  275. void ICON_Tune() {
  276. if (select_print.now == 0) {
  277. DWIN_ICON_Show(ICON, ICON_Setup_1, 8, 252);
  278. DWIN_Draw_Rectangle(0, Color_White, 8, 252, 87, 351);
  279. if (HMI_flag.language_chinese)
  280. DWIN_Frame_AreaCopy(1, 121, 447, 148, 458, 34, 325);
  281. else
  282. DWIN_Frame_AreaCopy(1, 0, 466, 34, 476, 31, 325);
  283. }
  284. else {
  285. DWIN_ICON_Show(ICON, ICON_Setup_0, 8, 252);
  286. if (HMI_flag.language_chinese)
  287. DWIN_Frame_AreaCopy(1, 121, 405, 148, 420, 34, 325);
  288. else
  289. DWIN_Frame_AreaCopy(1, 0, 438, 32, 448, 31, 325);
  290. }
  291. }
  292. void ICON_Pause() {
  293. if (select_print.now == 1) {
  294. DWIN_ICON_Show(ICON, ICON_Pause_1, 96, 252);
  295. DWIN_Draw_Rectangle(0, Color_White, 96, 252, 175, 351);
  296. if (HMI_flag.language_chinese)
  297. DWIN_Frame_AreaCopy(1, 181, 447, 208, 459, 124, 325);
  298. else
  299. DWIN_Frame_AreaCopy(1, 177, 451, 216, 462, 116, 325);
  300. }
  301. else {
  302. DWIN_ICON_Show(ICON, ICON_Pause_0, 96, 252);
  303. if (HMI_flag.language_chinese)
  304. DWIN_Frame_AreaCopy(1, 181, 405, 208, 420, 124, 325);
  305. else
  306. DWIN_Frame_AreaCopy(1, 177, 423, 215, 433, 116, 325);
  307. }
  308. }
  309. void ICON_Continue() {
  310. if (select_print.now == 1) {
  311. DWIN_ICON_Show(ICON, ICON_Continue_1, 96, 252);
  312. DWIN_Draw_Rectangle(0, Color_White, 96, 252, 175, 351);
  313. if (HMI_flag.language_chinese)
  314. DWIN_Frame_AreaCopy(1, 1, 447, 28, 460, 124, 325);
  315. else
  316. DWIN_Frame_AreaCopy(1, 1, 452, 32, 464, 121, 325);
  317. }
  318. else {
  319. DWIN_ICON_Show(ICON, ICON_Continue_0, 96, 252);
  320. if (HMI_flag.language_chinese)
  321. DWIN_Frame_AreaCopy(1, 1, 405, 28, 420, 124, 325);
  322. else
  323. DWIN_Frame_AreaCopy(1, 1, 424, 31, 434, 121, 325);
  324. }
  325. }
  326. void ICON_Stop() {
  327. if (select_print.now == 2) {
  328. DWIN_ICON_Show(ICON, ICON_Stop_1, 184, 252);
  329. DWIN_Draw_Rectangle(0, Color_White, 184, 252, 263, 351);
  330. if (HMI_flag.language_chinese)
  331. DWIN_Frame_AreaCopy(1, 151, 447, 178, 459, 210, 325);
  332. else
  333. DWIN_Frame_AreaCopy(1, 218, 452, 249, 466, 209, 325);
  334. }
  335. else {
  336. DWIN_ICON_Show(ICON, ICON_Stop_0, 184, 252);
  337. if (HMI_flag.language_chinese)
  338. DWIN_Frame_AreaCopy(1, 151, 405, 178, 420, 210, 325);
  339. else
  340. DWIN_Frame_AreaCopy(1, 218, 423, 247, 436, 209, 325);
  341. }
  342. }
  343. inline void Clear_Title_Bar() {
  344. DWIN_Draw_Rectangle(1, Color_Bg_Blue, 0, 0, DWIN_WIDTH, 30);
  345. }
  346. inline void Draw_Title(const char * const title) {
  347. DWIN_Draw_String(false, false, DWIN_FONT_HEAD, Color_White, Color_Bg_Blue, 14, 4, (char*)title);
  348. }
  349. inline void Draw_Title(const __FlashStringHelper * title) {
  350. DWIN_Draw_String(false, false, DWIN_FONT_HEAD, Color_White, Color_Bg_Blue, 14, 4, (char*)title);
  351. }
  352. inline void Clear_Menu_Area() {
  353. DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, 31, DWIN_WIDTH, STATUS_Y);
  354. }
  355. inline void Clear_Main_Window() {
  356. Clear_Title_Bar();
  357. Clear_Menu_Area();
  358. }
  359. inline void Clear_Popup_Area() {
  360. Clear_Title_Bar();
  361. DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, 31, DWIN_WIDTH, DWIN_HEIGHT);
  362. }
  363. void Draw_Popup_Bkgd_105() {
  364. DWIN_Draw_Rectangle(1, Color_Bg_Window, 14, 105, 258, 374);
  365. }
  366. inline void Draw_More_Icon(const uint8_t line) {
  367. DWIN_ICON_Show(ICON, ICON_More, 226, MBASE(line) - 3);
  368. }
  369. inline void Draw_Menu_Cursor(const uint8_t line) {
  370. // DWIN_ICON_Show(ICON,ICON_Rectangle, 0, MBASE(line) - 18);
  371. DWIN_Draw_Rectangle(1, Rectangle_Color, 0, MBASE(line) - 18, 14, MBASE(line + 1) - 20);
  372. }
  373. inline void Erase_Menu_Cursor(const uint8_t line) {
  374. DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, MBASE(line) - 18, 14, MBASE(line + 1) - 20);
  375. }
  376. inline void Move_Highlight(const int16_t from, const uint16_t newline) {
  377. Erase_Menu_Cursor(newline - from);
  378. Draw_Menu_Cursor(newline);
  379. }
  380. inline void Add_Menu_Line() {
  381. Move_Highlight(1, MROWS);
  382. DWIN_Draw_Line(Line_Color, 16, MBASE(MROWS + 1) - 20, 256, MBASE(MROWS + 1) - 19);
  383. }
  384. inline void Scroll_Menu(const uint8_t dir) {
  385. DWIN_Frame_AreaMove(1, dir, MLINE, Color_Bg_Black, 0, 31, DWIN_WIDTH, 349);
  386. switch (dir) {
  387. case DWIN_SCROLL_DOWN: Move_Highlight(-1, 0); break;
  388. case DWIN_SCROLL_UP: Add_Menu_Line(); break;
  389. }
  390. }
  391. inline uint16_t nr_sd_menu_items() {
  392. return card.get_num_Files() + !card.flag.workDirIsRoot;
  393. }
  394. inline void Draw_Menu_Icon(const uint8_t line, const uint8_t icon) {
  395. DWIN_ICON_Show(ICON, icon, 26, MBASE(line) - 3);
  396. }
  397. inline void Erase_Menu_Text(const uint8_t line) {
  398. DWIN_Draw_Rectangle(1, Color_Bg_Black, LBLX, MBASE(line) - 14, 271, MBASE(line) + 28);
  399. }
  400. inline void Draw_Menu_Line(const uint8_t line, const uint8_t icon=0, const char * const label=nullptr) {
  401. if (label) DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(line) - 1, (char*)label);
  402. if (icon) Draw_Menu_Icon(line, icon);
  403. DWIN_Draw_Line(Line_Color, 16, MBASE(line) + 33, 256, MBASE(line) + 34);
  404. }
  405. // The "Back" label is always on the first line
  406. inline void Draw_Back_Label() {
  407. if (HMI_flag.language_chinese)
  408. DWIN_Frame_AreaCopy(1, 129, 72, 156, 84, LBLX, MBASE(0));
  409. else
  410. DWIN_Frame_AreaCopy(1, 226, 179, 256, 189, LBLX, MBASE(0));
  411. }
  412. // Draw "Back" line at the top
  413. inline void Draw_Back_First(const bool is_sel=true) {
  414. Draw_Menu_Line(0, ICON_Back);
  415. Draw_Back_Label();
  416. if (is_sel) Draw_Menu_Cursor(0);
  417. }
  418. //
  419. // Draw Menus
  420. //
  421. #define MOTION_CASE_RATE 1
  422. #define MOTION_CASE_ACCEL 2
  423. #define MOTION_CASE_JERK (MOTION_CASE_ACCEL + ENABLED(HAS_CLASSIC_JERK))
  424. #define MOTION_CASE_STEPS (MOTION_CASE_JERK + 1)
  425. #define MOTION_CASE_TOTAL MOTION_CASE_STEPS
  426. #define PREPARE_CASE_MOVE 1
  427. #define PREPARE_CASE_DISA 2
  428. #define PREPARE_CASE_HOME 3
  429. #define PREPARE_CASE_ZOFF (PREPARE_CASE_HOME + ENABLED(HAS_ZOFFSET_ITEM))
  430. #define PREPARE_CASE_PLA (PREPARE_CASE_ZOFF + ENABLED(HAS_HOTEND))
  431. #define PREPARE_CASE_ABS (PREPARE_CASE_PLA + ENABLED(HAS_HOTEND))
  432. #define PREPARE_CASE_COOL (PREPARE_CASE_ABS + EITHER(HAS_HOTEND, HAS_HEATED_BED))
  433. #define PREPARE_CASE_LANG (PREPARE_CASE_COOL + 1)
  434. #define PREPARE_CASE_TOTAL PREPARE_CASE_LANG
  435. #define CONTROL_CASE_TEMP 1
  436. #define CONTROL_CASE_MOVE (CONTROL_CASE_TEMP + 1)
  437. #define CONTROL_CASE_SAVE (CONTROL_CASE_MOVE + ENABLED(EEPROM_SETTINGS))
  438. #define CONTROL_CASE_LOAD (CONTROL_CASE_SAVE + ENABLED(EEPROM_SETTINGS))
  439. #define CONTROL_CASE_RESET (CONTROL_CASE_LOAD + ENABLED(EEPROM_SETTINGS))
  440. #define CONTROL_CASE_INFO (CONTROL_CASE_RESET + 1)
  441. #define CONTROL_CASE_TOTAL CONTROL_CASE_INFO
  442. #define TUNE_CASE_SPEED 1
  443. #define TUNE_CASE_TEMP (TUNE_CASE_SPEED + ENABLED(HAS_HOTEND))
  444. #define TUNE_CASE_BED (TUNE_CASE_TEMP + ENABLED(HAS_HEATED_BED))
  445. #define TUNE_CASE_FAN (TUNE_CASE_BED + ENABLED(HAS_FAN))
  446. #define TUNE_CASE_ZOFF (TUNE_CASE_FAN + ENABLED(HAS_ZOFFSET_ITEM))
  447. #define TUNE_CASE_TOTAL TUNE_CASE_ZOFF
  448. #define TEMP_CASE_TEMP (0 + ENABLED(HAS_HOTEND))
  449. #define TEMP_CASE_BED (TEMP_CASE_TEMP + ENABLED(HAS_HEATED_BED))
  450. #define TEMP_CASE_FAN (TEMP_CASE_BED + ENABLED(HAS_FAN))
  451. #define TEMP_CASE_PLA (TEMP_CASE_FAN + ENABLED(HAS_HOTEND))
  452. #define TEMP_CASE_ABS (TEMP_CASE_PLA + ENABLED(HAS_HOTEND))
  453. #define TEMP_CASE_TOTAL TEMP_CASE_ABS
  454. #define PREHEAT_CASE_TEMP (0 + ENABLED(HAS_HOTEND))
  455. #define PREHEAT_CASE_BED (PREHEAT_CASE_TEMP + ENABLED(HAS_HEATED_BED))
  456. #define PREHEAT_CASE_FAN (PREHEAT_CASE_BED + ENABLED(HAS_FAN))
  457. #define PREHEAT_CASE_SAVE (PREHEAT_CASE_FAN + ENABLED(EEPROM_SETTINGS))
  458. #define PREHEAT_CASE_TOTAL PREHEAT_CASE_SAVE
  459. //
  460. // Draw Menus
  461. //
  462. inline void draw_move_en(const uint16_t line) {
  463. DWIN_Frame_AreaCopy(1, 69, 61, 102, 71, LBLX, line); // "Move"
  464. }
  465. inline void DWIN_Frame_TitleCopy(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) { DWIN_Frame_AreaCopy(id, x1, y1, x2, y2, 14, 8); }
  466. inline void Item_Prepare_Move(const uint8_t row) {
  467. if (HMI_flag.language_chinese)
  468. DWIN_Frame_AreaCopy(1, 159, 70, 200, 84, LBLX, MBASE(row));
  469. else
  470. draw_move_en(MBASE(row)); // "Move >"
  471. Draw_Menu_Line(row, ICON_Axis);
  472. Draw_More_Icon(row);
  473. }
  474. inline void Item_Prepare_Disable(const uint8_t row) {
  475. if (HMI_flag.language_chinese)
  476. DWIN_Frame_AreaCopy(1, 204, 70, 259, 82, LBLX, MBASE(row));
  477. else
  478. DWIN_Frame_AreaCopy(1, 103, 59, 200, 74, LBLX, MBASE(row)); // "Disable Stepper"
  479. Draw_Menu_Line(row, ICON_CloseMotor);
  480. }
  481. inline void Item_Prepare_Home(const uint8_t row) {
  482. if (HMI_flag.language_chinese)
  483. DWIN_Frame_AreaCopy(1, 0, 89, 41, 101, LBLX, MBASE(row));
  484. else
  485. DWIN_Frame_AreaCopy(1, 202, 61, 271, 71, LBLX, MBASE(row)); // "Auto Home"
  486. Draw_Menu_Line(row, ICON_Homing);
  487. }
  488. #if HAS_ZOFFSET_ITEM
  489. inline void Item_Prepare_Offset(const uint8_t row) {
  490. if (HMI_flag.language_chinese) {
  491. #if HAS_BED_PROBE
  492. DWIN_Frame_AreaCopy(1, 174, 164, 223, 177, LBLX, MBASE(row));
  493. DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 2, 2, 202, MBASE(row), BABY_Z_VAR * 100);
  494. #else
  495. DWIN_Frame_AreaCopy(1, 43, 89, 98, 101, LBLX, MBASE(row));
  496. #endif
  497. }
  498. else {
  499. #if HAS_BED_PROBE
  500. DWIN_Frame_AreaCopy(1, 93, 179, 141, 189, LBLX, MBASE(row)); // "Z-Offset"
  501. DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 2, 2, 202, MBASE(row), BABY_Z_VAR * 100);
  502. #else
  503. DWIN_Frame_AreaCopy(1, 1, 76, 106, 86, LBLX, MBASE(row)); // "..."
  504. #endif
  505. }
  506. Draw_Menu_Line(row, ICON_SetHome);
  507. }
  508. #endif
  509. #if HAS_HOTEND
  510. inline void Item_Prepare_PLA(const uint8_t row) {
  511. if (HMI_flag.language_chinese) {
  512. DWIN_Frame_AreaCopy(1, 100, 89, 151, 101, LBLX, MBASE(row));
  513. }
  514. else {
  515. DWIN_Frame_AreaCopy(1, 107, 76, 156, 86, LBLX, MBASE(row)); // "Preheat"
  516. DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX + 52, MBASE(row)); // "PLA"
  517. }
  518. Draw_Menu_Line(row, ICON_PLAPreheat);
  519. }
  520. inline void Item_Prepare_ABS(const uint8_t row) {
  521. if (HMI_flag.language_chinese) {
  522. DWIN_Frame_AreaCopy(1, 180, 89, 233, 100, LBLX, MBASE(row));
  523. }
  524. else {
  525. DWIN_Frame_AreaCopy(1, 107, 76, 156, 86, LBLX, MBASE(row)); // "Preheat"
  526. DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX + 52, MBASE(row)); // "ABS"
  527. }
  528. Draw_Menu_Line(row, ICON_ABSPreheat);
  529. }
  530. #endif
  531. #if HAS_PREHEAT
  532. inline void Item_Prepare_Cool(const uint8_t row) {
  533. if (HMI_flag.language_chinese)
  534. DWIN_Frame_AreaCopy(1, 1, 104, 56, 117, LBLX, MBASE(row));
  535. else
  536. DWIN_Frame_AreaCopy(1, 200, 76, 264, 86, LBLX, MBASE(row)); // "Cooldown"
  537. Draw_Menu_Line(row, ICON_Cool);
  538. }
  539. #endif
  540. inline void Item_Prepare_Lang(const uint8_t row) {
  541. if (HMI_flag.language_chinese) {
  542. DWIN_Frame_AreaCopy(1, 239, 134, 266, 146, LBLX, MBASE(row));
  543. DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, 226, MBASE(row), F("CN"));
  544. }
  545. else {
  546. DWIN_Frame_AreaCopy(1, 0, 194, 121, 207, LBLX, MBASE(row)); // "Language selection"
  547. DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, 226, MBASE(row), F("EN"));
  548. }
  549. Draw_Menu_Icon(row, ICON_Language);
  550. }
  551. inline void Draw_Prepare_Menu() {
  552. Clear_Main_Window();
  553. const int16_t scroll = MROWS - index_prepare; // Scrolled-up lines
  554. #define PSCROL(L) (scroll + (L))
  555. #define PVISI(L) WITHIN(PSCROL(L), 0, MROWS)
  556. if (HMI_flag.language_chinese) {
  557. DWIN_Frame_TitleCopy(1, 133, 1, 160, 13); // "Prepare"
  558. }
  559. else {
  560. #ifdef USE_STRING_HEADINGS
  561. Draw_Title(GET_TEXT_F(MSG_PREPARE));
  562. #else
  563. DWIN_Frame_TitleCopy(1, 178, 2, 229, 14); // "Prepare"
  564. #endif
  565. }
  566. if (PVISI(0)) Draw_Back_First(select_prepare.now == 0); // < Back
  567. if (PVISI(PREPARE_CASE_MOVE)) Item_Prepare_Move(PSCROL(PREPARE_CASE_MOVE)); // Move >
  568. if (PVISI(PREPARE_CASE_DISA)) Item_Prepare_Disable(PSCROL(PREPARE_CASE_DISA)); // Disable Stepper
  569. if (PVISI(PREPARE_CASE_HOME)) Item_Prepare_Home(PSCROL(PREPARE_CASE_HOME)); // Auto Home
  570. #if HAS_ZOFFSET_ITEM
  571. if (PVISI(PREPARE_CASE_ZOFF)) Item_Prepare_Offset(PSCROL(PREPARE_CASE_ZOFF)); // Edit Z-Offset / Babystep / Set Home Offset
  572. #endif
  573. #if HAS_HOTEND
  574. if (PVISI(PREPARE_CASE_PLA)) Item_Prepare_PLA(PSCROL(PREPARE_CASE_PLA)); // Preheat PLA
  575. if (PVISI(PREPARE_CASE_ABS)) Item_Prepare_ABS(PSCROL(PREPARE_CASE_ABS)); // Preheat ABS
  576. #endif
  577. #if HAS_PREHEAT
  578. if (PVISI(PREPARE_CASE_COOL)) Item_Prepare_Cool(PSCROL(PREPARE_CASE_COOL)); // Cooldown
  579. #endif
  580. if (PVISI(PREPARE_CASE_LANG)) Item_Prepare_Lang(PSCROL(PREPARE_CASE_LANG)); // Language CN/EN
  581. if (select_prepare.now) Draw_Menu_Cursor(PSCROL(select_prepare.now));
  582. }
  583. inline void Draw_Control_Menu() {
  584. Clear_Main_Window();
  585. #if CONTROL_CASE_TOTAL >= 6
  586. const int16_t scroll = MROWS - index_control; // Scrolled-up lines
  587. #define CSCROL(L) (scroll + (L))
  588. #else
  589. #define CSCROL(L) (L)
  590. #endif
  591. #define CLINE(L) MBASE(CSCROL(L))
  592. #define CVISI(L) WITHIN(CSCROL(L), 0, MROWS)
  593. if (CVISI(0)) Draw_Back_First(select_control.now == 0); // < Back
  594. if (HMI_flag.language_chinese) {
  595. DWIN_Frame_TitleCopy(1, 103, 1, 130, 14); // "Control"
  596. DWIN_Frame_AreaCopy(1, 57, 104, 84, 116, LBLX, CLINE(CONTROL_CASE_TEMP)); // Temperature >
  597. DWIN_Frame_AreaCopy(1, 87, 104, 114, 116, LBLX, CLINE(CONTROL_CASE_MOVE)); // Motion >
  598. #if ENABLED(EEPROM_SETTINGS)
  599. DWIN_Frame_AreaCopy(1, 117, 104, 172, 116, LBLX, CLINE(CONTROL_CASE_SAVE)); // Store Configuration
  600. DWIN_Frame_AreaCopy(1, 174, 103, 229, 116, LBLX, CLINE(CONTROL_CASE_LOAD)); // Read Configuration
  601. DWIN_Frame_AreaCopy(1, 1, 118, 56, 131, LBLX, CLINE(CONTROL_CASE_RESET)); // Reset Configuration
  602. #endif
  603. if (CVISI(CONTROL_CASE_INFO))
  604. DWIN_Frame_AreaCopy(1, 231, 104, 258, 116, LBLX, CLINE(CONTROL_CASE_TEMP)); // Info >
  605. }
  606. else {
  607. #ifdef USE_STRING_HEADINGS
  608. Draw_Title(GET_TEXT_F(MSG_CONTROL));
  609. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(CONTROL_CASE_TEMP), GET_TEXT_F(MSG_TEMPERATURE));
  610. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(CONTROL_CASE_MOVE), GET_TEXT_F(MSG_MOTION));
  611. #if ENABLED(EEPROM_SETTINGS)
  612. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(CONTROL_CASE_SAVE), GET_TEXT_F(MSG_STORE_EEPROM));
  613. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(CONTROL_CASE_LOAD), GET_TEXT_F(MSG_LOAD_EEPROM));
  614. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(CONTROL_CASE_RESET), GET_TEXT_F(MSG_RESTORE_DEFAULTS));
  615. #endif
  616. if (CVISI(CONTROL_CASE_INFO)) DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(CONTROL_CASE_INFO), F("Info"));
  617. #else
  618. DWIN_Frame_TitleCopy(1, 128, 2, 176, 12); // "Control"
  619. DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX, CLINE(CONTROL_CASE_TEMP)); // Temperature >
  620. DWIN_Frame_AreaCopy(1, 84, 89, 128, 99, LBLX, CLINE(CONTROL_CASE_MOVE)); // Motion >
  621. #if ENABLED(EEPROM_SETTINGS)
  622. DWIN_Frame_AreaCopy(1, 148, 89, 268, 101, LBLX , CLINE(CONTROL_CASE_SAVE // "Store Configuration"
  623. DWIN_Frame_AreaCopy(1, 26, 104, 57, 114, LBLX , CLINE(CONTROL_CASE_LOAD)); // "Read"
  624. DWIN_Frame_AreaCopy(1, 182, 89, 268, 101, LBLX + 34, CLINE(CONTROL_CASE_LOAD)); // "Configuration"
  625. DWIN_Frame_AreaCopy(1, 59, 104, 93, 114, LBLX , CLINE(CONTROL_CASE_RESET)); // "Reset"
  626. DWIN_Frame_AreaCopy(1, 182, 89, 268, 101, LBLX + 37, CLINE(CONTROL_CASE_RESET)); // "Configuration"
  627. #endif
  628. if (CVISI(CONTROL_CASE_INFO)) DWIN_Frame_AreaCopy(1, 0, 104, 25, 115, LBLX, CLINE(CONTROL_CASE_INFO)); // Info >
  629. #endif
  630. }
  631. if (select_control.now && CVISI(select_control.now))
  632. Draw_Menu_Cursor(CSCROL(select_control.now));
  633. // Draw icons and lines
  634. uint8_t i = 0;
  635. #define _TEMP_ICON(N) do{ ++i; if (CVISI(i)) Draw_Menu_Line(CSCROL(i), ICON_Temperature + (N) - 1); }while(0)
  636. _TEMP_ICON(CONTROL_CASE_TEMP);
  637. if (CVISI(i)) Draw_More_Icon(CSCROL(i));
  638. _TEMP_ICON(CONTROL_CASE_MOVE);
  639. Draw_More_Icon(CSCROL(i));
  640. #if ENABLED(EEPROM_SETTINGS)
  641. _TEMP_ICON(CONTROL_CASE_SAVE);
  642. _TEMP_ICON(CONTROL_CASE_LOAD);
  643. _TEMP_ICON(CONTROL_CASE_RESET);
  644. #endif
  645. _TEMP_ICON(CONTROL_CASE_INFO);
  646. if (CVISI(CONTROL_CASE_INFO)) Draw_More_Icon(CSCROL(i));
  647. }
  648. inline void Draw_Tune_Menu() {
  649. Clear_Main_Window();
  650. if (HMI_flag.language_chinese) {
  651. DWIN_Frame_AreaCopy(1, 73, 2, 100, 13, 14, 9);
  652. DWIN_Frame_AreaCopy(1, 116, 164, 171, 176, LBLX, MBASE(TUNE_CASE_SPEED));
  653. #if HAS_HOTEND
  654. DWIN_Frame_AreaCopy(1, 1, 134, 56, 146, LBLX, MBASE(TUNE_CASE_TEMP));
  655. #endif
  656. #if HAS_HEATED_BED
  657. DWIN_Frame_AreaCopy(1, 58, 134, 113, 146, LBLX, MBASE(TUNE_CASE_BED));
  658. #endif
  659. #if HAS_FAN
  660. DWIN_Frame_AreaCopy(1, 115, 134, 170, 146, LBLX, MBASE(TUNE_CASE_FAN));
  661. #endif
  662. #if HAS_ZOFFSET_ITEM
  663. DWIN_Frame_AreaCopy(1, 174, 164, 223, 177, LBLX, MBASE(TUNE_CASE_ZOFF));
  664. #endif
  665. }
  666. else {
  667. #ifdef USE_STRING_HEADINGS
  668. Draw_Title(GET_TEXT_F(MSG_TUNE));
  669. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(TUNE_CASE_SPEED), GET_TEXT_F(MSG_SPEED));
  670. #if HAS_HOTEND
  671. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(TUNE_CASE_TEMP), GET_TEXT_F(MSG_UBL_SET_TEMP_HOTEND));
  672. #endif
  673. #if HAS_HEATED_BED
  674. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(TUNE_CASE_BED), GET_TEXT_F(MSG_UBL_SET_TEMP_BED));
  675. #endif
  676. #if HAS_FAN
  677. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(TUNE_CASE_FAN), GET_TEXT_F(MSG_FAN_SPEED));
  678. #endif
  679. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(TUNE_CASE_ZOFF), GET_TEXT_F(MSG_ZPROBE_ZOFFSET));
  680. #else
  681. DWIN_Frame_AreaCopy(1, 94, 2, 126, 12, 14, 9);
  682. DWIN_Frame_AreaCopy(1, 1, 179, 92, 190, LBLX, MBASE(TUNE_CASE_SPEED)); // Print speed
  683. #if HAS_HOTEND
  684. DWIN_Frame_AreaCopy(1, 197, 104, 238, 114, LBLX, MBASE(TUNE_CASE_TEMP)); // Hotend...
  685. DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 44, MBASE(TUNE_CASE_TEMP)); // ...Temperature
  686. #endif
  687. #if HAS_HEATED_BED
  688. DWIN_Frame_AreaCopy(1, 240, 104, 264, 114, LBLX, MBASE(TUNE_CASE_BED)); // Bed...
  689. DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 27, MBASE(TUNE_CASE_BED)); // ...Temperature
  690. #endif
  691. #if HAS_FAN
  692. DWIN_Frame_AreaCopy(1, 0, 119, 64, 132, LBLX, MBASE(TUNE_CASE_FAN)); // Fan speed
  693. #endif
  694. #if HAS_ZOFFSET_ITEM
  695. DWIN_Frame_AreaCopy(1, 93, 179, 141, 189, LBLX, MBASE(TUNE_CASE_ZOFF)); // Z-offset
  696. #endif
  697. #endif
  698. }
  699. Draw_Back_First(select_tune.now == 0);
  700. if (select_tune.now) Draw_Menu_Cursor(select_tune.now);
  701. Draw_Menu_Line(TUNE_CASE_SPEED, ICON_Speed);
  702. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_SPEED), feedrate_percentage);
  703. #if HAS_HOTEND
  704. Draw_Menu_Line(TUNE_CASE_TEMP, ICON_HotendTemp);
  705. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_TEMP), thermalManager.temp_hotend[0].target);
  706. #endif
  707. #if HAS_HEATED_BED
  708. Draw_Menu_Line(TUNE_CASE_BED, ICON_BedTemp);
  709. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_BED), thermalManager.temp_bed.target);
  710. #endif
  711. #if HAS_FAN
  712. Draw_Menu_Line(TUNE_CASE_FAN, ICON_FanSpeed);
  713. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_FAN), thermalManager.fan_speed[0]);
  714. #endif
  715. #if HAS_ZOFFSET_ITEM
  716. Draw_Menu_Line(TUNE_CASE_ZOFF, ICON_Zoffset);
  717. DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 2, 2, 202, MBASE(TUNE_CASE_ZOFF), BABY_Z_VAR * 100);
  718. #endif
  719. }
  720. inline void draw_max_en(const uint16_t line) {
  721. DWIN_Frame_AreaCopy(1, 245, 119, 269, 129, LBLX, line); // "Max"
  722. }
  723. inline void draw_max_accel_en(const uint16_t line) {
  724. draw_max_en(line);
  725. DWIN_Frame_AreaCopy(1, 1, 135, 79, 145, LBLX + 27, line); // "Acceleration"
  726. }
  727. inline void draw_speed_en(const uint16_t inset, const uint16_t line) {
  728. DWIN_Frame_AreaCopy(1, 184, 119, 224, 132, LBLX + inset, line); // "Speed"
  729. }
  730. inline void draw_jerk_en(const uint16_t line) {
  731. DWIN_Frame_AreaCopy(1, 64, 119, 106, 129, LBLX + 27, line); // "Jerk"
  732. }
  733. inline void draw_steps_per_mm(const uint16_t line) {
  734. DWIN_Frame_AreaCopy(1, 1, 151, 101, 161, LBLX, line); // "Steps-per-mm"
  735. }
  736. inline void say_x(const uint16_t inset, const uint16_t line) {
  737. DWIN_Frame_AreaCopy(1, 95, 104, 102, 114, LBLX + inset, line); // "X"
  738. }
  739. inline void say_y(const uint16_t inset, const uint16_t line) {
  740. DWIN_Frame_AreaCopy(1, 104, 104, 110, 114, LBLX + inset, line); // "Y"
  741. }
  742. inline void say_z(const uint16_t inset, const uint16_t line) {
  743. DWIN_Frame_AreaCopy(1, 112, 104, 120, 114, LBLX + inset, line); // "Z"
  744. }
  745. inline void say_e(const uint16_t inset, const uint16_t line) {
  746. DWIN_Frame_AreaCopy(1, 237, 119, 244, 129, LBLX + inset, line); // "E"
  747. }
  748. inline void Draw_Motion_Menu() {
  749. Clear_Main_Window();
  750. if (HMI_flag.language_chinese) {
  751. DWIN_Frame_TitleCopy(1, 1, 16, 28, 28); // "Motion"
  752. DWIN_Frame_AreaCopy(1, 173, 133, 228, 147, LBLX, MBASE(MOTION_CASE_RATE)); // Max speed
  753. DWIN_Frame_AreaCopy(1, 173, 133, 200, 147, LBLX, MBASE(MOTION_CASE_ACCEL)); // Max...
  754. DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(MOTION_CASE_ACCEL) + 1); // ...Acceleration
  755. #if HAS_CLASSIC_JERK
  756. DWIN_Frame_AreaCopy(1, 173, 133, 200, 147, LBLX, MBASE(MOTION_CASE_JERK)); // Max...
  757. DWIN_Frame_AreaCopy(1, 1, 180, 28, 192, LBLX + 27, MBASE(MOTION_CASE_JERK) + 1); // ...
  758. DWIN_Frame_AreaCopy(1, 202, 133, 228, 147, LBLX + 54, MBASE(MOTION_CASE_JERK)); // ...Jerk
  759. #endif
  760. DWIN_Frame_AreaCopy(1, 153, 148, 194, 161, LBLX, MBASE(MOTION_CASE_STEPS)); // Flow ratio
  761. }
  762. else {
  763. #ifdef USE_STRING_HEADINGS
  764. Draw_Title(GET_TEXT_F(MSG_MOTION));
  765. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(MOTION_CASE_RATE), F("Feedrate"));
  766. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(MOTION_CASE_ACCEL), GET_TEXT_F(MSG_ACCELERATION));
  767. #if HAS_CLASSIC_JERK
  768. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(MOTION_CASE_JERK), GET_TEXT_F(MSG_JERK));
  769. #endif
  770. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(MOTION_CASE_STEPS), GET_TEXT_F(MSG_STEPS_PER_MM));
  771. #else
  772. DWIN_Frame_TitleCopy(1, 144, 16, 189, 26); // "Motion"
  773. draw_max_en(MBASE(MOTION_CASE_RATE)); draw_speed_en(27, MBASE(MOTION_CASE_RATE)); // "Max Speed"
  774. draw_max_accel_en(MBASE(MOTION_CASE_ACCEL)); // "Max Acceleration"
  775. #if HAS_CLASSIC_JERK
  776. draw_max_en(MBASE(MOTION_CASE_JERK)); draw_jerk_en(MBASE(MOTION_CASE_JERK)); // "Max Jerk"
  777. #endif
  778. draw_steps_per_mm(MBASE(MOTION_CASE_STEPS)); // "Steps-per-mm"
  779. #endif
  780. }
  781. Draw_Back_First(select_motion.now == 0);
  782. if (select_motion.now) Draw_Menu_Cursor(select_motion.now);
  783. uint8_t i = 0;
  784. #define _MOTION_ICON(N) Draw_Menu_Line(++i, ICON_MaxSpeed + (N) - 1)
  785. _MOTION_ICON(MOTION_CASE_RATE); Draw_More_Icon(i);
  786. _MOTION_ICON(MOTION_CASE_ACCEL); Draw_More_Icon(i);
  787. #if HAS_CLASSIC_JERK
  788. _MOTION_ICON(MOTION_CASE_JERK); Draw_More_Icon(i);
  789. #endif
  790. _MOTION_ICON(MOTION_CASE_STEPS); Draw_More_Icon(i);
  791. }
  792. //
  793. // Draw Popup Windows
  794. //
  795. #if HAS_HOTEND || HAS_HEATED_BED
  796. void DWIN_Popup_Temperature(const bool toohigh) {
  797. Clear_Popup_Area();
  798. Draw_Popup_Bkgd_105();
  799. if (toohigh) {
  800. DWIN_ICON_Show(ICON, ICON_TempTooHigh, 102, 165);
  801. if (HMI_flag.language_chinese) {
  802. DWIN_Frame_AreaCopy(1, 103, 371, 237, 386, 52, 285);
  803. DWIN_Frame_AreaCopy(1, 151, 389, 185, 402, 187, 285);
  804. DWIN_Frame_AreaCopy(1, 189, 389, 271, 402, 95, 310);
  805. }
  806. else {
  807. DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, 36, 300, F("Nozzle or Bed temperature"));
  808. DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, 92, 300, F("is too high"));
  809. }
  810. }
  811. else {
  812. DWIN_ICON_Show(ICON, ICON_TempTooLow, 102, 165);
  813. if (HMI_flag.language_chinese) {
  814. DWIN_Frame_AreaCopy(1, 103, 371, 270, 386, 52, 285);
  815. DWIN_Frame_AreaCopy(1, 189, 389, 271, 402, 95, 310);
  816. }
  817. else {
  818. DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, 36, 300, F("Nozzle or Bed temperature"));
  819. DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, 92, 300, F("is too low"));
  820. }
  821. }
  822. }
  823. #endif
  824. inline void Draw_Popup_Bkgd_60() {
  825. DWIN_Draw_Rectangle(1, Color_Bg_Window, 14, 60, 258, 330);
  826. }
  827. #if HAS_HOTEND
  828. void Popup_Window_ETempTooLow() {
  829. Clear_Main_Window();
  830. Draw_Popup_Bkgd_60();
  831. DWIN_ICON_Show(ICON, ICON_TempTooLow, 102, 105);
  832. if (HMI_flag.language_chinese) {
  833. DWIN_Frame_AreaCopy(1, 103, 371, 136, 386, 69, 240);
  834. DWIN_Frame_AreaCopy(1, 170, 371, 270, 386, 102, 240);
  835. DWIN_ICON_Show(ICON, ICON_Confirm_C, 86, 280);
  836. }
  837. else {
  838. DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, 20, 235, F("Nozzle is too cold"));
  839. DWIN_ICON_Show(ICON, ICON_Confirm_E, 86, 280);
  840. }
  841. }
  842. #endif
  843. void Popup_Window_Resume() {
  844. Clear_Popup_Area();
  845. Draw_Popup_Bkgd_105();
  846. if (HMI_flag.language_chinese) {
  847. DWIN_Frame_AreaCopy(1, 160, 338, 235, 354, 98, 135);
  848. DWIN_Frame_AreaCopy(1, 103, 321, 271, 335, 52, 192);
  849. DWIN_ICON_Show(ICON, ICON_Continue_C, 26, 307);
  850. DWIN_ICON_Show(ICON, ICON_Cancel_C, 146, 307);
  851. }
  852. else {
  853. DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 14) / 2, 115, F("Continue Print"));
  854. DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 22) / 2, 192, F("It looks like the last"));
  855. DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 22) / 2, 212, F("file was interrupted."));
  856. DWIN_ICON_Show(ICON, ICON_Continue_E, 26, 307);
  857. DWIN_ICON_Show(ICON, ICON_Cancel_E, 146, 307);
  858. }
  859. }
  860. void Popup_Window_Home(const bool parking/*=false*/) {
  861. Clear_Main_Window();
  862. Draw_Popup_Bkgd_60();
  863. DWIN_ICON_Show(ICON, ICON_BLTouch, 101, 105);
  864. if (HMI_flag.language_chinese) {
  865. DWIN_Frame_AreaCopy(1, 0, 371, 33, 386, 85, 240);
  866. DWIN_Frame_AreaCopy(1, 203, 286, 271, 302, 118, 240);
  867. DWIN_Frame_AreaCopy(1, 0, 389, 150, 402, 61, 280);
  868. }
  869. else {
  870. DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * (parking ? 7 : 10)) / 2, 230, parking ? F("Parking") : F("Homing XYZ"));
  871. DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 23) / 2, 260, F("Please wait until done."));
  872. }
  873. }
  874. #if HAS_ONESTEP_LEVELING
  875. void Popup_Window_Leveling() {
  876. Clear_Main_Window();
  877. Draw_Popup_Bkgd_60();
  878. DWIN_ICON_Show(ICON, ICON_AutoLeveling, 101, 105);
  879. if (HMI_flag.language_chinese) {
  880. DWIN_Frame_AreaCopy(1, 0, 371, 100, 386, 84, 240);
  881. DWIN_Frame_AreaCopy(1, 0, 389, 150, 402, 61, 280);
  882. }
  883. else {
  884. DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 13) / 2, 230, GET_TEXT_F(MSG_BED_LEVELING));
  885. DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 23) / 2, 260, F("Please wait until done."));
  886. }
  887. }
  888. #endif
  889. void Draw_Select_Highlight(const bool sel) {
  890. HMI_flag.select_flag = sel;
  891. const uint16_t c1 = sel ? Select_Color : Color_Bg_Window,
  892. c2 = sel ? Color_Bg_Window : Select_Color;
  893. DWIN_Draw_Rectangle(0, c1, 25, 279, 126, 318);
  894. DWIN_Draw_Rectangle(0, c1, 24, 278, 127, 319);
  895. DWIN_Draw_Rectangle(0, c2, 145, 279, 246, 318);
  896. DWIN_Draw_Rectangle(0, c2, 144, 278, 247, 319);
  897. }
  898. void Popup_window_PauseOrStop() {
  899. Clear_Main_Window();
  900. Draw_Popup_Bkgd_60();
  901. if (HMI_flag.language_chinese) {
  902. if (select_print.now == 1) DWIN_Frame_AreaCopy(1, 237, 338, 269, 356, 98, 150);
  903. else if (select_print.now == 2) DWIN_Frame_AreaCopy(1, 221, 320, 253, 336, 98, 150);
  904. DWIN_Frame_AreaCopy(1, 220, 304, 264, 319, 130, 150);
  905. DWIN_ICON_Show(ICON, ICON_Confirm_C, 26, 280);
  906. DWIN_ICON_Show(ICON, ICON_Cancel_C, 146, 280);
  907. }
  908. else {
  909. if (select_print.now == 1) DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 11) / 2, 150, GET_TEXT_F(MSG_PAUSE_PRINT));
  910. else if (select_print.now == 2) DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 10) / 2, 150, GET_TEXT_F(MSG_STOP_PRINT));
  911. DWIN_ICON_Show(ICON, ICON_Confirm_E, 26, 280);
  912. DWIN_ICON_Show(ICON, ICON_Cancel_E, 146, 280);
  913. }
  914. Draw_Select_Highlight(true);
  915. }
  916. void Draw_Printing_Screen() {
  917. if (HMI_flag.language_chinese) {
  918. DWIN_Frame_AreaCopy(1, 30, 1, 71, 14, 14, 9); // Tune
  919. DWIN_Frame_AreaCopy(1, 0, 72, 63, 86, 41, 188); // Pause
  920. DWIN_Frame_AreaCopy(1, 65, 72, 128, 86, 176, 188); // Stop
  921. }
  922. else {
  923. DWIN_Frame_AreaCopy(1, 40, 2, 92, 14, 14, 9); // Tune
  924. DWIN_Frame_AreaCopy(1, 0, 44, 96, 58, 41, 188); // Pause
  925. DWIN_Frame_AreaCopy(1, 98, 44, 152, 58, 176, 188); // Stop
  926. }
  927. }
  928. void Draw_Print_ProgressBar() {
  929. DWIN_ICON_Show(ICON, ICON_Bar, 15, 93);
  930. DWIN_Draw_Rectangle(1, BarFill_Color, 16 + Percentrecord * 240 / 100, 93, 256, 113);
  931. DWIN_Draw_IntValue(true, true, 0, font8x16, Percent_Color, Color_Bg_Black, 2, 117, 133, Percentrecord);
  932. DWIN_Draw_String(false, false, font8x16, Percent_Color, Color_Bg_Black, 133, 133, F("%"));
  933. }
  934. void Draw_Print_ProgressElapsed() {
  935. duration_t elapsed = print_job_timer.duration(); // print timer
  936. DWIN_Draw_IntValue(true, true, 1, font8x16, Color_White, Color_Bg_Black, 2, 42, 212, elapsed.value / 3600);
  937. DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, 58, 212, F(":"));
  938. DWIN_Draw_IntValue(true, true, 1, font8x16, Color_White, Color_Bg_Black, 2, 66, 212, (elapsed.value % 3600) / 60);
  939. }
  940. void Draw_Print_ProgressRemain() {
  941. DWIN_Draw_IntValue(true, true, 1, font8x16, Color_White, Color_Bg_Black, 2, 176, 212, remain_time / 3600);
  942. DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, 192, 212, F(":"));
  943. DWIN_Draw_IntValue(true, true, 1, font8x16, Color_White, Color_Bg_Black, 2, 200, 212, (remain_time % 3600) / 60);
  944. }
  945. void Goto_PrintProcess() {
  946. checkkey = PrintProcess;
  947. Clear_Main_Window();
  948. Draw_Printing_Screen();
  949. ICON_Tune();
  950. if (printingIsPaused()) ICON_Continue(); else ICON_Pause();
  951. ICON_Stop();
  952. // Copy into filebuf string before entry
  953. char * const name = card.longest_filename();
  954. const int8_t npos = _MAX(0U, DWIN_WIDTH - strlen(name) * MENU_CHR_W) / 2;
  955. DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, npos, 60, name);
  956. DWIN_ICON_Show(ICON, ICON_PrintTime, 17, 193);
  957. DWIN_ICON_Show(ICON, ICON_RemainTime, 150, 191);
  958. Draw_Print_ProgressBar();
  959. Draw_Print_ProgressElapsed();
  960. Draw_Print_ProgressRemain();
  961. }
  962. void Goto_MainMenu() {
  963. checkkey = MainMenu;
  964. Clear_Main_Window();
  965. if (HMI_flag.language_chinese) {
  966. DWIN_Frame_AreaCopy(1, 2, 2, 27, 14, 14, 9); // "Home"
  967. }
  968. else {
  969. #ifdef USE_STRING_HEADINGS
  970. Draw_Title(GET_TEXT_F(MSG_MAIN));
  971. #else
  972. DWIN_Frame_AreaCopy(1, 0, 2, 39, 12, 14, 9);
  973. #endif
  974. }
  975. DWIN_ICON_Show(ICON, ICON_LOGO, 71, 52);
  976. ICON_Print();
  977. ICON_Prepare();
  978. ICON_Control();
  979. TERN(HAS_ONESTEP_LEVELING, ICON_Leveling, ICON_StartInfo)(select_page.now == 3);
  980. }
  981. inline ENCODER_DiffState get_encoder_state() {
  982. static millis_t Encoder_ms = 0;
  983. const millis_t ms = millis();
  984. if (PENDING(ms, Encoder_ms)) return ENCODER_DIFF_NO;
  985. const ENCODER_DiffState state = Encoder_ReceiveAnalyze();
  986. if (state != ENCODER_DIFF_NO) Encoder_ms = ms + ENCODER_WAIT;
  987. return state;
  988. }
  989. void HMI_Move_X() {
  990. ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
  991. if (encoder_diffState != ENCODER_DIFF_NO) {
  992. if (encoder_diffState == ENCODER_DIFF_CW) {
  993. HMI_ValueStruct.Move_X_scale += EncoderRate.encoderMoveValue;
  994. }
  995. else if (encoder_diffState == ENCODER_DIFF_CCW) {
  996. HMI_ValueStruct.Move_X_scale -= EncoderRate.encoderMoveValue;
  997. }
  998. else if (encoder_diffState == ENCODER_DIFF_ENTER) {
  999. checkkey = AxisMove;
  1000. EncoderRate.enabled = false;
  1001. DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scale);
  1002. if (!planner.is_full()) {
  1003. // Wait for planner moves to finish!
  1004. planner.synchronize();
  1005. planner.buffer_line(current_position, MMM_TO_MMS(HOMING_FEEDRATE_XY), active_extruder);
  1006. }
  1007. DWIN_UpdateLCD();
  1008. return;
  1009. }
  1010. NOLESS(HMI_ValueStruct.Move_X_scale, (X_MIN_POS) * MINUNITMULT);
  1011. NOMORE(HMI_ValueStruct.Move_X_scale, (X_MAX_POS) * MINUNITMULT);
  1012. current_position.x = HMI_ValueStruct.Move_X_scale / 10;
  1013. DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scale);
  1014. DWIN_UpdateLCD();
  1015. }
  1016. }
  1017. void HMI_Move_Y() {
  1018. ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
  1019. if (encoder_diffState != ENCODER_DIFF_NO) {
  1020. if (encoder_diffState == ENCODER_DIFF_CW) {
  1021. HMI_ValueStruct.Move_Y_scale += EncoderRate.encoderMoveValue;
  1022. }
  1023. else if (encoder_diffState == ENCODER_DIFF_CCW) {
  1024. HMI_ValueStruct.Move_Y_scale -= EncoderRate.encoderMoveValue;
  1025. }
  1026. else if (encoder_diffState == ENCODER_DIFF_ENTER) {
  1027. checkkey = AxisMove;
  1028. EncoderRate.enabled = false;
  1029. DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scale);
  1030. if (!planner.is_full()) {
  1031. // Wait for planner moves to finish!
  1032. planner.synchronize();
  1033. planner.buffer_line(current_position, MMM_TO_MMS(HOMING_FEEDRATE_XY), active_extruder);
  1034. }
  1035. DWIN_UpdateLCD();
  1036. return;
  1037. }
  1038. NOLESS(HMI_ValueStruct.Move_Y_scale, (Y_MIN_POS) * MINUNITMULT);
  1039. NOMORE(HMI_ValueStruct.Move_Y_scale, (Y_MAX_POS) * MINUNITMULT);
  1040. current_position.y = HMI_ValueStruct.Move_Y_scale / 10;
  1041. DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scale);
  1042. DWIN_UpdateLCD();
  1043. }
  1044. }
  1045. void HMI_Move_Z() {
  1046. ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
  1047. if (encoder_diffState != ENCODER_DIFF_NO) {
  1048. if (encoder_diffState == ENCODER_DIFF_CW) {
  1049. HMI_ValueStruct.Move_Z_scale += EncoderRate.encoderMoveValue;
  1050. }
  1051. else if (encoder_diffState == ENCODER_DIFF_CCW) {
  1052. HMI_ValueStruct.Move_Z_scale -= EncoderRate.encoderMoveValue;
  1053. }
  1054. else if (encoder_diffState == ENCODER_DIFF_ENTER) {
  1055. checkkey = AxisMove;
  1056. EncoderRate.enabled = false;
  1057. DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scale);
  1058. if (!planner.is_full()) {
  1059. // Wait for planner moves to finish!
  1060. planner.synchronize();
  1061. planner.buffer_line(current_position, MMM_TO_MMS(HOMING_FEEDRATE_Z), active_extruder);
  1062. }
  1063. DWIN_UpdateLCD();
  1064. return;
  1065. }
  1066. NOLESS(HMI_ValueStruct.Move_Z_scale, Z_MIN_POS * MINUNITMULT);
  1067. NOMORE(HMI_ValueStruct.Move_Z_scale, Z_MAX_POS * MINUNITMULT);
  1068. current_position.z = HMI_ValueStruct.Move_Z_scale / 10;
  1069. DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scale);
  1070. DWIN_UpdateLCD();
  1071. }
  1072. }
  1073. #if HAS_HOTEND
  1074. void HMI_Move_E() {
  1075. static float last_E_scale = 0;
  1076. ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
  1077. if (encoder_diffState != ENCODER_DIFF_NO) {
  1078. if (encoder_diffState == ENCODER_DIFF_CW) {
  1079. HMI_ValueStruct.Move_E_scale += EncoderRate.encoderMoveValue;
  1080. }
  1081. else if (encoder_diffState == ENCODER_DIFF_CCW) {
  1082. HMI_ValueStruct.Move_E_scale -= EncoderRate.encoderMoveValue;
  1083. }
  1084. else if (encoder_diffState == ENCODER_DIFF_ENTER) {
  1085. checkkey = AxisMove;
  1086. EncoderRate.enabled = false;
  1087. last_E_scale = HMI_ValueStruct.Move_E_scale;
  1088. DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale);
  1089. if (!planner.is_full()) {
  1090. planner.synchronize(); // Wait for planner moves to finish!
  1091. planner.buffer_line(current_position, MMM_TO_MMS(FEEDRATE_E), active_extruder);
  1092. }
  1093. DWIN_UpdateLCD();
  1094. return;
  1095. }
  1096. if ((HMI_ValueStruct.Move_E_scale - last_E_scale) > (EXTRUDE_MAXLENGTH) * MINUNITMULT)
  1097. HMI_ValueStruct.Move_E_scale = last_E_scale + (EXTRUDE_MAXLENGTH) * MINUNITMULT;
  1098. else if ((last_E_scale - HMI_ValueStruct.Move_E_scale) > (EXTRUDE_MAXLENGTH) * MINUNITMULT)
  1099. HMI_ValueStruct.Move_E_scale = last_E_scale - (EXTRUDE_MAXLENGTH) * MINUNITMULT;
  1100. current_position.e = HMI_ValueStruct.Move_E_scale / 10;
  1101. DWIN_Draw_Signed_Float(font8x16, Select_Color, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale);
  1102. DWIN_UpdateLCD();
  1103. }
  1104. }
  1105. #endif
  1106. #if HAS_ZOFFSET_ITEM
  1107. bool printer_busy() { return planner.movesplanned() || printingIsActive(); }
  1108. void HMI_Zoffset() {
  1109. ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
  1110. if (encoder_diffState != ENCODER_DIFF_NO) {
  1111. uint8_t zoff_line;
  1112. switch (HMI_ValueStruct.show_mode) {
  1113. case -4: zoff_line = PREPARE_CASE_ZOFF + MROWS - index_prepare; break;
  1114. default: zoff_line = TUNE_CASE_ZOFF + MROWS - index_tune;
  1115. }
  1116. if (encoder_diffState == ENCODER_DIFF_CW)
  1117. HMI_ValueStruct.offset_value += EncoderRate.encoderMoveValue;
  1118. else if (encoder_diffState == ENCODER_DIFF_CCW)
  1119. HMI_ValueStruct.offset_value -= EncoderRate.encoderMoveValue;
  1120. else if (encoder_diffState == ENCODER_DIFF_ENTER) {
  1121. EncoderRate.enabled = false;
  1122. #if HAS_BED_PROBE
  1123. probe.offset.z = dwin_zoffset;
  1124. TERN_(EEPROM_SETTINGS, settings.save());
  1125. #endif
  1126. if (HMI_ValueStruct.show_mode == -4) {
  1127. checkkey = Prepare;
  1128. DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 2, 2, 202, MBASE(zoff_line), TERN(HAS_BED_PROBE, BABY_Z_VAR * 100, HMI_ValueStruct.offset_value));
  1129. }
  1130. else {
  1131. checkkey = Tune;
  1132. DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 2, 2, 202, MBASE(zoff_line), TERN(HAS_BED_PROBE, BABY_Z_VAR * 100, HMI_ValueStruct.offset_value));
  1133. }
  1134. DWIN_UpdateLCD();
  1135. return;
  1136. }
  1137. NOLESS(HMI_ValueStruct.offset_value, (Z_PROBE_OFFSET_RANGE_MIN) * 100);
  1138. NOMORE(HMI_ValueStruct.offset_value, (Z_PROBE_OFFSET_RANGE_MAX) * 100);
  1139. last_zoffset = dwin_zoffset;
  1140. dwin_zoffset = HMI_ValueStruct.offset_value / 100.0f;
  1141. #if EITHER(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP)
  1142. if ( (ENABLED(BABYSTEP_WITHOUT_HOMING) || all_axes_known()) && (ENABLED(BABYSTEP_ALWAYS_AVAILABLE) || printer_busy()) )
  1143. babystep.add_mm(Z_AXIS, dwin_zoffset - last_zoffset);
  1144. #endif
  1145. DWIN_Draw_Signed_Float(font8x16, Select_Color, 2, 2, 202, MBASE(zoff_line), HMI_ValueStruct.offset_value);
  1146. DWIN_UpdateLCD();
  1147. }
  1148. }
  1149. #endif // HAS_ZOFFSET_ITEM
  1150. #if HAS_HOTEND
  1151. void HMI_ETemp() {
  1152. ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
  1153. if (encoder_diffState != ENCODER_DIFF_NO) {
  1154. uint8_t temp_line;
  1155. switch (HMI_ValueStruct.show_mode) {
  1156. case -1: temp_line = TEMP_CASE_TEMP; break;
  1157. case -2: temp_line = PREHEAT_CASE_TEMP; break;
  1158. case -3: temp_line = PREHEAT_CASE_TEMP; break;
  1159. default: temp_line = TUNE_CASE_TEMP + MROWS - index_tune;
  1160. }
  1161. if (encoder_diffState == ENCODER_DIFF_CW) {
  1162. HMI_ValueStruct.E_Temp += EncoderRate.encoderMoveValue;
  1163. }
  1164. else if (encoder_diffState == ENCODER_DIFF_CCW) {
  1165. HMI_ValueStruct.E_Temp -= EncoderRate.encoderMoveValue;
  1166. }
  1167. else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return
  1168. EncoderRate.enabled = false;
  1169. if (HMI_ValueStruct.show_mode == -1) { // temperature
  1170. checkkey = TemperatureID;
  1171. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(temp_line), HMI_ValueStruct.E_Temp);
  1172. }
  1173. else if (HMI_ValueStruct.show_mode == -2) {
  1174. checkkey = PLAPreheat;
  1175. ui.material_preset[0].hotend_temp = HMI_ValueStruct.E_Temp;
  1176. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(temp_line), ui.material_preset[0].hotend_temp);
  1177. return;
  1178. }
  1179. else if (HMI_ValueStruct.show_mode == -3) {
  1180. checkkey = ABSPreheat;
  1181. ui.material_preset[1].hotend_temp = HMI_ValueStruct.E_Temp;
  1182. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(temp_line), ui.material_preset[1].hotend_temp);
  1183. return;
  1184. }
  1185. else { // tune
  1186. checkkey = Tune;
  1187. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(temp_line), HMI_ValueStruct.E_Temp);
  1188. }
  1189. thermalManager.setTargetHotend(HMI_ValueStruct.E_Temp, 0);
  1190. return;
  1191. }
  1192. // E_Temp limit
  1193. NOMORE(HMI_ValueStruct.E_Temp, MAX_E_TEMP);
  1194. NOLESS(HMI_ValueStruct.E_Temp, MIN_E_TEMP);
  1195. // E_Temp value
  1196. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(temp_line), HMI_ValueStruct.E_Temp);
  1197. }
  1198. }
  1199. #endif // HAS_HOTEND
  1200. #if HAS_HEATED_BED
  1201. void HMI_BedTemp() {
  1202. ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
  1203. if (encoder_diffState != ENCODER_DIFF_NO) {
  1204. uint8_t bed_line;
  1205. switch (HMI_ValueStruct.show_mode) {
  1206. case -1: bed_line = TEMP_CASE_BED; break;
  1207. case -2: bed_line = PREHEAT_CASE_BED; break;
  1208. case -3: bed_line = PREHEAT_CASE_BED; break;
  1209. default: bed_line = TUNE_CASE_BED + MROWS - index_tune;
  1210. }
  1211. if (encoder_diffState == ENCODER_DIFF_CW) {
  1212. HMI_ValueStruct.Bed_Temp += EncoderRate.encoderMoveValue;
  1213. }
  1214. else if (encoder_diffState == ENCODER_DIFF_CCW) {
  1215. HMI_ValueStruct.Bed_Temp -= EncoderRate.encoderMoveValue;
  1216. }
  1217. else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return
  1218. EncoderRate.enabled = false;
  1219. if (HMI_ValueStruct.show_mode == -1) {
  1220. checkkey = TemperatureID;
  1221. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(bed_line), HMI_ValueStruct.Bed_Temp);
  1222. }
  1223. else if (HMI_ValueStruct.show_mode == -2) {
  1224. checkkey = PLAPreheat;
  1225. ui.material_preset[0].bed_temp = HMI_ValueStruct.Bed_Temp;
  1226. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(bed_line), ui.material_preset[0].bed_temp);
  1227. return;
  1228. }
  1229. else if (HMI_ValueStruct.show_mode == -3) {
  1230. checkkey = ABSPreheat;
  1231. ui.material_preset[1].bed_temp = HMI_ValueStruct.Bed_Temp;
  1232. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(bed_line), ui.material_preset[1].bed_temp);
  1233. return;
  1234. }
  1235. else {
  1236. checkkey = Tune;
  1237. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(bed_line), HMI_ValueStruct.Bed_Temp);
  1238. }
  1239. thermalManager.setTargetBed(HMI_ValueStruct.Bed_Temp);
  1240. return;
  1241. }
  1242. // Bed_Temp limit
  1243. NOMORE(HMI_ValueStruct.Bed_Temp, BED_MAX_TARGET);
  1244. NOLESS(HMI_ValueStruct.Bed_Temp, MIN_BED_TEMP);
  1245. // Bed_Temp value
  1246. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(bed_line), HMI_ValueStruct.Bed_Temp);
  1247. }
  1248. }
  1249. #endif // HAS_HEATED_BED
  1250. #if HAS_PREHEAT
  1251. void HMI_FanSpeed() {
  1252. ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
  1253. if (encoder_diffState != ENCODER_DIFF_NO) {
  1254. uint8_t fan_line;
  1255. switch (HMI_ValueStruct.show_mode) {
  1256. case -1: fan_line = TEMP_CASE_FAN; break;
  1257. case -2: fan_line = PREHEAT_CASE_FAN; break;
  1258. case -3: fan_line = PREHEAT_CASE_FAN; break;
  1259. default: fan_line = TUNE_CASE_FAN + MROWS - index_tune;
  1260. }
  1261. if (encoder_diffState == ENCODER_DIFF_CW) {
  1262. HMI_ValueStruct.Fan_speed += EncoderRate.encoderMoveValue;
  1263. }
  1264. else if (encoder_diffState == ENCODER_DIFF_CCW) {
  1265. HMI_ValueStruct.Fan_speed -= EncoderRate.encoderMoveValue;
  1266. }
  1267. else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return
  1268. EncoderRate.enabled = false;
  1269. if (HMI_ValueStruct.show_mode == -1) {
  1270. checkkey = TemperatureID;
  1271. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(fan_line), HMI_ValueStruct.Fan_speed);
  1272. }
  1273. else if (HMI_ValueStruct.show_mode == -2) {
  1274. checkkey = PLAPreheat;
  1275. ui.material_preset[0].fan_speed = HMI_ValueStruct.Fan_speed;
  1276. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(fan_line), ui.material_preset[0].fan_speed);
  1277. return;
  1278. }
  1279. else if (HMI_ValueStruct.show_mode == -3) {
  1280. checkkey = ABSPreheat;
  1281. ui.material_preset[1].fan_speed = HMI_ValueStruct.Fan_speed;
  1282. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(fan_line), ui.material_preset[1].fan_speed);
  1283. return;
  1284. }
  1285. else {
  1286. checkkey = Tune;
  1287. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(fan_line), HMI_ValueStruct.Fan_speed);
  1288. }
  1289. thermalManager.set_fan_speed(0, HMI_ValueStruct.Fan_speed);
  1290. return;
  1291. }
  1292. // Fan_speed limit
  1293. NOMORE(HMI_ValueStruct.Fan_speed, FANON);
  1294. NOLESS(HMI_ValueStruct.Fan_speed, FANOFF);
  1295. // Fan_speed value
  1296. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(fan_line), HMI_ValueStruct.Fan_speed);
  1297. }
  1298. }
  1299. #endif // HAS_PREHEAT
  1300. void HMI_PrintSpeed() {
  1301. ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
  1302. if (encoder_diffState != ENCODER_DIFF_NO) {
  1303. if (encoder_diffState == ENCODER_DIFF_CW) {
  1304. HMI_ValueStruct.print_speed += EncoderRate.encoderMoveValue;
  1305. }
  1306. else if (encoder_diffState == ENCODER_DIFF_CCW) {
  1307. HMI_ValueStruct.print_speed -= EncoderRate.encoderMoveValue;
  1308. }
  1309. else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return
  1310. checkkey = Tune;
  1311. EncoderRate.enabled = false;
  1312. feedrate_percentage = HMI_ValueStruct.print_speed;
  1313. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(select_tune.now + MROWS - index_tune), HMI_ValueStruct.print_speed);
  1314. return;
  1315. }
  1316. // print_speed limit
  1317. NOMORE(HMI_ValueStruct.print_speed, MAX_PRINT_SPEED);
  1318. NOLESS(HMI_ValueStruct.print_speed, MIN_PRINT_SPEED);
  1319. // print_speed value
  1320. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(select_tune.now + MROWS - index_tune), HMI_ValueStruct.print_speed);
  1321. }
  1322. }
  1323. void HMI_MaxFeedspeedXYZE() {
  1324. ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
  1325. if (encoder_diffState != ENCODER_DIFF_NO) {
  1326. if (encoder_diffState == ENCODER_DIFF_CW) {
  1327. HMI_ValueStruct.Max_Feedspeed += EncoderRate.encoderMoveValue;
  1328. }
  1329. else if (encoder_diffState == ENCODER_DIFF_CCW) {
  1330. HMI_ValueStruct.Max_Feedspeed -= EncoderRate.encoderMoveValue;
  1331. }
  1332. else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return
  1333. checkkey = MaxSpeed;
  1334. EncoderRate.enabled = false;
  1335. if (WITHIN(HMI_flag.feedspeed_axis, X_AXIS, E_AXIS))
  1336. planner.set_max_feedrate(HMI_flag.feedspeed_axis, HMI_ValueStruct.Max_Feedspeed);
  1337. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 4, 210, MBASE(select_speed.now), HMI_ValueStruct.Max_Feedspeed);
  1338. return;
  1339. }
  1340. // MaxFeedspeed limit
  1341. if (WITHIN(HMI_flag.feedspeed_axis, X_AXIS, E_AXIS))
  1342. NOMORE(HMI_ValueStruct.Max_Feedspeed, default_max_feedrate[HMI_flag.feedspeed_axis] * 2);
  1343. if (HMI_ValueStruct.Max_Feedspeed < MIN_MAXFEEDSPEED) HMI_ValueStruct.Max_Feedspeed = MIN_MAXFEEDSPEED;
  1344. // MaxFeedspeed value
  1345. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 4, 210, MBASE(select_speed.now), HMI_ValueStruct.Max_Feedspeed);
  1346. }
  1347. }
  1348. void HMI_MaxAccelerationXYZE() {
  1349. ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
  1350. if (encoder_diffState != ENCODER_DIFF_NO) {
  1351. if (encoder_diffState == ENCODER_DIFF_CW) { HMI_ValueStruct.Max_Acceleration += EncoderRate.encoderMoveValue;}
  1352. else if (encoder_diffState == ENCODER_DIFF_CCW) { HMI_ValueStruct.Max_Acceleration -= EncoderRate.encoderMoveValue;}
  1353. else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return
  1354. checkkey = MaxAcceleration;
  1355. EncoderRate.enabled = false;
  1356. if (HMI_flag.acc_axis == X_AXIS) planner.set_max_acceleration(X_AXIS, HMI_ValueStruct.Max_Acceleration);
  1357. else if (HMI_flag.acc_axis == Y_AXIS) planner.set_max_acceleration(Y_AXIS, HMI_ValueStruct.Max_Acceleration);
  1358. else if (HMI_flag.acc_axis == Z_AXIS) planner.set_max_acceleration(Z_AXIS, HMI_ValueStruct.Max_Acceleration);
  1359. #if HAS_HOTEND
  1360. else if (HMI_flag.acc_axis == E_AXIS) planner.set_max_acceleration(E_AXIS, HMI_ValueStruct.Max_Acceleration);
  1361. #endif
  1362. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 4, 210, MBASE(select_acc.now), HMI_ValueStruct.Max_Acceleration);
  1363. return;
  1364. }
  1365. // MaxAcceleration limit
  1366. if (WITHIN(HMI_flag.acc_axis, X_AXIS, E_AXIS))
  1367. NOMORE(HMI_ValueStruct.Max_Acceleration, default_max_acceleration[HMI_flag.acc_axis] * 2);
  1368. if (HMI_ValueStruct.Max_Acceleration < MIN_MAXACCELERATION) HMI_ValueStruct.Max_Acceleration = MIN_MAXACCELERATION;
  1369. // MaxAcceleration value
  1370. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 4, 210, MBASE(select_acc.now), HMI_ValueStruct.Max_Acceleration);
  1371. }
  1372. }
  1373. #if HAS_CLASSIC_JERK
  1374. void HMI_MaxJerkXYZE() {
  1375. ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
  1376. if (encoder_diffState != ENCODER_DIFF_NO) {
  1377. if (encoder_diffState == ENCODER_DIFF_CW)
  1378. HMI_ValueStruct.Max_Jerk += EncoderRate.encoderMoveValue;
  1379. else if (encoder_diffState == ENCODER_DIFF_CCW)
  1380. HMI_ValueStruct.Max_Jerk -= EncoderRate.encoderMoveValue;
  1381. else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return
  1382. checkkey = MaxJerk;
  1383. EncoderRate.enabled = false;
  1384. if (WITHIN(HMI_flag.step_axis, X_AXIS, E_AXIS))
  1385. planner.set_max_jerk(HMI_flag.step_axis, HMI_ValueStruct.Max_Jerk / 10);
  1386. DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk);
  1387. return;
  1388. }
  1389. // MaxJerk limit
  1390. if (WITHIN(HMI_flag.jerk_axis, X_AXIS, E_AXIS))
  1391. NOMORE(HMI_ValueStruct.Max_Jerk, default_max_jerk[HMI_flag.jerk_axis] * 2 * MINUNITMULT);
  1392. NOLESS(HMI_ValueStruct.Max_Jerk, (MIN_MAXJERK) * MINUNITMULT);
  1393. // MaxJerk value
  1394. DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 1, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk);
  1395. }
  1396. }
  1397. #endif // HAS_CLASSIC_JERK
  1398. void HMI_StepXYZE() {
  1399. ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
  1400. if (encoder_diffState != ENCODER_DIFF_NO) {
  1401. if (encoder_diffState == ENCODER_DIFF_CW) {
  1402. HMI_ValueStruct.Max_Step += EncoderRate.encoderMoveValue;
  1403. }
  1404. else if (encoder_diffState == ENCODER_DIFF_CCW) {
  1405. HMI_ValueStruct.Max_Step -= EncoderRate.encoderMoveValue;
  1406. }
  1407. else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return
  1408. checkkey = Step;
  1409. EncoderRate.enabled = false;
  1410. if (WITHIN(HMI_flag.step_axis, X_AXIS, E_AXIS))
  1411. planner.settings.axis_steps_per_mm[HMI_flag.step_axis] = HMI_ValueStruct.Max_Step / 10;
  1412. DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step);
  1413. return;
  1414. }
  1415. // Step limit
  1416. if (WITHIN(HMI_flag.step_axis, X_AXIS, E_AXIS))
  1417. NOMORE(HMI_ValueStruct.Max_Step, default_axis_steps_per_unit[HMI_flag.step_axis] * 2 * MINUNITMULT);
  1418. NOLESS(HMI_ValueStruct.Max_Step, MIN_STEP);
  1419. // Step value
  1420. DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 1, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step);
  1421. }
  1422. }
  1423. void update_variable() {
  1424. #if HAS_HOTEND
  1425. static float last_temp_hotend_target = 0, last_temp_hotend_current = 0;
  1426. #endif
  1427. #if HAS_HEATED_BED
  1428. static float last_temp_bed_target = 0, last_temp_bed_current = 0;
  1429. #endif
  1430. #if HAS_FAN
  1431. static uint8_t last_fan_speed = 0;
  1432. #endif
  1433. /* Tune page temperature update */
  1434. if (checkkey == Tune) {
  1435. #if HAS_HOTEND
  1436. if (last_temp_hotend_target != thermalManager.temp_hotend[0].target)
  1437. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_TEMP + MROWS - index_tune), thermalManager.temp_hotend[0].target);
  1438. #endif
  1439. #if HAS_HEATED_BED
  1440. if (last_temp_bed_target != thermalManager.temp_bed.target)
  1441. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_BED + MROWS - index_tune), thermalManager.temp_bed.target);
  1442. #endif
  1443. #if HAS_FAN
  1444. if (last_fan_speed != thermalManager.fan_speed[0]) {
  1445. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_FAN + MROWS - index_tune), thermalManager.fan_speed[0]);
  1446. last_fan_speed = thermalManager.fan_speed[0];
  1447. }
  1448. #endif
  1449. }
  1450. /* Temperature page temperature update */
  1451. if (checkkey == TemperatureID) {
  1452. #if HAS_HOTEND
  1453. if (last_temp_hotend_target != thermalManager.temp_hotend[0].target)
  1454. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TEMP_CASE_TEMP), thermalManager.temp_hotend[0].target);
  1455. #endif
  1456. #if HAS_HEATED_BED
  1457. if (last_temp_bed_target != thermalManager.temp_bed.target)
  1458. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TEMP_CASE_BED), thermalManager.temp_bed.target);
  1459. #endif
  1460. #if HAS_FAN
  1461. if (last_fan_speed != thermalManager.fan_speed[0]) {
  1462. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TEMP_CASE_FAN), thermalManager.fan_speed[0]);
  1463. last_fan_speed = thermalManager.fan_speed[0];
  1464. }
  1465. #endif
  1466. }
  1467. /* Bottom temperature update */
  1468. #if HAS_HOTEND
  1469. if (last_temp_hotend_current != thermalManager.temp_hotend[0].celsius) {
  1470. DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 33, 382, thermalManager.temp_hotend[0].celsius);
  1471. last_temp_hotend_current = thermalManager.temp_hotend[0].celsius;
  1472. }
  1473. if (last_temp_hotend_target != thermalManager.temp_hotend[0].target) {
  1474. DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 33 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_hotend[0].target);
  1475. last_temp_hotend_target = thermalManager.temp_hotend[0].target;
  1476. }
  1477. #endif
  1478. #if HAS_HEATED_BED
  1479. if (last_temp_bed_current != thermalManager.temp_bed.celsius) {
  1480. DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 178, 382, thermalManager.temp_bed.celsius);
  1481. last_temp_bed_current = thermalManager.temp_bed.celsius;
  1482. }
  1483. if (last_temp_bed_target != thermalManager.temp_bed.target) {
  1484. DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 178 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_bed.target);
  1485. last_temp_bed_target = thermalManager.temp_bed.target;
  1486. }
  1487. #endif
  1488. static uint16_t last_speed = 0;
  1489. if (last_speed != feedrate_percentage) {
  1490. DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 33 + 2 * STAT_CHR_W, 429, feedrate_percentage);
  1491. last_speed = feedrate_percentage;
  1492. }
  1493. #if HAS_ZOFFSET_ITEM
  1494. if (last_zoffset != BABY_Z_VAR) {
  1495. DWIN_Draw_Signed_Float(DWIN_FONT_STAT, Color_Bg_Black, 2, 2, 178 + STAT_CHR_W, 429, BABY_Z_VAR * 100);
  1496. last_zoffset = BABY_Z_VAR;
  1497. }
  1498. #endif
  1499. }
  1500. /**
  1501. * Read and cache the working directory.
  1502. *
  1503. * TODO: New code can follow the pattern of menu_media.cpp
  1504. * and rely on Marlin caching for performance. No need to
  1505. * cache files here.
  1506. *
  1507. */
  1508. #ifndef strcasecmp_P
  1509. #define strcasecmp_P(a, b) strcasecmp((a), (b))
  1510. #endif
  1511. inline void make_name_without_ext(char *dst, char *src, size_t maxlen=MENU_CHAR_LIMIT) {
  1512. char * const name = card.longest_filename();
  1513. size_t pos = strlen(name); // index of ending nul
  1514. // For files, remove the extension
  1515. // which may be .gcode, .gco, or .g
  1516. if (!card.flag.filenameIsDir)
  1517. while (pos && src[pos] != '.') pos--; // find last '.' (stop at 0)
  1518. size_t len = pos; // nul or '.'
  1519. if (len > maxlen) { // Keep the name short
  1520. pos = len = maxlen; // move nul down
  1521. dst[--pos] = '.'; // insert dots
  1522. dst[--pos] = '.';
  1523. dst[--pos] = '.';
  1524. }
  1525. dst[len] = '\0'; // end it
  1526. // Copy down to 0
  1527. while (pos--) dst[pos] = src[pos];
  1528. }
  1529. inline void HMI_SDCardInit() { card.cdroot(); }
  1530. void MarlinUI::refresh() { /* Nothing to see here */ }
  1531. #define ICON_Folder ICON_More
  1532. #if ENABLED(SCROLL_LONG_FILENAMES)
  1533. char shift_name[LONG_FILENAME_LENGTH + 1];
  1534. int8_t shift_amt; // = 0
  1535. millis_t shift_ms; // = 0
  1536. // Init the shift name based on the highlighted item
  1537. inline void Init_Shift_Name() {
  1538. const bool is_subdir = !card.flag.workDirIsRoot;
  1539. const int8_t filenum = select_file.now - 1 - is_subdir; // Skip "Back" and ".."
  1540. const uint16_t fileCnt = card.get_num_Files();
  1541. if (WITHIN(filenum, 0, fileCnt - 1)) {
  1542. card.getfilename_sorted(SD_ORDER(filenum, fileCnt));
  1543. char * const name = card.longest_filename();
  1544. make_name_without_ext(shift_name, name, 100);
  1545. }
  1546. }
  1547. inline void Init_SDItem_Shift() {
  1548. shift_amt = 0;
  1549. shift_ms = select_file.now > 0 && strlen(shift_name) > MENU_CHAR_LIMIT
  1550. ? millis() + 750UL : 0;
  1551. }
  1552. #endif
  1553. /**
  1554. * Display an SD item, adding a CDUP for subfolders.
  1555. */
  1556. inline void Draw_SDItem(const uint16_t item, int16_t row=-1) {
  1557. if (row < 0) row = item + 1 + MROWS - index_file;
  1558. const bool is_subdir = !card.flag.workDirIsRoot;
  1559. if (is_subdir && item == 0) {
  1560. Draw_Menu_Line(row, ICON_Folder, "..");
  1561. return;
  1562. }
  1563. card.getfilename_sorted(item - is_subdir);
  1564. char * const name = card.longest_filename();
  1565. #if ENABLED(SCROLL_LONG_FILENAMES)
  1566. // Init the current selected name
  1567. // This is used during scroll drawing
  1568. if (item == select_file.now - 1) {
  1569. make_name_without_ext(shift_name, name, 100);
  1570. Init_SDItem_Shift();
  1571. }
  1572. #endif
  1573. // Draw the file/folder with name aligned left
  1574. char str[strlen(name) + 1];
  1575. make_name_without_ext(str, name);
  1576. Draw_Menu_Line(row, card.flag.filenameIsDir ? ICON_Folder : ICON_File, str);
  1577. }
  1578. #if ENABLED(SCROLL_LONG_FILENAMES)
  1579. inline void Draw_SDItem_Shifted(int8_t &shift) {
  1580. // Limit to the number of chars past the cutoff
  1581. const size_t len = strlen(shift_name);
  1582. NOMORE(shift, _MAX(len - MENU_CHAR_LIMIT, 0U));
  1583. // Shorten to the available space
  1584. const size_t lastchar = _MIN((signed)len, shift + MENU_CHAR_LIMIT);
  1585. const char c = shift_name[lastchar];
  1586. shift_name[lastchar] = '\0';
  1587. const uint8_t row = select_file.now + MROWS - index_file; // skip "Back" and scroll
  1588. Erase_Menu_Text(row);
  1589. Draw_Menu_Line(row, 0, &shift_name[shift]);
  1590. shift_name[lastchar] = c;
  1591. }
  1592. #endif
  1593. // Redraw the first set of SD Files
  1594. inline void Redraw_SD_List() {
  1595. select_file.reset();
  1596. index_file = MROWS;
  1597. Clear_Menu_Area(); // Leave title bar unchanged
  1598. Draw_Back_First();
  1599. // As many files as will fit
  1600. LOOP_L_N(i, _MIN(nr_sd_menu_items(), MROWS))
  1601. Draw_SDItem(i, i + 1);
  1602. TERN_(SCROLL_LONG_FILENAMES, Init_SDItem_Shift());
  1603. }
  1604. bool DWIN_lcd_sd_status = false;
  1605. inline void SDCard_Up() {
  1606. card.cdup();
  1607. Redraw_SD_List();
  1608. DWIN_lcd_sd_status = false; // On next DWIN_Update
  1609. }
  1610. inline void SDCard_Folder(char * const dirname) {
  1611. card.cd(dirname);
  1612. Redraw_SD_List();
  1613. DWIN_lcd_sd_status = false; // On next DWIN_Update
  1614. }
  1615. //
  1616. // Watch for media mount / unmount
  1617. //
  1618. void HMI_SDCardUpdate() {
  1619. if (HMI_flag.home_flag) return;
  1620. if (DWIN_lcd_sd_status != card.isMounted()) {
  1621. DWIN_lcd_sd_status = card.isMounted();
  1622. // SERIAL_ECHOLNPAIR("HMI_SDCardUpdate: ", int(DWIN_lcd_sd_status));
  1623. if (card.isMounted()) {
  1624. if (checkkey == SelectFile)
  1625. Redraw_SD_List();
  1626. }
  1627. else {
  1628. // clean file icon
  1629. if (checkkey == SelectFile) {
  1630. Redraw_SD_List();
  1631. }
  1632. else if (checkkey == PrintProcess || checkkey == Tune || printingIsActive()) {
  1633. // TODO: Move card removed abort handling
  1634. // to CardReader::manage_media.
  1635. card.flag.abort_sd_printing = true;
  1636. wait_for_heatup = false;
  1637. dwin_abort_flag = true;
  1638. }
  1639. }
  1640. DWIN_UpdateLCD();
  1641. }
  1642. }
  1643. /* Start Frame */
  1644. void HMI_StartFrame(const bool with_update) {
  1645. Goto_MainMenu();
  1646. // Clear the bottom area of the screen
  1647. DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, STATUS_Y, DWIN_WIDTH, DWIN_HEIGHT - 1);
  1648. //
  1649. // Status Area
  1650. //
  1651. #if HAS_HOTEND
  1652. DWIN_ICON_Show(ICON, ICON_HotendTemp, 13, 381);
  1653. DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 33, 382, thermalManager.temp_hotend[0].celsius);
  1654. DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 33 + 3 * STAT_CHR_W + 5, 383, F("/"));
  1655. DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 33 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_hotend[0].target);
  1656. #endif
  1657. #if HOTENDS > 1
  1658. // DWIN_ICON_Show(ICON,ICON_HotendTemp, 13, 381);
  1659. #endif
  1660. #if HAS_HEATED_BED
  1661. DWIN_ICON_Show(ICON, ICON_BedTemp, 158, 381);
  1662. DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 178, 382, thermalManager.temp_bed.celsius);
  1663. DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 178 + 3 * STAT_CHR_W + 5, 383, F("/"));
  1664. DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 178 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_bed.target);
  1665. #endif
  1666. DWIN_ICON_Show(ICON, ICON_Speed, 13, 429);
  1667. DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 33 + 2 * STAT_CHR_W, 429, feedrate_percentage);
  1668. DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 33 + 5 * STAT_CHR_W + 2, 429, F("%"));
  1669. #if HAS_ZOFFSET_ITEM
  1670. DWIN_ICON_Show(ICON, ICON_Zoffset, 158, 428);
  1671. DWIN_Draw_Signed_Float(DWIN_FONT_STAT, Color_Bg_Black, 2, 2, 178, 429, BABY_Z_VAR * 100);
  1672. #endif
  1673. if (with_update) {
  1674. DWIN_UpdateLCD();
  1675. delay(5);
  1676. }
  1677. }
  1678. inline void Draw_Info_Menu() {
  1679. Clear_Main_Window();
  1680. DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, (DWIN_WIDTH - strlen(MACHINE_SIZE) * MENU_CHR_W) / 2, 122, (char*)MACHINE_SIZE);
  1681. DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, (DWIN_WIDTH - strlen(SHORT_BUILD_VERSION) * MENU_CHR_W) / 2, 195, (char*)SHORT_BUILD_VERSION);
  1682. if (HMI_flag.language_chinese) {
  1683. DWIN_Frame_TitleCopy(1, 30, 17, 57, 29); // "Info"
  1684. DWIN_Frame_AreaCopy(1, 197, 149, 252, 161, 108, 102);
  1685. DWIN_Frame_AreaCopy(1, 1, 164, 56, 176, 108, 175);
  1686. DWIN_Frame_AreaCopy(1, 58, 164, 113, 176, 105, 248);
  1687. DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, (DWIN_WIDTH - strlen(CORP_WEBSITE_C) * MENU_CHR_W) / 2, 268, (char*)CORP_WEBSITE_C);
  1688. }
  1689. else {
  1690. #ifdef USE_STRING_HEADINGS
  1691. Draw_Title(GET_TEXT_F(MSG_INFO_SCREEN));
  1692. #else
  1693. DWIN_Frame_TitleCopy(1, 190, 16, 215, 26); // "Info"
  1694. #endif
  1695. DWIN_Frame_AreaCopy(1, 120, 150, 146, 161, 124, 102);
  1696. DWIN_Frame_AreaCopy(1, 146, 151, 254, 161, 82, 175);
  1697. DWIN_Frame_AreaCopy(1, 0, 165, 94, 175, 89, 248);
  1698. DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, (DWIN_WIDTH - strlen(CORP_WEBSITE_E) * MENU_CHR_W) / 2, 268, (char*)CORP_WEBSITE_E);
  1699. }
  1700. Draw_Back_First();
  1701. LOOP_L_N(i, 3) {
  1702. DWIN_ICON_Show(ICON, ICON_PrintSize + i, 26, 99 + i * 73);
  1703. DWIN_Draw_Line(Line_Color, 16, MBASE(2) + i * 73, 256, 156 + i * 73);
  1704. }
  1705. }
  1706. inline void Draw_Print_File_Menu() {
  1707. Clear_Title_Bar();
  1708. if (HMI_flag.language_chinese) {
  1709. DWIN_Frame_TitleCopy(1, 0, 31, 55, 44); // "Print file"
  1710. }
  1711. else {
  1712. #ifdef USE_STRING_HEADINGS
  1713. Draw_Title("Print file"); // TODO: GET_TEXT_F
  1714. #else
  1715. DWIN_Frame_TitleCopy(1, 52, 31, 137, 41); // "Print file"
  1716. #endif
  1717. }
  1718. Redraw_SD_List();
  1719. }
  1720. /* Main Process */
  1721. void HMI_MainMenu() {
  1722. ENCODER_DiffState encoder_diffState = get_encoder_state();
  1723. if (encoder_diffState == ENCODER_DIFF_NO) return;
  1724. if (encoder_diffState == ENCODER_DIFF_CW) {
  1725. if (select_page.inc(4)) {
  1726. switch (select_page.now) {
  1727. case 0: ICON_Print(); break;
  1728. case 1: ICON_Print(); ICON_Prepare(); break;
  1729. case 2: ICON_Prepare(); ICON_Control(); break;
  1730. case 3: ICON_Control(); TERN(HAS_ONESTEP_LEVELING, ICON_Leveling, ICON_StartInfo)(1); break;
  1731. }
  1732. }
  1733. }
  1734. else if (encoder_diffState == ENCODER_DIFF_CCW) {
  1735. if (select_page.dec()) {
  1736. switch (select_page.now) {
  1737. case 0: ICON_Print(); ICON_Prepare(); break;
  1738. case 1: ICON_Prepare(); ICON_Control(); break;
  1739. case 2: ICON_Control(); TERN(HAS_ONESTEP_LEVELING, ICON_Leveling, ICON_StartInfo)(0); break;
  1740. case 3: TERN(HAS_ONESTEP_LEVELING, ICON_Leveling, ICON_StartInfo)(1); break;
  1741. }
  1742. }
  1743. }
  1744. else if (encoder_diffState == ENCODER_DIFF_ENTER) {
  1745. switch (select_page.now) {
  1746. case 0: // Print File
  1747. checkkey = SelectFile;
  1748. Draw_Print_File_Menu();
  1749. break;
  1750. case 1: // Prepare
  1751. checkkey = Prepare;
  1752. select_prepare.reset();
  1753. index_prepare = MROWS;
  1754. Draw_Prepare_Menu();
  1755. break;
  1756. case 2: // Control
  1757. checkkey = Control;
  1758. select_control.reset();
  1759. index_control = MROWS;
  1760. Draw_Control_Menu();
  1761. break;
  1762. case 3: // Leveling or Info
  1763. #if HAS_ONESTEP_LEVELING
  1764. checkkey = Leveling;
  1765. HMI_Leveling();
  1766. #else
  1767. checkkey = Info;
  1768. Draw_Info_Menu();
  1769. #endif
  1770. break;
  1771. }
  1772. }
  1773. DWIN_UpdateLCD();
  1774. }
  1775. // Select (and Print) File
  1776. void HMI_SelectFile() {
  1777. ENCODER_DiffState encoder_diffState = get_encoder_state();
  1778. const uint16_t hasUpDir = !card.flag.workDirIsRoot;
  1779. if (encoder_diffState == ENCODER_DIFF_NO) {
  1780. #if ENABLED(SCROLL_LONG_FILENAMES)
  1781. if (shift_ms && select_file.now >= 1 + hasUpDir) {
  1782. // Scroll selected filename every second
  1783. const millis_t ms = millis();
  1784. if (ELAPSED(ms, shift_ms)) {
  1785. const bool was_reset = shift_amt < 0;
  1786. shift_ms = ms + 375UL + was_reset * 250UL; // ms per character
  1787. int8_t shift_new = shift_amt + 1; // Try to shift by...
  1788. Draw_SDItem_Shifted(shift_new); // Draw the item
  1789. if (!was_reset && shift_new == 0) // Was it limited to 0?
  1790. shift_ms = 0; // No scrolling needed
  1791. else if (shift_new == shift_amt) // Scroll reached the end
  1792. shift_new = -1; // Reset
  1793. shift_amt = shift_new; // Set new scroll
  1794. }
  1795. }
  1796. #endif
  1797. return;
  1798. }
  1799. // First pause is long. Easy.
  1800. // On reset, long pause must be after 0.
  1801. const uint16_t fullCnt = nr_sd_menu_items();
  1802. if (encoder_diffState == ENCODER_DIFF_CW && fullCnt) {
  1803. if (select_file.inc(1 + fullCnt)) {
  1804. const uint8_t itemnum = select_file.now - 1; // -1 for "Back"
  1805. if (TERN0(SCROLL_LONG_FILENAMES, shift_ms)) { // If line was shifted
  1806. Erase_Menu_Text(itemnum + MROWS - index_file); // Erase and
  1807. Draw_SDItem(itemnum - 1); // redraw
  1808. }
  1809. if (select_file.now > MROWS && select_file.now > index_file) { // Cursor past the bottom
  1810. index_file = select_file.now; // New bottom line
  1811. Scroll_Menu(DWIN_SCROLL_UP);
  1812. Draw_SDItem(itemnum, MROWS); // Draw and init the shift name
  1813. }
  1814. else {
  1815. Move_Highlight(1, select_file.now + MROWS - index_file); // Just move highlight
  1816. TERN_(SCROLL_LONG_FILENAMES, Init_Shift_Name()); // ...and init the shift name
  1817. }
  1818. TERN_(SCROLL_LONG_FILENAMES, Init_SDItem_Shift());
  1819. }
  1820. }
  1821. else if (encoder_diffState == ENCODER_DIFF_CCW && fullCnt) {
  1822. if (select_file.dec()) {
  1823. const uint8_t itemnum = select_file.now - 1; // -1 for "Back"
  1824. if (TERN0(SCROLL_LONG_FILENAMES, shift_ms)) { // If line was shifted
  1825. Erase_Menu_Text(select_file.now + 1 + MROWS - index_file); // Erase and
  1826. Draw_SDItem(itemnum + 1); // redraw
  1827. }
  1828. if (select_file.now < index_file - MROWS) { // Cursor past the top
  1829. index_file--; // New bottom line
  1830. Scroll_Menu(DWIN_SCROLL_DOWN);
  1831. if (index_file == MROWS) {
  1832. Draw_Back_First();
  1833. TERN_(SCROLL_LONG_FILENAMES, shift_ms = 0);
  1834. }
  1835. else {
  1836. Draw_SDItem(itemnum, 0); // Draw the item (and init shift name)
  1837. }
  1838. }
  1839. else {
  1840. Move_Highlight(-1, select_file.now + MROWS - index_file); // Just move highlight
  1841. TERN_(SCROLL_LONG_FILENAMES, Init_Shift_Name()); // ...and init the shift name
  1842. }
  1843. TERN_(SCROLL_LONG_FILENAMES, Init_SDItem_Shift()); // Reset left. Init timer.
  1844. }
  1845. }
  1846. else if (encoder_diffState == ENCODER_DIFF_ENTER) {
  1847. if (select_file.now == 0) { // Back
  1848. select_page.set(0);
  1849. Goto_MainMenu();
  1850. }
  1851. else if (hasUpDir && select_file.now == 1) { // CD-Up
  1852. SDCard_Up();
  1853. goto HMI_SelectFileExit;
  1854. }
  1855. else {
  1856. const uint16_t filenum = select_file.now - 1 - hasUpDir;
  1857. card.getfilename_sorted(SD_ORDER(filenum, card.get_num_Files()));
  1858. // Enter that folder!
  1859. if (card.flag.filenameIsDir) {
  1860. SDCard_Folder(card.filename);
  1861. goto HMI_SelectFileExit;
  1862. }
  1863. // Reset highlight for next entry
  1864. select_print.reset();
  1865. select_file.reset();
  1866. // Start choice and print SD file
  1867. HMI_flag.heat_flag = true;
  1868. HMI_flag.print_finish = false;
  1869. HMI_ValueStruct.show_mode = 0;
  1870. card.openAndPrintFile(card.filename);
  1871. #if FAN_COUNT > 0
  1872. // All fans on for Ender 3 v2 ?
  1873. // The slicer should manage this for us.
  1874. // for (uint8_t i = 0; i < FAN_COUNT; i++)
  1875. // thermalManager.fan_speed[i] = FANON;
  1876. #endif
  1877. Goto_PrintProcess();
  1878. }
  1879. }
  1880. HMI_SelectFileExit:
  1881. DWIN_UpdateLCD();
  1882. }
  1883. /* Printing */
  1884. void HMI_Printing() {
  1885. ENCODER_DiffState encoder_diffState = get_encoder_state();
  1886. if (encoder_diffState == ENCODER_DIFF_NO) return;
  1887. if (HMI_flag.done_confirm_flag) {
  1888. if (encoder_diffState == ENCODER_DIFF_ENTER) {
  1889. HMI_flag.done_confirm_flag = false;
  1890. dwin_abort_flag = true;
  1891. }
  1892. return;
  1893. }
  1894. // Avoid flicker by updating only the previous menu
  1895. if (encoder_diffState == ENCODER_DIFF_CW) {
  1896. if (select_print.inc(3)) {
  1897. switch (select_print.now) {
  1898. case 0: ICON_Tune(); break;
  1899. case 1:
  1900. ICON_Tune();
  1901. if (printingIsPaused()) ICON_Continue(); else ICON_Pause();
  1902. break;
  1903. case 2:
  1904. if (printingIsPaused()) ICON_Continue(); else ICON_Pause();
  1905. ICON_Stop();
  1906. break;
  1907. }
  1908. }
  1909. }
  1910. else if (encoder_diffState == ENCODER_DIFF_CCW) {
  1911. if (select_print.dec()) {
  1912. switch (select_print.now) {
  1913. case 0:
  1914. ICON_Tune();
  1915. if (printingIsPaused()) ICON_Continue(); else ICON_Pause();
  1916. break;
  1917. case 1:
  1918. if (printingIsPaused()) ICON_Continue(); else ICON_Pause();
  1919. ICON_Stop();
  1920. break;
  1921. case 2: ICON_Stop(); break;
  1922. }
  1923. }
  1924. }
  1925. else if (encoder_diffState == ENCODER_DIFF_ENTER) {
  1926. switch (select_print.now) {
  1927. case 0: // Tune
  1928. checkkey = Tune;
  1929. HMI_ValueStruct.show_mode = 0;
  1930. select_tune.reset();
  1931. index_tune = MROWS;
  1932. Draw_Tune_Menu();
  1933. break;
  1934. case 1: // Pause
  1935. if (HMI_flag.pause_flag) {
  1936. ICON_Pause();
  1937. char cmd[40];
  1938. cmd[0] = '\0';
  1939. #if ENABLED(PAUSE_HEAT)
  1940. #if HAS_HEATED_BED
  1941. if (tempbed) sprintf_P(cmd, PSTR("M190 S%i\n"), tempbed);
  1942. #endif
  1943. #if HAS_HOTEND
  1944. if (temphot) sprintf_P(&cmd[strlen(cmd)], PSTR("M109 S%i\n"), temphot);
  1945. #endif
  1946. #endif
  1947. strcat_P(cmd, PSTR("M24"));
  1948. queue.inject(cmd);
  1949. }
  1950. else {
  1951. HMI_flag.select_flag = true;
  1952. checkkey = Print_window;
  1953. Popup_window_PauseOrStop();
  1954. }
  1955. break;
  1956. case 2: // Stop
  1957. HMI_flag.select_flag = true;
  1958. checkkey = Print_window;
  1959. Popup_window_PauseOrStop();
  1960. break;
  1961. default: break;
  1962. }
  1963. }
  1964. DWIN_UpdateLCD();
  1965. }
  1966. /* Pause and Stop window */
  1967. void HMI_PauseOrStop() {
  1968. ENCODER_DiffState encoder_diffState = get_encoder_state();
  1969. if (encoder_diffState == ENCODER_DIFF_NO) return;
  1970. if (encoder_diffState == ENCODER_DIFF_CW) {
  1971. Draw_Select_Highlight(false);
  1972. }
  1973. else if (encoder_diffState == ENCODER_DIFF_CCW) {
  1974. Draw_Select_Highlight(true);
  1975. }
  1976. else if (encoder_diffState == ENCODER_DIFF_ENTER) {
  1977. if (select_print.now == 1) { // pause window
  1978. if (HMI_flag.select_flag) {
  1979. HMI_flag.pause_action = true;
  1980. ICON_Continue();
  1981. #if ENABLED(POWER_LOSS_RECOVERY)
  1982. if (recovery.enabled) recovery.save(true);
  1983. #endif
  1984. queue.inject_P(PSTR("M25"));
  1985. }
  1986. else {
  1987. // cancel pause
  1988. }
  1989. Goto_PrintProcess();
  1990. }
  1991. else if (select_print.now == 2) { // stop window
  1992. if (HMI_flag.select_flag) {
  1993. wait_for_heatup = false; // Stop waiting for heater
  1994. #if 0
  1995. // TODO: In ExtUI or MarlinUI add a common stop event
  1996. // card.flag.abort_sd_printing = true;
  1997. #else
  1998. checkkey = Back_Main;
  1999. // Wait for planner moves to finish!
  2000. if (HMI_flag.home_flag) planner.synchronize();
  2001. card.endFilePrint();
  2002. #ifdef ACTION_ON_CANCEL
  2003. host_action_cancel();
  2004. #endif
  2005. #ifdef EVENT_GCODE_SD_ABORT
  2006. Popup_Window_Home(true);
  2007. queue.inject_P(PSTR(EVENT_GCODE_SD_ABORT));
  2008. #endif
  2009. dwin_abort_flag = true;
  2010. #endif
  2011. }
  2012. else {
  2013. Goto_PrintProcess(); // cancel stop
  2014. }
  2015. }
  2016. }
  2017. DWIN_UpdateLCD();
  2018. }
  2019. inline void Draw_Move_Menu() {
  2020. Clear_Main_Window();
  2021. if (HMI_flag.language_chinese) {
  2022. DWIN_Frame_TitleCopy(1, 192, 1, 233, 14); // "Move"
  2023. DWIN_Frame_AreaCopy(1, 58, 118, 106, 132, LBLX, MBASE(1));
  2024. DWIN_Frame_AreaCopy(1, 109, 118, 157, 132, LBLX, MBASE(2));
  2025. DWIN_Frame_AreaCopy(1, 160, 118, 209, 132, LBLX, MBASE(3));
  2026. #if HAS_HOTEND
  2027. DWIN_Frame_AreaCopy(1, 212, 118, 253, 131, LBLX, MBASE(4));
  2028. #endif
  2029. }
  2030. else {
  2031. #ifdef USE_STRING_HEADINGS
  2032. Draw_Title(GET_TEXT_F(MSG_MOVE_AXIS));
  2033. #else
  2034. DWIN_Frame_TitleCopy(1, 231, 2, 265, 12); // "Move"
  2035. #endif
  2036. draw_move_en(MBASE(1)); say_x(36, MBASE(1)); // "Move X"
  2037. draw_move_en(MBASE(2)); say_y(36, MBASE(2)); // "Move Y"
  2038. draw_move_en(MBASE(3)); say_z(36, MBASE(3)); // "Move Z"
  2039. #if HAS_HOTEND
  2040. DWIN_Frame_AreaCopy(1, 123, 192, 176, 202, LBLX, MBASE(4)); // "Extruder"
  2041. #endif
  2042. }
  2043. Draw_Back_First(select_axis.now == 0);
  2044. if (select_axis.now) Draw_Menu_Cursor(select_axis.now);
  2045. // Draw separators and icons
  2046. LOOP_L_N(i, 3 + ENABLED(HAS_HOTEND)) Draw_Menu_Line(i + 1, ICON_MoveX + i);
  2047. }
  2048. #include "../../../libs/buzzer.h"
  2049. void HMI_AudioFeedback(const bool success=true) {
  2050. if (success) {
  2051. buzzer.tone(100, 659);
  2052. buzzer.tone(10, 0);
  2053. buzzer.tone(100, 698);
  2054. }
  2055. else
  2056. buzzer.tone(40, 440);
  2057. }
  2058. /* Prepare */
  2059. void HMI_Prepare() {
  2060. ENCODER_DiffState encoder_diffState = get_encoder_state();
  2061. if (encoder_diffState == ENCODER_DIFF_NO) return;
  2062. // Avoid flicker by updating only the previous menu
  2063. if (encoder_diffState == ENCODER_DIFF_CW) {
  2064. if (select_prepare.inc(1 + PREPARE_CASE_TOTAL)) {
  2065. if (select_prepare.now > MROWS && select_prepare.now > index_prepare) {
  2066. index_prepare = select_prepare.now;
  2067. // Scroll up and draw a blank bottom line
  2068. Scroll_Menu(DWIN_SCROLL_UP);
  2069. Draw_Menu_Icon(MROWS, ICON_Axis + select_prepare.now - 1);
  2070. // Draw "More" icon for sub-menus
  2071. if (index_prepare < 7) Draw_More_Icon(MROWS - index_prepare + 1);
  2072. #if HAS_HOTEND
  2073. if (index_prepare == PREPARE_CASE_ABS) Item_Prepare_ABS(MROWS);
  2074. #endif
  2075. #if HAS_PREHEAT
  2076. if (index_prepare == PREPARE_CASE_COOL) Item_Prepare_Cool(MROWS);
  2077. #endif
  2078. if (index_prepare == PREPARE_CASE_LANG) Item_Prepare_Lang(MROWS);
  2079. }
  2080. else {
  2081. Move_Highlight(1, select_prepare.now + MROWS - index_prepare);
  2082. }
  2083. }
  2084. }
  2085. else if (encoder_diffState == ENCODER_DIFF_CCW) {
  2086. if (select_prepare.dec()) {
  2087. if (select_prepare.now < index_prepare - MROWS) {
  2088. index_prepare--;
  2089. Scroll_Menu(DWIN_SCROLL_DOWN);
  2090. if (index_prepare == MROWS)
  2091. Draw_Back_First();
  2092. else
  2093. Draw_Menu_Line(0, ICON_Axis + select_prepare.now - 1);
  2094. if (index_prepare < 7) Draw_More_Icon(MROWS - index_prepare + 1);
  2095. if (index_prepare == 6) Item_Prepare_Move(0);
  2096. else if (index_prepare == 7) Item_Prepare_Disable(0);
  2097. else if (index_prepare == 8) Item_Prepare_Home(0);
  2098. }
  2099. else {
  2100. Move_Highlight(-1, select_prepare.now + MROWS - index_prepare);
  2101. }
  2102. }
  2103. }
  2104. else if (encoder_diffState == ENCODER_DIFF_ENTER) {
  2105. switch (select_prepare.now) {
  2106. case 0: // Back
  2107. select_page.set(1);
  2108. Goto_MainMenu();
  2109. break;
  2110. case PREPARE_CASE_MOVE: // Axis move
  2111. checkkey = AxisMove;
  2112. select_axis.reset();
  2113. Draw_Move_Menu();
  2114. DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(1), current_position.x * MINUNITMULT);
  2115. DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(2), current_position.y * MINUNITMULT);
  2116. DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(3), current_position.z * MINUNITMULT);
  2117. #if HAS_HOTEND
  2118. queue.inject_P(PSTR("G92 E0"));
  2119. current_position.e = HMI_ValueStruct.Move_E_scale = 0;
  2120. DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 3, 1, 216, MBASE(4), 0);
  2121. #endif
  2122. break;
  2123. case PREPARE_CASE_DISA: // Disable steppers
  2124. queue.inject_P(PSTR("M84"));
  2125. break;
  2126. case PREPARE_CASE_HOME: // Homing
  2127. checkkey = Last_Prepare;
  2128. index_prepare = MROWS;
  2129. queue.inject_P(PSTR("G28")); // G28 will set home_flag
  2130. Popup_Window_Home();
  2131. break;
  2132. #if HAS_ZOFFSET_ITEM
  2133. case PREPARE_CASE_ZOFF: // Z-offset
  2134. #if EITHER(HAS_BED_PROBE, BABYSTEPPING)
  2135. checkkey = Homeoffset;
  2136. HMI_ValueStruct.show_mode = -4;
  2137. HMI_ValueStruct.offset_value = BABY_Z_VAR * 100;
  2138. DWIN_Draw_Signed_Float(font8x16, Select_Color, 2, 2, 202, MBASE(PREPARE_CASE_ZOFF + MROWS - index_prepare), HMI_ValueStruct.offset_value);
  2139. EncoderRate.enabled = true;
  2140. #else
  2141. // Apply workspace offset, making the current position 0,0,0
  2142. queue.inject_P(PSTR("G92 X0 Y0 Z0"));
  2143. HMI_AudioFeedback();
  2144. #endif
  2145. break;
  2146. #endif
  2147. #if HAS_HOTEND
  2148. case PREPARE_CASE_PLA: // PLA preheat
  2149. thermalManager.setTargetHotend(ui.material_preset[0].hotend_temp, 0);
  2150. thermalManager.setTargetBed(ui.material_preset[0].bed_temp);
  2151. thermalManager.set_fan_speed(0, ui.material_preset[0].fan_speed);
  2152. break;
  2153. case PREPARE_CASE_ABS: // ABS preheat
  2154. thermalManager.setTargetHotend(ui.material_preset[1].hotend_temp, 0);
  2155. thermalManager.setTargetBed(ui.material_preset[1].bed_temp);
  2156. thermalManager.set_fan_speed(0, ui.material_preset[1].fan_speed);
  2157. break;
  2158. #endif
  2159. #if HAS_PREHEAT
  2160. case PREPARE_CASE_COOL: // Cool
  2161. TERN_(HAS_FAN, thermalManager.zero_fan_speeds());
  2162. #if HAS_HOTEND || HAS_HEATED_BED
  2163. thermalManager.disable_all_heaters();
  2164. #endif
  2165. break;
  2166. #endif
  2167. case PREPARE_CASE_LANG: // Toggle Language
  2168. HMI_ToggleLanguage();
  2169. Draw_Prepare_Menu();
  2170. break;
  2171. default: break;
  2172. }
  2173. }
  2174. DWIN_UpdateLCD();
  2175. }
  2176. void Draw_Temperature_Menu() {
  2177. Clear_Main_Window();
  2178. if (HMI_flag.language_chinese) {
  2179. DWIN_Frame_TitleCopy(1, 236, 2, 263, 13); // "Temperature"
  2180. #if HAS_HOTEND
  2181. DWIN_Frame_AreaCopy(1, 1, 134, 56, 146, LBLX, MBASE(TEMP_CASE_TEMP));
  2182. #endif
  2183. #if HAS_HEATED_BED
  2184. DWIN_Frame_AreaCopy(1, 58, 134, 113, 146, LBLX, MBASE(TEMP_CASE_BED));
  2185. #endif
  2186. #if HAS_FAN
  2187. DWIN_Frame_AreaCopy(1, 115, 134, 170, 146, LBLX, MBASE(TEMP_CASE_FAN));
  2188. #endif
  2189. #if HAS_HOTEND
  2190. DWIN_Frame_AreaCopy(1, 100, 89, 178, 101, LBLX, MBASE(TEMP_CASE_PLA));
  2191. DWIN_Frame_AreaCopy(1, 180, 89, 260, 100, LBLX, MBASE(TEMP_CASE_ABS));
  2192. #endif
  2193. }
  2194. else {
  2195. #ifdef USE_STRING_HEADINGS
  2196. Draw_Title(GET_TEXT_F(MSG_TEMPERATURE));
  2197. #if HAS_HOTEND
  2198. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(TEMP_CASE_TEMP), GET_TEXT_F(MSG_UBL_SET_TEMP_HOTEND));
  2199. #endif
  2200. #if HAS_HEATED_BED
  2201. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(TEMP_CASE_BED), GET_TEXT_F(MSG_UBL_SET_TEMP_BED));
  2202. #endif
  2203. #if HAS_FAN
  2204. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(TEMP_CASE_FAN), GET_TEXT_F(MSG_FAN_SPEED));
  2205. #endif
  2206. #if HAS_HOTEND
  2207. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(TEMP_CASE_PLA), F("PLA Preheat Settings"));
  2208. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(TEMP_CASE_ABS), F("ABS Preheat Settings"));
  2209. #endif
  2210. #else
  2211. DWIN_Frame_TitleCopy(1, 56, 16, 141, 28); // "Temperature"
  2212. #if HAS_HOTEND
  2213. DWIN_Frame_AreaCopy(1, 197, 104, 238, 114, LBLX, MBASE(TEMP_CASE_TEMP)); // Nozzle...
  2214. DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 44, MBASE(TEMP_CASE_TEMP)); // ...Temperature
  2215. #endif
  2216. #if HAS_HEATED_BED
  2217. DWIN_Frame_AreaCopy(1, 240, 104, 264, 114, LBLX, MBASE(TEMP_CASE_BED)); // Bed...
  2218. DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 27, MBASE(TEMP_CASE_BED)); // ...Temperature
  2219. #endif
  2220. #if HAS_FAN
  2221. DWIN_Frame_AreaCopy(1, 0, 119, 64, 132, LBLX, MBASE(TEMP_CASE_FAN)); // Fan speed
  2222. #endif
  2223. #if HAS_HOTEND
  2224. DWIN_Frame_AreaCopy(1, 107, 76, 156, 86, LBLX, MBASE(TEMP_CASE_PLA)); // Preheat...
  2225. DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX + 52, MBASE(TEMP_CASE_PLA)); // ...PLA
  2226. DWIN_Frame_AreaCopy(1, 131, 119, 182, 132, LBLX + 79, MBASE(TEMP_CASE_PLA)); // PLA setting
  2227. DWIN_Frame_AreaCopy(1, 107, 76, 156, 86, LBLX, MBASE(TEMP_CASE_ABS)); // Preheat...
  2228. DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX + 52, MBASE(TEMP_CASE_ABS)); // ...ABS
  2229. DWIN_Frame_AreaCopy(1, 131, 119, 182, 132, LBLX + 81, MBASE(TEMP_CASE_ABS)); // ABS setting
  2230. #endif
  2231. #endif
  2232. }
  2233. Draw_Back_First(select_temp.now == 0);
  2234. if (select_temp.now) Draw_Menu_Cursor(select_temp.now);
  2235. // Draw icons and lines
  2236. uint8_t i = 0;
  2237. #define _TMENU_ICON(N) Draw_Menu_Line(++i, ICON_SetEndTemp + (N) - 1)
  2238. #if HAS_HOTEND
  2239. _TMENU_ICON(TEMP_CASE_TEMP);
  2240. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(i), thermalManager.temp_hotend[0].target);
  2241. #endif
  2242. #if HAS_HEATED_BED
  2243. _TMENU_ICON(TEMP_CASE_BED);
  2244. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(i), thermalManager.temp_bed.target);
  2245. #endif
  2246. #if HAS_FAN
  2247. _TMENU_ICON(TEMP_CASE_FAN);
  2248. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(i), thermalManager.fan_speed[0]);
  2249. #endif
  2250. #if HAS_HOTEND
  2251. // PLA/ABS items have submenus
  2252. _TMENU_ICON(TEMP_CASE_PLA);
  2253. Draw_More_Icon(i);
  2254. _TMENU_ICON(TEMP_CASE_ABS);
  2255. Draw_More_Icon(i);
  2256. #endif
  2257. }
  2258. /* Control */
  2259. void HMI_Control() {
  2260. ENCODER_DiffState encoder_diffState = get_encoder_state();
  2261. if (encoder_diffState == ENCODER_DIFF_NO) return;
  2262. // Avoid flicker by updating only the previous menu
  2263. if (encoder_diffState == ENCODER_DIFF_CW) {
  2264. if (select_control.inc(1 + CONTROL_CASE_TOTAL)) {
  2265. if (select_control.now > MROWS && select_control.now > index_control) {
  2266. index_control = select_control.now;
  2267. Scroll_Menu(DWIN_SCROLL_UP);
  2268. Draw_Menu_Icon(MROWS, ICON_Temperature + index_control - 1);
  2269. Draw_More_Icon(CONTROL_CASE_TEMP + MROWS - index_control); // Temperature >
  2270. Draw_More_Icon(CONTROL_CASE_MOVE + MROWS - index_control); // Motion >
  2271. if (index_control > MROWS) {
  2272. Draw_More_Icon(CONTROL_CASE_INFO + MROWS - index_control); // Info >
  2273. if (HMI_flag.language_chinese)
  2274. DWIN_Frame_AreaCopy(1, 231, 104, 258, 116, LBLX, MBASE(CONTROL_CASE_INFO - 1));
  2275. else
  2276. DWIN_Frame_AreaCopy(1, 0, 104, 24, 114, LBLX, MBASE(CONTROL_CASE_INFO - 1));
  2277. }
  2278. }
  2279. else {
  2280. Move_Highlight(1, select_control.now + MROWS - index_control);
  2281. }
  2282. }
  2283. }
  2284. else if (encoder_diffState == ENCODER_DIFF_CCW) {
  2285. if (select_control.dec()) {
  2286. if (select_control.now < index_control - MROWS) {
  2287. index_control--;
  2288. Scroll_Menu(DWIN_SCROLL_DOWN);
  2289. if (index_control == MROWS)
  2290. Draw_Back_First();
  2291. else
  2292. Draw_Menu_Line(0, ICON_Temperature + select_control.now - 1);
  2293. Draw_More_Icon(0 + MROWS - index_control + 1); // Temperature >
  2294. Draw_More_Icon(1 + MROWS - index_control + 1); // Motion >
  2295. }
  2296. else {
  2297. Move_Highlight(-1, select_control.now + MROWS - index_control);
  2298. }
  2299. }
  2300. }
  2301. else if (encoder_diffState == ENCODER_DIFF_ENTER) {
  2302. switch (select_control.now) {
  2303. case 0: // Back
  2304. select_page.set(2);
  2305. Goto_MainMenu();
  2306. break;
  2307. case CONTROL_CASE_TEMP: // Temperature
  2308. checkkey = TemperatureID;
  2309. HMI_ValueStruct.show_mode = -1;
  2310. select_temp.reset();
  2311. Draw_Temperature_Menu();
  2312. break;
  2313. case CONTROL_CASE_MOVE: // Motion
  2314. checkkey = Motion;
  2315. select_motion.reset();
  2316. Draw_Motion_Menu();
  2317. break;
  2318. #if ENABLED(EEPROM_SETTINGS)
  2319. case CONTROL_CASE_SAVE: { // Write EEPROM
  2320. const bool success = settings.save();
  2321. HMI_AudioFeedback(success);
  2322. } break;
  2323. case CONTROL_CASE_LOAD: { // Read EEPROM
  2324. const bool success = settings.load();
  2325. HMI_AudioFeedback(success);
  2326. } break;
  2327. case CONTROL_CASE_RESET: // Reset EEPROM
  2328. settings.reset();
  2329. HMI_AudioFeedback();
  2330. break;
  2331. #endif
  2332. case CONTROL_CASE_INFO: // Info
  2333. checkkey = Info;
  2334. Draw_Info_Menu();
  2335. break;
  2336. default: break;
  2337. }
  2338. }
  2339. DWIN_UpdateLCD();
  2340. }
  2341. #if HAS_ONESTEP_LEVELING
  2342. /* Leveling */
  2343. void HMI_Leveling() {
  2344. Popup_Window_Leveling();
  2345. DWIN_UpdateLCD();
  2346. queue.inject_P(PSTR("G28O\nG29"));
  2347. }
  2348. #endif
  2349. /* Axis Move */
  2350. void HMI_AxisMove() {
  2351. ENCODER_DiffState encoder_diffState = get_encoder_state();
  2352. if (encoder_diffState == ENCODER_DIFF_NO) return;
  2353. #if ENABLED(PREVENT_COLD_EXTRUSION)
  2354. // popup window resume
  2355. if (HMI_flag.ETempTooLow_flag) {
  2356. if (encoder_diffState == ENCODER_DIFF_ENTER) {
  2357. HMI_flag.ETempTooLow_flag = false;
  2358. current_position.e = HMI_ValueStruct.Move_E_scale = 0;
  2359. Draw_Move_Menu();
  2360. DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scale);
  2361. DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scale);
  2362. DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scale);
  2363. DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 3, 1, 216, MBASE(4), 0);
  2364. DWIN_UpdateLCD();
  2365. }
  2366. return;
  2367. }
  2368. #endif
  2369. // Avoid flicker by updating only the previous menu
  2370. if (encoder_diffState == ENCODER_DIFF_CW) {
  2371. if (select_axis.inc(1 + 3 + ENABLED(HAS_HOTEND))) Move_Highlight(1, select_axis.now);
  2372. }
  2373. else if (encoder_diffState == ENCODER_DIFF_CCW) {
  2374. if (select_axis.dec()) Move_Highlight(-1, select_axis.now);
  2375. }
  2376. else if (encoder_diffState == ENCODER_DIFF_ENTER) {
  2377. switch (select_axis.now) {
  2378. case 0: // Back
  2379. checkkey = Prepare;
  2380. select_prepare.set(1);
  2381. index_prepare = MROWS;
  2382. Draw_Prepare_Menu();
  2383. break;
  2384. case 1: // X axis move
  2385. checkkey = Move_X;
  2386. HMI_ValueStruct.Move_X_scale = current_position.x * MINUNITMULT;
  2387. DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scale);
  2388. EncoderRate.enabled = true;
  2389. break;
  2390. case 2: // Y axis move
  2391. checkkey = Move_Y;
  2392. HMI_ValueStruct.Move_Y_scale = current_position.y * MINUNITMULT;
  2393. DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scale);
  2394. EncoderRate.enabled = true;
  2395. break;
  2396. case 3: // Z axis move
  2397. checkkey = Move_Z;
  2398. HMI_ValueStruct.Move_Z_scale = current_position.z * MINUNITMULT;
  2399. DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scale);
  2400. EncoderRate.enabled = true;
  2401. break;
  2402. #if HAS_HOTEND
  2403. case 4: // Extruder
  2404. // window tips
  2405. #ifdef PREVENT_COLD_EXTRUSION
  2406. if (thermalManager.temp_hotend[0].celsius < EXTRUDE_MINTEMP) {
  2407. HMI_flag.ETempTooLow_flag = true;
  2408. Popup_Window_ETempTooLow();
  2409. DWIN_UpdateLCD();
  2410. return;
  2411. }
  2412. #endif
  2413. checkkey = Extruder;
  2414. HMI_ValueStruct.Move_E_scale = current_position.e * MINUNITMULT;
  2415. DWIN_Draw_Signed_Float(font8x16, Select_Color, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale);
  2416. EncoderRate.enabled = true;
  2417. break;
  2418. #endif
  2419. }
  2420. }
  2421. DWIN_UpdateLCD();
  2422. }
  2423. /* TemperatureID */
  2424. void HMI_Temperature() {
  2425. ENCODER_DiffState encoder_diffState = get_encoder_state();
  2426. if (encoder_diffState == ENCODER_DIFF_NO) return;
  2427. // Avoid flicker by updating only the previous menu
  2428. if (encoder_diffState == ENCODER_DIFF_CW) {
  2429. if (select_temp.inc(1 + TEMP_CASE_TOTAL)) Move_Highlight(1, select_temp.now);
  2430. }
  2431. else if (encoder_diffState == ENCODER_DIFF_CCW) {
  2432. if (select_temp.dec()) Move_Highlight(-1, select_temp.now);
  2433. }
  2434. else if (encoder_diffState == ENCODER_DIFF_ENTER) {
  2435. switch (select_temp.now) {
  2436. case 0: // Back
  2437. checkkey = Control;
  2438. select_control.set(1);
  2439. index_control = MROWS;
  2440. Draw_Control_Menu();
  2441. break;
  2442. #if HAS_HOTEND
  2443. case TEMP_CASE_TEMP: // Nozzle temperature
  2444. checkkey = ETemp;
  2445. HMI_ValueStruct.E_Temp = thermalManager.temp_hotend[0].target;
  2446. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(1), thermalManager.temp_hotend[0].target);
  2447. EncoderRate.enabled = true;
  2448. break;
  2449. #endif
  2450. #if HAS_HEATED_BED
  2451. case TEMP_CASE_BED: // Bed temperature
  2452. checkkey = BedTemp;
  2453. HMI_ValueStruct.Bed_Temp = thermalManager.temp_bed.target;
  2454. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(2), thermalManager.temp_bed.target);
  2455. EncoderRate.enabled = true;
  2456. break;
  2457. #endif
  2458. #if HAS_FAN
  2459. case TEMP_CASE_FAN: // Fan speed
  2460. checkkey = FanSpeed;
  2461. HMI_ValueStruct.Fan_speed = thermalManager.fan_speed[0];
  2462. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(3), thermalManager.fan_speed[0]);
  2463. EncoderRate.enabled = true;
  2464. break;
  2465. #endif
  2466. #if HAS_HOTEND
  2467. case TEMP_CASE_PLA: { // PLA preheat setting
  2468. checkkey = PLAPreheat;
  2469. select_PLA.reset();
  2470. HMI_ValueStruct.show_mode = -2;
  2471. Clear_Main_Window();
  2472. if (HMI_flag.language_chinese) {
  2473. DWIN_Frame_TitleCopy(1, 59, 16, 139, 29); // "PLA Settings"
  2474. DWIN_Frame_AreaCopy(1, 100, 89, 124, 101, LBLX, MBASE(PREHEAT_CASE_TEMP));
  2475. DWIN_Frame_AreaCopy(1, 1, 134, 56, 146, LBLX + 24, MBASE(PREHEAT_CASE_TEMP)); // PLA nozzle temp
  2476. #if HAS_HEATED_BED
  2477. DWIN_Frame_AreaCopy(1, 100, 89, 124, 101, LBLX, MBASE(PREHEAT_CASE_BED));
  2478. DWIN_Frame_AreaCopy(1, 58, 134, 113, 146, LBLX + 24, MBASE(PREHEAT_CASE_BED)); // PLA bed temp
  2479. #endif
  2480. #if HAS_FAN
  2481. DWIN_Frame_AreaCopy(1, 100, 89, 124, 101, LBLX, MBASE(PREHEAT_CASE_FAN));
  2482. DWIN_Frame_AreaCopy(1, 115, 134, 170, 146, LBLX + 24, MBASE(PREHEAT_CASE_FAN)); // PLA fan speed
  2483. #endif
  2484. #if ENABLED(EEPROM_SETTINGS)
  2485. DWIN_Frame_AreaCopy(1, 72, 148, 151, 162, LBLX, MBASE(PREHEAT_CASE_SAVE)); // Save PLA configuration
  2486. #endif
  2487. }
  2488. else {
  2489. #ifdef USE_STRING_HEADINGS
  2490. Draw_Title("PLA Settings"); // TODO: GET_TEXT_F
  2491. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(PREHEAT_CASE_TEMP), F("Nozzle Temp"));
  2492. #if HAS_HEATED_BED
  2493. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(PREHEAT_CASE_BED), F("Bed Temp"));
  2494. #endif
  2495. #if HAS_FAN
  2496. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(PREHEAT_CASE_FAN), GET_TEXT_F(MSG_FAN_SPEED));
  2497. #endif
  2498. #if ENABLED(EEPROM_SETTINGS)
  2499. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(PREHEAT_CASE_SAVE), GET_TEXT_F(MSG_STORE_EEPROM));
  2500. #endif
  2501. #else
  2502. DWIN_Frame_TitleCopy(1, 56, 16, 141, 28); // "PLA Settings"
  2503. DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX, MBASE(PREHEAT_CASE_TEMP));
  2504. DWIN_Frame_AreaCopy(1, 197, 104, 238, 114, LBLX + 27, MBASE(PREHEAT_CASE_TEMP));
  2505. DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 71, MBASE(PREHEAT_CASE_TEMP)); // PLA nozzle temp
  2506. #if HAS_HEATED_BED
  2507. DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX, MBASE(PREHEAT_CASE_BED) + 3);
  2508. DWIN_Frame_AreaCopy(1, 240, 104, 264, 114, LBLX + 27, MBASE(PREHEAT_CASE_BED) + 3);
  2509. DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 54, MBASE(PREHEAT_CASE_BED) + 3); // PLA bed temp
  2510. #endif
  2511. #if HAS_FAN
  2512. DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX, MBASE(PREHEAT_CASE_FAN));
  2513. DWIN_Frame_AreaCopy(1, 0, 119, 64, 132, LBLX + 27, MBASE(PREHEAT_CASE_FAN)); // PLA fan speed
  2514. #endif
  2515. #if ENABLED(EEPROM_SETTINGS)
  2516. DWIN_Frame_AreaCopy(1, 97, 165, 229, 177, LBLX, MBASE(PREHEAT_CASE_SAVE)); // Save PLA configuration
  2517. #endif
  2518. #endif
  2519. }
  2520. Draw_Back_First();
  2521. uint8_t i = 0;
  2522. Draw_Menu_Line(++i, ICON_SetEndTemp);
  2523. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(i), ui.material_preset[0].hotend_temp);
  2524. #if HAS_HEATED_BED
  2525. Draw_Menu_Line(++i, ICON_SetBedTemp);
  2526. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(i), ui.material_preset[0].bed_temp);
  2527. #endif
  2528. #if HAS_FAN
  2529. Draw_Menu_Line(++i, ICON_FanSpeed);
  2530. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(i), ui.material_preset[0].fan_speed);
  2531. #endif
  2532. #if ENABLED(EEPROM_SETTINGS)
  2533. Draw_Menu_Line(++i, ICON_WriteEEPROM);
  2534. #endif
  2535. } break;
  2536. case TEMP_CASE_ABS: { // ABS preheat setting
  2537. checkkey = ABSPreheat;
  2538. select_ABS.reset();
  2539. HMI_ValueStruct.show_mode = -3;
  2540. Clear_Main_Window();
  2541. if (HMI_flag.language_chinese) {
  2542. DWIN_Frame_TitleCopy(1, 142, 16, 223, 29); // "ABS Settings"
  2543. DWIN_Frame_AreaCopy(1, 180, 89, 204, 100, LBLX, MBASE(PREHEAT_CASE_TEMP));
  2544. DWIN_Frame_AreaCopy(1, 1, 134, 56, 146, LBLX + 24, MBASE(PREHEAT_CASE_TEMP)); // ABS nozzle temp
  2545. #if HAS_HEATED_BED
  2546. DWIN_Frame_AreaCopy(1, 180, 89, 204, 100, LBLX, MBASE(PREHEAT_CASE_BED));
  2547. DWIN_Frame_AreaCopy(1, 58, 134, 113, 146, LBLX + 24, MBASE(PREHEAT_CASE_BED)); // ABS bed temp
  2548. #endif
  2549. #if HAS_FAN
  2550. DWIN_Frame_AreaCopy(1, 180, 89, 204, 100, LBLX, MBASE(PREHEAT_CASE_FAN));
  2551. DWIN_Frame_AreaCopy(1, 115, 134, 170, 146, LBLX + 24, MBASE(PREHEAT_CASE_FAN)); // ABS fan speed
  2552. #endif
  2553. #if ENABLED(EEPROM_SETTINGS)
  2554. DWIN_Frame_AreaCopy(1, 72, 148, 151, 162, LBLX, MBASE(PREHEAT_CASE_SAVE));
  2555. DWIN_Frame_AreaCopy(1, 180, 89, 204, 100, LBLX + 28, MBASE(PREHEAT_CASE_SAVE) + 2); // Save ABS configuration
  2556. #endif
  2557. }
  2558. else {
  2559. #ifdef USE_STRING_HEADINGS
  2560. Draw_Title("ABS Settings"); // TODO: GET_TEXT_F
  2561. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(PREHEAT_CASE_TEMP), F("Nozzle Temp"));
  2562. #if HAS_HEATED_BED
  2563. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(PREHEAT_CASE_BED), F("Bed Temp"));
  2564. #endif
  2565. #if HAS_FAN
  2566. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(PREHEAT_CASE_FAN), GET_TEXT_F(MSG_FAN_SPEED));
  2567. #endif
  2568. #if ENABLED(EEPROM_SETTINGS)
  2569. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(PREHEAT_CASE_SAVE), GET_TEXT_F(MSG_STORE_EEPROM));
  2570. #endif
  2571. #else
  2572. DWIN_Frame_TitleCopy(1, 56, 16, 141, 28); // "ABS Settings"
  2573. DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX, MBASE(PREHEAT_CASE_TEMP));
  2574. DWIN_Frame_AreaCopy(1, 197, 104, 238, 114, LBLX + 27, MBASE(PREHEAT_CASE_TEMP));
  2575. DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 71, MBASE(PREHEAT_CASE_TEMP)); // ABS nozzle temp
  2576. #if HAS_HEATED_BED
  2577. DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX, MBASE(PREHEAT_CASE_BED) + 3);
  2578. DWIN_Frame_AreaCopy(1, 240, 104, 264, 114, LBLX + 27, MBASE(PREHEAT_CASE_BED) + 3);
  2579. DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 54, MBASE(PREHEAT_CASE_BED) + 3); // ABS bed temp
  2580. #endif
  2581. #if HAS_FAN
  2582. DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX, MBASE(PREHEAT_CASE_FAN));
  2583. DWIN_Frame_AreaCopy(1, 0, 119, 64, 132, LBLX + 27, MBASE(PREHEAT_CASE_FAN)); // ABS fan speed
  2584. #endif
  2585. #if ENABLED(EEPROM_SETTINGS)
  2586. DWIN_Frame_AreaCopy(1, 97, 165, 229, 177, LBLX, MBASE(PREHEAT_CASE_SAVE));
  2587. DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX + 33, MBASE(PREHEAT_CASE_SAVE)); // Save ABS configuration
  2588. #endif
  2589. #endif
  2590. }
  2591. Draw_Back_First();
  2592. uint8_t i = 0;
  2593. Draw_Menu_Line(++i, ICON_SetEndTemp);
  2594. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(i), ui.material_preset[1].hotend_temp);
  2595. #if HAS_HEATED_BED
  2596. Draw_Menu_Line(++i, ICON_SetBedTemp);
  2597. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(i), ui.material_preset[1].bed_temp);
  2598. #endif
  2599. #if HAS_FAN
  2600. Draw_Menu_Line(++i, ICON_FanSpeed);
  2601. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(i), ui.material_preset[1].fan_speed);
  2602. #endif
  2603. #if ENABLED(EEPROM_SETTINGS)
  2604. Draw_Menu_Line(++i, ICON_WriteEEPROM);
  2605. #endif
  2606. } break;
  2607. #endif // HAS_HOTEND
  2608. }
  2609. }
  2610. DWIN_UpdateLCD();
  2611. }
  2612. inline void Draw_Max_Speed_Menu() {
  2613. Clear_Main_Window();
  2614. if (HMI_flag.language_chinese) {
  2615. DWIN_Frame_TitleCopy(1, 1, 16, 28, 28); // "Max Speed (mm/s)"
  2616. auto say_max_speed = [](const uint16_t row) {
  2617. DWIN_Frame_AreaCopy(1, 173, 133, 228, 147, LBLX, row); // "Max speed"
  2618. };
  2619. say_max_speed(MBASE(1)); // "Max speed"
  2620. DWIN_Frame_AreaCopy(1, 229, 133, 236, 147, LBLX + 58, MBASE(1)); // X
  2621. say_max_speed(MBASE(2)); // "Max speed"
  2622. DWIN_Frame_AreaCopy(1, 1, 150, 7, 160, LBLX + 58, MBASE(2) + 3); // Y
  2623. say_max_speed(MBASE(3)); // "Max speed"
  2624. DWIN_Frame_AreaCopy(1, 9, 150, 16, 160, LBLX + 58, MBASE(3) + 3); // Z
  2625. #if HAS_HOTEND
  2626. say_max_speed(MBASE(4)); // "Max speed"
  2627. DWIN_Frame_AreaCopy(1, 18, 150, 25, 160, LBLX + 58, MBASE(4) + 3); // E
  2628. #endif
  2629. }
  2630. else {
  2631. #ifdef USE_STRING_HEADINGS
  2632. Draw_Title("Max Speed (mm/s)"); // TODO: GET_TEXT_F
  2633. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(1), F("Max Feedrate X"));
  2634. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(2), F("Max Feedrate Y"));
  2635. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(3), F("Max Feedrate Z"));
  2636. #if HAS_HOTEND
  2637. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(4), F("Max Feedrate E"));
  2638. #endif
  2639. #else
  2640. DWIN_Frame_TitleCopy(1, 144, 16, 189, 26); // "Max Speed (mm/s)"
  2641. draw_max_en(MBASE(1)); // "Max"
  2642. DWIN_Frame_AreaCopy(1, 184, 119, 234, 132, LBLX + 27, MBASE(1)); // "Speed X"
  2643. draw_max_en(MBASE(2)); // "Max"
  2644. draw_speed_en(27, MBASE(2)); // "Speed"
  2645. say_y(70, MBASE(2)); // "Y"
  2646. draw_max_en(MBASE(3)); // "Max"
  2647. draw_speed_en(27, MBASE(3)); // "Speed"
  2648. say_z(70, MBASE(3)); // "Z"
  2649. #if HAS_HOTEND
  2650. draw_max_en(MBASE(4)); // "Max"
  2651. draw_speed_en(27, MBASE(4)); // "Speed"
  2652. say_e(70, MBASE(4)); // "E"
  2653. #endif
  2654. #endif
  2655. }
  2656. Draw_Back_First();
  2657. LOOP_L_N(i, 3 + ENABLED(HAS_HOTEND)) Draw_Menu_Line(i + 1, ICON_MaxSpeedX + i);
  2658. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 4, 210, MBASE(1), planner.settings.max_feedrate_mm_s[X_AXIS]);
  2659. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 4, 210, MBASE(2), planner.settings.max_feedrate_mm_s[Y_AXIS]);
  2660. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 4, 210, MBASE(3), planner.settings.max_feedrate_mm_s[Z_AXIS]);
  2661. #if HAS_HOTEND
  2662. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 4, 210, MBASE(4), planner.settings.max_feedrate_mm_s[E_AXIS]);
  2663. #endif
  2664. }
  2665. inline void Draw_Max_Accel_Menu() {
  2666. Clear_Main_Window();
  2667. if (HMI_flag.language_chinese) {
  2668. DWIN_Frame_TitleCopy(1, 1, 16, 28, 28); // "Acceleration"
  2669. DWIN_Frame_AreaCopy(1, 173, 133, 200, 147, LBLX, MBASE(1));
  2670. DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(1) + 1);
  2671. DWIN_Frame_AreaCopy(1, 229, 133, 236, 147, LBLX + 71, MBASE(1)); // Max acceleration X
  2672. DWIN_Frame_AreaCopy(1, 173, 133, 200, 147, LBLX, MBASE(2));
  2673. DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(2) + 1);
  2674. DWIN_Frame_AreaCopy(1, 1, 150, 7, 160, LBLX + 71, MBASE(2) + 2); // Max acceleration Y
  2675. DWIN_Frame_AreaCopy(1, 173, 133, 200, 147, LBLX, MBASE(3));
  2676. DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(3) + 1);
  2677. DWIN_Frame_AreaCopy(1, 9, 150, 16, 160, LBLX + 71, MBASE(3) + 2); // Max acceleration Z
  2678. #if HAS_HOTEND
  2679. DWIN_Frame_AreaCopy(1, 173, 133, 200, 147, LBLX, MBASE(4));
  2680. DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(4) + 1);
  2681. DWIN_Frame_AreaCopy(1, 18, 150, 25, 160, LBLX + 71, MBASE(4) + 2); // Max acceleration E
  2682. #endif
  2683. }
  2684. else {
  2685. #ifdef USE_STRING_HEADINGS
  2686. Draw_Title(GET_TEXT_F(MSG_ACCELERATION));
  2687. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(1), F("Max Accel X"));
  2688. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(2), F("Max Accel Y"));
  2689. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(3), F("Max Accel Z"));
  2690. #if HAS_HOTEND
  2691. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(4), F("Max Accel E"));
  2692. #endif
  2693. #else
  2694. DWIN_Frame_TitleCopy(1, 144, 16, 189, 26); // "Acceleration"
  2695. draw_max_accel_en(MBASE(1)); say_x(108, MBASE(1)); // "Max Acceleration X"
  2696. draw_max_accel_en(MBASE(2)); say_y(108, MBASE(2)); // "Max Acceleration Y"
  2697. draw_max_accel_en(MBASE(3)); say_z(108, MBASE(3)); // "Max Acceleration Z"
  2698. #if HAS_HOTEND
  2699. draw_max_accel_en(MBASE(4)); say_e(108, MBASE(4)); // "Max Acceleration E"
  2700. #endif
  2701. #endif
  2702. }
  2703. Draw_Back_First();
  2704. LOOP_L_N(i, 3 + ENABLED(HAS_HOTEND)) Draw_Menu_Line(i + 1, ICON_MaxAccX + i);
  2705. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 4, 210, MBASE(1), planner.settings.max_acceleration_mm_per_s2[X_AXIS]);
  2706. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 4, 210, MBASE(2), planner.settings.max_acceleration_mm_per_s2[Y_AXIS]);
  2707. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 4, 210, MBASE(3), planner.settings.max_acceleration_mm_per_s2[Z_AXIS]);
  2708. #if HAS_HOTEND
  2709. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 4, 210, MBASE(4), planner.settings.max_acceleration_mm_per_s2[E_AXIS]);
  2710. #endif
  2711. }
  2712. inline void Draw_Max_Jerk_Menu() {
  2713. Clear_Main_Window();
  2714. if (HMI_flag.language_chinese) {
  2715. DWIN_Frame_TitleCopy(1, 1, 16, 28, 28); // "Jerk"
  2716. DWIN_Frame_AreaCopy(1, 173, 133, 200, 147, LBLX , MBASE(1));
  2717. DWIN_Frame_AreaCopy(1, 1, 180, 28, 192, LBLX + 27, MBASE(1) + 1);
  2718. DWIN_Frame_AreaCopy(1, 202, 133, 228, 147, LBLX + 53, MBASE(1));
  2719. DWIN_Frame_AreaCopy(1, 229, 133, 236, 147, LBLX + 83, MBASE(1)); // Max Jerk speed X
  2720. DWIN_Frame_AreaCopy(1, 173, 133, 200, 147, LBLX , MBASE(2));
  2721. DWIN_Frame_AreaCopy(1, 1, 180, 28, 192, LBLX + 27, MBASE(2) + 1);
  2722. DWIN_Frame_AreaCopy(1, 202, 133, 228, 147, LBLX + 53, MBASE(2));
  2723. DWIN_Frame_AreaCopy(1, 1, 150, 7, 160, LBLX + 83, MBASE(2) + 3); // Max Jerk speed Y
  2724. DWIN_Frame_AreaCopy(1, 173, 133, 200, 147, LBLX , MBASE(3));
  2725. DWIN_Frame_AreaCopy(1, 1, 180, 28, 192, LBLX + 27, MBASE(3) + 1);
  2726. DWIN_Frame_AreaCopy(1, 202, 133, 228, 147, LBLX + 53, MBASE(3));
  2727. DWIN_Frame_AreaCopy(1, 9, 150, 16, 160, LBLX + 83, MBASE(3) + 3); // Max Jerk speed Z
  2728. #if HAS_HOTEND
  2729. DWIN_Frame_AreaCopy(1, 173, 133, 200, 147, LBLX , MBASE(4));
  2730. DWIN_Frame_AreaCopy(1, 1, 180, 28, 192, LBLX + 27, MBASE(4) + 1);
  2731. DWIN_Frame_AreaCopy(1, 202, 133, 228, 147, LBLX + 53, MBASE(4));
  2732. DWIN_Frame_AreaCopy(1, 18, 150, 25, 160, LBLX + 83, MBASE(4) + 3); // Max Jerk speed E
  2733. #endif
  2734. }
  2735. else {
  2736. #ifdef USE_STRING_HEADINGS
  2737. Draw_Title(GET_TEXT_F(MSG_JERK));
  2738. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(1), F("Max Jerk X"));
  2739. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(2), F("Max Jerk Y"));
  2740. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(3), F("Max Jerk Z"));
  2741. #if HAS_HOTEND
  2742. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(4), F("Max Jerk E"));
  2743. #endif
  2744. #else
  2745. DWIN_Frame_TitleCopy(1, 144, 16, 189, 26); // "Jerk"
  2746. draw_max_en(MBASE(1)); // "Max"
  2747. draw_jerk_en(MBASE(1)); // "Jerk"
  2748. draw_speed_en(72, MBASE(1)); // "Speed"
  2749. say_x(115, MBASE(1)); // "X"
  2750. draw_max_en(MBASE(2)); // "Max"
  2751. draw_jerk_en(MBASE(2)); // "Jerk"
  2752. draw_speed_en(72, MBASE(2)); // "Speed"
  2753. say_y(115, MBASE(2)); // "Y"
  2754. draw_max_en(MBASE(3)); // "Max"
  2755. draw_jerk_en(MBASE(3)); // "Jerk"
  2756. draw_speed_en(72, MBASE(3)); // "Speed"
  2757. say_z(115, MBASE(3)); // "Z"
  2758. #if HAS_HOTEND
  2759. draw_max_en(MBASE(4)); // "Max"
  2760. draw_jerk_en(MBASE(4)); // "Jerk"
  2761. draw_speed_en(72, MBASE(4)); // "Speed"
  2762. say_e(115, MBASE(4)); // "E"
  2763. #endif
  2764. #endif
  2765. }
  2766. Draw_Back_First();
  2767. LOOP_L_N(i, 3 + ENABLED(HAS_HOTEND)) Draw_Menu_Line(i + 1, ICON_MaxSpeedJerkX + i);
  2768. DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 210, MBASE(1), planner.max_jerk[X_AXIS] * MINUNITMULT);
  2769. DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 210, MBASE(2), planner.max_jerk[Y_AXIS] * MINUNITMULT);
  2770. DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 210, MBASE(3), planner.max_jerk[Z_AXIS] * MINUNITMULT);
  2771. #if HAS_HOTEND
  2772. DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 210, MBASE(4), planner.max_jerk[E_AXIS] * MINUNITMULT);
  2773. #endif
  2774. }
  2775. inline void Draw_Steps_Menu() {
  2776. Clear_Main_Window();
  2777. if (HMI_flag.language_chinese) {
  2778. DWIN_Frame_TitleCopy(1, 1, 16, 28, 28); // "Steps per mm"
  2779. DWIN_Frame_AreaCopy(1, 153, 148, 194, 161, LBLX, MBASE(1));
  2780. DWIN_Frame_AreaCopy(1, 229, 133, 236, 147, LBLX + 44, MBASE(1)); // Transmission Ratio X
  2781. DWIN_Frame_AreaCopy(1, 153, 148, 194, 161, LBLX, MBASE(2));
  2782. DWIN_Frame_AreaCopy(1, 1, 150, 7, 160, LBLX + 44, MBASE(2) + 3); // Transmission Ratio Y
  2783. DWIN_Frame_AreaCopy(1, 153, 148, 194, 161, LBLX, MBASE(3));
  2784. DWIN_Frame_AreaCopy(1, 9, 150, 16, 160, LBLX + 44, MBASE(3) + 3); // Transmission Ratio Z
  2785. #if HAS_HOTEND
  2786. DWIN_Frame_AreaCopy(1, 153, 148, 194, 161, LBLX, MBASE(4));
  2787. DWIN_Frame_AreaCopy(1, 18, 150, 25, 160, LBLX + 44, MBASE(4) + 3); // Transmission Ratio E
  2788. #endif
  2789. }
  2790. else {
  2791. #ifdef USE_STRING_HEADINGS
  2792. Draw_Title(GET_TEXT_F(MSG_STEPS_PER_MM));
  2793. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(1), F("Steps/mm X"));
  2794. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(2), F("Steps/mm Y"));
  2795. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(3), F("Steps/mm Z"));
  2796. #if HAS_HOTEND
  2797. DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(4), F("Steps/mm E"));
  2798. #endif
  2799. #else
  2800. DWIN_Frame_TitleCopy(1, 144, 16, 189, 26); // "Steps per mm"
  2801. draw_steps_per_mm(MBASE(1)); say_x(103, MBASE(1)); // "Steps-per-mm X"
  2802. draw_steps_per_mm(MBASE(2)); say_y(103, MBASE(2)); // "Y"
  2803. draw_steps_per_mm(MBASE(3)); say_z(103, MBASE(3)); // "Z"
  2804. #if HAS_HOTEND
  2805. draw_steps_per_mm(MBASE(4)); say_e(103, MBASE(4)); // "E"
  2806. #endif
  2807. #endif
  2808. }
  2809. Draw_Back_First();
  2810. LOOP_L_N(i, 3 + ENABLED(HAS_HOTEND)) Draw_Menu_Line(i + 1, ICON_StepX + i);
  2811. DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 210, MBASE(1), planner.settings.axis_steps_per_mm[X_AXIS] * MINUNITMULT);
  2812. DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 210, MBASE(2), planner.settings.axis_steps_per_mm[Y_AXIS] * MINUNITMULT);
  2813. DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 210, MBASE(3), planner.settings.axis_steps_per_mm[Z_AXIS] * MINUNITMULT);
  2814. #if HAS_HOTEND
  2815. DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 210, MBASE(4), planner.settings.axis_steps_per_mm[E_AXIS] * MINUNITMULT);
  2816. #endif
  2817. }
  2818. /* Motion */
  2819. void HMI_Motion() {
  2820. ENCODER_DiffState encoder_diffState = get_encoder_state();
  2821. if (encoder_diffState == ENCODER_DIFF_NO) return;
  2822. // Avoid flicker by updating only the previous menu
  2823. if (encoder_diffState == ENCODER_DIFF_CW) {
  2824. if (select_motion.inc(1 + MOTION_CASE_TOTAL)) Move_Highlight(1, select_motion.now);
  2825. }
  2826. else if (encoder_diffState == ENCODER_DIFF_CCW) {
  2827. if (select_motion.dec()) Move_Highlight(-1, select_motion.now);
  2828. }
  2829. else if (encoder_diffState == ENCODER_DIFF_ENTER) {
  2830. switch (select_motion.now) {
  2831. case 0: // Back
  2832. checkkey = Control;
  2833. select_control.set(CONTROL_CASE_MOVE);
  2834. index_control = MROWS;
  2835. Draw_Control_Menu();
  2836. break;
  2837. case MOTION_CASE_RATE: // Max speed
  2838. checkkey = MaxSpeed;
  2839. select_speed.reset();
  2840. Draw_Max_Speed_Menu();
  2841. break;
  2842. case MOTION_CASE_ACCEL: // Max acceleration
  2843. checkkey = MaxAcceleration;
  2844. select_acc.reset();
  2845. Draw_Max_Accel_Menu();
  2846. break;
  2847. #if HAS_CLASSIC_JERK
  2848. case MOTION_CASE_JERK: // Max jerk
  2849. checkkey = MaxJerk;
  2850. select_jerk.reset();
  2851. Draw_Max_Jerk_Menu();
  2852. break;
  2853. #endif
  2854. case MOTION_CASE_STEPS: // Steps per mm
  2855. checkkey = Step;
  2856. select_step.reset();
  2857. Draw_Steps_Menu();
  2858. break;
  2859. default: break;
  2860. }
  2861. }
  2862. DWIN_UpdateLCD();
  2863. }
  2864. /* Info */
  2865. void HMI_Info() {
  2866. ENCODER_DiffState encoder_diffState = get_encoder_state();
  2867. if (encoder_diffState == ENCODER_DIFF_NO) return;
  2868. if (encoder_diffState == ENCODER_DIFF_ENTER) {
  2869. #if HAS_ONESTEP_LEVELING
  2870. checkkey = Control;
  2871. select_control.set(CONTROL_CASE_INFO);
  2872. Draw_Control_Menu();
  2873. #else
  2874. select_page.set(3);
  2875. Goto_MainMenu();
  2876. #endif
  2877. }
  2878. DWIN_UpdateLCD();
  2879. }
  2880. /* Tune */
  2881. void HMI_Tune() {
  2882. ENCODER_DiffState encoder_diffState = get_encoder_state();
  2883. if (encoder_diffState == ENCODER_DIFF_NO) return;
  2884. // Avoid flicker by updating only the previous menu
  2885. if (encoder_diffState == ENCODER_DIFF_CW) {
  2886. if (select_tune.inc(1 + TUNE_CASE_TOTAL)) {
  2887. if (select_tune.now > MROWS && select_tune.now > index_tune) {
  2888. index_tune = select_tune.now;
  2889. Scroll_Menu(DWIN_SCROLL_UP);
  2890. }
  2891. else {
  2892. Move_Highlight(1, select_tune.now + MROWS - index_tune);
  2893. }
  2894. }
  2895. }
  2896. else if (encoder_diffState == ENCODER_DIFF_CCW) {
  2897. if (select_tune.dec()) {
  2898. if (select_tune.now < index_tune - MROWS) {
  2899. index_tune--;
  2900. Scroll_Menu(DWIN_SCROLL_DOWN);
  2901. if (index_tune == MROWS) Draw_Back_First();
  2902. }
  2903. else {
  2904. Move_Highlight(-1, select_tune.now + MROWS - index_tune);
  2905. }
  2906. }
  2907. }
  2908. else if (encoder_diffState == ENCODER_DIFF_ENTER) {
  2909. switch (select_tune.now) {
  2910. case 0: { // Back
  2911. select_print.set(0);
  2912. Goto_PrintProcess();
  2913. }
  2914. break;
  2915. case TUNE_CASE_SPEED: // Print speed
  2916. checkkey = PrintSpeed;
  2917. HMI_ValueStruct.print_speed = feedrate_percentage;
  2918. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(TUNE_CASE_SPEED + MROWS - index_tune), feedrate_percentage);
  2919. EncoderRate.enabled = true;
  2920. break;
  2921. #if HAS_HOTEND
  2922. case TUNE_CASE_TEMP: // Nozzle temp
  2923. checkkey = ETemp;
  2924. HMI_ValueStruct.E_Temp = thermalManager.temp_hotend[0].target;
  2925. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(TUNE_CASE_TEMP + MROWS - index_tune), thermalManager.temp_hotend[0].target);
  2926. EncoderRate.enabled = true;
  2927. break;
  2928. #endif
  2929. #if HAS_HEATED_BED
  2930. case TUNE_CASE_BED: // Bed temp
  2931. checkkey = BedTemp;
  2932. HMI_ValueStruct.Bed_Temp = thermalManager.temp_bed.target;
  2933. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(TUNE_CASE_BED + MROWS - index_tune), thermalManager.temp_bed.target);
  2934. EncoderRate.enabled = true;
  2935. break;
  2936. #endif
  2937. #if HAS_FAN
  2938. case TUNE_CASE_FAN: // Fan speed
  2939. checkkey = FanSpeed;
  2940. HMI_ValueStruct.Fan_speed = thermalManager.fan_speed[0];
  2941. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(TUNE_CASE_FAN + MROWS - index_tune), thermalManager.fan_speed[0]);
  2942. EncoderRate.enabled = true;
  2943. break;
  2944. #endif
  2945. #if HAS_ZOFFSET_ITEM
  2946. case TUNE_CASE_ZOFF: // Z-offset
  2947. #if EITHER(HAS_BED_PROBE, BABYSTEPPING)
  2948. checkkey = Homeoffset;
  2949. HMI_ValueStruct.offset_value = BABY_Z_VAR * 100;
  2950. DWIN_Draw_Signed_Float(font8x16, Select_Color, 2, 2, 202, MBASE(TUNE_CASE_ZOFF + MROWS - index_tune), HMI_ValueStruct.offset_value);
  2951. EncoderRate.enabled = true;
  2952. #else
  2953. // Apply workspace offset, making the current position 0,0,0
  2954. queue.inject_P(PSTR("G92 X0 Y0 Z0"));
  2955. HMI_AudioFeedback();
  2956. #endif
  2957. break;
  2958. #endif
  2959. default: break;
  2960. }
  2961. }
  2962. DWIN_UpdateLCD();
  2963. }
  2964. #if HAS_PREHEAT
  2965. /* PLA Preheat */
  2966. void HMI_PLAPreheatSetting() {
  2967. ENCODER_DiffState encoder_diffState = get_encoder_state();
  2968. if (encoder_diffState == ENCODER_DIFF_NO) return;
  2969. // Avoid flicker by updating only the previous menu
  2970. if (encoder_diffState == ENCODER_DIFF_CW) {
  2971. if (select_PLA.inc(1 + PREHEAT_CASE_TOTAL)) Move_Highlight(1, select_PLA.now);
  2972. }
  2973. else if (encoder_diffState == ENCODER_DIFF_CCW) {
  2974. if (select_PLA.dec()) Move_Highlight(-1, select_PLA.now);
  2975. }
  2976. else if (encoder_diffState == ENCODER_DIFF_ENTER) {
  2977. switch (select_PLA.now) {
  2978. case 0: // Back
  2979. checkkey = TemperatureID;
  2980. select_temp.now = TEMP_CASE_PLA;
  2981. HMI_ValueStruct.show_mode = -1;
  2982. Draw_Temperature_Menu();
  2983. break;
  2984. #if HAS_HOTEND
  2985. case PREHEAT_CASE_TEMP: // Nozzle temperature
  2986. checkkey = ETemp;
  2987. HMI_ValueStruct.E_Temp = ui.material_preset[0].hotend_temp;
  2988. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(PREHEAT_CASE_TEMP), ui.material_preset[0].hotend_temp);
  2989. EncoderRate.enabled = true;
  2990. break;
  2991. #endif
  2992. #if HAS_HEATED_BED
  2993. case PREHEAT_CASE_BED: // Bed temperature
  2994. checkkey = BedTemp;
  2995. HMI_ValueStruct.Bed_Temp = ui.material_preset[0].bed_temp;
  2996. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(PREHEAT_CASE_BED), ui.material_preset[0].bed_temp);
  2997. EncoderRate.enabled = true;
  2998. break;
  2999. #endif
  3000. #if HAS_FAN
  3001. case PREHEAT_CASE_FAN: // Fan speed
  3002. checkkey = FanSpeed;
  3003. HMI_ValueStruct.Fan_speed = ui.material_preset[0].fan_speed;
  3004. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(PREHEAT_CASE_FAN), ui.material_preset[0].fan_speed);
  3005. EncoderRate.enabled = true;
  3006. break;
  3007. #endif
  3008. #if ENABLED(EEPROM_SETTINGS)
  3009. case 4: { // Save PLA configuration
  3010. const bool success = settings.save();
  3011. HMI_AudioFeedback(success);
  3012. } break;
  3013. #endif
  3014. default: break;
  3015. }
  3016. }
  3017. DWIN_UpdateLCD();
  3018. }
  3019. /* ABS Preheat */
  3020. void HMI_ABSPreheatSetting() {
  3021. ENCODER_DiffState encoder_diffState = get_encoder_state();
  3022. if (encoder_diffState == ENCODER_DIFF_NO) return;
  3023. // Avoid flicker by updating only the previous menu
  3024. if (encoder_diffState == ENCODER_DIFF_CW) {
  3025. if (select_ABS.inc(1 + PREHEAT_CASE_TOTAL)) Move_Highlight(1, select_ABS.now);
  3026. }
  3027. else if (encoder_diffState == ENCODER_DIFF_CCW) {
  3028. if (select_ABS.dec()) Move_Highlight(-1, select_ABS.now);
  3029. }
  3030. else if (encoder_diffState == ENCODER_DIFF_ENTER) {
  3031. switch (select_ABS.now) {
  3032. case 0: // Back
  3033. checkkey = TemperatureID;
  3034. select_temp.now = TEMP_CASE_ABS;
  3035. HMI_ValueStruct.show_mode = -1;
  3036. Draw_Temperature_Menu();
  3037. break;
  3038. #if HAS_HOTEND
  3039. case PREHEAT_CASE_TEMP: // Set nozzle temperature
  3040. checkkey = ETemp;
  3041. HMI_ValueStruct.E_Temp = ui.material_preset[1].hotend_temp;
  3042. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(PREHEAT_CASE_TEMP), ui.material_preset[1].hotend_temp);
  3043. EncoderRate.enabled = true;
  3044. break;
  3045. #endif
  3046. #if HAS_HEATED_BED
  3047. case PREHEAT_CASE_BED: // Set bed temperature
  3048. checkkey = BedTemp;
  3049. HMI_ValueStruct.Bed_Temp = ui.material_preset[1].bed_temp;
  3050. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(PREHEAT_CASE_BED), ui.material_preset[1].bed_temp);
  3051. EncoderRate.enabled = true;
  3052. break;
  3053. #endif
  3054. #if HAS_FAN
  3055. case PREHEAT_CASE_FAN: // Set fan speed
  3056. checkkey = FanSpeed;
  3057. HMI_ValueStruct.Fan_speed = ui.material_preset[1].fan_speed;
  3058. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(PREHEAT_CASE_FAN), ui.material_preset[1].fan_speed);
  3059. EncoderRate.enabled = true;
  3060. break;
  3061. #endif
  3062. #if ENABLED(EEPROM_SETTINGS)
  3063. case PREHEAT_CASE_SAVE: { // Save ABS configuration
  3064. const bool success = settings.save();
  3065. HMI_AudioFeedback(success);
  3066. } break;
  3067. #endif
  3068. default: break;
  3069. }
  3070. }
  3071. DWIN_UpdateLCD();
  3072. }
  3073. #endif
  3074. /* Max Speed */
  3075. void HMI_MaxSpeed() {
  3076. ENCODER_DiffState encoder_diffState = get_encoder_state();
  3077. if (encoder_diffState == ENCODER_DIFF_NO) return;
  3078. // Avoid flicker by updating only the previous menu
  3079. if (encoder_diffState == ENCODER_DIFF_CW) {
  3080. if (select_speed.inc(1 + 3 + ENABLED(HAS_HOTEND))) Move_Highlight(1, select_speed.now);
  3081. }
  3082. else if (encoder_diffState == ENCODER_DIFF_CCW) {
  3083. if (select_speed.dec()) Move_Highlight(-1, select_speed.now);
  3084. }
  3085. else if (encoder_diffState == ENCODER_DIFF_ENTER) {
  3086. if (WITHIN(select_speed.now, 1, 4)) {
  3087. checkkey = MaxSpeed_value;
  3088. HMI_flag.feedspeed_axis = AxisEnum(select_speed.now - 1);
  3089. HMI_ValueStruct.Max_Feedspeed = planner.settings.max_feedrate_mm_s[HMI_flag.feedspeed_axis];
  3090. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 4, 210, MBASE(select_speed.now), HMI_ValueStruct.Max_Feedspeed);
  3091. EncoderRate.enabled = true;
  3092. }
  3093. else { // Back
  3094. checkkey = Motion;
  3095. select_motion.now = MOTION_CASE_RATE;
  3096. Draw_Motion_Menu();
  3097. }
  3098. }
  3099. DWIN_UpdateLCD();
  3100. }
  3101. /* Max Acceleration */
  3102. void HMI_MaxAcceleration() {
  3103. ENCODER_DiffState encoder_diffState = get_encoder_state();
  3104. if (encoder_diffState == ENCODER_DIFF_NO) return;
  3105. // Avoid flicker by updating only the previous menu
  3106. if (encoder_diffState == ENCODER_DIFF_CW) {
  3107. if (select_acc.inc(1 + 3 + ENABLED(HAS_HOTEND))) Move_Highlight(1, select_acc.now);
  3108. }
  3109. else if (encoder_diffState == ENCODER_DIFF_CCW) {
  3110. if (select_acc.dec()) Move_Highlight(-1, select_acc.now);
  3111. }
  3112. else if (encoder_diffState == ENCODER_DIFF_ENTER) {
  3113. if (WITHIN(select_acc.now, 1, 4)) {
  3114. checkkey = MaxAcceleration_value;
  3115. HMI_flag.acc_axis = AxisEnum(select_acc.now - 1);
  3116. HMI_ValueStruct.Max_Acceleration = planner.settings.max_acceleration_mm_per_s2[HMI_flag.acc_axis];
  3117. DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 4, 210, MBASE(select_acc.now), HMI_ValueStruct.Max_Acceleration);
  3118. EncoderRate.enabled = true;
  3119. }
  3120. else { // Back
  3121. checkkey = Motion;
  3122. select_motion.now = MOTION_CASE_ACCEL;
  3123. Draw_Motion_Menu();
  3124. }
  3125. }
  3126. DWIN_UpdateLCD();
  3127. }
  3128. #if HAS_CLASSIC_JERK
  3129. /* Max Jerk */
  3130. void HMI_MaxJerk() {
  3131. ENCODER_DiffState encoder_diffState = get_encoder_state();
  3132. if (encoder_diffState == ENCODER_DIFF_NO) return;
  3133. // Avoid flicker by updating only the previous menu
  3134. if (encoder_diffState == ENCODER_DIFF_CW) {
  3135. if (select_jerk.inc(1 + 3 + ENABLED(HAS_HOTEND))) Move_Highlight(1, select_jerk.now);
  3136. }
  3137. else if (encoder_diffState == ENCODER_DIFF_CCW) {
  3138. if (select_jerk.dec()) Move_Highlight(-1, select_jerk.now);
  3139. }
  3140. else if (encoder_diffState == ENCODER_DIFF_ENTER) {
  3141. if (WITHIN(select_jerk.now, 1, 4)) {
  3142. checkkey = MaxJerk_value;
  3143. HMI_flag.jerk_axis = AxisEnum(select_jerk.now - 1);
  3144. HMI_ValueStruct.Max_Jerk = planner.max_jerk[HMI_flag.jerk_axis] * MINUNITMULT;
  3145. DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 1, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk);
  3146. EncoderRate.enabled = true;
  3147. }
  3148. else { // Back
  3149. checkkey = Motion;
  3150. select_motion.now = MOTION_CASE_JERK;
  3151. Draw_Motion_Menu();
  3152. }
  3153. }
  3154. DWIN_UpdateLCD();
  3155. }
  3156. #endif // HAS_CLASSIC_JERK
  3157. /* Step */
  3158. void HMI_Step() {
  3159. ENCODER_DiffState encoder_diffState = get_encoder_state();
  3160. if (encoder_diffState == ENCODER_DIFF_NO) return;
  3161. // Avoid flicker by updating only the previous menu
  3162. if (encoder_diffState == ENCODER_DIFF_CW) {
  3163. if (select_step.inc(1 + 3 + ENABLED(HAS_HOTEND))) Move_Highlight(1, select_step.now);
  3164. }
  3165. else if (encoder_diffState == ENCODER_DIFF_CCW) {
  3166. if (select_step.dec()) Move_Highlight(-1, select_step.now);
  3167. }
  3168. else if (encoder_diffState == ENCODER_DIFF_ENTER) {
  3169. if (WITHIN(select_step.now, 1, 4)) {
  3170. checkkey = Step_value;
  3171. HMI_flag.step_axis = AxisEnum(select_step.now - 1);
  3172. HMI_ValueStruct.Max_Step = planner.settings.axis_steps_per_mm[HMI_flag.step_axis] * MINUNITMULT;
  3173. DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 1, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step);
  3174. EncoderRate.enabled = true;
  3175. }
  3176. else { // Back
  3177. checkkey = Motion;
  3178. select_motion.now = MOTION_CASE_STEPS;
  3179. Draw_Motion_Menu();
  3180. }
  3181. }
  3182. DWIN_UpdateLCD();
  3183. }
  3184. void HMI_Init() {
  3185. HMI_SDCardInit();
  3186. for (uint16_t t = 0; t <= 100; t += 2) {
  3187. DWIN_ICON_Show(ICON, ICON_Bar, 15, 260);
  3188. DWIN_Draw_Rectangle(1, Color_Bg_Black, 15 + t * 242 / 100, 260, 257, 280);
  3189. DWIN_UpdateLCD();
  3190. delay(20);
  3191. }
  3192. HMI_SetLanguage();
  3193. }
  3194. void DWIN_Update() {
  3195. EachMomentUpdate(); // Status update
  3196. HMI_SDCardUpdate(); // SD card update
  3197. DWIN_HandleScreen(); // Rotary encoder update
  3198. }
  3199. void EachMomentUpdate() {
  3200. static millis_t next_rts_update_ms = 0;
  3201. const millis_t ms = millis();
  3202. if (PENDING(ms, next_rts_update_ms)) return;
  3203. next_rts_update_ms = ms + DWIN_SCROLL_UPDATE_INTERVAL;
  3204. // variable update
  3205. update_variable();
  3206. if (checkkey == PrintProcess) {
  3207. // if print done
  3208. if (HMI_flag.print_finish && !HMI_flag.done_confirm_flag) {
  3209. HMI_flag.print_finish = false;
  3210. HMI_flag.done_confirm_flag = true;
  3211. TERN_(POWER_LOSS_RECOVERY, recovery.cancel());
  3212. planner.finish_and_disable();
  3213. // show percent bar and value
  3214. Percentrecord = 0;
  3215. Draw_Print_ProgressBar();
  3216. // show print done confirm
  3217. DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, 250, DWIN_WIDTH - 1, STATUS_Y);
  3218. DWIN_ICON_Show(ICON, HMI_flag.language_chinese ? ICON_Confirm_C : ICON_Confirm_E, 86, 283);
  3219. }
  3220. else if (HMI_flag.pause_flag != printingIsPaused()) {
  3221. // print status update
  3222. HMI_flag.pause_flag = printingIsPaused();
  3223. if (HMI_flag.pause_flag) ICON_Continue(); else ICON_Pause();
  3224. }
  3225. }
  3226. // pause after homing
  3227. if (HMI_flag.pause_action && printingIsPaused() && !planner.has_blocks_queued()) {
  3228. HMI_flag.pause_action = false;
  3229. #if ENABLED(PAUSE_HEAT)
  3230. #if HAS_HEATED_BED
  3231. tempbed = thermalManager.temp_bed.target;
  3232. #endif
  3233. #if HAS_HOTEND
  3234. temphot = thermalManager.temp_hotend[0].target;
  3235. #endif
  3236. thermalManager.disable_all_heaters();
  3237. #endif
  3238. queue.inject_P(PSTR("G1 F1200 X0 Y0"));
  3239. }
  3240. if (card.isPrinting() && checkkey == PrintProcess) { // print process
  3241. const uint8_t card_pct = card.percentDone();
  3242. static uint8_t last_cardpercentValue = 101;
  3243. if (last_cardpercentValue != card_pct) { // print percent
  3244. last_cardpercentValue = card_pct;
  3245. if (card_pct) {
  3246. Percentrecord = card_pct;
  3247. Draw_Print_ProgressBar();
  3248. }
  3249. }
  3250. duration_t elapsed = print_job_timer.duration(); // print timer
  3251. // Print time so far
  3252. static uint16_t last_Printtime = 0;
  3253. const uint16_t min = (elapsed.value % 3600) / 60;
  3254. if (last_Printtime != min) { // 1 minute update
  3255. last_Printtime = min;
  3256. Draw_Print_ProgressElapsed();
  3257. }
  3258. // Estimate remaining time every 20 seconds
  3259. static millis_t next_remain_time_update = 0;
  3260. if (Percentrecord > 1 && ELAPSED(ms, next_remain_time_update) && !HMI_flag.heat_flag) {
  3261. remain_time = (elapsed.value - dwin_heat_time) / (Percentrecord * 0.01f) - (elapsed.value - dwin_heat_time);
  3262. next_remain_time_update += 20 * 1000UL;
  3263. Draw_Print_ProgressRemain();
  3264. }
  3265. }
  3266. else if (dwin_abort_flag && !HMI_flag.home_flag) { // Print Stop
  3267. dwin_abort_flag = false;
  3268. HMI_ValueStruct.print_speed = feedrate_percentage = 100;
  3269. dwin_zoffset = TERN0(HAS_BED_PROBE, probe.offset.z);
  3270. planner.finish_and_disable();
  3271. #if DISABLED(SD_ABORT_NO_COOLDOWN)
  3272. thermalManager.disable_all_heaters();
  3273. #endif
  3274. select_page.set(0);
  3275. Goto_MainMenu();
  3276. }
  3277. #if ENABLED(POWER_LOSS_RECOVERY)
  3278. else if (DWIN_lcd_sd_status && recovery.dwin_flag) { // resume print before power off
  3279. static bool recovery_flag = false;
  3280. recovery.dwin_flag = false;
  3281. recovery.load();
  3282. if (!recovery.valid()) return recovery.purge();
  3283. auto draw_first_option = [](const bool sel) {
  3284. const uint16_t c1 = sel ? Color_Bg_Window : Select_Color;
  3285. DWIN_Draw_Rectangle(0, c1, 25, 306, 126, 345);
  3286. DWIN_Draw_Rectangle(0, c1, 24, 305, 127, 346);
  3287. };
  3288. auto update_selection = [&](const bool sel) {
  3289. HMI_flag.select_flag = sel;
  3290. draw_first_option(sel);
  3291. const uint16_t c2 = sel ? Select_Color : Color_Bg_Window;
  3292. DWIN_Draw_Rectangle(0, c2, 145, 306, 246, 345);
  3293. DWIN_Draw_Rectangle(0, c2, 144, 305, 247, 346);
  3294. };
  3295. const uint16_t fileCnt = card.get_num_Files();
  3296. for (uint16_t i = 0; i < fileCnt; i++) {
  3297. // TODO: Resume print via M1000 then update the UI
  3298. // with the active filename which can come from CardReader.
  3299. card.getfilename_sorted(SD_ORDER(i, fileCnt));
  3300. if (!strcmp(card.filename, &recovery.info.sd_filename[1])) { // Resume print before power failure while have the same file
  3301. recovery_flag = true;
  3302. HMI_flag.select_flag = true;
  3303. Popup_Window_Resume();
  3304. draw_first_option(false);
  3305. char * const name = card.longest_filename();
  3306. const int8_t npos = _MAX(0, DWIN_WIDTH - strlen(name) * (MENU_CHR_W)) / 2;
  3307. DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, npos, 252, name);
  3308. DWIN_UpdateLCD();
  3309. break;
  3310. }
  3311. }
  3312. // if hasn't resumable G-code file
  3313. if (!recovery_flag) return;
  3314. while (recovery_flag) {
  3315. ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
  3316. if (encoder_diffState != ENCODER_DIFF_NO) {
  3317. if (encoder_diffState == ENCODER_DIFF_ENTER) {
  3318. recovery_flag = false;
  3319. if (HMI_flag.select_flag) break;
  3320. TERN_(POWER_LOSS_RECOVERY, recovery.cancel());
  3321. HMI_StartFrame(true);
  3322. return;
  3323. }
  3324. else
  3325. update_selection(encoder_diffState == ENCODER_DIFF_CCW);
  3326. DWIN_UpdateLCD();
  3327. }
  3328. }
  3329. select_print.set(0);
  3330. HMI_ValueStruct.show_mode = 0;
  3331. HMI_StartFrame(false);
  3332. recovery.resume();
  3333. return;
  3334. }
  3335. #endif
  3336. DWIN_UpdateLCD();
  3337. }
  3338. void DWIN_HandleScreen() {
  3339. switch (checkkey) {
  3340. case MainMenu: HMI_MainMenu(); break;
  3341. case SelectFile: HMI_SelectFile(); break;
  3342. case Prepare: HMI_Prepare(); break;
  3343. case Control: HMI_Control(); break;
  3344. case Leveling: break;
  3345. case PrintProcess: HMI_Printing(); break;
  3346. case Print_window: HMI_PauseOrStop(); break;
  3347. case AxisMove: HMI_AxisMove(); break;
  3348. case TemperatureID: HMI_Temperature(); break;
  3349. case Motion: HMI_Motion(); break;
  3350. case Info: HMI_Info(); break;
  3351. case Tune: HMI_Tune(); break;
  3352. #if HAS_PREHEAT
  3353. case PLAPreheat: HMI_PLAPreheatSetting(); break;
  3354. case ABSPreheat: HMI_ABSPreheatSetting(); break;
  3355. #endif
  3356. case MaxSpeed: HMI_MaxSpeed(); break;
  3357. case MaxAcceleration: HMI_MaxAcceleration(); break;
  3358. case MaxJerk: HMI_MaxJerk(); break;
  3359. case Step: HMI_Step(); break;
  3360. case Move_X: HMI_Move_X(); break;
  3361. case Move_Y: HMI_Move_Y(); break;
  3362. case Move_Z: HMI_Move_Z(); break;
  3363. #if HAS_HOTEND
  3364. case Extruder: HMI_Move_E(); break;
  3365. case ETemp: HMI_ETemp(); break;
  3366. #endif
  3367. #if EITHER(HAS_BED_PROBE, BABYSTEPPING)
  3368. case Homeoffset: HMI_Zoffset(); break;
  3369. #endif
  3370. #if HAS_HEATED_BED
  3371. case BedTemp: HMI_BedTemp(); break;
  3372. #endif
  3373. #if HAS_PREHEAT
  3374. case FanSpeed: HMI_FanSpeed(); break;
  3375. #endif
  3376. case PrintSpeed: HMI_PrintSpeed(); break;
  3377. case MaxSpeed_value: HMI_MaxFeedspeedXYZE(); break;
  3378. case MaxAcceleration_value: HMI_MaxAccelerationXYZE(); break;
  3379. case MaxJerk_value: HMI_MaxJerkXYZE(); break;
  3380. case Step_value: HMI_StepXYZE(); break;
  3381. default: break;
  3382. }
  3383. }
  3384. void DWIN_CompletedHoming() {
  3385. HMI_flag.home_flag = false;
  3386. if (checkkey == Last_Prepare) {
  3387. checkkey = Prepare;
  3388. select_prepare.now = PREPARE_CASE_HOME;
  3389. index_prepare = MROWS;
  3390. Draw_Prepare_Menu();
  3391. }
  3392. else if (checkkey == Back_Main) {
  3393. HMI_ValueStruct.print_speed = feedrate_percentage = 100;
  3394. dwin_zoffset = TERN0(HAS_BED_PROBE, probe.offset.z);
  3395. planner.finish_and_disable();
  3396. Goto_MainMenu();
  3397. }
  3398. }
  3399. void DWIN_CompletedLeveling() {
  3400. if (checkkey == Leveling) Goto_MainMenu();
  3401. }
  3402. #endif // DWIN_CREALITY_LCD