diff --git a/config.h b/config.h index dbf37e3..ddaddcb 100644 --- a/config.h +++ b/config.h @@ -28,6 +28,10 @@ #ifndef config_h #define config_h +// Allows GRBL to tranck and report gcode line numbers. Enabling this means that the planning buffer +// goes from 18 or 16 to make room for the additional line number data in the plan_block_t struct +#define USE_LINE_NUMBERS + // Default settings. Used when resetting EEPROM. Change to desired name in defaults.h #define DEFAULTS_SHERLINE_5400 diff --git a/planner.c b/planner.c index f167522..dfc56db 100644 --- a/planner.c +++ b/planner.c @@ -280,8 +280,9 @@ void plan_buffer_line(float *target, float feed_rate, uint8_t invert_feed_rate, block->millimeters = 0; block->direction_bits = 0; block->acceleration = SOME_LARGE_VALUE; // Scaled down to maximum acceleration later +#ifdef USE_LINE_NUMBERS block->line_number = line_number; - +#endif // Compute and store initial move distance data. // TODO: After this for-loop, we don't touch the stepper algorithm data. Might be a good idea // to try to keep these types of things completely separate from the planner for portability. diff --git a/planner.h b/planner.h index e7ae716..7a255be 100644 --- a/planner.h +++ b/planner.h @@ -26,7 +26,11 @@ // The number of linear motions that can be in the plan at any give time #ifndef BLOCK_BUFFER_SIZE - #define BLOCK_BUFFER_SIZE 16 + #ifdef USE_LINE_NUMBERS + #define BLOCK_BUFFER_SIZE 16 + #else + #define BLOCK_BUFFER_SIZE 18 + #endif #endif // This struct stores a linear movement of a g-code block motion with its critical "nominal" values @@ -47,7 +51,9 @@ typedef struct { float acceleration; // Axis-limit adjusted line acceleration in (mm/min^2) float millimeters; // The remaining distance for this block to be executed in (mm) // uint8_t max_override; // Maximum override value based on axis speed limits +#ifdef USE_LINE_NUMBERS uint32_t line_number; +#endif } plan_block_t; diff --git a/report.c b/report.c index d62ed49..5b97dc1 100644 --- a/report.c +++ b/report.c @@ -350,6 +350,7 @@ void report_realtime_status() if (i < (N_AXIS-1)) { printPgmString(PSTR(",")); } } +#ifdef USE_LINE_NUMBERS // Report current line number printPgmString(PSTR(",")); printPgmString(PSTR("Ln:")); @@ -359,7 +360,7 @@ void report_realtime_status() ln = pb->line_number; } printInteger(ln); - +#endif printPgmString(PSTR(">\r\n")); }