Skip to content

Commit

Permalink
Merge branch 'bugfix-2.1.x' into pr/26017
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Jun 28, 2023
2 parents a9d9dbd + bbfaf74 commit 6894069
Showing 1 changed file with 19 additions and 123 deletions.
142 changes: 19 additions & 123 deletions Marlin/src/lcd/e3v2/jyersui/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1982,9 +1982,8 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
#define TEMP_HOTEND (TEMP_BACK + ENABLED(HAS_HOTEND))
#define TEMP_BED (TEMP_HOTEND + ENABLED(HAS_HEATED_BED))
#define TEMP_FAN (TEMP_BED + ENABLED(HAS_FAN))
#define TEMP_PID (TEMP_FAN + ANY(PIDTEMP, PIDTEMPBED))
#define TEMP_MPC (TEMP_PID + ANY(MPC_EDIT_MENU, MPC_AUTOTUNE_MENU))
#define TEMP_PREHEAT1 (TEMP_MPC + (PREHEAT_COUNT >= 1))
#define TEMP_PID (TEMP_FAN + ANY(HAS_HOTEND, HAS_HEATED_BED))
#define TEMP_PREHEAT1 (TEMP_PID + (PREHEAT_COUNT >= 1))
#define TEMP_PREHEAT2 (TEMP_PREHEAT1 + (PREHEAT_COUNT >= 2))
#define TEMP_PREHEAT3 (TEMP_PREHEAT2 + (PREHEAT_COUNT >= 3))
#define TEMP_PREHEAT4 (TEMP_PREHEAT3 + (PREHEAT_COUNT >= 4))
Expand Down Expand Up @@ -2028,22 +2027,14 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
modifyValue(thermalManager.fan_speed[0], MIN_FAN_SPEED, MAX_FAN_SPEED, 1);
break;
#endif
#if ANY(PIDTEMP, PIDTEMPBED)
#if HAS_HOTEND || HAS_HEATED_BED
case TEMP_PID:
if (draw)
drawMenuItem(row, ICON_Step, F("PID"), nullptr, true);
else
drawMenu(PID);
break;
#endif
#if ANY(MPC_EDIT_MENU, MPC_AUTOTUNE_MENU)
case TEMP_MPC:
if (draw)
drawMenuItem(row, ICON_Step, F("MPC"), nullptr, true);
else
drawMenu(MPC);
break;
#endif

#define _TEMP_PREHEAT_CASE(N) \
case TEMP_PREHEAT##N: { \
Expand All @@ -2059,8 +2050,8 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
case PID:

#define PID_BACK 0
#define PID_HOTEND (PID_BACK + ENABLED(PIDTEMP))
#define PID_BED (PID_HOTEND + ENABLED(PIDTEMPBED))
#define PID_HOTEND (PID_BACK + ENABLED(HAS_HOTEND))
#define PID_BED (PID_HOTEND + ENABLED(HAS_HEATED_BED))
#define PID_CYCLES (PID_BED + 1)
#define PID_TOTAL PID_CYCLES

Expand All @@ -2073,15 +2064,15 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
else
drawMenu(TempMenu, TEMP_PID);
break;
#if ENABLED(PIDTEMP)
#if HAS_HOTEND
case PID_HOTEND:
if (draw)
drawMenuItem(row, ICON_HotendTemp, F("Hotend"), nullptr, true);
else
drawMenu(HotendPID);
break;
#endif
#if ENABLED(PIDTEMPBED)
#if HAS_HEATED_BED
case PID_BED:
if (draw)
drawMenuItem(row, ICON_BedTemp, F("Bed"), nullptr, true);
Expand All @@ -2099,9 +2090,9 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
break;
}
break;
#endif // PIDTEMP || PIDTEMPBED
#endif // HAS_HOTEND || HAS_HEATED_BED

#if ENABLED(PIDTEMP)
#if HAS_HOTEND
case HotendPID:

#define HOTENDPID_BACK 0
Expand Down Expand Up @@ -2165,9 +2156,9 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
break;
}
break;
#endif // PIDTEMP
#endif // HAS_HOTEND

#if ENABLED(PIDTEMPBED)
#if HAS_HEATED_BED
case BedPID:

#define BEDPID_BACK 0
Expand Down Expand Up @@ -2233,94 +2224,6 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
break;
#endif // PIDTEMPBED

#if ANY(MPC_EDIT_MENU, MPC_AUTOTUNE_MENU)
case MPC:

