Browse Source

🎨 Standard material presets behavior

vanilla_fb_2.0.x
Scott Lahteine 3 years ago
committed by Scott Lahteine
parent
commit
205d867e4b
  1. 211
      Marlin/src/lcd/e3v2/creality/dwin.cpp
  2. 18
      Marlin/src/lcd/e3v2/enhanced/dwin.cpp
  3. 110
      Marlin/src/lcd/e3v2/jyersui/dwin.cpp
  4. 54
      Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp
  5. 5
      Marlin/src/lcd/extui/ui_api.cpp
  6. 11
      Marlin/src/lcd/marlinui.cpp
  7. 8
      Marlin/src/lcd/marlinui.h

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

@ -166,8 +166,14 @@ typedef struct {
select_t select_page{0}, select_file{0}, select_print{0}, select_prepare{0}
, select_control{0}, select_axis{0}, select_temp{0}, select_motion{0}, select_tune{0}
, select_advset{0}, select_PLA{0}, select_ABS{0}
, select_speed{0}, select_acc{0}, select_jerk{0}, select_step{0}, select_item{0};
, select_advset{0}, select_speed{0}, select_acc{0}, select_jerk{0}, select_step{0}, select_item{0};
#if HAS_PREHEAT
select_t select_PLA{0};
#if PREHEAT_COUNT > 1
select_t select_ABS{0};
#endif
#endif
uint8_t index_file = MROWS,
index_prepare = MROWS,
@ -492,8 +498,8 @@ inline bool Apply_Encoder(const EncoderState &encoder_diffState, T &valref) {
#define PREPARE_CASE_DISA 2
#define PREPARE_CASE_HOME 3
#define PREPARE_CASE_ZOFF (PREPARE_CASE_HOME + ENABLED(HAS_ZOFFSET_ITEM))
#define PREPARE_CASE_PLA (PREPARE_CASE_ZOFF + ENABLED(HAS_HOTEND))
#define PREPARE_CASE_ABS (PREPARE_CASE_PLA + ENABLED(HAS_HOTEND))
#define PREPARE_CASE_PLA (PREPARE_CASE_ZOFF + ENABLED(HAS_PREHEAT))
#define PREPARE_CASE_ABS (PREPARE_CASE_PLA + (TERN0(HAS_PREHEAT, PREHEAT_COUNT > 1)))
#define PREPARE_CASE_COOL (PREPARE_CASE_ABS + EITHER(HAS_HOTEND, HAS_HEATED_BED))
#define PREPARE_CASE_LANG (PREPARE_CASE_COOL + 1)
#define PREPARE_CASE_TOTAL PREPARE_CASE_LANG
@ -517,8 +523,8 @@ inline bool Apply_Encoder(const EncoderState &encoder_diffState, T &valref) {
#define TEMP_CASE_TEMP (0 + ENABLED(HAS_HOTEND))
#define TEMP_CASE_BED (TEMP_CASE_TEMP + ENABLED(HAS_HEATED_BED))
#define TEMP_CASE_FAN (TEMP_CASE_BED + ENABLED(HAS_FAN))
#define TEMP_CASE_PLA (TEMP_CASE_FAN + ENABLED(HAS_HOTEND))
#define TEMP_CASE_ABS (TEMP_CASE_PLA + ENABLED(HAS_HOTEND))
#define TEMP_CASE_PLA (TEMP_CASE_FAN + ENABLED(HAS_PREHEAT))
#define TEMP_CASE_ABS (TEMP_CASE_PLA + (TERN0(HAS_PREHEAT, PREHEAT_COUNT > 1)))
#define TEMP_CASE_TOTAL TEMP_CASE_ABS
#define PREHEAT_CASE_TEMP (0 + ENABLED(HAS_HOTEND))
@ -785,6 +791,8 @@ void Draw_Prepare_Menu() {
#if PREHEAT_COUNT > 1
if (PVISI(PREPARE_CASE_ABS)) Item_Prepare_ABS(PSCROL(PREPARE_CASE_ABS)); // Preheat ABS
#endif
#endif
#if HAS_HOTEND || HAS_HEATED_BED
if (PVISI(PREPARE_CASE_COOL)) Item_Prepare_Cool(PSCROL(PREPARE_CASE_COOL)); // Cooldown
#endif
if (PVISI(PREPARE_CASE_LANG)) Item_Prepare_Lang(PSCROL(PREPARE_CASE_LANG)); // Language CN/EN
@ -2664,10 +2672,10 @@ void HMI_Prepare() {
// Draw "More" icon for sub-menus
if (index_prepare < 7) Draw_More_Icon(MROWS - index_prepare + 1);
#if HAS_HOTEND
#if PREHEAT_COUNT > 1
if (index_prepare == PREPARE_CASE_ABS) Item_Prepare_ABS(MROWS);
#endif
#if HAS_PREHEAT
#if HAS_HOTEND || HAS_HEATED_BED
if (index_prepare == PREPARE_CASE_COOL) Item_Prepare_Cool(MROWS);
#endif
if (index_prepare == PREPARE_CASE_LANG) Item_Prepare_Lang(MROWS);
@ -2743,16 +2751,13 @@ void HMI_Prepare() {
break;
#endif
#if HAS_PREHEAT
case PREPARE_CASE_PLA:
TERN_(HAS_HOTEND, thermalManager.setTargetHotend(ui.material_preset[0].hotend_temp, 0));
TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(ui.material_preset[0].bed_temp));
TERN_(HAS_FAN, thermalManager.set_fan_speed(0, ui.material_preset[0].fan_speed));
break;
case PREPARE_CASE_ABS:
TERN_(HAS_HOTEND, thermalManager.setTargetHotend(ui.material_preset[1].hotend_temp, 0));
TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(ui.material_preset[1].bed_temp));
TERN_(HAS_FAN, thermalManager.set_fan_speed(0, ui.material_preset[1].fan_speed));
break;
case PREPARE_CASE_PLA: ui.preheat_all(0); break;
#if PREHEAT_COUNT > 1
case PREPARE_CASE_ABS: ui.preheat_all(1); break;
#endif
#endif
#if HAS_HOTEND || HAS_HEATED_BED
case PREPARE_CASE_COOL:
TERN_(HAS_FAN, thermalManager.zero_fan_speeds());
#if HAS_HOTEND || HAS_HEATED_BED
@ -2760,6 +2765,7 @@ void HMI_Prepare() {
#endif
break;
#endif
case PREPARE_CASE_LANG:
HMI_ToggleLanguage();
Draw_Prepare_Menu();
@ -2784,9 +2790,11 @@ void Draw_Temperature_Menu() {
#if HAS_FAN
Item_AreaCopy(115, 134, 170, 146, TEMP_CASE_FAN);
#endif
#if HAS_HOTEND
#if HAS_PREHEAT
Item_AreaCopy(100, 89, 178, 101, TEMP_CASE_PLA);
Item_AreaCopy(180, 89, 260, 100, TEMP_CASE_ABS);
#if PREHEAT_COUNT > 1
Item_AreaCopy(180, 89, 260, 100, TEMP_CASE_ABS);
#endif
#endif
}
else {
@ -2805,30 +2813,33 @@ void Draw_Temperature_Menu() {
#if HAS_FAN
DWIN_Draw_Label(TEMP_CASE_FAN, GET_TEXT_F(MSG_FAN_SPEED));
#endif
#if HAS_HOTEND
#if HAS_PREHEAT
DWIN_Draw_Label(TEMP_CASE_PLA, F(PREHEAT_1_LABEL " Preheat Settings"));
DWIN_Draw_Label(TEMP_CASE_ABS, F(PREHEAT_2_LABEL " Preheat Settings"));
#if PREHEAT_COUNT > 1
DWIN_Draw_Label(TEMP_CASE_ABS, F(PREHEAT_2_LABEL " Preheat Settings"));
#endif
#endif
#else
#if HAS_HOTEND
Item_AreaCopy(197, 104, 238, 114, TEMP_CASE_TEMP); // "Nozzle"
Item_AreaCopy(1, 89, 83, 101, TEMP_CASE_TEMP, 44); // "Temperature"
Item_AreaCopy(197, 104, 238, 114, TEMP_CASE_TEMP); // "Nozzle"
Item_AreaCopy(1, 89, 83, 101, TEMP_CASE_TEMP, 44); // "Temperature"
#endif
#if HAS_HEATED_BED
Item_AreaCopy(240, 104, 264, 114, TEMP_CASE_BED); // "Bed"
Item_AreaCopy(1, 89, 83, 101, TEMP_CASE_BED, 27); // "Temperature"
Item_AreaCopy(240, 104, 264, 114, TEMP_CASE_BED); // "Bed"
Item_AreaCopy(1, 89, 83, 101, TEMP_CASE_BED, 27); // "Temperature"
#endif
#if HAS_FAN
Item_AreaCopy( 1, 119, 61, 132, TEMP_CASE_FAN); // "Fan speed"
Item_AreaCopy( 1, 119, 61, 132, TEMP_CASE_FAN); // "Fan speed"
#endif
#if HAS_HOTEND
Item_AreaCopy(107, 76, 156, 86, TEMP_CASE_PLA); // "Preheat"
say_pla_en(52, TEMP_CASE_PLA); // "PLA"
Item_AreaCopy(150, 135, 202, 148, TEMP_CASE_PLA, 79); // "Settings"
Item_AreaCopy(107, 76, 156, 86, TEMP_CASE_ABS); // "Preheat"
say_abs_en(52, TEMP_CASE_ABS); // "ABS"
Item_AreaCopy(150, 135, 202, 148, TEMP_CASE_ABS, 81); // "Settings"
#if HAS_PREHEAT
Item_AreaCopy(107, 76, 156, 86, TEMP_CASE_PLA); // "Preheat"
say_pla_en(52, TEMP_CASE_PLA); // "PLA"
Item_AreaCopy(150, 135, 202, 148, TEMP_CASE_PLA, 79); // "Settings"
#if PREHEAT_COUNT > 1
Item_AreaCopy(107, 76, 156, 86, TEMP_CASE_ABS); // "Preheat"
say_abs_en(52, TEMP_CASE_ABS); // "ABS"
Item_AreaCopy(150, 135, 202, 148, TEMP_CASE_ABS, 81); // "Settings"
#endif
#endif
#endif
}
@ -2851,12 +2862,12 @@ void Draw_Temperature_Menu() {
_TMENU_ICON(TEMP_CASE_FAN);
Draw_Edit_Integer3(i, thermalManager.fan_speed[0]);
#endif
#if HAS_HOTEND
#if HAS_PREHEAT
// PLA/ABS items have submenus
_TMENU_ICON(TEMP_CASE_PLA);
Draw_More_Icon(i);
_TMENU_ICON(TEMP_CASE_ABS);
Draw_More_Icon(i);
_TMENU_ICON(TEMP_CASE_PLA); Draw_More_Icon(i);
#if PREHEAT_COUNT > 1
_TMENU_ICON(TEMP_CASE_ABS); Draw_More_Icon(i);
#endif
#endif
}
@ -3076,6 +3087,7 @@ void HMI_Temperature() {
EncoderRate.enabled = true;
break;
#endif
#if HAS_PREHEAT
case TEMP_CASE_PLA: {
checkkey = PLAPreheat;
@ -3153,7 +3165,8 @@ void HMI_Temperature() {
Draw_Menu_Line(++i, ICON_WriteEEPROM);
#endif
} break;
#endif
#endif // HAS_PREHEAT
#if PREHEAT_COUNT > 1
case TEMP_CASE_ABS: { // ABS preheat setting
checkkey = ABSPreheat;
@ -3236,7 +3249,7 @@ void HMI_Temperature() {
} break;
#endif // HAS_HOTEND
#endif // PREHEAT_COUNT > 1
}
}
DWIN_UpdateLCD();
@ -3579,14 +3592,12 @@ void HMI_AdvSet() {
#if HAS_HOTEND
case ADVSET_CASE_HEPID:
thermalManager.setTargetHotend(ui.material_preset[0].hotend_temp, 0);
thermalManager.PID_autotune(ui.material_preset[0].hotend_temp, H_E0, 10, true);
break;
#endif
#if HAS_HEATED_BED
case ADVSET_CASE_BEDPID:
thermalManager.setTargetBed(ui.material_preset[0].bed_temp);
thermalManager.PID_autotune(ui.material_preset[0].bed_temp, H_BED, 10, true);
break;
#endif
@ -3881,63 +3892,65 @@ void HMI_Tune() {
DWIN_UpdateLCD();
}
// ABS Preheat
void HMI_ABSPreheatSetting() {
EncoderState encoder_diffState = get_encoder_state();
if (encoder_diffState == ENCODER_DIFF_NO) return;
// Avoid flicker by updating only the previous menu
if (encoder_diffState == ENCODER_DIFF_CW) {
if (select_ABS.inc(1 + PREHEAT_CASE_TOTAL)) Move_Highlight(1, select_ABS.now);
}
else if (encoder_diffState == ENCODER_DIFF_CCW) {
if (select_ABS.dec()) Move_Highlight(-1, select_ABS.now);
}
else if (encoder_diffState == ENCODER_DIFF_ENTER) {
switch (select_ABS.now) {
case CASE_BACK:
checkkey = TemperatureID;
select_temp.now = TEMP_CASE_ABS;
HMI_ValueStruct.show_mode = -1;
Draw_Temperature_Menu();
break;
#if HAS_HOTEND
case PREHEAT_CASE_TEMP:
checkkey = ETemp;
HMI_ValueStruct.E_Temp = ui.material_preset[1].hotend_temp;
Draw_Edit_Integer3(PREHEAT_CASE_TEMP, ui.material_preset[1].hotend_temp, true);
EncoderRate.enabled = true;
break;
#endif
#if HAS_HEATED_BED
case PREHEAT_CASE_BED:
checkkey = BedTemp;
HMI_ValueStruct.Bed_Temp = ui.material_preset[1].bed_temp;
Draw_Edit_Integer3(PREHEAT_CASE_BED, ui.material_preset[1].bed_temp, true);
EncoderRate.enabled = true;
break;
#endif
#if HAS_FAN
case PREHEAT_CASE_FAN:
checkkey = FanSpeed;
HMI_ValueStruct.Fan_speed = ui.material_preset[1].fan_speed;
Draw_Edit_Integer3(PREHEAT_CASE_FAN, ui.material_preset[1].fan_speed, true);
EncoderRate.enabled = true;
#if PREHEAT_COUNT > 1
// ABS Preheat
void HMI_ABSPreheatSetting() {
EncoderState encoder_diffState = get_encoder_state();
if (encoder_diffState == ENCODER_DIFF_NO) return;
// Avoid flicker by updating only the previous menu
if (encoder_diffState == ENCODER_DIFF_CW) {
if (select_ABS.inc(1 + PREHEAT_CASE_TOTAL)) Move_Highlight(1, select_ABS.now);
}
else if (encoder_diffState == ENCODER_DIFF_CCW) {
if (select_ABS.dec()) Move_Highlight(-1, select_ABS.now);
}
else if (encoder_diffState == ENCODER_DIFF_ENTER) {
switch (select_ABS.now) {
case CASE_BACK:
checkkey = TemperatureID;
select_temp.now = TEMP_CASE_ABS;
HMI_ValueStruct.show_mode = -1;
Draw_Temperature_Menu();
break;
#endif
#if ENABLED(EEPROM_SETTINGS)
case PREHEAT_CASE_SAVE: {
const bool success = settings.save();
HMI_AudioFeedback(success);
} break;
#endif
default: break;
#if HAS_HOTEND
case PREHEAT_CASE_TEMP:
checkkey = ETemp;
HMI_ValueStruct.E_Temp = ui.material_preset[1].hotend_temp;
Draw_Edit_Integer3(PREHEAT_CASE_TEMP, ui.material_preset[1].hotend_temp, true);
EncoderRate.enabled = true;
break;
#endif
#if HAS_HEATED_BED
case PREHEAT_CASE_BED:
checkkey = BedTemp;
HMI_ValueStruct.Bed_Temp = ui.material_preset[1].bed_temp;
Draw_Edit_Integer3(PREHEAT_CASE_BED, ui.material_preset[1].bed_temp, true);
EncoderRate.enabled = true;
break;
#endif
#if HAS_FAN
case PREHEAT_CASE_FAN:
checkkey = FanSpeed;
HMI_ValueStruct.Fan_speed = ui.material_preset[1].fan_speed;
Draw_Edit_Integer3(PREHEAT_CASE_FAN, ui.material_preset[1].fan_speed, true);
EncoderRate.enabled = true;
break;
#endif
#if ENABLED(EEPROM_SETTINGS)
case PREHEAT_CASE_SAVE: {
const bool success = settings.save();
HMI_AudioFeedback(success);
} break;
#endif
default: break;
}
}
DWIN_UpdateLCD();
}
DWIN_UpdateLCD();
}
#endif // PREHEAT_COUNT > 1
#endif
#endif // HAS_PREHEAT
// Max Speed
void HMI_MaxSpeed() {
@ -4241,7 +4254,9 @@ void DWIN_HandleScreen() {
case Tune: HMI_Tune(); break;
#if HAS_PREHEAT
case PLAPreheat: HMI_PLAPreheatSetting(); break;
case ABSPreheat: HMI_ABSPreheatSetting(); break;
#if PREHEAT_COUNT > 1
case ABSPreheat: HMI_ABSPreheatSetting(); break;
#endif
#endif
case MaxSpeed: HMI_MaxSpeed(); break;
case MaxAcceleration: HMI_MaxAcceleration(); break;

18
Marlin/src/lcd/e3v2/enhanced/dwin.cpp

@ -2116,21 +2116,15 @@ void SetHome() {
#endif
#if HAS_PREHEAT
void SetPreheat(const uint8_t i) {
TERN_(HAS_HOTEND, thermalManager.setTargetHotend(ui.material_preset[i].hotend_temp, 0));
TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(ui.material_preset[i].bed_temp));
TERN_(HAS_FAN, thermalManager.set_fan_speed(0, ui.material_preset[i].fan_speed));
}
void SetPreheat0() { SetPreheat(0); }
void SetPreheat1() { SetPreheat(1); }
void SetPreheat2() { SetPreheat(2); }
void SetCoolDown() {
TERN_(HAS_FAN, thermalManager.zero_fan_speeds());
#if HAS_HOTEND || HAS_HEATED_BED
thermalManager.disable_all_heaters();
#endif
}
void DoPreheat0() { ui.preheat_all(0); }
void DoPreheat1() { ui.preheat_all(1); }
void DoPreheat2() { ui.preheat_all(2); }
#endif
void SetLanguage() {
@ -3125,12 +3119,12 @@ void Draw_Prepare_Menu() {
#endif
#endif
#if HAS_PREHEAT
ADDMENUITEM(ICON_PLAPreheat, GET_TEXT_F(MSG_PREHEAT_1), onDrawPreheat1, SetPreheat0);
ADDMENUITEM(ICON_PLAPreheat, GET_TEXT_F(MSG_PREHEAT_1), onDrawPreheat1, DoPreheat0);
#if PREHEAT_COUNT > 1
ADDMENUITEM(ICON_ABSPreheat, PSTR("Preheat " PREHEAT_2_LABEL), onDrawPreheat2, SetPreheat1);
ADDMENUITEM(ICON_ABSPreheat, PSTR("Preheat " PREHEAT_2_LABEL), onDrawPreheat2, DoPreheat1);
#endif
#if PREHEAT_COUNT > 2
ADDMENUITEM(ICON_CustomPreheat, GET_TEXT_F(MSG_PREHEAT_CUSTOM), onDrawMenuItem, SetPreheat2);
ADDMENUITEM(ICON_CustomPreheat, GET_TEXT_F(MSG_PREHEAT_CUSTOM), onDrawMenuItem, DoPreheat2);
#endif
ADDMENUITEM(ICON_Cool, GET_TEXT_F(MSG_COOLDOWN), onDrawCooldown, SetCoolDown);
#endif

110
Marlin/src/lcd/e3v2/jyersui/dwin.cpp

@ -1584,9 +1584,9 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
}
break;
#endif
#if HAS_PREHEAT
case Preheat:
#if HAS_PREHEAT
case Preheat: {
#define PREHEAT_BACK 0
#define PREHEAT_MODE (PREHEAT_BACK + 1)
#define PREHEAT_1 (PREHEAT_MODE + 1)
@ -1596,6 +1596,13 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
#define PREHEAT_5 (PREHEAT_4 + (PREHEAT_COUNT >= 5))
#define PREHEAT_TOTAL PREHEAT_5
auto do_preheat = [](const uint8_t m) {
thermalManager.disable_all_heaters();
TERN_(HAS_FAN, thermalManager.zero_fan_speeds());
if (preheatmode == 0 || preheatmode == 1) { ui.preheat_hotend_and_fan(m); }
if (preheatmode == 0 || preheatmode == 2) ui.preheat_bed(m);
};
switch (item) {
case PREHEAT_BACK:
if (draw)
@ -1616,17 +1623,8 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
case PREHEAT_1:
if (draw)
Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_1_LABEL));
else {
thermalManager.disable_all_heaters();
TERN_(HAS_FAN, thermalManager.zero_fan_speeds());
if (preheatmode == 0 || preheatmode == 1) {
TERN_(HAS_HOTEND, thermalManager.setTargetHotend(ui.material_preset[0].hotend_temp, 0));
TERN_(HAS_FAN, thermalManager.set_fan_speed(0, ui.material_preset[0].fan_speed));
}
#if HAS_HEATED_BED
if (preheatmode == 0 || preheatmode == 2) thermalManager.setTargetBed(ui.material_preset[0].bed_temp);
#endif
}
else
do_preheat(0);
break;
#endif
@ -1634,17 +1632,8 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
case PREHEAT_2:
if (draw)
Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_2_LABEL));
else {
thermalManager.disable_all_heaters();
TERN_(HAS_FAN, thermalManager.zero_fan_speeds());
if (preheatmode == 0 || preheatmode == 1) {
TERN_(HAS_HOTEND, thermalManager.setTargetHotend(ui.material_preset[1].hotend_temp, 0));
TERN_(HAS_FAN, thermalManager.set_fan_speed(0, ui.material_preset[1].fan_speed));
}
#if HAS_HEATED_BED
if (preheatmode == 0 || preheatmode == 2) thermalManager.setTargetBed(ui.material_preset[1].bed_temp);
#endif
}
else
do_preheat(1);
break;
#endif
@ -1652,17 +1641,8 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
case PREHEAT_3:
if (draw)
Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_3_LABEL));
else {
thermalManager.disable_all_heaters();
TERN_(HAS_FAN, thermalManager.zero_fan_speeds());
if (preheatmode == 0 || preheatmode == 1) {
TERN_(HAS_HOTEND, thermalManager.setTargetHotend(ui.material_preset[2].hotend_temp, 0));
TERN_(HAS_FAN, thermalManager.set_fan_speed(0, ui.material_preset[2].fan_speed));
}
#if HAS_HEATED_BED
if (preheatmode == 0 || preheatmode == 2) thermalManager.setTargetBed(ui.material_preset[2].bed_temp);
#endif
}
else
do_preheat(2);
break;
#endif
@ -1670,17 +1650,8 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
case PREHEAT_4:
if (draw)
Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_4_LABEL));
else {
thermalManager.disable_all_heaters();
TERN_(HAS_FAN, thermalManager.zero_fan_speeds());
if (preheatmode == 0 || preheatmode == 1) {
TERN_(HAS_HOTEND, thermalManager.setTargetHotend(ui.material_preset[3].hotend_temp, 0));
TERN_(HAS_FAN, thermalManager.set_fan_speed(0, ui.material_preset[3].fan_speed));
}
#if HAS_HEATED_BED
if (preheatmode == 0 || preheatmode == 2) thermalManager.setTargetBed(ui.material_preset[3].bed_temp);
#endif
}
else
do_preheat(3);
break;
#endif
@ -1688,22 +1659,13 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
case PREHEAT_5:
if (draw)
Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_5_LABEL));
else {
thermalManager.disable_all_heaters();
TERN_(HAS_FAN, thermalManager.zero_fan_speeds());
if (preheatmode == 0 || preheatmode == 1) {
TERN_(HAS_HOTEND, thermalManager.setTargetHotend(ui.material_preset[4].hotend_temp, 0));
TERN_(HAS_FAN, thermalManager.set_fan_speed(0, ui.material_preset[4].fan_speed));
}
#if HAS_HEATED_BED
if (preheatmode == 0 || preheatmode == 2) thermalManager.setTargetBed(ui.material_preset[4].bed_temp);
#endif
}
else
do_preheat(4);
break;
#endif
}
break;
#endif
} break;
#endif // HAS_PREHEAT
#if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
case ChangeFilament:
@ -3964,50 +3926,40 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
case PREHEATHOTEND_1:
if (draw)
Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_1_LABEL));
else {
thermalManager.setTargetHotend(ui.material_preset[0].hotend_temp, 0);
thermalManager.set_fan_speed(0, ui.material_preset[0].fan_speed);
}
else
ui.preheat_hotend_and_fan(0);
break;
#endif
#if PREHEAT_COUNT >= 2
case PREHEATHOTEND_2:
if (draw)
Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_2_LABEL));
else {
thermalManager.setTargetHotend(ui.material_preset[1].hotend_temp, 0);
thermalManager.set_fan_speed(0, ui.material_preset[1].fan_speed);
}
else
ui.preheat_hotend_and_fan(1);
break;
#endif
#if PREHEAT_COUNT >= 3
case PREHEATHOTEND_3:
if (draw)
Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_3_LABEL));
else {
thermalManager.setTargetHotend(ui.material_preset[2].hotend_temp, 0);
thermalManager.set_fan_speed(0, ui.material_preset[2].fan_speed);
}
else
ui.preheat_hotend_and_fan(2);
break;
#endif
#if PREHEAT_COUNT >= 4
case PREHEATHOTEND_4:
if (draw)
Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_4_LABEL));
else {
thermalManager.setTargetHotend(ui.material_preset[3].hotend_temp, 0);
thermalManager.set_fan_speed(0, ui.material_preset[3].fan_speed);
}
else
ui.preheat_hotend_and_fan(3);
break;
#endif
#if PREHEAT_COUNT >= 5
case PREHEATHOTEND_5:
if (draw)
Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_5_LABEL));
else {
thermalManager.setTargetHotend(ui.material_preset[4].hotend_temp, 0);
thermalManager.set_fan_speed(0, ui.material_preset[4].fan_speed);
}
else
ui.preheat_hotend_and_fan(4);
break;
#endif
case PREHEATHOTEND_CUSTOM:

