Skip to content

Commit

Permalink
🔧 Update CLASSIC_JERK conditionals
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Dec 14, 2023
1 parent 8bce9de commit 75da355
Show file tree
Hide file tree
Showing 21 changed files with 83 additions and 93 deletions.
4 changes: 2 additions & 2 deletions Marlin/src/gcode/calibrate/G28.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
planner.settings.max_acceleration_mm_per_s2[X_AXIS] = 100;
planner.settings.max_acceleration_mm_per_s2[Y_AXIS] = 100;
TERN_(DELTA, planner.settings.max_acceleration_mm_per_s2[Z_AXIS] = 100);
#if HAS_CLASSIC_JERK
#if ENABLED(CLASSIC_JERK)
motion_state.jerk_state = planner.max_jerk;
planner.max_jerk.set(0, 0 OPTARG(DELTA, 0));
#endif
Expand All @@ -167,7 +167,7 @@
planner.settings.max_acceleration_mm_per_s2[X_AXIS] = motion_state.acceleration.x;
planner.settings.max_acceleration_mm_per_s2[Y_AXIS] = motion_state.acceleration.y;
TERN_(DELTA, planner.settings.max_acceleration_mm_per_s2[Z_AXIS] = motion_state.acceleration.z);
TERN_(HAS_CLASSIC_JERK, planner.max_jerk = motion_state.jerk_state);
TERN_(CLASSIC_JERK, planner.max_jerk = motion_state.jerk_state);
planner.refresh_acceleration_rates();
}

