dda_create(): store prev_dda locally.
This obviously requires less place on the stack and accordingly a few CPU cycles less, but more importantly, it lets decide dda_start() whether a previous movement is to be taken into account or not. To make this decision more reliable, add a flag for movements done. Else it could happen we'd try to join with a movement done long before.
This commit is contained in:
parent
ec9e84a068
commit
ddd8988727
10
dda.c
10
dda.c
|
|
@ -83,12 +83,16 @@ void dda_new_startpoint(void) {
|
|||
|
||||
This algorithm is probably the main limiting factor to print speed in terms of firmware limitations
|
||||
*/
|
||||
void dda_create(DDA *dda, TARGET *target, DDA *prev_dda) {
|
||||
void dda_create(DDA *dda, TARGET *target) {
|
||||
uint32_t steps, x_delta_um, y_delta_um, z_delta_um, e_delta_um;
|
||||
uint32_t distance, c_limit, c_limit_calc;
|
||||
#ifdef LOOKAHEAD
|
||||
// Number the moves to identify them; allowed to overflow.
|
||||
static uint8_t idcnt = 0;
|
||||
static DDA* prev_dda = NULL;
|
||||
|
||||
if (prev_dda && prev_dda->done)
|
||||
prev_dda = NULL;
|
||||
#endif
|
||||
|
||||
// initialise DDA to a known state
|
||||
|
|
@ -405,6 +409,9 @@ void dda_create(DDA *dda, TARGET *target, DDA *prev_dda) {
|
|||
|
||||
// next dda starts where we finish
|
||||
memcpy(&startpoint, target, sizeof(TARGET));
|
||||
#ifdef LOOKAHEAD
|
||||
prev_dda = dda;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*! Start a prepared DDA
|
||||
|
|
@ -637,6 +644,7 @@ void dda_step(DDA *dda) {
|
|||
#endif
|
||||
) {
|
||||
dda->live = 0;
|
||||
dda->done = 1;
|
||||
#ifdef LOOKAHEAD
|
||||
// If look-ahead was using this move, it could have missed our activation:
|
||||
// make sure the ids do not match.
|
||||
|
|
|
|||
5
dda.h
5
dda.h
|
|
@ -103,6 +103,7 @@ typedef struct {
|
|||
// status fields
|
||||
uint8_t nullmove :1; ///< bool: no axes move, maybe we wait for temperatures or change speed
|
||||
uint8_t live :1; ///< bool: this DDA is running and still has steps to do
|
||||
uint8_t done :1; ///< bool: this DDA is done.
|
||||
#ifdef ACCELERATION_REPRAP
|
||||
uint8_t accel :1; ///< bool: speed changes during this move, run accel code
|
||||
#endif
|
||||
|
|
@ -116,7 +117,7 @@ typedef struct {
|
|||
uint8_t z_direction :1; ///< direction flag for Z axis
|
||||
uint8_t e_direction :1; ///< direction flag for E axis
|
||||
};
|
||||
uint8_t allflags; ///< used for clearing all flags
|
||||
uint16_t allflags; ///< used for clearing all flags
|
||||
};
|
||||
|
||||
// distances
|
||||
|
|
@ -198,7 +199,7 @@ void dda_init(void);
|
|||
void dda_new_startpoint(void);
|
||||
|
||||
// create a DDA
|
||||
void dda_create(DDA *dda, TARGET *target, DDA *prev_dda);
|
||||
void dda_create(DDA *dda, TARGET *target);
|
||||
|
||||
// start a created DDA (called from timer interrupt)
|
||||
void dda_start(DDA *dda) __attribute__ ((hot));
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ void queue_step() {
|
|||
if (current_movebuffer->waitfor_temp) {
|
||||
setTimer(HEATER_WAIT_TIMEOUT);
|
||||
if (temp_achieved()) {
|
||||
current_movebuffer->live = current_movebuffer->waitfor_temp = 0;
|
||||
current_movebuffer->live = current_movebuffer->done = 0;
|
||||
serial_writestr_P(PSTR("Temp achieved\n"));
|
||||
}
|
||||
}
|
||||
|
|
@ -112,10 +112,9 @@ void enqueue_home(TARGET *t, uint8_t endstop_check, uint8_t endstop_stop_cond) {
|
|||
h &= (MOVEBUFFER_SIZE - 1);
|
||||
|
||||
DDA* new_movebuffer = &(movebuffer[h]);
|
||||
DDA* prev_movebuffer = (queue_empty() != 0) ? NULL : &movebuffer[mb_head];
|
||||
|
||||
if (t != NULL) {
|
||||
dda_create(new_movebuffer, t, prev_movebuffer);
|
||||
dda_create(new_movebuffer, t);
|
||||
new_movebuffer->endstop_check = endstop_check;
|
||||
new_movebuffer->endstop_stop_cond = endstop_stop_cond;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue