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