mirror of
https://github.com/grblHAL/core.git
synced 2026-02-05 16:50:16 +08:00
Added experimental support for M70-M73, save and restore of modal state.
Added experimental support of LinuxCNC style subroutines. Available for gcode run from local filesystem such as on a SD card or in littlefs. Improved handling of G92 when G92 offset is changed while motion is ongoing. Ref. issue #241. Fix for issue #521, crash when running G65 macro on ESP32. "Hardened" stream switching code, likely fix for discussion #456.
This commit is contained in:
40
gcode.h
40
gcode.h
@@ -3,22 +3,22 @@
|
||||
|
||||
Part of grblHAL
|
||||
|
||||
Copyright (c) 2017-2023 Terje Io
|
||||
Copyright (c) 2017-2024 Terje Io
|
||||
Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC
|
||||
Copyright (c) 2009-2011 Simen Svale Skogsrud
|
||||
|
||||
Grbl is free software: you can redistribute it and/or modify
|
||||
grblHAL is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Grbl is distributed in the hope that it will be useful,
|
||||
grblHAL is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
||||
along with grblHAL. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _GCODE_H_
|
||||
@@ -29,8 +29,11 @@
|
||||
#include "spindle_control.h"
|
||||
#include "errors.h"
|
||||
|
||||
#define MAX_OFFSET_ENTRIES 4 // must be a power of 2
|
||||
|
||||
typedef uint32_t tool_id_t;
|
||||
typedef uint16_t macro_id_t;
|
||||
typedef int8_t offset_id_t;
|
||||
|
||||
// Define command actions for within execution-type modal groups (motion, stopping, non-modal). Used
|
||||
// internally by the parser to know which command to execute.
|
||||
@@ -59,6 +62,15 @@ typedef enum {
|
||||
NonModal_RestoreCoordinateOffset = 122 //!< 122 - G92.3
|
||||
} non_modal_t;
|
||||
|
||||
|
||||
typedef enum {
|
||||
ModalState_NoAction = 0, //!< 0 - Default, must be zero
|
||||
ModalState_Save = 70, //!< 70 - M70
|
||||
ModalState_Invalidate = 71, //!< 71 - M71
|
||||
ModalState_Restore = 72, //!< 72 - M72
|
||||
ModalState_SaveAutoRestore = 73, //!< 73 - M73
|
||||
} modal_state_action_t;
|
||||
|
||||
/*! Modal Group G1: Motion modes
|
||||
|
||||
Do not alter values!
|
||||
@@ -411,7 +423,7 @@ typedef struct {
|
||||
coord_system_t coord_data; //!< Coordinate data
|
||||
int32_t $; //!< Spindle id - single-meaning word
|
||||
int32_t n; //!< Line number - single-meaning word
|
||||
uint32_t o; //!< Subroutine identifier - single-meaning word (not used by the core)
|
||||
uint32_t o; //!< Subroutine identifier - single-meaning word
|
||||
uint32_t h; //!< Tool number or number of G76 thread spring passes
|
||||
tool_id_t t; //!< Tool selection - single-meaning word
|
||||
uint8_t l; //!< G10 or canned cycles parameters
|
||||
@@ -493,6 +505,11 @@ typedef struct {
|
||||
bool scaling_active; //!< {G50,G51}
|
||||
bool canned_cycle_active;
|
||||
float spline_pq[2]; //!< {G5}
|
||||
#if NGC_PARAMETERS_ENABLE
|
||||
bool auto_restore;
|
||||
float feed_rate; //!< {F} NOTE: only set when saving modal state
|
||||
float rpm; //!< {S} NOTE: only set when saving modal state
|
||||
#endif
|
||||
} gc_modal_t;
|
||||
|
||||
//! Data for canned cycles.
|
||||
@@ -570,6 +587,8 @@ typedef struct {
|
||||
bool tool_change;
|
||||
bool skip_blocks; //!< true if skipping conditional blocks
|
||||
status_code_t last_error; //!< last return value from parser
|
||||
offset_id_t offset_id; //!< id(x) of last G92 coordinate offset (into circular buffer)
|
||||
coord_data_t offset_queue[MAX_OFFSET_ENTRIES];
|
||||
//!< The following variables are not cleared upon warm restart when COMPATIBILITY_LEVEL <= 1
|
||||
bool g92_coord_offset_applied; //!< true when G92 offset applied
|
||||
float g92_coord_offset[N_AXIS]; //!< Retains the G92 coordinate offset (work coordinates) relative to
|
||||
@@ -602,6 +621,9 @@ typedef struct {
|
||||
output_command_t output_command; //!< Details about M62-M68 output command to execute if present in block.
|
||||
uint32_t arc_turns; //
|
||||
spindle_ptrs_t *spindle; //!< Spindle to control, NULL for all
|
||||
#if NGC_PARAMETERS_ENABLE
|
||||
modal_state_action_t state_action; //!< M70-M73 modal state action
|
||||
#endif
|
||||
} parser_block_t;
|
||||
|
||||
// Initialize the parser
|
||||
@@ -629,7 +651,7 @@ axes_signals_t gc_get_g51_state (void);
|
||||
float *gc_get_scaling (void);
|
||||
|
||||
// Get current axis offset.
|
||||
float gc_get_offset (uint_fast8_t idx);
|
||||
float gc_get_offset (uint_fast8_t idx, bool real_time);
|
||||
|
||||
spindle_ptrs_t *gc_spindle_get (void);
|
||||
|
||||
@@ -639,4 +661,8 @@ void gc_coolant (coolant_state_t state);
|
||||
void gc_set_tool_offset (tool_offset_mode_t mode, uint_fast8_t idx, int32_t offset);
|
||||
plane_t *gc_get_plane_data (plane_t *plane, plane_select_t select);
|
||||
|
||||
#if NGC_PARAMETERS_ENABLE
|
||||
bool gc_modal_state_restore (gc_modal_t *copy);
|
||||
#endif
|
||||
|
||||
#endif // _GCODE_H_
|
||||
|
||||
Reference in New Issue
Block a user