Browse Source

MKS / E3V2 LCD code cleanup

vanilla_fb_2.0.x
Scott Lahteine 4 years ago
committed by Scott Lahteine
parent
commit
58f0330d3f
  1. 2
      Marlin/src/lcd/HD44780/marlinui_HD44780.cpp
  2. 60
      Marlin/src/lcd/dwin/e3v2/dwin.cpp
  3. 13
      Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp
  4. 293
      Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp
  5. 1
      Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h
  6. 17
      Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp
  7. 12
      Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp
  8. 2
      Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.cpp
  9. 4
      Marlin/src/lcd/extui/lib/mks_ui/draw_number_key.cpp
  10. 6
      Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp
  11. 8
      Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h

2
Marlin/src/lcd/HD44780/marlinui_HD44780.cpp

@ -571,7 +571,7 @@ 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,
const int16_t tix = int16_t(percent * (LCD_WIDTH) * 3) / 100,
cel = tix / 3,
rem = tix % 3;
uint8_t i = LCD_WIDTH;

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

@ -104,17 +104,9 @@
#define MENU_CHAR_LIMIT 24
#define STATUS_Y 360
// Fan speed limit
#define FANON 255
#define FANOFF 0
// 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 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);
@ -2158,7 +2150,7 @@ void HMI_SelectFile() {
// 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;
// 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
@ -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"));

13
Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp

@ -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

293
Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp

@ -111,7 +111,7 @@ void DGUSScreenHandler::DGUSLCD_SendPrintTimeToDisplay_MKS(DGUS_VP_Variable &var
void DGUSScreenHandler::DGUSLCD_SetUint8(DGUS_VP_Variable &var, void *val_ptr) {
if (var.memadr) {
uint16_t value = swap16(*(uint16_t*)val_ptr);
const uint16_t value = swap16(*(uint16_t*)val_ptr);
DEBUG_ECHOLNPAIR("FAN value get:", value);
*(uint8_t*)var.memadr = map(constrain(value, 0, 255), 0, 255, 0, 255);
DEBUG_ECHOLNPAIR("FAN value change:", *(uint8_t*)var.memadr);
@ -314,7 +314,7 @@ void DGUSScreenHandler::ScreenChangeHook(DGUS_VP_Variable &var, void *val_ptr) {
}
void DGUSScreenHandler::ScreenBackChange(DGUS_VP_Variable &var, void *val_ptr) {
uint16_t target = swap16(*(uint16_t *)val_ptr);
const uint16_t target = swap16(*(uint16_t *)val_ptr);
DEBUG_ECHOLNPAIR(" back = 0x%x", target);
switch (target) {
}
@ -330,7 +330,7 @@ void DGUSScreenHandler::ZoffsetConfirm(DGUS_VP_Variable &var, void *val_ptr) {
void DGUSScreenHandler::GetTurnOffCtrl(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("ctrl turn off\n");
uint16_t value = swap16(*(uint16_t *)val_ptr);
const uint16_t value = swap16(*(uint16_t *)val_ptr);
switch (value) {
case 0 ... 1: DGUSAutoTurnOff = (bool)value; break;
default: break;
@ -339,7 +339,7 @@ void DGUSScreenHandler::GetTurnOffCtrl(DGUS_VP_Variable &var, void *val_ptr) {
void DGUSScreenHandler::GetMinExtrudeTemp(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("MinExtrudeTempChange DistanceChange");
uint16_t value = swap16(*(uint16_t *)val_ptr);
const uint16_t value = swap16(*(uint16_t *)val_ptr);
thermalManager.extrude_min_temp = value;
min_ex_temp = value;
settings.save();
@ -347,7 +347,7 @@ void DGUSScreenHandler::GetMinExtrudeTemp(DGUS_VP_Variable &var, void *val_ptr)
void DGUSScreenHandler::GetZoffsetDistance(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("Zoffset DistanceChange");
uint16_t value = swap16(*(uint16_t *)val_ptr);
const uint16_t value = swap16(*(uint16_t *)val_ptr);
float val_distance = 0;
switch (value) {
case 0: val_distance = 0.01; break;
@ -365,7 +365,7 @@ void DGUSScreenHandler::GetManualMovestep(DGUS_VP_Variable &var, void *val_ptr)
}
void DGUSScreenHandler::EEPROM_CTRL(DGUS_VP_Variable &var, void *val_ptr) {
uint16_t eep_flag = swap16(*(uint16_t *)val_ptr);
const uint16_t eep_flag = swap16(*(uint16_t *)val_ptr);
switch (eep_flag) {
case 0:
settings.save();
@ -383,7 +383,7 @@ void DGUSScreenHandler::EEPROM_CTRL(DGUS_VP_Variable &var, void *val_ptr) {
}
void DGUSScreenHandler::Z_offset_select(DGUS_VP_Variable &var, void *val_ptr) {
uint16_t z_value = swap16(*(uint16_t *)val_ptr);
const uint16_t z_value = swap16(*(uint16_t *)val_ptr);
switch (z_value) {
case 0: Z_distance = 0.01; break;
case 1: Z_distance = 0.1; break;
@ -410,7 +410,7 @@ void DGUSScreenHandler::GetOffsetValue(DGUS_VP_Variable &var, void *val_ptr) {
}
void DGUSScreenHandler::LanguageChange_MKS(DGUS_VP_Variable &var, void *val_ptr) {
uint16_t lag_flag = swap16(*(uint16_t *)val_ptr);
const uint16_t lag_flag = swap16(*(uint16_t *)val_ptr);
switch (lag_flag) {
case MKS_SimpleChinese:
DGUS_LanguageDisplay(MKS_SimpleChinese);
@ -435,7 +435,7 @@ void DGUSScreenHandler::LanguageChange_MKS(DGUS_VP_Variable &var, void *val_ptr)
#endif
void DGUSScreenHandler::Level_Ctrl_MKS(DGUS_VP_Variable &var, void *val_ptr) {
uint16_t lev_but = swap16(*(uint16_t *)val_ptr);
const uint16_t lev_but = swap16(*(uint16_t *)val_ptr);
#if ENABLED(MESH_BED_LEVELING)
auto cs = getCurrentScreen();
#endif
@ -482,7 +482,7 @@ void DGUSScreenHandler::Level_Ctrl_MKS(DGUS_VP_Variable &var, void *val_ptr) {
}
void DGUSScreenHandler::MeshLevelDistanceConfig(DGUS_VP_Variable &var, void *val_ptr) {
uint16_t mesh_dist = swap16(*(uint16_t *)val_ptr);
const uint16_t mesh_dist = swap16(*(uint16_t *)val_ptr);
switch (mesh_dist) {
case 0: mesh_adj_distance = 0.01; break;
case 1: mesh_adj_distance = 0.1; break;
@ -493,7 +493,7 @@ void DGUSScreenHandler::MeshLevelDistanceConfig(DGUS_VP_Variable &var, void *val
void DGUSScreenHandler::MeshLevel(DGUS_VP_Variable &var, void *val_ptr) {
#if ENABLED(MESH_BED_LEVELING)
uint16_t mesh_value = swap16(*(uint16_t *)val_ptr);
const uint16_t mesh_value = swap16(*(uint16_t *)val_ptr);
// static uint8_t a_first_level = 1;
char cmd_buf[30];
float offset = mesh_adj_distance;
@ -586,20 +586,16 @@ void DGUSScreenHandler::MeshLevel(DGUS_VP_Variable &var, void *val_ptr) {
}
void DGUSScreenHandler::LCD_BLK_Adjust(DGUS_VP_Variable &var, void *val_ptr) {
const uint16_t lcd_value = swap16(*(uint16_t *)val_ptr);
uint16_t lcd_value = swap16(*(uint16_t *)val_ptr);
if (lcd_value > 100) lcd_value = 100;
else if (lcd_value < 10) lcd_value = 10;
lcd_default_light = lcd_value;
lcd_default_light = constrain(lcd_value, 10, 100);
const uint16_t lcd_data[2] = { lcd_default_light, lcd_default_light };
dgusdisplay.WriteVariable(0x0082, &lcd_data, 5, true);
}
void DGUSScreenHandler::ManualAssistLeveling(DGUS_VP_Variable &var, void *val_ptr) {
int16_t point_value = swap16(*(uint16_t *)val_ptr);
const int16_t point_value = swap16(*(uint16_t *)val_ptr);
int16_t level_x_pos, level_y_pos;
char buf_level[32] = {0};
@ -686,7 +682,7 @@ void DGUSScreenHandler::ManualAssistLeveling(DGUS_VP_Variable &var, void *val_pt
#define mks_max(a, b) ((a) > (b)) ? (a) : (b)
void DGUSScreenHandler::TMC_ChangeConfig(DGUS_VP_Variable &var, void *val_ptr) {
#if EITHER(HAS_TRINAMIC_CONFIG, HAS_STEALTHCHOP)
uint16_t tmc_value = swap16(*(uint16_t*)val_ptr);
const uint16_t tmc_value = swap16(*(uint16_t*)val_ptr);
#endif
switch (var.VP) {
@ -930,7 +926,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
}
void DGUSScreenHandler::GetParkPos_MKS(DGUS_VP_Variable &var, void *val_ptr) {
int16_t value_pos = swap16(*(int16_t*)val_ptr);
const int16_t value_pos = swap16(*(int16_t*)val_ptr);
switch (var.VP) {
case VP_X_PARK_POS: x_park_pos = value_pos; break;
@ -939,75 +935,76 @@ void DGUSScreenHandler::GetParkPos_MKS(DGUS_VP_Variable &var, void *val_ptr) {
default: break;
}
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
return;
}
void DGUSScreenHandler::HandleChangeLevelPoint_MKS(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("HandleStepPerMMChanged");
int16_t value_raw = swap16(*(int16_t*)val_ptr);
DEBUG_ECHOLNPAIR_F("value:", value_raw);
const int16_t value_raw = swap16(*(int16_t*)val_ptr);
DEBUG_ECHOLNPAIR_F("value_raw:", value_raw);
*(int16_t*)var.memadr = value_raw;
settings.save();
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
return;
}
void DGUSScreenHandler::HandleStepPerMMChanged_MKS(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("HandleStepPerMMChanged");
uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
const uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
const float value = (float)value_raw;
DEBUG_ECHOLNPAIR("value_raw:", value_raw);
float value = (float)value_raw;
DEBUG_ECHOLNPAIR_F("value:", value);
ExtUI::axis_t axis;
switch (var.VP) {
default: return;
case VP_X_STEP_PER_MM: axis = ExtUI::axis_t::X; break;
case VP_Y_STEP_PER_MM: axis = ExtUI::axis_t::Y; break;
case VP_Z_STEP_PER_MM: axis = ExtUI::axis_t::Z; break;
default: return;
}
DEBUG_ECHOLNPAIR_F("value:", value);
ExtUI::setAxisSteps_per_mm(value, axis);
DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisSteps_per_mm(axis));
settings.save();
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
return;
}
void DGUSScreenHandler::HandleStepPerMMExtruderChanged_MKS(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("HandleStepPerMMExtruderChanged");
uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
const uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
const float value = (float)value_raw;
DEBUG_ECHOLNPAIR("value_raw:", value_raw);
float value = (float)value_raw;
DEBUG_ECHOLNPAIR_F("value:", value);
ExtUI::extruder_t extruder;
switch (var.VP) {
default: return;
#if HOTENDS >= 1
#if HAS_HOTEND
case VP_E0_STEP_PER_MM: extruder = ExtUI::extruder_t::E0; break;
#endif
#if HOTENDS >= 2
#endif
#if HAS_MULTI_HOTEND
case VP_E1_STEP_PER_MM: extruder = ExtUI::extruder_t::E1; break;
#endif
}
DEBUG_ECHOLNPAIR_F("value:", value);
ExtUI::setAxisSteps_per_mm(value, extruder);
DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisSteps_per_mm(extruder));
settings.save();
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
return;
}
void DGUSScreenHandler::HandleMaxSpeedChange_MKS(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("HandleMaxSpeedChange_MKS");
uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
const uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
const float value = (float)value_raw;
DEBUG_ECHOLNPAIR("value_raw:", value_raw);
float value = (float)value_raw;
DEBUG_ECHOLNPAIR_F("value:", value);
ExtUI::axis_t axis;
switch (var.VP) {
case VP_X_MAX_SPEED: axis = ExtUI::axis_t::X; break;
@ -1015,59 +1012,57 @@ void DGUSScreenHandler::HandleMaxSpeedChange_MKS(DGUS_VP_Variable &var, void *va
case VP_Z_MAX_SPEED: axis = ExtUI::axis_t::Z; break;
default: return;
}
DEBUG_ECHOLNPAIR_F("value:", value);
// ExtUI::setAxisSteps_per_mm(value,extruder);
ExtUI::setAxisMaxFeedrate_mm_s(value, axis);
DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisMaxFeedrate_mm_s(axis));
settings.save();
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
return;
}
void DGUSScreenHandler::HandleExtruderMaxSpeedChange_MKS(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("HandleMaxSpeedChange_MKS");
uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
const uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
const float value = (float)value_raw;
DEBUG_ECHOLNPAIR("value_raw:", value_raw);
float value = (float)value_raw;
DEBUG_ECHOLNPAIR_F("value:", value);
ExtUI::extruder_t extruder;
switch (var.VP) {
default: return;
#if HOTENDS >= 1
#if HAS_HOTEND
case VP_E0_MAX_SPEED: extruder = ExtUI::extruder_t::E0; break;
#endif
#if HOTENDS >= 2
#if HAS_MULTI_HOTEND
#endif
case VP_E1_MAX_SPEED: extruder = ExtUI::extruder_t::E1; break;
}
DEBUG_ECHOLNPAIR_F("value:", value);
// ExtUI::setAxisSteps_per_mm(value,extruder);
ExtUI::setAxisMaxFeedrate_mm_s(value, extruder);
DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisMaxFeedrate_mm_s(extruder));
settings.save();
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
return;
}
void DGUSScreenHandler::HandleMaxAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("HandleMaxSpeedChange_MKS");
uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
const uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
const float value = (float)value_raw;
DEBUG_ECHOLNPAIR("value_raw:", value_raw);
float value = (float)value_raw;
DEBUG_ECHOLNPAIR_F("value:", value);
ExtUI::axis_t axis;
switch (var.VP) {
default: return;
case VP_X_ACC_MAX_SPEED: axis = ExtUI::axis_t::X; break;
case VP_Y_ACC_MAX_SPEED: axis = ExtUI::axis_t::Y; break;
case VP_Z_ACC_MAX_SPEED: axis = ExtUI::axis_t::Z; break;
default: return;
}
DEBUG_ECHOLNPAIR_F("value:", value);
ExtUI::setAxisMaxAcceleration_mm_s2(value, axis);
DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisMaxAcceleration_mm_s2(axis));
settings.save();
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
return;
}
void DGUSScreenHandler::HandleExtruderAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr) {
@ -1079,76 +1074,66 @@ void DGUSScreenHandler::HandleExtruderAccChange_MKS(DGUS_VP_Variable &var, void
ExtUI::extruder_t extruder;
switch (var.VP) {
default: return;
#if HOTENDS >= 1
#if HAS_HOTEND
case VP_E0_ACC_MAX_SPEED: extruder = ExtUI::extruder_t::E0; settings.load(); break;
#endif
#if HOTENDS >= 2
#endif
#if HAS_MULTI_HOTEND
case VP_E1_ACC_MAX_SPEED: extruder = ExtUI::extruder_t::E1; settings.load(); break;
#endif
}
DEBUG_ECHOLNPAIR_F("value:", value);
// ExtUI::setAxisSteps_per_mm(value,extruder);
ExtUI::setAxisMaxAcceleration_mm_s2(value, extruder);
DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisMaxAcceleration_mm_s2(extruder));
settings.save();
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
return;
}
void DGUSScreenHandler::HandleTravelAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr) {
uint16_t value_travel = swap16(*(uint16_t*)val_ptr);
float value = (float)value_travel;
planner.settings.travel_acceleration = value;
planner.settings.travel_acceleration = (float)value_travel;
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
return;
}
void DGUSScreenHandler::HandleFeedRateMinChange_MKS(DGUS_VP_Variable &var, void *val_ptr) {
uint16_t value_t = swap16(*(uint16_t*)val_ptr);
float value = (float)value_t;
planner.settings.min_feedrate_mm_s = value;
planner.settings.min_feedrate_mm_s = (float)value_t;
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
return;
}
void DGUSScreenHandler::HandleMin_T_F_MKS(DGUS_VP_Variable &var, void *val_ptr) {
uint16_t value_t_f = swap16(*(uint16_t*)val_ptr);
float value = (float)value_t_f;
planner.settings.min_travel_feedrate_mm_s = value;
planner.settings.min_travel_feedrate_mm_s = (float)value_t_f;
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
return;
}
void DGUSScreenHandler::HandleAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr) {
uint16_t value_acc = swap16(*(uint16_t*)val_ptr);
float value = (float)value_acc;
planner.settings.acceleration = value;
planner.settings.acceleration = (float)value_acc;
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
return;
}
void DGUSScreenHandler::HandleGetExMinTemp_MKS(DGUS_VP_Variable &var, void *val_ptr) {
uint16_t value_ex_min_temp = swap16(*(uint16_t*)val_ptr);
const uint16_t value_ex_min_temp = swap16(*(uint16_t*)val_ptr);
thermalManager.extrude_min_temp = value_ex_min_temp;
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
}
#if HAS_PID_HEATING
void DGUSScreenHandler::HandleTemperaturePIDChanged(DGUS_VP_Variable &var, void *val_ptr) {
uint16_t rawvalue = swap16(*(uint16_t*)val_ptr);
const uint16_t rawvalue = swap16(*(uint16_t*)val_ptr);
DEBUG_ECHOLNPAIR("V1:", rawvalue);
float value = (float)rawvalue / 10;
const float value = 1.0f * rawvalue;
DEBUG_ECHOLNPAIR("V2:", value);
float newvalue = 0;
switch (var.VP) {
default: return;
#if HOTENDS >= 1
#if HAS_HOTEND
case VP_E0_PID_P: newvalue = value; break;
case VP_E0_PID_I: newvalue = scalePID_i(value); break;
case VP_E0_PID_D: newvalue = scalePID_d(value); break;
#endif
#if HOTENDS >= 2
#if HAS_MULTI_HOTEND
case VP_E1_PID_P: newvalue = value; break;
case VP_E1_PID_I: newvalue = scalePID_i(value); break;
case VP_E1_PID_D: newvalue = scalePID_d(value); break;
@ -1224,7 +1209,6 @@ void DGUSScreenHandler::GetManualFilament(DGUS_VP_Variable &var, void *val_ptr)
distanceFilament = value;
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
return;
}
void DGUSScreenHandler::GetManualFilamentSpeed(DGUS_VP_Variable &var, void *val_ptr) {
@ -1237,137 +1221,65 @@ void DGUSScreenHandler::GetManualFilamentSpeed(DGUS_VP_Variable &var, void *val_
FilamentSpeed = value_len;
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
return;
}
void DGUSScreenHandler::MKS_FilamentLoad(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("Load Filament");
char buf[40];
uint16_t val_t = swap16(*(uint16_t*)val_ptr);
void DGUSScreenHandler::MKS_FilamentLoadUnload(DGUS_VP_Variable &var, void *val_ptr, const int filamentDir) {
#if EITHER(HAS_MULTI_HOTEND, SINGLENOZZLE)
uint8_t swap_tool = 0;
#endif
#if HAS_HOTEND
uint8_t hotend_too_cold = 0;
#endif
if (!print_job_timer.isPaused() && !queue.ring_buffer.empty())
return;
char buf[40];
const uint16_t val_t = swap16(*(uint16_t*)val_ptr);
switch (val_t) {
default: break;
case 0:
#if HOTENDS >= 1
if (thermalManager.degHotend(0) < thermalManager.extrude_min_temp) {
if (thermalManager.degTargetHotend(0) < thermalManager.extrude_min_temp)
thermalManager.setTargetHotend(thermalManager.extrude_min_temp, 0);
sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please wait."), PSTR("Nozzle heating!"), true, true, true, true);
SetupConfirmAction(nullptr);
GotoScreen(DGUSLCD_SCREEN_POPUP);
}
else {
queue.enqueue_now_P(PSTR("T0"));
queue.enqueue_now_P(PSTR("G91"));
snprintf_P(buf,40,PSTR("G1 E%d F%d"),(int)distanceFilament,FilamentSpeed * 60);
queue.enqueue_one_now(buf);
queue.enqueue_now_P(PSTR("G90"));
}
#if HAS_HOTEND
if (thermalManager.tooColdToExtrude(0)) hotend_too_cold = 1; else swap_tool = 1;
#endif
break;
case 1:
#if HOTENDS >= 2
if (thermalManager.degHotend(1) < thermalManager.extrude_min_temp) {
if (thermalManager.degTargetHotend(1) < thermalManager.extrude_min_temp)
thermalManager.setTargetHotend(thermalManager.extrude_min_temp, 1);
sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please wait."), PSTR("Nozzle heating!"), true, true, true, true);
SetupConfirmAction(nullptr);
GotoScreen(DGUSLCD_SCREEN_POPUP);
}
else {
queue.enqueue_now_P(PSTR("T1"));
queue.enqueue_now_P(PSTR("G91"));
snprintf_P(buf,40,PSTR("G1 E%d F%d"),(int)distanceFilament,FilamentSpeed * 60);
queue.enqueue_one_now(buf);
queue.enqueue_now_P(PSTR("G90"));
}
#endif
#if ENABLED(SINGLENOZZLE)
if (thermalManager.degHotend(0) < thermalManager.extrude_min_temp) {
if (thermalManager.degTargetHotend(0) < thermalManager.extrude_min_temp)
thermalManager.setTargetHotend(thermalManager.extrude_min_temp, 0);
sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please wait."), PSTR("Nozzle heating!"), true, true, true, true);
SetupConfirmAction(nullptr);
GotoScreen(DGUSLCD_SCREEN_POPUP);
}
else {
queue.enqueue_now_P(PSTR("T1"));
queue.enqueue_now_P(PSTR("G91"));
snprintf_P(buf,40,PSTR("G1 E%d F%d"),(int)distanceFilament,FilamentSpeed * 60);
queue.enqueue_one_now(buf);
queue.enqueue_now_P(PSTR("G90"));
}
#if HAS_MULTI_HOTEND
if (thermalManager.tooColdToExtrude(1)) hotend_too_cold = 2; else swap_tool = 2;
#elif ENABLED(SINGLENOZZLE)
if (thermalManager.tooColdToExtrude(0)) hotend_too_cold = 1; else swap_tool = 2;
#endif
break;
default:
break;
}
}
void DGUSScreenHandler::MKS_FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("UnLoad Filament");
char buf[40];
uint16_t val_t = swap16(*(uint16_t*)val_ptr);
switch (val_t) {
case 0:
#if HOTENDS >= 1
if (thermalManager.degHotend(0) < thermalManager.extrude_min_temp) {
if (thermalManager.degTargetHotend(0) < thermalManager.extrude_min_temp)
thermalManager.setTargetHotend(thermalManager.extrude_min_temp, 0);
#if HAS_HOTEND
if (hotend_too_cold) {
if (thermalManager.targetTooColdToExtrude(hotend_too_cold - 1)) thermalManager.setTargetHotend(thermalManager.extrude_min_temp, hotend_too_cold - 1);
sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please wait."), PSTR("Nozzle heating!"), true, true, true, true);
SetupConfirmAction(nullptr);
GotoScreen(DGUSLCD_SCREEN_POPUP);
}
else {
queue.enqueue_now_P(PSTR("T0"));
queue.enqueue_now_P(PSTR("G91"));
snprintf_P(buf,40,PSTR("G1 E-%d F%d"),(int)distanceFilament,FilamentSpeed * 60);
queue.enqueue_one_now(buf);
queue.enqueue_now_P(PSTR("G90"));
}
#endif
break;
case 1:
#if HOTENDS >= 2
if (thermalManager.degHotend(1) < thermalManager.extrude_min_temp) {
if (thermalManager.degTargetHotend(1) < thermalManager.extrude_min_temp)
thermalManager.setTargetHotend(thermalManager.extrude_min_temp, 1);
sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please wait."), PSTR("Nozzle heating!"), true, true, true, true);
SetupConfirmAction(nullptr);
GotoScreen(DGUSLCD_SCREEN_POPUP);
}
else {
queue.enqueue_now_P(PSTR("T1"));
queue.enqueue_now_P(PSTR("G91"));
snprintf_P(buf,40,PSTR("G1 E-%d F%d"),(int)distanceFilament,FilamentSpeed * 60);
queue.enqueue_one_now(buf);
queue.enqueue_now_P(PSTR("G90"));
}
#endif
#if ENABLED(SINGLENOZZLE)
if (thermalManager.degHotend(0) < thermalManager.extrude_min_temp) {
if (thermalManager.degTargetHotend(0) < thermalManager.extrude_min_temp)
thermalManager.setTargetHotend(thermalManager.extrude_min_temp, 0);
sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please wait."), PSTR("Nozzle heating!"), true, true, true, true);
SetupConfirmAction(nullptr);
GotoScreen(DGUSLCD_SCREEN_POPUP);
}
else {
queue.enqueue_now_P(PSTR("T1"));
#if EITHER(HAS_MULTI_HOTEND, SINGLENOZZLE)
if (swap_tool) {
queue.enqueue_now_P(swap_tool == 2 ? PSTR("T1") : PSTR("T0"));
queue.enqueue_now_P(PSTR("G91"));
snprintf_P(buf,40,PSTR("G1 E-%d F%d"),(int)distanceFilament,FilamentSpeed * 60);
snprintf_P(buf, 40, PSTR("G1 E%d F%d"), (int)distanceFilament * filamentDir, FilamentSpeed * 60);
queue.enqueue_one_now(buf);
queue.enqueue_now_P(PSTR("G90"));
}
#endif
break;
}
void DGUSScreenHandler::MKS_FilamentLoad(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("Load Filament");
MKS_FilamentLoadUnload(var, val_ptr, 1);
}
void DGUSScreenHandler::MKS_FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPGM("UnLoad Filament");
MKS_FilamentLoadUnload(var, val_ptr, -1);
}
#if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
@ -1378,17 +1290,15 @@ void DGUSScreenHandler::MKS_FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr)
uint8_t e_temp = 0;
filament_data.heated = false;
uint16_t preheat_option = swap16(*(uint16_t*)val_ptr);
if (preheat_option <= 8) { // Load filament type
filament_data.action = 1;
}
else if (preheat_option >= 10) { // Unload filament type
if (preheat_option >= 10) { // Unload filament type
preheat_option -= 10;
filament_data.action = 2;
filament_data.purge_length = DGUS_FILAMENT_PURGE_LENGTH;
}
else { // Cancel filament operation
else if (preheat_option <= 8) // Load filament type
filament_data.action = 1;
else // Cancel filament operation
filament_data.action = 0;
}
switch (preheat_option) {
case 0: // Load PLA
@ -1416,10 +1326,10 @@ void DGUSScreenHandler::MKS_FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr)
}
if (filament_data.action == 0) { // Go back to utility screen
#if HOTENDS >= 1
#if HAS_HOTEND
thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E0);
#endif
#if HOTENDS >= 2
#if HAS_MULTI_HOTEND
thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E1);
#endif
GotoScreen(DGUSLCD_SCREEN_UTILITY);
@ -1427,13 +1337,13 @@ void DGUSScreenHandler::MKS_FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr)
else { // Go to the preheat screen to show the heating progress
switch (var.VP) {
default: return;
#if HOTENDS >= 1
#if HAS_HOTEND
case VP_E0_FILAMENT_LOAD_UNLOAD:
filament_data.extruder = ExtUI::extruder_t::E0;
thermalManager.setTargetHotend(e_temp, filament_data.extruder);
break;
#endif
#if HOTENDS >= 2
#if HAS_MULTI_HOTEND
case VP_E1_FILAMENT_LOAD_UNLOAD:
filament_data.extruder = ExtUI::extruder_t::E1;
thermalManager.setTargetHotend(e_temp, filament_data.extruder);
@ -1475,6 +1385,7 @@ void DGUSScreenHandler::MKS_FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr)
ExtUI::setAxisPosition_mm(movevalue, filament_data.extruder);
}
}
#endif // DGUS_FILAMENT_LOADUNLOAD
bool DGUSScreenHandler::loop() {

1
Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h

@ -149,6 +149,7 @@ public:
// Hook for filament load and unload
static void HandleFilamentLoadUnload(DGUS_VP_Variable &var);
static void MKS_FilamentLoadUnload(DGUS_VP_Variable &var, void *val_ptr, const int filamentDir);
static void MKS_FilamentLoad(DGUS_VP_Variable &var, void *val_ptr);
static void MKS_FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr);
static void MKS_LOAD_UNLOAD_IDLE();

17
Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp

@ -514,14 +514,14 @@ void filament_dialog_handle() {
queue.inject(public_buf_m);
}
if ( ((abs((int)((int)thermalManager.degHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temper)) <= 1)
|| ((int)thermalManager.degHotend(uiCfg.extruderIndex) > gCfgItems.filament_limit_temper))
&& uiCfg.filament_load_heat_flg
) {
if (uiCfg.filament_load_heat_flg) {
const int16_t diff = thermalManager.degHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temp;
if (abs(diff) < 2 || diff > 0) {
uiCfg.filament_load_heat_flg = false;
lv_clear_dialog();
lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED);
}
}
if (uiCfg.filament_loading_completed) {
uiCfg.filament_rate = 0;
@ -529,14 +529,15 @@ void filament_dialog_handle() {
lv_clear_dialog();
lv_draw_dialog(DIALOG_TYPE_FILAMENT_LOAD_COMPLETED);
}
if (((abs((int)((int)thermalManager.degHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temper)) <= 1)
|| ((int)thermalManager.degHotend(uiCfg.extruderIndex) > gCfgItems.filament_limit_temper))
&& uiCfg.filament_unload_heat_flg
) {
if (uiCfg.filament_unload_heat_flg) {
const int16_t diff = thermalManager.degHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temp;
if (abs(diff) < 2 || diff > 0) {
uiCfg.filament_unload_heat_flg = false;
lv_clear_dialog();
lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED);
}
}
if (uiCfg.filament_unloading_completed) {
uiCfg.filament_rate = 0;

12
Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp

@ -51,15 +51,15 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
case ID_FILAMNT_IN:
uiCfg.filament_load_heat_flg = true;
if ((abs(thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.degHotend(uiCfg.extruderIndex)) <= 1)
|| (gCfgItems.filament_limit_temper <= thermalManager.degHotend(uiCfg.extruderIndex))) {
|| (gCfgItems.filament_limit_temp <= thermalManager.degHotend(uiCfg.extruderIndex))) {
lv_clear_filament_change();
lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED);
}
else {
lv_clear_filament_change();
lv_draw_dialog(DIALOG_TYPE_FILAMENT_LOAD_HEAT);
if (thermalManager.degTargetHotend(uiCfg.extruderIndex) < gCfgItems.filament_limit_temper) {
thermalManager.setTargetHotend(gCfgItems.filament_limit_temper, uiCfg.extruderIndex);
if (thermalManager.degTargetHotend(uiCfg.extruderIndex) < gCfgItems.filament_limit_temp) {
thermalManager.setTargetHotend(gCfgItems.filament_limit_temp, uiCfg.extruderIndex);
thermalManager.start_watching_hotend(uiCfg.extruderIndex);
}
}
@ -68,7 +68,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
uiCfg.filament_unload_heat_flg = true;
if (thermalManager.degTargetHotend(uiCfg.extruderIndex)
&& ((abs((int)((int)thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.degHotend(uiCfg.extruderIndex))) <= 1)
|| ((int)thermalManager.degHotend(uiCfg.extruderIndex) >= gCfgItems.filament_limit_temper))
|| ((int)thermalManager.degHotend(uiCfg.extruderIndex) >= gCfgItems.filament_limit_temp))
) {
lv_clear_filament_change();
lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED);
@ -76,8 +76,8 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
else {
lv_clear_filament_change();
lv_draw_dialog(DIALOG_TYPE_FILAMENT_UNLOAD_HEAT);
if (thermalManager.degTargetHotend(uiCfg.extruderIndex) < gCfgItems.filament_limit_temper) {
thermalManager.setTargetHotend(gCfgItems.filament_limit_temper, uiCfg.extruderIndex);
if (thermalManager.degTargetHotend(uiCfg.extruderIndex) < gCfgItems.filament_limit_temp) {
thermalManager.setTargetHotend(gCfgItems.filament_limit_temp, uiCfg.extruderIndex);
thermalManager.start_watching_hotend(uiCfg.extruderIndex);
}
filament_sprayer_temp();

2
Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.cpp

@ -107,7 +107,7 @@ void lv_draw_filament_settings() {
lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.next, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_FILAMENT_SET_DOWN, true);
}
else {
sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filament_limit_temper);
sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filament_limit_temp);
lv_screen_menu_item_1_edit(scr, machine_menu.FilamentTemperature, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_FILAMENT_SET_TEMP, 0, public_buf_l);
lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.previous, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_FILAMENT_SET_UP, true);

4
Marlin/src/lcd/extui/lib/mks_ui/draw_number_key.cpp

@ -261,7 +261,7 @@ static void disp_key_value() {
sprintf_P(public_buf_m, PSTR("%d"), gCfgItems.filamentchange_unload_speed);
break;
case filament_temp:
sprintf_P(public_buf_m, PSTR("%d"), gCfgItems.filament_limit_temper);
sprintf_P(public_buf_m, PSTR("%d"), gCfgItems.filament_limit_temp);
break;
case x_sensitivity:
#if X_SENSORLESS
@ -505,7 +505,7 @@ static void set_value_confirm() {
update_spi_flash();
break;
case filament_temp:
gCfgItems.filament_limit_temper = atoi(key_value);
gCfgItems.filament_limit_temp = atoi(key_value);
update_spi_flash();
break;
case x_sensitivity:

6
Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp

@ -143,7 +143,7 @@ void gCfgItems_init() {
gCfgItems.filamentchange_load_speed = 1000;
gCfgItems.filamentchange_unload_length = 200;
gCfgItems.filamentchange_unload_speed = 1000;
gCfgItems.filament_limit_temper = 200;
gCfgItems.filament_limit_temp = 200;
gCfgItems.encoder_enable = true;
@ -226,8 +226,8 @@ void ui_cfg_init() {
uiCfg.cloud_port = 10086;
#endif
uiCfg.filament_loading_time = (uint32_t)((gCfgItems.filamentchange_load_length * 60.0 / gCfgItems.filamentchange_load_speed) + 0.5);
uiCfg.filament_unloading_time = (uint32_t)((gCfgItems.filamentchange_unload_length * 60.0 / gCfgItems.filamentchange_unload_speed) + 0.5);
uiCfg.filament_loading_time = (uint32_t)((gCfgItems.filamentchange_load_length * 60.0f / gCfgItems.filamentchange_load_speed) + 0.5f);
uiCfg.filament_unloading_time = (uint32_t)((gCfgItems.filamentchange_unload_length * 60.0f / gCfgItems.filamentchange_unload_speed) + 0.5f);
}
void update_spi_flash() {

8
Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h

@ -201,11 +201,9 @@ typedef struct {
int filamentchange_load_length,
filamentchange_load_speed,
filamentchange_unload_length,
filamentchange_unload_speed,
filament_limit_temper;
float pausePosX,
pausePosY,
pausePosZ;
filamentchange_unload_speed;
int16_t filament_limit_temp;
float pausePosX, pausePosY, pausePosZ;
uint32_t curFilesize;
} CFG_ITMES;

Loading…
Cancel
Save