mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-13 01:37:53 -06:00
GCodeAnalyzer now recognizes tool-changing commands with MakerWare and Sailfish flavor
These firmwares use M135 Tn and M108 Tn commands for changing active tool, which the analyzer did not recognize. The toolpaths were then rendered in wrong color, extruder offset etc. This surfaced in issue https://github.com/prusa3d/PrusaSlicer/issues/2566
This commit is contained in:
parent
cc70c8dff9
commit
2ee572bd31
3 changed files with 48 additions and 2 deletions
|
@ -106,6 +106,11 @@ void GCodeAnalyzer::set_extruder_offsets(const GCodeAnalyzer::ExtruderOffsetsMap
|
|||
m_extruder_offsets = extruder_offsets;
|
||||
}
|
||||
|
||||
void GCodeAnalyzer::set_gcode_flavor(const GCodeFlavor& flavor)
|
||||
{
|
||||
m_gcode_flavor = flavor;
|
||||
}
|
||||
|
||||
void GCodeAnalyzer::reset()
|
||||
{
|
||||
_set_units(Millimeters);
|
||||
|
@ -249,6 +254,14 @@ void GCodeAnalyzer::_process_gcode_line(GCodeReader&, const GCodeReader::GCodeLi
|
|||
_processM83(line);
|
||||
break;
|
||||
}
|
||||
case 108:
|
||||
case 135:
|
||||
{
|
||||
// these are used by MakerWare and Sailfish firmwares
|
||||
// for tool changing - we can process it in one place
|
||||
_processM108orM135(line);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -426,9 +439,27 @@ void GCodeAnalyzer::_processM600(const GCodeReader::GCodeLine& line)
|
|||
_set_cp_color_id(m_state.cur_cp_color_id);
|
||||
}
|
||||
|
||||
void GCodeAnalyzer::_processT(const GCodeReader::GCodeLine& line)
|
||||
void GCodeAnalyzer::_processM108orM135(const GCodeReader::GCodeLine& line)
|
||||
{
|
||||
// These M-codes are used by MakerWare and Sailfish to change active tool.
|
||||
// They have to be processed otherwise toolchanges will be unrecognised
|
||||
// by the analyzer - see https://github.com/prusa3d/PrusaSlicer/issues/2566
|
||||
|
||||
size_t code = ::atoi(&(line.cmd()[1]));
|
||||
if ((code == 108 && m_gcode_flavor == gcfSailfish)
|
||||
|| (code == 135 && m_gcode_flavor == gcfMakerWare)) {
|
||||
|
||||
std::string cmd = line.raw();
|
||||
size_t T_pos = cmd.find("T");
|
||||
if (T_pos != std::string::npos) {
|
||||
cmd = cmd.substr(T_pos);
|
||||
_processT(cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GCodeAnalyzer::_processT(const std::string& cmd)
|
||||
{
|
||||
std::string cmd = line.cmd();
|
||||
if (cmd.length() > 1)
|
||||
{
|
||||
unsigned int id = (unsigned int)::strtol(cmd.substr(1).c_str(), nullptr, 10);
|
||||
|
@ -442,6 +473,11 @@ void GCodeAnalyzer::_processT(const GCodeReader::GCodeLine& line)
|
|||
}
|
||||
}
|
||||
|
||||
void GCodeAnalyzer::_processT(const GCodeReader::GCodeLine& line)
|
||||
{
|
||||
_processT(line.cmd());
|
||||
}
|
||||
|
||||
bool GCodeAnalyzer::_process_tags(const GCodeReader::GCodeLine& line)
|
||||
{
|
||||
std::string comment = line.comment();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue