this->step_ticker->set_unstep_time( microseconds_per_step_pulse );
// Core modules
+ this->add_module( this->conveyor = new Conveyor() );
this->add_module( this->gcode_dispatch = new GcodeDispatch() );
this->add_module( this->robot = new Robot() );
- this->add_module( this->conveyor = new Conveyor() );
this->add_module( this->simpleshell = new SimpleShell() );
this->planner = new Planner();
// called from step ticker ISR
inline void set_direction(bool f) { dir_pin.set(f); direction= f; }
- inline void enable(bool state) { en_pin.set(!state); };
- inline bool is_enabled() const { return !en_pin.get(); };
- inline bool is_moving() const { return moving; };
+ void enable(bool state) { en_pin.set(!state); };
+ bool is_enabled() const { return !en_pin.get(); };
+ bool is_moving() const { return moving; };
void start_moving() { moving= true; }
void stop_moving() { moving= false; }
}
// Wait for the queue to be empty and for all the jobs to finish in step ticker
-void Conveyor::wait_for_idle()
+void Conveyor::wait_for_idle(bool wait_for_motors)
{
// wait for the job queue to empty, this means cycling everything on the block queue into the job queue
// forcing them to be jobs
THEKERNEL->call_event(ON_IDLE, this);
}
- // now we wait for all motors to stop moving
- while(!is_idle()) {
- THEKERNEL->call_event(ON_IDLE, this);
+ if(wait_for_motors) {
+ // now we wait for all motors to stop moving
+ while(!is_idle()) {
+ THEKERNEL->call_event(ON_IDLE, this);
+ }
}
+
running = true;
// returning now means that everything has totally finished
}
// we do this to allow an idle system to pre load the queue a bit so the first few blocks run smoothly.
if(force || queue.is_full() || (us_ticker_read() - last_time_check) >= (queue_delay_time_ms * 1000)) {
last_time_check = us_ticker_read(); // reset timeout
- allow_fetch = true;
+ if(!flush) allow_fetch = true;
return;
}
}
// default the feerate to zero if there is no block available
this->current_feedrate= 0;
- if(queue.isr_tail_i == queue.head_i) return false; // we do not have anything to give
+ if(halted || queue.isr_tail_i == queue.head_i) return false; // we do not have anything to give
// wait for queue to fill up, optimizes planning
if(!allow_fetch) return false;
// TODO force deceleration of last block
- running = false; // stops on_idle calling check_queue
- if(halted) {
- // wait for the queue to be drained by the stepticker and emptied by on idle
- // FIXME we do not wait for motors to stop here due to a race condition or bug
- while (!queue.is_empty()) {
- check_queue(true); // forces queue to be made available to stepticker
- THEKERNEL->call_event(ON_IDLE, this);
- }
- }else{
- // now wait until the job queue has finished and all motors are idle too
- wait_for_idle();
- }
+ // now wait until the block queue has been flushed
+ wait_for_idle(false);
flush= false;
}