🐛 Fix ProUI with disabled PID, mesh, etc.

This commit is contained in:
Scott Lahteine 2023-01-08 20:00:13 -06:00
parent 7eccd3dd8c
commit 202114c018
2 changed files with 107 additions and 93 deletions

View file

@ -61,15 +61,9 @@ void GcodeSuite::M303() {
const heater_id_t hid = (heater_id_t)parser.intval('E'); const heater_id_t hid = (heater_id_t)parser.intval('E');
celsius_t default_temp; celsius_t default_temp;
switch (hid) { switch (hid) {
#if ENABLED(PIDTEMP) OPTCODE(PIDTEMP, case 0 ... HOTENDS - 1: default_temp = PREHEAT_1_TEMP_HOTEND; break)
case 0 ... HOTENDS - 1: default_temp = PREHEAT_1_TEMP_HOTEND; break; OPTCODE(PIDTEMPBED, case H_BED: default_temp = PREHEAT_1_TEMP_BED; break)
#endif OPTCODE(PIDTEMPCHAMBER, case H_CHAMBER: default_temp = PREHEAT_1_TEMP_CHAMBER; break)
#if ENABLED(PIDTEMPBED)
case H_BED: default_temp = PREHEAT_1_TEMP_BED; break;
#endif
#if ENABLED(PIDTEMPCHAMBER)
case H_CHAMBER: default_temp = PREHEAT_1_TEMP_CHAMBER; break;
#endif
default: default:
SERIAL_ECHOPGM(STR_PID_AUTOTUNE); SERIAL_ECHOPGM(STR_PID_AUTOTUNE);
SERIAL_ECHOLNPGM(STR_PID_BAD_HEATER_ID); SERIAL_ECHOLNPGM(STR_PID_BAD_HEATER_ID);
@ -84,9 +78,15 @@ void GcodeSuite::M303() {
const celsius_t temp = seenS ? parser.value_celsius() : default_temp; const celsius_t temp = seenS ? parser.value_celsius() : default_temp;
const bool u = parser.boolval('U'); const bool u = parser.boolval('U');
#if ENABLED(DWIN_LCD_PROUI) #if ENABLED(DWIN_LCD_PROUI) && EITHER(PIDTEMP, PIDTEMPBED)
if (seenC) HMI_data.PidCycles = c; if (seenC) HMI_data.PidCycles = c;
if (seenS) { if (hid == H_BED) HMI_data.BedPidT = temp; else TERN_(PIDTEMP, HMI_data.HotendPidT = temp); } if (seenS) {
switch (hid) {
OPTCODE(PIDTEMP, case 0 ... HOTENDS - 1: HMI_data.HotendPidT = temp; break)
OPTCODE(PIDTEMPBED, case H_BED: HMI_data.BedPidT = temp; break)
default: break;
}
}
#endif #endif
#if DISABLED(BUSY_WHILE_HEATING) #if DISABLED(BUSY_WHILE_HEATING)

View file

@ -197,7 +197,12 @@
#define DWIN_UPDATE_INTERVAL 1024 #define DWIN_UPDATE_INTERVAL 1024
#define DWIN_REMAIN_TIME_UPDATE_INTERVAL SEC_TO_MS(20) #define DWIN_REMAIN_TIME_UPDATE_INTERVAL SEC_TO_MS(20)
#define BABY_Z_VAR TERN(HAS_BED_PROBE, probe.offset.z, HMI_data.ManualZOffset) #if HAS_MESH
#define BABY_Z_VAR TERN(HAS_BED_PROBE, probe.offset.z, HMI_data.ManualZOffset)
#else
float z_offset = 0;
#define BABY_Z_VAR z_offset
#endif
// Structs // Structs
HMI_value_t HMI_value; HMI_value_t HMI_value;
@ -1520,62 +1525,71 @@ void DWIN_LevelingDone() {
DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 100, GET_TEXT_F(MSG_PID_AUTOTUNE)); DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 100, GET_TEXT_F(MSG_PID_AUTOTUNE));
DWINUI::Draw_String(HMI_data.PopupTxt_Color, gfrm.x, gfrm.y - DWINUI::fontHeight() - 4, F("PID target: Celsius")); DWINUI::Draw_String(HMI_data.PopupTxt_Color, gfrm.x, gfrm.y - DWINUI::fontHeight() - 4, F("PID target: Celsius"));
switch (HMI_value.pidresult) { switch (HMI_value.pidresult) {
case PIDTEMP_START: #if ENABLED(PIDTEMP)
DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 120, F("for Nozzle is running.")); case PIDTEMP_START:
Plot.Draw(gfrm, thermalManager.hotend_maxtemp[0], HMI_data.HotendPidT); DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 120, F("for Nozzle is running."));
DWINUI::Draw_Int(HMI_data.PopupTxt_Color, 3, gfrm.x + 90, gfrm.y - DWINUI::fontHeight() - 4, HMI_data.HotendPidT); Plot.Draw(gfrm, thermalManager.hotend_maxtemp[0], HMI_data.HotendPidT);
break; DWINUI::Draw_Int(HMI_data.PopupTxt_Color, 3, gfrm.x + 90, gfrm.y - DWINUI::fontHeight() - 4, HMI_data.HotendPidT);
case PIDTEMPBED_START: break;
DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 120, F("for BED is running.")); #endif
Plot.Draw(gfrm, BED_MAXTEMP, HMI_data.BedPidT); #if ENABLED(PIDTEMPBED)
DWINUI::Draw_Int(HMI_data.PopupTxt_Color, 3, gfrm.x + 90, gfrm.y - DWINUI::fontHeight() - 4, HMI_data.BedPidT); case PIDTEMPBED_START:
break; DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 120, F("for BED is running."));
default: Plot.Draw(gfrm, BED_MAXTEMP, HMI_data.BedPidT);
break; DWINUI::Draw_Int(HMI_data.PopupTxt_Color, 3, gfrm.x + 90, gfrm.y - DWINUI::fontHeight() - 4, HMI_data.BedPidT);
break;
#endif
default: break;
} }
} }
#endif #endif
void DWIN_PidTuning(pidresult_t result) { #if EITHER(PIDTEMP, PIDTEMPBED)
HMI_value.pidresult = result;
switch (result) { void DWIN_PidTuning(pidresult_t result) {
case PIDTEMPBED_START: HMI_value.pidresult = result;
HMI_SaveProcessID(PidProcess); switch (result) {
#if HAS_PIDPLOT #if ENABLED(PIDTEMP)
DWIN_Draw_PIDPopup(); case PIDTEMP_START:
#else HMI_SaveProcessID(PidProcess);
DWIN_Draw_Popup(ICON_TempTooHigh, GET_TEXT_F(MSG_PID_AUTOTUNE), F("for BED is running.")); #if HAS_PIDPLOT
DWIN_Draw_PIDPopup();
#else
DWIN_Draw_Popup(ICON_TempTooHigh, GET_TEXT_F(MSG_PID_AUTOTUNE), F("for Nozzle is running."));
#endif
break;
case PID_BAD_EXTRUDER_NUM:
checkkey = last_checkkey;
DWIN_Popup_Confirm(ICON_TempTooLow, GET_TEXT_F(MSG_PID_AUTOTUNE_FAILED), GET_TEXT_F(MSG_BAD_EXTRUDER_NUM));
break;
#endif #endif
break; #if ENABLED(PIDTEMPBED)
case PIDTEMP_START: case PIDTEMPBED_START:
HMI_SaveProcessID(PidProcess); HMI_SaveProcessID(PidProcess);
#if HAS_PIDPLOT #if HAS_PIDPLOT
DWIN_Draw_PIDPopup(); DWIN_Draw_PIDPopup();
#else #else
DWIN_Draw_Popup(ICON_TempTooHigh, GET_TEXT_F(MSG_PID_AUTOTUNE), F("for Nozzle is running.")); DWIN_Draw_Popup(ICON_TempTooHigh, GET_TEXT_F(MSG_PID_AUTOTUNE), F("for BED is running."));
#endif
break;
#endif #endif
break; case PID_TUNING_TIMEOUT:
case PID_BAD_EXTRUDER_NUM: checkkey = last_checkkey;
checkkey = last_checkkey; DWIN_Popup_Confirm(ICON_TempTooHigh, GET_TEXT_F(MSG_ERROR), GET_TEXT_F(MSG_PID_TIMEOUT));
DWIN_Popup_Confirm(ICON_TempTooLow, GET_TEXT_F(MSG_PID_AUTOTUNE_FAILED), GET_TEXT_F(MSG_BAD_EXTRUDER_NUM)); break;
break; case PID_TEMP_TOO_HIGH:
case PID_TUNING_TIMEOUT: checkkey = last_checkkey;
checkkey = last_checkkey; DWIN_Popup_Confirm(ICON_TempTooHigh, GET_TEXT_F(MSG_PID_AUTOTUNE_FAILED), GET_TEXT_F(MSG_TEMP_TOO_HIGH));
DWIN_Popup_Confirm(ICON_TempTooHigh, GET_TEXT_F(MSG_ERROR), GET_TEXT_F(MSG_PID_TIMEOUT)); break;
break; case PID_DONE:
case PID_TEMP_TOO_HIGH: checkkey = last_checkkey;
checkkey = last_checkkey; DWIN_Popup_Confirm(ICON_TempTooLow, GET_TEXT_F(MSG_PID_AUTOTUNE), GET_TEXT_F(MSG_BUTTON_DONE));
DWIN_Popup_Confirm(ICON_TempTooHigh, GET_TEXT_F(MSG_PID_AUTOTUNE_FAILED), GET_TEXT_F(MSG_TEMP_TOO_HIGH)); break;
break; default: checkkey = last_checkkey; break;
case PID_DONE: }
checkkey = last_checkkey;
DWIN_Popup_Confirm(ICON_TempTooLow, GET_TEXT_F(MSG_PID_AUTOTUNE), GET_TEXT_F(MSG_BUTTON_DONE));
break;
default:
checkkey = last_checkkey;
break;
} }
}
#endif // PIDTEMP || PIDTEMPBED
// Started a Print Job // Started a Print Job
void DWIN_Print_Started() { void DWIN_Print_Started() {
@ -1675,18 +1689,14 @@ void DWIN_SetDataDefaults() {
HMI_data.ExtMinT = EXTRUDE_MINTEMP; HMI_data.ExtMinT = EXTRUDE_MINTEMP;
ApplyExtMinT(); ApplyExtMinT();
#endif #endif
#if BOTH(HAS_HEATED_BED, PREHEAT_BEFORE_LEVELING) TERN_(PREHEAT_BEFORE_LEVELING, HMI_data.BedLevT = LEVELING_BED_TEMP);
HMI_data.BedLevT = LEVELING_BED_TEMP;
#endif
TERN_(BAUD_RATE_GCODE, SetBaud250K()); TERN_(BAUD_RATE_GCODE, SetBaud250K());
HMI_data.FullManualTramming = false; HMI_data.FullManualTramming = false;
HMI_data.MediaAutoMount = ENABLED(HAS_SD_EXTENDER); HMI_data.MediaAutoMount = ENABLED(HAS_SD_EXTENDER);
#if BOTH(INDIVIDUAL_AXIS_HOMING_SUBMENU, MESH_BED_LEVELING) #if BOTH(INDIVIDUAL_AXIS_HOMING_SUBMENU, MESH_BED_LEVELING)
HMI_data.z_after_homing = DEF_Z_AFTER_HOMING; HMI_data.z_after_homing = DEF_Z_AFTER_HOMING;
#endif #endif
#if DISABLED(HAS_BED_PROBE) IF_DISABLED(HAS_BED_PROBE, HMI_data.ManualZOffset = 0);
HMI_data.ManualZOffset = 0;
#endif
#if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS)
TERN_(LED_COLOR_PRESETS, leds.set_default()); TERN_(LED_COLOR_PRESETS, leds.set_default());
ApplyLEDColor(); ApplyLEDColor();
@ -2062,21 +2072,23 @@ void SetMoveZ() { HMI_value.axis = Z_AXIS; SetPFloatOnClick(Z_MIN_POS, Z_MAX_POS
} }
#endif #endif
void SetPID(celsius_t t, heater_id_t h) { #if EITHER(PIDTEMP, PIDTEMPBED)
char cmd[53] = ""; void SetPID(celsius_t t, heater_id_t h) {
char str_1[5] = "", str_2[5] = ""; char cmd[53] = "";
sprintf_P(cmd, PSTR("G28OXY\nG0Z5F300\nG0X%sY%sF5000\nM84\nM400"), char str_1[5] = "", str_2[5] = "";
dtostrf(X_CENTER, 1, 1, str_1), sprintf_P(cmd, PSTR("G28OXY\nG0Z5F300\nG0X%sY%sF5000\nM84\nM400"),
dtostrf(Y_CENTER, 1, 1, str_2) dtostrf(X_CENTER, 1, 1, str_1),
); dtostrf(Y_CENTER, 1, 1, str_2)
gcode.process_subcommands_now(cmd); );
thermalManager.PID_autotune(t, h, HMI_data.PidCycles, true); gcode.process_subcommands_now(cmd);
} thermalManager.PID_autotune(t, h, HMI_data.PidCycles, true);
#if ENABLED(PIDTEMP) }
void HotendPID() { SetPID(HMI_data.HotendPidT, H_E0); } #if ENABLED(PIDTEMP)
#endif void HotendPID() { SetPID(HMI_data.HotendPidT, H_E0); }
#if ENABLED(PIDTEMPBED) #endif
void BedPID() { SetPID(HMI_data.BedPidT, H_BED); } #if ENABLED(PIDTEMPBED)
void BedPID() { SetPID(HMI_data.BedPidT, H_BED); }
#endif
#endif #endif
#if ENABLED(POWER_LOSS_RECOVERY) #if ENABLED(POWER_LOSS_RECOVERY)
@ -2375,14 +2387,14 @@ void TramBR() { Tram(2); }
void TramBL() { Tram(3); } void TramBL() { Tram(3); }
void TramC () { Tram(4); } void TramC () { Tram(4); }
#if HAS_BED_PROBE #if HAS_BED_PROBE && HAS_MESH
void Trammingwizard() { void Trammingwizard() {
bed_mesh_t zval = {0};
if (HMI_data.FullManualTramming) { if (HMI_data.FullManualTramming) {
LCD_MESSAGE_F("Disable manual tramming"); LCD_MESSAGE_F("Disable manual tramming");
return; return;
} }
bed_mesh_t zval = {0};
zval[0][0] = Tram(0); zval[0][0] = Tram(0);
checkkey = NothingToDo; checkkey = NothingToDo;
MeshViewer.DrawMesh(zval, 2, 2); MeshViewer.DrawMesh(zval, 2, 2);
@ -2441,7 +2453,7 @@ void TramC () { Tram(4); }
Toogle_Chkb_Line(HMI_data.FullManualTramming); Toogle_Chkb_Line(HMI_data.FullManualTramming);
} }
#endif // HAS_BED_PROBE #endif // HAS_BED_PROBE && HAS_MESH
#if ENABLED(MESH_BED_LEVELING) #if ENABLED(MESH_BED_LEVELING)
@ -2531,11 +2543,11 @@ void SetStepsZ() { HMI_value.axis = Z_AXIS, SetPFloatOnClick( MIN_STEP, MAX_STEP
void SetKp() { SetPFloatOnClick(0, 1000, 2); } void SetKp() { SetPFloatOnClick(0, 1000, 2); }
void ApplyPIDi() { void ApplyPIDi() {
*MenuData.P_Float = scalePID_i(MenuData.Value / POW(10, 2)); *MenuData.P_Float = scalePID_i(MenuData.Value / POW(10, 2));
thermalManager.updatePID(); TERN_(PIDTEMP, thermalManager.updatePID());
} }
void ApplyPIDd() { void ApplyPIDd() {
*MenuData.P_Float = scalePID_d(MenuData.Value / POW(10, 2)); *MenuData.P_Float = scalePID_d(MenuData.Value / POW(10, 2));
thermalManager.updatePID(); TERN_(PIDTEMP, thermalManager.updatePID());
} }
void SetKi() { void SetKi() {
MenuData.P_Float = (float*)static_cast<MenuItemPtrClass*>(CurrentMenu->SelectedItem())->value; MenuData.P_Float = (float*)static_cast<MenuItemPtrClass*>(CurrentMenu->SelectedItem())->value;
@ -2698,8 +2710,10 @@ void onDrawGetColorItem(MenuItemClass* menuitem, int8_t line) {
} }
void onDrawPIDi(MenuItemClass* menuitem, int8_t line) { onDrawFloatMenu(menuitem, line, 2, unscalePID_i(*(float*)static_cast<MenuItemPtrClass*>(menuitem)->value)); } #if EITHER(PIDTEMP, PIDTEMPBED)
void onDrawPIDd(MenuItemClass* menuitem, int8_t line) { onDrawFloatMenu(menuitem, line, 2, unscalePID_d(*(float*)static_cast<MenuItemPtrClass*>(menuitem)->value)); } void onDrawPIDi(MenuItemClass* menuitem, int8_t line) { onDrawFloatMenu(menuitem, line, 2, unscalePID_i(*(float*)static_cast<MenuItemPtrClass*>(menuitem)->value)); }
void onDrawPIDd(MenuItemClass* menuitem, int8_t line) { onDrawFloatMenu(menuitem, line, 2, unscalePID_d(*(float*)static_cast<MenuItemPtrClass*>(menuitem)->value)); }
#endif
void onDrawSpeedItem(MenuItemClass* menuitem, int8_t line) { void onDrawSpeedItem(MenuItemClass* menuitem, int8_t line) {
if (HMI_IsChinese()) menuitem->SetFrame(1, 116, 164, 171, 176); if (HMI_IsChinese()) menuitem->SetFrame(1, 116, 164, 171, 176);
@ -2992,10 +3006,10 @@ void Draw_Tramming_Menu() {
checkkey = Menu; checkkey = Menu;
if (SET_MENU(TrammingMenu, MSG_BED_TRAMMING, 8)) { if (SET_MENU(TrammingMenu, MSG_BED_TRAMMING, 8)) {
BACK_ITEM(Draw_Prepare_Menu); BACK_ITEM(Draw_Prepare_Menu);
#if HAS_BED_PROBE #if HAS_BED_PROBE && HAS_MESH
MENU_ITEM(ICON_ProbeSet, MSG_TRAMMING_WIZARD, onDrawMenuItem, Trammingwizard); MENU_ITEM(ICON_ProbeSet, MSG_TRAMMING_WIZARD, onDrawMenuItem, Trammingwizard);
EDIT_ITEM(ICON_ProbeSet, MSG_BED_TRAMMING_MANUAL, onDrawChkbMenu, SetManualTramming, &HMI_data.FullManualTramming); EDIT_ITEM(ICON_ProbeSet, MSG_BED_TRAMMING_MANUAL, onDrawChkbMenu, SetManualTramming, &HMI_data.FullManualTramming);
#else #elif !HAS_BED_PROBE && HAS_ZOFFSET_ITEM
MENU_ITEM_F(ICON_MoveZ0, "Home Z and disable", onDrawMenuItem, HomeZandDisable); MENU_ITEM_F(ICON_MoveZ0, "Home Z and disable", onDrawMenuItem, HomeZandDisable);
#endif #endif
MENU_ITEM(ICON_Axis, MSG_LEVBED_FL, onDrawMenuItem, TramFL); MENU_ITEM(ICON_Axis, MSG_LEVBED_FL, onDrawMenuItem, TramFL);
@ -3547,7 +3561,7 @@ void Draw_Steps_Menu() {
DWIN_UpdateLCD(); DWIN_UpdateLCD();
} }
#if BOTH(HAS_HEATED_BED, PREHEAT_BEFORE_LEVELING) #if ENABLED(PREHEAT_BEFORE_LEVELING)
void SetBedLevT() { SetPIntOnClick(MIN_BEDTEMP, MAX_BEDTEMP); } void SetBedLevT() { SetPIntOnClick(MIN_BEDTEMP, MAX_BEDTEMP); }
#endif #endif
@ -3613,7 +3627,7 @@ void Draw_Steps_Menu() {
checkkey = Menu; checkkey = Menu;
if (SET_MENU(MeshMenu, MSG_MESH_LEVELING, 13)) { if (SET_MENU(MeshMenu, MSG_MESH_LEVELING, 13)) {
BACK_ITEM(Draw_AdvancedSettings_Menu); BACK_ITEM(Draw_AdvancedSettings_Menu);
#if BOTH(HAS_HEATED_BED, PREHEAT_BEFORE_LEVELING) #if ENABLED(PREHEAT_BEFORE_LEVELING)
EDIT_ITEM(ICON_Temperature, MSG_UBL_SET_TEMP_BED, onDrawPIntMenu, SetBedLevT, &HMI_data.BedLevT); EDIT_ITEM(ICON_Temperature, MSG_UBL_SET_TEMP_BED, onDrawPIntMenu, SetBedLevT, &HMI_data.BedLevT);
#endif #endif
EDIT_ITEM(ICON_SetZOffset, MSG_Z_FADE_HEIGHT, onDrawPFloatMenu, SetMeshFadeHeight, &planner.z_fade_height); EDIT_ITEM(ICON_SetZOffset, MSG_Z_FADE_HEIGHT, onDrawPFloatMenu, SetMeshFadeHeight, &planner.z_fade_height);