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

E3V2/LCD: unify limits for feedrate, acc, jerk and steps #25045

Merged
merged 2 commits into from
May 18, 2023
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
94 changes: 94 additions & 0 deletions Marlin/src/lcd/e3v2/common/limits.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once

/*****************************************************************************
* @file lcd/e3v2/common/limits.h
* @brief Limits for UI values
****************************************************************************/

#include "../../../inc/MarlinConfig.h"

// If max edit values are not specified use default * DEFAULT_MAX_MULTIPLIER
#define DEFAULT_MAX_MULTIPLIER 2

//
// Feedrate limits
//
#define MIN_FEEDRATE_EDIT_VALUE 1

constexpr xyze_float_t min_feedrate_edit_values = LOGICAL_AXIS_ARRAY_1(MIN_FEEDRATE_EDIT_VALUE),
default_max_feedrate = DEFAULT_MAX_FEEDRATE,
max_feedrate_edit_values =
#ifdef MAX_FEEDRATE_EDIT_VALUES
MAX_FEEDRATE_EDIT_VALUES
#else
default_max_feedrate * float(DEFAULT_MAX_MULTIPLIER)
#endif
;

//
// Acceleration limits
//
#define MIN_ACCELERATION_EDIT_VALUE 1

constexpr xyze_float_t min_acceleration_edit_values = LOGICAL_AXIS_ARRAY_1(MIN_ACCELERATION_EDIT_VALUE),
default_max_acceleration = DEFAULT_MAX_ACCELERATION,
max_acceleration_edit_values =
#ifdef MAX_ACCEL_EDIT_VALUES
MAX_ACCEL_EDIT_VALUES
#else
default_max_acceleration * float(DEFAULT_MAX_MULTIPLIER)
#endif
;

//
// Max jerk limits
//
#define MIN_JERK_EDIT_VALUE 0.1
#define DEFAULT_MAX_JERK_MULTIPLIER 2

#if HAS_CLASSIC_JERK
constexpr xyze_float_t min_jerk_edit_values = LOGICAL_AXIS_ARRAY_1(MIN_JERK_EDIT_VALUE),
default_jerk = LOGICAL_AXIS_ARRAY(
DEFAULT_EJERK,
DEFAULT_XJERK, DEFAULT_YJERK, DEFAULT_ZJERK,
DEFAULT_IJERK, DEFAULT_JJERK, DEFAULT_KJERK,
DEFAULT_UJERK, DEFAULT_VJERK, DEFAULT_WJERK
),
max_jerk_edit_values =
#ifdef MAX_JERK_EDIT_VALUES
MAX_JERK_EDIT_VALUES
#else
default_jerk * float(DEFAULT_MAX_JERK_MULTIPLIER)
#endif
;
#endif

//
// Steps per mm limits
//
#define MIN_STEPS_EDIT_VALUE 1

constexpr xyze_float_t min_steps_edit_values = LOGICAL_AXIS_ARRAY_1(MIN_STEPS_EDIT_VALUE),
default_steps = DEFAULT_AXIS_STEPS_PER_UNIT,
max_steps_edit_values = default_steps * float(DEFAULT_MAX_MULTIPLIER);
29 changes: 6 additions & 23 deletions Marlin/src/lcd/e3v2/creality/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,6 @@
#define MIN_PRINT_SPEED 10
#define MAX_PRINT_SPEED 999

// Feedspeed limit (max feedspeed = DEFAULT_MAX_FEEDRATE * 2)
#define MIN_MAXFEEDSPEED 1
#define MIN_MAXACCELERATION 1
#define MIN_MAXJERK 0.1
#define MIN_STEP 1

#define FEEDRATE_E (60)

// Minimum unit (0.1) : multiple (10)
Expand Down Expand Up @@ -181,13 +175,6 @@ uint8_t index_file = MROWS,

bool dwin_abort_flag = false; // Flag to reset feedrate, return to Home

constexpr float default_max_feedrate[] = DEFAULT_MAX_FEEDRATE;
constexpr float default_max_acceleration[] = DEFAULT_MAX_ACCELERATION;

#if HAS_CLASSIC_JERK
constexpr float default_max_jerk[] = { DEFAULT_XJERK, DEFAULT_YJERK, DEFAULT_ZJERK, DEFAULT_EJERK };
#endif

static uint8_t _card_percent = 0;
static uint16_t _remain_time = 0;

