1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592 |
- /**
- * Marlin 3D Printer Firmware
- * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
- *
- * Based on Sprinter and grbl.
- * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- *
- */
-
- /**
- * DWIN by Creality3D
- */
-
- #include "../../../inc/MarlinConfigPre.h"
-
- #if ENABLED(DWIN_CREALITY_LCD)
-
- #if ANY(AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT) && DISABLED(PROBE_MANUALLY)
- #define HAS_ONESTEP_LEVELING 1
- #endif
-
- #include "dwin.h"
-
- #include <WString.h>
- #include <stdio.h>
- #include <string.h>
-
- #include "../../fontutils.h"
- #include "../../ultralcd.h"
-
- #include "../../../sd/cardreader.h"
-
- #include "../../../MarlinCore.h"
- #include "../../../core/serial.h"
- #include "../../../core/macros.h"
- #include "../../../gcode/queue.h"
-
- #include "../../../feature/babystep.h"
-
- #include "../../../module/temperature.h"
- #include "../../../module/printcounter.h"
- #include "../../../module/motion.h"
- #include "../../../module/planner.h"
-
- #if ENABLED(EEPROM_SETTINGS)
- #include "../../../module/settings.h"
- #endif
-
- #if ENABLED(HOST_ACTION_COMMANDS)
- #include "../../../feature/host_actions.h"
- #endif
-
- #if HAS_ONESTEP_LEVELING
- #include "../../../feature/bedlevel/bedlevel.h"
- #endif
-
- #if HAS_BED_PROBE
- #include "../../../module/probe.h"
- #endif
-
- #if ENABLED(POWER_LOSS_RECOVERY)
- #include "../../../feature/powerloss.h"
- #endif
-
- #ifndef MACHINE_SIZE
- #define MACHINE_SIZE "220x220x250"
- #endif
- #ifndef CORP_WEBSITE_C
- #define CORP_WEBSITE_C "www.cxsw3d.com"
- #endif
- #ifndef CORP_WEBSITE_E
- #define CORP_WEBSITE_E "www.creality.com"
- #endif
-
- #define PAUSE_HEAT true
-
- #define USE_STRING_HEADINGS
-
- #define MENU_FONT font8x16
- #define STAT_FONT font10x20
- #define HEADER_FONT font10x20
-
- #define MENU_CHAR_LIMIT 24
-
- // Fan speed limit
- #define FANON 255
- #define FANOFF 0
-
- // Print speed limit
- #define MAX_PRINT_SPEED 999
- #define MIN_PRINT_SPEED 10
-
- // Temp limits
- #if HAS_HOTEND
- #define MAX_E_TEMP (HEATER_0_MAXTEMP - (HOTEND_OVERSHOOT))
- #define MIN_E_TEMP HEATER_0_MINTEMP
- #endif
-
- #if HAS_HEATED_BED
- #define MIN_BED_TEMP BED_MINTEMP
- #endif
-
- // Feedspeed limit (max feedspeed = DEFAULT_MAX_FEEDRATE * 2)
- #define MIN_MAXFEEDSPEED 1
- #define MIN_MAXACCELERATION 1
- #define MIN_MAXCORNER 0.1
- #define MIN_STEP 1
-
- #define FEEDRATE_E (60)
-
- // Mininum unit (0.1) : multiple (10)
- #define MINUNITMULT 10
-
- #define ENCODER_WAIT 20
- #define DWIN_SCROLL_UPDATE_INTERVAL 2000
- #define DWIN_REMAIN_TIME_UPDATE_INTERVAL 20000
-
- constexpr uint16_t TROWS = 6, MROWS = TROWS - 1, // Total rows, and other-than-Back
- TITLE_HEIGHT = 30, // Title bar height
- MLINE = 53, // Menu line height
- LBLX = 60, // Menu item label X
- MENU_CHR_W = 8, STAT_CHR_W = 10;
-
- #define MBASE(L) (49 + (L)*MLINE)
-
- #define BABY_Z_VAR TERN(HAS_BED_PROBE, probe.offset.z, dwin_zoffset)
-
- /* Value Init */
- HMI_value_t HMI_ValueStruct;
- HMI_Flag HMI_flag{0};
-
- millis_t Encoder_ms = 0;
- millis_t Wait_ms = 0;
- millis_t dwin_heat_time = 0;
-
- int checkkey = 0, last_checkkey = 0;
-
- typedef struct {
- uint8_t now, last;
- void set(uint8_t v) { now = last = v; }
- void reset() { set(0); }
- bool changed() { bool c = (now != last); if (c) last = now; return c; }
- bool dec() { if (now) now--; return changed(); }
- bool inc(uint8_t v) { if (now < v) now++; else now = v; return changed(); }
- } select_t;
-
- select_t select_page{0}, select_file{0}, select_print{0}, select_prepare{0}
- , select_control{0}, select_axis{0}, select_temp{0}, select_motion{0}, select_tune{0}
- , select_PLA{0}, select_ABS{0}
- , select_speed{0}
- , select_acc{0}
- , select_jerk{0}
- , select_step{0}
- // , select_leveling{0}
- ;
-
- uint8_t index_file = MROWS,
- index_prepare = MROWS,
- index_control = MROWS,
- index_leveling = MROWS,
- index_tune = 5;
-
- // char filebuf[50];
-
- uint8_t countbuf = 0;
-
- bool recovery_flag = false, abort_flag = false;
-
- constexpr float default_max_feedrate[] = DEFAULT_MAX_FEEDRATE;
- constexpr float default_max_acceleration[] = DEFAULT_MAX_ACCELERATION;
- constexpr float default_max_jerk[] = { DEFAULT_XJERK, DEFAULT_YJERK, DEFAULT_ZJERK, DEFAULT_EJERK };
- constexpr float default_axis_steps_per_unit[] = DEFAULT_AXIS_STEPS_PER_UNIT;
-
- uint8_t Percentrecord = 0;
- uint16_t last_Printtime = 0, remain_time = 0;
- float last_temp_hotend_target = 0, last_temp_bed_target = 0;
- float last_temp_hotend_current = 0, last_temp_bed_current = 0;
- uint8_t last_fan_speed = 0;
- uint16_t last_speed = 0;
- float last_E_scale = 0;
- bool DWIN_lcd_sd_status = 0;
- bool pause_action_flag = 0;
- int temphot = 0, tempbed = 0;
- float dwin_zoffset = 0;
- float last_zoffset = 0;
-
- #define DWIN_LANGUAGE_EEPROM_ADDRESS 0x01 // Between 0x01 and 0x63 (EEPROM_OFFSET-1)
- // BL24CXX::check() uses 0x00
-
- void HMI_SetLanguage(void) {
- BL24CXX::read(DWIN_LANGUAGE_EEPROM_ADDRESS, (uint8_t*)&HMI_flag.language_chinese, sizeof(HMI_flag.language_chinese));
- if (HMI_flag.language_chinese)
- DWIN_JPG_CacheTo1(Language_Chinese);
- else
- DWIN_JPG_CacheTo1(Language_English);
- }
-
- void HMI_SetAndSaveLanguageWestern(void) {
- HMI_flag.language_chinese = false;
- DWIN_JPG_CacheTo1(Language_English);
- BL24CXX::write(DWIN_LANGUAGE_EEPROM_ADDRESS, (uint8_t*)&HMI_flag.language_chinese, sizeof(HMI_flag.language_chinese));
- }
- void HMI_SetAndSaveLanguageChinese(void) {
- HMI_flag.language_chinese = true;
- DWIN_JPG_CacheTo1(Language_Chinese);
- BL24CXX::write(DWIN_LANGUAGE_EEPROM_ADDRESS, (uint8_t*)&HMI_flag.language_chinese, sizeof(HMI_flag.language_chinese));
- }
-
- 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) {
- if (value < 0) {
- DWIN_Draw_String(false, true, size, White, bColor, x - 6, y, F("-"));
- DWIN_Draw_FloatValue(true, true, 0, size, White, bColor, iNum, fNum, x, y, -value);
- }
- else {
- DWIN_Draw_String(false, true, size, White, bColor, x - 6, y, F(" "));
- DWIN_Draw_FloatValue(true, true, 0, size, White, bColor, iNum, fNum, x, y, value);
- }
- }
-
- void ICON_Print() {
- if (select_page.now == 0) {
- DWIN_ICON_Show(ICON, ICON_Print_1, 17, 130);
- DWIN_Draw_Rectangle(0, White, 17, 130, 126, 229);
- if (HMI_flag.language_chinese)
- DWIN_Frame_AreaCopy(1, 1, 447, 28, 460, 58, 201);
- else
- DWIN_Frame_AreaCopy(1, 1, 451, 31, 463, 57, 201);
- }
- else {
- DWIN_ICON_Show(ICON, ICON_Print_0, 17, 130);
- if (HMI_flag.language_chinese)
- DWIN_Frame_AreaCopy(1, 1, 405, 28, 420, 58, 201);
- else
- DWIN_Frame_AreaCopy(1, 1, 423, 31, 435, 57, 201);
- }
- }
-
- void ICON_Prepare() {
- if (select_page.now == 1) {
- DWIN_ICON_Show(ICON, ICON_Prepare_1, 145, 130);
- DWIN_Draw_Rectangle(0, White, 145, 130, 254, 229);
- if (HMI_flag.language_chinese)
- DWIN_Frame_AreaCopy(1, 31, 447, 58, 460, 186, 201);
- else
- DWIN_Frame_AreaCopy(1, 33, 451, 82, 466, 175, 201);
- }
- else {
- DWIN_ICON_Show(ICON, ICON_Prepare_0, 145, 130);
- if (HMI_flag.language_chinese)
- DWIN_Frame_AreaCopy(1, 31, 405, 58, 420, 186, 201);
- else
- DWIN_Frame_AreaCopy(1, 33, 423, 82, 438, 175, 201);
- }
- }
-
- void ICON_Control() {
- if (select_page.now == 2) {
- DWIN_ICON_Show(ICON, ICON_Control_1, 17, 246);
- DWIN_Draw_Rectangle(0, White, 17, 246, 126, 345);
- if (HMI_flag.language_chinese)
- DWIN_Frame_AreaCopy(1, 61, 447, 88, 460, 58, 318);
- else
- DWIN_Frame_AreaCopy(1, 85, 451, 132, 463, 48, 318);
- }
- else {
- DWIN_ICON_Show(ICON, ICON_Control_0, 17, 246);
- if (HMI_flag.language_chinese)
- DWIN_Frame_AreaCopy(1, 61, 405, 88, 420, 58, 318);
- else
- DWIN_Frame_AreaCopy(1, 85, 423, 132, 434, 48, 318);
- }
- }
-
- void ICON_StartInfo(bool show) {
- if (show) {
- DWIN_ICON_Show(ICON, ICON_Info_1, 145, 246);
- DWIN_Draw_Rectangle(0, White, 145, 246, 254, 345);
- if (HMI_flag.language_chinese)
- DWIN_Frame_AreaCopy(1, 91, 447, 118, 460, 186, 318);
- else
- DWIN_Frame_AreaCopy(1, 132, 451, 159, 466, 186, 318);
- }
- else {
- DWIN_ICON_Show(ICON, ICON_Info_0, 145, 246);
- if (HMI_flag.language_chinese)
- DWIN_Frame_AreaCopy(1, 91, 405, 118, 420, 186, 318);
- else
- DWIN_Frame_AreaCopy(1, 132, 423, 159, 435, 186, 318);
- }
- }
-
- void ICON_Leveling(bool show) {
- if (show) {
- DWIN_ICON_Show(ICON, ICON_Leveling_1, 145, 246);
- DWIN_Draw_Rectangle(0, White, 145, 246, 254, 345);
- if (HMI_flag.language_chinese)
- DWIN_Frame_AreaCopy(1, 211, 447, 238, 460, 186, 318);
- else
- DWIN_Frame_AreaCopy(1, 84, 437, 120, 449, 182, 318);
- }
- else {
- DWIN_ICON_Show(ICON, ICON_Leveling_0, 145, 246);
- if (HMI_flag.language_chinese)
- DWIN_Frame_AreaCopy(1, 211, 405, 238, 420, 186, 318);
- else
- DWIN_Frame_AreaCopy(1, 84, 465, 120, 478, 182, 318);
- }
- }
-
- void ICON_Tune() {
- if (select_print.now == 0) {
- DWIN_ICON_Show(ICON, ICON_Setup_1, 8, 252);
- DWIN_Draw_Rectangle(0, White, 8, 252, 87, 351);
- if (HMI_flag.language_chinese)
- DWIN_Frame_AreaCopy(1, 121, 447, 148, 458, 34, 325);
- else
- DWIN_Frame_AreaCopy(1, 1, 465, 34, 477, 31, 325);
- }
- else {
- DWIN_ICON_Show(ICON, ICON_Setup_0, 8, 252);
- if (HMI_flag.language_chinese)
- DWIN_Frame_AreaCopy(1, 121, 405, 148, 420, 34, 325);
- else
- DWIN_Frame_AreaCopy(1, 1, 438, 32, 448, 31, 325);
- }
- }
-
- void ICON_Pause() {
- if (select_print.now == 1) {
- DWIN_ICON_Show(ICON, ICON_Pause_1, 96, 252);
- DWIN_Draw_Rectangle(0, White, 96, 252, 175, 351);
- if (HMI_flag.language_chinese)
- DWIN_Frame_AreaCopy(1, 181, 447, 208, 459, 124, 325);
- else
- DWIN_Frame_AreaCopy(1, 177, 451, 216, 462, 116, 325);
- }
- else {
- DWIN_ICON_Show(ICON, ICON_Pause_0, 96, 252);
- if (HMI_flag.language_chinese)
- DWIN_Frame_AreaCopy(1, 181, 405, 208, 420, 124, 325);
- else
- DWIN_Frame_AreaCopy(1, 177, 423, 215, 433, 116, 325);
- }
- }
-
- void ICON_Continue() {
- if (select_print.now == 1) {
- DWIN_ICON_Show(ICON, ICON_Continue_1, 96, 252);
- DWIN_Draw_Rectangle(0, White, 96, 252, 175, 351);
- if (HMI_flag.language_chinese)
- DWIN_Frame_AreaCopy(1, 1, 447, 28, 460, 124, 325);
- else
- DWIN_Frame_AreaCopy(1, 1, 451, 32, 463, 121, 325);
- }
- else {
- DWIN_ICON_Show(ICON, ICON_Continue_0, 96, 252);
- if (HMI_flag.language_chinese)
- DWIN_Frame_AreaCopy(1, 1, 405, 28, 420, 124, 325);
- else
- DWIN_Frame_AreaCopy(1, 1, 424, 31, 434, 121, 325);
- }
- }
-
- void ICON_Stop() {
- if (select_print.now == 2) {
- DWIN_ICON_Show(ICON, ICON_Stop_1, 184, 252);
- DWIN_Draw_Rectangle(0, White, 184, 252, 263, 351);
- if (HMI_flag.language_chinese)
- DWIN_Frame_AreaCopy(1, 151, 447, 178, 459, 210, 325);
- else
- DWIN_Frame_AreaCopy(1, 218, 451, 249, 465, 209, 325);
- }
- else {
- DWIN_ICON_Show(ICON, ICON_Stop_0, 184, 252);
- if (HMI_flag.language_chinese)
- DWIN_Frame_AreaCopy(1, 151, 405, 178, 420, 210, 325);
- else
- DWIN_Frame_AreaCopy(1, 218, 423, 247, 436, 209, 325);
- }
- }
-
- inline void Clear_Title_Bar(void) {
- DWIN_Draw_Rectangle(1, Background_blue, 0, 0, DWIN_WIDTH, 30);
- }
-
- inline void Draw_Title(const char * const title) {
- DWIN_Draw_String(false, false, HEADER_FONT, White, Background_blue, 14, 4, (char*)title);
- }
-
- inline void Draw_Title(const __FlashStringHelper * title) {
- DWIN_Draw_String(false, false, HEADER_FONT, White, Background_blue, 14, 4, (char*)title);
- }
-
- inline void Clear_Menu_Area(void) {
- DWIN_Draw_Rectangle(1, Background_black, 0, 31, DWIN_WIDTH, 360);
- }
-
- inline void Clear_Main_Window(void) {
- Clear_Title_Bar();
- Clear_Menu_Area();
- }
-
- inline void Clear_Popup_Area(void) {
- Clear_Title_Bar();
- DWIN_Draw_Rectangle(1, Background_black, 0, 31, DWIN_WIDTH, DWIN_HEIGHT);
- }
-
- void Draw_Popup_Bkgd_105(void) {
- DWIN_Draw_Rectangle(1, Background_window, 14, 105, 258, 374);
- }
-
- inline void Draw_More_Icon(const uint8_t line) {
- DWIN_ICON_Show(ICON, ICON_More, 226, 46 + line * MLINE);
- }
-
- inline void Draw_Menu_Cursor(const uint8_t line) {
- // DWIN_ICON_Show(ICON,ICON_Rectangle, 0, 31 + line * MLINE);
- DWIN_Draw_Rectangle(1, Rectangle_Color, 0, 31 + line * MLINE, 14, 31 + (line + 1) * MLINE - 2);
- }
-
- inline void Erase_Menu_Cursor(const uint8_t line) {
- DWIN_Draw_Rectangle(1, Background_black, 0, 31 + line * MLINE, 14, 31 + (line + 1) * MLINE - 2);
- }
-
- inline void Move_Highlight(const int16_t from, const uint16_t newline) {
- Erase_Menu_Cursor(newline - from);
- Draw_Menu_Cursor(newline);
- }
-
- inline void Add_Menu_Line() {
- Move_Highlight(1, MROWS);
- DWIN_Draw_Line(Line_Color, 16, 82 + MROWS * MLINE, 256, 83 + MROWS * MLINE);
- }
-
- inline void Scroll_Menu(const uint8_t dir) {
- DWIN_Frame_AreaMove(1, dir, MLINE, Background_black, 0, 31, DWIN_WIDTH, 349);
- switch (dir) {
- case DWIN_SCROLL_DOWN: Move_Highlight(-1, 0); break;
- case DWIN_SCROLL_UP: Add_Menu_Line(); break;
- }
- }
-
- inline uint16_t nr_sd_menu_items() {
- return card.get_num_Files() + !card.flag.workDirIsRoot;
- }
-
- inline void Draw_Menu_Icon(const uint8_t line, const uint8_t icon) {
- DWIN_ICON_Show(ICON, icon, 26, 46 + line * MLINE);
- }
-
- inline void Erase_Menu_Text(const uint8_t line) {
- DWIN_Draw_Rectangle(1, Background_black, LBLX, 31 + line * MLINE + 4, 271, 28 + (line + 1) * MLINE - 4);
- }
-
- inline void Draw_Menu_Line(const uint8_t line, const uint8_t icon=0, const char * const label=nullptr) {
- if (label) DWIN_Draw_String(false, false, font8x16, White, Background_black, LBLX, 48 + line * MLINE, (char*)label);
- if (icon) Draw_Menu_Icon(line, icon);
- DWIN_Draw_Line(Line_Color, 16, 29 + (line + 1) * MLINE, 256, 30 + (line + 1) * MLINE);
- }
-
- // The "Back" label is always on the first line
- inline void Draw_Back_Label(void) {
- if (HMI_flag.language_chinese)
- DWIN_Frame_AreaCopy(1, 129, 72, 156, 84, LBLX, MBASE(0));
- else
- DWIN_Frame_AreaCopy(1, 226, 179, 256, 189, LBLX, MBASE(0));
- }
-
- // Draw "Back" line at the top
- inline void Draw_Back_First(const bool is_sel=true) {
- Draw_Menu_Line(0, ICON_Back);
- Draw_Back_Label();
- if (is_sel) Draw_Menu_Cursor(0);
- }
-
- //
- // Draw Menus
- //
-
- inline void draw_move_en(const uint16_t line) {
- DWIN_Frame_AreaCopy(1, 69, 61, 102, 71, LBLX, line); // "Move"
- }
-
- inline void Prepare_Item_Move(const uint8_t row) {
- if (HMI_flag.language_chinese)
- DWIN_Frame_AreaCopy(1, 159, 70, 200, 84, LBLX, MBASE(row));
- else
- draw_move_en(MBASE(row)); // "Move >"
- Draw_Menu_Line(row, ICON_Axis);
- Draw_More_Icon(row);
- }
-
- inline void Prepare_Item_Disable(const uint8_t row) {
- if (HMI_flag.language_chinese)
- DWIN_Frame_AreaCopy(1, 204, 70, 259, 82, LBLX, MBASE(row));
- else
- DWIN_Frame_AreaCopy(1, 103, 59, 200, 74, LBLX, MBASE(row)); // "Disable Stepper"
- Draw_Menu_Line(row, ICON_CloseMotor);
- }
-
- inline void Prepare_Item_Home(const uint8_t row) {
- if (HMI_flag.language_chinese)
- DWIN_Frame_AreaCopy(1, 0, 89, 41, 101, LBLX, MBASE(row));
- else
- DWIN_Frame_AreaCopy(1, 202, 61, 271, 71, LBLX, MBASE(row)); // "Auto Home"
- Draw_Menu_Line(row, ICON_Homing);
- }
-
- inline void Prepare_Item_Offset(const uint8_t row) {
- if (HMI_flag.language_chinese) {
- #if HAS_BED_PROBE
- DWIN_Frame_AreaCopy(1, 174, 164, 223, 177, LBLX, MBASE(row));
- DWIN_Draw_Signed_Float(font8x16, Background_black, 2, 2, 202, MBASE(row), probe.offset.z * 100);
- #else
- DWIN_Frame_AreaCopy(1, 43, 89, 98, 101, LBLX, MBASE(row));
- #endif
- }
- else {
- #if HAS_BED_PROBE
- DWIN_Frame_AreaCopy(1, 93, 179, 141, 189, LBLX, MBASE(row)); // "Z-Offset"
- DWIN_Draw_Signed_Float(font8x16, Background_black, 2, 2, 202, MBASE(row), probe.offset.z * 100);
- #else
- DWIN_Frame_AreaCopy(1, 1, 76, 106, 86, LBLX, MBASE(row)); // "..."
- #endif
- }
- Draw_Menu_Line(row, ICON_SetHome);
- }
-
- inline void Prepare_Item_PLA(const uint8_t row) {
- if (HMI_flag.language_chinese) {
- DWIN_Frame_AreaCopy(1, 100, 89, 151, 101, LBLX, MBASE(row));
- }
- else {
- DWIN_Frame_AreaCopy(1, 107, 76, 156, 86, LBLX, MBASE(row)); // "Preheat"
- DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX + 52, MBASE(row)); // "PLA"
- }
- Draw_Menu_Line(row, ICON_PLAPreheat);
- }
-
- inline void Prepare_Item_ABS(const uint8_t row) {
- if (HMI_flag.language_chinese) {
- DWIN_Frame_AreaCopy(1, 180, 89, 233, 100, LBLX, MBASE(row));
- }
- else {
- DWIN_Frame_AreaCopy(1, 107, 76, 156, 86, LBLX, MBASE(row)); // "Preheat"
- DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX + 52, MBASE(row)); // "ABS"
- }
- Draw_Menu_Line(row, ICON_ABSPreheat);
- }
-
- inline void Prepare_Item_Cool(const uint8_t row) {
- if (HMI_flag.language_chinese)
- DWIN_Frame_AreaCopy(1, 1, 104, 56, 117, LBLX, MBASE(row));
- else
- DWIN_Frame_AreaCopy(1, 200, 76, 264, 86, LBLX, MBASE(row)); // "Cooldown"
- Draw_Menu_Line(row, ICON_Cool);
- }
-
- inline void Prepare_Item_Lang(const uint8_t row) {
- if (HMI_flag.language_chinese) {
- DWIN_Frame_AreaCopy(1, 239, 134, 266, 146, LBLX, MBASE(row));
- DWIN_Draw_String(false, false, font8x16, White, Background_black, 226, MBASE(row), F("CN"));
- }
- else {
- DWIN_Frame_AreaCopy(1, 0, 194, 121, 207, LBLX, MBASE(row)); // "Language selection"
- DWIN_Draw_String(false, false, font8x16, White, Background_black, 226, MBASE(row), F("EN"));
- }
- Draw_Menu_Icon(row, ICON_Language);
- }
-
- inline void Draw_Prepare_Menu() {
- Clear_Main_Window();
-
- const int16_t scroll = MROWS - index_prepare; // Scrolled-up lines
- #define PSCROL(L) (scroll + (L))
- #define PVISI(L) WITHIN(PSCROL(L), 0, MROWS)
-
- if (HMI_flag.language_chinese) {
- DWIN_Frame_AreaCopy(1, 133, 1, 160, 13, 14, 8); // "Prepare"
- }
- else {
- #ifdef USE_STRING_HEADINGS
- Draw_Title(GET_TEXT_F(MSG_PREPARE));
- #else
- DWIN_Frame_AreaCopy(1, 178, 2, 229, 14, 14, 8); // "Prepare"
- #endif
- }
-
- if (PVISI(0)) Draw_Back_First(select_prepare.now == 0); // < Back
- if (PVISI(1)) Prepare_Item_Move(PSCROL(1)); // Move >
- if (PVISI(2)) Prepare_Item_Disable(PSCROL(2)); // Disable Stepper
- if (PVISI(3)) Prepare_Item_Home(PSCROL(3)); // Auto Home
- if (PVISI(4)) Prepare_Item_Offset(PSCROL(4)); // Z-Offset
- if (PVISI(5)) Prepare_Item_PLA(PSCROL(5)); // Preheat PLA
- if (PVISI(6)) Prepare_Item_ABS(PSCROL(6)); // Preheat ABS
- if (PVISI(7)) Prepare_Item_Cool(PSCROL(7)); // Cooldown
- if (PVISI(8)) Prepare_Item_Lang(PSCROL(8)); // Language CN/EN
-
- if (select_prepare.now) Draw_Menu_Cursor(PSCROL(select_prepare.now));
- }
-
- inline void Draw_Control_Menu() {
- Clear_Main_Window();
-
- const int16_t scroll = TERN(HAS_ONESTEP_LEVELING, MROWS - index_control, 0); // Scrolled-up lines
-
- #define CSCROL(L) (scroll + (L))
- #define CLINE(L) MBASE(CSCROL(L))
- #define CVISI(L) WITHIN(CSCROL(L), 0, MROWS)
-
- if (CVISI(0)) Draw_Back_First(select_control.now == 0); // < Back
-
- if (HMI_flag.language_chinese) {
- DWIN_Frame_AreaCopy(1, 103, 1, 130, 14, 14, 8);
- DWIN_Frame_AreaCopy(1, 57, 104, 84, 116, LBLX, CLINE(1)); // Temperature >
- DWIN_Frame_AreaCopy(1, 87, 104, 114, 116, LBLX, CLINE(2)); // Motion >
- DWIN_Frame_AreaCopy(1, 117, 104, 172, 116, LBLX, CLINE(3)); // Store Config
- DWIN_Frame_AreaCopy(1, 174, 103, 229, 116, LBLX, CLINE(4)); // Read Config
- DWIN_Frame_AreaCopy(1, 1, 118, 56, 131, LBLX, CLINE(5)); // Reset Config
-
- if (CVISI(6))
- DWIN_Frame_AreaCopy(1, 231, 104, 258, 116, LBLX, CLINE(6)); // Info >
- }
- else {
- #ifdef USE_STRING_HEADINGS
- Draw_Title(GET_TEXT_F(MSG_CONTROL));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 0), GET_TEXT_F(MSG_TEMPERATURE));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 1), GET_TEXT_F(MSG_MOTION));
- #if ENABLED(EEPROM_SETTINGS)
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 2), GET_TEXT_F(MSG_STORE_EEPROM));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 3), GET_TEXT_F(MSG_LOAD_EEPROM));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 4), GET_TEXT_F(MSG_RESTORE_DEFAULTS));
- if (CVISI(6)) DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 5), F("Info"));
- #else
- if (CVISI(3)) DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 2), F("Info"));
- #endif
- #else
- DWIN_Frame_AreaCopy(1, 128, 2, 176, 12, 14, 8);
- DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX, CLINE(1)); // Temperature >
- DWIN_Frame_AreaCopy(1, 84, 89, 128, 99, LBLX, CLINE(2)); // Motion >
- #if ENABLED(EEPROM_SETTINGS)
- DWIN_Frame_AreaCopy(1, 148, 89, 268, 101, LBLX, CLINE(3)); // "Store Configuration"
- DWIN_Frame_AreaCopy(1, 26, 104, 57, 114, LBLX, CLINE(4)); // "Read"
- DWIN_Frame_AreaCopy(1, 182, 89, 268, 101, LBLX + 34, CLINE(4)); // "Configuration"
- DWIN_Frame_AreaCopy(1, 59, 104, 93, 114, LBLX, CLINE(5)); // "Reset"
- DWIN_Frame_AreaCopy(1, 182, 89, 268, 101, LBLX + 37, CLINE(5)); // "Configuration"
- if (CVISI(6)) DWIN_Frame_AreaCopy(1, 0, 104, 25, 115, LBLX, CLINE(6)); // Info >
- #else
- if (CVISI(3)) DWIN_Frame_AreaCopy(1, 0, 104, 25, 115, LBLX, CLINE(3)); // Info >
- #endif
- #endif
- }
-
- if (select_control.now && CVISI(select_control.now))
- Draw_Menu_Cursor(CSCROL(select_control.now));
-
- // Draw icons and lines
- LOOP_L_N(i, 6)
- if (CVISI(i + 1)) Draw_Menu_Line(CSCROL(i + 1), ICON_Temperature + i);
-
- Draw_More_Icon(CSCROL(1));
- Draw_More_Icon(CSCROL(2));
- if (CVISI(6)) Draw_More_Icon(CSCROL(6));
- }
-
- inline void Draw_Tune_Menu() {
- Clear_Main_Window();
-
- if (HMI_flag.language_chinese) {
- DWIN_Frame_AreaCopy(1, 73, 2, 100, 13, 14, 9);
- DWIN_Frame_AreaCopy(1, 116, 164, 171, 176, LBLX, MBASE(1));
- DWIN_Frame_AreaCopy(1, 1, 134, 56, 146, LBLX, MBASE(2));
- DWIN_Frame_AreaCopy(1, 58, 134, 113, 146, LBLX, MBASE(3));
- DWIN_Frame_AreaCopy(1, 115, 134, 170, 146, LBLX, MBASE(4));
- DWIN_Frame_AreaCopy(1, 174, 164, 223, 177, LBLX, MBASE(5));
- }
- else {
- #ifdef USE_STRING_HEADINGS
- Draw_Title(GET_TEXT_F(MSG_TUNE));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 0), GET_TEXT_F(MSG_SPEED));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 1), GET_TEXT_F(MSG_UBL_SET_TEMP_HOTEND));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 2), GET_TEXT_F(MSG_UBL_SET_TEMP_BED));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 3), GET_TEXT_F(MSG_FAN_SPEED));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 4), GET_TEXT_F(MSG_ZPROBE_ZOFFSET));
- #else
- DWIN_Frame_AreaCopy(1, 94, 2, 126, 12, 14, 9);
- DWIN_Frame_AreaCopy(1, 1, 179, 92, 190, LBLX, MBASE(1)); // print speed
- DWIN_Frame_AreaCopy(1, 197, 104, 238, 114, LBLX, MBASE(2)); // Hotend...
- DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 44, MBASE(2)); // ...Temperature
- DWIN_Frame_AreaCopy(1, 240, 104, 264, 114, LBLX, MBASE(3)); // Bed...
- DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 27, MBASE(3)); // ...Temperature
- DWIN_Frame_AreaCopy(1, 0, 119, 64, 132, LBLX, MBASE(4)); // fan speed
- DWIN_Frame_AreaCopy(1, 93, 179, 141, 189, LBLX, MBASE(5)); // Z-offset
- #endif
- }
-
- Draw_Back_First(select_tune.now == 0);
- if (select_tune.now) Draw_Menu_Cursor(select_tune.now);
-
- Draw_Menu_Line(1, ICON_Speed);
- Draw_Menu_Line(2, ICON_HotendTemp);
- Draw_Menu_Line(3, ICON_BedTemp);
- Draw_Menu_Line(4, ICON_FanSpeed);
- Draw_Menu_Line(5, ICON_Zoffset);
-
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(1), feedrate_percentage);
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(2), thermalManager.temp_hotend[0].target);
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(3), thermalManager.temp_bed.target);
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(4), thermalManager.fan_speed[0]);
- DWIN_Draw_Signed_Float(font8x16, Background_black, 2, 2, 202, MBASE(5), BABY_Z_VAR * 100);
- }
-
- inline void draw_max_en(const uint16_t line) {
- DWIN_Frame_AreaCopy(1, 245, 119, 269, 129, LBLX, line); // "Max"
- }
- inline void draw_max_accel_en(const uint16_t line) {
- draw_max_en(line);
- DWIN_Frame_AreaCopy(1, 1, 135, 79, 145, LBLX + 27, line); // "Acceleration"
- }
- inline void draw_speed_en(const uint16_t inset, const uint16_t line) {
- DWIN_Frame_AreaCopy(1, 184, 119, 224, 132, LBLX + inset, line); // "Speed"
- }
- inline void draw_jerk_en(const uint16_t line) {
- DWIN_Frame_AreaCopy(1, 64, 119, 106, 129, LBLX + 27, line); // "Jerk"
- }
- inline void draw_steps_per_mm(const uint16_t line) {
- DWIN_Frame_AreaCopy(1, 1, 151, 101, 161, LBLX, line); // "Steps-per-mm"
- }
- inline void say_x(const uint16_t inset, const uint16_t line) {
- DWIN_Frame_AreaCopy(1, 95, 104, 102, 114, LBLX + inset, line); // "X"
- }
- inline void say_y(const uint16_t inset, const uint16_t line) {
- DWIN_Frame_AreaCopy(1, 104, 104, 110, 114, LBLX + inset, line); // "Y"
- }
- inline void say_z(const uint16_t inset, const uint16_t line) {
- DWIN_Frame_AreaCopy(1, 112, 104, 120, 114, LBLX + inset, line); // "Z"
- }
- inline void say_e(const uint16_t inset, const uint16_t line) {
- DWIN_Frame_AreaCopy(1, 237, 119, 244, 129, LBLX + inset, line); // "E"
- }
-
- inline void Draw_Motion_Menu() {
- Clear_Main_Window();
-
- if (HMI_flag.language_chinese) {
- DWIN_Frame_AreaCopy(1, 1, 16, 28, 28, 14, 8);
-
- DWIN_Frame_AreaCopy(1, 173, 133, 228, 147, LBLX, MBASE(1)); // Max speed
- DWIN_Frame_AreaCopy(1, 173, 133, 200, 147, LBLX, MBASE(2)); // Max...
- DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(2) + 1); // ...acceleration
- DWIN_Frame_AreaCopy(1, 173, 133, 200, 147, LBLX, MBASE(3)); // Max...
- DWIN_Frame_AreaCopy(1, 1, 180, 28, 192, LBLX + 27, MBASE(3) + 1); // ...
- DWIN_Frame_AreaCopy(1, 202, 133, 228, 147, LBLX + 54, MBASE(3)); // ...jerk
- DWIN_Frame_AreaCopy(1, 153, 148, 194, 161, LBLX, MBASE(4)); // Flow ratio
- }
- else {
- #ifdef USE_STRING_HEADINGS
- Draw_Title(GET_TEXT_F(MSG_MOTION));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 0), F("Feedrate"));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 1), GET_TEXT_F(MSG_ACCELERATION));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 2), GET_TEXT_F(MSG_JERK));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 3), GET_TEXT_F(MSG_STEPS_PER_MM));
- #else
- DWIN_Frame_AreaCopy(1, 144, 16, 189, 26, 14, 8);
- draw_max_en(MBASE(1)); draw_speed_en(27, MBASE(1)); // "Max Speed"
- draw_max_accel_en(MBASE(2)); // "Max Acceleration"
- draw_max_en(MBASE(3)); draw_jerk_en(MBASE(3)); // "Max Jerk"
- draw_steps_per_mm(MBASE(4)); // "Steps-per-mm"
- #endif
- }
-
- Draw_Back_First(select_motion.now == 0);
- if (select_motion.now) Draw_Menu_Cursor(select_motion.now);
-
- LOOP_L_N(i, 4) Draw_Menu_Line(i + 1, ICON_MaxSpeed + i);
-
- Draw_More_Icon(1);
- Draw_More_Icon(2);
- Draw_More_Icon(3);
- Draw_More_Icon(4);
- }
-
- //
- // Draw Popup Windows
- //
-
- void Popup_Window_Temperature(const bool toohigh) {
- Clear_Popup_Area();
- Draw_Popup_Bkgd_105();
- if (toohigh) {
- DWIN_ICON_Show(ICON, ICON_TempTooHigh, 102, 165);
- if (HMI_flag.language_chinese) {
- DWIN_Frame_AreaCopy(1, 103, 371, 237, 386, 52, 285);
- DWIN_Frame_AreaCopy(1, 151, 389, 185, 402, 187, 285);
- DWIN_Frame_AreaCopy(1, 189, 389, 271, 402, 95, 310);
- }
- else {
- DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 36, 300, F("Nozzle or Bed temperature"));
- DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 92, 300, F("is too high"));
- }
- }
- else {
- DWIN_ICON_Show(ICON, ICON_TempTooLow, 102, 165);
- if (HMI_flag.language_chinese) {
- DWIN_Frame_AreaCopy(1, 103, 371, 270, 386, 52, 285);
- DWIN_Frame_AreaCopy(1, 189, 389, 271, 402, 95, 310);
- }
- else {
- DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 36, 300, F("Nozzle or Bed temperature"));
- DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 92, 300, F("is too low"));
- }
- }
- }
-
- inline void Draw_Popup_Bkgd_60() {
- DWIN_Draw_Rectangle(1, Background_window, 14, 60, 258, 330);
- }
-
- #if HAS_HOTEND
-
- void Popup_Window_ETempTooLow(void) {
- Clear_Main_Window();
- Draw_Popup_Bkgd_60();
- DWIN_ICON_Show(ICON, ICON_TempTooLow, 102, 105);
- if (HMI_flag.language_chinese) {
- DWIN_Frame_AreaCopy(1, 103, 371, 136, 386, 69, 240);
- DWIN_Frame_AreaCopy(1, 170, 371, 270, 386, 102, 240);
- DWIN_ICON_Show(ICON, ICON_Confirm_C, 86, 280);
- }
- else {
- DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 20, 235, F("Nozzle is too cold"));
- DWIN_ICON_Show(ICON, ICON_Confirm_E, 86, 280);
- }
- }
-
- #endif
-
- void Popup_Window_Resume(void) {
- Clear_Popup_Area();
- Draw_Popup_Bkgd_105();
- if (HMI_flag.language_chinese) {
- DWIN_Frame_AreaCopy(1, 160, 338, 235, 354, 98, 135);
- DWIN_Frame_AreaCopy(1, 103, 321, 271, 335, 52, 192);
- DWIN_ICON_Show(ICON, ICON_Continue_C, 26, 307);
- DWIN_ICON_Show(ICON, ICON_Cancel_C, 146, 307);
- }
- else {
- DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 120, 115, F("Tips"));
- DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 24, 192, F("I see the file stopped"));
- DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 68, 212, F("unexpectedly last time"));
- DWIN_ICON_Show(ICON, ICON_Continue_E, 26, 307);
- DWIN_ICON_Show(ICON, ICON_Cancel_E, 146, 307);
- }
- }
-
- void Popup_Window_Home(void) {
- Clear_Main_Window();
- Draw_Popup_Bkgd_60();
- DWIN_ICON_Show(ICON, ICON_BLTouch, 101, 105);
- if (HMI_flag.language_chinese) {
- DWIN_Frame_AreaCopy(1, 0, 371, 33, 386, 85, 240);
- DWIN_Frame_AreaCopy(1, 203, 286, 271, 302, 118, 240);
- DWIN_Frame_AreaCopy(1, 0, 389, 150, 402, 61, 280);
- }
- else {
- DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 80, 230, GET_TEXT_F(MSG_LEVEL_BED_HOMING));
- DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 24, 260, F("Please wait until completed"));
- }
- }
-
- void Popup_Window_Leveling(void) {
- Clear_Main_Window();
- Draw_Popup_Bkgd_60();
- DWIN_ICON_Show(ICON, ICON_AutoLeveling, 101, 105);
- if (HMI_flag.language_chinese) {
- DWIN_Frame_AreaCopy(1, 0, 371, 100, 386, 84, 240);
- DWIN_Frame_AreaCopy(1, 0, 389, 150, 402, 61, 280);
- }
- else {
- DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 76, 230, GET_TEXT_F(MSG_BED_LEVELING));
- DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 24, 260, F("Please wait until completed"));
- }
- }
-
- void Draw_Select_Highlight(const bool sel) {
- HMI_flag.select_flag = sel;
- const uint16_t c1 = sel ? Select_Color : Background_window,
- c2 = sel ? Background_window : Select_Color;
- DWIN_Draw_Rectangle(0, c1, 25, 279, 126, 318);
- DWIN_Draw_Rectangle(0, c1, 24, 278, 127, 319);
- DWIN_Draw_Rectangle(0, c2, 145, 279, 246, 318);
- DWIN_Draw_Rectangle(0, c2, 144, 278, 247, 319);
- }
-
- void Popup_window_PauseOrStop(void) {
- Clear_Main_Window();
- Draw_Popup_Bkgd_60();
- if (HMI_flag.language_chinese) {
- if (select_print.now == 1) DWIN_Frame_AreaCopy(1, 237, 338, 269, 356, 98, 150);
- else if (select_print.now == 2) DWIN_Frame_AreaCopy(1, 221, 320, 253, 336, 98, 150);
- DWIN_Frame_AreaCopy(1, 220, 304, 264, 319, 130, 150);
- DWIN_ICON_Show(ICON, ICON_Confirm_C, 26, 280);
- DWIN_ICON_Show(ICON, ICON_Cancel_C, 146, 280);
- }
- else {
- if (select_print.now == 1) DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 88, 150, GET_TEXT_F(MSG_PAUSE_PRINT));
- else if (select_print.now == 2) DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 92, 150, GET_TEXT_F(MSG_STOP_PRINT));
- DWIN_ICON_Show(ICON, ICON_Confirm_E, 26, 280);
- DWIN_ICON_Show(ICON, ICON_Cancel_E, 146, 280);
- }
- Draw_Select_Highlight(true);
- }
-
- void Draw_Printing_Screen(void) {
- if (HMI_flag.language_chinese) {
- DWIN_Frame_AreaCopy(1, 30, 1, 71, 14, 14, 9); // Tune
- DWIN_Frame_AreaCopy(1, 0, 72, 63, 86, 41, 188); // Pause
- DWIN_Frame_AreaCopy(1, 65, 72, 128, 86, 176, 188); // Stop
- }
- else {
- DWIN_Frame_AreaCopy(1, 40, 2, 92, 14, 14, 9); // Tune
- DWIN_Frame_AreaCopy(1, 0, 44, 96, 58, 41, 188); // Pause
- DWIN_Frame_AreaCopy(1, 98, 44, 152, 58, 176, 188); // Stop
- }
- }
-
- void Draw_Print_ProgressBar() {
- DWIN_ICON_Show(ICON, ICON_Bar, 15, 93);
- DWIN_Draw_Rectangle(1, BarFill_Color, 16 + Percentrecord * 240 / 100, 93, 256, 113);
- DWIN_Draw_IntValue(true, true, 0, font8x16, Percent_Color, Background_black, 2, 117, 133, Percentrecord);
- DWIN_Draw_String(false, false, font8x16, Percent_Color, Background_black, 133, 133, F("%"));
- }
-
- void Draw_Print_ProgressElapsed() {
- duration_t elapsed = print_job_timer.duration(); // print timer
- DWIN_Draw_IntValue(true, true, 1, font8x16, White, Background_black, 2, 42, 212, elapsed.value / 3600);
- DWIN_Draw_String(false, false, font8x16, White, Background_black, 58, 212, F(":"));
- DWIN_Draw_IntValue(true, true, 1, font8x16, White, Background_black, 2, 66, 212, (elapsed.value % 3600) / 60);
- }
-
- void Draw_Print_ProgressRemain() {
- DWIN_Draw_IntValue(true, true, 1, font8x16, White, Background_black, 2, 176, 212, remain_time / 3600);
- DWIN_Draw_String(false, false, font8x16, White, Background_black, 192, 212, F(":"));
- DWIN_Draw_IntValue(true, true, 1, font8x16, White, Background_black, 2, 200, 212, (remain_time % 3600) / 60);
- }
-
- void Goto_PrintProcess(void) {
- checkkey = PrintProcess;
-
- Clear_Main_Window();
- Draw_Printing_Screen();
-
- ICON_Tune();
- if (printingIsPaused()) ICON_Continue(); else ICON_Pause();
- ICON_Stop();
-
- // Copy into filebuf string before entry
- char * const name = card.longest_filename();
- const int8_t npos = _MAX(0, DWIN_WIDTH - strlen(name) * MENU_CHR_W) / 2;
- DWIN_Draw_String(false, false, font8x16, White, Background_black, npos, 60, name);
-
- DWIN_ICON_Show(ICON, ICON_PrintTime, 17, 193);
- DWIN_ICON_Show(ICON, ICON_RemainTime, 150, 191);
-
- Draw_Print_ProgressBar();
- Draw_Print_ProgressElapsed();
- Draw_Print_ProgressRemain();
- }
-
- void Goto_MainMenu(void) {
- checkkey = MainMenu;
-
- Clear_Main_Window();
-
- if (HMI_flag.language_chinese) {
- DWIN_Frame_AreaCopy(1, 2, 2, 27, 14, 14, 9); // "Home"
- }
- else {
- #ifdef USE_STRING_HEADINGS
- Draw_Title(GET_TEXT_F(MSG_MAIN));
- #else
- DWIN_Frame_AreaCopy(1, 0, 2, 39, 12, 14, 9);
- #endif
- }
-
- DWIN_ICON_Show(ICON, ICON_LOGO, 71, 52);
-
- ICON_Print();
- ICON_Prepare();
- ICON_Control();
- TERN(HAS_ONESTEP_LEVELING, ICON_Leveling, ICON_StartInfo)(select_page.now == 3);
- }
-
- inline ENCODER_DiffState get_encoder_state() {
- const millis_t ms = millis();
- if (PENDING(ms, Encoder_ms)) return ENCODER_DIFF_NO;
- const ENCODER_DiffState state = Encoder_ReceiveAnalyze();
- if (state != ENCODER_DIFF_NO) Encoder_ms = ms + ENCODER_WAIT;
- return state;
- }
-
- void HMI_Move_X(void) {
- ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
- if (encoder_diffState != ENCODER_DIFF_NO) {
- if (encoder_diffState == ENCODER_DIFF_CW) {
- HMI_ValueStruct.Move_X_scale += EncoderRate.encoderMoveValue;
- }
- else if (encoder_diffState == ENCODER_DIFF_CCW) {
- HMI_ValueStruct.Move_X_scale -= EncoderRate.encoderMoveValue;
- }
- else if (encoder_diffState == ENCODER_DIFF_ENTER) {
- checkkey = AxisMove;
- EncoderRate.encoderRateEnabled = 0;
- DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scale);
- if (!planner.is_full()) {
- // Wait for planner moves to finish!
- planner.synchronize();
- planner.buffer_line(current_position, MMM_TO_MMS(HOMING_FEEDRATE_XY), active_extruder);
- }
- DWIN_UpdateLCD();
- return;
- }
- NOLESS(HMI_ValueStruct.Move_X_scale, (X_MIN_POS) * MINUNITMULT);
- NOMORE(HMI_ValueStruct.Move_X_scale, (X_MAX_POS) * MINUNITMULT);
- current_position[X_AXIS] = HMI_ValueStruct.Move_X_scale / 10;
- DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scale);
- DWIN_UpdateLCD();
- }
- }
-
- void HMI_Move_Y(void) {
- ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
- if (encoder_diffState != ENCODER_DIFF_NO) {
- if (encoder_diffState == ENCODER_DIFF_CW) {
- HMI_ValueStruct.Move_Y_scale += EncoderRate.encoderMoveValue;
- }
- else if (encoder_diffState == ENCODER_DIFF_CCW) {
- HMI_ValueStruct.Move_Y_scale -= EncoderRate.encoderMoveValue;
- }
- else if (encoder_diffState == ENCODER_DIFF_ENTER) {
- checkkey = AxisMove;
- EncoderRate.encoderRateEnabled = 0;
- DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scale);
- if (!planner.is_full()) {
- // Wait for planner moves to finish!
- planner.synchronize();
- planner.buffer_line(current_position, MMM_TO_MMS(HOMING_FEEDRATE_XY), active_extruder);
- }
- DWIN_UpdateLCD();
- return;
- }
- NOLESS(HMI_ValueStruct.Move_Y_scale, (Y_MIN_POS) * MINUNITMULT);
- NOMORE(HMI_ValueStruct.Move_Y_scale, (Y_MAX_POS) * MINUNITMULT);
- current_position[Y_AXIS] = HMI_ValueStruct.Move_Y_scale / 10;
- DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scale);
- DWIN_UpdateLCD();
- }
- }
-
- void HMI_Move_Z(void) {
- ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
- if (encoder_diffState != ENCODER_DIFF_NO) {
- if (encoder_diffState == ENCODER_DIFF_CW) {
- HMI_ValueStruct.Move_Z_scale += EncoderRate.encoderMoveValue;
- }
- else if (encoder_diffState == ENCODER_DIFF_CCW) {
- HMI_ValueStruct.Move_Z_scale -= EncoderRate.encoderMoveValue;
- }
- else if (encoder_diffState == ENCODER_DIFF_ENTER) {
- checkkey = AxisMove;
- EncoderRate.encoderRateEnabled = 0;
- DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scale);
- if (!planner.is_full()) {
- // Wait for planner moves to finish!
- planner.synchronize();
- planner.buffer_line(current_position, MMM_TO_MMS(HOMING_FEEDRATE_Z), active_extruder);
- }
- DWIN_UpdateLCD();
- return;
- }
- NOLESS(HMI_ValueStruct.Move_Z_scale, Z_MIN_POS * MINUNITMULT);
- NOMORE(HMI_ValueStruct.Move_Z_scale, Z_MAX_POS * MINUNITMULT);
- current_position[Z_AXIS] = HMI_ValueStruct.Move_Z_scale / 10;
- DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scale);
- DWIN_UpdateLCD();
- }
- }
-
- #if EXTRUDERS
-
- void HMI_Move_E(void) {
- ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
- if (encoder_diffState != ENCODER_DIFF_NO) {
- if (encoder_diffState == ENCODER_DIFF_CW) {
- HMI_ValueStruct.Move_E_scale += EncoderRate.encoderMoveValue;
- }
- else if (encoder_diffState == ENCODER_DIFF_CCW) {
- HMI_ValueStruct.Move_E_scale -= EncoderRate.encoderMoveValue;
- }
- else if (encoder_diffState == ENCODER_DIFF_ENTER) {
- checkkey = AxisMove;
- EncoderRate.encoderRateEnabled = 0;
- last_E_scale = HMI_ValueStruct.Move_E_scale;
- DWIN_Draw_Signed_Float(font8x16, Background_black, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale);
- if (!planner.is_full()) {
- planner.synchronize(); // Wait for planner moves to finish!
- planner.buffer_line(current_position, MMM_TO_MMS(FEEDRATE_E), active_extruder);
- }
- DWIN_UpdateLCD();
- return;
- }
- if ((HMI_ValueStruct.Move_E_scale - last_E_scale) > (EXTRUDE_MAXLENGTH) * MINUNITMULT)
- HMI_ValueStruct.Move_E_scale = last_E_scale + (EXTRUDE_MAXLENGTH) * MINUNITMULT;
- else if ((last_E_scale - HMI_ValueStruct.Move_E_scale) > (EXTRUDE_MAXLENGTH) * MINUNITMULT)
- HMI_ValueStruct.Move_E_scale = last_E_scale - (EXTRUDE_MAXLENGTH) * MINUNITMULT;
- current_position.e = HMI_ValueStruct.Move_E_scale / 10;
- DWIN_Draw_Signed_Float(font8x16, Select_Color, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale);
- DWIN_UpdateLCD();
- }
- }
-
- #endif
-
- void HMI_Zoffset(void) {
- ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
- if (encoder_diffState != ENCODER_DIFF_NO) {
- last_zoffset = dwin_zoffset;
- if (encoder_diffState == ENCODER_DIFF_CW) {
- HMI_ValueStruct.offset_value += EncoderRate.encoderMoveValue;
- }
- else if (encoder_diffState == ENCODER_DIFF_CCW) {
- HMI_ValueStruct.offset_value -= EncoderRate.encoderMoveValue;
- }
- else if (encoder_diffState == ENCODER_DIFF_ENTER) {
- EncoderRate.encoderRateEnabled = 0;
- dwin_zoffset = HMI_ValueStruct.offset_value / 100;
- #if HAS_BED_PROBE
- if (WITHIN(dwin_zoffset - last_zoffset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX))
- probe.offset.z = dwin_zoffset;
- TERN_(EEPROM_SETTINGS, settings.save());
- #elif ENABLED(BABYSTEPPING)
- babystep.add_mm(Z_AXIS, dwin_zoffset - last_zoffset);
- #endif
-
- if (HMI_ValueStruct.show_mode == -4) {
- checkkey = Prepare;
- DWIN_Draw_Signed_Float(font8x16, Background_black, 2, 2, 202, MBASE(4 + MROWS - index_prepare), TERN(HAS_BED_PROBE, probe.offset.z * 100, HMI_ValueStruct.offset_value));
- }
- else {
- checkkey = Tune;
- DWIN_Draw_Signed_Float(font8x16, Background_black, 2, 2, 202, MBASE(5 + MROWS - index_tune), TERN(HAS_BED_PROBE, probe.offset.z * 100, HMI_ValueStruct.offset_value));
- }
- DWIN_UpdateLCD();
- return;
- }
- NOLESS(HMI_ValueStruct.offset_value, (Z_PROBE_OFFSET_RANGE_MIN) * 100);
- NOMORE(HMI_ValueStruct.offset_value, (Z_PROBE_OFFSET_RANGE_MAX) * 100);
- if (HMI_ValueStruct.show_mode == -4)
- DWIN_Draw_Signed_Float(font8x16, Select_Color, 2, 2, 202, MBASE(4 + MROWS - index_prepare), HMI_ValueStruct.offset_value);
- else
- DWIN_Draw_Signed_Float(font8x16, Select_Color, 2, 2, 202, MBASE(5 + MROWS - index_tune), HMI_ValueStruct.offset_value);
- DWIN_UpdateLCD();
- }
- }
-
- #if HAS_HOTEND
-
- void HMI_ETemp(void) {
- ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
- if (encoder_diffState != ENCODER_DIFF_NO) {
- if (encoder_diffState == ENCODER_DIFF_CW) {
- HMI_ValueStruct.E_Temp += EncoderRate.encoderMoveValue;
- }
- else if (encoder_diffState == ENCODER_DIFF_CCW) {
- HMI_ValueStruct.E_Temp -= EncoderRate.encoderMoveValue;
- }
- else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return
- EncoderRate.encoderRateEnabled = 0;
- if (HMI_ValueStruct.show_mode == -1) { // temperature
- checkkey = TemperatureID;
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(1), HMI_ValueStruct.E_Temp);
- }
- else if (HMI_ValueStruct.show_mode == -2) {
- checkkey = PLAPreheat;
- ui.material_preset[0].hotend_temp = HMI_ValueStruct.E_Temp;
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(1), ui.material_preset[0].hotend_temp);
- return;
- }
- else if (HMI_ValueStruct.show_mode == -3) {
- checkkey = ABSPreheat;
- ui.material_preset[1].hotend_temp = HMI_ValueStruct.E_Temp;
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(1), ui.material_preset[1].hotend_temp);
- return;
- }
- else { // tune
- checkkey = Tune;
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(2 + MROWS - index_tune), HMI_ValueStruct.E_Temp);
- }
- thermalManager.setTargetHotend(HMI_ValueStruct.E_Temp, 0);
- return;
- }
- // E_Temp limit
- NOMORE(HMI_ValueStruct.E_Temp, MAX_E_TEMP);
- NOLESS(HMI_ValueStruct.E_Temp, MIN_E_TEMP);
- // E_Temp value
- if (HMI_ValueStruct.show_mode >= 0) // tune
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(2 + MROWS - index_tune), HMI_ValueStruct.E_Temp);
- else // other page
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(1), HMI_ValueStruct.E_Temp);
- }
- }
-
- #endif // HAS_HOTEND
-
- #if HAS_HEATED_BED
-
- void HMI_BedTemp(void) {
- ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
- if (encoder_diffState != ENCODER_DIFF_NO) {
- if (encoder_diffState == ENCODER_DIFF_CW) {
- HMI_ValueStruct.Bed_Temp += EncoderRate.encoderMoveValue;
- }
- else if (encoder_diffState == ENCODER_DIFF_CCW) {
- HMI_ValueStruct.Bed_Temp -= EncoderRate.encoderMoveValue;
- }
- else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return
- EncoderRate.encoderRateEnabled = 0;
- if (HMI_ValueStruct.show_mode == -1) {
- checkkey = TemperatureID;
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(2), HMI_ValueStruct.Bed_Temp);
- }
- else if (HMI_ValueStruct.show_mode == -2) {
- checkkey = PLAPreheat;
- ui.material_preset[0].bed_temp = HMI_ValueStruct.Bed_Temp;
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(2), ui.material_preset[0].bed_temp);
- return;
- }
- else if (HMI_ValueStruct.show_mode == -3) {
- checkkey = ABSPreheat;
- ui.material_preset[1].bed_temp = HMI_ValueStruct.Bed_Temp;
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(2), ui.material_preset[1].bed_temp);
- return;
- }
- else {
- checkkey = Tune;
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(3 + MROWS - index_tune), HMI_ValueStruct.Bed_Temp);
- }
- thermalManager.setTargetBed(HMI_ValueStruct.Bed_Temp);
- return;
- }
- // Bed_Temp limit
- NOMORE(HMI_ValueStruct.Bed_Temp, BED_MAX_TARGET);
- NOLESS(HMI_ValueStruct.Bed_Temp, MIN_BED_TEMP);
- // Bed_Temp value
- if (HMI_ValueStruct.show_mode >= 0) // tune page
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(3 + MROWS - index_tune), HMI_ValueStruct.Bed_Temp);
- else // other page
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(2), HMI_ValueStruct.Bed_Temp);
- }
- }
-
- #endif // HAS_HEATED_BED
-
- #if HAS_FAN
-
- void HMI_FanSpeed(void) {
- ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
- if (encoder_diffState != ENCODER_DIFF_NO) {
- if (encoder_diffState == ENCODER_DIFF_CW) {
- HMI_ValueStruct.Fan_speed += EncoderRate.encoderMoveValue;
- }
- else if (encoder_diffState == ENCODER_DIFF_CCW) {
- HMI_ValueStruct.Fan_speed -= EncoderRate.encoderMoveValue;
- }
- else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return
- EncoderRate.encoderRateEnabled = 0;
- if (HMI_ValueStruct.show_mode == -1) {
- checkkey = TemperatureID;
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(3), HMI_ValueStruct.Fan_speed);
- }
- else if (HMI_ValueStruct.show_mode == -2) {
- checkkey = PLAPreheat;
- ui.material_preset[0].fan_speed = HMI_ValueStruct.Fan_speed;
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(3), ui.material_preset[0].fan_speed);
- return;
- }
- else if (HMI_ValueStruct.show_mode == -3) {
- checkkey = ABSPreheat;
- ui.material_preset[1].fan_speed = HMI_ValueStruct.Fan_speed;
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(3), ui.material_preset[1].fan_speed);
- return;
- }
- else {
- checkkey = Tune;
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(4 + MROWS - index_tune), HMI_ValueStruct.Fan_speed);
- }
- thermalManager.set_fan_speed(0, HMI_ValueStruct.Fan_speed);
- return;
- }
- // Fan_speed limit
- NOMORE(HMI_ValueStruct.Fan_speed, FANON);
- NOLESS(HMI_ValueStruct.Fan_speed, FANOFF);
- // Fan_speed value
- if (HMI_ValueStruct.show_mode >= 0) // tune page
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(4 + MROWS - index_tune), HMI_ValueStruct.Fan_speed);
- else // other page
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(3), HMI_ValueStruct.Fan_speed);
- }
- }
-
- #endif // HAS_FAN
-
- void HMI_PrintSpeed(void) {
- ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
- if (encoder_diffState != ENCODER_DIFF_NO) {
- if (encoder_diffState == ENCODER_DIFF_CW) {
- HMI_ValueStruct.print_speed += EncoderRate.encoderMoveValue;
- }
- else if (encoder_diffState == ENCODER_DIFF_CCW) {
- HMI_ValueStruct.print_speed -= EncoderRate.encoderMoveValue;
- }
- else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return
- checkkey = Tune;
- EncoderRate.encoderRateEnabled = 0;
- feedrate_percentage = HMI_ValueStruct.print_speed;
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(1 + MROWS - index_tune), HMI_ValueStruct.print_speed);
- return;
- }
- // print_speed limit
- NOMORE(HMI_ValueStruct.print_speed, MAX_PRINT_SPEED);
- NOLESS(HMI_ValueStruct.print_speed, MIN_PRINT_SPEED);
- // print_speed value
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(1 + MROWS - index_tune), HMI_ValueStruct.print_speed);
- }
- }
-
- void HMI_MaxFeedspeedXYZE(void) {
- ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
- if (encoder_diffState != ENCODER_DIFF_NO) {
- if (encoder_diffState == ENCODER_DIFF_CW) {
- HMI_ValueStruct.Max_Feedspeed += EncoderRate.encoderMoveValue;
- }
- else if (encoder_diffState == ENCODER_DIFF_CCW) {
- HMI_ValueStruct.Max_Feedspeed -= EncoderRate.encoderMoveValue;
- }
- else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return
- checkkey = MaxSpeed;
- EncoderRate.encoderRateEnabled = 0;
- if (HMI_flag.feedspeed_flag == X_AXIS) planner.set_max_feedrate(X_AXIS, HMI_ValueStruct.Max_Feedspeed);
- else if (HMI_flag.feedspeed_flag == Y_AXIS) planner.set_max_feedrate(Y_AXIS, HMI_ValueStruct.Max_Feedspeed);
- else if (HMI_flag.feedspeed_flag == Z_AXIS) planner.set_max_feedrate(Z_AXIS, HMI_ValueStruct.Max_Feedspeed);
- #if HAS_HOTEND
- else if (HMI_flag.feedspeed_flag == E_AXIS) planner.set_max_feedrate(E_AXIS, HMI_ValueStruct.Max_Feedspeed);
- #endif
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 4, 210, MBASE(select_speed.now), HMI_ValueStruct.Max_Feedspeed);
- return;
- }
- // MaxFeedspeed limit
- if (HMI_flag.feedspeed_flag == X_AXIS) {if (HMI_ValueStruct.Max_Feedspeed > default_max_feedrate[X_AXIS] * 2) HMI_ValueStruct.Max_Feedspeed = default_max_feedrate[X_AXIS] * 2; }
- else if (HMI_flag.feedspeed_flag == Y_AXIS) {if (HMI_ValueStruct.Max_Feedspeed > default_max_feedrate[Y_AXIS] * 2) HMI_ValueStruct.Max_Feedspeed = default_max_feedrate[Y_AXIS] * 2; }
- else if (HMI_flag.feedspeed_flag == Z_AXIS) {if (HMI_ValueStruct.Max_Feedspeed > default_max_feedrate[Z_AXIS] * 2) HMI_ValueStruct.Max_Feedspeed = default_max_feedrate[Z_AXIS] * 2; }
- #if HAS_HOTEND
- else if (HMI_flag.feedspeed_flag == E_AXIS) {if (HMI_ValueStruct.Max_Feedspeed > default_max_feedrate[E_AXIS] * 2) HMI_ValueStruct.Max_Feedspeed = default_max_feedrate[E_AXIS] * 2; }
- #endif
- if (HMI_ValueStruct.Max_Feedspeed < MIN_MAXFEEDSPEED) HMI_ValueStruct.Max_Feedspeed = MIN_MAXFEEDSPEED;
- // MaxFeedspeed value
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 4, 210, MBASE(select_speed.now), HMI_ValueStruct.Max_Feedspeed);
- }
- }
-
- void HMI_MaxAccelerationXYZE(void) {
- ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
- if (encoder_diffState != ENCODER_DIFF_NO) {
- if (encoder_diffState == ENCODER_DIFF_CW) { HMI_ValueStruct.Max_Acceleration += EncoderRate.encoderMoveValue;}
- else if (encoder_diffState == ENCODER_DIFF_CCW) { HMI_ValueStruct.Max_Acceleration -= EncoderRate.encoderMoveValue;}
- else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return
- checkkey = MaxAcceleration;
- EncoderRate.encoderRateEnabled = 0;
- if (HMI_flag.acc_flag == X_AXIS) planner.set_max_acceleration(X_AXIS, HMI_ValueStruct.Max_Acceleration);
- else if (HMI_flag.acc_flag == Y_AXIS) planner.set_max_acceleration(Y_AXIS, HMI_ValueStruct.Max_Acceleration);
- else if (HMI_flag.acc_flag == Z_AXIS) planner.set_max_acceleration(Z_AXIS, HMI_ValueStruct.Max_Acceleration);
- #if HAS_HOTEND
- else if (HMI_flag.acc_flag == E_AXIS) planner.set_max_acceleration(E_AXIS, HMI_ValueStruct.Max_Acceleration);
- #endif
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 4, 210, MBASE(select_acc.now), HMI_ValueStruct.Max_Acceleration);
- return;
- }
- // MaxAcceleration limit
- if (HMI_flag.acc_flag == X_AXIS) {if (HMI_ValueStruct.Max_Acceleration > default_max_acceleration[X_AXIS] * 2) HMI_ValueStruct.Max_Acceleration = default_max_acceleration[X_AXIS] * 2; }
- else if (HMI_flag.acc_flag == Y_AXIS) {if (HMI_ValueStruct.Max_Acceleration > default_max_acceleration[Y_AXIS] * 2) HMI_ValueStruct.Max_Acceleration = default_max_acceleration[Y_AXIS] * 2; }
- else if (HMI_flag.acc_flag == Z_AXIS) {if (HMI_ValueStruct.Max_Acceleration > default_max_acceleration[Z_AXIS] * 2) HMI_ValueStruct.Max_Acceleration = default_max_acceleration[Z_AXIS] * 2; }
- #if HAS_HOTEND
- else if (HMI_flag.acc_flag == E_AXIS) {if (HMI_ValueStruct.Max_Acceleration > default_max_acceleration[E_AXIS] * 2) HMI_ValueStruct.Max_Acceleration = default_max_acceleration[E_AXIS] * 2; }
- #endif
- if (HMI_ValueStruct.Max_Acceleration < MIN_MAXACCELERATION) HMI_ValueStruct.Max_Acceleration = MIN_MAXACCELERATION;
- // MaxAcceleration value
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 4, 210, MBASE(select_acc.now), HMI_ValueStruct.Max_Acceleration);
- }
- }
-
- void HMI_MaxJerkXYZE(void) {
- ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
- if (encoder_diffState != ENCODER_DIFF_NO) {
- if (encoder_diffState == ENCODER_DIFF_CW) {
- HMI_ValueStruct.Max_Jerk += EncoderRate.encoderMoveValue;
- }
- else if (encoder_diffState == ENCODER_DIFF_CCW) {
- HMI_ValueStruct.Max_Jerk -= EncoderRate.encoderMoveValue;
- }
- else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return
- checkkey = MaxJerk;
- EncoderRate.encoderRateEnabled = 0;
- if (HMI_flag.jerk_flag == X_AXIS) planner.set_max_jerk(X_AXIS, HMI_ValueStruct.Max_Jerk / 10);
- else if (HMI_flag.jerk_flag == Y_AXIS) planner.set_max_jerk(Y_AXIS, HMI_ValueStruct.Max_Jerk / 10);
- else if (HMI_flag.jerk_flag == Z_AXIS) planner.set_max_jerk(Z_AXIS, HMI_ValueStruct.Max_Jerk / 10);
- else if (HMI_flag.jerk_flag == E_AXIS) planner.set_max_jerk(E_AXIS, HMI_ValueStruct.Max_Jerk / 10);
- DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk);
- return;
- }
- // MaxJerk limit
- if (HMI_flag.jerk_flag == X_AXIS)
- NOMORE(HMI_ValueStruct.Max_Jerk, default_max_jerk[X_AXIS] * 2 * MINUNITMULT);
- else if (HMI_flag.jerk_flag == Y_AXIS)
- NOMORE(HMI_ValueStruct.Max_Jerk, default_max_jerk[Y_AXIS] * 2 * MINUNITMULT);
- else if (HMI_flag.jerk_flag == Z_AXIS)
- NOMORE(HMI_ValueStruct.Max_Jerk, default_max_jerk[Z_AXIS] * 2 * MINUNITMULT);
- else if (HMI_flag.jerk_flag == E_AXIS)
- NOMORE(HMI_ValueStruct.Max_Jerk, default_max_jerk[E_AXIS] * 2 * MINUNITMULT);
- NOLESS(HMI_ValueStruct.Max_Jerk, (MIN_MAXCORNER) * MINUNITMULT);
- // MaxJerk value
- DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk);
- }
- }
-
- void HMI_StepXYZE(void) {
- ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
- if (encoder_diffState != ENCODER_DIFF_NO) {
- if (encoder_diffState == ENCODER_DIFF_CW) {
- HMI_ValueStruct.Max_Step += EncoderRate.encoderMoveValue;
- }
- else if (encoder_diffState == ENCODER_DIFF_CCW) {
- HMI_ValueStruct.Max_Step -= EncoderRate.encoderMoveValue;
- }
- else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return
- checkkey = Step;
- EncoderRate.encoderRateEnabled = 0;
- if (HMI_flag.step_flag == X_AXIS) planner.settings.axis_steps_per_mm[X_AXIS] = HMI_ValueStruct.Max_Step / 10;
- else if (HMI_flag.step_flag == Y_AXIS) planner.settings.axis_steps_per_mm[Y_AXIS] = HMI_ValueStruct.Max_Step / 10;
- else if (HMI_flag.step_flag == Z_AXIS) planner.settings.axis_steps_per_mm[Z_AXIS] = HMI_ValueStruct.Max_Step / 10;
- else if (HMI_flag.step_flag == E_AXIS) planner.settings.axis_steps_per_mm[E_AXIS] = HMI_ValueStruct.Max_Step / 10;
- DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step);
- return;
- }
- // Step limit
- if (HMI_flag.step_flag == X_AXIS)
- NOMORE(HMI_ValueStruct.Max_Step, default_axis_steps_per_unit[X_AXIS] * 2 * MINUNITMULT);
- else if (HMI_flag.step_flag == Y_AXIS)
- NOMORE(HMI_ValueStruct.Max_Step, default_axis_steps_per_unit[Y_AXIS] * 2 * MINUNITMULT);
- else if (HMI_flag.step_flag == Z_AXIS)
- NOMORE(HMI_ValueStruct.Max_Step, default_axis_steps_per_unit[Z_AXIS] * 2 * MINUNITMULT);
- else if (HMI_flag.step_flag == E_AXIS)
- NOMORE(HMI_ValueStruct.Max_Step, default_axis_steps_per_unit[E_AXIS] * 2 * MINUNITMULT);
- NOLESS(HMI_ValueStruct.Max_Step, MIN_STEP);
- // Step value
- DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step);
- }
- }
-
- void update_variable(void) {
- /* Tune page temperature update */
- if (checkkey == Tune) {
- if (last_temp_hotend_target != thermalManager.temp_hotend[0].target)
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(2 + MROWS - index_tune), thermalManager.temp_hotend[0].target);
- if (last_temp_bed_target != thermalManager.temp_bed.target)
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(3 + MROWS - index_tune), thermalManager.temp_bed.target);
- if (last_fan_speed != thermalManager.fan_speed[0]) {
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(4 + MROWS - index_tune), thermalManager.fan_speed[0]);
- last_fan_speed = thermalManager.fan_speed[0];
- }
- }
-
- /* Temperature page temperature update */
- if (checkkey == TemperatureID) {
- if (last_temp_hotend_target != thermalManager.temp_hotend[0].target)
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(1), thermalManager.temp_hotend[0].target);
- if (last_temp_bed_target != thermalManager.temp_bed.target)
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(2), thermalManager.temp_bed.target);
- if (last_fan_speed != thermalManager.fan_speed[0]) {
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(3), thermalManager.fan_speed[0]);
- last_fan_speed = thermalManager.fan_speed[0];
- }
- }
-
- /* Bottom temperature update */
- if (last_temp_hotend_current != thermalManager.temp_hotend[0].celsius) {
- DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 33, 382, thermalManager.temp_hotend[0].celsius);
- last_temp_hotend_current = thermalManager.temp_hotend[0].celsius;
- }
- if (last_temp_hotend_target != thermalManager.temp_hotend[0].target) {
- DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 33 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_hotend[0].target);
- last_temp_hotend_target = thermalManager.temp_hotend[0].target;
- }
- if (last_temp_bed_current != thermalManager.temp_bed.celsius) {
- DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 178, 382, thermalManager.temp_bed.celsius);
- last_temp_bed_current = thermalManager.temp_bed.celsius;
- }
- if (last_temp_bed_target != thermalManager.temp_bed.target) {
- DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 178 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_bed.target);
- last_temp_bed_target = thermalManager.temp_bed.target;
- }
- if (last_speed != feedrate_percentage) {
- DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 33 + 2 * STAT_CHR_W, 429, feedrate_percentage);
- last_speed = feedrate_percentage;
- }
- if (last_zoffset != BABY_Z_VAR) {
- DWIN_Draw_Signed_Float(STAT_FONT, Background_black, 2, 2, 178 + STAT_CHR_W, 429, BABY_Z_VAR * 100);
- last_zoffset = BABY_Z_VAR;
- }
- }
-
- /**
- * Read and cache the working directory.
- *
- * TODO: New code can follow the pattern of menu_media.cpp
- * and rely on Marlin caching for performance. No need to
- * cache files here.
- *
- */
-
- #ifndef strcasecmp_P
- #define strcasecmp_P(a, b) strcasecmp((a), (b))
- #endif
-
- inline void make_name_without_ext(char *dst, char *src, size_t maxlen=MENU_CHAR_LIMIT) {
- char * const name = card.longest_filename();
- size_t pos = strlen(name); // index of ending nul
-
- // For files, remove the extension
- // which may be .gcode, .gco, or .g
- if (!card.flag.filenameIsDir)
- while (pos && src[pos] != '.') pos--; // find last '.' (stop at 0)
-
- size_t len = pos; // nul or '.'
- if (len > maxlen) { // Keep the name short
- pos = len = maxlen; // move nul down
- dst[--pos] = '.'; // insert dots
- dst[--pos] = '.';
- dst[--pos] = '.';
- }
-
- dst[len] = '\0'; // end it
-
- // Copy down to 0
- while (pos--) dst[pos] = src[pos];
- }
-
- inline void HMI_SDCardInit(void) { card.cdroot(); }
-
- void MarlinUI::refresh() {
- // The card was mounted or unmounted
- // or some other status change occurred
- // DWIN_lcd_sd_status = false; // On next DWIN_Update
- // HMI_SDCardUpdate();
- }
-
- #define ICON_Folder ICON_More
-
- char shift_name[LONG_FILENAME_LENGTH + 1];
- int8_t shift_amt; // = 0
- millis_t shift_ms; // = 0
-
- // Init the shift name based on the highlighted item
- inline void Init_Shift_Name() {
- const bool is_subdir = !card.flag.workDirIsRoot;
- const int8_t filenum = select_file.now - 1 - is_subdir; // Skip "Back" and ".."
- const uint16_t fileCnt = card.get_num_Files();
- if (WITHIN(filenum, 0, fileCnt - 1)) {
- card.getfilename_sorted(SD_ORDER(filenum, fileCnt));
- char * const name = card.longest_filename();
- make_name_without_ext(shift_name, name, 100);
- }
- }
-
- inline void Init_SDItem_Shift() {
- shift_amt = 0;
- shift_ms = select_file.now > 0 && strlen(shift_name) > MENU_CHAR_LIMIT
- ? millis() + 750UL : 0;
- }
-
- /**
- * Display an SD item, adding a CDUP for subfolders.
- */
- inline void Draw_SDItem(const uint16_t item, int16_t row=-1) {
- if (row < 0) row = item + 1 + MROWS - index_file;
- const bool is_subdir = !card.flag.workDirIsRoot;
- if (is_subdir && item == 0) {
- Draw_Menu_Line(row, ICON_Folder, "..");
- return;
- }
-
- card.getfilename_sorted(item - is_subdir);
- char * const name = card.longest_filename();
-
- // Init the current selected name
- // This is used during scroll drawing
- if (item == select_file.now - 1) {
- make_name_without_ext(shift_name, name, 100);
- Init_SDItem_Shift();
- }
-
- char str[strlen(name) + 1];
-
- make_name_without_ext(str, name);
-
- Draw_Menu_Line(row, card.flag.filenameIsDir ? ICON_Folder : ICON_File, str);
- }
-
- inline void Draw_SDItem_Shifted(int8_t &shift) {
- // Limit to the number of chars past the cutoff
- const size_t len = strlen(shift_name);
- NOMORE(shift, _MAX((signed)len - MENU_CHAR_LIMIT, 0));
-
- // Shorten to the available space
- const size_t lastchar = _MIN((signed)len, shift + MENU_CHAR_LIMIT);
-
- const char c = shift_name[lastchar];
- shift_name[lastchar] = '\0';
-
- const uint8_t row = select_file.now + MROWS - index_file; // skip "Back" and scroll
- Erase_Menu_Text(row);
- Draw_Menu_Line(row, 0, &shift_name[shift]);
-
- shift_name[lastchar] = c;
- }
-
- // Redraw the first set of SD Files
- inline void Redraw_SD_List() {
- select_file.reset();
- index_file = MROWS;
-
- Clear_Menu_Area(); // Leave title bar unchanged
-
- Draw_Back_First();
-
- // As many files as will fit
- LOOP_L_N(i, _MIN(nr_sd_menu_items(), MROWS))
- Draw_SDItem(i, i + 1);
-
- Init_SDItem_Shift();
- }
-
- inline void SDCard_Up(void) {
- card.cdup();
- Redraw_SD_List();
- DWIN_lcd_sd_status = false; // On next DWIN_Update
- }
-
- inline void SDCard_Folder(char * const dirname) {
- card.cd(dirname);
- Redraw_SD_List();
- DWIN_lcd_sd_status = false; // On next DWIN_Update
- }
-
- //
- // Watch for media mount / unmount
- //
- void HMI_SDCardUpdate(void) {
- if (HMI_flag.home_flag) return;
- if (DWIN_lcd_sd_status != card.isMounted()) {
- DWIN_lcd_sd_status = card.isMounted();
- // SERIAL_ECHOLNPAIR("HMI_SDCardUpdate: ", int(DWIN_lcd_sd_status));
- if (card.isMounted()) {
- if (checkkey == SelectFile)
- Redraw_SD_List();
- }
- else {
- // clean file icon
- if (checkkey == SelectFile) {
- Redraw_SD_List();
- }
- else if (checkkey == PrintProcess || checkkey == Tune || printingIsActive()) {
- // TODO: Move card removed abort handling
- // to CardReader::manage_media.
- card.flag.abort_sd_printing = true;
- wait_for_heatup = false;
- abort_flag = true;
- }
- }
- DWIN_UpdateLCD();
- }
- }
-
- /* Start */
- void HMI_StartFrame(const bool with_update) {
- Goto_MainMenu();
-
- DWIN_Draw_Rectangle(1, Background_black, 0, 360, DWIN_WIDTH, DWIN_HEIGHT - 1);
-
- DWIN_ICON_Show(ICON, ICON_HotendTemp, 13, 381);
- #if HOTENDS > 1
- // DWIN_ICON_Show(ICON,ICON_HotendTemp, 13, 381);
- #endif
- DWIN_ICON_Show(ICON, ICON_BedTemp, 158, 381);
- DWIN_ICON_Show(ICON, ICON_Speed, 13, 429);
- DWIN_ICON_Show(ICON, ICON_Zoffset, 158, 428);
-
- // Draw initial Status Area
- DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 33, 382, thermalManager.temp_hotend[0].celsius);
- DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 33 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_hotend[0].target);
- DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 178, 382, thermalManager.temp_bed.celsius);
- DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 178 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_bed.target);
-
- DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 33 + 2 * STAT_CHR_W, 429, feedrate_percentage);
- DWIN_Draw_String(false, false, STAT_FONT, White, Background_black, 33 + 5 * STAT_CHR_W + 2, 429, F("%"));
-
- DWIN_Draw_Signed_Float(STAT_FONT, Background_black, 2, 2, 178, 429, BABY_Z_VAR * 100);
- DWIN_Draw_String(false, false, STAT_FONT, White, Background_black, 33 + 3 * STAT_CHR_W + 5, 383, F("/"));
- DWIN_Draw_String(false, false, STAT_FONT, White, Background_black, 178 + 3 * STAT_CHR_W + 5, 383, F("/"));
-
- if (with_update) {
- DWIN_UpdateLCD();
- delay(5);
- }
- }
-
- inline void Draw_Info_Menu() {
- Clear_Main_Window();
-
- DWIN_Draw_String(false, false, font8x16, White, Background_black, (DWIN_WIDTH - strlen(MACHINE_SIZE) * MENU_CHR_W) / 2, 122, (char*)MACHINE_SIZE);
- DWIN_Draw_String(false, false, font8x16, White, Background_black, (DWIN_WIDTH - strlen(SHORT_BUILD_VERSION) * MENU_CHR_W) / 2, 195, (char*)SHORT_BUILD_VERSION);
-
- if (HMI_flag.language_chinese) {
- DWIN_Frame_AreaCopy(1, 30, 17, 57, 29, 14, 8);
-
- DWIN_Frame_AreaCopy(1, 197, 149, 252, 161, 108, 102);
- DWIN_Frame_AreaCopy(1, 1, 164, 56, 176, 108, 175);
- DWIN_Frame_AreaCopy(1, 58, 164, 113, 176, 105, 248);
- DWIN_Draw_String(false, false, font8x16, White, Background_black, (DWIN_WIDTH - strlen(CORP_WEBSITE_C) * MENU_CHR_W) / 2, 268, (char*)CORP_WEBSITE_C);
- }
- else {
- #ifdef USE_STRING_HEADINGS
- Draw_Title(GET_TEXT_F(MSG_INFO_SCREEN));
- #else
- DWIN_Frame_AreaCopy(1, 190, 16, 215, 26, 14, 8);
- #endif
-
- DWIN_Frame_AreaCopy(1, 120, 150, 146, 161, 124, 102);
- DWIN_Frame_AreaCopy(1, 146, 151, 254, 161, 82, 175);
- DWIN_Frame_AreaCopy(1, 0, 165, 94, 175, 89, 248);
- DWIN_Draw_String(false, false, font8x16, White, Background_black, (DWIN_WIDTH - strlen(CORP_WEBSITE_E) * MENU_CHR_W) / 2, 268, (char*)CORP_WEBSITE_E);
- }
-
- Draw_Back_First();
- LOOP_L_N(i, 3) {
- DWIN_ICON_Show(ICON, ICON_PrintSize + i, 26, 99 + i * 73);
- DWIN_Draw_Line(Line_Color, 16, MBASE(2) + i * 73, 256, 156 + i * 73);
- }
- }
-
- inline void Draw_Print_File_Menu() {
- Clear_Title_Bar();
-
- if (HMI_flag.language_chinese) {
- DWIN_Frame_AreaCopy(1, 0, 31, 55, 44, 14, 8);
- }
- else {
- #ifdef USE_STRING_HEADINGS
- Draw_Title("Print file"); // TODO: GET_TEXT_F
- #else
- DWIN_Frame_AreaCopy(1, 52, 31, 137, 41, 14, 8); // "Print file"
- #endif
- }
-
- Redraw_SD_List();
- }
-
- /* Main Process */
- void HMI_MainMenu(void) {
- ENCODER_DiffState encoder_diffState = get_encoder_state();
- if (encoder_diffState == ENCODER_DIFF_NO) return;
-
- if (encoder_diffState == ENCODER_DIFF_CW) {
- if (select_page.inc(3)) {
- switch (select_page.now) {
- case 0: ICON_Print(); break;
- case 1: ICON_Print(); ICON_Prepare(); break;
- case 2: ICON_Prepare(); ICON_Control(); break;
- case 3: ICON_Control(); TERN(HAS_ONESTEP_LEVELING, ICON_Leveling, ICON_StartInfo)(1); break;
- }
- }
- }
- else if (encoder_diffState == ENCODER_DIFF_CCW) {
- if (select_page.dec()) {
- switch (select_page.now) {
- case 0: ICON_Print(); ICON_Prepare(); break;
- case 1: ICON_Prepare(); ICON_Control(); break;
- case 2: ICON_Control(); TERN(HAS_ONESTEP_LEVELING, ICON_Leveling, ICON_StartInfo)(0); break;
- case 3: TERN(HAS_ONESTEP_LEVELING, ICON_Leveling, ICON_StartInfo)(1); break;
- }
- }
- }
- else if (encoder_diffState == ENCODER_DIFF_ENTER) {
- switch (select_page.now) {
- /* Print File */
- case 0:
- checkkey = SelectFile;
- Draw_Print_File_Menu();
- break;
-
- /* Prepare */
- case 1:
- checkkey = Prepare;
- select_prepare.reset();
- index_prepare = MROWS;
- Draw_Prepare_Menu();
- break;
-
- /* Control */
- case 2:
- checkkey = Control;
- select_control.reset();
- index_control = MROWS;
- Draw_Control_Menu();
- break;
-
- /* Leveling */
- case 3:
- #if HAS_ONESTEP_LEVELING
- checkkey = Leveling;
- HMI_Leveling();
- #else
- checkkey = Info;
- Draw_Info_Menu();
- #endif
- break;
- }
- }
- DWIN_UpdateLCD();
- }
-
- /* Select (and Print) File */
- void HMI_SelectFile(void) {
- ENCODER_DiffState encoder_diffState = get_encoder_state();
-
- const uint16_t hasUpDir = !card.flag.workDirIsRoot;
-
- if (encoder_diffState == ENCODER_DIFF_NO) {
- if (shift_ms && select_file.now >= 1 + hasUpDir) {
- // Scroll selected filename every second
- const millis_t ms = millis();
- if (ELAPSED(ms, shift_ms)) {
- const bool was_reset = shift_amt < 0;
- shift_ms = ms + 375UL + was_reset * 250UL; // ms per character
- int8_t shift_new = shift_amt + 1; // Try to shift by...
- Draw_SDItem_Shifted(shift_new); // Draw the item
- if (!was_reset && shift_new == 0) // Was it limited to 0?
- shift_ms = 0; // No scrolling needed
- else if (shift_new == shift_amt) // Scroll reached the end
- shift_new = -1; // Reset
- shift_amt = shift_new; // Set new scroll
- }
- }
- return;
- }
-
- // First pause is long. Easy.
- // On reset, long pause must be after 0.
-
- const uint16_t fullCnt = nr_sd_menu_items();
-
- if (encoder_diffState == ENCODER_DIFF_CW && fullCnt) {
- if (select_file.inc(fullCnt)) {
- const uint8_t itemnum = select_file.now - 1; // -1 for "Back"
- if (shift_ms) { // If line was shifted
- Erase_Menu_Text(select_file.now - 1 + MROWS - index_file); // Erase and
- Draw_SDItem(itemnum - 1); // redraw
- }
- if (select_file.now > MROWS && select_file.now > index_file) { // Cursor past the bottom
- index_file = select_file.now; // New bottom line
- Scroll_Menu(DWIN_SCROLL_UP);
- Draw_SDItem(itemnum, MROWS); // Draw and init the shift name
- }
- else {
- Move_Highlight(1, select_file.now + MROWS - index_file); // Just move highlight
- Init_Shift_Name(); // ...and init the shift name
- }
- Init_SDItem_Shift();
- }
- }
- else if (encoder_diffState == ENCODER_DIFF_CCW && fullCnt) {
- if (select_file.dec()) {
- const uint8_t itemnum = select_file.now - 1; // -1 for "Back"
- if (shift_ms) { // If line was shifted
- Erase_Menu_Text(select_file.now + 1 + MROWS - index_file); // Erase and
- Draw_SDItem(itemnum + 1); // redraw
- }
- if (select_file.now < index_file - MROWS) { // Cursor past the top
- index_file--; // New bottom line
- Scroll_Menu(DWIN_SCROLL_DOWN);
- if (index_file == MROWS) {
- Draw_Back_First();
- shift_ms = 0;
- }
- else {
- Draw_SDItem(itemnum, 0); // Draw the item (and init shift name)
- }
- }
- else {
- Move_Highlight(-1, select_file.now + MROWS - index_file); // Just move highlight
- Init_Shift_Name(); // ...and init the shift name
- }
- Init_SDItem_Shift(); // Reset left. Init timer.
- }
- }
- else if (encoder_diffState == ENCODER_DIFF_ENTER) {
- if (select_file.now == 0) {
- /* back */
- select_page.set(0);
- Goto_MainMenu();
- }
- else if (hasUpDir && select_file.now == 1) {
- /* CDUP */
- SDCard_Up();
- goto HMI_SelectFileExit;
- }
- else {
- const uint16_t filenum = select_file.now - 1 - hasUpDir;
- card.getfilename_sorted(SD_ORDER(filenum, card.get_num_Files()));
-
- // Enter that folder!
- if (card.flag.filenameIsDir) {
- SDCard_Folder(card.filename);
- goto HMI_SelectFileExit;
- }
-
- // Reset highlight for next entry
- select_print.reset();
- select_file.reset();
-
- // Start choice and print SD file
- HMI_flag.heat_flag = 1;
- HMI_flag.print_finish = 0;
- HMI_ValueStruct.show_mode = 0;
-
- card.openAndPrintFile(card.filename);
-
- #if FAN_COUNT > 0
- // All fans on for Ender 3 v2 ?
- // The slicer should manage this for us.
- // for (uint8_t i = 0; i < FAN_COUNT; i++)
- // thermalManager.fan_speed[i] = FANON;
- #endif
-
- Goto_PrintProcess();
- }
- }
- HMI_SelectFileExit:
- DWIN_UpdateLCD();
- }
-
- /* Printing */
- void HMI_Printing(void) {
- ENCODER_DiffState encoder_diffState = get_encoder_state();
- if (encoder_diffState == ENCODER_DIFF_NO) return;
-
- if (HMI_flag.confirm_flag) {
- if (encoder_diffState == ENCODER_DIFF_ENTER) {
- HMI_flag.confirm_flag = 0;
- abort_flag = 1;
- }
- return;
- }
-
- // Avoid flicker by updating only the previous menu
- if (encoder_diffState == ENCODER_DIFF_CW) {
- if (select_print.inc(2)) {
- switch (select_print.now) {
- case 0: ICON_Tune(); break;
- case 1:
- ICON_Tune();
- if (printingIsPaused()) ICON_Continue(); else ICON_Pause();
- break;
- case 2:
- if (printingIsPaused()) ICON_Continue(); else ICON_Pause();
- ICON_Stop();
- break;
- }
- }
- }
- else if (encoder_diffState == ENCODER_DIFF_CCW) {
- if (select_print.dec()) {
- switch (select_print.now) {
- case 0:
- ICON_Tune();
- if (printingIsPaused()) ICON_Continue(); else ICON_Pause();
- break;
- case 1:
- if (printingIsPaused()) ICON_Continue(); else ICON_Pause();
- ICON_Stop();
- break;
- case 2: ICON_Stop(); break;
- }
- }
- }
- else if (encoder_diffState == ENCODER_DIFF_ENTER) {
- switch (select_print.now) {
- case 0: // setting
- checkkey = Tune;
- HMI_ValueStruct.show_mode = 0;
- select_tune.reset();
- index_tune = 5;
- Draw_Tune_Menu();
- break;
- case 1: // pause
- /* pause */
- if (HMI_flag.pause_flag) {
- ICON_Pause();
-
- char cmd[40];
- cmd[0] = '\0';
-
- #if ENABLED(PAUSE_HEAT)
- if (tempbed) sprintf_P(cmd, PSTR("M190 S%i\n"), tempbed);
- if (temphot) sprintf_P(&cmd[strlen(cmd)], PSTR("M109 S%i\n"), temphot);
- #endif
-
- strcat_P(cmd, PSTR("M24"));
- queue.inject(cmd);
- }
- else {
- HMI_flag.select_flag = 1;
- checkkey = Print_window;
- Popup_window_PauseOrStop();
- }
- break;
-
- case 2: // stop
- /* stop */
- HMI_flag.select_flag = 1;
- checkkey = Print_window;
- Popup_window_PauseOrStop();
- break;
-
- default: break;
- }
- }
- DWIN_UpdateLCD();
- }
-
- /* pause and stop window */
- void HMI_PauseOrStop(void) {
- ENCODER_DiffState encoder_diffState = get_encoder_state();
- if (encoder_diffState == ENCODER_DIFF_NO) return;
-
- if (encoder_diffState == ENCODER_DIFF_CW) {
- Draw_Select_Highlight(false);
- }
- else if (encoder_diffState == ENCODER_DIFF_CCW) {
- Draw_Select_Highlight(true);
- }
- else if (encoder_diffState == ENCODER_DIFF_ENTER) {
- if (select_print.now == 1) { // pause window
- if (HMI_flag.select_flag) {
- pause_action_flag = 1;
- ICON_Continue();
- #if ENABLED(POWER_LOSS_RECOVERY)
- if (recovery.enabled) recovery.save(true);
- #endif
- queue.inject_P(PSTR("M25"));
- }
- else {
- // cancel pause
- }
- Goto_PrintProcess();
- }
- else if (select_print.now == 2) { // stop window
- if (HMI_flag.select_flag) {
- wait_for_heatup = false; // Stop waiting for heater
-
- #if 0
- // TODO: In ExtUI or MarlinUI add a common stop event
- // card.flag.abort_sd_printing = true;
- #else
- checkkey = Back_Main;
- // Wait for planner moves to finish!
- if (HMI_flag.home_flag) planner.synchronize();
- card.endFilePrint();
- #ifdef ACTION_ON_CANCEL
- host_action_cancel();
- #endif
- #ifdef EVENT_GCODE_SD_ABORT
- Popup_Window_Home();
- queue.inject_P(PSTR(EVENT_GCODE_SD_ABORT));
- #endif
- abort_flag = true;
- #endif
- }
- else {
- Goto_PrintProcess(); // cancel stop
- }
- }
- }
- DWIN_UpdateLCD();
- }
-
- inline void Draw_Move_Menu() {
- Clear_Main_Window();
-
- if (HMI_flag.language_chinese) {
- DWIN_Frame_AreaCopy(1, 192, 1, 233, 14, 14, 8);
- DWIN_Frame_AreaCopy(1, 58, 118, 106, 132, LBLX, MBASE(1));
- DWIN_Frame_AreaCopy(1, 109, 118, 157, 132, LBLX, MBASE(2));
- DWIN_Frame_AreaCopy(1, 160, 118, 209, 132, LBLX, MBASE(3));
- #if HAS_HOTEND
- DWIN_Frame_AreaCopy(1, 212, 118, 253, 131, LBLX, MBASE(4));
- #endif
- }
- else {
- #ifdef USE_STRING_HEADINGS
- Draw_Title(GET_TEXT_F(MSG_MOVE_AXIS));
- #else
- DWIN_Frame_AreaCopy(1, 231, 2, 265, 12, 14, 8);
- #endif
- draw_move_en(MBASE(1)); say_x(36, MBASE(1)); // "Move X"
- draw_move_en(MBASE(2)); say_y(36, MBASE(2)); // "Move Y"
- draw_move_en(MBASE(3)); say_z(36, MBASE(3)); // "Move Z"
- #if HAS_HOTEND
- DWIN_Frame_AreaCopy(1, 123, 192, 176, 202, LBLX, MBASE(4)); // "Extruder"
- #endif
- }
-
- Draw_Back_First(select_axis.now == 0);
- if (select_axis.now) Draw_Menu_Cursor(select_axis.now);
-
- LOOP_L_N(i, MROWS) Draw_Menu_Line(i + 1, ICON_MoveX + i);
- }
-
- #include "../../../libs/buzzer.h"
-
- void HMI_AudioFeedback(const bool success=true) {
- if (success) {
- buzzer.tone(100, 659);
- buzzer.tone(10, 0);
- buzzer.tone(100, 698);
- }
- else
- buzzer.tone(40, 440);
- }
-
- /* Prepare */
- void HMI_Prepare(void) {
- ENCODER_DiffState encoder_diffState = get_encoder_state();
- if (encoder_diffState == ENCODER_DIFF_NO) return;
-
- // Avoid flicker by updating only the previous menu
- if (encoder_diffState == ENCODER_DIFF_CW) {
- if (select_prepare.inc(8)) {
- if (select_prepare.now > MROWS && select_prepare.now > index_prepare) {
- index_prepare = select_prepare.now;
-
- // Scroll up and draw a blank bottom line
- Scroll_Menu(DWIN_SCROLL_UP);
- Draw_Menu_Icon(MROWS, ICON_Axis + select_prepare.now - 1);
-
- // Draw "More" icon for sub-menus
- if (index_prepare < 7) Draw_More_Icon(MROWS - index_prepare + 1);
-
- if (index_prepare == 6) Prepare_Item_ABS(MROWS);
- else if (index_prepare == 7) Prepare_Item_Cool(MROWS);
- else if (index_prepare == 8) Prepare_Item_Lang(MROWS);
- }
- else {
- Move_Highlight(1, select_prepare.now + MROWS - index_prepare);
- }
- }
- }
- else if (encoder_diffState == ENCODER_DIFF_CCW) {
- if (select_prepare.dec()) {
- if (select_prepare.now < index_prepare - MROWS) {
- index_prepare--;
- Scroll_Menu(DWIN_SCROLL_DOWN);
-
- if (index_prepare == MROWS)
- Draw_Back_First();
- else
- Draw_Menu_Line(0, ICON_Axis + select_prepare.now - 1);
-
- if (index_prepare < 7) Draw_More_Icon(MROWS - index_prepare + 1);
-
- if (index_prepare == 6) Prepare_Item_Move(0);
- else if (index_prepare == 7) Prepare_Item_Disable(0);
- else if (index_prepare == 8) Prepare_Item_Home(0);
- }
- else {
- Move_Highlight(-1, select_prepare.now + MROWS - index_prepare);
- }
- }
- }
- else if (encoder_diffState == ENCODER_DIFF_ENTER) {
- switch (select_prepare.now) {
- case 0: // back
- select_page.set(1);
- Goto_MainMenu();
- break;
- case 1: // axis move
- checkkey = AxisMove;
- select_axis.reset();
- Draw_Move_Menu();
-
- queue.inject_P(PSTR("G92 E0"));
- current_position.e = HMI_ValueStruct.Move_E_scale = 0;
- DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(1), current_position[X_AXIS] * MINUNITMULT);
- DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(2), current_position[Y_AXIS] * MINUNITMULT);
- DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(3), current_position[Z_AXIS] * MINUNITMULT);
- DWIN_Draw_Signed_Float(font8x16, Background_black, 3, 1, 216, MBASE(4), current_position.e * MINUNITMULT);
- break;
- case 2: // close motion
- queue.inject_P(PSTR("M84"));
- break;
- case 3: // homing
- checkkey = Last_Prepare;
- index_prepare = MROWS;
- queue.inject_P(PSTR("G28")); // G28 will set home_flag
- Popup_Window_Home();
- break;
- case 4: // Z-offset
- #if HAS_BED_PROBE
- checkkey = Homeoffset;
- HMI_ValueStruct.show_mode = -4;
- HMI_ValueStruct.offset_value = probe.offset.z * 100;
- DWIN_Draw_Signed_Float(font8x16, Select_Color, 2, 2, 202, MBASE(4 + MROWS - index_prepare), HMI_ValueStruct.offset_value);
- EncoderRate.encoderRateEnabled = 1;
- #else
- // Apply workspace offset, making the current position 0,0,0
- queue.inject_P(PSTR("G92 X0 Y0 Z0"));
- HMI_AudioFeedback();
- #endif
- break;
- case 5: // PLA preheat
- thermalManager.setTargetHotend(ui.material_preset[0].hotend_temp, 0);
- thermalManager.setTargetBed(ui.material_preset[0].bed_temp);
- thermalManager.set_fan_speed(0, ui.material_preset[0].fan_speed);
- break;
- case 6: // ABS preheat
- thermalManager.setTargetHotend(ui.material_preset[1].hotend_temp, 0);
- thermalManager.setTargetBed(ui.material_preset[1].bed_temp);
- thermalManager.set_fan_speed(0, ui.material_preset[1].fan_speed);
- break;
- case 7: // cool
- thermalManager.zero_fan_speeds();
- thermalManager.disable_all_heaters();
- break;
- case 8: // language
- /* select language */
- HMI_flag.language_chinese ^= true;
- if (HMI_flag.language_chinese) {
- HMI_SetAndSaveLanguageChinese();
- DWIN_JPG_CacheTo1(Language_Chinese);
- }
- else {
- HMI_SetAndSaveLanguageWestern();
- DWIN_JPG_CacheTo1(Language_English);
- }
- Draw_Prepare_Menu();
- break;
- default: break;
- }
- }
- DWIN_UpdateLCD();
- }
-
- void Draw_Temperature_Menu() {
- Clear_Main_Window();
-
- if (HMI_flag.language_chinese) {
- DWIN_Frame_AreaCopy(1, 236, 2, 263, 13, 14, 8);
-
- DWIN_Frame_AreaCopy(1, 1, 134, 56, 146, LBLX, MBASE(1));
- DWIN_Frame_AreaCopy(1, 58, 134, 113, 146, LBLX, MBASE(2));
- DWIN_Frame_AreaCopy(1, 115, 134, 170, 146, LBLX, MBASE(3));
- DWIN_Frame_AreaCopy(1, 100, 89, 178, 101, LBLX, MBASE(4));
- DWIN_Frame_AreaCopy(1, 180, 89, 260, 100, LBLX, MBASE(5));
- }
- else {
- #ifdef USE_STRING_HEADINGS
- Draw_Title(GET_TEXT_F(MSG_TEMPERATURE));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 0), GET_TEXT_F(MSG_UBL_SET_TEMP_HOTEND));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 1), GET_TEXT_F(MSG_UBL_SET_TEMP_BED));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 2), GET_TEXT_F(MSG_FAN_SPEED));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 3), F("PLA Preheat Settings"));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 4), F("ABS Preheat Settings"));
- #else
- DWIN_Frame_AreaCopy(1, 56, 16, 141, 28, 14, 8);
- DWIN_Frame_AreaCopy(1, 197, 104, 238, 114, LBLX, MBASE(1)); // Nozzle...
- DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 44, MBASE(1)); // ...Temperature
- DWIN_Frame_AreaCopy(1, 240, 104, 264, 114, LBLX, MBASE(2)); // Bed...
- DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 27, MBASE(2)); // ...Temperature
- DWIN_Frame_AreaCopy(1, 0, 119, 64, 132, LBLX, MBASE(3)); // Fan speed
- DWIN_Frame_AreaCopy(1, 107, 76, 156, 86, LBLX, MBASE(4)); // Preheat...
- DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX + 52, MBASE(4)); // ...PLA
- DWIN_Frame_AreaCopy(1, 131, 119, 182, 132, LBLX + 79, MBASE(4)); // PLA setting
- DWIN_Frame_AreaCopy(1, 107, 76, 156, 86, LBLX, MBASE(5)); // Preheat...
- DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX + 52, MBASE(5)); // ...ABS
- DWIN_Frame_AreaCopy(1, 131, 119, 182, 132, LBLX + 81, MBASE(5)); // ABS setting
- #endif
- }
-
- Draw_Back_First(select_temp.now == 0);
- if (select_temp.now) Draw_Menu_Cursor(select_temp.now);
-
- LOOP_L_N(i, 5) Draw_Menu_Line(i + 1, ICON_SetEndTemp + i);
-
- Draw_More_Icon(4);
- Draw_More_Icon(5);
-
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(1), thermalManager.temp_hotend[0].target);
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(2), thermalManager.temp_bed.target);
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(3), thermalManager.fan_speed[0]);
- }
-
- /* Control */
- void HMI_Control(void) {
- ENCODER_DiffState encoder_diffState = get_encoder_state();
- if (encoder_diffState == ENCODER_DIFF_NO) return;
-
- // Avoid flicker by updating only the previous menu
- if (encoder_diffState == ENCODER_DIFF_CW) {
- #define CONTROL_ITEMS (5 + ENABLED(HAS_ONESTEP_LEVELING))
- if (select_control.inc(CONTROL_ITEMS)) {
- if (select_control.now > MROWS && select_control.now > index_control) {
- index_control = select_control.now;
- Scroll_Menu(DWIN_SCROLL_UP);
- Draw_Menu_Icon(MROWS, ICON_Temperature + select_control.now - 1);
- Draw_More_Icon(1 + MROWS - index_control); // Temperature >
- Draw_More_Icon(2 + MROWS - index_control); // Motion >
- if (index_control > MROWS) {
- Draw_More_Icon(6 + MROWS - index_control); // Info >
- if (HMI_flag.language_chinese)
- DWIN_Frame_AreaCopy(1, 231, 104, 258, 116, LBLX, MBASE(5));
- else
- DWIN_Frame_AreaCopy(1, 0, 104, 24, 114, LBLX, MBASE(5));
- }
- }
- else {
- Move_Highlight(1, select_control.now + MROWS - index_control);
- }
- }
- }
- else if (encoder_diffState == ENCODER_DIFF_CCW) {
- if (select_control.dec()) {
- if (select_control.now < index_control - MROWS) {
- index_control--;
- Scroll_Menu(DWIN_SCROLL_DOWN);
- if (index_control == MROWS)
- Draw_Back_First();
- else
- Draw_Menu_Line(0, ICON_Temperature + select_control.now - 1);
- Draw_More_Icon(0 + MROWS - index_control + 1); // Temperature >
- Draw_More_Icon(1 + MROWS - index_control + 1); // Motion >
- }
- else {
- Move_Highlight(-1, select_control.now + MROWS - index_control);
- }
- }
- }
- else if (encoder_diffState == ENCODER_DIFF_ENTER) {
- switch (select_control.now) {
- case 0: // back
- select_page.set(2);
- Goto_MainMenu();
- break;
- case 1: // temperature
- checkkey = TemperatureID;
- HMI_ValueStruct.show_mode = -1;
- select_temp.reset();
- Draw_Temperature_Menu();
- break;
- case 2: // motion
- checkkey = Motion;
- select_motion.reset();
- Draw_Motion_Menu();
- break;
- case 3:
- #if ENABLED(EEPROM_SETTINGS)
- { // write EEPROM
- const bool success = settings.save();
- HMI_AudioFeedback(success);
- } break;
- case 4: { // read EEPROM
- const bool success = settings.load();
- HMI_AudioFeedback(success);
- } break;
- case 5: // resume EEPROM
- settings.reset();
- HMI_AudioFeedback();
- break;
- case 6: // info
- #endif
- checkkey = Info;
- Draw_Info_Menu();
- break;
- default: break;
- }
- }
- DWIN_UpdateLCD();
- }
-
-
- #if HAS_ONESTEP_LEVELING
-
- /* Leveling */
- void HMI_Leveling(void) {
- Popup_Window_Leveling();
- DWIN_UpdateLCD();
- queue.inject_P(PSTR("G28O\nG29"));
- }
-
- #endif
-
- /* Axis Move */
- void HMI_AxisMove(void) {
- ENCODER_DiffState encoder_diffState = get_encoder_state();
- if (encoder_diffState == ENCODER_DIFF_NO) return;
-
- #if HAS_HOTEND
- // popup window resume
- if (HMI_flag.ETempTooLow_flag) {
- if (encoder_diffState == ENCODER_DIFF_ENTER) {
- HMI_flag.ETempTooLow_flag = 0;
- Draw_Move_Menu();
- current_position.e = HMI_ValueStruct.Move_E_scale = 0;
- DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scale);
- DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scale);
- DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scale);
- DWIN_Draw_Signed_Float(font8x16, Background_black, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale);
- DWIN_UpdateLCD();
- }
- return;
- }
- #endif
-
- // Avoid flicker by updating only the previous menu
- if (encoder_diffState == ENCODER_DIFF_CW) {
- if (select_axis.inc(4)) Move_Highlight(1, select_axis.now);
- }
- else if (encoder_diffState == ENCODER_DIFF_CCW) {
- if (select_axis.dec()) Move_Highlight(-1, select_axis.now);
- }
- else if (encoder_diffState == ENCODER_DIFF_ENTER) {
- switch (select_axis.now) {
- case 0: // back
- checkkey = Prepare;
- select_prepare.set(1);
- index_prepare = MROWS;
- Draw_Prepare_Menu();
- break;
- case 1: // X axis move
- checkkey = Move_X;
- HMI_ValueStruct.Move_X_scale = current_position[X_AXIS] * MINUNITMULT;
- DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scale);
- EncoderRate.encoderRateEnabled = 1;
- break;
- case 2: // Y axis move
- checkkey = Move_Y;
- HMI_ValueStruct.Move_Y_scale = current_position[Y_AXIS] * MINUNITMULT;
- DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scale);
- EncoderRate.encoderRateEnabled = 1;
- break;
- case 3: // Z axis move
- checkkey = Move_Z;
- HMI_ValueStruct.Move_Z_scale = current_position[Z_AXIS] * MINUNITMULT;
- DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scale);
- EncoderRate.encoderRateEnabled = 1;
- break;
- #if HAS_HOTEND
- case 4: // Extruder
- // window tips
- #ifdef PREVENT_COLD_EXTRUSION
- if (thermalManager.temp_hotend[0].celsius < EXTRUDE_MINTEMP) {
- HMI_flag.ETempTooLow_flag = 1;
- Popup_Window_ETempTooLow();
- DWIN_UpdateLCD();
- return;
- }
- #endif
- checkkey = Extruder;
- HMI_ValueStruct.Move_E_scale = current_position.e * MINUNITMULT;
- DWIN_Draw_Signed_Float(font8x16, Select_Color, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale);
- EncoderRate.encoderRateEnabled = 1;
- break;
- #endif
- }
- }
- DWIN_UpdateLCD();
- }
-
- /* TemperatureID */
- void HMI_Temperature(void) {
- ENCODER_DiffState encoder_diffState = get_encoder_state();
- if (encoder_diffState == ENCODER_DIFF_NO) return;
-
- // Avoid flicker by updating only the previous menu
- if (encoder_diffState == ENCODER_DIFF_CW) {
- if (select_temp.inc(5)) Move_Highlight(1, select_temp.now);
- }
- else if (encoder_diffState == ENCODER_DIFF_CCW) {
- if (select_temp.dec()) Move_Highlight(-1, select_temp.now);
- }
- else if (encoder_diffState == ENCODER_DIFF_ENTER) {
- switch (select_temp.now) {
- case 0: // back
- checkkey = Control;
- select_control.set(1);
- index_control = MROWS;
- Draw_Control_Menu();
- break;
- #if HAS_HOTEND
- case 1: // nozzle temperature
- checkkey = ETemp;
- HMI_ValueStruct.E_Temp = thermalManager.temp_hotend[0].target;
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(1), thermalManager.temp_hotend[0].target);
- EncoderRate.encoderRateEnabled = 1;
- break;
- #endif
- #if HAS_HEATED_BED
- case 2: // bed temperature
- checkkey = BedTemp;
- HMI_ValueStruct.Bed_Temp = thermalManager.temp_bed.target;
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(2), thermalManager.temp_bed.target);
- EncoderRate.encoderRateEnabled = 1;
- break;
- #endif
- #if HAS_FAN
- case 3: // fan speed
- checkkey = FanSpeed;
- HMI_ValueStruct.Fan_speed = thermalManager.fan_speed[0];
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(3), thermalManager.fan_speed[0]);
- EncoderRate.encoderRateEnabled = 1;
- break;
- #endif
- #if HAS_HOTEND
- case 4: // PLA preheat setting
- checkkey = PLAPreheat;
- select_PLA.reset();
- HMI_ValueStruct.show_mode = -2;
-
- Clear_Main_Window();
-
- if (HMI_flag.language_chinese) {
- DWIN_Frame_AreaCopy(1, 59, 16, 139, 29, 14, 8);
-
- DWIN_Frame_AreaCopy(1, 100, 89, 124, 101, LBLX, MBASE(1));
- DWIN_Frame_AreaCopy(1, 1, 134, 56, 146, LBLX + 24, MBASE(1)); // PLA nozzle temp
- DWIN_Frame_AreaCopy(1, 100, 89, 124, 101, LBLX, MBASE(2));
- DWIN_Frame_AreaCopy(1, 58, 134, 113, 146, LBLX + 24, MBASE(2)); // PLA bed temp
- DWIN_Frame_AreaCopy(1, 100, 89, 124, 101, LBLX, MBASE(3));
- DWIN_Frame_AreaCopy(1, 115, 134, 170, 146, LBLX + 24, MBASE(3)); // PLA fan speed
- DWIN_Frame_AreaCopy(1, 72, 148, 151, 162, LBLX, MBASE(4)); // save PLA configuration
- }
- else {
- #ifdef USE_STRING_HEADINGS
- Draw_Title("PLA Settings"); // TODO: GET_TEXT_F
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 0), F("Nozzle Temp"));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 1), F("Bed Temp"));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 2), GET_TEXT_F(MSG_FAN_SPEED));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 3), GET_TEXT_F(MSG_STORE_EEPROM));
- #else
- DWIN_Frame_AreaCopy(1, 56, 16, 141, 28, 14, 8);
- DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX, MBASE(1));
- DWIN_Frame_AreaCopy(1, 197, 104, 238, 114, LBLX + 27, MBASE(1));
- DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 71, MBASE(1)); // PLA nozzle temp
- DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX, MBASE(2) + 3);
- DWIN_Frame_AreaCopy(1, 240, 104, 264, 114, LBLX + 27, MBASE(2) + 3);
- DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 54, MBASE(2) + 3); // PLA bed temp
- DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX, MBASE(3));
- DWIN_Frame_AreaCopy(1, 0, 119, 64, 132, LBLX + 27, MBASE(3)); // PLA fan speed
- DWIN_Frame_AreaCopy(1, 97, 165, 229, 177, LBLX, MBASE(4)); // save PLA configuration
- #endif
- }
-
- Draw_Back_First();
-
- Draw_Menu_Line(1, ICON_SetEndTemp);
- Draw_Menu_Line(2, ICON_SetBedTemp);
- Draw_Menu_Line(3, ICON_FanSpeed);
- #if ENABLED(EEPROM_SETTINGS)
- Draw_Menu_Line(4, ICON_WriteEEPROM);
- #endif
-
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(1), ui.material_preset[0].hotend_temp);
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(2), ui.material_preset[0].bed_temp);
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(3), ui.material_preset[0].fan_speed);
-
- break;
-
- case 5: // ABS preheat setting
- checkkey = ABSPreheat;
- select_ABS.reset();
- HMI_ValueStruct.show_mode = -3;
-
- Clear_Main_Window();
-
- if (HMI_flag.language_chinese) {
- DWIN_Frame_AreaCopy(1, 142, 16, 223, 29, 14, 8);
-
- DWIN_Frame_AreaCopy(1, 180, 89, 204, 100, LBLX, MBASE(1));
- DWIN_Frame_AreaCopy(1, 1, 134, 56, 146, LBLX + 24, MBASE(1)); // ABS nozzle temp
- DWIN_Frame_AreaCopy(1, 180, 89, 204, 100, LBLX, MBASE(2));
- DWIN_Frame_AreaCopy(1, 58, 134, 113, 146, LBLX + 24, MBASE(2)); // ABS bed temp
- DWIN_Frame_AreaCopy(1, 180, 89, 204, 100, LBLX, MBASE(3));
- DWIN_Frame_AreaCopy(1, 115, 134, 170, 146, LBLX + 24, MBASE(3)); // ABS fan speed
- DWIN_Frame_AreaCopy(1, 72, 148, 151, 162, LBLX, MBASE(4));
- DWIN_Frame_AreaCopy(1, 180, 89, 204, 100, LBLX + 28, MBASE(4) + 2); // save ABS configuration
- }
- else {
- #ifdef USE_STRING_HEADINGS
- Draw_Title("ABS Settings"); // TODO: GET_TEXT_F
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 0), F("Nozzle Temp"));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 1), F("Bed Temp"));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 2), GET_TEXT_F(MSG_FAN_SPEED));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 3), GET_TEXT_F(MSG_STORE_EEPROM));
- #else
- DWIN_Frame_AreaCopy(1, 56, 16, 141, 28, 14, 8);
- DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX, MBASE(1));
- DWIN_Frame_AreaCopy(1, 197, 104, 238, 114, LBLX + 27, MBASE(1));
- DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 71, MBASE(1)); // ABS nozzle temp
- DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX, MBASE(2) + 3);
- DWIN_Frame_AreaCopy(1, 240, 104, 264, 114, LBLX + 27, MBASE(2) + 3);
- DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 54, MBASE(2) + 3); // ABS bed temp
- DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX, MBASE(3));
- DWIN_Frame_AreaCopy(1, 0, 119, 64, 132, LBLX + 27, MBASE(3)); // ABS fan speed
- DWIN_Frame_AreaCopy(1, 97, 165, 229, 177, LBLX, MBASE(4));
- DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX + 33, MBASE(4)); // save ABS configuration
- #endif
- }
-
- Draw_Back_First();
-
- Draw_Menu_Line(1, ICON_SetEndTemp);
- Draw_Menu_Line(2, ICON_SetBedTemp);
- Draw_Menu_Line(3, ICON_FanSpeed);
- #if ENABLED(EEPROM_SETTINGS)
- Draw_Menu_Line(4, ICON_WriteEEPROM);
- #endif
-
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(1), ui.material_preset[1].hotend_temp);
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(2), ui.material_preset[1].bed_temp);
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(3), ui.material_preset[1].fan_speed);
-
- break;
- #endif // HAS_HOTEND
- }
- }
- DWIN_UpdateLCD();
- }
-
- inline void Draw_Max_Speed_Menu() {
- Clear_Main_Window();
-
- if (HMI_flag.language_chinese) {
- DWIN_Frame_AreaCopy(1, 1, 16, 28, 28, 14, 8);
-
- auto say_max_speed = [](const uint16_t row) {
- DWIN_Frame_AreaCopy(1, 173, 133, 228, 147, LBLX, row); // "Max speed"
- };
-
- say_max_speed(MBASE(1)); // "Max speed"
- DWIN_Frame_AreaCopy(1, 229, 133, 236, 147, LBLX + 58, MBASE(1)); // X
- say_max_speed(MBASE(2)); // "Max speed"
- DWIN_Frame_AreaCopy(1, 1, 150, 7, 160, LBLX + 58, MBASE(2) + 3); // Y
- say_max_speed(MBASE(3)); // "Max speed"
- DWIN_Frame_AreaCopy(1, 9, 150, 16, 160, LBLX + 58, MBASE(3) + 3); // Z
- say_max_speed(MBASE(4)); // "Max speed"
- DWIN_Frame_AreaCopy(1, 18, 150, 25, 160, LBLX + 58, MBASE(4) + 3); // E
- }
- else {
- #ifdef USE_STRING_HEADINGS
- Draw_Title("Max Speed (mm/s)"); // TODO: GET_TEXT_F
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 0), F("Max Feedrate X"));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 1), F("Max Feedrate Y"));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 2), F("Max Feedrate Z"));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 3), F("Max Feedrate E"));
- #else
- DWIN_Frame_AreaCopy(1, 144, 16, 189, 26, 14, 8);
-
- draw_max_en(MBASE(1)); // "Max"
- DWIN_Frame_AreaCopy(1, 184, 119, 234, 132, LBLX + 27, MBASE(1)); // "Speed X"
-
- draw_max_en(MBASE(2)); // "Max"
- draw_speed_en(27, MBASE(2)); // "Speed"
- say_y(70, MBASE(2)); // "Y"
-
- draw_max_en(MBASE(3)); // "Max"
- draw_speed_en(27, MBASE(3)); // "Speed"
- say_z(70, MBASE(3)); // "Z"
-
- draw_max_en(MBASE(4)); // "Max"
- draw_speed_en(27, MBASE(4)); // "Speed"
- say_e(70, MBASE(4)); // "E"
- #endif
- }
-
- Draw_Back_First();
- LOOP_L_N(i, 4) Draw_Menu_Line(i + 1, ICON_MaxSpeedX + i);
-
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 4, 210, MBASE(1), planner.settings.max_feedrate_mm_s[X_AXIS]);
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 4, 210, MBASE(2), planner.settings.max_feedrate_mm_s[Y_AXIS]);
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 4, 210, MBASE(3), planner.settings.max_feedrate_mm_s[Z_AXIS]);
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 4, 210, MBASE(4), planner.settings.max_feedrate_mm_s[E_AXIS]);
- }
-
- inline void Draw_Max_Accel_Menu() {
- Clear_Main_Window();
-
- if (HMI_flag.language_chinese) {
- DWIN_Frame_AreaCopy(1, 1, 16, 28, 28, 14, 8);
-
- DWIN_Frame_AreaCopy(1, 173, 133, 200, 147, LBLX, MBASE(1));
- DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(1) + 1);
- DWIN_Frame_AreaCopy(1, 229, 133, 236, 147, LBLX + 71, MBASE(1)); // Max acceleration X
- DWIN_Frame_AreaCopy(1, 173, 133, 200, 147, LBLX, MBASE(2));
- DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(2) + 1);
- DWIN_Frame_AreaCopy(1, 1, 150, 7, 160, LBLX + 71, MBASE(2) + 2); // Max acceleration Y
- DWIN_Frame_AreaCopy(1, 173, 133, 200, 147, LBLX, MBASE(3));
- DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(3) + 1);
- DWIN_Frame_AreaCopy(1, 9, 150, 16, 160, LBLX + 71, MBASE(3) + 2); // Max acceleration Z
- DWIN_Frame_AreaCopy(1, 173, 133, 200, 147, LBLX, MBASE(4));
- DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(4) + 1);
- DWIN_Frame_AreaCopy(1, 18, 150, 25, 160, LBLX + 71, MBASE(4) + 2); // Max acceleration E
- }
- else {
- #ifdef USE_STRING_HEADINGS
- Draw_Title(GET_TEXT_F(MSG_ACCELERATION));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 0), F("Max Accel X"));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 1), F("Max Accel Y"));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 2), F("Max Accel Z"));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 3), F("Max Accel E"));
- #else
- DWIN_Frame_AreaCopy(1, 144, 16, 189, 26, 14, 8);
- draw_max_accel_en(MBASE(1)); say_x(108, MBASE(1)); // "Max Acceleration X"
- draw_max_accel_en(MBASE(2)); say_y(108, MBASE(2)); // "Max Acceleration Y"
- draw_max_accel_en(MBASE(3)); say_z(108, MBASE(3)); // "Max Acceleration Z"
- draw_max_accel_en(MBASE(4)); say_e(108, MBASE(4)); // "Max Acceleration E"
- #endif
- }
-
- Draw_Back_First();
- LOOP_L_N(i, 4) Draw_Menu_Line(i + 1, ICON_MaxAccX + i);
-
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 4, 210, MBASE(1), planner.settings.max_acceleration_mm_per_s2[X_AXIS]);
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 4, 210, MBASE(2), planner.settings.max_acceleration_mm_per_s2[Y_AXIS]);
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 4, 210, MBASE(3), planner.settings.max_acceleration_mm_per_s2[Z_AXIS]);
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 4, 210, MBASE(4), planner.settings.max_acceleration_mm_per_s2[E_AXIS]);
- }
-
- inline void Draw_Max_Jerk_Menu() {
- Clear_Main_Window();
-
- if (HMI_flag.language_chinese) {
- DWIN_Frame_AreaCopy(1, 1, 16, 28, 28, 14, 8);
-
- DWIN_Frame_AreaCopy(1, 173, 133, 200, 147, LBLX, MBASE(1));
- DWIN_Frame_AreaCopy(1, 1, 180, 28, 192, LBLX + 27, MBASE(1) + 1);
- DWIN_Frame_AreaCopy(1, 202, 133, 228, 147, LBLX + 53, MBASE(1));
- DWIN_Frame_AreaCopy(1, 229, 133, 236, 147, LBLX + 83, MBASE(1)); // Max jerk speed X
- DWIN_Frame_AreaCopy(1, 173, 133, 200, 147, LBLX, MBASE(2));
- DWIN_Frame_AreaCopy(1, 1, 180, 28, 192, LBLX + 27, MBASE(2) + 1);
- DWIN_Frame_AreaCopy(1, 202, 133, 228, 147, LBLX + 53, MBASE(2));
- DWIN_Frame_AreaCopy(1, 1, 150, 7, 160, LBLX + 83, MBASE(2) + 3); // Max jerk speed Y
- DWIN_Frame_AreaCopy(1, 173, 133, 200, 147, LBLX, MBASE(3));
- DWIN_Frame_AreaCopy(1, 1, 180, 28, 192, LBLX + 27, MBASE(3) + 1);
- DWIN_Frame_AreaCopy(1, 202, 133, 228, 147, LBLX + 53, MBASE(3));
- DWIN_Frame_AreaCopy(1, 9, 150, 16, 160, LBLX + 83, MBASE(3) + 3); // Max jerk speed Z
- DWIN_Frame_AreaCopy(1, 173, 133, 200, 147, LBLX, MBASE(4));
- DWIN_Frame_AreaCopy(1, 1, 180, 28, 192, LBLX + 27, MBASE(4) + 1);
- DWIN_Frame_AreaCopy(1, 202, 133, 228, 147, LBLX + 53, MBASE(4));
- DWIN_Frame_AreaCopy(1, 18, 150, 25, 160, LBLX + 83, MBASE(4) + 3); // Max jerk speed E
- }
- else {
- #ifdef USE_STRING_HEADINGS
- Draw_Title(GET_TEXT_F(MSG_JERK));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 0), F("Max Jerk X"));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 1), F("Max Jerk Y"));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 2), F("Max Jerk Z"));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 3), F("Max Jerk E"));
- #else
- DWIN_Frame_AreaCopy(1, 144, 16, 189, 26, 14, 8);
- draw_max_en(MBASE(1)); // "Max"
- draw_jerk_en(MBASE(1)); // "Jerk"
- draw_speed_en(72, MBASE(1)); // "Speed"
- say_x(115, MBASE(1)); // "X"
-
- draw_max_en(MBASE(2)); // "Max"
- draw_jerk_en(MBASE(2)); // "Jerk"
- draw_speed_en(72, MBASE(2)); // "Speed"
- say_y(115, MBASE(2)); // "Y"
-
- draw_max_en(MBASE(3)); // "Max"
- draw_jerk_en(MBASE(3)); // "Jerk"
- draw_speed_en(72, MBASE(3)); // "Speed"
- say_z(115, MBASE(3)); // "Z"
-
- draw_max_en(MBASE(4)); // "Max"
- draw_jerk_en(MBASE(4)); // "Jerk"
- draw_speed_en(72, MBASE(4)); // "Speed"
- say_e(115, MBASE(4)); // "E"
- #endif
- }
-
- Draw_Back_First();
- LOOP_L_N(i, 4) Draw_Menu_Line(i + 1, ICON_MaxSpeedJerkX + i);
-
- DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 210, MBASE(1), planner.max_jerk[X_AXIS] * MINUNITMULT);
- DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 210, MBASE(2), planner.max_jerk[Y_AXIS] * MINUNITMULT);
- DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 210, MBASE(3), planner.max_jerk[Z_AXIS] * MINUNITMULT);
- DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 210, MBASE(4), planner.max_jerk[E_AXIS] * MINUNITMULT);
- }
-
- inline void Draw_Steps_Menu() {
- Clear_Main_Window();
-
- if (HMI_flag.language_chinese) {
- DWIN_Frame_AreaCopy(1, 1, 16, 28, 28, 14, 8);
-
- DWIN_Frame_AreaCopy(1, 153, 148, 194, 161, LBLX, MBASE(1));
- DWIN_Frame_AreaCopy(1, 229, 133, 236, 147, LBLX + 44, MBASE(1)); // Transmission Ratio X
- DWIN_Frame_AreaCopy(1, 153, 148, 194, 161, LBLX, MBASE(2));
- DWIN_Frame_AreaCopy(1, 1, 150, 7, 160, LBLX + 44, MBASE(2) + 3); // Transmission Ratio Y
- DWIN_Frame_AreaCopy(1, 153, 148, 194, 161, LBLX, MBASE(3));
- DWIN_Frame_AreaCopy(1, 9, 150, 16, 160, LBLX + 44, MBASE(3) + 3); // Transmission Ratio Z
- DWIN_Frame_AreaCopy(1, 153, 148, 194, 161, LBLX, MBASE(4));
- DWIN_Frame_AreaCopy(1, 18, 150, 25, 160, LBLX + 44, MBASE(4) + 3); // Transmission Ratio E
- }
- else {
- #ifdef USE_STRING_HEADINGS
- Draw_Title(GET_TEXT_F(MSG_STEPS_PER_MM));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 0), F("Steps/mm X"));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 1), F("Steps/mm Y"));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 2), F("Steps/mm Z"));
- DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 3), F("Steps/mm E"));
- #else
- DWIN_Frame_AreaCopy(1, 144, 16, 189, 26, 14, 8);
- draw_steps_per_mm(MBASE(1)); say_x(103, MBASE(1)); // "Steps-per-mm X"
- draw_steps_per_mm(MBASE(2)); say_y(103, MBASE(2)); // "Y"
- draw_steps_per_mm(MBASE(3)); say_z(103, MBASE(3)); // "Z"
- draw_steps_per_mm(MBASE(4)); say_e(103, MBASE(4)); // "E"
- #endif
- }
-
- Draw_Back_First();
- LOOP_L_N(i, 4) Draw_Menu_Line(i + 1, ICON_StepX + i);
-
- DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 210, MBASE(1), planner.settings.axis_steps_per_mm[X_AXIS] * MINUNITMULT);
- DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 210, MBASE(2), planner.settings.axis_steps_per_mm[Y_AXIS] * MINUNITMULT);
- DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 210, MBASE(3), planner.settings.axis_steps_per_mm[Z_AXIS] * MINUNITMULT);
- DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 210, MBASE(4), planner.settings.axis_steps_per_mm[E_AXIS] * MINUNITMULT);
- }
-
- /* Motion */
- void HMI_Motion(void) {
- ENCODER_DiffState encoder_diffState = get_encoder_state();
- if (encoder_diffState == ENCODER_DIFF_NO) return;
-
- // Avoid flicker by updating only the previous menu
- if (encoder_diffState == ENCODER_DIFF_CW) {
- if (select_motion.inc(4)) Move_Highlight(1, select_motion.now);
- }
- else if (encoder_diffState == ENCODER_DIFF_CCW) {
- if (select_motion.dec()) Move_Highlight(-1, select_motion.now);
- }
- else if (encoder_diffState == ENCODER_DIFF_ENTER) {
- switch (select_motion.now) {
- case 0: // back
- checkkey = Control;
- select_control.set(2);
- index_control = MROWS;
- Draw_Control_Menu();
- break;
- case 1: // max speed
- checkkey = MaxSpeed;
- select_speed.reset();
- Draw_Max_Speed_Menu();
- break;
- case 2: // max acceleration
- checkkey = MaxAcceleration;
- select_acc.reset();
- Draw_Max_Accel_Menu();
- break;
- case 3: // max jerk speed
- checkkey = MaxJerk;
- select_jerk.reset();
- Draw_Max_Jerk_Menu();
- break;
- case 4: // transmission ratio
- checkkey = Step;
- select_step.reset();
- Draw_Steps_Menu();
- break;
- default: break;
- }
- }
- DWIN_UpdateLCD();
- }
-
- /* Info */
- void HMI_Info(void) {
- ENCODER_DiffState encoder_diffState = get_encoder_state();
- if (encoder_diffState == ENCODER_DIFF_NO) return;
- if (encoder_diffState == ENCODER_DIFF_ENTER) {
- #if HAS_ONESTEP_LEVELING
- checkkey = Control;
- select_control.set(CONTROL_ITEMS);
- Draw_Control_Menu();
- #else
- select_page.set(3);
- Goto_MainMenu();
- #endif
- }
- DWIN_UpdateLCD();
- }
-
- /* Tune */
- void HMI_Tune(void) {
- ENCODER_DiffState encoder_diffState = get_encoder_state();
- if (encoder_diffState == ENCODER_DIFF_NO) return;
-
- // Avoid flicker by updating only the previous menu
- if (encoder_diffState == ENCODER_DIFF_CW) {
- if (select_tune.inc(6)) {
- if (select_tune.now > MROWS && select_tune.now > index_tune) {
- index_tune = select_tune.now;
- Scroll_Menu(DWIN_SCROLL_UP);
- Prepare_Item_Lang(5);
- }
- else {
- Move_Highlight(1, select_tune.now + MROWS - index_tune);
- }
- }
- }
- else if (encoder_diffState == ENCODER_DIFF_CCW) {
- if (select_tune.dec()) {
- if (select_tune.now < index_tune - MROWS) {
- index_tune--;
- Scroll_Menu(DWIN_SCROLL_DOWN);
- if (index_tune == MROWS) Draw_Back_First();
- }
- else {
- Move_Highlight(-1, select_tune.now + MROWS - index_tune);
- }
- }
- }
- else if (encoder_diffState == ENCODER_DIFF_ENTER) {
- switch (select_tune.now) {
- case 0: { // Back
- select_print.set(0);
- Goto_PrintProcess();
- }
- break;
- case 1: // Print speed
- checkkey = PrintSpeed;
- HMI_ValueStruct.print_speed = feedrate_percentage;
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(1 + MROWS - index_tune), feedrate_percentage);
- EncoderRate.encoderRateEnabled = 1;
- break;
- #if HAS_HOTEND
- case 2: // Nozzle temp
- checkkey = ETemp;
- HMI_ValueStruct.E_Temp = thermalManager.temp_hotend[0].target;
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(2 + MROWS - index_tune), thermalManager.temp_hotend[0].target);
- EncoderRate.encoderRateEnabled = 1;
- break;
- #endif
- #if HAS_HEATED_BED
- case 3: // Bed temp
- checkkey = BedTemp;
- HMI_ValueStruct.Bed_Temp = thermalManager.temp_bed.target;
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(3 + MROWS - index_tune), thermalManager.temp_bed.target);
- EncoderRate.encoderRateEnabled = 1;
- break;
- #endif
- #if HAS_FAN
- case 4: // Fan speed
- checkkey = FanSpeed;
- HMI_ValueStruct.Fan_speed = thermalManager.fan_speed[0];
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(4 + MROWS - index_tune), thermalManager.fan_speed[0]);
- EncoderRate.encoderRateEnabled = 1;
- break;
- #endif
- case 5: // Z-offset
- checkkey = Homeoffset;
- HMI_ValueStruct.offset_value = BABY_Z_VAR * 100;
- DWIN_Draw_Signed_Float(font8x16, Select_Color, 2, 2, 202, MBASE(5 + MROWS - index_tune), HMI_ValueStruct.offset_value);
- EncoderRate.encoderRateEnabled = 1;
- break;
- case 6: // Language
- // Select language
- HMI_flag.language_chinese ^= true;
-
- Clear_Main_Window();
-
- if (HMI_flag.language_chinese) {
- HMI_SetAndSaveLanguageChinese();
- DWIN_JPG_CacheTo1(Language_Chinese);
- }
- else {
- HMI_SetAndSaveLanguageWestern();
- DWIN_JPG_CacheTo1(Language_English);
- }
-
- Draw_Tune_Menu();
- break;
-
- default: break;
- }
- }
- DWIN_UpdateLCD();
- }
-
- /* PLA Preheat */
- void HMI_PLAPreheatSetting(void) {
- ENCODER_DiffState encoder_diffState = get_encoder_state();
- if (encoder_diffState == ENCODER_DIFF_NO) return;
-
- // Avoid flicker by updating only the previous menu
- if (encoder_diffState == ENCODER_DIFF_CW) {
- if (select_PLA.inc(4)) Move_Highlight(1, select_PLA.now);
- }
- else if (encoder_diffState == ENCODER_DIFF_CCW) {
- if (select_PLA.dec()) Move_Highlight(-1, select_PLA.now);
- }
- else if (encoder_diffState == ENCODER_DIFF_ENTER) {
- switch (select_PLA.now) {
- case 0: // back
- checkkey = TemperatureID;
- select_temp.now = 4;
- HMI_ValueStruct.show_mode = -1;
- Draw_Temperature_Menu();
- break;
- #if HAS_HOTEND
- case 1: // set nozzle temperature
- checkkey = ETemp;
- HMI_ValueStruct.E_Temp = ui.material_preset[0].hotend_temp;
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(1), ui.material_preset[0].hotend_temp);
- EncoderRate.encoderRateEnabled = 1;
- break;
- #endif
- #if HAS_HEATED_BED
- case 2: // set bed temperature
- checkkey = BedTemp;
- HMI_ValueStruct.Bed_Temp = ui.material_preset[0].bed_temp;
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(2), ui.material_preset[0].bed_temp);
- EncoderRate.encoderRateEnabled = 1;
- break;
- #endif
- #if HAS_FAN
- case 3: // set fan speed
- checkkey = FanSpeed;
- HMI_ValueStruct.Fan_speed = ui.material_preset[0].fan_speed;
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(3), ui.material_preset[0].fan_speed);
- EncoderRate.encoderRateEnabled = 1;
- break;
- #endif
- #if ENABLED(EEPROM_SETTINGS)
- case 4: { // save PLA configuration
- const bool success = settings.save();
- HMI_AudioFeedback(success);
- } break;
- #endif
- default: break;
- }
- }
- DWIN_UpdateLCD();
- }
-
- /* ABS Preheat */
- void HMI_ABSPreheatSetting(void) {
- ENCODER_DiffState encoder_diffState = get_encoder_state();
- if (encoder_diffState == ENCODER_DIFF_NO) return;
-
- // Avoid flicker by updating only the previous menu
- if (encoder_diffState == ENCODER_DIFF_CW) {
- if (select_ABS.inc(4)) Move_Highlight(1, select_ABS.now);
- }
- else if (encoder_diffState == ENCODER_DIFF_CCW) {
- if (select_ABS.dec()) Move_Highlight(-1, select_ABS.now);
- }
- else if (encoder_diffState == ENCODER_DIFF_ENTER) {
- switch (select_ABS.now) {
- case 0: // back
- checkkey = TemperatureID;
- select_temp.now = 5;
- HMI_ValueStruct.show_mode = -1;
- Draw_Temperature_Menu();
- break;
- #if HAS_HOTEND
- case 1: // set nozzle temperature
- checkkey = ETemp;
- HMI_ValueStruct.E_Temp = ui.material_preset[1].hotend_temp;
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(1), ui.material_preset[1].hotend_temp);
- EncoderRate.encoderRateEnabled = 1;
- break;
- #endif
- #if HAS_HEATED_BED
- case 2: // set bed temperature
- checkkey = BedTemp;
- HMI_ValueStruct.Bed_Temp = ui.material_preset[1].bed_temp;
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(2), ui.material_preset[1].bed_temp);
- EncoderRate.encoderRateEnabled = 1;
- break;
- #endif
- #if HAS_FAN
- case 3: // set fan speed
- checkkey = FanSpeed;
- HMI_ValueStruct.Fan_speed = ui.material_preset[1].fan_speed;
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(3), ui.material_preset[1].fan_speed);
- EncoderRate.encoderRateEnabled = 1;
- break;
- #endif
- #if ENABLED(EEPROM_SETTINGS)
- case 4: { // save ABS configuration
- const bool success = settings.save();
- HMI_AudioFeedback(success);
- } break;
- #endif
- default: break;
- }
- }
- DWIN_UpdateLCD();
- }
-
- /* Max Speed */
- void HMI_MaxSpeed(void) {
- ENCODER_DiffState encoder_diffState = get_encoder_state();
- if (encoder_diffState == ENCODER_DIFF_NO) return;
-
- // Avoid flicker by updating only the previous menu
- if (encoder_diffState == ENCODER_DIFF_CW) {
- if (select_speed.inc(4)) Move_Highlight(1, select_speed.now);
- }
- else if (encoder_diffState == ENCODER_DIFF_CCW) {
- if (select_speed.dec()) Move_Highlight(-1, select_speed.now);
- }
- else if (encoder_diffState == ENCODER_DIFF_ENTER) {
- switch (select_speed.now) {
- case 0: // back
- checkkey = Motion;
- select_motion.now = 1;
- Draw_Motion_Menu();
- break;
- case 1: // max Speed X
- checkkey = MaxSpeed_value;
- HMI_flag.feedspeed_flag = X_AXIS;
- HMI_ValueStruct.Max_Feedspeed = planner.settings.max_feedrate_mm_s[X_AXIS];
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 4, 210, MBASE(select_speed.now), HMI_ValueStruct.Max_Feedspeed);
- EncoderRate.encoderRateEnabled = 1;
- break;
- case 2: // max Speed Y
- checkkey = MaxSpeed_value;
- HMI_flag.feedspeed_flag = Y_AXIS;
- HMI_ValueStruct.Max_Feedspeed = planner.settings.max_feedrate_mm_s[Y_AXIS];
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 4, 210, MBASE(select_speed.now), HMI_ValueStruct.Max_Feedspeed);
- EncoderRate.encoderRateEnabled = 1;
- break;
- case 3: // max Speed Z
- checkkey = MaxSpeed_value;
- HMI_flag.feedspeed_flag = Z_AXIS;
- HMI_ValueStruct.Max_Feedspeed = planner.settings.max_feedrate_mm_s[Z_AXIS];
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 4, 210, MBASE(select_speed.now), HMI_ValueStruct.Max_Feedspeed);
- EncoderRate.encoderRateEnabled = 1;
- break;
- case 4: // max Speed E
- checkkey = MaxSpeed_value;
- HMI_flag.feedspeed_flag = E_AXIS;
- HMI_ValueStruct.Max_Feedspeed = planner.settings.max_feedrate_mm_s[E_AXIS];
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 4, 210, MBASE(select_speed.now), HMI_ValueStruct.Max_Feedspeed);
- EncoderRate.encoderRateEnabled = 1;
- break;
- default: break;
- }
- }
- DWIN_UpdateLCD();
- }
-
- /* Max Acceleration */
- void HMI_MaxAcceleration(void) {
- ENCODER_DiffState encoder_diffState = get_encoder_state();
- if (encoder_diffState == ENCODER_DIFF_NO) return;
-
- // Avoid flicker by updating only the previous menu
- if (encoder_diffState == ENCODER_DIFF_CW) {
- if (select_acc.inc(4)) Move_Highlight(1, select_acc.now);
- }
- else if (encoder_diffState == ENCODER_DIFF_CCW) {
- if (select_acc.dec()) Move_Highlight(-1, select_acc.now);
- }
- else if (encoder_diffState == ENCODER_DIFF_ENTER) {
- switch (select_acc.now) {
- case 0: // back
- checkkey = Motion;
- select_motion.now = 2;
- Draw_Motion_Menu();
- break;
- case 1: // max acceleration X
- checkkey = MaxAcceleration_value;
- HMI_flag.acc_flag = X_AXIS;
- HMI_ValueStruct.Max_Acceleration = planner.settings.max_acceleration_mm_per_s2[X_AXIS];
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 4, 210, MBASE(select_acc.now), HMI_ValueStruct.Max_Acceleration);
- EncoderRate.encoderRateEnabled = 1;
- break;
- case 2: // max acceleration Y
- checkkey = MaxAcceleration_value;
- HMI_flag.acc_flag = Y_AXIS;
- HMI_ValueStruct.Max_Acceleration = planner.settings.max_acceleration_mm_per_s2[Y_AXIS];
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 4, 210, MBASE(select_acc.now), HMI_ValueStruct.Max_Acceleration);
- EncoderRate.encoderRateEnabled = 1;
- break;
- case 3: // max acceleration Z
- checkkey = MaxAcceleration_value;
- HMI_flag.acc_flag = Z_AXIS;
- HMI_ValueStruct.Max_Acceleration = planner.settings.max_acceleration_mm_per_s2[Z_AXIS];
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 4, 210, MBASE(select_acc.now), HMI_ValueStruct.Max_Acceleration);
- EncoderRate.encoderRateEnabled = 1;
- break;
- case 4: // max acceleration E
- checkkey = MaxAcceleration_value;
- HMI_flag.acc_flag = E_AXIS;
- HMI_ValueStruct.Max_Acceleration = planner.settings.max_acceleration_mm_per_s2[E_AXIS];
- DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 4, 210, MBASE(select_acc.now), HMI_ValueStruct.Max_Acceleration);
- EncoderRate.encoderRateEnabled = 1;
- break;
- default: break;
- }
- }
- DWIN_UpdateLCD();
- }
-
- /* Max Jerk */
- void HMI_MaxJerk(void) {
- ENCODER_DiffState encoder_diffState = get_encoder_state();
- if (encoder_diffState == ENCODER_DIFF_NO) return;
-
- // Avoid flicker by updating only the previous menu
- if (encoder_diffState == ENCODER_DIFF_CW) {
- if (select_jerk.inc(4)) Move_Highlight(1, select_jerk.now);
- }
- else if (encoder_diffState == ENCODER_DIFF_CCW) {
- if (select_jerk.dec()) Move_Highlight(-1, select_jerk.now);
- }
- else if (encoder_diffState == ENCODER_DIFF_ENTER) {
- switch (select_jerk.now) {
- case 0: // back
- checkkey = Motion;
- select_motion.now = 3;
- Draw_Motion_Menu();
- break;
- case 1: // max jerk X
- checkkey = MaxJerk_value;
- HMI_flag.jerk_flag = X_AXIS;
- HMI_ValueStruct.Max_Jerk = planner.max_jerk[X_AXIS] * MINUNITMULT;
- DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk);
- EncoderRate.encoderRateEnabled = 1;
- break;
- case 2: // max jerk Y
- checkkey = MaxJerk_value;
- HMI_flag.jerk_flag = Y_AXIS;
- HMI_ValueStruct.Max_Jerk = planner.max_jerk[Y_AXIS] * MINUNITMULT;
- DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk);
- EncoderRate.encoderRateEnabled = 1;
- break;
- case 3: // max jerk Z
- checkkey = MaxJerk_value;
- HMI_flag.jerk_flag = Z_AXIS;
- HMI_ValueStruct.Max_Jerk = planner.max_jerk[Z_AXIS] * MINUNITMULT;
- DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk);
- EncoderRate.encoderRateEnabled = 1;
- break;
- case 4: // max jerk E
- checkkey = MaxJerk_value;
- HMI_flag.jerk_flag = E_AXIS;
- HMI_ValueStruct.Max_Jerk = planner.max_jerk[E_AXIS] * MINUNITMULT;
- DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk);
- EncoderRate.encoderRateEnabled = 1;
- break;
- default: break;
- }
- }
- DWIN_UpdateLCD();
- }
-
- /* Step */
- void HMI_Step(void) {
- ENCODER_DiffState encoder_diffState = get_encoder_state();
- if (encoder_diffState == ENCODER_DIFF_NO) return;
-
- // Avoid flicker by updating only the previous menu
- if (encoder_diffState == ENCODER_DIFF_CW) {
- if (select_step.inc(4)) Move_Highlight(1, select_step.now);
- }
- else if (encoder_diffState == ENCODER_DIFF_CCW) {
- if (select_step.dec()) Move_Highlight(-1, select_step.now);
- }
- else if (encoder_diffState == ENCODER_DIFF_ENTER) {
- switch (select_step.now) {
- case 0: // back
- checkkey = Motion;
- select_motion.now = 4;
- Draw_Motion_Menu();
- break;
- case 1: // max step X
- checkkey = Step_value;
- HMI_flag.step_flag = X_AXIS;
- HMI_ValueStruct.Max_Step = planner.settings.axis_steps_per_mm[X_AXIS] * MINUNITMULT;
- DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step);
- EncoderRate.encoderRateEnabled = 1;
- break;
- case 2: // max step Y
- checkkey = Step_value;
- HMI_flag.step_flag = Y_AXIS;
- HMI_ValueStruct.Max_Step = planner.settings.axis_steps_per_mm[Y_AXIS] * MINUNITMULT;
- DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step);
- EncoderRate.encoderRateEnabled = 1;
- break;
- case 3: // max step Z
- checkkey = Step_value;
- HMI_flag.step_flag = Z_AXIS;
- HMI_ValueStruct.Max_Step = planner.settings.axis_steps_per_mm[Z_AXIS] * MINUNITMULT;
- DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step);
- EncoderRate.encoderRateEnabled = 1;
- break;
- case 4: // max step E
- checkkey = Step_value;
- HMI_flag.step_flag = E_AXIS;
- HMI_ValueStruct.Max_Step = planner.settings.axis_steps_per_mm[E_AXIS] * MINUNITMULT;
- DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step);
- EncoderRate.encoderRateEnabled = 1;
- break;
- default: break;
- }
- }
- DWIN_UpdateLCD();
- }
-
- void HMI_Init(void) {
- HMI_SDCardInit();
-
- for (uint16_t t = 0; t <= 100; t += 2) {
- DWIN_ICON_Show(ICON, ICON_Bar, 15, 260);
- DWIN_Draw_Rectangle(1, Background_black, 15 + t * 242 / 100, 260, 257, 280);
- DWIN_UpdateLCD();
- delay(20);
- }
-
- HMI_SetLanguage();
- }
-
- void DWIN_Update(void) {
- EachMomentUpdate(); // Status update
- HMI_SDCardUpdate(); // SD card update
- DWIN_HandleScreen(); // Rotary encoder update
- }
-
- void EachMomentUpdate(void) {
- static millis_t next_rts_update_ms = 0;
- const millis_t ms = millis();
- if (PENDING(ms, next_rts_update_ms)) return;
- next_rts_update_ms = ms + DWIN_SCROLL_UPDATE_INTERVAL;
-
- // variable update
- update_variable();
-
- if (checkkey == PrintProcess) {
- // if print done
- if (HMI_flag.print_finish && !HMI_flag.confirm_flag) {
- HMI_flag.print_finish = 0;
- HMI_flag.confirm_flag = 1;
-
- TERN_(POWER_LOSS_RECOVERY, recovery.cancel());
-
- planner.finish_and_disable();
-
- // show percent bar and value
- Percentrecord = 0;
- Draw_Print_ProgressBar();
-
- // show print done confirm
- DWIN_Draw_Rectangle(1, Background_black, 0, 250, 271, 360);
- DWIN_ICON_Show(ICON, HMI_flag.language_chinese ? ICON_Confirm_C : ICON_Confirm_E, 86, 283);
- }
- else if (HMI_flag.pause_flag != printingIsPaused()) {
- // print status update
- HMI_flag.pause_flag = printingIsPaused();
- if (HMI_flag.pause_flag) ICON_Continue(); else ICON_Pause();
- }
- }
-
- // pause after homing
- if (pause_action_flag && printingIsPaused() && !planner.has_blocks_queued()) {
- pause_action_flag = 0;
- #if ENABLED(PAUSE_HEAT)
- tempbed = thermalManager.temp_bed.target;
- temphot = thermalManager.temp_hotend[0].target;
- thermalManager.disable_all_heaters();
- #endif
- queue.inject_P(PSTR("G1 F1200 X0 Y0"));
- }
-
- if (card.isPrinting() && checkkey == PrintProcess) { // print process
- const uint8_t card_pct = card.percentDone();
- static uint8_t last_cardpercentValue = 101;
- if (last_cardpercentValue != card_pct) { // print percent
- last_cardpercentValue = card_pct;
- if (card_pct) {
- Percentrecord = card_pct;
- Draw_Print_ProgressBar();
- }
- }
-
- duration_t elapsed = print_job_timer.duration(); // print timer
- /* already print time */
- const uint16_t min = (elapsed.value % 3600) / 60;
- if (last_Printtime != min) { // 1 minute update
- last_Printtime = min;
- Draw_Print_ProgressElapsed();
- }
- /* remain print time */
- static millis_t next_remain_time_update = 0;
- if (elapsed.minute() > 5 && ELAPSED(ms, next_remain_time_update) && HMI_flag.heat_flag == 0) { // show after 5 min and 20s update
- remain_time = ((elapsed.value - dwin_heat_time) * ((float)card.getFileSize() / (float)card.getIndex())) - (elapsed.value - dwin_heat_time);
- next_remain_time_update += 20 * 1000UL;
- Draw_Print_ProgressRemain();
- }
- }
- else if (abort_flag && !HMI_flag.home_flag) { // Print Stop
- abort_flag = 0;
- HMI_ValueStruct.print_speed = feedrate_percentage = 100;
- dwin_zoffset = TERN0(HAS_BED_PROBE, probe.offset.z);
-
- planner.finish_and_disable();
-
- #if DISABLED(SD_ABORT_NO_COOLDOWN)
- thermalManager.disable_all_heaters();
- #endif
-
- select_page.set(0);
- Goto_MainMenu();
- }
- #if ENABLED(POWER_LOSS_RECOVERY)
- else if (DWIN_lcd_sd_status && recovery.dwin_flag) { // resume print before power off
- recovery.dwin_flag = false;
-
- recovery.load();
- if (!recovery.valid()) return recovery.purge();
-
- auto draw_first_option = [](const bool sel) {
- const uint16_t c1 = sel ? Background_window : Select_Color;
- DWIN_Draw_Rectangle(0, c1, 25, 306, 126, 345);
- DWIN_Draw_Rectangle(0, c1, 24, 305, 127, 346);
- };
-
- auto update_selection = [&](const bool sel) {
- HMI_flag.select_flag = sel;
- draw_first_option(sel);
- const uint16_t c2 = sel ? Select_Color : Background_window;
- DWIN_Draw_Rectangle(0, c2, 145, 306, 246, 345);
- DWIN_Draw_Rectangle(0, c2, 144, 305, 247, 346);
- };
-
- const uint16_t fileCnt = card.get_num_Files();
- for (uint16_t i = 0; i < fileCnt; i++) {
- // TODO: Resume print via M1000 then update the UI
- // with the active filename which can come from CardReader.
- card.getfilename_sorted(SD_ORDER(i, fileCnt));
- if (!strcmp(card.filename, &recovery.info.sd_filename[1])) { // Resume print before power failure while have the same file
- recovery_flag = 1;
- HMI_flag.select_flag = 1;
- Popup_Window_Resume();
- draw_first_option(false);
- char * const name = card.longest_filename();
- const int8_t npos = _MAX(0, DWIN_WIDTH - strlen(name) * (MENU_CHR_W)) / 2;
- DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, npos, 252, name);
- DWIN_UpdateLCD();
- break;
- }
- }
-
- // if hasn't resumable G-code file
- if (!recovery_flag) return;
-
- while (recovery_flag) {
- ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
- if (encoder_diffState != ENCODER_DIFF_NO) {
- if (encoder_diffState == ENCODER_DIFF_ENTER) {
- recovery_flag = 0;
- if (HMI_flag.select_flag) break;
- TERN_(POWER_LOSS_RECOVERY, recovery.cancel());
- HMI_StartFrame(true);
- return;
- }
- else
- update_selection(encoder_diffState == ENCODER_DIFF_CCW);
-
- DWIN_UpdateLCD();
- }
- }
-
- select_print.set(0);
- HMI_ValueStruct.show_mode = 0;
- HMI_StartFrame(false);
- recovery.resume();
- return;
- }
- #endif
- DWIN_UpdateLCD();
- }
-
- void DWIN_HandleScreen(void) {
- switch (checkkey) {
- case MainMenu: HMI_MainMenu(); break;
- case SelectFile: HMI_SelectFile(); break;
- case Prepare: HMI_Prepare(); break;
- case Control: HMI_Control(); break;
- case Leveling: break;
- case PrintProcess: HMI_Printing(); break;
- case Print_window: HMI_PauseOrStop(); break;
- case AxisMove: HMI_AxisMove(); break;
- case TemperatureID: HMI_Temperature(); break;
- case Motion: HMI_Motion(); break;
- case Info: HMI_Info(); break;
- case Tune: HMI_Tune(); break;
- case PLAPreheat: HMI_PLAPreheatSetting(); break;
- case ABSPreheat: HMI_ABSPreheatSetting(); break;
- case MaxSpeed: HMI_MaxSpeed(); break;
- case MaxAcceleration: HMI_MaxAcceleration(); break;
- case MaxJerk: HMI_MaxJerk(); break;
- case Step: HMI_Step(); break;
- case Move_X: HMI_Move_X(); break;
- case Move_Y: HMI_Move_Y(); break;
- case Move_Z: HMI_Move_Z(); break;
- #if HAS_HOTEND
- case Extruder: HMI_Move_E(); break;
- case ETemp: HMI_ETemp(); break;
- #endif
- case Homeoffset: HMI_Zoffset(); break;
- #if HAS_HEATED_BED
- case BedTemp: HMI_BedTemp(); break;
- #endif
- #if HAS_FAN
- case FanSpeed: HMI_FanSpeed(); break;
- #endif
- case PrintSpeed: HMI_PrintSpeed(); break;
- case MaxSpeed_value: HMI_MaxFeedspeedXYZE(); break;
- case MaxAcceleration_value: HMI_MaxAccelerationXYZE(); break;
- case MaxJerk_value: HMI_MaxJerkXYZE(); break;
- case Step_value: HMI_StepXYZE(); break;
- default: break;
- }
- }
-
- void DWIN_CompletedHoming(void) {
- HMI_flag.home_flag = false;
- if (checkkey == Last_Prepare) {
- checkkey = Prepare;
- select_prepare.now = 3;
- index_prepare = MROWS;
- Draw_Prepare_Menu();
- }
- else if (checkkey == Back_Main) {
- HMI_ValueStruct.print_speed = feedrate_percentage = 100;
- dwin_zoffset = TERN0(HAS_BED_PROBE, probe.offset.z);
- planner.finish_and_disable();
- Goto_MainMenu();
- }
- }
-
- void DWIN_CompletedLeveling(void) {
- if (checkkey == Leveling) Goto_MainMenu();
- }
-
- #endif // DWIN_CREALITY_LCD
|