Use constant names for G-codes like M600, M601 and "tool_change"(Change extruder)

This commit is contained in:
YuSanka 2019-11-11 09:38:45 +01:00
parent 7a22e43825
commit 6c8bb51f4a
8 changed files with 58 additions and 57 deletions

View file

@ -1692,7 +1692,7 @@ void GCode::process_layer(
int m600_before_extruder = -1;
while (!m_custom_g_code_heights.empty() && m_custom_g_code_heights.front().height-EPSILON < layer.print_z) {
custom_code = m_custom_g_code_heights.front().gcode;
if (custom_code == "M600" && m_custom_g_code_heights.front().extruder > 0)
if (custom_code == ColorChangeCode && m_custom_g_code_heights.front().extruder > 0)
m600_before_extruder = m_custom_g_code_heights.front().extruder - 1;
m_custom_g_code_heights.erase(m_custom_g_code_heights.begin());
colorprint_change = true;
@ -1710,11 +1710,11 @@ void GCode::process_layer(
// gcode += "M600\n";
// }
// don't save "tool_change" code to GCode
if (colorprint_change && custom_code != "tool_change") {
// don't save "tool_change"(ExtruderChangeCode) code to GCode
if (colorprint_change && custom_code != ExtruderChangeCode) {
const bool single_material_print = print.config().nozzle_diameter.size() == 1;
if (custom_code == "M600") // color change
if (custom_code == ColorChangeCode) // color change
{
// add tag for analyzer
gcode += "; " + GCodeAnalyzer::Color_Change_Tag + ",T" + std::to_string(m600_before_extruder) + "\n";
@ -1732,7 +1732,7 @@ void GCode::process_layer(
}
else
{
if (custom_code == "M601") // Pause print
if (custom_code == PausePrintCode) // Pause print
{
// add tag for analyzer
gcode += "; " + GCodeAnalyzer::Pause_Print_Tag + "\n";
@ -1750,16 +1750,16 @@ void GCode::process_layer(
}
/*
if (single_material_print || custom_code != "tool_change")
if (single_material_print || custom_code != ExtruderChangeCode)
{
// add tag for analyzer
gcode += "; " + GCodeAnalyzer::Color_Change_Tag + "\n";
// add tag for time estimator
gcode += "; " + GCodeTimeEstimator::Color_Change_Tag + "\n";
if (single_material_print && custom_code == "tool_change")
custom_code = "M600";
if (single_material_print && custom_code == ExtruderChangeCode)
custom_code = ColorChangeCode;
if (!single_material_print && custom_code == "M600" &&
if (!single_material_print && custom_code == ColorChangeCode &&
m600_before_extruder >= 0 && first_extruder_id != m600_before_extruder
// && !MMU1
) {

View file

@ -591,7 +591,7 @@ std::vector<std::pair<double, DynamicPrintConfig>> Model::get_custom_tool_change
std::vector<std::pair<double, DynamicPrintConfig>> custom_tool_changes;
if (!custom_gcode_per_height.empty()) {
for (const CustomGCode& custom_gcode : custom_gcode_per_height)
if (custom_gcode.gcode == "tool_change") {
if (custom_gcode.gcode == ExtruderChangeCode) {
DynamicPrintConfig config;
// If extruder count in PrinterSettings was changed, use default (0) extruder for extruders, more than num_extruders
config.set_key_value("extruder", new ConfigOptionInt(custom_gcode.extruder > num_extruders ? 0 : custom_gcode.extruder));

View file

@ -71,6 +71,12 @@ enum SLAPillarConnectionMode {
slapcmDynamic
};
// ys_FIXME ! may be, it's not a best place
// Additional Codes which can be set by user using DoubleSlider
static const std::string ColorChangeCode = "M600";
static const std::string PausePrintCode = "M601";
static const std::string ExtruderChangeCode = "tool_change";
template<> inline const t_config_enum_values& ConfigOptionEnum<PrinterTechnology>::get_enum_values() {
static t_config_enum_values keys_map;
if (keys_map.empty()) {