From 61987c7b5b41fab2ebc92ae8037262fd68c1b424 Mon Sep 17 00:00:00 2001 From: bdring Date: Thu, 14 Nov 2024 19:33:59 -0600 Subject: [PATCH] Got rid of gc_state.tool It is now .selected_tool --- FluidNC/src/Channel.cpp | 4 ++-- FluidNC/src/GCode.cpp | 8 ++------ FluidNC/src/GCode.h | 2 +- FluidNC/src/Parameters.cpp | 2 +- FluidNC/src/ToolChangers/atc_manual.cpp | 2 +- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/FluidNC/src/Channel.cpp b/FluidNC/src/Channel.cpp index 50b8bda4c..1d626beda 100644 --- a/FluidNC/src/Channel.cpp +++ b/FluidNC/src/Channel.cpp @@ -93,11 +93,11 @@ void Channel::autoReportGCodeState() { // Force the compare to succeed if the only change is the motion mode _lastModal.motion = gc_state.modal.motion; } - if (memcmp(&_lastModal, &gc_state.modal, sizeof(_lastModal)) || _lastTool != gc_state.tool || + if (memcmp(&_lastModal, &gc_state.modal, sizeof(_lastModal)) || _lastTool != gc_state.selected_tool || (!motionState() && (_lastSpindleSpeed != gc_state.spindle_speed || _lastFeedRate != gc_state.feed_rate))) { report_gcode_modes(*this); memcpy(&_lastModal, &gc_state.modal, sizeof(_lastModal)); - _lastTool = gc_state.tool; + _lastTool = gc_state.selected_tool; _lastSpindleSpeed = gc_state.spindle_speed; _lastFeedRate = gc_state.feed_rate; } diff --git a/FluidNC/src/GCode.cpp b/FluidNC/src/GCode.cpp index 11da1b724..17e6e3bc0 100644 --- a/FluidNC/src/GCode.cpp +++ b/FluidNC/src/GCode.cpp @@ -1605,10 +1605,9 @@ Error gc_execute_line(char* line) { pl_data->spindle_speed = gc_state.spindle_speed; // Record data for planner use. } // else { pl_data->spindle_speed = 0.0; } // Initialized as zero already. // [5. Select tool ]: NOT SUPPORTED. Only tracks tool value. - // gc_state.tool = gc_block.values.t; // [M6. Change tool ]: if (gc_block.modal.tool_change == ToolChange::Enable) { - if (gc_state.selected_tool != gc_state.tool) { + if (gc_state.selected_tool != gc_state.current_tool) { bool stopped_spindle = false; // was spindle stopped via the change bool new_spindle = false; // was the spindle changed protocol_buffer_synchronize(); // wait for motion in buffer to finish @@ -1621,16 +1620,13 @@ Error gc_execute_line(char* line) { gc_state.spindle_speed = 0.0; } spindle->tool_change(gc_state.selected_tool, false, false); - gc_state.tool = gc_state.selected_tool; - gc_state.current_tool = gc_state.tool; + gc_state.current_tool = gc_state.selected_tool; report_ovr_counter = 0; // Set to report change immediately gc_ovr_changed(); } } if (gc_block.modal.set_tool_number == SetToolNumber::Enable) { gc_state.selected_tool = gc_block.values.q; - gc_state.tool = gc_state.selected_tool; - bool stopped_spindle = false; // was spindle stopped via the change bool new_spindle = false; // was the spindle changed protocol_buffer_synchronize(); // wait for motion in buffer to finish diff --git a/FluidNC/src/GCode.h b/FluidNC/src/GCode.h index 799d71eaf..f21acc4fe 100644 --- a/FluidNC/src/GCode.h +++ b/FluidNC/src/GCode.h @@ -300,7 +300,7 @@ struct parser_state_t { float spindle_speed; // RPM float feed_rate; // Millimeters/min - uint32_t tool; // Tracks tool number + //uint32_t tool; // Tracks tool number uint32_t selected_tool; // tool from T value int32_t current_tool; // the tool in use. default is -1 int32_t line_number; // Last line number sent diff --git a/FluidNC/src/Parameters.cpp b/FluidNC/src/Parameters.cpp index a5d85a6b3..4b7e74610 100644 --- a/FluidNC/src/Parameters.cpp +++ b/FluidNC/src/Parameters.cpp @@ -162,7 +162,7 @@ bool get_numbered_param(ngc_param_id_t id, float& result) { return true; } if (id == 5400) { - result = static_cast(gc_state.tool); + result = static_cast(gc_state.selected_tool); return true; } diff --git a/FluidNC/src/ToolChangers/atc_manual.cpp b/FluidNC/src/ToolChangers/atc_manual.cpp index fc3a3e9db..21d0938c8 100644 --- a/FluidNC/src/ToolChangers/atc_manual.cpp +++ b/FluidNC/src/ToolChangers/atc_manual.cpp @@ -161,7 +161,7 @@ namespace ATCs { void Manual_ATC::reset() { _is_OK = true; _have_tool_setter_offset = false; - _prev_tool = gc_state.tool; // Double check this + _prev_tool = gc_state.selected_tool; // Double check this _macro.addf("G43.1Z0"); // reset the TLO to 0 _macro.addf("(MSG: TLO Z reset to 0)"); // }