Prevent absolute movement if user hasn't homed both X and Y

This commit is contained in:
Alessandro Ranellucci 2015-11-20 09:36:17 +01:00
parent cc57432be4
commit 4a65671f64
2 changed files with 9 additions and 2 deletions

View File

@ -9,7 +9,7 @@ use Wx qw(:dialog :id :misc :sizer :choicebook :button :bitmap
use Wx::Event qw(EVT_CLOSE EVT_BUTTON);
use base qw(Wx::Dialog Class::Accessor);
__PACKAGE__->mk_accessors(qw(sender config2));
__PACKAGE__->mk_accessors(qw(sender config2 x_homed y_homed));
sub new {
my ($class, $parent, $config, $sender) = @_;
@ -62,6 +62,11 @@ sub new {
$canvas->on_move(sub {
my ($pos) = @_;
if (!($self->x_homed && $self->y_homed)) {
Slic3r::GUI::show_error($self, "Please home both X and Y before moving.");
return ;
}
# delete any pending commands to get a smoother movement
$self->sender->purge_queue(1);
$self->abs_xy_move($pos);
@ -177,6 +182,8 @@ sub home {
$self->sender->send(sprintf("G28 %s", $axis), 1);
$self->{canvas}->set_pos(undef);
$self->x_homed if $axis eq 'X';
$self->y_homed if $axis eq 'Y';
}
1;

View File

@ -281,7 +281,7 @@ sub new {
);
if (!$res || !$sender->wait_connected) {
Slic3r::GUI::show_error(undef, "Connection failed. Check serial port and speed.");
return;
#return;
}
my $dlg = Slic3r::GUI::Controller::ManualControlDialog->new
($self, $self->config, $sender);