Use homing_feedrate function

This commit is contained in:
Scott Lahteine 2020-12-16 22:18:40 -06:00
parent 6d47baee5d
commit 20b3af1cc2
13 changed files with 25 additions and 28 deletions

View File

@ -75,7 +75,6 @@ typedef float feedRate_t;
// Conversion macros
#define MMM_TO_MMS(MM_M) feedRate_t(float(MM_M) / 60.0f)
#define MMS_TO_MMM(MM_S) (float(MM_S) * 60.0f)
#define MMS_SCALED(V) ((V) * 0.01f * feedrate_percentage)
//
// Coordinates structures for XY, XYZ, XYZE...

View File

@ -332,7 +332,7 @@ bool I2CPositionEncoder::test_axis() {
const float startPosition = soft_endstop.min[encoderAxis] + 10,
endPosition = soft_endstop.max[encoderAxis] - 10;
const feedRate_t fr_mm_s = FLOOR(MMM_TO_MMS((encoderAxis == Z_AXIS) ? HOMING_FEEDRATE_Z : HOMING_FEEDRATE_XY));
const feedRate_t fr_mm_s = FLOOR(homing_feedrate(encoderAxis));
ec = false;
@ -382,7 +382,7 @@ void I2CPositionEncoder::calibrate_steps_mm(const uint8_t iter) {
int32_t startCount, stopCount;
const feedRate_t fr_mm_s = MMM_TO_MMS((encoderAxis == Z_AXIS) ? HOMING_FEEDRATE_Z : HOMING_FEEDRATE_XY);
const feedRate_t fr_mm_s = homing_feedrate(encoderAxis);
bool oldec = ec;
ec = false;

View File

@ -180,7 +180,7 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=0*/
// Machine state
info.current_position = current_position;
info.feedrate = uint16_t(feedrate_mm_s * 60.0f);
info.feedrate = uint16_t(MMS_TO_MMM(feedrate_mm_s));
info.zraise = zraise;
TERN_(GCODE_REPEAT_MARKERS, info.stored_repeat = repeat);

View File

@ -63,7 +63,7 @@ void GcodeSuite::G34() {
// Move Z to pounce position
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Setting Z Pounce");
do_blocking_move_to_z(zpounce, MMM_TO_MMS(HOMING_FEEDRATE_Z));
do_blocking_move_to_z(zpounce, homing_feedrate(Z_AXIS));
// Store current motor settings, then apply reduced value

View File

@ -49,10 +49,6 @@ void GcodeSuite::G61(void) {
// No saved position? No axes being restored?
if (!TEST(saved_slots[slot >> 3], slot & 0x07) || !parser.seen("XYZ")) return;
// Apply any given feedrate over 0.0
const float fr = parser.linearval('F');
if (fr > 0.0) feedrate_mm_s = MMM_TO_MMS(fr);
SERIAL_ECHOPAIR(STR_RESTORING_POS " S", int(slot));
LOOP_XYZ(i) {
destination[i] = parser.seen(XYZ_CHAR(i))
@ -63,8 +59,15 @@ void GcodeSuite::G61(void) {
}
SERIAL_EOL();
// Apply any given feedrate over 0.0
feedRate_t saved_feedrate = feedrate_mm_s;
const float fr = parser.linearval('F');
if (fr > 0.0) feedrate_mm_s = MMM_TO_MMS(fr);
// Move to the saved position
prepare_line_to_destination();
feedrate_mm_s = saved_feedrate;
}
#endif // SAVED_POSITIONS

View File

@ -1166,7 +1166,7 @@ void HMI_Move_X() {
if (!planner.is_full()) {
// Wait for planner moves to finish!
planner.synchronize();
planner.buffer_line(current_position, MMM_TO_MMS(HOMING_FEEDRATE_XY), active_extruder);
planner.buffer_line(current_position, homing_feedrate(X_AXIS), active_extruder);
}
DWIN_UpdateLCD();
return;
@ -1189,7 +1189,7 @@ void HMI_Move_Y() {
if (!planner.is_full()) {
// Wait for planner moves to finish!
planner.synchronize();
planner.buffer_line(current_position, MMM_TO_MMS(HOMING_FEEDRATE_XY), active_extruder);
planner.buffer_line(current_position, homing_feedrate(Y_AXIS), active_extruder);
}
DWIN_UpdateLCD();
return;
@ -1212,7 +1212,7 @@ void HMI_Move_Z() {
if (!planner.is_full()) {
// Wait for planner moves to finish!
planner.synchronize();
planner.buffer_line(current_position, MMM_TO_MMS(HOMING_FEEDRATE_Z), active_extruder);
planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder);
}
DWIN_UpdateLCD();
return;

View File

@ -45,8 +45,6 @@ enum {
ID_FILAMNT_RETURN
};
extern feedRate_t feedrate_mm_s;
static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) {

View File

@ -53,8 +53,6 @@ enum {
static lv_obj_t *label_PowerOff;
static lv_obj_t *buttonPowerOff;
extern feedRate_t feedrate_mm_s;
static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) {

View File

@ -146,7 +146,7 @@ void prepare_for_probe_offset_wizard() {
// Move Nozzle to Probing/Homing Position
ui.wait_for_move = true;
current_position += probe.offset_xy;
line_to_current_position(MMM_TO_MMS(HOMING_FEEDRATE_XY));
line_to_current_position(MMM_TO_MMS(XY_PROBE_SPEED));
ui.synchronize(GET_TEXT(MSG_PROBE_WIZARD_MOVING));
ui.wait_for_move = false;

View File

@ -510,7 +510,7 @@ void do_z_clearance(const float &zclear, const bool z_trusted/*=true*/, const bo
const bool rel = raise_on_untrusted && !z_trusted;
float zdest = zclear + (rel ? current_position.z : 0.0f);
if (!lower_allowed) NOLESS(zdest, current_position.z);
do_blocking_move_to_z(_MIN(zdest, Z_MAX_POS), MMM_TO_MMS(TERN(HAS_BED_PROBE, Z_PROBE_SPEED_FAST, HOMING_FEEDRATE_Z)));
do_blocking_move_to_z(_MIN(zdest, Z_MAX_POS), TERN(HAS_BED_PROBE, MMM_TO_MMS(Z_PROBE_SPEED_FAST), homing_feedrate(Z_AXIS)));
}
//

View File

@ -73,12 +73,16 @@ extern const feedRate_t homing_feedrate_mm_s[XYZ];
FORCE_INLINE feedRate_t homing_feedrate(const AxisEnum a) { return pgm_read_float(&homing_feedrate_mm_s[a]); }
feedRate_t get_homing_bump_feedrate(const AxisEnum axis);
/**
* The default feedrate for many moves, set by the most recent move
*/
extern feedRate_t feedrate_mm_s;
/**
* Feedrate scaling
* Feedrate scaling is applied to all G0/G1, G2/G3, and G5 moves
*/
extern int16_t feedrate_percentage;
#define MMS_SCALED(V) ((V) * 0.01f * feedrate_percentage)
// The active extruder (tool). Set with T<extruder> command.
#if HAS_MULTI_EXTRUDER

View File

@ -978,6 +978,6 @@ class Planner {
#endif // !CLASSIC_JERK
};
#define PLANNER_XY_FEEDRATE() (_MIN(planner.settings.max_feedrate_mm_s[X_AXIS], planner.settings.max_feedrate_mm_s[Y_AXIS]))
#define PLANNER_XY_FEEDRATE() _MIN(planner.settings.max_feedrate_mm_s[X_AXIS], planner.settings.max_feedrate_mm_s[Y_AXIS])
extern Planner planner;

View File

@ -152,8 +152,8 @@ xyz_pos_t Probe::offset; // Initialized by settings.load()
inline void run_stow_moves_script() {
const xyz_pos_t oldpos = current_position;
endstops.enable_z_probe(false);
do_blocking_move_to_z(TOUCH_MI_RETRACT_Z, MMM_TO_MMS(HOMING_FEEDRATE_Z));
do_blocking_move_to(oldpos, MMM_TO_MMS(HOMING_FEEDRATE_Z));
do_blocking_move_to_z(TOUCH_MI_RETRACT_Z, homing_feedrate(Z_AXIS));
do_blocking_move_to(oldpos, homing_feedrate(Z_AXIS));
}
#elif ENABLED(Z_PROBE_ALLEN_KEY)
@ -664,11 +664,8 @@ float Probe::probe_at_point(const float &rx, const float &ry, const ProbePtRaise
}
else if (!position_is_reachable(npos)) return NAN; // The given position is in terms of the nozzle
const float old_feedrate_mm_s = feedrate_mm_s;
feedrate_mm_s = XY_PROBE_FEEDRATE_MM_S;
// Move the probe to the starting XYZ
do_blocking_move_to(npos);
do_blocking_move_to(npos, feedRate_t(XY_PROBE_FEEDRATE_MM_S));
float measured_z = NAN;
if (!deploy()) measured_z = run_z_probe(sanity_check) + offset.z;
@ -683,8 +680,6 @@ float Probe::probe_at_point(const float &rx, const float &ry, const ProbePtRaise
SERIAL_ECHOLNPAIR("Bed X: ", LOGICAL_X_POSITION(rx), " Y: ", LOGICAL_Y_POSITION(ry), " Z: ", measured_z);
}
feedrate_mm_s = old_feedrate_mm_s;
if (isnan(measured_z)) {
stow();
LCD_MESSAGEPGM(MSG_LCD_PROBING_FAILED);