54
Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp

@ -621,55 +621,19 @@ void DGUSScreenHandler::HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr
void DGUSScreenHandler::HandlePreheat(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("HandlePreheat");
uint8_t e_temp = 0;
#if HAS_HEATED_BED
uint8_t bed_temp = 0;
#endif
const uint16_t preheat_option = swap16(*(uint16_t*)val_ptr);
switch (preheat_option) {
default:
case 0: // Preheat PLA
#if defined(PREHEAT_1_TEMP_HOTEND) && defined(PREHEAT_1_TEMP_BED)
e_temp = PREHEAT_1_TEMP_HOTEND;
TERN_(HAS_HEATED_BED, bed_temp = PREHEAT_1_TEMP_BED);
#endif
break;
case 1: // Preheat ABS
#if defined(PREHEAT_2_TEMP_HOTEND) && defined(PREHEAT_2_TEMP_BED)
e_temp = PREHEAT_2_TEMP_HOTEND;
TERN_(HAS_HEATED_BED, bed_temp = PREHEAT_2_TEMP_BED);
#endif
break;
case 2: // Preheat PET
#if defined(PREHEAT_3_TEMP_HOTEND) && defined(PREHEAT_3_TEMP_BED)
e_temp = PREHEAT_3_TEMP_HOTEND;
TERN_(HAS_HEATED_BED, bed_temp = PREHEAT_3_TEMP_BED);
#endif
break;
case 3: // Preheat FLEX
#if defined(PREHEAT_4_TEMP_HOTEND) && defined(PREHEAT_4_TEMP_BED)
e_temp = PREHEAT_4_TEMP_HOTEND;
TERN_(HAS_HEATED_BED, bed_temp = PREHEAT_4_TEMP_BED);
#endif
break;
switch (var.VP) {
default: return;
case VP_E0_BED_PREHEAT: TERN_(HAS_HOTEND, ui.preheat_all(0)); break;
case VP_E1_BED_PREHEAT: TERN_(HAS_MULTI_HOTEND, ui.preheat_all(1)); break;
}
case 7: break; // Custom preheat
case 9: break; // Cool down
}
switch (var.VP) {
default: return;
#if HAS_HOTEND
case VP_E0_BED_PREHEAT:
thermalManager.setTargetHotend(e_temp, 0);
TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(bed_temp));
break;
#endif
#if HOTENDS >= 2
case VP_E1_BED_PREHEAT:
thermalManager.setTargetHotend(e_temp, 1);
TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(bed_temp));
break;
#endif
case 9: // Cool down
thermalManager.zero_fan_speeds();
thermalManager.disable_all_heaters();
break;
}
// Go to the preheat screen to show the heating progress

