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

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