Skip to content

Commit

Permalink
Got rid of gc_state.tool
Browse files Browse the repository at this point in the history
It is now .selected_tool
  • Loading branch information
bdring committed Nov 15, 2024
1 parent 00f365c commit 61987c7
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 11 deletions.
4 changes: 2 additions & 2 deletions FluidNC/src/Channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 2 additions & 6 deletions FluidNC/src/GCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion FluidNC/src/GCode.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion FluidNC/src/Parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ bool get_numbered_param(ngc_param_id_t id, float& result) {
return true;
}
if (id == 5400) {
result = static_cast<float>(gc_state.tool);
result = static_cast<float>(gc_state.selected_tool);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion FluidNC/src/ToolChangers/atc_manual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)"); //
}
Expand Down

0 comments on commit 61987c7

Please sign in to comment.