#define MPCMENU_BACK 0
#define MPCMENU_AUTOTUNE (MPCMENU_BACK + ENABLED(MPC_AUTOTUNE_MENU))
#define MPCMENU_HEATER_POWER (MPCMENU_AUTOTUNE + ENABLED(MPC_EDIT_MENU))
#define MPCMENU_BLOCK_HEAT_CAPACITY (MPCMENU_HEATER_POWER + ENABLED(MPC_EDIT_MENU))
#define MPCMENU_SENSOR_RESPONSIVENESS (MPCMENU_BLOCK_HEAT_CAPACITY + ENABLED(MPC_EDIT_MENU))
#define MPCMENU_AMBIENT_XFER_COEFF (MPCMENU_SENSOR_RESPONSIVENESS + ENABLED(MPC_EDIT_MENU))
#define MPCMENU_AMBIENT_XFER_COEFF_FAN (MPCMENU_AMBIENT_XFER_COEFF + ALL(MPC_EDIT_MENU, MPC_INCLUDE_FAN))
#define MPCMENU_TOTAL MPCMENU_AMBIENT_XFER_COEFF_FAN

switch (item) {
case MPCMENU_BACK:
if (draw)
drawMenuItem(row, ICON_Back, F("Back"));
else
drawMenu(TempMenu, TEMP_MPC);
break;

#if ENABLED(MPC_AUTOTUNE_MENU)
case MPCMENU_AUTOTUNE:
if (draw)
drawMenuItem(row, ICON_HotendTemp, F("Autotune"));
else {
popupHandler(MPCWait);
thermalManager.MPC_autotune(active_extruder, Temperature::MPCTuningType::AUTO);
redrawMenu();
}
break;
#endif

#if ENABLED(MPC_EDIT_MENU)
case MPCMENU_HEATER_POWER:
if (draw) {
drawMenuItem(row, ICON_Version, F("Heater Power"));
drawFloat(thermalManager.temp_hotend[0].mpc.heater_power, row, false, 1);
}
else
modifyValue(thermalManager.temp_hotend[0].mpc.heater_power, 1, 200, 1);
break;

case MPCMENU_BLOCK_HEAT_CAPACITY:
if (draw) {
drawMenuItem(row, ICON_Version, F("Block Heat Cap."));
drawFloat(thermalManager.temp_hotend[0].mpc.block_heat_capacity, row, false, 100);
}
else
modifyValue(thermalManager.temp_hotend[0].mpc.block_heat_capacity, 0, 40, 100);
break;

case MPCMENU_SENSOR_RESPONSIVENESS:
if (draw) {
drawMenuItem(row, ICON_Version, F("Sensor Resp."));
drawFloat(thermalManager.temp_hotend[0].mpc.sensor_responsiveness, row, false, 10000);
}
else
modifyValue(thermalManager.temp_hotend[0].mpc.sensor_responsiveness, 0, 1, 10000);
break;

case MPCMENU_AMBIENT_XFER_COEFF:
if (draw) {
drawMenuItem(row, ICON_Version, F("Amb. xfer coeff"));
drawFloat(thermalManager.temp_hotend[0].mpc.ambient_xfer_coeff_fan0, row, false, 10000);
}
else
modifyValue(thermalManager.temp_hotend[0].mpc.ambient_xfer_coeff_fan0, 0, 1, 10000);
break;

#if ENABLED(MPC_INCLUDE_FAN)
case MPCMENU_AMBIENT_XFER_COEFF_FAN: {
static float fan255_adjustment;
if (draw) {
drawMenuItem(row, ICON_Version, F("Amb. xfer adj."));
fan255_adjustment = thermalManager.temp_hotend[0].fanCoefficient();
drawFloat(fan255_adjustment, row, false, 10000);
}
else
modifyValue(fan255_adjustment, 0, 1, 10000, []{ thermalManager.temp_hotend[0].applyFanAdjustment(fan255_adjustment); });
} break;
#endif

#endif // MPC_EDIT_MENU
}
break;

#endif // MPC_EDIT_MENU || MPC_AUTOTUNE_MENU

