improve handling of flush queue in extruder
authorJim Morris <morris@wolfman.com>
Tue, 18 Nov 2014 23:38:24 +0000 (15:38 -0800)
committerJim Morris <morris@wolfman.com>
Tue, 18 Nov 2014 23:38:24 +0000 (15:38 -0800)
src/modules/robot/Stepper.cpp
src/modules/tools/extruder/Extruder.cpp

index 229f2c1..c9aa130 100644 (file)
@@ -248,11 +248,11 @@ uint32_t Stepper::trapezoid_generator_tick( uint32_t dummy )
                 trapezoid_adjusted_rate -= current_block->rate_delta;
 
             } else if (trapezoid_adjusted_rate == current_block->rate_delta * 0.5F) {
-                for (auto i : THEKERNEL->robot->actuators)
-                    i->move(i->direction, 0);
-                if (current_block)
-                    current_block->release();
+                for (auto i : THEKERNEL->robot->actuators) i->move(i->direction, 0); // stop motors
+                if (current_block) current_block->release();
+                THEKERNEL->call_event(ON_SPEED_CHANGE, 0); // tell others we stopped
                 return 0;
+
             } else {
                 trapezoid_adjusted_rate = current_block->rate_delta * 0.5F;
             }
index 9d0e02e..e709fcc 100644 (file)
@@ -569,9 +569,9 @@ void Extruder::on_speed_change( void *argument )
         return;
     }
 
-    // if we are flushing the queue we need to stop the motor when it has decelerated to zero
+    // if we are flushing the queue we need to stop the motor when it has decelerated to zero, we get this call with argumnet == 0 when this happens
     // this is what steppermotor does
-    if(THEKERNEL->conveyor->is_flushing() && THEKERNEL->stepper->get_trapezoid_adjusted_rate() == this->current_block->rate_delta * 0.5F) {
+    if(argument == 0) {
         this->stepper_motor->move(0, 0);
         this->current_block->release();
         this->current_block = NULL;