Skip to content

Commit e20a46a

Browse files
committed
Handle nozzle switch with BambuLab flavor
CURA-12474
1 parent 471652f commit e20a46a

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

Diff for: include/settings/EnumSettings.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,13 @@ enum class EGCodeFlavor
238238
* Real RepRap GCode suitable for printers using RepRap firmware (e.g. Duet controllers)
239239
**/
240240
REPRAP = 8,
241-
PLUGIN = 9,
241+
242+
/**
243+
* Marlin-based GCode, with some variants to handle specific BambuLab instructions, e.g. AMS
244+
**/
245+
BAMBULAB = 9,
246+
247+
PLUGIN = 10,
242248
};
243249

244250
/*!

Diff for: src/gcodeExport.cpp

+11-3
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ std::string GCodeExport::flavorToString(const EGCodeFlavor& flavor)
195195
return "Repetier";
196196
case EGCodeFlavor::REPRAP:
197197
return "RepRap";
198+
case EGCodeFlavor::BAMBULAB:
199+
return "BambuLab";
198200
case EGCodeFlavor::MARLIN:
199201
default:
200202
return "Marlin";
@@ -302,7 +304,7 @@ std::string GCodeExport::getFileHeader(
302304

303305
prefix << ";NOZZLE_DIAMETER:" << Application::getInstance().current_slice_->scene.extruders[0].settings_.get<double>("machine_nozzle_size") << new_line_;
304306
}
305-
else if (flavor_ == EGCodeFlavor::REPRAP || flavor_ == EGCodeFlavor::MARLIN || flavor_ == EGCodeFlavor::MARLIN_VOLUMATRIC)
307+
else if (flavor_ == EGCodeFlavor::REPRAP || flavor_ == EGCodeFlavor::MARLIN || flavor_ == EGCodeFlavor::MARLIN_VOLUMATRIC || flavor_ == EGCodeFlavor::BAMBULAB)
306308
{
307309
prefix << ";Filament used: ";
308310
if (filament_used.size() > 0)
@@ -1319,6 +1321,12 @@ void GCodeExport::startExtruder(const size_t new_extruder)
13191321
extruder_attr_[new_extruder].is_used_ = true;
13201322
if (new_extruder != current_extruder_) // wouldn't be the case on the very first extruder start if it's extruder 0
13211323
{
1324+
if (flavor_ == EGCodeFlavor::BAMBULAB)
1325+
{
1326+
// Prepare AMS for extruder change
1327+
*output_stream_ << "M620 S" << new_extruder << "A" << new_line_;
1328+
}
1329+
13221330
if (flavor_ == EGCodeFlavor::MAKERBOT)
13231331
{
13241332
*output_stream_ << "M135 T" << new_extruder << new_line_;
@@ -1594,7 +1602,7 @@ void GCodeExport::writeTemperatureCommand(const size_t extruder, const Temperatu
15941602

15951603
if (wait && flavor_ != EGCodeFlavor::MAKERBOT)
15961604
{
1597-
if (flavor_ == EGCodeFlavor::MARLIN)
1605+
if (flavor_ == EGCodeFlavor::MARLIN || flavor_ == EGCodeFlavor::BAMBULAB)
15981606
{
15991607
*output_stream_ << "M105" << new_line_; // get temperatures from the last update, the M109 will not let get the target temperature
16001608
}
@@ -1638,7 +1646,7 @@ void GCodeExport::writeBedTemperatureCommand(const Temperature& temperature, con
16381646
{
16391647
if (wait)
16401648
{
1641-
if (flavor_ == EGCodeFlavor::MARLIN)
1649+
if (flavor_ == EGCodeFlavor::MARLIN || flavor_ == EGCodeFlavor::BAMBULAB)
16421650
{
16431651
*output_stream_ << "M140 S"; // set the temperature, it will be used as target temperature from M105
16441652
*output_stream_ << PrecisionedDouble{ 1, temperature } << new_line_;

Diff for: src/settings/Settings.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,8 @@ EGCodeFlavor Settings::get<EGCodeFlavor>(const std::string& key) const
387387
return EGCodeFlavor::REPETIER;
388388
case "RepRap (RepRap)"_sw:
389389
return EGCodeFlavor::REPRAP;
390+
case "BambuLab"_sw:
391+
return EGCodeFlavor::BAMBULAB;
390392
case "plugin"_sw:
391393
return EGCodeFlavor::PLUGIN;
392394
default:

0 commit comments

Comments
 (0)