Skip to content

Commit 84f9490

Browse files
committed
🎨 Define HAS_PREHEAT conditional
1 parent 1fd4258 commit 84f9490

55 files changed

Lines changed: 183 additions & 182 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Marlin/src/gcode/bedlevel/G26.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ void GcodeSuite::G26() {
520520
g26.keep_heaters_on = parser.boolval('K');
521521

522522
// Accept 'I' if temperature presets are defined
523-
#if PREHEAT_COUNT
523+
#if HAS_PREHEAT
524524
const uint8_t preset_index = parser.seenval('I') ? _MIN(parser.value_byte(), PREHEAT_COUNT - 1) + 1 : 0;
525525
#endif
526526

@@ -530,7 +530,7 @@ void GcodeSuite::G26() {
530530
celsius_t bedtemp = 0;
531531

532532
// Use the 'I' index if temperature presets are defined
533-
#if PREHEAT_COUNT
533+
#if HAS_PREHEAT
534534
if (preset_index) bedtemp = ui.material_preset[preset_index - 1].bed_temp;
535535
#endif
536536

@@ -613,7 +613,7 @@ void GcodeSuite::G26() {
613613
celsius_t noztemp = 0;
614614

615615
// Accept 'I' if temperature presets are defined
616-
#if PREHEAT_COUNT
616+
#if HAS_PREHEAT
617617
if (preset_index) noztemp = ui.material_preset[preset_index - 1].hotend_temp;
618618
#endif
619619

Marlin/src/gcode/gcode.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
640640
case 120: M120(); break; // M120: Enable endstops
641641
case 121: M121(); break; // M121: Disable endstops
642642

643-
#if PREHEAT_COUNT
643+
#if HAS_PREHEAT
644644
case 145: M145(); break; // M145: Set material heatup parameters
645645
#endif
646646

Marlin/src/gcode/gcode.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ class GcodeSuite {
749749
static void M193();
750750
#endif
751751

752-
#if PREHEAT_COUNT
752+
#if HAS_PREHEAT
753753
static void M145();
754754
static void M145_report(const bool forReplay=true);
755755
#endif

Marlin/src/gcode/lcd/M145.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
#include "../../inc/MarlinConfig.h"
2424

25-
#if PREHEAT_COUNT
25+
#if HAS_PREHEAT
2626

2727
#include "../gcode.h"
2828
#include "../../lcd/marlinui.h"
@@ -79,4 +79,4 @@ void GcodeSuite::M145_report(const bool forReplay/*=true*/) {
7979
}
8080
}
8181

82-
#endif // PREHEAT_COUNT
82+
#endif // HAS_PREHEAT

Marlin/src/gcode/temp/M104_M109.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void GcodeSuite::M104_M109(const bool isM109) {
8888
celsius_t temp = 0;
8989

9090
// Accept 'I' if temperature presets are defined
91-
#if PREHEAT_COUNT
91+
#if HAS_PREHEAT
9292
got_temp = parser.seenval('I');
9393
if (got_temp) {
9494
const uint8_t index = parser.value_byte();

Marlin/src/gcode/temp/M106_M107.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#include "../../module/planner.h"
3333
#endif
3434

35-
#if PREHEAT_COUNT
35+
#if HAS_PREHEAT
3636
#include "../../lcd/marlinui.h"
3737
#endif
3838

@@ -75,7 +75,7 @@ void GcodeSuite::M106() {
7575
uint16_t speed = dspeed;
7676

7777
// Accept 'I' if temperature presets are defined
78-
#if PREHEAT_COUNT
78+
#if HAS_PREHEAT
7979
const bool got_preset = parser.seenval('I');
8080
if (got_preset) speed = ui.material_preset[_MIN(parser.value_byte(), PREHEAT_COUNT - 1)].fan_speed;
8181
#else

Marlin/src/gcode/temp/M140_M190.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void GcodeSuite::M140_M190(const bool isM190) {
6363
celsius_t temp = 0;
6464

6565
// Accept 'I' if temperature presets are defined
66-
#if PREHEAT_COUNT
66+
#if HAS_PREHEAT
6767
got_temp = parser.seenval('I');
6868
if (got_temp) {
6969
const uint8_t index = parser.value_byte();

Marlin/src/inc/Conditionals_post.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2874,10 +2874,14 @@
28742874
#elif defined(PREHEAT_1_LABEL)
28752875
#define PREHEAT_COUNT 1
28762876
#endif
2877+
#if PREHEAT_COUNT && ANY(HAS_HOTEND, HAS_HEATED_BED, HAS_FAN)
2878+
#define HAS_PREHEAT 1
2879+
#endif
28772880
#endif
28782881

2879-
#if !PREHEAT_COUNT
2882+
#if !HAS_PREHEAT
28802883
#undef PREHEAT_SHORTCUT_MENU_ITEM
2884+
#undef DGUS_PREHEAT_UI
28812885
#endif
28822886

28832887
/**

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

Lines changed: 81 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,9 @@ typedef struct {
165165
} select_t;
166166

167167
select_t select_page{0}, select_file{0}, select_print{0}, select_prepare{0}
168-
, select_control{0}, select_axis{0}, select_temp{0}, select_motion{0}, select_tune{0}
169-
, select_advset{0}, select_PLA{0}, select_ABS{0}
170-
, select_speed{0}
171-
, select_acc{0}
172-
, select_jerk{0}
173-
, select_step{0}
174-
, select_item{0}
175-
;
168+
, select_control{0}, select_axis{0}, select_temp{0}, select_motion{0}, select_tune{0}
169+
, select_advset{0}, select_PLA{0}, select_ABS{0}
170+
, select_speed{0}, select_acc{0}, select_jerk{0}, select_step{0}, select_item{0};
176171

177172
uint8_t index_file = MROWS,
178173
index_prepare = MROWS,
@@ -700,7 +695,7 @@ void Item_Prepare_Home(const uint8_t row) {
700695

701696
#endif
702697

703-
#if HAS_HOTEND
698+
#if HAS_PREHEAT
704699
void Item_Prepare_PLA(const uint8_t row) {
705700
if (HMI_IsChinese())
706701
Item_AreaCopy(100, 89, 151, 101, row);
@@ -715,22 +710,22 @@ void Item_Prepare_Home(const uint8_t row) {
715710
Draw_Menu_Line(row, ICON_PLAPreheat);
716711
}
717712

718-
void Item_Prepare_ABS(const uint8_t row) {
719-
if (HMI_IsChinese())
720-
Item_AreaCopy(180, 89, 233, 100, row);
721-
else {
722-
#ifdef USE_STRING_TITLES
723-
DWIN_Draw_Label(row, F("Preheat " PREHEAT_2_LABEL));
724-
#else
725-
Item_AreaCopy(108, 76, 155, 87, row); // "Preheat"
726-
say_abs_en(52, row); // "ABS"
727-
#endif
713+
#if PREHEAT_COUNT > 1
714+
void Item_Prepare_ABS(const uint8_t row) {
715+
if (HMI_IsChinese())
716+
Item_AreaCopy(180, 89, 233, 100, row);
717+
else {
718+
#ifdef USE_STRING_TITLES
719+
DWIN_Draw_Label(row, F("Preheat " PREHEAT_2_LABEL));
720+
#else
721+
Item_AreaCopy(108, 76, 155, 87, row); // "Preheat"
722+
say_abs_en(52, row); // "ABS"
723+
#endif
724+
}
725+
Draw_Menu_Line(row, ICON_ABSPreheat);
728726
}
729-
Draw_Menu_Line(row, ICON_ABSPreheat);
730-
}
731-
#endif
727+
#endif
732728

733-
#if HAS_PREHEAT
734729
void Item_Prepare_Cool(const uint8_t row) {
735730
if (HMI_IsChinese())
736731
Item_AreaCopy(1, 104, 56, 117, row);
@@ -785,11 +780,11 @@ void Draw_Prepare_Menu() {
785780
#if HAS_ZOFFSET_ITEM
786781
if (PVISI(PREPARE_CASE_ZOFF)) Item_Prepare_Offset(PSCROL(PREPARE_CASE_ZOFF)); // Edit Z-Offset / Babystep / Set Home Offset
787782
#endif
788-
#if HAS_HOTEND
789-
if (PVISI(PREPARE_CASE_PLA)) Item_Prepare_PLA(PSCROL(PREPARE_CASE_PLA)); // Preheat PLA
790-
if (PVISI(PREPARE_CASE_ABS)) Item_Prepare_ABS(PSCROL(PREPARE_CASE_ABS)); // Preheat ABS
791-
#endif
792783
#if HAS_PREHEAT
784+
if (PVISI(PREPARE_CASE_PLA)) Item_Prepare_PLA(PSCROL(PREPARE_CASE_PLA)); // Preheat PLA
785+
#if PREHEAT_COUNT > 1
786+
if (PVISI(PREPARE_CASE_ABS)) Item_Prepare_ABS(PSCROL(PREPARE_CASE_ABS)); // Preheat ABS
787+
#endif
793788
if (PVISI(PREPARE_CASE_COOL)) Item_Prepare_Cool(PSCROL(PREPARE_CASE_COOL)); // Cooldown
794789
#endif
795790
if (PVISI(PREPARE_CASE_LANG)) Item_Prepare_Lang(PSCROL(PREPARE_CASE_LANG)); // Language CN/EN
@@ -1425,25 +1420,34 @@ void HMI_Move_Z() {
14251420
uint8_t temp_line;
14261421
switch (HMI_ValueStruct.show_mode) {
14271422
case -1: temp_line = TEMP_CASE_TEMP; break;
1428-
case -2: temp_line = PREHEAT_CASE_TEMP; break;
1429-
case -3: temp_line = PREHEAT_CASE_TEMP; break;
1423+
#if HAS_PREHEAT
1424+
case -2: temp_line = PREHEAT_CASE_TEMP; break;
1425+
#if PREHEAT_COUNT > 1
1426+
case -3: temp_line = PREHEAT_CASE_TEMP; break;
1427+
#endif
1428+
#endif
14301429
default: temp_line = TUNE_CASE_TEMP + MROWS - index_tune;
14311430
}
14321431
if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.E_Temp)) {
14331432
EncoderRate.enabled = false;
1434-
if (HMI_ValueStruct.show_mode == -2) {
1435-
checkkey = PLAPreheat;
1436-
ui.material_preset[0].hotend_temp = HMI_ValueStruct.E_Temp;
1437-
Draw_Edit_Integer3(temp_line, ui.material_preset[0].hotend_temp);
1438-
return;
1439-
}
1440-
else if (HMI_ValueStruct.show_mode == -3) {
1441-
checkkey = ABSPreheat;
1442-
ui.material_preset[1].hotend_temp = HMI_ValueStruct.E_Temp;
1443-
Draw_Edit_Integer3(temp_line, ui.material_preset[1].hotend_temp);
1444-
return;
1445-
}
1446-
else if (HMI_ValueStruct.show_mode == -1) // Temperature
1433+
#if HAS_PREHEAT
1434+
if (HMI_ValueStruct.show_mode == -2) {
1435+
checkkey = PLAPreheat;
1436+
ui.material_preset[0].hotend_temp = HMI_ValueStruct.E_Temp;
1437+
Draw_Edit_Integer3(temp_line, ui.material_preset[0].hotend_temp);
1438+
return;
1439+
}
1440+
#if PREHEAT_COUNT > 1
1441+
if (HMI_ValueStruct.show_mode == -3) {
1442+
checkkey = ABSPreheat;
1443+
ui.material_preset[1].hotend_temp = HMI_ValueStruct.E_Temp;
1444+
Draw_Edit_Integer3(temp_line, ui.material_preset[1].hotend_temp);
1445+
return;
1446+
}
1447+
#endif
1448+
#endif
1449+
1450+
if (HMI_ValueStruct.show_mode == -1) // Temperature
14471451
checkkey = TemperatureID;
14481452
else
14491453
checkkey = Tune;
@@ -1467,28 +1471,33 @@ void HMI_Move_Z() {
14671471
uint8_t bed_line;
14681472
switch (HMI_ValueStruct.show_mode) {
14691473
case -1: bed_line = TEMP_CASE_BED; break;
1470-
case -2: bed_line = PREHEAT_CASE_BED; break;
1471-
case -3: bed_line = PREHEAT_CASE_BED; break;
1474+
#if HAS_PREHEAT
1475+
case -2: bed_line = PREHEAT_CASE_BED; break;
1476+
#if PREHEAT_COUNT > 1
1477+
case -3: bed_line = PREHEAT_CASE_BED; break;
1478+
#endif
1479+
#endif
14721480
default: bed_line = TUNE_CASE_BED + MROWS - index_tune;
14731481
}
14741482
if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Bed_Temp)) {
14751483
EncoderRate.enabled = false;
1476-
if (HMI_ValueStruct.show_mode == -2) {
1477-
checkkey = PLAPreheat;
1478-
ui.material_preset[0].bed_temp = HMI_ValueStruct.Bed_Temp;
1479-
Draw_Edit_Integer3(bed_line, ui.material_preset[0].bed_temp);
1480-
return;
1481-
}
1482-
else if (HMI_ValueStruct.show_mode == -3) {
1483-
checkkey = ABSPreheat;
1484-
ui.material_preset[1].bed_temp = HMI_ValueStruct.Bed_Temp;
1485-
Draw_Edit_Integer3(bed_line, ui.material_preset[1].bed_temp);
1486-
return;
1487-
}
1488-
else if (HMI_ValueStruct.show_mode == -1)
1489-
checkkey = TemperatureID;
1490-
else
1491-
checkkey = Tune;
1484+
#if HAS_PREHEAT
1485+
if (HMI_ValueStruct.show_mode == -2) {
1486+
checkkey = PLAPreheat;
1487+
ui.material_preset[0].bed_temp = HMI_ValueStruct.Bed_Temp;
1488+
Draw_Edit_Integer3(bed_line, ui.material_preset[0].bed_temp);
1489+
return;
1490+
}
1491+
#if PREHEAT_COUNT > 1
1492+
if (HMI_ValueStruct.show_mode == -3) {
1493+
checkkey = ABSPreheat;
1494+
ui.material_preset[1].bed_temp = HMI_ValueStruct.Bed_Temp;
1495+
Draw_Edit_Integer3(bed_line, ui.material_preset[1].bed_temp);
1496+
return;
1497+
}
1498+
#endif
1499+
#endif
1500+
checkkey = HMI_ValueStruct.show_mode == -1 ? TemperatureID : Tune;
14921501
Draw_Edit_Integer3(bed_line, HMI_ValueStruct.Bed_Temp);
14931502
thermalManager.setTargetBed(HMI_ValueStruct.Bed_Temp);
14941503
return;
@@ -1522,16 +1531,15 @@ void HMI_Move_Z() {
15221531
Draw_Edit_Integer3(fan_line, ui.material_preset[0].fan_speed);
15231532
return;
15241533
}
1525-
else if (HMI_ValueStruct.show_mode == -3) {
1526-
checkkey = ABSPreheat;
1527-
ui.material_preset[1].fan_speed = HMI_ValueStruct.Fan_speed;
1528-
Draw_Edit_Integer3(fan_line, ui.material_preset[1].fan_speed);
1529-
return;
1530-
}
1531-
else if (HMI_ValueStruct.show_mode == -1)
1532-
checkkey = TemperatureID;
1533-
else
1534-
checkkey = Tune;
1534+
#if PREHEAT_COUNT > 1
1535+
if (HMI_ValueStruct.show_mode == -3) {
1536+
checkkey = ABSPreheat;
1537+
ui.material_preset[1].fan_speed = HMI_ValueStruct.Fan_speed;
1538+
Draw_Edit_Integer3(fan_line, ui.material_preset[1].fan_speed);
1539+
return;
1540+
}
1541+
#endif
1542+
checkkey = HMI_ValueStruct.show_mode == -1 ? TemperatureID : Tune;
15351543
Draw_Edit_Integer3(fan_line, HMI_ValueStruct.Fan_speed);
15361544
thermalManager.set_fan_speed(0, HMI_ValueStruct.Fan_speed);
15371545
return;
@@ -3068,7 +3076,7 @@ void HMI_Temperature() {
30683076
EncoderRate.enabled = true;
30693077
break;
30703078
#endif
3071-
#if HAS_HOTEND
3079+
#if HAS_PREHEAT
30723080
case TEMP_CASE_PLA: {
30733081
checkkey = PLAPreheat;
30743082
select_PLA.reset();
@@ -3145,7 +3153,8 @@ void HMI_Temperature() {
31453153
Draw_Menu_Line(++i, ICON_WriteEEPROM);
31463154
#endif
31473155
} break;
3148-
3156+
#endif
3157+
#if PREHEAT_COUNT > 1
31493158
case TEMP_CASE_ABS: { // ABS preheat setting
31503159
checkkey = ABSPreheat;
31513160
select_ABS.reset();

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,6 @@
3131

3232
#include "../../../inc/MarlinConfigPre.h"
3333

34-
#if ANY(HAS_HOTEND, HAS_HEATED_BED, HAS_FAN) && PREHEAT_COUNT
35-
#define HAS_PREHEAT 1
36-
#if PREHEAT_COUNT < 2
37-
#error "Creality DWIN requires two material preheat presets."
38-
#endif
39-
#endif
40-
4134
enum processID : uint8_t {
4235
// Process ID
4336
MainMenu,
@@ -53,7 +46,9 @@ enum processID : uint8_t {
5346
Tune,
5447
#if HAS_PREHEAT
5548
PLAPreheat,
56-
ABSPreheat,
49+
#if PREHEAT_COUNT > 1
50+
ABSPreheat,
51+
#endif
5752
#endif
5853
MaxSpeed,
5954
MaxSpeed_value,

0 commit comments

Comments
 (0)