mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-14 06:26:05 +08:00
This commit is contained in:
parent
6ff5df7dd1
commit
c21af799d7
@ -1445,7 +1445,6 @@ void GCode::_do_export(Print &print, FILE *file)
|
|||||||
print.throw_if_canceled();
|
print.throw_if_canceled();
|
||||||
|
|
||||||
m_cooling_buffer->set_current_extruder(initial_extruder_id);
|
m_cooling_buffer->set_current_extruder(initial_extruder_id);
|
||||||
m_writer.toolchange(initial_extruder_id);
|
|
||||||
|
|
||||||
// Emit machine envelope limits for the Marlin firmware.
|
// Emit machine envelope limits for the Marlin firmware.
|
||||||
this->print_machine_envelope(file, print);
|
this->print_machine_envelope(file, print);
|
||||||
@ -1453,7 +1452,7 @@ void GCode::_do_export(Print &print, FILE *file)
|
|||||||
// Disable fan.
|
// Disable fan.
|
||||||
if ( print.config().disable_fan_first_layers.get_at(initial_extruder_id)
|
if ( print.config().disable_fan_first_layers.get_at(initial_extruder_id)
|
||||||
&& config().gcode_flavor != gcfKlipper)
|
&& config().gcode_flavor != gcfKlipper)
|
||||||
_write(file, m_writer.set_fan(0, true));
|
_write(file, m_writer.set_fan(0, true, initial_extruder_id));
|
||||||
|
|
||||||
// Let the start-up script prime the 1st printing tool.
|
// Let the start-up script prime the 1st printing tool.
|
||||||
m_placeholder_parser.set("initial_tool", initial_extruder_id);
|
m_placeholder_parser.set("initial_tool", initial_extruder_id);
|
||||||
|
@ -31,6 +31,44 @@ void GCodeWriter::apply_print_region_config(const PrintRegionConfig& print_regio
|
|||||||
config_region = &print_region_config;
|
config_region = &print_region_config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<uint16_t> GCodeWriter::extruder_ids() const {
|
||||||
|
std::vector<uint16_t> out;
|
||||||
|
out.reserve(m_extruders.size());
|
||||||
|
for (const Extruder& e : m_extruders)
|
||||||
|
out.push_back(e.id());
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<uint16_t> GCodeWriter::mill_ids() const {
|
||||||
|
std::vector<uint16_t> out;
|
||||||
|
out.reserve(m_millers.size());
|
||||||
|
for (const Tool& e : m_millers)
|
||||||
|
out.push_back(e.id());
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t GCodeWriter::first_mill() const {
|
||||||
|
if (m_millers.empty()) {
|
||||||
|
uint16_t max = 0;
|
||||||
|
for (const Extruder& e : m_extruders)
|
||||||
|
max = std::max(max, e.id());
|
||||||
|
max++;
|
||||||
|
return (uint16_t)max;
|
||||||
|
} else return m_millers.front().id();
|
||||||
|
}
|
||||||
|
bool GCodeWriter::tool_is_extruder() const {
|
||||||
|
return m_tool->id() < first_mill();
|
||||||
|
}
|
||||||
|
const Tool* GCodeWriter::get_tool(uint16_t id) const{
|
||||||
|
for (const Extruder& e : m_extruders)
|
||||||
|
if (id == e.id())
|
||||||
|
return &e;
|
||||||
|
for (const Tool& e : m_millers)
|
||||||
|
if (id == e.id())
|
||||||
|
return &e;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void GCodeWriter::set_extruders(std::vector<uint16_t> extruder_ids)
|
void GCodeWriter::set_extruders(std::vector<uint16_t> extruder_ids)
|
||||||
{
|
{
|
||||||
std::sort(extruder_ids.begin(), extruder_ids.end());
|
std::sort(extruder_ids.begin(), extruder_ids.end());
|
||||||
@ -89,9 +127,13 @@ std::string GCodeWriter::postamble() const
|
|||||||
|
|
||||||
std::string GCodeWriter::set_temperature(const unsigned int temperature, bool wait, int tool)
|
std::string GCodeWriter::set_temperature(const unsigned int temperature, bool wait, int tool)
|
||||||
{
|
{
|
||||||
|
//use m_tool if tool isn't set
|
||||||
|
if (tool < 0 && m_tool != nullptr)
|
||||||
|
tool = m_tool->id();
|
||||||
|
|
||||||
//add offset
|
//add offset
|
||||||
int16_t temp_w_offset = int16_t(temperature);
|
int16_t temp_w_offset = int16_t(temperature);
|
||||||
temp_w_offset += int16_t(m_tool->temp_offset());
|
temp_w_offset += int16_t(get_tool(tool)->temp_offset());
|
||||||
temp_w_offset = std::max(int16_t(0), std::min(int16_t(2000), temp_w_offset));
|
temp_w_offset = std::max(int16_t(0), std::min(int16_t(2000), temp_w_offset));
|
||||||
|
|
||||||
if (m_last_temperature_with_offset == temp_w_offset)
|
if (m_last_temperature_with_offset == temp_w_offset)
|
||||||
@ -175,13 +217,15 @@ std::string GCodeWriter::set_bed_temperature(unsigned int temperature, bool wait
|
|||||||
return gcode.str();
|
return gcode.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GCodeWriter::set_fan(const unsigned int speed, bool dont_save)
|
std::string GCodeWriter::set_fan(const unsigned int speed, bool dont_save, uint16_t default_tool)
|
||||||
{
|
{
|
||||||
std::ostringstream gcode;
|
std::ostringstream gcode;
|
||||||
|
|
||||||
|
const Tool *tool = m_tool == nullptr ? get_tool(default_tool) : m_tool;
|
||||||
//add fan_offset
|
//add fan_offset
|
||||||
int16_t fan_speed = int16_t(speed);
|
int16_t fan_speed = int16_t(speed);
|
||||||
fan_speed += int8_t(m_tool->fan_offset());
|
if (tool != nullptr)
|
||||||
|
fan_speed += int8_t(tool->fan_offset());
|
||||||
fan_speed = std::max(int16_t(0), std::min(int16_t(100), fan_speed));
|
fan_speed = std::max(int16_t(0), std::min(int16_t(100), fan_speed));
|
||||||
|
|
||||||
//test if it's useful to write it
|
//test if it's useful to write it
|
||||||
|
@ -34,41 +34,21 @@ public:
|
|||||||
// Extruders are expected to be sorted in an increasing order.
|
// Extruders are expected to be sorted in an increasing order.
|
||||||
void set_extruders(std::vector<uint16_t> extruder_ids);
|
void set_extruders(std::vector<uint16_t> extruder_ids);
|
||||||
const std::vector<Extruder>& extruders() const { return m_extruders; }
|
const std::vector<Extruder>& extruders() const { return m_extruders; }
|
||||||
std::vector<uint16_t> extruder_ids() const {
|
std::vector<uint16_t> extruder_ids() const;
|
||||||
std::vector<uint16_t> out;
|
|
||||||
out.reserve(m_extruders.size());
|
|
||||||
for (const Extruder& e : m_extruders)
|
|
||||||
out.push_back(e.id());
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
void set_mills(std::vector<uint16_t> extruder_ids);
|
void set_mills(std::vector<uint16_t> extruder_ids);
|
||||||
const std::vector<Mill>& mills() const { return m_millers; }
|
const std::vector<Mill>& mills() const { return m_millers; }
|
||||||
std::vector<uint16_t> mill_ids() const {
|
std::vector<uint16_t> mill_ids() const;
|
||||||
std::vector<uint16_t> out;
|
|
||||||
out.reserve(m_millers.size());
|
|
||||||
for (const Tool& e : m_millers)
|
|
||||||
out.push_back(e.id());
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
//give the first mill id or an id after the last extruder. Can be used to see if an id is an extruder or a mill
|
//give the first mill id or an id after the last extruder. Can be used to see if an id is an extruder or a mill
|
||||||
uint16_t first_mill() const {
|
uint16_t first_mill() const;
|
||||||
if (m_millers.empty()) {
|
bool tool_is_extruder() const;
|
||||||
uint16_t max = 0;
|
const Tool* get_tool(uint16_t id) const;
|
||||||
for (const Extruder& e : m_extruders)
|
|
||||||
max = std::max(max, e.id());
|
|
||||||
max++;
|
|
||||||
return (uint16_t)max;
|
|
||||||
}else return m_millers.front().id();
|
|
||||||
}
|
|
||||||
bool tool_is_extruder() const {
|
|
||||||
return m_tool->id() < first_mill();
|
|
||||||
}
|
|
||||||
std::string preamble();
|
std::string preamble();
|
||||||
std::string postamble() const;
|
std::string postamble() const;
|
||||||
std::string set_temperature(unsigned int temperature, bool wait = false, int tool = -1);
|
std::string set_temperature(unsigned int temperature, bool wait = false, int tool = -1);
|
||||||
std::string set_bed_temperature(unsigned int temperature, bool wait = false);
|
std::string set_bed_temperature(unsigned int temperature, bool wait = false);
|
||||||
unsigned int get_fan() { return m_last_fan_speed; }
|
unsigned int get_fan() { return m_last_fan_speed; }
|
||||||
std::string set_fan(unsigned int speed, bool dont_save = false);
|
/// set fan at speed. Save it as current fan speed if !dont_save, and use tool default_tool if the internal m_tool is null (no toolchange done yet).
|
||||||
|
std::string set_fan(unsigned int speed, bool dont_save = false, uint16_t default_tool = 0);
|
||||||
void set_acceleration(unsigned int acceleration);
|
void set_acceleration(unsigned int acceleration);
|
||||||
std::string write_acceleration();
|
std::string write_acceleration();
|
||||||
std::string reset_e(bool force = false);
|
std::string reset_e(bool force = false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user