diff --git a/dda_queue.c b/dda_queue.c index e97a916..05d566f 100644 --- a/dda_queue.c +++ b/dda_queue.c @@ -153,19 +153,18 @@ void enqueue_home(TARGET *t, uint8_t endstop_check, uint8_t endstop_stop_cond) { /// timer interrupt is disabled). void next_move() { while ((queue_empty() == 0) && (movebuffer[mb_tail].live == 0)) { - // next item - mb_tail = MB_NEXT(mb_tail); - DDA* current_movebuffer = &movebuffer[mb_tail]; // Tail must be set before calling timer_set(), as timer_set() reenables // the timer interrupt, potentially exposing mb_tail to the timer // interrupt routine. - if (current_movebuffer->waitfor_temp) { + mb_tail = MB_NEXT(mb_tail); + + if (movebuffer[mb_tail].waitfor_temp) { serial_writestr_P(PSTR("Waiting for target temp\n")); - current_movebuffer->live = 1; + movebuffer[mb_tail].live = 1; timer_set(HEATER_WAIT_TIMEOUT, 0); } else { - dda_start(current_movebuffer); + dda_start(&movebuffer[mb_tail]); } } }