Break out prevent_dangerous_extrude feature
- It’s inline here, but could be a macro and duplicated for `planner.cpp`
This commit is contained in:
parent
740152ee70
commit
8b16ebe705
@ -547,9 +547,7 @@ void servo_init()
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
void setup() {
|
||||
setup_killpin();
|
||||
setup_filrunoutpin();
|
||||
setup_powerhold();
|
||||
@ -567,7 +565,8 @@ void setup()
|
||||
MCUSR = 0;
|
||||
|
||||
SERIAL_ECHOPGM(MSG_MARLIN);
|
||||
SERIAL_ECHOLNPGM(STRING_VERSION);
|
||||
SERIAL_ECHOLNPGM(" " STRING_VERSION);
|
||||
|
||||
#ifdef STRING_VERSION_CONFIG_H
|
||||
#ifdef STRING_CONFIG_H_AUTHOR
|
||||
SERIAL_ECHO_START;
|
||||
@ -579,16 +578,15 @@ void setup()
|
||||
SERIAL_ECHOLNPGM(__DATE__);
|
||||
#endif // STRING_CONFIG_H_AUTHOR
|
||||
#endif // STRING_VERSION_CONFIG_H
|
||||
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOPGM(MSG_FREE_MEMORY);
|
||||
SERIAL_ECHO(freeMemory());
|
||||
SERIAL_ECHOPGM(MSG_PLANNER_BUFFER_BYTES);
|
||||
SERIAL_ECHOLN((int)sizeof(block_t)*BLOCK_BUFFER_SIZE);
|
||||
|
||||
#ifdef SDSUPPORT
|
||||
for(int8_t i = 0; i < BUFSIZE; i++)
|
||||
{
|
||||
fromsd[i] = false;
|
||||
}
|
||||
for (int8_t i = 0; i < BUFSIZE; i++) fromsd[i] = false;
|
||||
#endif // !SDSUPPORT
|
||||
|
||||
// loads data from EEPROM if available else uses defaults (and resets step acceleration rate)
|
||||
@ -601,7 +599,6 @@ void setup()
|
||||
setup_photpin();
|
||||
servo_init();
|
||||
|
||||
|
||||
lcd_init();
|
||||
_delay_ms(1000); // wait 1sec to display the splash screen
|
||||
|
||||
@ -612,16 +609,19 @@ void setup()
|
||||
#ifdef DIGIPOT_I2C
|
||||
digipot_i2c_init();
|
||||
#endif
|
||||
|
||||
#ifdef Z_PROBE_SLED
|
||||
pinMode(SERVO0_PIN, OUTPUT);
|
||||
digitalWrite(SERVO0_PIN, LOW); // turn it off
|
||||
#endif // Z_PROBE_SLED
|
||||
|
||||
setup_homepin();
|
||||
|
||||
#ifdef STAT_LED_RED
|
||||
pinMode(STAT_LED_RED, OUTPUT);
|
||||
digitalWrite(STAT_LED_RED, LOW); // turn it off
|
||||
#endif
|
||||
|
||||
#ifdef STAT_LED_BLUE
|
||||
pinMode(STAT_LED_BLUE, OUTPUT);
|
||||
digitalWrite(STAT_LED_BLUE, LOW); // turn it off
|
||||
@ -5447,26 +5447,37 @@ void mesh_plan_buffer_line(float x, float y, float z, const float e, float feed_
|
||||
}
|
||||
#endif // MESH_BED_LEVELING
|
||||
|
||||
#ifdef PREVENT_DANGEROUS_EXTRUDE
|
||||
|
||||
inline float prevent_dangerous_extrude(float &curr_e, float &dest_e) {
|
||||
float de = dest_e - curr_e;
|
||||
if (de) {
|
||||
if (degHotend(active_extruder) < extrude_min_temp) {
|
||||
curr_e = dest_e; // Behave as if the move really took place, but ignore E part
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP);
|
||||
return 0;
|
||||
}
|
||||
#ifdef PREVENT_LENGTHY_EXTRUDE
|
||||
if (labs(de) > EXTRUDE_MAXLENGTH) {
|
||||
curr_e = dest_e; // Behave as if the move really took place, but ignore E part
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLNPGM(MSG_ERR_LONG_EXTRUDE_STOP);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return de;
|
||||
}
|
||||
|
||||
#endif // PREVENT_DANGEROUS_EXTRUDE
|
||||
|
||||
void prepare_move() {
|
||||
clamp_to_software_endstops(destination);
|
||||
refresh_cmd_timeout();
|
||||
|
||||
#ifdef PREVENT_DANGEROUS_EXTRUDE
|
||||
float de = destination[E_AXIS] - current_position[E_AXIS];
|
||||
if (de) {
|
||||
if (degHotend(active_extruder) < extrude_min_temp) {
|
||||
current_position[E_AXIS] = destination[E_AXIS]; // Behave as if the move really took place, but ignore E part
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP);
|
||||
}
|
||||
#ifdef PREVENT_LENGTHY_EXTRUDE
|
||||
if (labs(de) > EXTRUDE_MAXLENGTH) {
|
||||
current_position[E_AXIS] = destination[E_AXIS]; // Behave as if the move really took place, but ignore E part
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLNPGM(MSG_ERR_LONG_EXTRUDE_STOP);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
(void)prevent_dangerous_extrude(current_position[E_AXIS], destination[E_AXIS]);
|
||||
#endif
|
||||
|
||||
#ifdef SCARA //for now same as delta-code
|
||||
|
Loading…
Reference in New Issue
Block a user