#if HAS_PREHEAT
#define _PREHEAT_SUBMENU_CASE(N) case Preheat##N: preheat_submenu((N) - 1, item, TEMP_PREHEAT##N); break;
REPEAT_1(PREHEAT_COUNT, _PREHEAT_SUBMENU_CASE)
Expand Down Expand Up @@ -4047,18 +3950,15 @@ FSTR_P JyersDWIN::getMenuTitle(const uint8_t menu) {
#endif
case Control: return GET_TEXT_F(MSG_CONTROL);
case TempMenu: return GET_TEXT_F(MSG_TEMPERATURE);
#if ANY(PIDTEMP, PIDTEMPBED)
#if HAS_HOTEND || HAS_HEATED_BED
case PID: return F("PID Menu");
#endif
#if ENABLED(PIDTEMP)
#if HAS_HOTEND
case HotendPID: return F("Hotend PID Settings");
#endif
#if ENABLED(PIDTEMPBED)
#if HAS_HEATED_BED
case BedPID: return F("Bed PID Settings");
#endif
#if ANY(MPC_EDIT_MENU, MPC_AUTOTUNE_MENU)
case MPC: return F("MPC Menu");
#endif
#if HAS_PREHEAT
#define _PREHEAT_TITLE_CASE(N) case Preheat##N: return F(PREHEAT_## N ##_LABEL " Settings");
REPEAT_1(PREHEAT_COUNT, _PREHEAT_TITLE_CASE)
Expand Down Expand Up @@ -4121,18 +4021,15 @@ uint8_t JyersDWIN::getMenuSize(const uint8_t menu) {
#endif
case Control: return CONTROL_TOTAL;
case TempMenu: return TEMP_TOTAL;
#if ANY(PIDTEMP, PIDTEMPBED)
#if HAS_HOTEND || HAS_HEATED_BED
case PID: return PID_TOTAL;
#endif
#if ENABLED(PIDTEMP)
#if HAS_HOTEND
case HotendPID: return HOTENDPID_TOTAL;
#endif
#if ENABLED(PIDTEMPBED)
#if HAS_HEATED_BED
case BedPID: return BEDPID_TOTAL;
#endif
#if ANY(MPC_EDIT_MENU, MPC_AUTOTUNE_MENU)
case MPC: return MPCMENU_TOTAL;
#endif
#if HAS_PREHEAT
case Preheat1 ... CAT(Preheat, PREHEAT_COUNT):
return PREHEAT_SUBMENU_TOTAL;
Expand Down Expand Up @@ -4204,7 +4101,6 @@ void JyersDWIN::popupHandler(const PopupID popupid, const bool option/*=false*/)
case TempWarn: drawPopup(option ? F("Nozzle temp too low!") : F("Nozzle temp too high!"), F(""), F(""), Wait, option ? ICON_TempTooLow : ICON_TempTooHigh); break;
case Runout: drawPopup(F("Filament Runout"), F(""), F(""), Wait, ICON_BLTouch); break;
case PIDWait: drawPopup(F("PID Autotune"), F("in process"), F("Please wait until done."), Wait, ICON_BLTouch); break;
case MPCWait: drawPopup(F("MPC Autotune"), F("in process"), F("Please wait until done."), Wait, ICON_BLTouch); break;
case Resuming: drawPopup(F("Resuming Print"), F("Please wait until done."), F(""), Wait, ICON_BLTouch); break;
case Custom: drawPopup(F("Running Custom GCode"), F("Please wait until done."), F(""), Wait, ICON_BLTouch); break;
default: break;
Expand Down Expand Up @@ -4298,9 +4194,9 @@ void JyersDWIN::valueControl() {
else if (active_menu == Tune && selection == TUNE_ZOFFSET) {
gcode.process_subcommands_now(TS(F("M290Z"), p_float_t((tempvalue / valueunit - zoffsetvalue), 3)));
}
if (TERN0(PIDTEMP, valuepointer == &thermalManager.temp_hotend[0].pid.Ki) || TERN0(PIDTEMPBED, valuepointer == &thermalManager.temp_bed.pid.Ki))
if (TERN0(HAS_HOTEND, valuepointer == &thermalManager.temp_hotend[0].pid.Ki) || TERN0(HAS_HEATED_BED, valuepointer == &thermalManager.temp_bed.pid.Ki))
tempvalue = scalePID_i(tempvalue);
if (TERN0(PIDTEMP, valuepointer == &thermalManager.temp_hotend[0].pid.Kd) || TERN0(PIDTEMPBED, valuepointer == &thermalManager.temp_bed.pid.Kd))
if (TERN0(HAS_HOTEND, valuepointer == &thermalManager.temp_hotend[0].pid.Kd) || TERN0(HAS_HEATED_BED, valuepointer == &thermalManager.temp_bed.pid.Kd))
tempvalue = scalePID_d(tempvalue);
switch (valuetype) {
case 0: *(float*)valuepointer = tempvalue / valueunit; break;
Expand Down

0 comments on commit 6894069

Please sign in to comment.