Expand Down
10 changes: 5 additions & 5 deletions Marlin/src/gcode/config/M200-M205.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ void GcodeSuite::M205() {
if (parser.seenval('S')) planner.settings.min_feedrate_mm_s = parser.value_linear_units();
if (parser.seenval('T')) planner.settings.min_travel_feedrate_mm_s = parser.value_linear_units();
#if HAS_JUNCTION_DEVIATION
#if HAS_CLASSIC_JERK && AXIS_COLLISION('J')
#if ENABLED(CLASSIC_JERK) && AXIS_COLLISION('J')
#error "Can't set_max_jerk for 'J' axis because 'J' is used for Junction Deviation."
#endif
if (parser.seenval('J')) {
Expand All @@ -310,7 +310,7 @@ void GcodeSuite::M205() {
SERIAL_ERROR_MSG("?J out of range (0.01 to 0.3)");
}
#endif
#if HAS_CLASSIC_JERK
#if ENABLED(CLASSIC_JERK)
bool seenZ = false;
LOGICAL_AXIS_CODE(
if (parser.seenval('E')) planner.set_max_jerk(E_AXIS, parser.value_linear_units()),
Expand All @@ -328,14 +328,14 @@ void GcodeSuite::M205() {
if (seenZ && planner.max_jerk.z <= 0.1f)
SERIAL_ECHOLNPGM("WARNING! Low Z Jerk may lead to unwanted pauses.");
#endif
#endif // HAS_CLASSIC_JERK
#endif // CLASSIC_JERK
}

void GcodeSuite::M205_report(const bool forReplay/*=true*/) {
report_heading_etc(forReplay, F(
"Advanced (" M205_MIN_SEG_TIME_STR "<min_segment_time_us> S<min_feedrate> T<min_travel_feedrate>"
TERN_(HAS_JUNCTION_DEVIATION, " J<junc_dev>")
#if HAS_CLASSIC_JERK
#if ENABLED(CLASSIC_JERK)
NUM_AXIS_GANG(
" X<max_jerk>", " Y<max_jerk>", " Z<max_jerk>",
" " STR_I "<max_jerk>", " " STR_J "<max_jerk>", " " STR_K "<max_jerk>",
Expand All @@ -352,7 +352,7 @@ void GcodeSuite::M205_report(const bool forReplay/*=true*/) {
#if HAS_JUNCTION_DEVIATION
, PSTR(" J"), LINEAR_UNIT(planner.junction_deviation_mm)
#endif
#if HAS_CLASSIC_JERK && NUM_AXES
#if ENABLED(CLASSIC_JERK) && NUM_AXES
, LIST_N(DOUBLE(NUM_AXES),
SP_X_STR, LINEAR_UNIT(planner.max_jerk.x),
SP_Y_STR, LINEAR_UNIT(planner.max_jerk.y),
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/config/M92.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void GcodeSuite::M92() {
const float value = parser.value_per_axis_units((AxisEnum)(E_AXIS_N(target_extruder)));
if (value < 20) {
float factor = planner.settings.axis_steps_per_mm[E_AXIS_N(target_extruder)] / value; // increase e constants if M92 E14 is given for netfab.
#if HAS_CLASSIC_JERK && HAS_CLASSIC_E_JERK
#if ALL(CLASSIC_JERK, HAS_CLASSIC_E_JERK)
planner.max_jerk.e *= factor;
#endif
planner.settings.max_feedrate_mm_s[E_AXIS_N(target_extruder)] *= factor;
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/gcode/host/M360.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void GcodeSuite::M360() {
//
// XYZ Axis Jerk
//
#if HAS_CLASSIC_JERK
#if ENABLED(CLASSIC_JERK)
if (planner.max_jerk.x == planner.max_jerk.y)
config_line(F("XY"), planner.max_jerk.x, FPSTR(JERK_STR));
else {
Expand Down Expand Up @@ -182,7 +182,7 @@ void GcodeSuite::M360() {
config_line(F("NumExtruder"), EXTRUDERS);
#if HAS_EXTRUDERS
EXTRUDER_LOOP() {
config_line_e(e, JERK_STR, TERN(HAS_LINEAR_E_JERK, planner.max_e_jerk[E_INDEX_N(e)], TERN(HAS_CLASSIC_JERK, planner.max_jerk.e, DEFAULT_EJERK)));
config_line_e(e, JERK_STR, TERN(HAS_LINEAR_E_JERK, planner.max_e_jerk[E_INDEX_N(e)], TERN(CLASSIC_JERK, planner.max_jerk.e, DEFAULT_EJERK)));
config_line_e(e, F("MaxSpeed"), planner.settings.max_feedrate_mm_s[E_AXIS_N(e)]);
config_line_e(e, F("Acceleration"), planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(e)]);
config_line_e(e, F("Diameter"), TERN(NO_VOLUMETRICS, DEFAULT_NOMINAL_FILAMENT_DIA, planner.filament_size[e]));
Expand Down
14 changes: 0 additions & 14 deletions Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -1615,20 +1615,6 @@
#undef DELTA_HOME_TO_SAFE_ZONE
#endif

// This flag indicates some kind of jerk storage is needed
#if ANY(CLASSIC_JERK, IS_KINEMATIC)
#define HAS_CLASSIC_JERK 1
#endif

#if DISABLED(CLASSIC_JERK)
#define HAS_JUNCTION_DEVIATION 1
#endif

// E jerk exists with JD disabled (of course) but also when Linear Advance is disabled on Delta/SCARA
#if HAS_EXTRUDERS && (ENABLED(CLASSIC_JERK) || (IS_KINEMATIC && DISABLED(LIN_ADVANCE)))
#define HAS_CLASSIC_E_JERK 1
#endif

//
// Serial Port Info
//
Expand Down
15 changes: 15 additions & 0 deletions Marlin/src/inc/Conditionals_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,21 @@
#endif
#endif

// Use Junction Deviation for motion if Jerk is disabled
#if DISABLED(CLASSIC_JERK)
#define HAS_JUNCTION_DEVIATION 1
#endif

// E jerk exists with JD disabled (of course) but also when Linear Advance is disabled on Delta/SCARA
#if HAS_EXTRUDERS && (ENABLED(CLASSIC_JERK) || (IS_KINEMATIC && DISABLED(LIN_ADVANCE)))
#define HAS_CLASSIC_E_JERK 1
#endif

// Linear advance uses Jerk since E is an isolated axis
#if ALL(HAS_JUNCTION_DEVIATION, LIN_ADVANCE)
#define HAS_LINEAR_E_JERK 1
#endif

/**
* Temperature Sensors; define what sensor(s) we have.
*/
Expand Down
5 changes: 0 additions & 5 deletions Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@
#define ADC_VREF_MV HAL_ADC_VREF_MV
#endif

// Linear advance uses Jerk since E is an isolated axis
#if ALL(HAS_JUNCTION_DEVIATION, LIN_ADVANCE)
#define HAS_LINEAR_E_JERK 1
#endif

// Determine which type of 'EEPROM' is in use
#if ENABLED(EEPROM_SETTINGS)
// EEPROM type may be defined by compile flags, configs, HALs, or pins
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L
* Junction deviation is incompatible with kinematic systems.
*/
#if HAS_JUNCTION_DEVIATION && IS_KINEMATIC
#error "CLASSIC_JERK is required for DELTA, SCARA, and POLAR."
#error "CLASSIC_JERK is required for the kinematics of DELTA, SCARA, POLAR, etc."
#endif

/**
Expand Down Expand Up @@ -1583,7 +1583,7 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L
#error "Only enable RESTORE_LEVELING_AFTER_G28 or ENABLE_LEVELING_AFTER_G28, but not both."
#endif

#if HAS_MESH && HAS_CLASSIC_JERK
#if ALL(HAS_MESH, CLASSIC_JERK)
static_assert(DEFAULT_ZJERK > 0.1, "Low DEFAULT_ZJERK values are incompatible with mesh-based leveling.");
#endif
#if HAS_MESH && DGUS_LCD_UI_IA_CREALITY && GRID_MAX_POINTS > 25
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/e3v2/common/limits.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ constexpr xyze_float_t min_acceleration_edit_values = LOGICAL_AXIS_ARRAY_1(MIN_A
#define MIN_JERK_EDIT_VALUE 0.1
#define DEFAULT_MAX_JERK_MULTIPLIER 2

#if HAS_CLASSIC_JERK
#if ENABLED(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,
Expand Down
26 changes: 13 additions & 13 deletions Marlin/src/lcd/e3v2/creality/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ void drawBackFirst(const bool is_sel=true) {

#define MOTION_CASE_RATE 1
#define MOTION_CASE_ACCEL 2
#define MOTION_CASE_JERK (MOTION_CASE_ACCEL + ENABLED(HAS_CLASSIC_JERK))
#define MOTION_CASE_JERK (MOTION_CASE_ACCEL + ENABLED(CLASSIC_JERK))
#define MOTION_CASE_STEPS (MOTION_CASE_JERK + 1)
#define MOTION_CASE_TOTAL MOTION_CASE_STEPS

Expand Down Expand Up @@ -1004,7 +1004,7 @@ void drawMotionMenu() {
itemAreaCopy(173, 133, 228, 147, MOTION_CASE_RATE); // Max speed
itemAreaCopy(173, 133, 200, 147, MOTION_CASE_ACCEL); // Max...
itemAreaCopy(28, 149, 69, 161, MOTION_CASE_ACCEL, 30, 1); // ...Acceleration
#if HAS_CLASSIC_JERK
#if ENABLED(CLASSIC_JERK)
itemAreaCopy(173, 133, 200, 147, MOTION_CASE_JERK); // Max...
itemAreaCopy(1, 180, 28, 192, MOTION_CASE_JERK, 30, 1); // ...
itemAreaCopy(202, 133, 228, 147, MOTION_CASE_JERK, 57); // ...Jerk
Expand All @@ -1020,14 +1020,14 @@ void drawMotionMenu() {
#ifdef USE_STRING_TITLES
dwinDrawLabel(MOTION_CASE_RATE, F("Feedrate")); // "Feedrate"
dwinDrawLabel(MOTION_CASE_ACCEL, GET_TEXT_F(MSG_ACCELERATION)); // "Acceleration"
#if HAS_CLASSIC_JERK
#if ENABLED(CLASSIC_JERK)
dwinDrawLabel(MOTION_CASE_JERK, GET_TEXT_F(MSG_JERK)); // "Jerk"
#endif
dwinDrawLabel(MOTION_CASE_STEPS, GET_TEXT_F(MSG_STEPS_PER_MM)); // "Steps/mm"
#else
say_max_en(MOTION_CASE_RATE); say_speed_en(30, MOTION_CASE_RATE); // "Max Speed"
say_max_accel_en(MOTION_CASE_ACCEL); // "Max Acceleration"
#if HAS_CLASSIC_JERK
#if ENABLED(CLASSIC_JERK)
say_max_en(MOTION_CASE_JERK); say_jerk_en(MOTION_CASE_JERK); // "Max Jerk"
#endif
say_steps_per_mm_en(MOTION_CASE_STEPS); // "Steps-per-mm"
Expand All @@ -1041,7 +1041,7 @@ void drawMotionMenu() {
#define _MOTION_ICON(N) drawMenuLine(++i, ICON_MaxSpeed + (N) - 1)
_MOTION_ICON(MOTION_CASE_RATE); drawMoreIcon(i);
_MOTION_ICON(MOTION_CASE_ACCEL); drawMoreIcon(i);
#if HAS_CLASSIC_JERK
#if ENABLED(CLASSIC_JERK)
_MOTION_ICON(MOTION_CASE_JERK); drawMoreIcon(i);
#endif
_MOTION_ICON(MOTION_CASE_STEPS); drawMoreIcon(i);
Expand Down Expand Up @@ -1597,7 +1597,7 @@ void hmiMaxAccelerationXYZE() {
drawEditInteger4(select_acc.now, hmiValues.maxAcceleration, true);
}

#if HAS_CLASSIC_JERK
#if ENABLED(CLASSIC_JERK)

void hmiMaxJerkXYZE() {
EncoderState encoder_diffState = encoderReceiveAnalyze();
Expand All @@ -1617,7 +1617,7 @@ void hmiMaxAccelerationXYZE() {
drawEditFloat3(select_jerk.now, hmiValues.maxJerkScaled, true);
}

#endif // HAS_CLASSIC_JERK
#endif // CLASSIC_JERK

void hmiStepXYZE() {
EncoderState encoder_diffState = encoderReceiveAnalyze();
Expand Down Expand Up @@ -3349,7 +3349,7 @@ void drawMaxAccelMenu() {
#endif
}

#if HAS_CLASSIC_JERK
#if ENABLED(CLASSIC_JERK)
void drawMaxJerkMenu() {
clearMainWindow();

Expand Down Expand Up @@ -3489,7 +3489,7 @@ void hmiMotion() {
select_acc.reset();
drawMaxAccelMenu();
break;
#if HAS_CLASSIC_JERK
#if ENABLED(CLASSIC_JERK)
case MOTION_CASE_JERK:
checkkey = ID_MaxJerk;
select_jerk.reset();
Expand Down Expand Up @@ -3996,7 +3996,7 @@ void hmiMaxAcceleration() {
dwinUpdateLCD();
}

#if HAS_CLASSIC_JERK
#if ENABLED(CLASSIC_JERK)
// Max Jerk
void hmiMaxJerk() {
EncoderState encoder_diffState = get_encoder_state();
Expand Down Expand Up @@ -4025,7 +4025,7 @@ void hmiMaxAcceleration() {
}
dwinUpdateLCD();
}
#endif // HAS_CLASSIC_JERK
#endif // CLASSIC_JERK

// Step
void hmiStep() {
Expand Down Expand Up @@ -4251,7 +4251,7 @@ void dwinHandleScreen() {
#endif
case ID_MaxSpeed: hmiMaxSpeed(); break;
case ID_MaxAcceleration: hmiMaxAcceleration(); break;
#if HAS_CLASSIC_JERK
#if ENABLED(CLASSIC_JERK)
case ID_MaxJerk: hmiMaxJerk(); break;
#endif
case ID_Step: hmiStep(); break;
Expand All @@ -4274,7 +4274,7 @@ void dwinHandleScreen() {
case ID_PrintSpeed: hmiPrintSpeed(); break;
case ID_MaxSpeedValue: hmiMaxFeedspeedXYZE(); break;
case ID_MaxAccelerationValue: hmiMaxAccelerationXYZE(); break;
#if HAS_CLASSIC_JERK
#if ENABLED(CLASSIC_JERK)
case ID_MaxJerkValue: hmiMaxJerkXYZE(); break;
#endif
case ID_StepValue: hmiStepXYZE(); break;
Expand Down
10 changes: 5 additions & 5 deletions Marlin/src/lcd/e3v2/jyersui/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2333,7 +2333,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
#define MOTION_HOMEOFFSETS (MOTION_BACK + 1)
#define MOTION_SPEED (MOTION_HOMEOFFSETS + 1)
#define MOTION_ACCEL (MOTION_SPEED + 1)
#define MOTION_JERK (MOTION_ACCEL + ENABLED(HAS_CLASSIC_JERK))
#define MOTION_JERK (MOTION_ACCEL + ENABLED(CLASSIC_JERK))
#define MOTION_STEPS (MOTION_JERK + 1)
#define MOTION_FLOW (MOTION_STEPS + ENABLED(HAS_HOTEND))
#define MOTION_LA (MOTION_FLOW + ENABLED(LIN_ADVANCE))
Expand Down Expand Up @@ -2364,7 +2364,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
else
drawMenu(ID_MaxAcceleration);
break;
#if HAS_CLASSIC_JERK
#if ENABLED(CLASSIC_JERK)
case MOTION_JERK:
if (draw)
drawMenuItem(row, ICON_MaxJerk, GET_TEXT_F(MSG_JERK), nullptr, true);
Expand Down Expand Up @@ -2553,7 +2553,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
#endif
}
break;
#if HAS_CLASSIC_JERK
#if ENABLED(CLASSIC_JERK)
case ID_MaxJerk:

#define JERK_BACK 0
Expand Down Expand Up @@ -4170,7 +4170,7 @@ FSTR_P JyersDWIN::getMenuTitle(const uint8_t menu) {
case ID_HomeOffsets: return GET_TEXT_F(MSG_SET_HOME_OFFSETS);
case ID_MaxSpeed: return GET_TEXT_F(MSG_MAX_SPEED);
case ID_MaxAcceleration: return F("Max Acceleration");
#if HAS_CLASSIC_JERK
#if ENABLED(CLASSIC_JERK)
case ID_MaxJerk: return F("Max Jerk");
#endif
case ID_Steps: return GET_TEXT_F(MSG_STEPS_PER_MM);
Expand Down Expand Up @@ -4247,7 +4247,7 @@ uint8_t JyersDWIN::getMenuSize(const uint8_t menu) {
case ID_HomeOffsets: return HOMEOFFSETS_TOTAL;
case ID_MaxSpeed: return SPEED_TOTAL;
case ID_MaxAcceleration: return ACCEL_TOTAL;
#if HAS_CLASSIC_JERK
#if ENABLED(CLASSIC_JERK)
case ID_MaxJerk: return JERK_TOTAL;
#endif
case ID_Steps: return STEPS_TOTAL;
Expand Down
14 changes: 7 additions & 7 deletions Marlin/src/lcd/e3v2/proui/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ Menu *filamentMenu = nullptr;
Menu *temperatureMenu = nullptr;
Menu *maxSpeedMenu = nullptr;
Menu *maxAccelMenu = nullptr;
#if HAS_CLASSIC_JERK
#if ENABLED(CLASSIC_JERK)
Menu *maxJerkMenu = nullptr;
#endif
Menu *stepsMenu = nullptr;
Expand Down Expand Up @@ -2545,7 +2545,7 @@ void applyMaxAccel() { planner.set_max_acceleration(hmiValue.axis, menuData.valu
void setMaxAccelE() { hmiValue.axis = E_AXIS; setIntOnClick(min_acceleration_edit_values.e, max_acceleration_edit_values.e, planner.settings.max_acceleration_mm_per_s2[E_AXIS], applyMaxAccel); }
#endif

#if HAS_CLASSIC_JERK
#if ENABLED(CLASSIC_JERK)
void applyMaxJerk() { planner.set_max_jerk(hmiValue.axis, menuData.value / MINUNITMULT); }
#if HAS_X_AXIS
void setMaxJerkX() { hmiValue.axis = X_AXIS, setFloatOnClick(min_jerk_edit_values.x, max_jerk_edit_values.x, UNITFDIGITS, planner.max_jerk.x, applyMaxJerk); }
Expand Down Expand Up @@ -2880,7 +2880,7 @@ void onDrawAcc(MenuItem* menuitem, int8_t line) {
}
#endif

#if HAS_CLASSIC_JERK
#if ENABLED(CLASSIC_JERK)

void onDrawJerk(MenuItem* menuitem, int8_t line) {
if (hmiIsChinese()) {
Expand Down Expand Up @@ -2941,7 +2941,7 @@ void onDrawAcc(MenuItem* menuitem, int8_t line) {

#endif

#endif // HAS_CLASSIC_JERK
#endif // CLASSIC_JERK

#if HAS_X_AXIS
void onDrawStepsX(MenuItem* menuitem, int8_t line) {
Expand Down Expand Up @@ -3451,7 +3451,7 @@ void drawMotionMenu() {
BACK_ITEM(drawControlMenu);
MENU_ITEM(ICON_MaxSpeed, MSG_SPEED, onDrawSpeed, drawMaxSpeedMenu);
MENU_ITEM(ICON_MaxAccelerated, MSG_ACCELERATION, onDrawAcc, drawMaxAccelMenu);
#if HAS_CLASSIC_JERK
#if ENABLED(CLASSIC_JERK)
MENU_ITEM(ICON_MaxJerk, MSG_JERK, onDrawJerk, drawMaxJerkMenu);
#elif HAS_JUNCTION_DEVIATION
EDIT_ITEM(ICON_JDmm, MSG_JUNCTION_DEVIATION, onDrawPFloat3Menu, setJDmm, &planner.junction_deviation_mm);
Expand Down Expand Up @@ -3616,7 +3616,7 @@ void drawMaxAccelMenu() {
updateMenu(maxAccelMenu);
}

#if HAS_CLASSIC_JERK
#if ENABLED(CLASSIC_JERK)

void drawMaxJerkMenu() {
checkkey = ID_Menu;
Expand All @@ -3638,7 +3638,7 @@ void drawMaxAccelMenu() {
updateMenu(maxJerkMenu);
}

#endif // HAS_CLASSIC_JERK
#endif // CLASSIC_JERK

void drawStepsMenu() {
checkkey = ID_Menu;
Expand Down
Loading

0 comments on commit 75da355

Please sign in to comment.