Expand Down Expand Up @@ -1568,8 +1555,7 @@ void HMI_MaxFeedspeedXYZE() {
}
// MaxFeedspeed limit
if (WITHIN(HMI_flag.feedspeed_axis, X_AXIS, LAST_AXIS))
NOMORE(HMI_ValueStruct.Max_Feedspeed, default_max_feedrate[HMI_flag.feedspeed_axis] * 2);
if (HMI_ValueStruct.Max_Feedspeed < MIN_MAXFEEDSPEED) HMI_ValueStruct.Max_Feedspeed = MIN_MAXFEEDSPEED;
LIMIT(HMI_ValueStruct.Max_Feedspeed, min_feedrate_edit_values[HMI_flag.feedspeed_axis], max_feedrate_edit_values[HMI_flag.feedspeed_axis]);
// MaxFeedspeed value
Draw_Edit_Integer4(select_speed.now, HMI_ValueStruct.Max_Feedspeed, true);
}
Expand All @@ -1587,8 +1573,7 @@ void HMI_MaxAccelerationXYZE() {
}
// MaxAcceleration limit
if (WITHIN(HMI_flag.acc_axis, X_AXIS, LAST_AXIS))
NOMORE(HMI_ValueStruct.Max_Acceleration, default_max_acceleration[HMI_flag.acc_axis] * 2);
if (HMI_ValueStruct.Max_Acceleration < MIN_MAXACCELERATION) HMI_ValueStruct.Max_Acceleration = MIN_MAXACCELERATION;
LIMIT(HMI_ValueStruct.Max_Acceleration, min_acceleration_edit_values[HMI_flag.acc_axis], max_acceleration_edit_values[HMI_flag.acc_axis]);
// MaxAcceleration value
Draw_Edit_Integer4(select_acc.now, HMI_ValueStruct.Max_Acceleration, true);
}
Expand All @@ -1602,14 +1587,13 @@ void HMI_MaxAccelerationXYZE() {
checkkey = MaxJerk;
EncoderRate.enabled = false;
if (WITHIN(HMI_flag.jerk_axis, X_AXIS, LAST_AXIS))
planner.set_max_jerk(HMI_flag.jerk_axis, HMI_ValueStruct.Max_Jerk_scaled / 10);
planner.set_max_jerk(HMI_flag.jerk_axis, HMI_ValueStruct.Max_Jerk_scaled / MINUNITMULT);
Draw_Edit_Float3(select_jerk.now, HMI_ValueStruct.Max_Jerk_scaled);
return;
}
// MaxJerk limit
if (WITHIN(HMI_flag.jerk_axis, X_AXIS, LAST_AXIS))
NOMORE(HMI_ValueStruct.Max_Jerk_scaled, default_max_jerk[HMI_flag.jerk_axis] * 2 * MINUNITMULT);
NOLESS(HMI_ValueStruct.Max_Jerk_scaled, (MIN_MAXJERK) * MINUNITMULT);
LIMIT(HMI_ValueStruct.Max_Jerk_scaled, min_jerk_edit_values[HMI_flag.jerk_axis] * MINUNITMULT, max_jerk_edit_values[HMI_flag.jerk_axis] * MINUNITMULT);
// MaxJerk value
Draw_Edit_Float3(select_jerk.now, HMI_ValueStruct.Max_Jerk_scaled, true);
}
Expand All @@ -1623,14 +1607,13 @@ void HMI_StepXYZE() {
checkkey = Step;
EncoderRate.enabled = false;
if (WITHIN(HMI_flag.step_axis, X_AXIS, LAST_AXIS))
planner.settings.axis_steps_per_mm[HMI_flag.step_axis] = HMI_ValueStruct.Max_Step_scaled / 10;
planner.settings.axis_steps_per_mm[HMI_flag.step_axis] = HMI_ValueStruct.Max_Step_scaled / MINUNITMULT;
Draw_Edit_Float3(select_step.now, HMI_ValueStruct.Max_Step_scaled);
return;
}
// Step limit
if (WITHIN(HMI_flag.step_axis, X_AXIS, LAST_AXIS))
NOMORE(HMI_ValueStruct.Max_Step_scaled, 999.9 * MINUNITMULT);
NOLESS(HMI_ValueStruct.Max_Step_scaled, MIN_STEP);
LIMIT(HMI_ValueStruct.Max_Step_scaled, min_steps_edit_values[HMI_flag.step_axis] * MINUNITMULT, max_steps_edit_values[HMI_flag.step_axis] * MINUNITMULT);
// Step value
Draw_Edit_Float3(select_step.now, HMI_ValueStruct.Max_Step_scaled, true);
}
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/lcd/e3v2/creality/dwin.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include "dwin_lcd.h"
#include "../common/encoder.h"
#include "../common/limits.h"
#include "../../../libs/BL24CXX.h"

#include "../../../inc/MarlinConfigPre.h"
Expand Down
Loading