Skip to content

Commit

Permalink
MKS H43 fix, cleanup (MarlinFirmware#21485)
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Lahteine <[email protected]>
  • Loading branch information
2 people authored and hliebscher committed Mar 31, 2021
1 parent 0d126bd commit e2ab74d
Show file tree
Hide file tree
Showing 8 changed files with 207 additions and 210 deletions.
6 changes: 5 additions & 1 deletion Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -2376,7 +2376,11 @@
//#define DGUS_LCD_UI_ORIGIN
//#define DGUS_LCD_UI_FYSETC
//#define DGUS_LCD_UI_HIPRECY
//#define DGUS_LCD_UI_MKS

// #define DGUS_LCD_UI_MKS
#if ENABLED(DGUS_LCD_UI_MKS)
#define USE_MKS_GREEN_UI
#endif

//
// Touch-screen LCD for Malyan M200/M300 printers
Expand Down
3 changes: 3 additions & 0 deletions Marlin/src/HAL/LPC1768/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ extern DefaultSerial1 USBSerial;
#else
#error "LCD_SERIAL_PORT must be from -1 to 3. Please update your configuration."
#endif
#if HAS_DGUS_LCD
#define SERIAL_GET_TX_BUFFER_FREE() MSerial0.available()
#endif
#endif

//
Expand Down
8 changes: 5 additions & 3 deletions Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ void DGUSDisplay::InitDisplay() {
#define LCD_BAUDRATE 115200
#endif
LCD_SERIAL.begin(LCD_BAUDRATE);
#if BOTH(DGUS_LCD_UI_MKS, POWER_LOSS_RECOVERY)
if (!recovery.valid()) delay(LOGO_TIME_DELAY);
#endif

if (TERN1(POWER_LOSS_RECOVERY, !recovery.valid())) { // If no Power-Loss Recovery is needed...
TERN_(DGUS_LCD_UI_MKS, delay(LOGO_TIME_DELAY)); // Show the logo for a little while
}

RequestScreen(TERN(SHOW_BOOTSCREEN, DGUSLCD_SCREEN_BOOT, DGUSLCD_SCREEN_MAIN));
}

Expand Down
97 changes: 42 additions & 55 deletions Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,58 +43,45 @@
uint16_t distanceToMove = 10;
#endif

uint16_t distanceMove = 1;
uint16_t manualMoveStep = 1;
float distanceFilament = 10;
uint16_t FilamentSpeed = 25;
float ZOffset_distance = 0.1;
float mesh_adj_distance = 0.1;
float mesh_adj_distance = 0.01;
float Z_distance = 0.1;

int16_t level_1_x_point = 20;
int16_t level_1_y_point = 20;

int16_t level_2_x_point = 20;
int16_t level_2_y_point = 20;

int16_t level_3_x_point = 20;
int16_t level_3_y_point = 20;

int16_t level_4_x_point = 20;
int16_t level_4_y_point = 20;
int16_t level_5_x_point = X_MAX_POS / 2;
int16_t level_5_y_point = Y_MAX_POS / 2;

uint16_t tim_h;
uint16_t tim_m;
uint16_t tim_s;

uint16_t x_park_pos = 20;
uint16_t y_park_pos = 20;
uint16_t z_park_pos = 10;
//struct { uint16_t h, m, s; } dgus_time;

//
// Persistent settings
//
xy_int_t mks_corner_offsets[5]; // Initialized by settings.load()
xyz_int_t mks_park_pos; // Initialized by settings.load()
celsius_t mks_min_extrusion_temp; // Initialized by settings.load()

void MKS_reset_settings() {
constexpr xy_int_t init_dgus_level_offsets[5] = {
{ 20, 20 }, { 20, 20 },
{ 20, 20 }, { 20, 20 },
{ X_CENTER, Y_CENTER }
};
mks_language_index = 0;
COPY(mks_corner_offsets, init_dgus_level_offsets);
mks_park_pos.set(20, 20, 10);
mks_min_extrusion_temp = 0;
}

xyz_pos_t position_before_pause;

void MKS_pause_print_move() {
queue.exhaust();
position_before_pause = current_position;
do_blocking_move_to(X_MIN_POS + x_park_pos, Y_MIN_POS + y_park_pos, current_position.z + z_park_pos);
do_blocking_move_to(X_MIN_POS + mks_park_pos.x, Y_MIN_POS + mks_park_pos.y, current_position.z + mks_park_pos.z);
}

void MKS_resume_print_move() { do_blocking_move_to(position_before_pause); }

uint16_t min_ex_temp = 0;

float z_offset_add = 0;

#if ENABLED(SENSORLESS_HOMING)
uint16_t tmc_x_step = 0;
uint16_t tmc_y_step = 0;
uint16_t tmc_z_step = 0;
#else
uint16_t tmc_x_step = 0;
uint16_t tmc_y_step = 0;
uint16_t tmc_z_step = 0;
#endif
xyz_int_t tmc_step; // = { 0, 0, 0 }

uint16_t lcd_default_light = 50;

Expand Down Expand Up @@ -525,7 +512,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
VPHELPER(VP_Y_HOME, nullptr, &ScreenHandler.HandleManualMove, nullptr),
VPHELPER(VP_Z_HOME, nullptr, &ScreenHandler.HandleManualMove, nullptr),

VPHELPER(VP_MOVE_DISTANCE, &distanceMove, &ScreenHandler.GetManualMovestep, nullptr),
VPHELPER(VP_MOVE_DISTANCE, &manualMoveStep, &ScreenHandler.GetManualMovestep, nullptr),

VPHELPER(VP_MOTOR_LOCK_UNLOK, nullptr, &ScreenHandler.HandleManualMove, nullptr),
VPHELPER(VP_LEVEL_POINT, nullptr, &ScreenHandler.ManualAssistLeveling, nullptr),
Expand Down Expand Up @@ -567,7 +554,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
#if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
VPHELPER(VP_LOAD_Filament, nullptr, &ScreenHandler.MKS_FilamentLoad, nullptr),
VPHELPER(VP_UNLOAD_Filament, nullptr, &ScreenHandler.MKS_FilamentUnLoad, nullptr),
VPHELPER(VP_Filament_distance, &distanceFilament, &ScreenHandler.GetManualFilament, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
VPHELPER(VP_Filament_distance, &distanceFilament, &ScreenHandler.GetManualFilament, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>),
VPHELPER(VP_Filament_speed, &FilamentSpeed, &ScreenHandler.GetManualFilamentSpeed, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
#endif
#endif
Expand Down Expand Up @@ -623,16 +610,16 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
VPHELPER(VP_ZPos, &current_position.z, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),

// Level Point Set
VPHELPER(VP_Level_Point_One_X, &level_1_x_point, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_One_Y, &level_1_y_point, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Two_X, &level_2_x_point, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Two_Y, &level_2_y_point, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Three_X, &level_3_x_point, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Three_Y, &level_3_y_point, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Four_X, &level_4_x_point, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Four_Y, &level_4_y_point, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Five_X, &level_5_x_point, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Five_Y, &level_5_y_point, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_One_X, &mks_corner_offsets[0].x, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_One_Y, &mks_corner_offsets[0].y, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Two_X, &mks_corner_offsets[1].x, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Two_Y, &mks_corner_offsets[1].y, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Three_X, &mks_corner_offsets[2].x, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Three_Y, &mks_corner_offsets[2].y, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Four_X, &mks_corner_offsets[3].x, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Four_Y, &mks_corner_offsets[3].y, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Five_X, &mks_corner_offsets[4].x, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Level_Point_Five_Y, &mks_corner_offsets[4].y, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),

// Print Progress
VPHELPER(VP_PrintProgress_Percentage, nullptr, nullptr, ScreenHandler.DGUSLCD_SendPrintProgressToDisplay),
Expand Down Expand Up @@ -679,20 +666,20 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
VPHELPER(VP_T_F_SPEED, (uint16_t *)&planner.settings.min_travel_feedrate_mm_s, ScreenHandler.HandleMin_T_F_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
VPHELPER(VP_ACC_SPEED, (uint16_t *)&planner.settings.acceleration, ScreenHandler.HandleAccChange_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),

VPHELPER(VP_X_PARK_POS, &x_park_pos, ScreenHandler.GetParkPos_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Y_PARK_POS, &y_park_pos, ScreenHandler.GetParkPos_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Z_PARK_POS, &z_park_pos, ScreenHandler.GetParkPos_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_X_PARK_POS, &mks_park_pos.x, ScreenHandler.GetParkPos_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Y_PARK_POS, &mks_park_pos.y, ScreenHandler.GetParkPos_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Z_PARK_POS, &mks_park_pos.z, ScreenHandler.GetParkPos_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_MIN_EX_T, &thermalManager.extrude_min_temp, ScreenHandler.HandleGetExMinTemp_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay),

#if ENABLED(SENSORLESS_HOMING) // TMC SENSORLESS Setting
#if AXIS_HAS_STEALTHCHOP(X)
VPHELPER(VP_TMC_X_STEP, &tmc_x_step, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendTMCStepValue),
VPHELPER(VP_TMC_X_STEP, &tmc_step.x, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendTMCStepValue),
#endif
#if AXIS_HAS_STEALTHCHOP(Y)
VPHELPER(VP_TMC_Y_STEP, &tmc_y_step, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendTMCStepValue),
VPHELPER(VP_TMC_Y_STEP, &tmc_step.y, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendTMCStepValue),
#endif
#if AXIS_HAS_STEALTHCHOP(Z)
VPHELPER(VP_TMC_Z_STEP, &tmc_z_step, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendTMCStepValue),
VPHELPER(VP_TMC_Z_STEP, &tmc_step.z, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendTMCStepValue),
#endif
#endif

Expand Down
37 changes: 10 additions & 27 deletions Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

#include "../DGUSDisplayDef.h"

#define USE_MKS_GREEN_UI
//#define DGUS_MKS_RUNOUT_SENSOR

#define LOGO_TIME_DELAY TERN(USE_MKS_GREEN_UI, 8000, 1500)
Expand All @@ -36,43 +35,27 @@

#define MKS_FINSH

extern uint16_t distanceMove;
extern uint16_t manualMoveStep;
extern float distanceFilament;
extern uint16_t FilamentSpeed;
extern float ZOffset_distance;
extern float mesh_adj_distance;
extern float Z_distance;

extern int16_t level_1_x_point;
extern int16_t level_1_y_point;
extern int16_t level_2_x_point;
extern int16_t level_2_y_point;
extern int16_t level_3_x_point;
extern int16_t level_3_y_point;
extern int16_t level_4_x_point;
extern int16_t level_4_y_point;
extern int16_t level_5_x_point;
extern int16_t level_5_y_point;

extern uint16_t tim_h;
extern uint16_t tim_m;
extern uint16_t tim_s;

extern uint16_t x_park_pos;
extern uint16_t y_park_pos;
extern uint16_t z_park_pos;

extern xyz_pos_t position_before_pause;
//extern struct { uint16_t h, m, s; } dgus_time;

extern xy_int_t mks_corner_offsets[5];
extern xyz_int_t mks_park_pos;
extern celsius_t mks_min_extrusion_temp;

void MKS_reset_settings(); // Restore persistent settings to defaults

void MKS_pause_print_move();
void MKS_resume_print_move();

extern uint16_t min_ex_temp;

extern float z_offset_add;

extern uint16_t tmc_x_step;
extern uint16_t tmc_y_step;
extern uint16_t tmc_z_step;
xyz_int_t tmc_step;

extern uint16_t lcd_default_light;

Expand Down
Loading

0 comments on commit e2ab74d

Please sign in to comment.