MKS / E3V2 LCD code cleanup

This commit is contained in:
Scott Lahteine
2021-03-19 16:41:47 -05:00
committed by Scott Lahteine
parent f7aaa2e1c7
commit 58f0330d3f
12 changed files with 210 additions and 308 deletions

View File

@ -102,19 +102,11 @@
#define DWIN_FONT_HEAD font10x20
#define MENU_CHAR_LIMIT 24
#define STATUS_Y 360
// Fan speed limit
#define FANON 255
#define FANOFF 0
#define STATUS_Y 360
// Print speed limit
#define MAX_PRINT_SPEED 999
#define MIN_PRINT_SPEED 10
#if HAS_HEATED_BED
#define MIN_BED_TEMP BED_MINTEMP
#endif
#define MIN_PRINT_SPEED 10
#define MAX_PRINT_SPEED 999
// Feedspeed limit (max feedspeed = DEFAULT_MAX_FEEDRATE * 2)
#define MIN_MAXFEEDSPEED 1
@ -883,11 +875,11 @@ void Draw_Tune_Menu() {
#if HAS_HOTEND
Draw_Menu_Line(TUNE_CASE_TEMP, ICON_HotendTemp);
DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_TEMP), thermalManager.temp_hotend[0].target);
DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_TEMP), thermalManager.degTargetHotend(0));
#endif
#if HAS_HEATED_BED
Draw_Menu_Line(TUNE_CASE_BED, ICON_BedTemp);
DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_BED), thermalManager.temp_bed.target);
DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_BED), thermalManager.degTargetBed());
#endif
#if HAS_FAN
Draw_Menu_Line(TUNE_CASE_FAN, ICON_FanSpeed);
@ -1394,7 +1386,7 @@ void HMI_Move_Z() {
return;
}
// Bed_Temp limit
LIMIT(HMI_ValueStruct.Bed_Temp, MIN_BED_TEMP, BED_MAX_TARGET);
LIMIT(HMI_ValueStruct.Bed_Temp, BED_MINTEMP, BED_MAX_TARGET);
// Bed_Temp value
DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(bed_line), HMI_ValueStruct.Bed_Temp);
}
@ -1438,7 +1430,7 @@ void HMI_Move_Z() {
return;
}
// Fan_speed limit
LIMIT(HMI_ValueStruct.Fan_speed, FANOFF, FANON);
LIMIT(HMI_ValueStruct.Fan_speed, 0, 255);
// Fan_speed value
DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(fan_line), HMI_ValueStruct.Fan_speed);
}
@ -1882,9 +1874,9 @@ void Draw_Status_Area(const bool with_update) {
#if HAS_HOTEND
DWIN_ICON_Show(ICON, ICON_HotendTemp, 10, 383);
DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 28, 384, thermalManager.temp_hotend[0].celsius);
DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 28, 384, thermalManager.degHotend(0));
DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 25 + 3 * STAT_CHR_W + 5, 384, F("/"));
DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 384, thermalManager.temp_hotend[0].target);
DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 384, thermalManager.degTargetHotend(0));
DWIN_ICON_Show(ICON, ICON_StepE, 112, 417);
DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 116 + 2 * STAT_CHR_W, 417, planner.flow_percentage[0]);
@ -1893,9 +1885,9 @@ void Draw_Status_Area(const bool with_update) {
#if HAS_HEATED_BED
DWIN_ICON_Show(ICON, ICON_BedTemp, 10, 416);
DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 28, 417, thermalManager.temp_bed.celsius);
DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 28, 417, thermalManager.degBed());
DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 25 + 3 * STAT_CHR_W + 5, 417, F("/"));
DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 417, thermalManager.temp_bed.target);
DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 417, thermalManager.degTargetBed());
#endif
DWIN_ICON_Show(ICON, ICON_Speed, 113, 383);
@ -2157,8 +2149,8 @@ void HMI_SelectFile() {
#if FAN_COUNT > 0
// All fans on for Ender 3 v2 ?
// The slicer should manage this for us.
// for (uint8_t i = 0; i < FAN_COUNT; i++)
// thermalManager.fan_speed[i] = FANON;
//for (uint8_t i = 0; i < FAN_COUNT; i++)
// thermalManager.fan_speed[i] = 255;
#endif
Goto_PrintProcess();
@ -2539,11 +2531,11 @@ void Draw_Temperature_Menu() {
#define _TMENU_ICON(N) Draw_Menu_Line(++i, ICON_SetEndTemp + (N) - 1)
#if HAS_HOTEND
_TMENU_ICON(TEMP_CASE_TEMP);
DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(i), thermalManager.temp_hotend[0].target);
DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(i), thermalManager.degTargetHotend(0));
#endif
#if HAS_HEATED_BED
_TMENU_ICON(TEMP_CASE_BED);
DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(i), thermalManager.temp_bed.target);
DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(i), thermalManager.degTargetBed());
#endif
#if HAS_FAN
_TMENU_ICON(TEMP_CASE_FAN);
@ -2711,7 +2703,7 @@ void HMI_AxisMove() {
case 4: // Extruder
// window tips
#ifdef PREVENT_COLD_EXTRUSION
if (thermalManager.temp_hotend[0].celsius < EXTRUDE_MINTEMP) {
if (thermalManager.degHotend(0) < EXTRUDE_MINTEMP) {
HMI_flag.ETempTooLow_flag = true;
Popup_Window_ETempTooLow();
DWIN_UpdateLCD();
@ -2752,16 +2744,16 @@ void HMI_Temperature() {
#if HAS_HOTEND
case TEMP_CASE_TEMP: // Nozzle temperature
checkkey = ETemp;
HMI_ValueStruct.E_Temp = thermalManager.temp_hotend[0].target;
DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(1), thermalManager.temp_hotend[0].target);
HMI_ValueStruct.E_Temp = thermalManager.degTargetHotend(0);
DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(1), HMI_ValueStruct.E_Temp);
EncoderRate.enabled = true;
break;
#endif
#if HAS_HEATED_BED
case TEMP_CASE_BED: // Bed temperature
checkkey = BedTemp;
HMI_ValueStruct.Bed_Temp = thermalManager.temp_bed.target;
DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(2), thermalManager.temp_bed.target);
HMI_ValueStruct.Bed_Temp = thermalManager.degTargetBed();
DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(2), HMI_ValueStruct.Bed_Temp);
EncoderRate.enabled = true;
break;
#endif
@ -2769,7 +2761,7 @@ void HMI_Temperature() {
case TEMP_CASE_FAN: // Fan speed
checkkey = FanSpeed;
HMI_ValueStruct.Fan_speed = thermalManager.fan_speed[0];
DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(3), thermalManager.fan_speed[0]);
DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(3), HMI_ValueStruct.Fan_speed);
EncoderRate.enabled = true;
break;
#endif
@ -2801,7 +2793,7 @@ void HMI_Temperature() {
#ifdef USE_STRING_HEADINGS
Draw_Title("PLA Settings"); // TODO: GET_TEXT_F
#else
DWIN_Frame_TitleCopy(1, 56, 16, 141, 28); // "PLA Settings"
DWIN_Frame_TitleCopy(1, 56, 16, 141, 28); // "PLA Settings"
#endif
#ifdef USE_STRING_TITLES
DWIN_Draw_Label(MBASE(PREHEAT_CASE_TEMP), F("Nozzle Temp"));
@ -2817,7 +2809,7 @@ void HMI_Temperature() {
#else
DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX, MBASE(PREHEAT_CASE_TEMP));
DWIN_Frame_AreaCopy(1, 197, 104, 238, 114, LBLX + 27, MBASE(PREHEAT_CASE_TEMP));
DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 71, MBASE(PREHEAT_CASE_TEMP)); // PLA nozzle temp
DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 71, MBASE(PREHEAT_CASE_TEMP)); // PLA nozzle temp
#if HAS_HEATED_BED
DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX, MBASE(PREHEAT_CASE_BED) + 3);
DWIN_Frame_AreaCopy(1, 240, 104, 264, 114, LBLX + 27, MBASE(PREHEAT_CASE_BED) + 3);
@ -2828,7 +2820,7 @@ void HMI_Temperature() {
DWIN_Frame_AreaCopy(1, 0, 119, 64, 132, LBLX + 27, MBASE(PREHEAT_CASE_FAN)); // PLA fan speed
#endif
#if ENABLED(EEPROM_SETTINGS)
DWIN_Frame_AreaCopy(1, 97, 165, 229, 177, LBLX, MBASE(PREHEAT_CASE_SAVE)); // Save PLA configuration
DWIN_Frame_AreaCopy(1, 97, 165, 229, 177, LBLX, MBASE(PREHEAT_CASE_SAVE)); // Save PLA configuration
#endif
#endif
}
@ -3285,22 +3277,22 @@ void HMI_Tune() {
case TUNE_CASE_SPEED: // Print speed
checkkey = PrintSpeed;
HMI_ValueStruct.print_speed = feedrate_percentage;
DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(TUNE_CASE_SPEED + MROWS - index_tune), feedrate_percentage);
DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(TUNE_CASE_SPEED + MROWS - index_tune), HMI_ValueStruct.print_speed);
EncoderRate.enabled = true;
break;
#if HAS_HOTEND
case TUNE_CASE_TEMP: // Nozzle temp
checkkey = ETemp;
HMI_ValueStruct.E_Temp = thermalManager.temp_hotend[0].target;
DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(TUNE_CASE_TEMP + MROWS - index_tune), thermalManager.temp_hotend[0].target);
HMI_ValueStruct.E_Temp = thermalManager.degTargetHotend(0);
DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(TUNE_CASE_TEMP + MROWS - index_tune), HMI_ValueStruct.E_Temp);
EncoderRate.enabled = true;
break;
#endif
#if HAS_HEATED_BED
case TUNE_CASE_BED: // Bed temp
checkkey = BedTemp;
HMI_ValueStruct.Bed_Temp = thermalManager.temp_bed.target;
DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(TUNE_CASE_BED + MROWS - index_tune), thermalManager.temp_bed.target);
HMI_ValueStruct.Bed_Temp = thermalManager.degTargetBed();
DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(TUNE_CASE_BED + MROWS - index_tune), HMI_ValueStruct.Bed_Temp);
EncoderRate.enabled = true;
break;
#endif
@ -3308,7 +3300,7 @@ void HMI_Tune() {
case TUNE_CASE_FAN: // Fan speed
checkkey = FanSpeed;
HMI_ValueStruct.Fan_speed = thermalManager.fan_speed[0];
DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(TUNE_CASE_FAN + MROWS - index_tune), thermalManager.fan_speed[0]);
DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(TUNE_CASE_FAN + MROWS - index_tune), HMI_ValueStruct.Fan_speed);
EncoderRate.enabled = true;
break;
#endif
@ -3626,8 +3618,8 @@ void EachMomentUpdate() {
if (HMI_flag.pause_action && printingIsPaused() && !planner.has_blocks_queued()) {
HMI_flag.pause_action = false;
#if ENABLED(PAUSE_HEAT)
TERN_(HAS_HOTEND, resume_hotend_temp = thermalManager.temp_hotend[0].target);
TERN_(HAS_HEATED_BED, resume_bed_temp = thermalManager.temp_bed.target);
TERN_(HAS_HOTEND, resume_hotend_temp = thermalManager.degTargetHotend(0));
TERN_(HAS_HEATED_BED, resume_bed_temp = thermalManager.degTargetBed());
thermalManager.disable_all_heaters();
#endif
queue.inject_P(PSTR("G1 F1200 X0 Y0"));