From 90fca505359abaedc5fae4964f00583ccc060303 Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Thu, 30 Sep 2010 21:51:18 +0200 Subject: [PATCH] dda_queue.c/.h: merge enqueue() and enqueue_temp_wait(). This saves almost 200 bytes. --- dda_queue.c | 46 +++++++++++++++------------------------------- dda_queue.h | 4 +--- gcode.c | 4 ++-- 3 files changed, 18 insertions(+), 36 deletions(-) diff --git a/dda_queue.c b/dda_queue.c index 87af4f4..c4b1b85 100644 --- a/dda_queue.c +++ b/dda_queue.c @@ -69,7 +69,21 @@ void enqueue(TARGET *t) { uint8_t h = mb_head + 1; h &= (MOVEBUFFER_SIZE - 1); - dda_create(&movebuffer[h], t); + if (t != NULL) { + dda_create(&movebuffer[h], t); + } + else { + // it's a wait for temp + movebuffer[h].waitfor_temp = 1; + movebuffer[h].nullmove = 0; + #if (F_CPU & 0xFF000000) == 0 + // set "step" timeout to 1 second + movebuffer[h].c = F_CPU << 8; + #else + // set "step" timeout to maximum + movebuffer[h].c = 0xFFFFFF00; + #endif + } mb_head = h; @@ -84,36 +98,6 @@ void enqueue(TARGET *t) { enableTimerInterrupt(); } -void enqueue_temp_wait() { - // don't call this function when the queue is full, but just in case, wait for a move to complete and free up the space for the passed target - while (queue_full()) - delay(WAITING_DELAY); - - uint8_t h = mb_head + 1; - h &= (MOVEBUFFER_SIZE - 1); - - // wait for temp flag - movebuffer[h].waitfor_temp = 1; - movebuffer[h].nullmove = 0; - #if (F_CPU & 0xFF000000) == 0 - // set "step" timeout to 1 second - movebuffer[h].c = F_CPU << 8; - #else - // set "step" timeout to maximum - movebuffer[h].c = 0xFFFFFF00; - #endif - - mb_head = h; - - #ifdef XONXOFF - if (((mb_tail - mb_head - 1) & (MOVEBUFFER_SIZE - 1)) < (MOVEBUFFER_SIZE - 2)) - xoff(); - #endif - - // fire up in case we're not running yet - enableTimerInterrupt(); -} - void next_move() { if (queue_empty() == 0) { // next item diff --git a/dda_queue.h b/dda_queue.h index 90d5fab..9edf865 100644 --- a/dda_queue.h +++ b/dda_queue.h @@ -24,11 +24,9 @@ uint8_t queue_empty(void); void queue_step(void); // add a new target to the queue +// t == NULL means add a wait for target temp to the queue void enqueue(TARGET *t); -// add a wait for target temp to the queue -void enqueue_temp_wait(void); - // called from step timer when current move is complete void next_move(void) __attribute__ ((hot)); diff --git a/gcode.c b/gcode.c index 4f3212b..74cbbf8 100644 --- a/gcode.c +++ b/gcode.c @@ -533,7 +533,7 @@ void process_gcode_command(GCODE_COMMAND *gcmd) { // M101- extruder on case 101: if (temp_achieved() == 0) { - enqueue_temp_wait(); + enqueue(NULL); } do { // backup feedrate, move E very quickly then restore feedrate @@ -595,7 +595,7 @@ void process_gcode_command(GCODE_COMMAND *gcmd) { else { disable_heater(); } - enqueue_temp_wait(); + enqueue(NULL); break; // M110- set line number