5
Marlin/src/lcd/extui/ui_api.cpp

@ -1035,10 +1035,7 @@ namespace ExtUI {
void setFeedrate_percent(const_float_t value) { feedrate_percentage = constrain(value, 10, 500); }
void coolDown() {
#if HAS_HOTEND
HOTEND_LOOP() thermalManager.setTargetHotend(0, e);
#endif
TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(0));
thermalManager.disable_all_heaters();
TERN_(HAS_FAN, thermalManager.zero_fan_speeds());
}

11
Marlin/src/lcd/marlinui.cpp

@ -135,7 +135,10 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
#endif
#if HAS_PREHEAT
#include "../module/temperature.h"
preheat_t MarlinUI::material_preset[PREHEAT_COUNT]; // Initialized by settings.load()
PGM_P MarlinUI::get_preheat_label(const uint8_t m) {
#define _PDEF(N) static PGMSTR(preheat_##N##_label, PREHEAT_##N##_LABEL);
#define _PLBL(N) preheat_##N##_label,
@ -143,6 +146,14 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
static PGM_P const preheat_labels[PREHEAT_COUNT] PROGMEM = { REPEAT_1(PREHEAT_COUNT, _PLBL) };
return (PGM_P)pgm_read_ptr(&preheat_labels[m]);
}
void MarlinUI::apply_preheat(const uint8_t m, const uint8_t pmask, const uint8_t e/*=active_extruder*/) {
const preheat_t &pre = material_preset[m];
TERN_(HAS_HOTEND, if (TEST(pmask, PM_HOTEND)) thermalManager.setTargetHotend(pre.hotend_temp, e));
TERN_(HAS_HEATED_BED, if (TEST(pmask, PM_BED)) thermalManager.setTargetBed(pre.bed_temp));
//TERN_(HAS_HEATED_CHAMBER, if (TEST(pmask, PM_CHAMBER)) thermalManager.setTargetBed(pre.chamber_temp));
TERN_(HAS_FAN, if (TEST(pmask, PM_FAN)) thermalManager.set_fan_speed(0, pre.fan_speed));
}
#endif
#if EITHER(HAS_LCD_MENU, EXTENSIBLE_UI)

