fix an issue that pressure eq may cause 0 feedrate in vase mode (#4398)

fix an issue that pressure eq may cause 0 feedrate
This commit is contained in:
SoftFever 2024-03-10 09:30:13 +08:00 committed by GitHub
parent 89f51031eb
commit 849fe44bf9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 27 additions and 18 deletions

View file

@ -769,8 +769,11 @@ inline bool is_just_line_with_extrude_set_speed_tag(const std::string &line)
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, float new_feedrate, const char *comment)
{
// Orca: sanity check, 1 mm/s is the minimum feedrate.
if (new_feedrate < 60)
new_feedrate = 60;
const GCodeLine &line = m_gcode_lines[line_idx];
if (line_idx > 0 && output_buffer_length > 0) {
const std::string prev_line_str = std::string(output_buffer.begin() + int(this->output_buffer_prev_length),

View file

@ -132,7 +132,8 @@ private:
float time() const { return dist_xyz() / feedrate(); }
float time_inv() const { return feedrate() / dist_xyz(); }
float volumetric_correction_avg() const {
float avg_correction = 0.5f * (volumetric_extrusion_rate_start + volumetric_extrusion_rate_end) / volumetric_extrusion_rate;
// Orca: cap the correction to 0.05 - 1.00000001 to avoid zero feedrate
float avg_correction = std::max(0.05f,0.5f * (volumetric_extrusion_rate_start + volumetric_extrusion_rate_end) / volumetric_extrusion_rate);
assert(avg_correction > 0.f);
assert(avg_correction <= 1.00000001f);
return avg_correction;