FIX: wrong bed temp in placeholder

1.Also add a new field to mark whether enable high low temp mix

jira: NONE

Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Change-Id: I208e0e7a4ce75feccc8659ecf940447e591d9505
This commit is contained in:
xun.zhang 2025-02-26 17:17:15 +08:00 committed by lane.wei
parent 74902e5870
commit e79ba2f1ec
2 changed files with 22 additions and 10 deletions

View File

@ -2267,7 +2267,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
int max_chamber_temp = 0; int max_chamber_temp = 0;
{ {
int curr_bed_type = m_config.curr_bed_type.getInt(); BedType curr_bed_type = m_config.curr_bed_type;
for (const auto& extruder : m_writer.extruders()) for (const auto& extruder : m_writer.extruders())
max_chamber_temp = std::max(max_chamber_temp, m_config.chamber_temperatures.get_at(extruder.id())); max_chamber_temp = std::max(max_chamber_temp, m_config.chamber_temperatures.get_at(extruder.id()));
@ -2275,13 +2275,20 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
std::string first_layer_bed_temp_str; std::string first_layer_bed_temp_str;
const ConfigOptionInts* first_bed_temp_opt = m_config.option<ConfigOptionInts>(get_bed_temp_1st_layer_key((BedType)curr_bed_type)); const ConfigOptionInts* first_bed_temp_opt = m_config.option<ConfigOptionInts>(get_bed_temp_1st_layer_key((BedType)curr_bed_type));
const ConfigOptionInts* bed_temp_opt = m_config.option<ConfigOptionInts>(get_bed_temp_key((BedType)curr_bed_type)); const ConfigOptionInts* bed_temp_opt = m_config.option<ConfigOptionInts>(get_bed_temp_key((BedType)curr_bed_type));
int target_bed_temp=0;
if (m_config.bed_temperature_formula == BedTempFormula::btfHighestTemp)
target_bed_temp = get_highest_bed_temperature(true, print);
else
target_bed_temp = get_bed_temperature(initial_extruder_id, true,curr_bed_type);
m_placeholder_parser.set("bbl_bed_temperature_gcode", new ConfigOptionBool(false)); m_placeholder_parser.set("bbl_bed_temperature_gcode", new ConfigOptionBool(false));
m_placeholder_parser.set("bed_temperature_initial_layer", new ConfigOptionInts(*first_bed_temp_opt)); m_placeholder_parser.set("bed_temperature_initial_layer", new ConfigOptionInts(*first_bed_temp_opt));
m_placeholder_parser.set("bed_temperature", new ConfigOptionInts(*bed_temp_opt)); m_placeholder_parser.set("bed_temperature", new ConfigOptionInts(*bed_temp_opt));
m_placeholder_parser.set("bed_temperature_initial_layer_single", new ConfigOptionInt(first_bed_temp_opt->get_at(initial_extruder_id))); m_placeholder_parser.set("bed_temperature_initial_layer_single", new ConfigOptionInt(target_bed_temp));
m_placeholder_parser.set("bed_temperature_initial_layer_vector", new ConfigOptionString("")); m_placeholder_parser.set("bed_temperature_initial_layer_vector", new ConfigOptionString(""));
m_placeholder_parser.set("chamber_temperature", new ConfigOptionInts({max_chamber_temp})); m_placeholder_parser.set("chamber_temperature", new ConfigOptionInts({max_chamber_temp}));
m_placeholder_parser.set("overall_chamber_temperature", new ConfigOptionInt(max_chamber_temp)); m_placeholder_parser.set("overall_chamber_temperature", new ConfigOptionInt(max_chamber_temp));
m_placeholder_parser.set("enable_high_low_temp_mix", new ConfigOptionBool(!print.need_check_multi_filaments_compatibility()));
//support variables `first_layer_temperature` and `first_layer_bed_temperature` //support variables `first_layer_temperature` and `first_layer_bed_temperature`
m_placeholder_parser.set("first_layer_bed_temperature", new ConfigOptionInts(*first_bed_temp_opt)); m_placeholder_parser.set("first_layer_bed_temperature", new ConfigOptionInts(*first_bed_temp_opt));
@ -3166,6 +3173,15 @@ int GCode::get_bed_temperature(const int extruder_id, const bool is_first_layer,
return bed_temp_opt->get_at(extruder_id); return bed_temp_opt->get_at(extruder_id);
} }
int GCode::get_highest_bed_temperature(const bool is_first_layer, const Print& print) const
{
auto bed_type = m_config.curr_bed_type;
int bed_temp = 0;
for (auto fidx : print.get_slice_used_filaments(is_first_layer)) {
bed_temp = std::max(bed_temp, get_bed_temperature(fidx, is_first_layer, bed_type));
}
return bed_temp;
}
// Write 1st layer bed temperatures into the G-code. // Write 1st layer bed temperatures into the G-code.
// Only do that if the start G-code does not already contain any M-code controlling an extruder temperature. // Only do that if the start G-code does not already contain any M-code controlling an extruder temperature.
@ -3178,9 +3194,7 @@ void GCode::_print_first_layer_bed_temperature(GCodeOutputStream &file, Print &p
std::vector<int> temps_per_bed; std::vector<int> temps_per_bed;
int bed_temp = 0; int bed_temp = 0;
if (m_config.bed_temperature_formula.value == BedTempFormula::btfHighestTemp) { if (m_config.bed_temperature_formula.value == BedTempFormula::btfHighestTemp) {
for (auto fidx : print.get_slice_used_filaments(true)) { bed_temp = get_highest_bed_temperature(true, print);
bed_temp = std::max(bed_temp, get_bed_temperature(fidx, true, print.config().curr_bed_type));
}
} }
else { else {
bed_temp = get_bed_temperature(first_printing_extruder_id, true, print.config().curr_bed_type); bed_temp = get_bed_temperature(first_printing_extruder_id, true, print.config().curr_bed_type);
@ -3709,11 +3723,8 @@ GCode::LayerResult GCode::process_layer(
// BBS // BBS
int bed_temp = 0; int bed_temp = 0;
if (m_config.bed_temperature_formula == BedTempFormula::btfHighestTemp) { if (m_config.bed_temperature_formula == BedTempFormula::btfHighestTemp)
for (auto fidx : print.get_slice_used_filaments(false)) { bed_temp = get_highest_bed_temperature(false,print);
bed_temp = std::max(bed_temp, get_bed_temperature(fidx, false, m_config.curr_bed_type));
}
}
else else
bed_temp = get_bed_temperature(first_extruder_id, false, m_config.curr_bed_type); bed_temp = get_bed_temperature(first_extruder_id, false, m_config.curr_bed_type);
gcode += m_writer.set_bed_temperature(bed_temp); gcode += m_writer.set_bed_temperature(bed_temp);

View File

@ -570,6 +570,7 @@ private:
std::vector<std::vector<unsigned int>> m_sorted_layer_filaments; std::vector<std::vector<unsigned int>> m_sorted_layer_filaments;
// BBS // BBS
int get_bed_temperature(const int extruder_id, const bool is_first_layer, const BedType bed_type) const; int get_bed_temperature(const int extruder_id, const bool is_first_layer, const BedType bed_type) const;
int get_highest_bed_temperature(const bool is_first_layer,const Print &print) const;
std::string _extrude(const ExtrusionPath &path, std::string description = "", double speed = -1, bool set_holes_and_compensation_speed = false, bool is_first_slope = false); std::string _extrude(const ExtrusionPath &path, std::string description = "", double speed = -1, bool set_holes_and_compensation_speed = false, bool is_first_slope = false);
ExtrusionPaths set_speed_transition(ExtrusionPaths &paths); ExtrusionPaths set_speed_transition(ExtrusionPaths &paths);