Fix manual move with MKS H43 (#21511)

Co-authored-by: Scott Lahteine <github@thinkyhead.com>
This commit is contained in:
Sola
2021-04-10 04:29:59 +08:00
committed by GitHub
parent 8048d1411f
commit 4cba40f9fd
5 changed files with 52 additions and 18 deletions

View File

@@ -840,7 +840,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
// buf[4] = axiscode;
char buf[6];
sprintf(buf,"G28 %c",axiscode);
sprintf(buf, "G28 %c", axiscode);
//DEBUG_ECHOPAIR(" ", buf);
queue.enqueue_one_now(buf);
//DEBUG_ECHOLNPGM(" ✓");
@@ -1190,17 +1190,18 @@ void DGUSScreenHandler::GetManualFilamentSpeed(DGUS_VP_Variable &var, void *val_
uint16_t value_len = swap16(*(uint16_t*)val_ptr);
DEBUG_ECHOLNPAIR_F("FilamentSpeed value:", value_len);
DEBUG_ECHOLNPAIR_F("filamentSpeed_mm_s value:", value_len);
FilamentSpeed = value_len;
filamentSpeed_mm_s = value_len;
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
}
void DGUSScreenHandler::MKS_FilamentLoadUnload(DGUS_VP_Variable &var, void *val_ptr, const int filamentDir) {
#if EITHER(HAS_MULTI_HOTEND, SINGLENOZZLE)
char buf[40];
uint8_t swap_tool = 0;
#else
constexpr uint8_t swap_tool = 1; // T0 (or none at all)
#endif
#if HAS_HOTEND
@@ -1215,9 +1216,8 @@ void DGUSScreenHandler::MKS_FilamentLoadUnload(DGUS_VP_Variable &var, void *val_
default: break;
case 0:
#if HAS_HOTEND
if (thermalManager.tooColdToExtrude(0)) {
if (thermalManager.tooColdToExtrude(0))
hotend_too_cold = 1;
}
else {
#if EITHER(HAS_MULTI_HOTEND, SINGLENOZZLE)
swap_tool = 1;
@@ -1243,15 +1243,41 @@ void DGUSScreenHandler::MKS_FilamentLoadUnload(DGUS_VP_Variable &var, void *val_
}
#endif
if (swap_tool) {
char buf[30];
snprintf_P(buf, 30
#if EITHER(HAS_MULTI_HOTEND, SINGLENOZZLE)
, PSTR("M1002T%cE%dF%d"), char('0' + swap_tool - 1)
#else
, PSTR("M1002E%dF%d")
#endif
, (int)distanceFilament * filamentDir, filamentSpeed_mm_s * 60
);
queue.inject(buf);
}
}
/**
* M1002: Do a tool-change and relative move for MKS_FilamentLoadUnload
* within the G-code execution window for best concurrency.
*/
void GcodeSuite::M1002() {
#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 * filamentDir, FilamentSpeed * 60);
queue.enqueue_one_now(buf);
queue.enqueue_now_P(PSTR("G90"));
}
{
char buf[3];
sprintf_P(buf, PSTR("T%c"), char('0' + parser.intval('T')));
process_subcommands_now(buf);
}
#endif
const uint8_t old_axis_relative = axis_relative;
set_e_relative(true); // M83
{
char buf[20];
snprintf_P(buf, 20, PSTR("G1E%dF%d"), parser.intval('E'), parser.intval('F'));
process_subcommands_now(buf);
}
axis_relative = old_axis_relative;
}
void DGUSScreenHandler::MKS_FilamentLoad(DGUS_VP_Variable &var, void *val_ptr) {
@@ -1445,7 +1471,7 @@ void DGUSScreenHandler::LanguagePInit() {
void DGUSScreenHandler::DGUS_ExtrudeLoadInit(void) {
ex_filament.ex_length = distanceFilament;
ex_filament.ex_load_unload_flag = 0;
ex_filament.ex_need_time = FilamentSpeed;
ex_filament.ex_need_time = filamentSpeed_mm_s;
ex_filament.ex_speed = 0;
ex_filament.ex_status = EX_NONE;
ex_filament.ex_tick_end = 0;