From 1e9cb8b8e19411b7ee093b51d3ce17402b9eea6c Mon Sep 17 00:00:00 2001 From: Phil Hord Date: Wed, 1 Feb 2017 10:21:48 -0800 Subject: [PATCH] dda->id is needed even when !LOOKAHEAD In `ACCELERATION_RAMPING` code we use the dda->id field even when we do not enable `LOOKAHEAD`. Expose the variable and its related `idcnt` when `ACCELERATION_RAMPING` is used. Add a regression-test to catch this in the future. --- Makefile-common | 3 +++ dda.c | 6 +++++- dda.h | 2 +- testcases/config.regtest-no-lookahead.h | 7 +++++++ 4 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 testcases/config.regtest-no-lookahead.h diff --git a/Makefile-common b/Makefile-common index d14b24b..a0a32f2 100644 --- a/Makefile-common +++ b/Makefile-common @@ -158,6 +158,9 @@ regressiontests: # Config scenario: no endstops defined $(MAKE) -f Makefile-AVR USER_CONFIG=testcases/config.regtest-no-endstops.h \ MCU=atmega644 F_CPU=20000000UL EXTRA_CFLAGS=-Werror all + # Config scenario: ACCELERATION_RAMPING without LOOKAHEAD + $(MAKE) -f Makefile-AVR USER_CONFIG=testcases/config.regtest-no-lookahead.h \ + MCU=atmega644 F_CPU=20000000UL EXTRA_CFLAGS=-Werror all # Don't forget the hostside simulator. $(MAKE) -f Makefile-SIM USER_CONFIG=testcases/config.regtest-gen7-avr.h \ MCU=atmega644 F_CPU=20000000UL EXTRA_CFLAGS=-Werror all diff --git a/dda.c b/dda.c index 8514e2e..7d58724 100644 --- a/dda.c +++ b/dda.c @@ -154,9 +154,11 @@ void dda_create(DDA *dda, const TARGET *target) { axes_int32_t steps; uint32_t distance, c_limit, c_limit_calc; enum axis_e i; - #ifdef LOOKAHEAD + #ifdef ACCELERATION_RAMPING // Number the moves to identify them; allowed to overflow. static uint8_t idcnt = 0; + #endif + #ifdef LOOKAHEAD static DDA* prev_dda = NULL; if (prev_dda && prev_dda->done) @@ -184,6 +186,8 @@ void dda_create(DDA *dda, const TARGET *target) { dda->crossF = 0; dda->start_steps = 0; dda->end_steps = 0; + #endif + #ifdef ACCELERATION_RAMPING // Give this move an identifier. dda->id = idcnt++; #endif diff --git a/dda.h b/dda.h index 51ab484..2f07d91 100644 --- a/dda.h +++ b/dda.h @@ -134,11 +134,11 @@ typedef struct { // These two are based on the "fast" axis, the axis with the most steps. uint32_t start_steps; ///< would be required to reach start feedrate uint32_t end_steps; ///< would be required to stop from end feedrate + #endif // Number the moves to be able to test at the end of lookahead if the moves // are the same. Note: we do not need a lot of granularity here: more than // MOVEBUFFER_SIZE is already enough. uint8_t id; - #endif #endif #ifdef ACCELERATION_TEMPORAL axes_uint32_t step_interval; ///< time between steps on each axis diff --git a/testcases/config.regtest-no-lookahead.h b/testcases/config.regtest-no-lookahead.h new file mode 100644 index 0000000..ed5322d --- /dev/null +++ b/testcases/config.regtest-no-lookahead.h @@ -0,0 +1,7 @@ + +// Configuration for controller board. +#include "../config/board.gen7-v1.4.h" + +// Configuration for printer board. +#include "../config/printer.wolfstrap.h" +#undef LOOKAHEAD