Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feedrate and flow percentages added to PLR FR #23535 #27201

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions Marlin/src/feature/powerloss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW
// info.sdpos and info.current_position are pre-filled from the Stepper ISR

info.feedrate = uint16_t(MMS_TO_MMM(feedrate_mm_s));
info.feedrate_percentage = feedrate_percentage;
COPY(info.flow_percentage, planner.flow_percentage);

info.zraise = zraise;
info.flag.raised = raised; // Was Z raised before power-off?

Expand All @@ -216,7 +219,7 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW
#if DISABLED(NO_VOLUMETRICS)
info.flag.volumetric_enabled = parser.volumetric_enabled;
#if HAS_MULTI_EXTRUDER
EXTRUDER_LOOP() info.filament_size[e] = planner.filament_size[e];
COPY(info.filament_size, planner.filament_size);
#else
if (parser.volumetric_enabled) info.filament_size[0] = planner.filament_size[active_extruder];
#endif
Expand Down Expand Up @@ -269,7 +272,10 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW

#if POWER_LOSS_RETRACT_LEN
// Retract filament now
gcode.process_subcommands_now(F("G1 F3000 E-" STRINGIFY(POWER_LOSS_RETRACT_LEN)));
const uint16_t old_flow = planner.flow_percentage[active_extruder];
planner.set_flow(active_extruder, 100);
gcode.process_subcommands_now(F("G1F3000E-" STRINGIFY(POWER_LOSS_RETRACT_LEN)));
planner.set_flow(active_extruder, old_flow);
#endif

