grblHAL core  20250618
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-2025 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 
32 #define MAX_OFFSET_ENTRIES 4 // must be a power of 2
33 
34 typedef int32_t tool_id_t;
35 typedef int16_t pocket_id_t;
36 typedef uint16_t macro_id_t;
37 typedef int8_t offset_id_t;
38 
39 // Define command actions for within execution-type modal groups (motion, stopping, non-modal). Used
40 // internally by the parser to know which command to execute.
41 // NOTE: Some values are assigned specific values to make g-code state reporting and parsing
42 // compile a little smaller. Although not
43 // ideal, just be careful with values that state 'do not alter' and check both report.c and gcode.c
44 // to see how they are used, if you need to alter them.
45 
50 typedef enum {
63  #if ENABLE_ACCELERATION_PROFILES
65  NonModal_SetAccelerationProfile = 187
66  #else
68  #endif
70 
71 
72 typedef enum {
79 
84 typedef enum {
105  MotionMode_None = 80
107 
112 typedef enum {
115  PlaneSelect_YZ = 2
117 
118 // Modal Group G4: Arc IJK distance mode
119 //#define DISTANCE_ARC_MODE_INCREMENTAL 0 // G91.1 - Default, must be zero
120 
121 
126 typedef enum {
131 
132 // Modal Group G7: Cutter radius compensation mode
133 //#define CUTTER_COMP_DISABLE 0 // G40 - Default, must be zero
134 
139 typedef enum {
145 
150 typedef enum {
152  CCRetractMode_RPos = 1
154 
155 
161 typedef enum {
168 #if COMPATIBILITY_LEVEL <= 1
172 #endif
178 } __attribute__ ((__packed__)) coord_system_id_t;
179 
180 
185 typedef enum {
190 
195 typedef enum {
199 
204 typedef enum {
214 
215 // Modal Group M9: Override control
216 typedef enum {
222  Override_Parking = 56
224 
227 typedef enum {
235 } io_mcode_t;
236 
240 typedef enum {
246  Fan_On = 106,
247  Fan_Off = 107,
262  OpenPNP_SetJerk = 20130,
268  Probe_Deploy = 401,
269  Probe_Stow = 402,
280 
282 typedef struct output_command {
284  uint8_t port;
285  int32_t value;
288 
290 typedef enum {
296  WaitMode_Max
298 
300 typedef enum {
305 
310 typedef enum {
315  #if SET_CHECK_MODE_PROBE_TO_START
317  #else
319  #endif
321 
323 typedef union {
324  uint16_t value;
325  struct {
326  uint16_t jog_motion :1,
327  canned_cycle_change :1, // Use motion_mode_changed?
337  };
339 
341 typedef union {
342  uint8_t value;
343  struct {
344  uint8_t feed_rate_disable :1,
349  sync :1;
350  };
352 
354 typedef union {
355  float values[N_AXIS];
356  struct {
357  float x;
358  float y;
359  float z;
360 #ifdef A_AXIS
361  float a;
362 #endif
363 #ifdef B_AXIS
364  float b;
365 #endif
366 #ifdef C_AXIS
367  float c;
368 #endif
369 #ifdef U_AXIS
370  float u;
371 #endif
372 #ifdef V_AXIS
373  float v;
374 #endif
375  };
376  struct {
377  float m0;
378  float m1;
379  float m2;
380 #if N_AXIS > 3
381  float m3;
382 #endif
383 #if N_AXIS > 4
384  float m4;
385 #endif
386 #if N_AXIS > 5
387  float m5;
388 #endif
389 #if N_AXIS > 6
390  float m6;
391 #endif
392 #if N_AXIS == 8
393  float m7;
394 #endif
395  };
396 } coord_data_t;
397 
399 typedef struct {
400  float xyz[N_AXIS];
403 
405 typedef union {
406  uint8_t axis[3];
407  struct {
408  uint8_t axis_0;
409  uint8_t axis_1;
410  uint8_t axis_linear;
411  };
412 } plane_t;
413 
421 typedef struct {
422  float d;
423  float e;
424  float f;
425  float ijk[3];
426  float k;
427  float m;
428  float p;
429  float q;
430  float r;
431  float s;
432 #ifndef A_AXIS
433  float a;
434 #endif
435 #ifndef B_AXIS
436  float b;
437 #endif
438 #ifndef C_AXIS
439  float c;
440 #endif
441 #if !defined(U_AXIS) && !AXIS_REMAP_ABC2UVW
442  float u;
443 #endif
444 #if !defined(V_AXIS) && !AXIS_REMAP_ABC2UVW
445  float v;
446 #endif
447 #if !AXIS_REMAP_ABC2UVW
448  float w;
449 #endif
450  float xyz[N_AXIS];
451 #if LATHE_UVW_OPTION
452  float uvw[3];
453 #endif
455  int32_t $;
456  int32_t n;
457  uint32_t o;
458  uint32_t h;
460  uint8_t l;
461 } gc_values_t;
462 
464 typedef union {
465  uint32_t mask;
466  uint32_t value;
467  struct {
468  uint32_t $ :1,
469  a :1,
470  b :1,
471  c :1,
472  i :1,
473  j :1,
474  k :1,
475  d :1,
476  e :1,
477  f :1,
478  g :1,
479  h :1,
480  l :1,
481  m :1,
482  n :1,
483  o :1,
484  p :1,
485  q :1,
486  r :1,
487  s :1,
488  t :1,
489  u :1,
490  v :1,
491  w :1,
492  x :1,
493  y :1,
494  z :1;
495  };
497 
498 typedef enum {
505 
506 typedef struct {
507  const void *value;
510 
511 typedef union {
512  uint8_t value;
513  struct {
517 
518  };
520 
521 typedef struct {
526  float rpm;
528 } spindle_t;
529 
530 typedef struct {
534 
535 // NOTE: When this struct is zeroed, the above defines set the defaults for the system.
536 typedef struct {
542  //< uint8_t distance_arc; //!< {G91.1} NOTE: Don't track. Only default supported.
544  //< uint8_t cutter_comp; //!< {G40} NOTE: Don't track. Only default supported.
547 #if ENABLE_PATH_BLENDING
548  control_mode_t control;
549 #endif
552 #if N_SYS_SPINDLE > 1
553  spindle_t spindle[N_SYS_SPINDLE];
554 #else
556 #endif
561  float spline_pq[2];
562 #if NGC_PARAMETERS_ENABLE
564  float feed_rate;
565 #endif
566 #if ENABLE_ACCELERATION_PROFILES
567  float acceleration_factor;
568 #endif
569 } gc_modal_t;
570 
572 typedef struct {
573  float xyz[3];
574  float delta;
575  float dwell;
580  bool change;
581 } gc_canned_t;
582 
584 typedef enum {
588  Taper_Both
590 
591 typedef struct {
592  float pitch;
593  float z_final;
594  float peak;
596  float depth;
602  uint_fast16_t spring_passes;
605 
607 typedef struct {
609  float radius;
611 } tool_data_t;
612 
613 typedef struct {
616 } tool_pocket_t;
617 
621 typedef struct {
625  float feed_rate;
627  float position[N_AXIS];
628 #if ENABLE_PATH_BLENDING
629  float path_tolerance;
630  float cam_tolerance;
631 #endif
632  int32_t line_number;
634 #if NGC_EXPRESSIONS_ENABLE
635  uint32_t g43_pending;
636 #endif
637  bool file_run;
638  bool file_stream;
642  bool skip_blocks;
648  float g92_coord_offset[N_AXIS];
651  float tool_length_offset[N_AXIS];
654 
655 typedef struct {
656  float xyz[N_AXIS];
657  float ijk[N_AXIS];
659 
660 extern parser_state_t gc_state;
661 
667 typedef struct {
677  uint32_t arc_turns; //
678 #if NGC_PARAMETERS_ENABLE
680 #endif
681 #if N_AXIS > 3
682  axes_signals_t rotary_wrap;
683 #endif
685 
686 
687 static inline axes_signals_t gc_paramwords_to_axes (parameter_words_t p_words)
688 {
689 #if N_AXIS == 3
690  return (axes_signals_t){ (uint8_t)(p_words.mask >> 24) };
691 #else
692  return (axes_signals_t){ (uint8_t)(((p_words.mask >> 24) | ((p_words.mask << 2) & 0b00111000) | ((p_words.mask >> (21 - 6)) & 0b11000000)) & AXES_BITMASK) };
693 #endif
694 }
695 
696 // Initialize the parser
697 void gc_init (bool stop);
698 
699 char *gc_normalize_block (char *block, status_code_t *status, char **message);
700 
701 // Execute one block of rs275/ngc/g-code
702 status_code_t gc_execute_block (char *block);
703 
704 // Sets g-code parser position in mm. Input in steps. Called by the system abort and hard
705 // limit pull-off routines.
706 #define gc_sync_position() system_convert_array_steps_to_mpos (gc_state.position, sys.position)
707 
708 // Sets g-code parser and planner position in mm.
709 #define sync_position() plan_sync_position(); system_convert_array_steps_to_mpos (gc_state.position, sys.position)
710 
711 // Set dynamic laser power mode to PPI (Pulses Per Inch)
712 // Driver support for pulsing the laser on signal is required for this to work.
713 // Returns true if driver uses hardware implementation.
714 bool gc_laser_ppi_enable (uint_fast16_t ppi, uint_fast16_t pulse_length);
716 // Gets axes scaling state.
718 float *gc_get_scaling (void);
719 
720 // Get current axis offset.
721 float gc_get_offset (uint_fast8_t idx, bool real_time);
722 
724 
726 
728 
729 void gc_spindle_off (void);
730 void gc_coolant (coolant_state_t state);
731 
732 void gc_set_tool_offset (tool_offset_mode_t mode, uint_fast8_t idx, int32_t offset);
734 
735 #if NGC_PARAMETERS_ENABLE
738 #endif
739 
740 #if ENABLE_ACCELERATION_PROFILES
741 float gc_get_accel_factor (uint8_t profile);
742 #endif
743 
744 #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:30
override_mode_t
Definition: gcode.h:216
@ Override_FeedRate
50 - M50
Definition: gcode.h:219
@ Override_FeedHold
53 - M53
Definition: gcode.h:221
@ Override_FeedSpeedDisable
49 - M49
Definition: gcode.h:218
@ Override_SpindleSpeed
51 - M51
Definition: gcode.h:220
@ Override_Parking
56 - M56
Definition: gcode.h:222
@ Override_FeedSpeedEnable
48 - M48
Definition: gcode.h:217
modal_state_action_t
Definition: gcode.h:72
@ ModalState_Save
70 - M70
Definition: gcode.h:74
@ ModalState_Invalidate
71 - M71
Definition: gcode.h:75
@ ModalState_NoAction
0 - Default, must be zero
Definition: gcode.h:73
@ ModalState_SaveAutoRestore
73 - M73
Definition: gcode.h:77
@ ModalState_Restore
72 - M72
Definition: gcode.h:76
char * gc_normalize_block(char *block, status_code_t *status, char **message)
Definition: gcode.c:625
int32_t tool_id_t
Definition: gcode.h:34
feed_mode_t
Definition: gcode.h:126
@ FeedMode_InverseTime
1 - G93
Definition: gcode.h:128
@ FeedMode_UnitsPerRev
2 - G95
Definition: gcode.h:129
@ FeedMode_UnitsPerMin
0 - G94 - Default, must be zero
Definition: gcode.h:127
#define MAX_OFFSET_ENTRIES
Definition: gcode.h:32
int8_t offset_id_t
Definition: gcode.h:37
tool_offset_mode_t
Definition: gcode.h:139
@ ToolLengthOffset_EnableDynamic
2 - G43.1
Definition: gcode.h:142
@ ToolLengthOffset_Cancel
0 - G49 - Default, must be zero
Definition: gcode.h:140
@ ToolLengthOffset_Enable
1 - G43
Definition: gcode.h:141
@ ToolLengthOffset_ApplyAdditional
3 - G43.2
Definition: gcode.h:143
plane_t * gc_get_plane_data(plane_t *plane, plane_select_t select)
Definition: gcode.c:285
void gc_init(bool stop)
Definition: gcode.c:328
motion_mode_t
Definition: gcode.h:84
@ MotionMode_RigidTapping
331 - G33.1
Definition: gcode.h:92
@ MotionMode_DrillChipBreak
73 - G73
Definition: gcode.h:93
@ MotionMode_CannedCycle82
82 - G82
Definition: gcode.h:96
@ MotionMode_CannedCycle83
83 - G83
Definition: gcode.h:97
@ MotionMode_CannedCycle89
89 - G89
Definition: gcode.h:100
@ MotionMode_CcwArc
3 - G3
Definition: gcode.h:88
@ MotionMode_Seek
0 - G0 - Default, must be zero
Definition: gcode.h:85
@ MotionMode_ProbeToward
140 - G38.2
Definition: gcode.h:101
@ MotionMode_SpindleSynchronized
33 - G33
Definition: gcode.h:91
@ MotionMode_CubicSpline
5 - G5
Definition: gcode.h:89
@ MotionMode_CwArc
2 - G2
Definition: gcode.h:87
@ MotionMode_ProbeAway
142 - G38.4
Definition: gcode.h:103
@ MotionMode_Linear
1 - G1
Definition: gcode.h:86
@ MotionMode_ProbeTowardNoError
141 - G38.3
Definition: gcode.h:102
@ MotionMode_Threading
76 - G76
Definition: gcode.h:94
@ MotionMode_QuadraticSpline
51 - G5.1
Definition: gcode.h:90
@ MotionMode_CannedCycle86
86 - G86
Definition: gcode.h:99
@ MotionMode_CannedCycle85
85 - G85
Definition: gcode.h:98
@ MotionMode_CannedCycle81
81 - G81
Definition: gcode.h:95
@ MotionMode_None
80 - G80
Definition: gcode.h:105
@ MotionMode_ProbeAwayNoError
143 - G38.5
Definition: gcode.h:104
io_mcode_t
Definition: gcode.h:227
@ IoMCode_OutputOffSynced
63 - M63
Definition: gcode.h:229
@ IoMCode_WaitOnInput
66 - M66
Definition: gcode.h:232
@ IoMCode_OutputOnSynced
62 - M62
Definition: gcode.h:228
@ IoMCode_AnalogOutSynced
67 - M67
Definition: gcode.h:233
@ IoMCode_AnalogOutImmediate
68 - M68
Definition: gcode.h:234
@ IoMCode_OutputOnImmediate
64 - M64
Definition: gcode.h:230
@ IoMCode_OutputOffImmediate
65 - M65
Definition: gcode.h:231
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)
Definition: gcode.c:578
non_modal_t
Definition: gcode.h:50
@ NonModal_SetCoordinateData
10 - G10
Definition: gcode.h:53
@ NonModal_SetHome_1
40 - G30.1
Definition: gcode.h:57
@ NonModal_SetCoordinateOffset
92 - G92
Definition: gcode.h:60
@ NonModal_SetHome_0
38 - G28.1
Definition: gcode.h:55
@ NonModal_MacroCall
65 - G65
Definition: gcode.h:59
@ NonModal_AbsoluteOverride
53 - G53
Definition: gcode.h:58
@ NonModal_Dwell
4 - G4
Definition: gcode.h:52
@ NonModal_NoAction
0 - Default, must be zero
Definition: gcode.h:51
@ NonModal_RestoreCoordinateOffset
122 - G92.3
Definition: gcode.h:67
@ NonModal_GoHome_1
30 - G30
Definition: gcode.h:56
@ NonModal_ResetCoordinateOffset
102 - G92.1
Definition: gcode.h:61
@ NonModal_ClearCoordinateOffset
112 - G92.2
Definition: gcode.h:62
@ NonModal_GoHome_0
28 - G28
Definition: gcode.h:54
pos_update_t
Parser position updating flags.
Definition: gcode.h:300
@ GCUpdatePos_None
2
Definition: gcode.h:303
@ GCUpdatePos_System
1
Definition: gcode.h:302
@ GCUpdatePos_Target
0
Definition: gcode.h:301
spindle_t * gc_spindle_get(spindle_num_t spindle)
Definition: gcode.c:435
user_mcode_t
Definition: gcode.h:240
@ Trinamic_ModeToggle
569 - M569, Marlin format
Definition: gcode.h:271
@ Plasma_SelectMaterial
150 - M190, LinuxCNC format
Definition: gcode.h:261
@ RGB_WriteLEDs
150 - M150, Marlin format
Definition: gcode.h:260
@ LaserPPI_Enable
126 - M126
Definition: gcode.h:253
@ OpenPNP_FinishMoves
400 - M400
Definition: gcode.h:267
@ OpenPNP_GetADCScaled
144 - M144
Definition: gcode.h:258
@ OpenPNP_GetCurrentPosition
114 - M114
Definition: gcode.h:248
@ UserMCode_Generic1
101 - For private use only
Definition: gcode.h:242
@ UserMCode_Generic4
104 - For private use only
Definition: gcode.h:245
@ UserMCode_Generic2
102 - For private use only
Definition: gcode.h:243
@ SetFeedOverrides
220 - M220, Marlin format
Definition: gcode.h:264
@ OpenPNP_SettingsReset
502 - M502
Definition: gcode.h:270
@ OpenPNP_GetPinState
143 - M143
Definition: gcode.h:257
@ Trinamic_ChopperTiming
919 - M919, Marlin format
Definition: gcode.h:277
@ OpenPNP_FirmwareInfo
115 - M115
Definition: gcode.h:249
@ Laser_Overdrive
129 - M129
Definition: gcode.h:256
@ UserMCode_Generic3
103 - For private use only
Definition: gcode.h:244
@ OpenPNP_SetADCScaling
145 - M145
Definition: gcode.h:259
@ PWMServo_SetPosition
280 - M280, Marlin format
Definition: gcode.h:265
@ LaserPPI_PulseLength
128 - M128
Definition: gcode.h:255
@ Trinamic_StepperCurrent
906 - M906, Marlin format
Definition: gcode.h:272
@ Trinamic_ReportPrewarnFlags
911 - M911, Marlin format
Definition: gcode.h:273
@ Trinamic_HomingSensitivity
914 - M914, Marlin format
Definition: gcode.h:276
@ Probe_Deploy
401 - M401, Marlin format
Definition: gcode.h:268
@ Probe_Stow
402 - M402, Marlin format
Definition: gcode.h:269
@ RGB_Inspection_Light
356 - M356
Definition: gcode.h:266
@ Fan_Off
107 - M107, Marlin format
Definition: gcode.h:247
@ LaserPPI_Rate
127 - M127
Definition: gcode.h:254
@ Trinamic_DebugReport
122 - M122, Marlin format
Definition: gcode.h:250
@ OpenPNP_SetJerk
20130 - M201.3
Definition: gcode.h:262
@ Trinamic_HybridThreshold
913 - M913, Marlin format
Definition: gcode.h:275
@ Spindle_Select
Value to be assigned later!
Definition: gcode.h:278
@ OpenPNP_SetPinState
42 - M42
Definition: gcode.h:241
@ Trinamic_ClearPrewarnFlags
912 - M912, Marlin format
Definition: gcode.h:274
@ Trinamic_ReadRegister
123 - M123
Definition: gcode.h:251
@ Fan_On
106 - M106, Marlin format
Definition: gcode.h:246
@ OpenPNP_SetAcceleration
204 - M204
Definition: gcode.h:263
@ Trinamic_WriteRegister
124 - M124
Definition: gcode.h:252
program_flow_t
Definition: gcode.h:204
@ ProgramFlow_EndPercent
255 - %
Definition: gcode.h:212
@ ProgramFlow_Running
0 - Default, must be zero
Definition: gcode.h:205
@ ProgramFlow_CompletedM60
60 - M60
Definition: gcode.h:210
@ ProgramFlow_OptionalStop
1 - M1
Definition: gcode.h:207
@ ProgramFlow_CompletedM2
2 - M2
Definition: gcode.h:208
@ ProgramFlow_Return
99 - M99
Definition: gcode.h:211
@ ProgramFlow_Paused
3 - M0
Definition: gcode.h:206
@ ProgramFlow_CompletedM30
30 - M30
Definition: gcode.h:209
uint16_t macro_id_t
Definition: gcode.h:36
gc_taper_type
Thread taper types.
Definition: gcode.h:584
@ Taper_None
0
Definition: gcode.h:585
@ Taper_Both
3
Definition: gcode.h:588
@ Taper_Exit
2
Definition: gcode.h:587
@ Taper_Entry
1
Definition: gcode.h:586
gc_probe_t
Definition: gcode.h:310
@ GCProbe_FailEnd
0
Definition: gcode.h:314
@ GCProbe_FailInit
2
Definition: gcode.h:313
@ GCProbe_CheckMode
0
Definition: gcode.h:318
@ GCProbe_Found
1
Definition: gcode.h:311
@ GCProbe_Abort
2
Definition: gcode.h:312
float * gc_get_scaling(void)
Definition: gcode.c:209
cc_retract_mode_t
Definition: gcode.h:150
@ CCRetractMode_Previous
0 - G98 - Default, must be zero
Definition: gcode.h:151
@ CCRetractMode_RPos
1 - G99
Definition: gcode.h:152
spindle_rpm_mode_t
Definition: gcode.h:195
@ SpindleSpeedMode_RPM
0 - G97 - Default, must be zero
Definition: gcode.h:196
@ SpindleSpeedMode_CSS
1 - G96
Definition: gcode.h:197
parser_state_t gc_state
Definition: gcode.c:121
int16_t pocket_id_t
Definition: gcode.h:35
control_mode_t
Definition: gcode.h:185
@ ControlMode_ExactStop
1 - G61.1
Definition: gcode.h:187
@ ControlMode_PathBlending
2 - G64
Definition: gcode.h:188
@ ControlMode_ExactPath
0 - G61 - Default, must be zero
Definition: gcode.h:186
char * gc_coord_system_to_str(coord_system_id_t id)
Definition: gcode.c:168
bool gc_modal_state_restore(gc_modal_t *copy)
Definition: gcode.c:583
axes_signals_t gc_get_g51_state(void)
Definition: gcode.c:214
void gc_coolant(coolant_state_t state)
Definition: gcode.c:459
void gc_clear_output_commands(output_command_t *cmd)
Definition: gcode.c:517
void gc_spindle_off(void)
Definition: gcode.c:444
coord_system_id_t
Definition: gcode.h:161
@ CoordinateSystem_G55
1 - G55 (G12)
Definition: gcode.h:163
@ CoordinateSystem_G28
9 - G28 (G0) when COMPATIBILITY_LEVEL <= 1, 6 otherwise
Definition: gcode.h:174
@ CoordinateSystem_G59_3
8 - G59.3 (G12) - availability depending on COMPATIBILITY_LEVEL <= 1
Definition: gcode.h:171
@ CoordinateSystem_G54
0 - G54 (G12)
Definition: gcode.h:162
@ N_WorkCoordinateSystems
9 when COMPATIBILITY_LEVEL <= 1, 6 otherwise
Definition: gcode.h:173
@ CoordinateSystem_G56
2 - G56 (G12)
Definition: gcode.h:164
@ CoordinateSystem_G92
11 - G92 (G0) when COMPATIBILITY_LEVEL <= 1, 8 otherwise
Definition: gcode.h:176
@ CoordinateSystem_G59
5 - G59 (G12)
Definition: gcode.h:167
@ CoordinateSystem_G57
3 - G57 (G12)
Definition: gcode.h:165
@ CoordinateSystem_G30
10 - G30 (G0) when COMPATIBILITY_LEVEL <= 1, 7 otherwise
Definition: gcode.h:175
@ CoordinateSystem_G59_2
7 - G59.2 (G12) - availability depending on COMPATIBILITY_LEVEL <= 1
Definition: gcode.h:170
@ CoordinateSystem_G59_1
6 - G59.1 (G12) - availability depending on COMPATIBILITY_LEVEL <= 1
Definition: gcode.h:169
@ CoordinateSystem_G58
4 - G58 (G12)
Definition: gcode.h:166
@ N_CoordinateSystems
12 when COMPATIBILITY_LEVEL <= 1, 9 otherwise
Definition: gcode.h:177
gc_value_type_t
Definition: gcode.h:498
@ ValueType_UInt8
Definition: gcode.h:500
@ ValueType_UInt32
Definition: gcode.h:501
@ ValueType_NA
Definition: gcode.h:499
@ ValueType_Int32
Definition: gcode.h:502
@ ValueType_Float
Definition: gcode.h:503
status_code_t gc_execute_block(char *block)
Definition: gcode.c:709
bool gc_laser_ppi_enable(uint_fast16_t ppi, uint_fast16_t pulse_length)
Definition: gcode.c:428
wait_mode_t
M66 Allowed L-parameter values.
Definition: gcode.h:290
@ WaitMode_High
3
Definition: gcode.h:294
@ WaitMode_Immediate
0 - This is the only mode allowed for analog inputs
Definition: gcode.h:291
@ WaitMode_Fall
2
Definition: gcode.h:293
@ WaitMode_Max
For internal use.
Definition: gcode.h:296
@ WaitMode_Low
4
Definition: gcode.h:295
@ WaitMode_Rise
1
Definition: gcode.h:292
void gc_set_tool_offset(tool_offset_mode_t mode, uint_fast8_t idx, int32_t offset)
Definition: gcode.c:246
float gc_get_offset(uint_fast8_t idx, bool real_time)
Definition: gcode.c:229
plane_select_t
Definition: gcode.h:112
@ PlaneSelect_YZ
2 - G19
Definition: gcode.h:115
@ PlaneSelect_ZX
1 - G18
Definition: gcode.h:114
@ PlaneSelect_XY
0 - G17 - Default, must be zero
Definition: gcode.h:113
parser_state_t * gc_get_state(void)
Definition: gcode.c:163
#define AXES_BITMASK
Definition: nuts_bolts.h:96
int8_t spindle_num_t
Definition: spindle_control.h:56
Coordinate data including id.
Definition: gcode.h:399
coord_system_id_t id
Definition: gcode.h:401
Data for canned cycles.
Definition: gcode.h:572
float dwell
Definition: gcode.h:575
cc_retract_mode_t retract_mode
Definition: gcode.h:579
float delta
Definition: gcode.h:574
bool spindle_off
Definition: gcode.h:578
bool change
Definition: gcode.h:580
float retract_position
Canned cycle retract position.
Definition: gcode.h:576
bool rapid_retract
Definition: gcode.h:577
Definition: gcode.h:536
cc_retract_mode_t retract_mode
{G98,G99}
Definition: gcode.h:558
bool canned_cycle_active
Definition: gcode.h:560
feed_mode_t feed_mode
{G93,G94,G95}
Definition: gcode.h:538
motion_mode_t motion
{G0,G1,G2,G3,G38.2,G80}
Definition: gcode.h:537
spindle_t spindle
{M3,M4,M5 and G96,G97}
Definition: gcode.h:555
gc_override_flags_t override_ctrl
{M48,M49,M50,M51,M53,M56}
Definition: gcode.h:557
plane_select_t plane_select
{G17,G18,G19}
Definition: gcode.h:543
coolant_state_t coolant
{M7,M8,M9}
Definition: gcode.h:551
tool_offset_mode_t tool_offset_mode
{G43,G43.1,G49}
Definition: gcode.h:545
program_flow_t program_flow
{M0,M1,M2,M30,M60}
Definition: gcode.h:550
bool auto_restore
Definition: gcode.h:563
float feed_rate
{F} NOTE: only set when saving modal state
Definition: gcode.h:564
bool scaling_active
{G50,G51}
Definition: gcode.h:559
bool units_imperial
{G20,G21}
Definition: gcode.h:539
coord_system_t coord_system
{G54,G55,G56,G57,G58,G59,G59.1,G59.2,G59.3}
Definition: gcode.h:546
bool diameter_mode
{G7,G8} Lathe diameter mode.
Definition: gcode.h:541
bool distance_incremental
{G90,G91}
Definition: gcode.h:540
Definition: gcode.h:591
float main_taper_height
Definition: gcode.h:598
float infeed_angle
Definition: gcode.h:600
float pitch
Definition: gcode.h:592
gc_taper_type end_taper_type
Definition: gcode.h:603
uint_fast16_t spring_passes
Definition: gcode.h:602
float cut_direction
Definition: gcode.h:601
float peak
Definition: gcode.h:594
float z_final
Definition: gcode.h:593
float depth
Definition: gcode.h:596
float end_taper_length
Definition: gcode.h:599
float initial_depth
Definition: gcode.h:595
float depth_degression
Definition: gcode.h:597
Definition: gcode.h:506
const gc_value_type_t type
Definition: gcode.h:508
const void * value
Definition: gcode.h:507
G- and M-code parameter values.
Definition: gcode.h:421
float q
User defined M-code parameter, M67 output value, G64 naive CAM tolerance, G83 delta increment.
Definition: gcode.h:429
coord_system_t coord_data
Coordinate data.
Definition: gcode.h:454
float p
G10, 664 or dwell parameters.
Definition: gcode.h:428
float d
Max spindle RPM in Constant Surface Speed Mode (G96)
Definition: gcode.h:422
float r
Arc radius or retract position.
Definition: gcode.h:430
float v
Definition: gcode.h:445
float a
Definition: gcode.h:433
int32_t n
Line number - single-meaning word.
Definition: gcode.h:456
float e
Thread taper length (G76), M67 output number.
Definition: gcode.h:423
uint32_t h
Tool number or number of G76 thread spring passes.
Definition: gcode.h:458
uint8_t l
G10 or canned cycles parameters.
Definition: gcode.h:460
float u
Definition: gcode.h:442
float w
Definition: gcode.h:448
float b
Definition: gcode.h:436
float s
Spindle speed - single-meaning word.
Definition: gcode.h:431
uint32_t o
Subroutine identifier - single-meaning word.
Definition: gcode.h:457
tool_id_t t
Tool selection - single-meaning word.
Definition: gcode.h:459
float k
G33 distance per revolution.
Definition: gcode.h:426
float m
G65 argument.
Definition: gcode.h:427
float c
Definition: gcode.h:439
float f
Feed rate - single-meaning word.
Definition: gcode.h:424
Data for M62, M63 and M67 commands when executed synchronized with motion.
Definition: gcode.h:282
int32_t value
Definition: gcode.h:285
uint8_t port
Definition: gcode.h:284
bool is_digital
Definition: gcode.h:283
struct output_command * next
Definition: gcode.h:286
Parser block structure.
Definition: gcode.h:667
user_mcode_t user_mcode
Set > 0 if a user M-code is found.
Definition: gcode.h:670
spindle_modal_t spindle_modal
Definition: gcode.h:673
override_mode_t override_command
Override command TODO: add to non_modal above?
Definition: gcode.h:669
output_command_t output_command
Details about M62-M68 output command to execute if present in block.
Definition: gcode.h:676
gc_values_t values
Parameter values for block.
Definition: gcode.h:674
modal_state_action_t state_action
M70-M73 modal state action.
Definition: gcode.h:679
uint32_t arc_turns
Definition: gcode.h:677
bool user_mcode_sync
Set to true by M-code validation handler if M-code is to be executed after synchronization.
Definition: gcode.h:671
non_modal_t non_modal_command
Non modal command.
Definition: gcode.h:668
gc_modal_t modal
The current modal state is copied here before parsing starts.
Definition: gcode.h:672
parameter_words_t words
Bitfield for tracking found parameter values.
Definition: gcode.h:675
Parser state.
Definition: gcode.h:621
status_code_t last_error
last return value from parser
Definition: gcode.h:643
tool_data_t * tool
Tracks tool number and tool offset.
Definition: gcode.h:652
float distance_per_rev
Millimeters/rev.
Definition: gcode.h:626
bool file_run
Tracks % command.
Definition: gcode.h:637
int32_t line_number
Last line number sent.
Definition: gcode.h:632
gc_canned_t canned
Definition: gcode.h:623
bool tool_change
Definition: gcode.h:641
bool g92_coord_offset_applied
true when G92 offset applied
Definition: gcode.h:647
bool skip_blocks
true if skipping conditional blocks
Definition: gcode.h:642
bool is_laser_ppi_mode
Definition: gcode.h:639
tool_id_t tool_pending
Tool to be selected on next M6.
Definition: gcode.h:633
float feed_rate
Millimeters/min.
Definition: gcode.h:625
bool file_stream
Tracks streaming from file.
Definition: gcode.h:638
bool is_rpm_rate_adjusted
Definition: gcode.h:640
gc_modal_t modal
Definition: gcode.h:622
spindle_t * spindle
Last referenced spindle.
Definition: gcode.h:624
offset_id_t offset_id
id(x) of last G92 coordinate offset (into circular buffer)
Definition: gcode.h:644
Definition: gcode.h:655
Data used for Constant Surface Speed (CSS) mode calculations.
Definition: spindle_control.h:324
Definition: gcode.h:530
spindle_state_t state
{M3,M4,M5}
Definition: gcode.h:531
spindle_rpm_mode_t rpm_mode
{G96,G97}
Definition: gcode.h:532
Handlers and data for spindle support.
Definition: spindle_control.h:295
Definition: gcode.h:521
float rpm
Spindle speed. Must be second last!
Definition: gcode.h:526
spindle_state_t state
{M3,M4,M5}
Definition: gcode.h:522
spindle_rpm_mode_t rpm_mode
{G96,G97}
Definition: gcode.h:523
spindle_ptrs_t * hal
Spindle function pointers etc. Must be last!
Definition: gcode.h:527
spindle_css_data_t * css
Data used for Constant Surface Speed Mode calculations.
Definition: gcode.h:525
spindle_cond_t condition
TODO: move data from planner_cond_t here.
Definition: gcode.h:524
Tool data.
Definition: gcode.h:607
coord_data_t offset
Tool offset.
Definition: gcode.h:608
float radius
Radius of tool (currently unsupported)
Definition: gcode.h:609
tool_id_t tool_id
Tool number.
Definition: gcode.h:610
Definition: gcode.h:613
tool_data_t tool
Definition: gcode.h:614
pocket_id_t pocket_id
Definition: gcode.h:615
Definition: nuts_bolts.h:125
Definition: coolant_control.h:27
Coordinate data.
Definition: gcode.h:354
float m0
Definition: gcode.h:377
float m2
Definition: gcode.h:379
float y
Definition: gcode.h:358
float m1
Definition: gcode.h:378
float x
Definition: gcode.h:357
float z
Definition: gcode.h:359
Override flags.
Definition: gcode.h:341
uint8_t feed_hold_disable
Definition: gcode.h:345
uint8_t value
Definition: gcode.h:342
uint8_t spindle_rpm_disable
Definition: gcode.h:346
uint8_t parking_disable
Definition: gcode.h:347
uint8_t feed_rate_disable
Definition: gcode.h:344
uint8_t reserved
Definition: gcode.h:348
uint8_t sync
Definition: gcode.h:349
Parser flags for special cases.
Definition: gcode.h:323
uint16_t set_coolant
Definition: gcode.h:334
uint16_t spindle_force_sync
Definition: gcode.h:331
uint16_t laser_disable
Definition: gcode.h:332
uint16_t canned_cycle_change
Definition: gcode.h:327
uint16_t probe_is_away
Definition: gcode.h:329
uint16_t jog_motion
Definition: gcode.h:326
uint16_t reserved
Definition: gcode.h:336
uint16_t probe_is_no_error
Definition: gcode.h:330
uint16_t laser_is_motion
Definition: gcode.h:333
uint16_t value
Definition: gcode.h:324
uint16_t motion_mode_changed
Definition: gcode.h:335
uint16_t arc_is_clockwise
Definition: gcode.h:328
Parameter words found by parser - do NOT change order!
Definition: gcode.h:464
uint32_t a
A-axis.
Definition: gcode.h:469
uint32_t l
Number of repetitions in canned cycles, wait mode for M66.
Definition: gcode.h:480
uint32_t g
Unused (placeholder).
Definition: gcode.h:478
uint32_t b
B-axis.
Definition: gcode.h:470
uint32_t s
Spindle speed.
Definition: gcode.h:487
uint32_t d
Tool radius compensation.
Definition: gcode.h:475
uint32_t n
Line number.
Definition: gcode.h:482
uint32_t h
Tool length offset index.
Definition: gcode.h:479
uint32_t j
Y-axis offset for arcs.
Definition: gcode.h:473
uint32_t i
X-axis offset for arcs.
Definition: gcode.h:472
uint32_t e
Analog port number for M66 - M68.
Definition: gcode.h:476
uint32_t m
G65 argument.
Definition: gcode.h:481
uint32_t o
Subroutine identifier.
Definition: gcode.h:483
uint32_t p
Dwell time for G4 or in canned cycles, port number for M62 - M66.
Definition: gcode.h:484
uint32_t q
Feed increment for G83 canned cycle, tool number for M61, timeout for M66.
Definition: gcode.h:485
uint32_t y
Y-axis.
Definition: gcode.h:493
uint32_t v
V-axis.
Definition: gcode.h:490
uint32_t u
U-axis.
Definition: gcode.h:489
uint32_t x
X-axis.
Definition: gcode.h:492
uint32_t c
C-axis.
Definition: gcode.h:471
uint32_t w
W-axis.
Definition: gcode.h:491
uint32_t mask
All flags as a bitmap.
Definition: gcode.h:465
uint32_t z
Z-axis.
Definition: gcode.h:494
uint32_t k
Z-axis offset for arcs.
Definition: gcode.h:474
uint32_t r
Arc radius, canned cycle retract level.
Definition: gcode.h:486
uint32_t f
Feedrate.
Definition: gcode.h:477
uint32_t value
Synonymous with mask.
Definition: gcode.h:466
uint32_t t
Tool number.
Definition: gcode.h:488
Axis index to plane assignment.
Definition: gcode.h:405
uint8_t axis_linear
Definition: gcode.h:410
uint8_t axis_0
Definition: gcode.h:408
uint8_t axis_1
Definition: gcode.h:409
Definition: gcode.h:511
uint8_t is_laser_ppi_mode
Definition: gcode.h:515
uint8_t is_rpm_rate_adjusted
Definition: gcode.h:514
uint8_t unassigned
Definition: gcode.h:516
uint8_t value
Definition: gcode.h:512
Definition: spindle_control.h:59