8
Marlin/src/lcd/marlinui.h

@ -56,7 +56,6 @@
#if ENABLED(ADVANCED_PAUSE_FEATURE) && ANY(HAS_LCD_MENU, EXTENSIBLE_UI, HAS_DWIN_E3V2)
#include "../feature/pause.h"
#include "../module/motion.h" // for active_extruder
#endif
#if ENABLED(DWIN_CREALITY_LCD)
@ -498,8 +497,15 @@ public:
#endif
#if HAS_PREHEAT
enum PreheatMask : uint8_t { PM_HOTEND = _BV(0), PM_BED = _BV(1), PM_FAN = _BV(2), PM_CHAMBER = _BV(3) };
static preheat_t material_preset[PREHEAT_COUNT];
static PGM_P get_preheat_label(const uint8_t m);
static void apply_preheat(const uint8_t m, const uint8_t pmask, const uint8_t e=active_extruder);
static inline void preheat_set_fan(const uint8_t m) { TERN_(HAS_FAN, apply_preheat(m, PM_FAN)); }
static inline void preheat_hotend(const uint8_t m, const uint8_t e=active_extruder) { TERN_(HAS_HOTEND, apply_preheat(m, PM_HOTEND)); }
static inline void preheat_hotend_and_fan(const uint8_t m, const uint8_t e=active_extruder) { preheat_hotend(m, e); preheat_set_fan(m); }
static inline void preheat_bed(const uint8_t m) { TERN_(HAS_HEATED_BED, apply_preheat(m, PM_BED)); }
static inline void preheat_all(const uint8_t m) { apply_preheat(m, 0xFF); }
#endif
#if SCREENS_CAN_TIME_OUT

Loading…
Cancel
Save