grblHAL core  20260225
gcode.h
Go to the documentation of this file.
1 /*
2  gcode.h - rs274/ngc parser.
3 
4  Part of grblHAL
5 
6  Copyright (c) 2017-2026 Terje Io
7  Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC
8  Copyright (c) 2009-2011 Simen Svale Skogsrud
9 
10  grblHAL is free software: you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  grblHAL is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with grblHAL. If not, see <http://www.gnu.org/licenses/>.
22 */
23 
24 #ifndef _GCODE_H_
25 #define _GCODE_H_
26 
27 #include "nuts_bolts.h"
28 #include "coolant_control.h"
29 #include "spindle_control.h"
30 #include "errors.h"
31 #include "vfs.h"
32 
33 #define MAX_OFFSET_ENTRIES 4 // must be a power of 2
34 
35 typedef int32_t tool_id_t;
36 typedef int16_t pocket_id_t;
37 typedef uint16_t macro_id_t;
38 typedef int8_t offset_id_t;
39 
40 // Define command actions for within execution-type modal groups (motion, stopping, non-modal). Used
41 // internally by the parser to know which command to execute.
42 // NOTE: Some values are assigned specific values to make g-code state reporting and parsing
43 // compile a little smaller. Although not
44 // ideal, just be careful with values that state 'do not alter' and check both report.c and gcode.c
45 // to see how they are used, if you need to alter them.
46 
51 typedef enum {
63  #if ENABLE_ACCELERATION_PROFILES
65  NonModal_SetAccelerationProfile = 187
66  #else
68  #endif
70 
71 typedef enum {
76 
77 typedef enum {
83 } macro_call_t;
84 
85 typedef enum {
92 
97 typedef enum {
119  MotionMode_None = 80
121 
126 typedef enum {
129  PlaneSelect_YZ = 2
131 
132 // Modal Group G4: Arc IJK distance mode
133 //#define DISTANCE_ARC_MODE_INCREMENTAL 0 // G91.1 - Default, must be zero
134 
135 
140 typedef enum {
145 
146 // Modal Group G7: Cutter radius compensation mode
147 typedef enum {
148  CComp_Off = 0,
150  CComp_Right
152 
157 typedef enum {
163 
168 typedef enum {
170  CCRetractMode_RPos = 1
172 
173 
179 typedef enum {
186 #if COMPATIBILITY_LEVEL <= 1
190 #endif
196 } __attribute__ ((__packed__)) coord_system_id_t;
197 
198 
203 typedef enum {
208 
213 typedef enum {
223 
224 // Modal Group M9: Override control
225 typedef enum {
231  Override_Parking = 56
233 
236 typedef enum {
244 } io_mcode_t;
245 
249 typedef enum {
255  Fan_On = 106,
256  Fan_Off = 107,
271  OpenPNP_SetJerk = 20130,
277  Probe_Deploy = 401,
278  Probe_Stow = 402,
300 
302 typedef struct output_command {
304  uint8_t port;
305  int32_t value;
308 
310 typedef enum {
316  WaitMode_Max
318 
320 typedef enum {
325 
330 typedef enum {
335  #if SET_CHECK_MODE_PROBE_TO_START
337  #else
339  #endif
341 
342 typedef struct {
345  float radius;
346 } gc_ccomp_t;
347 
349 typedef union {
350  uint16_t value;
351  struct {
352  uint16_t jog_motion :1,
353  canned_cycle_change :1, // Use motion_mode_changed?
363  };
365 
367 typedef union {
368  uint16_t value;
369  struct {
370  uint16_t spindle_rpm_disable :8,
376  sync :1;
377  };
378  struct {
379  uint16_t spindle_rpm :8,
385  reserved2 :1; // sync synonym
386  };
388 
390 typedef struct {
394 
402 typedef struct {
403  float d;
404  float e;
405  float f;
406  float h;
407  float ijk[3];
408  float k;
409  float m;
410  float p;
411  float q;
412  float r;
413  float s;
414  float t;
415 #ifndef A_AXIS
416  float a;
417 #endif
418 #ifndef B_AXIS
419  float b;
420 #endif
421 #ifndef C_AXIS
422  float c;
423 #endif
424 #ifndef U_AXIS
425  float u;
426 #endif
427 #ifndef V_AXIS
428  float v;
429 #endif
430 #ifndef W_AXIS
431  float w;
432 #endif
433  float xyz[N_AXIS];
434 #if LATHE_UVW_OPTION
435  float uvw[3];
436 #endif
437  int32_t $;
438  int32_t n;
439  uint32_t o;
440  uint32_t l;
441 } gc_values_t;
442 
444 typedef union {
445  uint32_t mask;
446  uint32_t value;
447  struct {
448  uint32_t $ :1,
449  a :1,
450  b :1,
451  c :1,
452  i :1,
453  j :1,
454  k :1,
455  d :1,
456  e :1,
457  f :1,
458  g :1,
459  h :1,
460  l :1,
461  m :1,
462  n :1,
463  o :1,
464  p :1,
465  q :1,
466  r :1,
467  s :1,
468  t :1,
469  u :1,
470  v :1,
471  w :1,
472  x :1,
473  y :1,
474  z :1;
475  };
477 
478 typedef union {
479  uint8_t value;
480  struct {
484 
485  };
487 
488 typedef struct {
493  float rpm;
495 } spindle_t;
496 
497 typedef struct {
501 
502 // NOTE: When this struct is zeroed, the above defines set the defaults for the system.
503 typedef struct {
509  //< uint8_t distance_arc; //!< {G91.1} NOTE: Don't track. Only default supported.
511  //< gc_ccomp_t cutter_comp; //!< {G40,G41,G41.1,G42,G42.1} NOTE: Don't track. Only default (G40) supported.
514 #if ENABLE_PATH_BLENDING
515  control_mode_t control;
516 #endif
524 #if ENABLE_ACCELERATION_PROFILES
525  float acceleration_factor;
526 #endif
527  float spline_pq[2];
529 
531  float tool_length_offset[N_AXIS];
532 #if NGC_PARAMETERS_ENABLE
533  float feed_rate;
535 #endif
536 } gc_modal_t;
537 
538 typedef struct {
541  override_t spindle_rpm[N_SYS_SPINDLE];
543 
545 typedef struct {
549 
551 typedef struct {
552  float xyz[3];
553  float delta;
554  float dwell;
559  bool change;
560 } gc_canned_t;
561 
563 typedef enum {
567  Taper_Both
569 
570 typedef struct {
571  float pitch;
572  float z_final;
573  float peak;
575  float depth;
581  uint_fast16_t spring_passes;
584 
586 typedef struct {
588  float radius;
590 } tool_data_t;
591 
593 typedef struct {
594  const char *name;
598 
599 typedef struct {
602  char name[101];
603 } tool_pocket_t;
604 
605 typedef struct {
606  float angle;
608 } rotation_t;
609 
610 #if NGC_PARAMETERS_ENABLE
611 
612 typedef struct g66_arguments
613 {
615  uint32_t call_level;
620 
621 #endif
622 
626 typedef struct {
630  float feed_rate;
632  float position[N_AXIS];
633 #if ENABLE_PATH_BLENDING
634  float path_tolerance;
635  float cam_tolerance;
636 #endif
637  uint32_t line_number;
639 #if NGC_EXPRESSIONS_ENABLE
640  tool_id_t g43_pending;
641 #endif
642  bool file_run;
643  bool file_stream;
647  bool skip_blocks;
657 #if NGC_PARAMETERS_ENABLE
659 #endif
661 
662 typedef struct {
663  float xyz[N_AXIS];
664  float ijk[N_AXIS];
666 
667 extern parser_state_t gc_state;
668 
674 typedef struct {
685  uint32_t arc_turns; //
687 #if NGC_PARAMETERS_ENABLE
690 #endif
691 #if N_AXIS > 3
692  axes_signals_t rotary_wrap;
693 #endif
695 
696 
697 static inline axes_signals_t gc_paramwords_to_axes (parameter_words_t p_words)
698 {
699 #if N_AXIS == 3
700  return (axes_signals_t){ (uint8_t)(p_words.mask >> 24) };
701 #elif N_AXIS == 7
702  return (axes_signals_t){ (uint8_t)(((p_words.mask >> 24) | ((p_words.mask << 2) & 0b00111000) | ((p_words.mask >> (21 - 6)) & 0b11000000)) & AXES_BITMASK) };
703 #else
704  axes_signals_t axes = (axes_signals_t){ (uint8_t)(p_words.mask >> 24) };
705 
706  #ifdef A_AXIS
707  axes.a = p_words.a;
708  #endif
709  #ifdef B_AXIS
710  axes.b = p_words.b;
711  #endif
712  #ifdef C_AXIS
713  axes.c = p_words.c;
714  #endif
715  #ifdef U_AXIS
716  axes.u = p_words.u;
717  #endif
718  #ifdef V_AXIS
719  axes.v = p_words.v;
720  #endif
721  #ifdef W_AXIS
722  axes.w = p_words.w;
723  #endif
724 
725  return axes;
726 #endif
727 }
728 
729 // Initialize the parser
730 void gc_init (bool stop);
731 
732 char *gc_normalize_block (char *block, status_code_t *status, char **message);
733 
734 // Execute one block of rs275/ngc/g-code
735 status_code_t gc_execute_block (char *block);
736 
737 // Sets g-code parser position in mm. Input in steps. Called by the system abort and hard
738 // limit pull-off routines.
739 #define gc_sync_position() system_convert_array_steps_to_mpos (gc_state.position, sys.position)
740 
741 // Sets g-code parser and planner position in mm.
742 #define sync_position() plan_sync_position(); system_convert_array_steps_to_mpos (gc_state.position, sys.position)
743 
744 // Set dynamic laser power mode to PPI (Pulses Per Inch)
745 // Driver support for pulsing the laser on signal is required for this to work.
746 // Returns true if driver uses hardware implementation.
747 bool gc_laser_ppi_enable (uint_fast16_t ppi, uint_fast16_t pulse_length);
749 // Gets axes scaling state.
751 float *gc_get_scaling (void);
752 
753 // Get current axis offset.
754 float gc_get_offset (uint_fast8_t idx, bool real_time);
755 
757 
759 
761 
762 void gc_spindle_off (void);
763 void gc_coolant (coolant_state_t state);
764 
765 void gc_set_tool_offset (tool_offset_mode_t mode, uint_fast8_t idx, int32_t offset);
768 size_t gc_macro_get_pos (macro_id_t id, vfs_file_t *file);
769 
770 #if NGC_PARAMETERS_ENABLE
773 #endif
774 
775 #if ENABLE_ACCELERATION_PROFILES
776 float gc_get_accel_factor (uint8_t profile);
777 #endif
778 
779 #endif // _GCODE_H_
#define N_SYS_SPINDLE
Defines number of simultaneously active spindles supported - minimum 1 (none), maximum 8.
Definition: config.h:65
#define N_AXIS
Defines number of axes supported - minimum 3, maximum 8. If more than 3 axes are configured a complia...
Definition: config.h:42
status_code_t
Definition: errors.h:31
override_mode_t
Definition: gcode.h:225
@ Override_FeedRate
50 - M50
Definition: gcode.h:228
@ Override_FeedHold
53 - M53
Definition: gcode.h:230
@ Override_FeedSpeedDisable
49 - M49
Definition: gcode.h:227
@ Override_SpindleSpeed
51 - M51
Definition: gcode.h:229
@ Override_Parking
56 - M56
Definition: gcode.h:231
@ Override_FeedSpeedEnable
48 - M48
Definition: gcode.h:226
modal_state_action_t
Definition: gcode.h:85
@ ModalState_Save
70 - M70
Definition: gcode.h:87
@ ModalState_Invalidate
71 - M71
Definition: gcode.h:88
@ ModalState_NoAction
0 - Default, must be zero
Definition: gcode.h:86
@ ModalState_SaveAutoRestore
73 - M73
Definition: gcode.h:90
@ ModalState_Restore
72 - M72
Definition: gcode.h:89
char * gc_normalize_block(char *block, status_code_t *status, char **message)
Definition: gcode.c:970
int32_t tool_id_t
Definition: gcode.h:35
feed_mode_t
Definition: gcode.h:140
@ FeedMode_InverseTime
1 - G93
Definition: gcode.h:142
@ FeedMode_UnitsPerRev
2 - G95
Definition: gcode.h:143
@ FeedMode_UnitsPerMin
0 - G94 - Default, must be zero
Definition: gcode.h:141
#define MAX_OFFSET_ENTRIES
Definition: gcode.h:33
int8_t offset_id_t
Definition: gcode.h:38
tool_offset_mode_t
Definition: gcode.h:157
@ ToolLengthOffset_EnableDynamic
2 - G43.1
Definition: gcode.h:160
@ ToolLengthOffset_Cancel
0 - G49 - Default, must be zero
Definition: gcode.h:158
@ ToolLengthOffset_Enable
1 - G43
Definition: gcode.h:159
@ ToolLengthOffset_ApplyAdditional
3 - G43.2
Definition: gcode.h:161
plane_t * gc_get_plane_data(plane_t *plane, plane_select_t select)
Definition: gcode.c:331
void gc_init(bool stop)
Definition: gcode.c:721
motion_mode_t
Definition: gcode.h:97
@ MotionMode_RigidTapping
331 - G33.1
Definition: gcode.h:105
@ MotionMode_DrillChipBreak
73 - G73
Definition: gcode.h:106
@ MotionMode_CannedCycle84
83 - G84, right hand tapping - experimental
Definition: gcode.h:111
@ MotionMode_CannedCycle82
82 - G82, drill with dwell
Definition: gcode.h:109
@ MotionMode_CannedCycle83
83 - G83, peck drill
Definition: gcode.h:110
@ MotionMode_CannedCycle89
89 - G89, not implemented
Definition: gcode.h:114
@ MotionMode_CcwArc
3 - G3
Definition: gcode.h:101
@ MotionMode_Seek
0 - G0 - Default, must be zero
Definition: gcode.h:98
@ MotionMode_ProbeToward
140 - G38.2
Definition: gcode.h:115
@ MotionMode_SpindleSynchronized
33 - G33
Definition: gcode.h:104
@ MotionMode_CubicSpline
5 - G5
Definition: gcode.h:102
@ MotionMode_CwArc
2 - G2
Definition: gcode.h:100
@ MotionMode_ProbeAway
142 - G38.4
Definition: gcode.h:117
@ MotionMode_Linear
1 - G1
Definition: gcode.h:99
@ MotionMode_ProbeTowardNoError
141 - G38.3
Definition: gcode.h:116
@ MotionMode_Threading
76 - G76
Definition: gcode.h:107
@ MotionMode_QuadraticSpline
51 - G5.1
Definition: gcode.h:103
@ MotionMode_CannedCycle86
86 - G86, not implemented
Definition: gcode.h:113
@ MotionMode_CannedCycle85
85 - G85, not implemented
Definition: gcode.h:112
@ MotionMode_CannedCycle81
81 - G81, drill
Definition: gcode.h:108
@ MotionMode_None
80 - G80
Definition: gcode.h:119
@ MotionMode_ProbeAwayNoError
143 - G38.5
Definition: gcode.h:118
io_mcode_t
Definition: gcode.h:236
@ IoMCode_OutputOffSynced
63 - M63
Definition: gcode.h:238
@ IoMCode_WaitOnInput
66 - M66
Definition: gcode.h:241
@ IoMCode_OutputOnSynced
62 - M62
Definition: gcode.h:237
@ IoMCode_AnalogOutSynced
67 - M67
Definition: gcode.h:242
@ IoMCode_AnalogOutImmediate
68 - M68
Definition: gcode.h:243
@ IoMCode_OutputOnImmediate
64 - M64
Definition: gcode.h:239
@ IoMCode_OutputOffImmediate
65 - M65
Definition: gcode.h:240
struct output_command output_command_t
Data for M62, M63 and M67 commands when executed synchronized with motion.
parameter_words_t gc_get_g65_arguments(void)
non_modal_t
Definition: gcode.h:51
@ NonModal_SetHome_1
40 - G30.1
Definition: gcode.h:58
@ NonModal_SetCoordinateOffset
92 - G92
Definition: gcode.h:60
@ NonModal_SetHome_0
38 - G28.1
Definition: gcode.h:56
@ NonModal_AbsoluteOverride
53 - G53
Definition: gcode.h:59
@ NonModal_Dwell
4 - G4
Definition: gcode.h:53
@ NonModal_NoAction
0 - Default, must be zero
Definition: gcode.h:52
@ NonModal_RestoreCoordinateOffset
122 - G92.3
Definition: gcode.h:67
@ NonModal_GoHome_1
30 - G30
Definition: gcode.h:57
@ NonModal_ResetCoordinateOffset
102 - G92.1
Definition: gcode.h:61
@ NonModal_ClearCoordinateOffset
112 - G92.2
Definition: gcode.h:62
@ NonModal_Settings
10 - G10
Definition: gcode.h:54
@ NonModal_GoHome_0
28 - G28
Definition: gcode.h:55
tool_action_t
Definition: gcode.h:71
@ ToolAction_Set
61 - M61
Definition: gcode.h:74
@ ToolAction_Change
6 - M6
Definition: gcode.h:73
@ ToolAction_None
0 - Default, must be zero
Definition: gcode.h:72
pos_update_t
Parser position updating flags.
Definition: gcode.h:320
@ GCUpdatePos_None
2
Definition: gcode.h:323
@ GCUpdatePos_System
1
Definition: gcode.h:322
@ GCUpdatePos_Target
0
Definition: gcode.h:321
size_t gc_macro_get_pos(macro_id_t id, vfs_file_t *file)
Definition: gcode.c:630
bool gc_modal_state_restore(gc_modal_snapshot_t *snapshot)
Definition: gcode.c:578
spindle_t * gc_spindle_get(spindle_num_t spindle)
Definition: gcode.c:825
user_mcode_t
Definition: gcode.h:249
@ Trinamic_ModeToggle
569 - M569, Marlin format
Definition: gcode.h:280
@ Plasma_SelectMaterial
150 - M190, LinuxCNC format
Definition: gcode.h:270
@ Macro_Execute6
816 - M816, Marlin format
Definition: gcode.h:287
@ RGB_WriteLEDs
150 - M150, Marlin format
Definition: gcode.h:269
@ LaserPPI_Enable
126 - M126
Definition: gcode.h:262
@ OpenPNP_FinishMoves
400 - M400
Definition: gcode.h:276
@ OpenPNP_GetADCScaled
144 - M144
Definition: gcode.h:267
@ OpenPNP_GetCurrentPosition
114 - M114
Definition: gcode.h:257
@ Macro_Execute2
812 - M812, Marlin format
Definition: gcode.h:283
@ UserMCode_Generic1
101 - For private use only
Definition: gcode.h:251
@ UserMCode_Generic4
104 - For private use only
Definition: gcode.h:254
@ UserMCode_Generic2
102 - For private use only
Definition: gcode.h:252
@ SetFeedOverrides
220 - M220, Marlin format
Definition: gcode.h:273
@ OpenPNP_SettingsReset
502 - M502
Definition: gcode.h:279
@ OpenPNP_GetPinState
143 - M143
Definition: gcode.h:266
@ Trinamic_ChopperTiming
919 - M919, Marlin format
Definition: gcode.h:296
@ OpenPNP_FirmwareInfo
115 - M115
Definition: gcode.h:258
@ Laser_Overdrive
129 - M129
Definition: gcode.h:265
@ UserMCode_Generic3
103 - For private use only
Definition: gcode.h:253
@ OpenPNP_SetADCScaling
145 - M145
Definition: gcode.h:268
@ PWMServo_SetPosition
280 - M280, Marlin format
Definition: gcode.h:274
@ LaserPPI_PulseLength
128 - M128
Definition: gcode.h:264
@ Trinamic_StepperCurrent
906 - M906, Marlin format
Definition: gcode.h:291
@ Trinamic_ReportPrewarnFlags
911 - M911, Marlin format
Definition: gcode.h:292
@ Macro_Execute9
819 - M819, Marlin format
Definition: gcode.h:290
@ Sienci_Atci_Enable
960 - M960
Definition: gcode.h:297
@ Macro_Execute3
813 - M813, Marlin format
Definition: gcode.h:284
@ Macro_Execute1
811 - M811, Marlin format
Definition: gcode.h:282
@ Trinamic_HomingSensitivity
914 - M914, Marlin format
Definition: gcode.h:295
@ Probe_Deploy
401 - M401, Marlin format
Definition: gcode.h:277
@ Macro_Execute0
810 - M810, Marlin format
Definition: gcode.h:281
@ Probe_Stow
402 - M402, Marlin format
Definition: gcode.h:278
@ Macro_Execute8
818 - M818, Marlin format
Definition: gcode.h:289
@ Macro_Execute4
814 - M814, Marlin format
Definition: gcode.h:285
@ RGB_Inspection_Light
356 - M356
Definition: gcode.h:275
@ Fan_Off
107 - M107, Marlin format
Definition: gcode.h:256
@ Macro_Execute5
815 - M815, Marlin format
Definition: gcode.h:286
@ LaserPPI_Rate
127 - M127
Definition: gcode.h:263
@ Trinamic_DebugReport
122 - M122, Marlin format
Definition: gcode.h:259
@ OpenPNP_SetJerk
20130 - M201.3
Definition: gcode.h:271
@ Trinamic_HybridThreshold
913 - M913, Marlin format
Definition: gcode.h:294
@ Spindle_Select
Value to be assigned later!
Definition: gcode.h:298
@ OpenPNP_SetPinState
42 - M42
Definition: gcode.h:250
@ Macro_Execute7
817 - M817, Marlin format
Definition: gcode.h:288
@ Trinamic_ClearPrewarnFlags
912 - M912, Marlin format
Definition: gcode.h:293
@ Trinamic_ReadRegister
123 - M123
Definition: gcode.h:260
@ Fan_On
106 - M106, Marlin format
Definition: gcode.h:255
@ OpenPNP_SetAcceleration
204 - M204
Definition: gcode.h:272
@ Trinamic_WriteRegister
124 - M124
Definition: gcode.h:261
program_flow_t
Definition: gcode.h:213
@ ProgramFlow_EndPercent
255 - %
Definition: gcode.h:221
@ ProgramFlow_Running
0 - Default, must be zero
Definition: gcode.h:214
@ ProgramFlow_CompletedM60
60 - M60
Definition: gcode.h:219
@ ProgramFlow_OptionalStop
1 - M1
Definition: gcode.h:216
@ ProgramFlow_CompletedM2
2 - M2
Definition: gcode.h:217
@ ProgramFlow_Return
99 - M99
Definition: gcode.h:220
@ ProgramFlow_Paused
3 - M0
Definition: gcode.h:215
@ ProgramFlow_CompletedM30
30 - M30
Definition: gcode.h:218
uint16_t macro_id_t
Definition: gcode.h:37
gc_taper_type
Thread taper types.
Definition: gcode.h:563
@ Taper_None
0
Definition: gcode.h:564
@ Taper_Both
3
Definition: gcode.h:567
@ Taper_Exit
2
Definition: gcode.h:566
@ Taper_Entry
1
Definition: gcode.h:565
gc_probe_t
Definition: gcode.h:330
@ GCProbe_FailEnd
0
Definition: gcode.h:334
@ GCProbe_FailInit
2
Definition: gcode.h:333
@ GCProbe_CheckMode
0
Definition: gcode.h:338
@ GCProbe_Found
1
Definition: gcode.h:331
@ GCProbe_Abort
2
Definition: gcode.h:332
float * gc_get_scaling(void)
Definition: gcode.c:255
cc_retract_mode_t
Definition: gcode.h:168
@ CCRetractMode_Previous
0 - G98 - Default, must be zero
Definition: gcode.h:169
@ CCRetractMode_RPos
1 - G99
Definition: gcode.h:170
parser_state_t gc_state
Definition: gcode.c:127
ccomp_mode_t
Definition: gcode.h:147
@ CComp_Right
2 - G42, G42.1
Definition: gcode.h:150
@ CComp_Off
0 - G40 - Default, must be zero
Definition: gcode.h:148
@ CComp_Left
1 - G41, G41.1
Definition: gcode.h:149
int16_t pocket_id_t
Definition: gcode.h:36
control_mode_t
Definition: gcode.h:203
@ ControlMode_ExactStop
1 - G61.1
Definition: gcode.h:205
@ ControlMode_PathBlending
2 - G64
Definition: gcode.h:206
@ ControlMode_ExactPath
0 - G61 - Default, must be zero
Definition: gcode.h:204
char * gc_coord_system_to_str(coord_system_id_t id)
Definition: gcode.c:175
macro_call_t
Definition: gcode.h:77
@ MacroCall_NonModal98
98 - M98
Definition: gcode.h:82
@ MacroCall_Modal1
166 - G66.1
Definition: gcode.h:81
@ MacroCall_Modal
66 - G66
Definition: gcode.h:80
@ MacroCall_End
0 - Default, must be zero (G67)
Definition: gcode.h:78
@ MacroCall_NonModal
65 - G65
Definition: gcode.h:79
axes_signals_t gc_get_g51_state(void)
Definition: gcode.c:260
axes_signals_t gc_claim_axis_words(parser_block_t *gc_block, axes_signals_t validate)
Definition: gcode.c:356
void gc_coolant(coolant_state_t state)
Definition: gcode.c:845
void gc_clear_output_commands(output_command_t *cmd)
Definition: gcode.c:912
void gc_spindle_off(void)
Definition: gcode.c:834
coord_system_id_t
Definition: gcode.h:179
@ CoordinateSystem_G55
1 - G55 (G12)
Definition: gcode.h:181
@ CoordinateSystem_G28
9 - G28 (G0) when COMPATIBILITY_LEVEL <= 1, 6 otherwise
Definition: gcode.h:192
@ CoordinateSystem_G59_3
8 - G59.3 (G12) - availability depending on COMPATIBILITY_LEVEL <= 1
Definition: gcode.h:189
@ CoordinateSystem_G54
0 - G54 (G12)
Definition: gcode.h:180
@ N_WorkCoordinateSystems
9 when COMPATIBILITY_LEVEL <= 1, 6 otherwise
Definition: gcode.h:191
@ CoordinateSystem_G56
2 - G56 (G12)
Definition: gcode.h:182
@ CoordinateSystem_G92
11 - G92 (G0) when COMPATIBILITY_LEVEL <= 1, 8 otherwise
Definition: gcode.h:194
@ CoordinateSystem_G59
5 - G59 (G12)
Definition: gcode.h:185
@ CoordinateSystem_G57
3 - G57 (G12)
Definition: gcode.h:183
@ CoordinateSystem_G30
10 - G30 (G0) when COMPATIBILITY_LEVEL <= 1, 7 otherwise
Definition: gcode.h:193
@ CoordinateSystem_G59_2
7 - G59.2 (G12) - availability depending on COMPATIBILITY_LEVEL <= 1
Definition: gcode.h:188
@ CoordinateSystem_G59_1
6 - G59.1 (G12) - availability depending on COMPATIBILITY_LEVEL <= 1
Definition: gcode.h:187
@ CoordinateSystem_G58
4 - G58 (G12)
Definition: gcode.h:184
@ N_CoordinateSystems
12 when COMPATIBILITY_LEVEL <= 1, 9 otherwise
Definition: gcode.h:195
status_code_t gc_execute_block(char *block)
Definition: gcode.c:1054
struct g66_arguments g66_arguments_t
bool gc_laser_ppi_enable(uint_fast16_t ppi, uint_fast16_t pulse_length)
Definition: gcode.c:818
wait_mode_t
M66 Allowed L-parameter values.
Definition: gcode.h:310
@ WaitMode_High
3
Definition: gcode.h:314
@ WaitMode_Immediate
0 - This is the only mode allowed for analog inputs
Definition: gcode.h:311
@ WaitMode_Fall
2
Definition: gcode.h:313
@ WaitMode_Max
For internal use.
Definition: gcode.h:316
@ WaitMode_Low
4
Definition: gcode.h:315
@ WaitMode_Rise
1
Definition: gcode.h:312
void gc_set_tool_offset(tool_offset_mode_t mode, uint_fast8_t idx, int32_t offset)
Definition: gcode.c:292
float gc_get_offset(uint_fast8_t idx, bool real_time)
Definition: gcode.c:275
plane_select_t
Definition: gcode.h:126
@ PlaneSelect_YZ
2 - G19
Definition: gcode.h:129
@ PlaneSelect_ZX
1 - G18
Definition: gcode.h:128
@ PlaneSelect_XY
0 - G17 - Default, must be zero
Definition: gcode.h:127
parser_state_t * gc_get_state(void)
Definition: gcode.c:170
uint_fast16_t override_t
Definition: grbl.h:262
#define AXES_BITMASK
Definition: nuts_bolts.h:99
spindle_rpm_mode_t
Definition: spindle_control.h:134
int8_t spindle_num_t
Definition: spindle_control.h:56
Coordinate system data.
Definition: nuts_bolts.h:319
Coordinate data including id.
Definition: gcode.h:390
coord_system_data_t data
Definition: gcode.h:392
coord_system_id_t id
Definition: gcode.h:391
Definition: gcode.h:613
uint32_t call_level
Definition: gcode.h:615
gc_values_t values
Definition: gcode.h:616
struct g66_arguments * prev
Definition: gcode.h:618
parameter_words_t words
Definition: gcode.h:617
macro_call_t call
Definition: gcode.h:614
Data for canned cycles.
Definition: gcode.h:551
float dwell
Definition: gcode.h:554
cc_retract_mode_t retract_mode
Definition: gcode.h:558
float delta
Definition: gcode.h:553
bool spindle_off
Definition: gcode.h:557
bool change
Definition: gcode.h:559
float retract_position
Canned cycle retract position.
Definition: gcode.h:555
bool rapid_retract
Definition: gcode.h:556
Definition: gcode.h:342
float radius
Definition: gcode.h:345
ccomp_mode_t side
Definition: gcode.h:343
bool first_move
Definition: gcode.h:344
Data for G70-G73.
Definition: gcode.h:545
gc_modal_t modal
Definition: gcode.h:546
Definition: gcode.h:503
cc_retract_mode_t retract_mode
{G98,G99}
Definition: gcode.h:521
bool canned_cycle_active
Definition: gcode.h:523
coord_system_t g5x_offset
{G54,G55,G56,G57,G58,G59,G59.1,G59.2,G59.3}
Definition: gcode.h:513
feed_mode_t feed_mode
{G93,G94,G95}
Definition: gcode.h:505
motion_mode_t motion
{G0,G1,G2,G3,G38.2,G80}
Definition: gcode.h:504
gc_override_flags_t override_ctrl
{M48,M49,M50,M51,M53,M56}
Definition: gcode.h:520
plane_select_t plane_select
{G17,G18,G19}
Definition: gcode.h:510
coolant_state_t coolant
{M7,M8,M9}
Definition: gcode.h:518
tool_offset_mode_t tool_offset_mode
{G43,G43.1,G49}
Definition: gcode.h:512
program_flow_t program_flow
{M0,M1,M2,M30,M60}
Definition: gcode.h:517
bool auto_restore
{M73} NOTE: set in snapshot when saving modal state
Definition: gcode.h:534
float feed_rate
{F} NOTE: set in snapshot when saving modal state
Definition: gcode.h:533
bool scaling_active
{G50,G51}
Definition: gcode.h:522
bool units_imperial
{G20,G21}
Definition: gcode.h:506
bool diameter_mode
{G7,G8} Lathe diameter mode.
Definition: gcode.h:508
bool distance_incremental
{G90,G91}
Definition: gcode.h:507
Definition: gcode.h:538
override_t rapid_rate
Rapids override value in percent.
Definition: gcode.h:540
override_t feed_rate
Feed rate override value in percent.
Definition: gcode.h:539
Definition: gcode.h:570
float main_taper_height
Definition: gcode.h:577
float infeed_angle
Definition: gcode.h:579
float pitch
Definition: gcode.h:571
gc_taper_type end_taper_type
Definition: gcode.h:582
uint_fast16_t spring_passes
Definition: gcode.h:581
float cut_direction
Definition: gcode.h:580
float peak
Definition: gcode.h:573
float z_final
Definition: gcode.h:572
float depth
Definition: gcode.h:575
float end_taper_length
Definition: gcode.h:578
float initial_depth
Definition: gcode.h:574
float depth_degression
Definition: gcode.h:576
G- and M-code parameter values.
Definition: gcode.h:402
float q
User defined M-code parameter, M67 output value, G64 naive CAM tolerance, G83 delta increment.
Definition: gcode.h:411
float p
G10, 664 or dwell parameters.
Definition: gcode.h:410
uint32_t l
G10, G65, G66 or canned cycles parameters.
Definition: gcode.h:440
float d
Max spindle RPM in Constant Surface Speed Mode (G96)
Definition: gcode.h:403
float r
Arc radius or retract position.
Definition: gcode.h:412
float v
G65 argument.
Definition: gcode.h:428
float a
G65 argument.
Definition: gcode.h:416
int32_t n
Line number - single-meaning word.
Definition: gcode.h:438
float e
Thread taper length (G76), M67 output number.
Definition: gcode.h:404
float u
G65 argument.
Definition: gcode.h:425
float w
G65 argument.
Definition: gcode.h:431
float b
G65 argument.
Definition: gcode.h:419
float h
Tool number or number of G76 thread spring passes.
Definition: gcode.h:406
float s
Spindle speed - single-meaning word.
Definition: gcode.h:413
uint32_t o
Subroutine identifier - single-meaning word.
Definition: gcode.h:439
float k
G33 distance per revolution.
Definition: gcode.h:408
float m
G65 argument.
Definition: gcode.h:409
float c
G65 argument.
Definition: gcode.h:422
float f
Feed rate - single-meaning word.
Definition: gcode.h:405
float t
Tool selection - single-meaning word //.
Definition: gcode.h:414
Data for M62, M63 and M67 commands when executed synchronized with motion.
Definition: gcode.h:302
int32_t value
Definition: gcode.h:305
uint8_t port
Definition: gcode.h:304
bool is_digital
Definition: gcode.h:303
struct output_command * next
Definition: gcode.h:306
Parser block structure.
Definition: gcode.h:674
user_mcode_t user_mcode
Set > 0 if a user M-code is found.
Definition: gcode.h:678
spindle_modal_t spindle_modal
Definition: gcode.h:681
tool_action_t tool_action
Non modal tool change.
Definition: gcode.h:676
override_mode_t override_command
Override command TODO: add to non_modal above?
Definition: gcode.h:677
output_command_t output_command
Details about M62-M68 output command to execute if present in block.
Definition: gcode.h:684
parameter_words_t g65_words
Parameter words to pass to G65 macro.
Definition: gcode.h:686
gc_values_t values
Parameter values for block.
Definition: gcode.h:682
modal_state_action_t state_action
M70-M73 modal state action.
Definition: gcode.h:689
uint32_t arc_turns
Definition: gcode.h:685
bool user_mcode_sync
Set to true by M-code validation handler if M-code is to be executed after synchronization.
Definition: gcode.h:679
macro_call_t macro_call
Definition: gcode.h:688
non_modal_t non_modal_command
Non modal command.
Definition: gcode.h:675
gc_modal_t modal
The current modal state is copied here before parsing starts.
Definition: gcode.h:680
parameter_words_t words
Bitfield for tracking found parameter values.
Definition: gcode.h:683
Parser state.
Definition: gcode.h:626
status_code_t last_error
last return value from parser
Definition: gcode.h:648
uint32_t line_number
Last line number sent.
Definition: gcode.h:637
tool_data_t * tool
Tracks tool number and tool offset.
Definition: gcode.h:656
float distance_per_rev
Millimeters/rev.
Definition: gcode.h:631
bool file_run
Tracks % command.
Definition: gcode.h:642
coord_system_data_t g92_offset
Definition: gcode.h:653
g66_arguments_t * g66_args
Linked list with G66 arguments, NULL if G66 is not active.
Definition: gcode.h:658
bool g92_offset_applied
true when G92 offset applied
Definition: gcode.h:652
gc_canned_t canned
Definition: gcode.h:628
bool tool_change
Definition: gcode.h:646
bool skip_blocks
true if skipping conditional blocks
Definition: gcode.h:647
bool is_laser_ppi_mode
Definition: gcode.h:644
tool_id_t tool_pending
Tool to be selected on next M6.
Definition: gcode.h:638
float feed_rate
Millimeters/min.
Definition: gcode.h:630
bool file_stream
Tracks streaming from file.
Definition: gcode.h:643
bool is_rpm_rate_adjusted
Definition: gcode.h:645
gc_modal_t modal
Definition: gcode.h:627
spindle_t * spindle
Last referenced spindle.
Definition: gcode.h:629
offset_id_t offset_id
id(x) of last G92 coordinate offset (into circular buffer)
Definition: gcode.h:649
Definition: gcode.h:605
point_2d_t offsets
Definition: gcode.h:607
float angle
Definition: gcode.h:606
Definition: gcode.h:662
Data used for Constant Surface Speed (CSS) mode calculations.
Definition: spindle_control.h:343
Definition: gcode.h:497
spindle_state_t state
{M3,M4,M5}
Definition: gcode.h:498
spindle_rpm_mode_t rpm_mode
{G96,G97}
Definition: gcode.h:499
Handlers and data for spindle support.
Definition: spindle_control.h:314
Definition: gcode.h:488
float rpm
Spindle speed. Must be second last!
Definition: gcode.h:493
spindle_state_t state
{M3,M4,M5}
Definition: gcode.h:489
spindle_rpm_mode_t rpm_mode
{G96,G97}
Definition: gcode.h:490
spindle_ptrs_t * hal
Spindle function pointers etc. Must be last!
Definition: gcode.h:494
spindle_css_data_t * css
Data used for Constant Surface Speed Mode calculations.
Definition: gcode.h:492
spindle_cond_t condition
TODO: move data from planner_cond_t here.
Definition: gcode.h:491
Tool data.
Definition: gcode.h:586
coord_data_t offset
Tool offset.
Definition: gcode.h:587
float radius
Radius of tool (currently unsupported)
Definition: gcode.h:588
tool_id_t tool_id
Tool number.
Definition: gcode.h:589
Definition: gcode.h:599
tool_data_t tool
Definition: gcode.h:600
pocket_id_t pocket_id
Definition: gcode.h:601
Tool table entry.
Definition: gcode.h:593
tool_data_t * data
Definition: gcode.h:595
pocket_id_t pocket
Definition: gcode.h:596
const char * name
Definition: gcode.h:594
Definition: vfs.h:87
Definition: nuts_bolts.h:246
Definition: coolant_control.h:27
Coordinate data.
Definition: nuts_bolts.h:289
Override flags.
Definition: gcode.h:367
uint16_t reserved2
Definition: gcode.h:385
uint16_t parking
Definition: gcode.h:382
uint16_t spindle_rpm
Definition: gcode.h:379
uint16_t parking_disable
Definition: gcode.h:373
uint16_t feed_hold
Definition: gcode.h:381
uint16_t feed_hold_disable
Definition: gcode.h:372
uint16_t spindle_rpm_disable
Definition: gcode.h:370
uint16_t sync
Definition: gcode.h:376
uint16_t feed_rates
Definition: gcode.h:380
uint16_t reserved
Definition: gcode.h:375
uint16_t reserved1
Definition: gcode.h:384
uint16_t value
Definition: gcode.h:368
uint16_t spindle
Definition: gcode.h:383
uint16_t spindle_wait_disable
Definition: gcode.h:374
uint16_t feed_rates_disable
Definition: gcode.h:371
Parser flags for special cases.
Definition: gcode.h:349
uint16_t set_coolant
Definition: gcode.h:360
uint16_t spindle_force_sync
Definition: gcode.h:357
uint16_t laser_disable
Definition: gcode.h:358
uint16_t canned_cycle_change
Definition: gcode.h:353
uint16_t probe_is_away
Definition: gcode.h:355
uint16_t jog_motion
Definition: gcode.h:352
uint16_t reserved
Definition: gcode.h:362
uint16_t probe_is_no_error
Definition: gcode.h:356
uint16_t laser_is_motion
Definition: gcode.h:359
uint16_t value
Definition: gcode.h:350
uint16_t motion_mode_changed
Definition: gcode.h:361
uint16_t arc_is_clockwise
Definition: gcode.h:354
Parameter words found by parser - do NOT change order!
Definition: gcode.h:444
uint32_t a
A-axis or G65 argument.
Definition: gcode.h:449
uint32_t l
Number of repetitions in canned cycles, wait mode for M66.
Definition: gcode.h:460
uint32_t g
Unused (placeholder).
Definition: gcode.h:458
uint32_t b
B-axis or G65 argument.
Definition: gcode.h:450
uint32_t s
Spindle speed.
Definition: gcode.h:467
uint32_t d
Tool radius compensation.
Definition: gcode.h:455
uint32_t n
Line number.
Definition: gcode.h:462
uint32_t h
Tool length offset index.
Definition: gcode.h:459
uint32_t j
Y-axis offset for arcs.
Definition: gcode.h:453
uint32_t i
X-axis offset for arcs.
Definition: gcode.h:452
uint32_t e
Analog port number for M66 - M68.
Definition: gcode.h:456
uint32_t m
G65 argument.
Definition: gcode.h:461
uint32_t o
Subroutine identifier.
Definition: gcode.h:463
uint32_t p
Dwell time for G4 or in canned cycles, port number for M62 - M66.
Definition: gcode.h:464
uint32_t q
Feed increment for G83 canned cycle, tool number for M61, timeout for M66.
Definition: gcode.h:465
uint32_t y
Y-axis.
Definition: gcode.h:473
uint32_t v
V-axis or G65 argument.
Definition: gcode.h:470
uint32_t u
U-axis or G65 argument.
Definition: gcode.h:469
uint32_t x
X-axis.
Definition: gcode.h:472
uint32_t c
C-axis or G65 argument.
Definition: gcode.h:451
uint32_t w
W-axis or G65 argument.
Definition: gcode.h:471
uint32_t mask
All flags as a bitmap.
Definition: gcode.h:445
uint32_t z
Z-axis.
Definition: gcode.h:474
uint32_t k
Z-axis offset for arcs.
Definition: gcode.h:454
uint32_t r
Arc radius, canned cycle retract level.
Definition: gcode.h:466
uint32_t f
Feedrate.
Definition: gcode.h:457
uint32_t value
Synonymous with mask.
Definition: gcode.h:446
uint32_t t
Tool number.
Definition: gcode.h:468
Axis index to plane assignment.
Definition: nuts_bolts.h:373
Definition: nuts_bolts.h:355
Definition: gcode.h:478
uint8_t is_laser_ppi_mode
Definition: gcode.h:482
uint8_t is_rpm_rate_adjusted
Definition: gcode.h:481
uint8_t unassigned
Definition: gcode.h:483
uint8_t value
Definition: gcode.h:479
Definition: spindle_control.h:59