mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-12 10:58:59 +08:00
Merge branch 'feature-2700-has_heatbed' of https://github.com/lordofhyphens/Slic3r into lordofhyphens-feature-2700-has_heatbed
Conflicts: t/gcode.t
This commit is contained in:
commit
bec26c51af
@ -1046,7 +1046,7 @@ sub build {
|
|||||||
my (%params) = @_;
|
my (%params) = @_;
|
||||||
|
|
||||||
$self->init_config_options(qw(
|
$self->init_config_options(qw(
|
||||||
bed_shape z_offset
|
bed_shape z_offset has_heatbed
|
||||||
gcode_flavor use_relative_e_distances
|
gcode_flavor use_relative_e_distances
|
||||||
serial_port serial_speed
|
serial_port serial_speed
|
||||||
octoprint_host octoprint_apikey
|
octoprint_host octoprint_apikey
|
||||||
@ -1113,6 +1113,7 @@ sub build {
|
|||||||
);
|
);
|
||||||
$optgroup->append_single_option_line($option);
|
$optgroup->append_single_option_line($option);
|
||||||
}
|
}
|
||||||
|
$optgroup->append_single_option_line('has_heatbed');
|
||||||
$optgroup->on_change(sub {
|
$optgroup->on_change(sub {
|
||||||
my ($opt_id) = @_;
|
my ($opt_id) = @_;
|
||||||
if ($opt_id eq 'extruders_count') {
|
if ($opt_id eq 'extruders_count') {
|
||||||
|
@ -162,7 +162,7 @@ sub export {
|
|||||||
if $self->config->cooling && $self->config->disable_fan_first_layers;
|
if $self->config->cooling && $self->config->disable_fan_first_layers;
|
||||||
|
|
||||||
# set bed temperature
|
# set bed temperature
|
||||||
if ((my $temp = $self->config->first_layer_bed_temperature) && $self->config->start_gcode !~ /M(?:190|140)/i) {
|
if ($self->config->has_heatbed && (my $temp = $self->config->first_layer_bed_temperature) && $self->config->start_gcode !~ /M(?:190|140)/i) {
|
||||||
printf $fh $gcodegen->writer->set_bed_temperature($temp, 1);
|
printf $fh $gcodegen->writer->set_bed_temperature($temp, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,7 +264,7 @@ sub export {
|
|||||||
# is triggered, so machine has more time to reach such temperatures
|
# is triggered, so machine has more time to reach such temperatures
|
||||||
if ($layer->id == 0 && $finished_objects > 0) {
|
if ($layer->id == 0 && $finished_objects > 0) {
|
||||||
printf $fh $gcodegen->writer->set_bed_temperature($self->config->first_layer_bed_temperature),
|
printf $fh $gcodegen->writer->set_bed_temperature($self->config->first_layer_bed_temperature),
|
||||||
if $self->config->first_layer_bed_temperature;
|
if $self->config->first_layer_bed_temperature && $self->config->has_heatbed;
|
||||||
$self->_print_first_layer_temperature(0);
|
$self->_print_first_layer_temperature(0);
|
||||||
}
|
}
|
||||||
$self->process_layer($layer, [$copy]);
|
$self->process_layer($layer, [$copy]);
|
||||||
@ -375,7 +375,7 @@ sub process_layer {
|
|||||||
if $temperature && $temperature != $self->config->get_at('first_layer_temperature', $extruder->id);
|
if $temperature && $temperature != $self->config->get_at('first_layer_temperature', $extruder->id);
|
||||||
}
|
}
|
||||||
$gcode .= $self->_gcodegen->writer->set_bed_temperature($self->print->config->bed_temperature)
|
$gcode .= $self->_gcodegen->writer->set_bed_temperature($self->print->config->bed_temperature)
|
||||||
if $self->print->config->bed_temperature && $self->print->config->bed_temperature != $self->print->config->first_layer_bed_temperature;
|
if $self->config->has_heatbed && $self->print->config->bed_temperature && $self->print->config->bed_temperature != $self->print->config->first_layer_bed_temperature;
|
||||||
$self->_second_layer_things_done(1);
|
$self->_second_layer_things_done(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
47
t/gcode.t
47
t/gcode.t
@ -1,4 +1,4 @@
|
|||||||
use Test::More tests => 25;
|
use Test::More tests => 27;
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
@ -216,7 +216,6 @@ use Slic3r::Test;
|
|||||||
ok !$spiral, 'spiral vase is correctly disabled on layers with multiple loops';
|
ok !$spiral, 'spiral vase is correctly disabled on layers with multiple loops';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
# Tests that the Repetier flavor produces M201 Xnnn Ynnn for resetting
|
# Tests that the Repetier flavor produces M201 Xnnn Ynnn for resetting
|
||||||
# acceleration, also that M204 Snnn syntax is not generated.
|
# acceleration, also that M204 Snnn syntax is not generated.
|
||||||
@ -243,4 +242,48 @@ use Slic3r::Test;
|
|||||||
ok !$has_m204, 'M204 is not generated for repetier firmware';
|
ok !$has_m204, 'M204 is not generated for repetier firmware';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
# Test verifies that if has_heatbed is false, M190/M140 gcodes are not
|
||||||
|
# generated by default even if a bed temperature is set.
|
||||||
|
my $config = Slic3r::Config->new_from_defaults;
|
||||||
|
$config->set('has_heatbed', 0);
|
||||||
|
$config->set('first_layer_bed_temperature', 100);
|
||||||
|
$config->set('bed_temperature', 60);
|
||||||
|
|
||||||
|
my $had_gcode = 0;
|
||||||
|
my $print = Slic3r::Test::init_print('cube_with_hole', config => $config);
|
||||||
|
Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub {
|
||||||
|
my ($self, $cmd, $args, $info) = @_;
|
||||||
|
|
||||||
|
if (($cmd eq 'M140' && exists $args->{S}) ||
|
||||||
|
($cmd eq 'M190' && exists $args->{S})) {
|
||||||
|
$had_gcode = 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ok !$had_gcode, 'M190/M140 codes are not generated if has_heatbed = 0';
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
# Test verifies that if has_heatbed is true, M190/M140 gcodes are
|
||||||
|
# generated by default if a bed temperature is set.
|
||||||
|
my $config = Slic3r::Config->new_from_defaults;
|
||||||
|
$config->set('has_heatbed', 1);
|
||||||
|
$config->set('first_layer_bed_temperature', 100);
|
||||||
|
$config->set('bed_temperature', 60);
|
||||||
|
|
||||||
|
my $had_gcode = 0;
|
||||||
|
my $print = Slic3r::Test::init_print('cube_with_hole', config => $config);
|
||||||
|
Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub {
|
||||||
|
my ($self, $cmd, $args, $info) = @_;
|
||||||
|
|
||||||
|
if (($cmd eq 'M140' && exists $args->{S}) ||
|
||||||
|
($cmd eq 'M190' && exists $args->{S})) {
|
||||||
|
$had_gcode = 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ok $had_gcode, 'M190/M140 codes are generated if has_heatbed = 1';
|
||||||
|
}
|
||||||
|
|
||||||
__END__
|
__END__
|
||||||
|
@ -23,6 +23,11 @@ PrintConfigDef::PrintConfigDef()
|
|||||||
opt->values.push_back(Pointf(0,200));
|
opt->values.push_back(Pointf(0,200));
|
||||||
def->default_value = opt;
|
def->default_value = opt;
|
||||||
}
|
}
|
||||||
|
def = this->add("has_heatbed", coBool);
|
||||||
|
def->label = "Has heated bed";
|
||||||
|
def->tooltip = "Unselecting this will suppress automatic generation of bed heating gcode.";
|
||||||
|
def->cli = "has_heatbed!";
|
||||||
|
def->default_value = new ConfigOptionBool(true);
|
||||||
|
|
||||||
def = this->add("bed_temperature", coInt);
|
def = this->add("bed_temperature", coInt);
|
||||||
def->label = "Other layers";
|
def->label = "Other layers";
|
||||||
|
@ -362,6 +362,7 @@ class PrintConfig : public GCodeConfig
|
|||||||
public:
|
public:
|
||||||
ConfigOptionBool avoid_crossing_perimeters;
|
ConfigOptionBool avoid_crossing_perimeters;
|
||||||
ConfigOptionPoints bed_shape;
|
ConfigOptionPoints bed_shape;
|
||||||
|
ConfigOptionBool has_heatbed;
|
||||||
ConfigOptionInt bed_temperature;
|
ConfigOptionInt bed_temperature;
|
||||||
ConfigOptionFloat bridge_acceleration;
|
ConfigOptionFloat bridge_acceleration;
|
||||||
ConfigOptionInt bridge_fan_speed;
|
ConfigOptionInt bridge_fan_speed;
|
||||||
@ -420,6 +421,7 @@ class PrintConfig : public GCodeConfig
|
|||||||
virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) {
|
virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) {
|
||||||
OPT_PTR(avoid_crossing_perimeters);
|
OPT_PTR(avoid_crossing_perimeters);
|
||||||
OPT_PTR(bed_shape);
|
OPT_PTR(bed_shape);
|
||||||
|
OPT_PTR(has_heatbed);
|
||||||
OPT_PTR(bed_temperature);
|
OPT_PTR(bed_temperature);
|
||||||
OPT_PTR(bridge_acceleration);
|
OPT_PTR(bridge_acceleration);
|
||||||
OPT_PTR(bridge_fan_speed);
|
OPT_PTR(bridge_fan_speed);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user