Fix #8716, #8717, and #8718: The pressure equalizer was producing a malformed GCode that caused underextrusion.

This commit is contained in:
Lukáš Hejl 2022-08-19 12:14:45 +02:00
parent f95a6e3d33
commit 8c0db761c1
2 changed files with 20 additions and 7 deletions

View File

@ -669,17 +669,32 @@ inline void PressureEqualizer::push_to_output(const char *text, const size_t len
output_buffer[output_buffer_length] = 0; output_buffer[output_buffer_length] = 0;
} }
inline bool PressureEqualizer::is_just_feedrate_provided(const GCodeLine &line) inline bool is_just_line_with_extrude_set_speed_tag(const std::string &line)
{ {
return line.pos_provided[4] && !line.pos_provided[0] && !line.pos_provided[1] && !line.pos_provided[2] && !line.pos_provided[3]; if (line.empty() && !boost::starts_with(line, "G1 ") && !boost::ends_with(line, EXTRUDE_SET_SPEED_TAG))
return false;
const char *p_line = line.data() + 3;
const char *const line_end = line.data() + line.length() - 1;
while (!is_eol(*p_line)) {
if (toupper(*p_line++) == 'F')
break;
else
return false;
}
parse_float(p_line, line_end - p_line);
eatws(p_line);
p_line += EXTRUDE_SET_SPEED_TAG.length();
return p_line <= line_end && is_eol(*p_line);
} }
void PressureEqualizer::push_line_to_output(const size_t line_idx, const float new_feedrate, const char *comment) void PressureEqualizer::push_line_to_output(const size_t line_idx, const float new_feedrate, const char *comment)
{ {
const GCodeLine &line = this->m_gcode_lines[line_idx]; const GCodeLine &line = this->m_gcode_lines[line_idx];
if (line_idx > 0) { if (line_idx > 0 && output_buffer_length > 0) {
const GCodeLine &prev_line = this->m_gcode_lines[line_idx - 1]; const std::string prev_line_str = std::string(output_buffer.begin() + int(this->output_buffer_prev_length),
if (prev_line.extrude_set_speed_tag && this->is_just_feedrate_provided(prev_line)) output_buffer.begin() + int(this->output_buffer_length) + 1);
if (is_just_line_with_extrude_set_speed_tag(prev_line_str))
this->output_buffer_length = this->output_buffer_prev_length; // Remove the last line because it only sets the speed for an empty block of g-code lines, so it is useless. this->output_buffer_length = this->output_buffer_prev_length; // Remove the last line because it only sets the speed for an empty block of g-code lines, so it is useless.
else else
push_to_output(EXTRUDE_END_TAG.data(), EXTRUDE_END_TAG.length(), true); push_to_output(EXTRUDE_END_TAG.data(), EXTRUDE_END_TAG.length(), true);

View File

@ -193,8 +193,6 @@ private:
// Push a G-code line to the output. // Push a G-code line to the output.
void push_line_to_output(size_t line_idx, float new_feedrate, const char *comment); void push_line_to_output(size_t line_idx, float new_feedrate, const char *comment);
inline bool is_just_feedrate_provided(const GCodeLine &line);
public: public:
std::queue<LayerResult*> m_layer_results; std::queue<LayerResult*> m_layer_results;