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