#if POWER_LOSS_ZRAISE
Expand Down Expand Up @@ -555,8 +561,12 @@ void PrintJobRecovery::resume() {
// Move back down to the saved Z for printing
PROCESS_SUBCOMMANDS_NOW(TS(F("G1F600Z"), p_float_t(z_print, 3)));

// Restore the feedrate
// Restore the feedrate and percentage
PROCESS_SUBCOMMANDS_NOW(TS(F("G1F"), info.feedrate));
feedrate_percentage = info.feedrate_percentage;

// Flowrate percentage
EXTRUDER_LOOP() planner.set_flow(e, info.flow_percentage[e]);

// Restore E position with G92.9
PROCESS_SUBCOMMANDS_NOW(TS(F("G92.9E"), p_float_t(resume_pos.e, 3)));
Expand Down Expand Up @@ -589,7 +599,8 @@ void PrintJobRecovery::resume() {
}
DEBUG_EOL();

DEBUG_ECHOLNPGM("feedrate: ", info.feedrate);
DEBUG_ECHOLN(F("feedrate: "), info.feedrate, F(" x "), info.feedrate_percentage, '%');
EXTRUDER_LOOP() DEBUG_ECHOLN('E', e + 1, F(" flow %: "), info.flow_percentage[e]);

DEBUG_ECHOLNPGM("zraise: ", info.zraise, " ", info.flag.raised ? "(before)" : "");

Expand Down
2 changes: 2 additions & 0 deletions Marlin/src/feature/powerloss.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ typedef struct {
// Machine state
xyze_pos_t current_position;
uint16_t feedrate;
int16_t feedrate_percentage;
uint16_t flow_percentage[EXTRUDERS];

float zraise;

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/e3v2/jyersui/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ void JyersDWIN::drawStatusArea(const bool icons/*=false*/) {
}
if (planner.flow_percentage[0] != flow) {
flow = planner.flow_percentage[0];
dwinDrawIntValue(true, true, 0, DWIN_FONT_STAT, getColor(eeprom_settings.status_area_text, COLOR_WHITE), COLOR_BG_BLACK, 3, 116 + 2 * STAT_CHR_W, 417, planner.flow_percentage[0]);
dwinDrawIntValue(true, true, 0, DWIN_FONT_STAT, getColor(eeprom_settings.status_area_text, COLOR_WHITE), COLOR_BG_BLACK, 3, 116 + 2 * STAT_CHR_W, 417, flow);
}
#endif

Expand Down
47 changes: 11 additions & 36 deletions Marlin/src/lcd/extui/mks_ui/draw_change_speed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,42 +51,22 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) {
case ID_C_ADD:
if (!editingFlowrate) {
if (feedrate_percentage < MAX_EXT_SPEED_PERCENT - uiCfg.stepPrintSpeed)
feedrate_percentage += uiCfg.stepPrintSpeed;
else
feedrate_percentage = MAX_EXT_SPEED_PERCENT;
}
if (!editingFlowrate)
feedrate_percentage = _MIN(MAX_EXT_SPEED_PERCENT, feedrate_percentage + uiCfg.stepPrintSpeed);
else {
if (planner.flow_percentage[0] < MAX_EXT_SPEED_PERCENT - uiCfg.stepPrintSpeed)
planner.flow_percentage[0] += uiCfg.stepPrintSpeed;
else
planner.flow_percentage[0] = MAX_EXT_SPEED_PERCENT;
planner.refresh_e_factor(0);
#if HAS_MULTI_EXTRUDER
planner.flow_percentage[1] = planner.flow_percentage[0];
planner.refresh_e_factor(1);
#endif
const int16_t new_flow = _MIN(MAX_EXT_SPEED_PERCENT, planner.flow_percentage[0] + uiCfg.stepPrintSpeed);
planner.set_flow(0, new_flow);
TERN_(HAS_MULTI_EXTRUDER, planner.set_flow(1, new_flow));
}
disp_print_speed();
break;
case ID_C_DEC:
if (!editingFlowrate) {
if (feedrate_percentage > MIN_EXT_SPEED_PERCENT + uiCfg.stepPrintSpeed)
feedrate_percentage -= uiCfg.stepPrintSpeed;
else
feedrate_percentage = MIN_EXT_SPEED_PERCENT;
}
if (!editingFlowrate)
feedrate_percentage = _MAX(MIN_EXT_SPEED_PERCENT, feedrate_percentage + uiCfg.stepPrintSpeed);
else {
if (planner.flow_percentage[0] > MIN_EXT_SPEED_PERCENT + uiCfg.stepPrintSpeed)
planner.flow_percentage[0] -= uiCfg.stepPrintSpeed;
else
planner.flow_percentage[0] = MIN_EXT_SPEED_PERCENT;
planner.refresh_e_factor(0);
#if HAS_MULTI_EXTRUDER
planner.flow_percentage[1] = planner.flow_percentage[0];
planner.refresh_e_factor(1);
#endif
const int16_t new_flow = _MAX(MIN_EXT_SPEED_PERCENT, planner.flow_percentage[0] - uiCfg.stepPrintSpeed);
planner.set_flow(0, new_flow);
TERN_(HAS_MULTI_EXTRUDER, planner.set_flow(1, new_flow));
}
disp_print_speed();
break;
Expand All @@ -101,12 +81,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
disp_print_speed();
break;
case ID_C_STEP:
if (uiCfg.stepPrintSpeed == 1)
uiCfg.stepPrintSpeed = 5;
else if (uiCfg.stepPrintSpeed == 5)
uiCfg.stepPrintSpeed = 10;
else
uiCfg.stepPrintSpeed = 1;
uiCfg.stepPrintSpeed = (uiCfg.stepPrintSpeed == 5) ? 10 : (uiCfg.stepPrintSpeed == 1) ? 5 : 1;
disp_speed_step();
break;
case ID_C_RETURN:
Expand Down
8 changes: 2 additions & 6 deletions Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,8 @@ static void btn_ok_event_cb(lv_obj_t *btn, lv_event_t event) {
card.openFileRead(cur_name);
if (card.isFileOpen()) {
feedrate_percentage = 100;
planner.flow_percentage[0] = 100;
planner.e_factor[0] = planner.flow_percentage[0] * 0.01f;
#if HAS_MULTI_EXTRUDER
planner.flow_percentage[1] = 100;
planner.e_factor[1] = planner.flow_percentage[1] * 0.01f;
#endif
TERN_(HAS_EXTRUDERS, planner.set_flow(0, 100));
TERN_(HAS_MULTI_EXTRUDER, planner.set_flow(1, 100));
card.startOrResumeFilePrinting();
TERN_(POWER_LOSS_RECOVERY, recovery.prepare());
once_flag = false;
Expand Down
8 changes: 2 additions & 6 deletions Marlin/src/lcd/extui/mks_ui/draw_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -660,12 +660,8 @@ char *creat_title_text() {
card.openFileRead(cur_name);
if (card.isFileOpen()) {
feedrate_percentage = 100;
planner.flow_percentage[0] = 100;
planner.e_factor[0] = planner.flow_percentage[0] * 0.01;
#if HAS_MULTI_EXTRUDER
planner.flow_percentage[1] = 100;
planner.e_factor[1] = planner.flow_percentage[1] * 0.01;
#endif
TERN_(HAS_EXTRUDERS, planner.set_flow(0, 100));
TERN_(HAS_MULTI_EXTRUDER, planner.set_flow(1, 100));
card.startOrResumeFilePrinting();
TERN_(POWER_LOSS_RECOVERY, recovery.prepare());
once_flag = false;
Expand Down
10 changes: 2 additions & 8 deletions Marlin/src/lcd/extui/mks_ui/wifi_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1011,14 +1011,8 @@ static void wifi_gcode_exec(uint8_t * const cmd_line) {
if (card.isFileOpen()) {
//saved_feedrate_percentage = feedrate_percentage;
feedrate_percentage = 100;
#if HAS_EXTRUDERS
planner.flow_percentage[0] = 100;
planner.e_factor[0] = planner.flow_percentage[0] * 0.01f;
#endif
#if HAS_MULTI_EXTRUDER
planner.flow_percentage[1] = 100;
planner.e_factor[1] = planner.flow_percentage[1] * 0.01f;
#endif
TERN_(HAS_EXTRUDERS, planner.set_flow(0, 100));
TERN_(HAS_MULTI_EXTRUDER, planner.set_flow(1, 100));
card.startOrResumeFilePrinting();
TERN_(POWER_LOSS_RECOVERY, recovery.prepare());
once_flag = false;
Expand Down
Loading