Skip to content

Commit

Permalink
FIx 0 acceleration for reprap
Browse files Browse the repository at this point in the history
  • Loading branch information
supermerill committed Jan 10, 2024
1 parent d927a87 commit 85f90bc
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 30 deletions.
27 changes: 19 additions & 8 deletions src/libslic3r/GCodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,23 +311,34 @@ std::string GCodeWriter::write_acceleration(){
//try to set only printing acceleration, travel should be untouched if possible
if (FLAVOR_IS(gcfRepetier)) {
// M201: Set max printing acceleration
gcode << "M201 X" << m_current_acceleration << " Y" << m_current_acceleration;
if (m_current_acceleration > 0)
gcode << "M201 X" << m_current_acceleration << " Y" << m_current_acceleration;
} else if(FLAVOR_IS(gcfLerdge) || FLAVOR_IS(gcfSprinter)){
// M204: Set printing acceleration
// This is new MarlinFirmware with separated print/retraction/travel acceleration.
// Use M204 P, we don't want to override travel acc by M204 S (which is deprecated anyway).
gcode << "M204 P" << m_current_acceleration;
if (m_current_acceleration > 0)
gcode << "M204 P" << m_current_acceleration;
} else if (FLAVOR_IS(gcfMarlinFirmware) || FLAVOR_IS(gcfRepRap)) {
// M204: Set printing & travel acceleration
gcode << "M204 P" << m_current_acceleration << " T" << (m_current_travel_acceleration > 0 ? m_current_travel_acceleration : m_current_acceleration);
if (m_current_acceleration > 0)
gcode << "M204 P" << m_current_acceleration << " T" << (m_current_travel_acceleration > 0 ? m_current_travel_acceleration : m_current_acceleration);
else if(m_current_travel_acceleration > 0)
gcode << "M204 T" << m_current_travel_acceleration;
} else { // gcfMarlinLegacy
// M204: Set default acceleration
gcode << "M204 S" << m_current_acceleration;
if (m_current_acceleration > 0)
gcode << "M204 S" << m_current_acceleration;
}
if (this->config.gcode_comments) gcode << " ; adjust acceleration";
gcode << "\n";

return gcode.str();
//if at least something, add comment and line return
if (gcode.tellp() != std::streampos(0)) {
if (this->config.gcode_comments)
gcode << " ; adjust acceleration";
gcode << "\n";
return gcode.str();
}
assert(gcode.str().empty());
return "";
}

std::string GCodeWriter::reset_e(bool force)
Expand Down
38 changes: 16 additions & 22 deletions src/libslic3r/GCodeWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,7 @@ class GCodeWriter {
// override from region
const PrintRegionConfig* config_region = nullptr;

GCodeWriter() :
multiple_extruders(false), m_extrusion_axis("E"), m_tool(nullptr),
m_single_extruder_multi_material(false),
m_last_acceleration(0), m_current_acceleration(0), m_current_speed(0),
m_last_bed_temperature(0), m_last_bed_temperature_reached(true),
m_lifted(0)
{}
GCodeWriter() {}
Tool* tool() { return m_tool; }
const Tool* tool() const { return m_tool; }

Expand Down Expand Up @@ -96,25 +90,25 @@ class GCodeWriter {
// Extruders are sorted by their ID, so that binary search is possible.
std::vector<Extruder> m_extruders;
std::vector<Mill> m_millers;
std::string m_extrusion_axis;
bool m_single_extruder_multi_material;
Tool* m_tool;
uint32_t m_last_acceleration;
uint32_t m_last_travel_acceleration;
uint32_t m_current_acceleration;
uint32_t m_current_travel_acceleration;
double m_current_speed;
uint8_t m_last_fan_speed;
int16_t m_last_temperature;
int16_t m_last_temperature_with_offset;
int16_t m_last_bed_temperature;
bool m_last_bed_temperature_reached;
std::string m_extrusion_axis = "E";
bool m_single_extruder_multi_material = false;
Tool* m_tool = nullptr;
uint32_t m_last_acceleration = 0;
uint32_t m_last_travel_acceleration = 0;
uint32_t m_current_acceleration = 0;
uint32_t m_current_travel_acceleration = 0;
double m_current_speed = 0;
uint8_t m_last_fan_speed = 0;
int16_t m_last_temperature = 0;
int16_t m_last_temperature_with_offset = 0;
int16_t m_last_bed_temperature = 0;
bool m_last_bed_temperature_reached = true;
// if positive, it's set, and the next lift wil have this extra lift
double m_extra_lift = 0;
// current lift, to remove from m_pos to have the current height.
double m_lifted;
double m_lifted = 0;
Vec3d m_pos = Vec3d::Zero();

std::string _travel_to_z(double z, const std::string &comment);
std::string _retract(double length, std::optional<double> restart_extra, std::optional<double> restart_extra_toolchange, const std::string &comment);

Expand Down

0 comments on commit 85f90bc

Please sign in to comment.