Smoother manual control movements

This commit is contained in:
Alessandro Ranellucci 2015-11-08 10:10:54 +01:00
parent 37ecc61d06
commit 9febb10bd7
4 changed files with 12 additions and 6 deletions

View File

@ -58,6 +58,9 @@ sub new {
$canvas->interactive(1);
$canvas->on_move(sub {
my ($pos) = @_;
# delete any pending commands to get a smoother movement
$self->purge_queue(1);
$self->abs_xy_move($pos);
});
$bed_sizer->Add($canvas, 0, wxEXPAND | wxRIGHT, 3);

View File

@ -172,16 +172,19 @@ GCodeSender::resume_queue()
}
void
GCodeSender::purge_queue()
GCodeSender::purge_queue(bool priority)
{
boost::lock_guard<boost::mutex> l(this->queue_mutex);
{
// clear queue
std::queue<std::string> empty;
if (priority) {
// clear priority queue
std::swap(this->priqueue, empty);
} else {
// clear queue
std::swap(this->queue, empty);
}
this->queue_paused = false;
}
}
// purge log and return its contents
std::vector<std::string>

View File

@ -28,7 +28,7 @@ class GCodeSender : private boost::noncopyable {
size_t queue_size() const;
void pause_queue();
void resume_queue();
void purge_queue();
void purge_queue(bool priority = false);
std::vector<std::string> purge_log();
std::string getT() const;
std::string getB() const;

View File

@ -18,7 +18,7 @@
void send(std::string s, bool priority = false);
void pause_queue();
void resume_queue();
void purge_queue();
void purge_queue(bool priority = false);
std::vector<std::string> purge_log();
std::string getT();
std::string getB();