Add "Manual filament change" option and logic (#2379)

* Add "Manual filament change" option and logic

* make suggested changes

* make suggested changes

* change tag from "CHANGE_TOOL" to "MANUAL_TOOL_CHANGE"

* some tweaks

* More fixes

---------

Co-authored-by: SoftFever <softfeverever@gmail.com>
Co-authored-by: SoftFever <103989404+SoftFever@users.noreply.github.com>
This commit is contained in:
Ocraftyone 2023-10-22 07:31:09 -04:00 committed by GitHub
parent 90601c098a
commit f84e94faf7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 32 additions and 5 deletions

View file

@ -60,6 +60,7 @@ const std::vector<std::string> GCodeProcessor::Reserved_Tags = {
"_GP_LAST_LINE_M73_PLACEHOLDER",
"_GP_ESTIMATED_PRINTING_TIME_PLACEHOLDER",
"_GP_TOTAL_LAYER_NUMBER_PLACEHOLDER",
" MANUAL_TOOL_CHANGE ",
"_DURING_PRINT_EXHAUST_FAN"
};
@ -76,7 +77,8 @@ const std::vector<std::string> GCodeProcessor::Reserved_Tags_compatible = {
"_GP_FIRST_LINE_M73_PLACEHOLDER",
"_GP_LAST_LINE_M73_PLACEHOLDER",
"_GP_ESTIMATED_PRINTING_TIME_PLACEHOLDER",
"_GP_TOTAL_LAYER_NUMBER_PLACEHOLDER"
"_GP_TOTAL_LAYER_NUMBER_PLACEHOLDER",
" MANUAL_TOOL_CHANGE "
};
@ -1010,7 +1012,9 @@ void GCodeProcessor::apply_config(const PrintConfig& config)
if (spiral_vase != nullptr)
m_spiral_vase_active = spiral_vase->value;
const ConfigOptionBool* manual_filament_change = config.option<ConfigOptionBool>("manual_filament_change");
if (manual_filament_change != nullptr)
m_manual_filament_change = manual_filament_change->value;
}
void GCodeProcessor::apply_config(const DynamicPrintConfig& config)
@ -2108,6 +2112,13 @@ void GCodeProcessor::process_tags(const std::string_view comment, bool producers
BOOST_LOG_TRIVIAL(error) << "GCodeProcessor encountered an invalid value for Width (" << comment << ").";
return;
}
// Orca: manual tool change tag
if (m_manual_filament_change && boost::starts_with(comment, reserved_tag(ETags::Manual_Tool_Change))) {
std::string_view tool_change_cmd = comment.substr(reserved_tag(ETags::Manual_Tool_Change).length());
if (boost::starts_with(tool_change_cmd, "T")) {
process_T(tool_change_cmd);
}
}
}
// color change tag