From 427fe4d15412290fdc089a56862a1d6cb3f1c5eb Mon Sep 17 00:00:00 2001 From: Denis Vygovskiy Date: Tue, 2 Apr 2019 13:55:46 +1000 Subject: [PATCH] Do not clear G43.1 and G92 on soft-reset --- grbl/gcode.c | 3 ++- grbl/gcode.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/grbl/gcode.c b/grbl/gcode.c index 57e31e5..905a792 100644 --- a/grbl/gcode.c +++ b/grbl/gcode.c @@ -20,6 +20,7 @@ */ #include "grbl.h" +#include // NOTE: Max line number is defined by the g-code standard to be 99999. It seems to be an // arbitrary value, and some GUIs may require more. So we increased it based on a max safe @@ -41,7 +42,7 @@ parser_block_t gc_block; void gc_init() { - memset(&gc_state, 0, sizeof(parser_state_t)); + memset(&gc_state, 0, offsetof(parser_state_t, coord_offset)); // Load default G54 coordinate system. if (!(settings_read_coord_data(gc_state.modal.coord_select,gc_state.coord_system))) { diff --git a/grbl/gcode.h b/grbl/gcode.h index 6cdc61b..7706c71 100644 --- a/grbl/gcode.h +++ b/grbl/gcode.h @@ -222,6 +222,8 @@ typedef struct { float coord_system[N_AXIS]; // Current work coordinate system (G54+). Stores offset from absolute machine // position in mm. Loaded from EEPROM when called. + + // coord_offset and all following members retain their values during soft-resets float coord_offset[N_AXIS]; // Retains the G92 coordinate offset (work coordinates) relative to // machine zero in mm. Non-persistent. Cleared upon reset and boot. float tool_length_offset; // Tracks tool length offset value when enabled.