3131
3232#if ENABLED(DWIN_LCD_PROUI)
3333
34- #if DISABLED(LIMITED_MAX_FR_EDITING)
35- #warning "LIMITED_MAX_FR_EDITING is recommended with ProUI."
36- #endif
37- #if DISABLED(LIMITED_MAX_ACCEL_EDITING)
38- #warning "LIMITED_MAX_ACCEL_EDITING is recommended with ProUI."
39- #endif
40- #if ENABLED(CLASSIC_JERK) && DISABLED(LIMITED_JERK_EDITING)
41- #warning "LIMITED_JERK_EDITING is recommended with ProUI."
42- #endif
43- #if DISABLED(INDIVIDUAL_AXIS_HOMING_SUBMENU)
44- #warning "INDIVIDUAL_AXIS_HOMING_SUBMENU is recommended with ProUI."
45- #endif
46- #if DISABLED(SET_PROGRESS_MANUALLY)
47- #warning "SET_PROGRESS_MANUALLY is recommended with ProUI."
48- #endif
49- #if DISABLED(STATUS_MESSAGE_SCROLLING)
50- #warning "STATUS_MESSAGE_SCROLLING is recommended with ProUI."
51- #endif
52- #if DISABLED(BAUD_RATE_GCODE)
53- #warning "BAUD_RATE_GCODE is recommended with ProUI."
54- #endif
55- #if DISABLED(SOUND_MENU_ITEM)
56- #warning "SOUND_MENU_ITEM is recommended with ProUI."
57- #endif
58- #if DISABLED(PRINTCOUNTER)
59- #warning "PRINTCOUNTER is recommended with ProUI."
60- #endif
61- #if HAS_MESH && DISABLED(MESH_EDIT_MENU)
62- #warning "MESH_EDIT_MENU is recommended with ProUI."
63- #endif
64-
6534#include " ../../fontutils.h"
6635#include " ../../marlinui.h"
6736
142111 #include " endstop_diag.h"
143112#endif
144113
145- #if HAS_PIDPLOT
114+ #if SHOW_TUNING_GRAPH
146115 #include " plot.h"
147116#endif
148117
@@ -297,6 +266,9 @@ MenuClass *MaxAccelMenu = nullptr;
297266 MenuClass *MaxJerkMenu = nullptr ;
298267#endif
299268MenuClass *StepsMenu = nullptr ;
269+ #if ENABLED(MPCTEMP)
270+ MenuClass *HotendMPCMenu = nullptr ;
271+ #endif
300272#if ENABLED(PIDTEMP)
301273 MenuClass *HotendPIDMenu = nullptr ;
302274#endif
@@ -1275,8 +1247,8 @@ void EachMomentUpdate() {
12751247 #if HAS_ESDIAG
12761248 if (checkkey == ESDiagProcess) ESDiag.Update ();
12771249 #endif
1278- #if HAS_PIDPLOT
1279- if (checkkey == PidProcess) Plot .Update ((HMI_value.pidresult == PIDTEMP_START) ? thermalManager.wholeDegHotend (0 ) : thermalManager.wholeDegBed ());
1250+ #if SHOW_TUNING_GRAPH
1251+ if (checkkey == PidProcess) plot .Update ((HMI_value.pidresult == PIDTEMP_START) ? thermalManager.wholeDegHotend (0 ) : thermalManager.wholeDegBed ());
12801252 #endif
12811253 }
12821254
@@ -1498,36 +1470,64 @@ void DWIN_LevelingDone() {
14981470 }
14991471#endif
15001472
1501- // PID process
1473+ // PID/MPC process
15021474
1503- #if BOTH(HAS_PIDPLOT, DWIN_PID_TUNE)
1475+ #if SHOW_TUNING_GRAPH
1476+
1477+ #include " plot.h"
15041478
1505- void DWIN_Draw_PIDPopup () {
1506- frame_rect_t gfrm = { 40 , 180 , DWIN_WIDTH - 80 , 120 };
1479+ celsius_t _maxtemp, _target;
1480+ void DWIN_Draw_PID_MPC_Popup () {
1481+ constexpr frame_rect_t gfrm = { 40 , 180 , DWIN_WIDTH - 80 , 120 };
15071482 DWINUI::ClearMainArea ();
15081483 Draw_Popup_Bkgd ();
1509- DWINUI::Draw_CenteredString (HMI_data.PopupTxt_Color , 100 , GET_TEXT_F (MSG_PID_AUTOTUNE));
1510- DWINUI::Draw_String (HMI_data.PopupTxt_Color , gfrm.x , gfrm.y - DWINUI::fontHeight () - 4 , F (" PID target: Celsius" ));
1511- switch (HMI_value.pidresult ) {
1512- #if ENABLED(PIDTEMP)
1484+
1485+ #if ENABLED(MPCTEMP)
1486+
1487+ switch (HMI_value.pidresult ) {
1488+ case MPCTEMP_START:
1489+ _maxtemp = thermalManager.hotend_maxtemp [0 ];
1490+ _target = 200 ;
1491+ DWINUI::Draw_CenteredString (HMI_data.PopupTxt_Color , 100 , GET_TEXT_F (MSG_MPC_AUTOTUNE));
1492+ DWINUI::Draw_String (HMI_data.PopupTxt_Color , gfrm.x , gfrm.y - DWINUI::fontHeight () - 4 , F (" MPC target: Celsius" ));
1493+ DWINUI::Draw_CenteredString (HMI_data.PopupTxt_Color , 120 , F (" for Nozzle is running." ));
1494+ break ;
1495+ case PIDTEMPBED_START:
1496+ _maxtemp = BED_MAXTEMP;
1497+ _target = HMI_data.BedPidT ;
1498+ DWINUI::Draw_CenteredString (HMI_data.PopupTxt_Color , 100 , GET_TEXT_F (MSG_PID_AUTOTUNE));
1499+ DWINUI::Draw_String (HMI_data.PopupTxt_Color , gfrm.x , gfrm.y - DWINUI::fontHeight () - 4 , F (" PID target: Celsius" ));
1500+ DWINUI::Draw_CenteredString (HMI_data.PopupTxt_Color , 120 , F (" for BED is running." ));
1501+ break ;
1502+ default : return ;
1503+ }
1504+
1505+ #else // PID
1506+
1507+ DWINUI::Draw_CenteredString (HMI_data.PopupTxt_Color , 100 , GET_TEXT_F (MSG_PID_AUTOTUNE));
1508+ DWINUI::Draw_String (HMI_data.PopupTxt_Color , gfrm.x , gfrm.y - DWINUI::fontHeight () - 4 , F (" PID target: Celsius" ));
1509+
1510+ switch (HMI_value.pidresult ) {
15131511 case PIDTEMP_START:
1512+ _maxtemp = thermalManager.hotend_maxtemp [0 ];
1513+ _target = HMI_data.HotendPidT ;
15141514 DWINUI::Draw_CenteredString (HMI_data.PopupTxt_Color , 120 , F (" for Nozzle is running." ));
1515- Plot.Draw (gfrm, thermalManager.hotend_maxtemp [0 ], HMI_data.HotendPidT );
1516- DWINUI::Draw_Int (HMI_data.PopupTxt_Color , 3 , gfrm.x + 90 , gfrm.y - DWINUI::fontHeight () - 4 , HMI_data.HotendPidT );
15171515 break ;
1518- #endif
1519- #if ENABLED(PIDTEMPBED)
15201516 case PIDTEMPBED_START:
1517+ _maxtemp = BED_MAXTEMP;
1518+ _target = HMI_data.BedPidT ;
15211519 DWINUI::Draw_CenteredString (HMI_data.PopupTxt_Color , 120 , F (" for BED is running." ));
1522- Plot.Draw (gfrm, BED_MAXTEMP, HMI_data.BedPidT );
1523- DWINUI::Draw_Int (HMI_data.PopupTxt_Color , 3 , gfrm.x + 90 , gfrm.y - DWINUI::fontHeight () - 4 , HMI_data.BedPidT );
15241520 break ;
1525- #endif
1526- default : break ;
1527- }
1521+ default : return ;
1522+ }
1523+
1524+ #endif // PID
1525+
1526+ plot.Draw (gfrm, _maxtemp, _target);
1527+ DWINUI::Draw_Int (HMI_data.PopupTxt_Color , 3 , gfrm.x + 90 , gfrm.y - DWINUI::fontHeight () - 4 , _target);
15281528 }
15291529
1530- #endif
1530+ #endif // SHOW_TUNING_GRAPH
15311531
15321532#if DWIN_PID_TUNE
15331533
@@ -1542,40 +1542,40 @@ void DWIN_LevelingDone() {
15421542 }
15431543 }
15441544
1545- void DWIN_PidTuning (pidresult_t result) {
1545+ void DWIN_PidTuning (tempcontrol_t result) {
15461546 HMI_value.pidresult = result;
15471547 switch (result) {
15481548 #if ENABLED(PIDTEMP)
15491549 case PIDTEMP_START:
15501550 HMI_SaveProcessID (PidProcess);
1551- #if HAS_PIDPLOT
1552- DWIN_Draw_PIDPopup ();
1551+ #if SHOW_TUNING_GRAPH
1552+ DWIN_Draw_PID_MPC_Popup ();
15531553 #else
15541554 DWIN_Draw_Popup (ICON_TempTooHigh, GET_TEXT_F (MSG_PID_AUTOTUNE), F (" for Nozzle is running." ));
15551555 #endif
15561556 break ;
1557- case PID_BAD_HEATER_ID :
1557+ case PID_TEMP_TOO_HIGH :
15581558 checkkey = last_checkkey;
1559- DWIN_Popup_Confirm (ICON_TempTooLow , GET_TEXT_F (MSG_PID_AUTOTUNE_FAILED), GET_TEXT_F (MSG_BAD_HEATER_ID ));
1559+ DWIN_Popup_Confirm (ICON_TempTooHigh , GET_TEXT_F (MSG_PID_AUTOTUNE_FAILED), GET_TEXT_F (MSG_TEMP_TOO_HIGH ));
15601560 break ;
15611561 #endif
15621562 #if ENABLED(PIDTEMPBED)
15631563 case PIDTEMPBED_START:
15641564 HMI_SaveProcessID (PidProcess);
1565- #if HAS_PIDPLOT
1566- DWIN_Draw_PIDPopup ();
1565+ #if SHOW_TUNING_GRAPH
1566+ DWIN_Draw_PID_MPC_Popup ();
15671567 #else
15681568 DWIN_Draw_Popup (ICON_TempTooHigh, GET_TEXT_F (MSG_PID_AUTOTUNE), F (" for BED is running." ));
15691569 #endif
15701570 break ;
15711571 #endif
1572- case PID_TUNING_TIMEOUT :
1572+ case PID_BAD_HEATER_ID :
15731573 checkkey = last_checkkey;
1574- DWIN_Popup_Confirm (ICON_TempTooHigh , GET_TEXT_F (MSG_ERROR ), GET_TEXT_F (MSG_PID_TIMEOUT ));
1574+ DWIN_Popup_Confirm (ICON_TempTooLow , GET_TEXT_F (MSG_PID_AUTOTUNE_FAILED ), GET_TEXT_F (MSG_PID_BAD_HEATER_ID ));
15751575 break ;
1576- case PID_TEMP_TOO_HIGH :
1576+ case PID_TUNING_TIMEOUT :
15771577 checkkey = last_checkkey;
1578- DWIN_Popup_Confirm (ICON_TempTooHigh, GET_TEXT_F (MSG_PID_AUTOTUNE_FAILED ), GET_TEXT_F (MSG_TEMP_TOO_HIGH ));
1578+ DWIN_Popup_Confirm (ICON_TempTooHigh, GET_TEXT_F (MSG_ERROR ), GET_TEXT_F (MSG_PID_TIMEOUT ));
15791579 break ;
15801580 case PID_DONE:
15811581 checkkey = last_checkkey;
@@ -1589,6 +1589,43 @@ void DWIN_LevelingDone() {
15891589
15901590#endif // DWIN_PID_TUNE
15911591
1592+ #if ENABLED(MPCTEMP)
1593+
1594+ void DWIN_MPCTuning (tempcontrol_t result) {
1595+ HMI_value.pidresult = result;
1596+ switch (result) {
1597+ case MPCTEMP_START:
1598+ HMI_SaveProcessID (MPCProcess);
1599+ #if SHOW_TUNING_GRAPH
1600+ DWIN_Draw_PID_MPC_Popup ();
1601+ #else
1602+ DWIN_Draw_Popup (ICON_TempTooHigh, GET_TEXT_F (MSG_MPC_AUTOTUNE), F (" for Nozzle is running." ));
1603+ #endif
1604+ break ;
1605+ case MPC_TEMP_ERROR:
1606+ checkkey = last_checkkey;
1607+ DWIN_Popup_Confirm (ICON_TempTooHigh, GET_TEXT_F (MSG_PID_AUTOTUNE_FAILED), F (STR_MPC_TEMPERATURE_ERROR));
1608+ ui.reset_alert_level ();
1609+ break ;
1610+ case MPC_INTERRUPTED:
1611+ checkkey = last_checkkey;
1612+ DWIN_Popup_Confirm (ICON_TempTooHigh, GET_TEXT_F (MSG_ERROR), F (STR_MPC_AUTOTUNE STR_MPC_AUTOTUNE_INTERRUPTED));
1613+ ui.reset_alert_level ();
1614+ break ;
1615+ case MPC_DONE:
1616+ checkkey = last_checkkey;
1617+ DWIN_Popup_Confirm (ICON_TempTooLow, GET_TEXT_F (MSG_MPC_AUTOTUNE), GET_TEXT_F (MSG_BUTTON_DONE));
1618+ ui.reset_alert_level ();
1619+ break ;
1620+ default :
1621+ checkkey = last_checkkey;
1622+ ui.reset_alert_level ();
1623+ break ;
1624+ }
1625+ }
1626+
1627+ #endif // MPCTEMP
1628+
15921629// Started a Print Job
15931630void DWIN_Print_Started () {
15941631 DEBUG_ECHOLNPGM (" DWIN_Print_Started: " , SD_Printing ());
@@ -3054,7 +3091,7 @@ void Draw_Control_Menu() {
30543091
30553092void Draw_AdvancedSettings_Menu () {
30563093 checkkey = Menu;
3057- if (SET_MENU (AdvancedSettings, MSG_ADVANCED_SETTINGS, 18 )) {
3094+ if (SET_MENU (AdvancedSettings, MSG_ADVANCED_SETTINGS, 19 )) {
30583095 BACK_ITEM (Goto_Main_Menu);
30593096 #if ENABLED(EEPROM_SETTINGS)
30603097 MENU_ITEM (ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawMenuItem, WriteEeprom);
@@ -3069,6 +3106,9 @@ void Draw_AdvancedSettings_Menu() {
30693106 #if ENABLED(PIDTEMP)
30703107 MENU_ITEM_F (ICON_PIDNozzle, STR_HOTEND_PID " Settings" , onDrawSubMenu, Draw_HotendPID_Menu);
30713108 #endif
3109+ #if ENABLED(MPCTEMP)
3110+ MENU_ITEM_F (ICON_MPCNozzle, STR_MPC_AUTOTUNE " Settings" , onDrawSubMenu, Draw_HotendMPC_Menu);
3111+ #endif
30723112 #if ENABLED(PIDTEMPBED)
30733113 MENU_ITEM_F (ICON_PIDBed, STR_BED_PID " Settings" , onDrawSubMenu, Draw_BedPID_Menu);
30743114 #endif
@@ -3500,6 +3540,38 @@ void Draw_Steps_Menu() {
35003540
35013541#endif
35023542
3543+ #if ENABLED(MPCTEMP)
3544+
3545+ void HotendMPC () { thermalManager.MPC_autotune (); }
3546+ void SetHeaterPower () { SetPFloatOnClick (1 , 200 , 1 ); }
3547+ void SetBlkHeatCapacity () { SetPFloatOnClick (0 , 40 , 2 ); }
3548+ void SetSensorRespons () { SetPFloatOnClick (0 , 1 , 4 ); }
3549+ void SetAmbientXfer () { SetPFloatOnClick (0 , 1 , 4 ); }
3550+ #if ENABLED(MPC_INCLUDE_FAN)
3551+ void onDrawFanAdj (MenuItemClass* menuitem, int8_t line) { onDrawFloatMenu (menuitem, line, 4 , thermalManager.temp_hotend [0 ].fanCoefficient ()); }
3552+ void ApplyFanAdj () { thermalManager.temp_hotend [0 ].applyFanAdjustment (MenuData.Value / POW (10 , 4 )); }
3553+ void SetFanAdj () { SetFloatOnClick (0 , 1 , 4 , thermalManager.temp_hotend [0 ].fanCoefficient (), ApplyFanAdj); }
3554+ #endif
3555+
3556+ void Draw_HotendMPC_Menu () {
3557+ checkkey = Menu;
3558+ if (SET_MENU_F (HotendMPCMenu, STR_MPC_AUTOTUNE " Settings" , 7 )) {
3559+ MPC_t &mpc = thermalManager.temp_hotend [0 ].mpc ;
3560+ BACK_ITEM (Draw_AdvancedSettings_Menu);
3561+ MENU_ITEM (ICON_MPCNozzle, MSG_MPC_AUTOTUNE, onDrawMenuItem, HotendMPC);
3562+ EDIT_ITEM (ICON_MPCHeater, MSG_MPC_POWER, onDrawPFloatMenu, SetHeaterPower, &mpc.heater_power );
3563+ EDIT_ITEM (ICON_MPCHeatCap, MSG_MPC_BLOCK_HEAT_CAPACITY, onDrawPFloat2Menu, SetBlkHeatCapacity, &mpc.block_heat_capacity );
3564+ EDIT_ITEM (ICON_MPCValue, MSG_SENSOR_RESPONSIVENESS, onDrawPFloat4Menu, SetSensorRespons, &mpc.sensor_responsiveness );
3565+ EDIT_ITEM (ICON_MPCValue, MSG_MPC_AMBIENT_XFER_COEFF, onDrawPFloat4Menu, SetAmbientXfer, &mpc.ambient_xfer_coeff_fan0 );
3566+ #if ENABLED(MPC_INCLUDE_FAN)
3567+ EDIT_ITEM (ICON_MPCFan, MSG_MPC_AMBIENT_XFER_COEFF_FAN, onDrawFanAdj, SetFanAdj, &mpc.fan255_adjustment );
3568+ #endif
3569+ }
3570+ UpdateMenu (HotendMPCMenu);
3571+ }
3572+
3573+ #endif // MPCTEMP
3574+
35033575#if ENABLED(PIDTEMPBED)
35043576
35053577 void Draw_BedPID_Menu () {
0 commit comments