this->num_motors = 0;
this->running = false;
+ this->current_block = nullptr;
#ifdef STEPTICKER_DEBUG_PIN
// setup debug pin if defined
if(finished_fnc) finished_fnc();
}
-
// step clock
void StepTicker::step_tick (void)
{
//SET_STEPTICKER_DEBUG_PIN(running ? 1 : 0);
+ // if nothing has been setup we ignore the ticks
if(!running){
- // if nothing has been setup we ignore the ticks
- if(current_block == nullptr) return;
- running= true;
+ // check if anything new available
+ if(THECONVEYOR->get_next_block(¤t_block)) { // returns false if no new block is available
+ running= start_next_block(); // returns true if there is at least one motor with steps to issue
+ if(!running) return;
+ }else{
+ return;
+ }
+ }
+
+ if(THEKERNEL->is_halted()) {
+ running= false;
+ return;
}
bool still_moving= false;
++current_block->tick_info[m].step_count;
// step the motor
- motor[m]->step();
+ bool ismoving= motor[m]->step(); // returns false if the moving flag was set to false externally (probes, endstops etc)
// we stepped so schedule an unstep
unstep.set(m);
- if(current_block->tick_info[m].step_count == current_block->tick_info[m].steps_to_move) {
+ if(!ismoving || current_block->tick_info[m].step_count == current_block->tick_info[m].steps_to_move) {
// done
current_block->tick_info[m].steps_to_move = 0;
motor[m]->moving= false; // let motor know it is no longer moving
// get next block
// do it here so there is no delay in ticks
+ THECONVEYOR->block_finished();
- if(THECONVEYOR->get_next_block(¤t_block)) { // returns false if no new job available
+ if(THECONVEYOR->get_next_block(¤t_block)) { // returns false if no new block is available
running= start_next_block(); // returns true if there is at least one motor with steps to issue
+
}else{
current_block= nullptr;
running= false;