mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-22 02:12:13 +00:00
Merge branch 'main' into bugfox/layer-cooling
This commit is contained in:
@@ -50,7 +50,11 @@ float get_axis_value(const std::string& line, char axis)
|
||||
char match[3] = " X";
|
||||
match[1] = axis;
|
||||
|
||||
size_t pos = line.find(match) + 2;
|
||||
size_t pos = line.find(match);
|
||||
if (pos == std::string::npos) {
|
||||
return NAN;
|
||||
}
|
||||
pos += 2;
|
||||
//size_t end = std::min(line.find(' ', pos + 1), line.find(';', pos + 1));
|
||||
// Try to parse the numeric value.
|
||||
const char* c = line.c_str();
|
||||
@@ -83,6 +87,15 @@ int16_t get_fan_speed(const std::string &line, GCodeFlavor flavor) {
|
||||
if (flavor == (gcfMach3) || flavor == (gcfMachinekit)) {
|
||||
return (int16_t)get_axis_value(line, 'P');
|
||||
} else {
|
||||
// Bambu machines use both M106 P1(not P0!) and M106 for part cooling fan.
|
||||
// Non-bambu machines usually use M106 (without P parameter) for part cooling fan.
|
||||
// P2 is reserved for auxiliary fan regardless of bambu or not.
|
||||
// To keep compatibility with Bambu machines, we accept M106 and M106 P1 as the only two valid form
|
||||
// of gcode that control the part cooling fan. Any other command will be ignored!
|
||||
const auto idx = get_axis_value(line, 'P');
|
||||
if (!isnan(idx) && idx != 1.0f) {
|
||||
return -1;
|
||||
}
|
||||
return (int16_t)get_axis_value(line, 'S');
|
||||
}
|
||||
} else if (line.compare(0, 4, "M127") == 0 || line.compare(0, 4, "M107") == 0) {
|
||||
|
||||
@@ -98,6 +98,8 @@ const std::vector<std::string> GCodeProcessor::Reserved_Tags_compatible = {
|
||||
const std::string GCodeProcessor::Flush_Start_Tag = " FLUSH_START";
|
||||
const std::string GCodeProcessor::Flush_End_Tag = " FLUSH_END";
|
||||
|
||||
//Orca: External device purge tag
|
||||
const std::string GCodeProcessor::External_Purge_Tag = " EXTERNAL_PURGE";
|
||||
|
||||
const float GCodeProcessor::Wipe_Width = 0.05f;
|
||||
const float GCodeProcessor::Wipe_Height = 0.05f;
|
||||
@@ -2289,6 +2291,24 @@ void GCodeProcessor::process_tags(const std::string_view comment, bool producers
|
||||
m_flushing = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// Orca: Integrate filament consumption for purging performed to an external device and controlled via macros
|
||||
// (eg. Happy Hare) in the filament consumption stats.
|
||||
if (boost::starts_with(comment, GCodeProcessor::External_Purge_Tag)) {
|
||||
std::regex numberRegex(R"(\d+\.\d+)");
|
||||
std::smatch match;
|
||||
std::string line(comment);
|
||||
if (std::regex_search(line, match, numberRegex)) {
|
||||
float filament_diameter = (static_cast<size_t>(m_extruder_id) < m_result.filament_diameters.size()) ? m_result.filament_diameters[m_extruder_id] : m_result.filament_diameters.back();
|
||||
float filament_radius = 0.5f * filament_diameter;
|
||||
float area_filament_cross_section = static_cast<float>(M_PI) * sqr(filament_radius);
|
||||
|
||||
float dE = std::stof(match.str());
|
||||
float volume_extruded_filament = area_filament_cross_section * dE;
|
||||
m_used_filaments.update_flush_per_filament(m_extruder_id, volume_extruded_filament);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!producers_enabled || m_producer == EProducer::OrcaSlicer) {
|
||||
// height tag
|
||||
|
||||
@@ -272,6 +272,7 @@ class Print;
|
||||
static const std::vector<std::string> Reserved_Tags_compatible;
|
||||
static const std::string Flush_Start_Tag;
|
||||
static const std::string Flush_End_Tag;
|
||||
static const std::string External_Purge_Tag;
|
||||
public:
|
||||
enum class ETags : unsigned char
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user