Skip to content

Commit

Permalink
MKS / E3V2 LCD code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Mar 23, 2021
1 parent f7aaa2e commit 58f0330
Show file tree
Hide file tree
Showing 12 changed files with 210 additions and 308 deletions.
6 changes: 3 additions & 3 deletions Marlin/src/lcd/HD44780/marlinui_HD44780.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,9 +571,9 @@ FORCE_INLINE void _draw_bed_status(const bool blink) {
#if ENABLED(LCD_PROGRESS_BAR)

void MarlinUI::draw_progress_bar(const uint8_t percent) {
const int16_t tix = (int16_t)(percent * (LCD_WIDTH) * 3) / 100,
cel = tix / 3,
rem = tix % 3;
const int16_t tix = int16_t(percent * (LCD_WIDTH) * 3) / 100,
cel = tix / 3,
rem = tix % 3;
uint8_t i = LCD_WIDTH;
char msg[LCD_WIDTH + 1], b = ' ';
msg[LCD_WIDTH] = '\0';
Expand Down
72 changes: 32 additions & 40 deletions Marlin/src/lcd/dwin/e3v2/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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]);
Expand All @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -2752,24 +2744,24 @@ 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
#if HAS_FAN
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
Expand Down Expand Up @@ -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"));
Expand All @@ -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);
Expand All @@ -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
}
Expand Down Expand Up @@ -3285,30 +3277,30 @@ 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
#if HAS_FAN
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
Expand Down Expand Up @@ -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"));
Expand Down
13 changes: 6 additions & 7 deletions Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,32 +560,31 @@ void AnycubicTFTClass::GetCommandFromTFT() {

switch (a_command) {
case 0: { // A0 GET HOTEND TEMP
float hotendActualTemp = getActualTemp_celsius((extruder_t) (extruder_t) E0);
const float hotendActualTemp = getActualTemp_celsius(E0);
SEND_PGM_VAL("A0V ", int(hotendActualTemp + 0.5));
}
break;

case 1: { // A1 GET HOTEND TARGET TEMP
float hotendTargetTemp = getTargetTemp_celsius((extruder_t) (extruder_t) E0);
const float hotendTargetTemp = getTargetTemp_celsius(E0);
SEND_PGM_VAL("A1V ", int(hotendTargetTemp + 0.5));
}
break;

case 2: { // A2 GET HOTBED TEMP
float heatedBedActualTemp = getActualTemp_celsius((heater_t) BED);
const float heatedBedActualTemp = getActualTemp_celsius(BED);
SEND_PGM_VAL("A2V ", int(heatedBedActualTemp + 0.5));
}
break;

case 3: { // A3 GET HOTBED TARGET TEMP
float heatedBedTargetTemp = getTargetTemp_celsius((heater_t) BED);
const float heatedBedTargetTemp = getTargetTemp_celsius(BED);
SEND_PGM_VAL("A3V ", int(heatedBedTargetTemp + 0.5));
} break;

case 4: { // A4 GET FAN SPEED
float fanPercent = getActualFan_percent(FAN0);
fanPercent = constrain(fanPercent, 0, 100);
SEND_PGM_VAL("A4V ", int(fanPercent));
const float fanPercent = getActualFan_percent(FAN0);
SEND_PGM_VAL("A4V ", int(LIMIT(fanPercent, 0, 100)));
} break;

case 5: { // A5 GET CURRENT COORDINATE
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -764,8 +764,8 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, ScreenHandler.DGUSLCD_SD_ReallyAbort, nullptr),
VPHELPER(VP_SD_Print_Setting, nullptr, ScreenHandler.DGUSLCD_SD_PrintTune, nullptr),
#if ENABLED(BABYSTEPPING)
VPHELPER(VP_SD_Print_LiveAdjustZ,nullptr, ScreenHandler.HandleLiveAdjustZ, &ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<2>),
VPHELPER(VP_ZOffset_DE_DIS,&z_offset_add,nullptr, &ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, ScreenHandler.HandleLiveAdjustZ, &ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<2>),
VPHELPER(VP_ZOffset_DE_DIS, &z_offset_add, nullptr, &ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
#endif
#if HAS_BED_PROBE
VPHELPER(VP_OFFSET_X, &probe.offset.x, ScreenHandler.GetOffsetValue,ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
Expand Down
Loading

0 comments on commit 58f0330

Please sign in to comment.