Skip to content

Commit 56ac5d0

Browse files
🚸 Update ProUI Plot graph (MarlinFirmware#26539)
1 parent ec7ab5a commit 56ac5d0

File tree

8 files changed

+199
-92
lines changed

8 files changed

+199
-92
lines changed

Marlin/src/inc/Warnings.cpp

+10-3
Original file line numberDiff line numberDiff line change
@@ -792,10 +792,17 @@
792792
#endif
793793

794794
/**
795-
* ProUI Boot Screen Duration
795+
* ProUI Extras
796796
*/
797-
#if ENABLED(DWIN_LCD_PROUI) && BOOTSCREEN_TIMEOUT > 2000
798-
#warning "For ProUI the original BOOTSCREEN_TIMEOUT of 1100 is recommended."
797+
#if ENABLED(DWIN_LCD_PROUI)
798+
#if BOOTSCREEN_TIMEOUT > 2000
799+
#warning "For ProUI the original BOOTSCREEN_TIMEOUT of 1100 is recommended."
800+
#endif
801+
#if HAS_PID_HEATING && NONE(PID_AUTOTUNE_MENU, PID_EDIT_MENU)
802+
#warning "For ProUI PID_AUTOTUNE_MENU and PID_EDIT_MENU is recommended for PID tuning."
803+
#elif ENABLED(MPCTEMP) && NONE(MPC_EDIT_MENU, MPC_AUTOTUNE_MENU)
804+
#warning "For ProUI MPC_EDIT_MENU and MPC_AUTOTUNE_MENU is recommended for MPC tuning."
805+
#endif
799806
#endif
800807

801808
/**

Marlin/src/lcd/e3v2/proui/dwin.cpp

+122-52
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ void _drawIconBlink(bool &flag, const bool sensor, const uint8_t icon1, const ui
735735
void _drawZOffsetIcon() {
736736
#if HAS_LEVELING
737737
static bool _leveling_active = false;
738-
_drawIconBlink(_leveling_active, planner.leveling_active, ICON_Zoffset, ICON_SetZOffset, 186, 416);
738+
_drawIconBlink(_leveling_active, planner.leveling_active, ICON_Zoffset, ICON_SetZOffset, 187, 416);
739739
#else
740740
DWINUI::drawIcon(ICON_Zoffset, 187, 416);
741741
#endif
@@ -763,9 +763,9 @@ void _drawFeedrate() {
763763
}
764764

765765
void _drawXYZPosition(const bool force) {
766-
_update_axis_value(X_AXIS, 27, 459, force);
767-
_update_axis_value(Y_AXIS, 112, 459, force);
768-
_update_axis_value(Z_AXIS, 197, 459, force);
766+
_update_axis_value(X_AXIS, 27, 457, force);
767+
_update_axis_value(Y_AXIS, 112, 457, force);
768+
_update_axis_value(Z_AXIS, 197, 457, force);
769769
}
770770

771771
void updateVariable() {
@@ -778,7 +778,18 @@ void updateVariable() {
778778
_new_hotend_target = _hotendtarget != ht;
779779
if (_new_hotend_temp) _hotendtemp = hc;
780780
if (_new_hotend_target) _hotendtarget = ht;
781-
#endif
781+
782+
// if hotend is near target or heating, ICON indicates hot
783+
if (thermalManager.degHotendNear(0, ht) || thermalManager.isHeatingHotend(0)) {
784+
dwinDrawBox(1, hmiData.colorBackground, 10, 383, 20, 20);
785+
DWINUI::drawIcon(ICON_SetEndTemp, 10, 383);
786+
}
787+
else {
788+
dwinDrawBox(1, hmiData.colorBackground, 10, 383, 20, 20);
789+
DWINUI::drawIcon(ICON_HotendTemp, 10, 383);
790+
}
791+
#endif // HAS_HOTEND
792+
782793
#if HAS_HEATED_BED
783794
static celsius_t _bedtemp = 0, _bedtarget = 0;
784795
const celsius_t bc = thermalManager.wholeDegBed(),
@@ -787,7 +798,18 @@ void updateVariable() {
787798
_new_bed_target = _bedtarget != bt;
788799
if (_new_bed_temp) _bedtemp = bc;
789800
if (_new_bed_target) _bedtarget = bt;
790-
#endif
801+
802+
// if bed is near target, heating, or if degrees > 44, ICON indicates hot
803+
if (thermalManager.degBedNear(bt) || thermalManager.isHeatingBed() || (bc > 44)) {
804+
dwinDrawBox(1, hmiData.colorBackground, 10, 416, 20, 20);
805+
DWINUI::drawIcon(ICON_BedTemp, 10, 416);
806+
}
807+
else {
808+
dwinDrawBox(1, hmiData.colorBackground, 10, 416, 20, 20);
809+
DWINUI::drawIcon(ICON_SetBedTemp, 10, 416);
810+
}
811+
#endif // HAS_HEATED_BED
812+
791813
#if HAS_FAN
792814
static uint8_t _fanspeed = 0;
793815
const bool _new_fanspeed = _fanspeed != thermalManager.fan_speed[0];
@@ -1022,9 +1044,9 @@ void dwinDrawDashboard() {
10221044
dwinDrawRectangle(1, hmiData.colorBackground, 0, STATUS_Y + 21, DWIN_WIDTH, DWIN_HEIGHT - 1);
10231045
dwinDrawRectangle(1, hmiData.colorSplitLine, 0, 449, DWIN_WIDTH, 451);
10241046

1025-
DWINUI::drawIcon(ICON_MaxSpeedX, 10, 456);
1026-
DWINUI::drawIcon(ICON_MaxSpeedY, 95, 456);
1027-
DWINUI::drawIcon(ICON_MaxSpeedZ, 180, 456);
1047+
DWINUI::drawIcon(ICON_MaxSpeedX, 10, 454);
1048+
DWINUI::drawIcon(ICON_MaxSpeedY, 95, 454);
1049+
DWINUI::drawIcon(ICON_MaxSpeedZ, 180, 454);
10281050
_drawXYZPosition(true);
10291051

10301052
#if HAS_HOTEND
@@ -1033,7 +1055,7 @@ void dwinDrawDashboard() {
10331055
DWINUI::drawString(DWIN_FONT_STAT, hmiData.colorIndicator, hmiData.colorBackground, 25 + 3 * STAT_CHR_W + 5, 384, F("/"));
10341056
DWINUI::drawInt(DWIN_FONT_STAT, hmiData.colorIndicator, hmiData.colorBackground, 3, 25 + 4 * STAT_CHR_W + 6, 384, thermalManager.degTargetHotend(0));
10351057

1036-
DWINUI::drawIcon(ICON_StepE, 112, 417);
1058+
DWINUI::drawIcon(ICON_StepE, 113, 416);
10371059
DWINUI::drawInt(DWIN_FONT_STAT, hmiData.colorIndicator, hmiData.colorBackground, 3, 116 + 2 * STAT_CHR_W, 417, planner.flow_percentage[0]);
10381060
DWINUI::drawString(DWIN_FONT_STAT, hmiData.colorIndicator, hmiData.colorBackground, 116 + 5 * STAT_CHR_W + 2, 417, F("%"));
10391061
#endif
@@ -1269,6 +1291,16 @@ void eachMomentUpdate() {
12691291
TERN_(PIDTEMPBED, if (hmiValue.tempControl == PIDTEMPBED_START) plot.update(thermalManager.wholeDegBed()));
12701292
}
12711293
TERN_(MPCTEMP, if (checkkey == ID_MPCProcess) plot.update(thermalManager.wholeDegHotend(0)));
1294+
#if ENABLED(PROUI_ITEM_PLOT)
1295+
if (checkkey == ID_PlotProcess) {
1296+
TERN_(PIDTEMP, if (hmiValue.tempControl == PIDTEMP_START) { plot.update(thermalManager.wholeDegHotend(0)); })
1297+
TERN_(PIDTEMPBED, if (hmiValue.tempControl == PIDTEMPBED_START) { plot.update(thermalManager.wholeDegBed()); })
1298+
TERN_(MPCTEMP, if (hmiValue.tempControl == MPCTEMP_START) { plot.update(thermalManager.wholeDegHotend(0)); })
1299+
if (hmiFlag.abort_flag || hmiFlag.pause_flag || print_job_timer.isPaused()) {
1300+
hmiReturnScreen();
1301+
}
1302+
}
1303+
#endif
12721304
#endif
12731305
}
12741306

@@ -1402,29 +1434,32 @@ void dwinHandleScreen() {
14021434
case ID_SetIntNoDraw: hmiSetNoDraw(); break;
14031435
case ID_PrintProcess: hmiPrinting(); break;
14041436
case ID_Popup: hmiPopup(); break;
1405-
case ID_Leveling: break;
14061437
#if HAS_LOCKSCREEN
14071438
case ID_Locked: hmiLockScreen(); break;
14081439
#endif
1409-
case ID_PrintDone:
1440+
14101441
TERN_(HAS_ESDIAG, case ID_ESDiagProcess:)
1442+
TERN_(PROUI_ITEM_PLOT, case ID_PlotProcess:)
1443+
case ID_PrintDone:
14111444
case ID_WaitResponse: hmiWaitForUser(); break;
1445+
1446+
TERN_(HAS_BED_PROBE, case ID_Leveling:)
14121447
case ID_Homing:
14131448
case ID_PIDProcess:
1414-
case ID_NothingToDo: break;
1449+
case ID_NothingToDo:
14151450
default: break;
14161451
}
14171452
}
14181453

14191454
bool idIsPopUp() { // If ID is popup...
14201455
switch (checkkey) {
1456+
TERN_(HAS_BED_PROBE, case ID_Leveling:)
1457+
TERN_(HAS_ESDIAG, case ID_ESDiagProcess:)
14211458
case ID_NothingToDo:
14221459
case ID_WaitResponse:
14231460
case ID_Popup:
14241461
case ID_Homing:
1425-
case ID_Leveling:
14261462
case ID_PIDProcess:
1427-
TERN_(HAS_ESDIAG, case ID_ESDiagProcess:)
14281463
return true;
14291464
default: break;
14301465
}
@@ -1439,8 +1474,9 @@ void hmiSaveProcessID(const uint8_t id) {
14391474
case ID_Popup:
14401475
case ID_WaitResponse:
14411476
case ID_PrintDone:
1442-
case ID_Leveling:
1477+
TERN_(HAS_BED_PROBE, case ID_Leveling:)
14431478
TERN_(HAS_ESDIAG, case ID_ESDiagProcess:)
1479+
TERN_(PROUI_ITEM_PLOT, case ID_PlotProcess:)
14441480
wait_for_user = true;
14451481
default: break;
14461482
}
@@ -1515,68 +1551,94 @@ void dwinLevelingDone() {
15151551

15161552
celsius_t _maxtemp, _target;
15171553
void dwinDrawPIDMPCPopup() {
1518-
constexpr frame_rect_t gfrm = { 40, 180, DWIN_WIDTH - 80, 120 };
1554+
constexpr frame_rect_t gfrm = { 30, 150, DWIN_WIDTH - 60, 160 };
15191555
DWINUI::clearMainArea();
15201556
drawPopupBkgd();
15211557

15221558
switch (hmiValue.tempControl) {
15231559
default: return;
15241560
#if ENABLED(MPC_AUTOTUNE)
15251561
case MPCTEMP_START:
1526-
DWINUI::drawCenteredString(hmiData.colorPopupTxt, 100, GET_TEXT_F(MSG_MPC_AUTOTUNE));
1527-
DWINUI::drawString(hmiData.colorPopupTxt, gfrm.x, gfrm.y - DWINUI::fontHeight() - 4, F("MPC target: Celsius"));
1528-
break;
1529-
#endif
1530-
#if ANY(PIDTEMP, PIDTEMPBED)
1531-
TERN_(PIDTEMP, case PIDTEMP_START:)
1532-
TERN_(PIDTEMPBED, case PIDTEMPBED_START:)
1533-
DWINUI::drawCenteredString(hmiData.colorPopupTxt, 100, GET_TEXT_F(MSG_PID_AUTOTUNE));
1534-
DWINUI::drawString(hmiData.colorPopupTxt, gfrm.x, gfrm.y - DWINUI::fontHeight() - 4, F("PID target: Celsius"));
1535-
break;
1536-
#endif
1537-
}
1538-
1539-
switch (hmiValue.tempControl) {
1540-
default: break;
1541-
#if ANY(PIDTEMP, MPC_AUTOTUNE)
1542-
TERN_(PIDTEMP, case PIDTEMP_START:)
1543-
TERN_(MPC_AUTOTUNE, case MPCTEMP_START:)
1544-
DWINUI::drawCenteredString(hmiData.colorPopupTxt, 120, F("for Nozzle is running."));
1545-
break;
1546-
#endif
1547-
#if ENABLED(PIDTEMPBED)
1548-
case PIDTEMPBED_START:
1549-
DWINUI::drawCenteredString(hmiData.colorPopupTxt, 120, F("for BED is running."));
1550-
break;
1551-
#endif
1552-
}
1553-
1554-
switch (hmiValue.tempControl) {
1555-
default: break;
1556-
#if ENABLED(MPC_AUTOTUNE)
1557-
case MPCTEMP_START:
1562+
DWINUI::drawCenteredString(hmiData.colorPopupTxt, 70, GET_TEXT_F(MSG_MPC_AUTOTUNE));
1563+
DWINUI::drawString(hmiData.colorPopupTxt, gfrm.x, gfrm.y - DWINUI::fontHeight() - 4, F("MPC target: Celsius"));
1564+
DWINUI::drawCenteredString(hmiData.colorPopupTxt, 92, F("for NOZZLE is running."));
15581565
_maxtemp = thermalManager.hotend_maxtemp[0];
15591566
_target = 200;
15601567
break;
15611568
#endif
15621569
#if ENABLED(PIDTEMP)
15631570
case PIDTEMP_START:
1571+
DWINUI::drawCenteredString(hmiData.colorPopupTxt, 70, GET_TEXT_F(MSG_PID_AUTOTUNE));
1572+
DWINUI::drawString(hmiData.colorPopupTxt, gfrm.x, gfrm.y - DWINUI::fontHeight() - 4, F("PID target: Celsius"));
1573+
DWINUI::drawCenteredString(hmiData.colorPopupTxt, 92, F("for NOZZLE is running."));
15641574
_maxtemp = thermalManager.hotend_maxtemp[0];
15651575
_target = hmiData.hotendPidT;
15661576
break;
15671577
#endif
15681578
#if ENABLED(PIDTEMPBED)
15691579
case PIDTEMPBED_START:
1580+
DWINUI::drawCenteredString(hmiData.colorPopupTxt, 70, GET_TEXT_F(MSG_PID_AUTOTUNE));
1581+
DWINUI::drawString(hmiData.colorPopupTxt, gfrm.x, gfrm.y - DWINUI::fontHeight() - 4, F("PID target: Celsius"));
1582+
DWINUI::drawCenteredString(hmiData.colorPopupTxt, 92, F("for BED is running."));
15701583
_maxtemp = BED_MAXTEMP;
15711584
_target = hmiData.bedPidT;
15721585
break;
15731586
#endif
15741587
}
15751588

15761589
plot.draw(gfrm, _maxtemp, _target);
1577-
DWINUI::drawInt(hmiData.colorPopupTxt, 3, gfrm.x + 90, gfrm.y - DWINUI::fontHeight() - 4, _target);
1590+
DWINUI::drawInt(false, 2, hmiData.colorStatusTxt, hmiData.colorPopupTxt, 3, gfrm.x + 92, gfrm.y - DWINUI::fontHeight() - 6, _target);
15781591
}
15791592

1593+
// Plot Temperature Graph (PID Tuning Graph)
1594+
#if ENABLED(PROUI_ITEM_PLOT)
1595+
1596+
void dwinDrawPlot(tempcontrol_t result) {
1597+
hmiValue.tempControl = result;
1598+
constexpr frame_rect_t gfrm = {30, 135, DWIN_WIDTH - 60, 160};
1599+
DWINUI::clearMainArea();
1600+
drawPopupBkgd();
1601+
hmiSaveProcessID(ID_PlotProcess);
1602+
1603+
switch (result) {
1604+
#if ENABLED(MPCTEMP)
1605+
case MPCTEMP_START:
1606+
#elif ENABLED(PIDTEMP)
1607+
case PIDTEMP_START:
1608+
#endif
1609+
title.showCaption(GET_TEXT_F(MSG_HOTEND_TEMP_GRAPH));
1610+
DWINUI::drawCenteredString(3, hmiData.colorPopupTxt, 75, F("Nozzle Temperature"));
1611+
_maxtemp = thermalManager.hotend_max_target(0);
1612+
_target = thermalManager.degTargetHotend(0);
1613+
break;
1614+
#if ENABLED(PIDTEMPBED)
1615+
case PIDTEMPBED_START:
1616+
title.showCaption(GET_TEXT_F(MSG_BED_TEMP_GRAPH));
1617+
DWINUI::drawCenteredString(3, hmiData.colorPopupTxt, 75, F("Bed Temperature"));
1618+
_maxtemp = BED_MAX_TARGET;
1619+
_target = thermalManager.degTargetBed();
1620+
break;
1621+
#endif
1622+
default: break;
1623+
}
1624+
1625+
dwinDrawString(false, 2, hmiData.colorPopupTxt, hmiData.colorPopupBg, gfrm.x, gfrm.y - DWINUI::fontHeight() - 4, F("Target: Celsius"));
1626+
plot.draw(gfrm, _maxtemp, _target);
1627+
DWINUI::drawInt(false, 2, hmiData.colorStatusTxt, hmiData.colorPopupBg, 3, gfrm.x + 80, gfrm.y - DWINUI::fontHeight() - 4, _target);
1628+
DWINUI::drawButton(BTN_Continue, 86, 305);
1629+
dwinUpdateLCD();
1630+
}
1631+
1632+
void drawHPlot() {
1633+
TERN_(PIDTEMP, dwinDrawPlot(PIDTEMP_START);)
1634+
TERN_(MPCTEMP, dwinDrawPlot(MPCTEMP_START);)
1635+
}
1636+
void drawBPlot() {
1637+
TERN_(PIDTEMPBED, dwinDrawPlot(PIDTEMPBED_START);)
1638+
}
1639+
1640+
#endif // PROUI_ITEM_PLOT
1641+
15801642
#endif // PROUI_TUNING_GRAPH
15811643

15821644
#if PROUI_PID_TUNE
@@ -2993,7 +3055,7 @@ frame_rect_t selrect(frame_rect_t) {
29933055

29943056
void drawPrepareMenu() {
29953057
checkkey = ID_Menu;
2996-
if (SET_MENU_R(prepareMenu, selrect({133, 1, 28, 13}), MSG_PREPARE, 10 + PREHEAT_COUNT)) {
3058+
if (SET_MENU_R(prepareMenu, selrect({133, 1, 28, 13}), MSG_PREPARE, 12 + PREHEAT_COUNT)) {
29973059
BACK_ITEM(gotoMainMenu);
29983060
MENU_ITEM(ICON_FilMan, MSG_FILAMENT_MAN, onDrawSubMenu, drawFilamentManMenu);
29993061
MENU_ITEM(ICON_Axis, MSG_MOVE_AXIS, onDrawMoveSubMenu, drawMoveMenu);
@@ -3023,6 +3085,10 @@ void drawPrepareMenu() {
30233085
REPEAT_1(PREHEAT_COUNT, _ITEM_PREHEAT)
30243086
#endif
30253087
MENU_ITEM(ICON_Cool, MSG_COOLDOWN, onDrawCooldown, doCoolDown);
3088+
#if ALL(PROUI_TUNING_GRAPH, PROUI_ITEM_PLOT)
3089+
MENU_ITEM(ICON_PIDNozzle, MSG_HOTEND_TEMP_GRAPH, onDrawMenuItem, drawHPlot);
3090+
MENU_ITEM(ICON_PIDBed, MSG_BED_TEMP_GRAPH, onDrawMenuItem, drawBPlot);
3091+
#endif
30263092
MENU_ITEM(ICON_Language, MSG_UI_LANGUAGE, onDrawLanguage, setLanguage);
30273093
}
30283094
ui.reset_status(true);
@@ -3304,7 +3370,7 @@ void drawFilSetMenu() {
33043370

33053371
void drawTuneMenu() {
33063372
checkkey = ID_Menu;
3307-
if (SET_MENU_R(tuneMenu, selrect({73, 2, 28, 12}), MSG_TUNE, 18)) {
3373+
if (SET_MENU_R(tuneMenu, selrect({73, 2, 28, 12}), MSG_TUNE, 20)) {
33083374
BACK_ITEM(gotoPrintProcess);
33093375
EDIT_ITEM(ICON_Speed, MSG_SPEED, onDrawSpeedItem, setSpeed, &feedrate_percentage);
33103376
#if HAS_HOTEND
@@ -3350,6 +3416,10 @@ void drawTuneMenu() {
33503416
#if ENABLED(EDITABLE_DISPLAY_TIMEOUT)
33513417
EDIT_ITEM(ICON_Brightness, MSG_SCREEN_TIMEOUT, onDrawPIntMenu, setTimer, &ui.backlight_timeout_minutes);
33523418
#endif
3419+
#if ALL(PROUI_TUNING_GRAPH, PROUI_ITEM_PLOT)
3420+
MENU_ITEM(ICON_PIDNozzle, MSG_HOTEND_TEMP_GRAPH, onDrawMenuItem, drawHPlot);
3421+
MENU_ITEM(ICON_PIDBed, MSG_BED_TEMP_GRAPH, onDrawMenuItem, drawBPlot);
3422+
#endif
33533423
#if ENABLED(CASE_LIGHT_MENU)
33543424
EDIT_ITEM(ICON_CaseLight, MSG_CASE_LIGHT, onDrawChkbMenu, setCaseLight, &caselight.on);
33553425
#if CASELIGHT_USES_BRIGHTNESS

Marlin/src/lcd/e3v2/proui/dwin.h

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ enum processID : uint8_t {
6767
ID_WaitResponse,
6868
ID_Homing,
6969
ID_PIDProcess,
70+
ID_PlotProcess,
7071
ID_MPCProcess,
7172
ID_NothingToDo
7273
};

Marlin/src/lcd/e3v2/proui/dwin_defines.h

+3
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@
106106
#if ANY(PROUI_PID_TUNE, MPC_AUTOTUNE) && DISABLED(DISABLE_TUNING_GRAPH)
107107
#define PROUI_TUNING_GRAPH 1
108108
#endif
109+
#if PROUI_TUNING_GRAPH
110+
#define PROUI_ITEM_PLOT // Plot temp graph viewer
111+
#endif
109112
#define HAS_GCODE_PREVIEW 1 // Preview G-code model thumbnail
110113
#define HAS_CUSTOM_COLORS 1 // Change display colors
111114
#define HAS_ESDIAG 1 // View End-stop/Runout switch continuity

0 commit comments

Comments
 (0)