gnea\grbl-Mega  1.0f
Source Code Documentation ( Internal Workings )
jog.c
Go to the documentation of this file.
1 /*
2  jog.h - Jogging methods
3  Part of Grbl
4 
5  Copyright (c) 2016 Sungeun K. Jeon for Gnea Research LLC
6 
7  Grbl is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  Grbl is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with Grbl. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #include "grbl.h"
22 
25 {
26 // Initialize planner data struct for jogging motions.
27 //
29  pl_data->feed_rate = gc_block->values.f;
31  pl_data->line_number = gc_block->values.n;
32 
34  if (system_check_travel_limits(gc_block->values.xyz)) { return(STATUS_TRAVEL_EXCEEDED); }
35  }
36 
37 // Valid jog command. Plan, set state, and execute.
38  mc_line(gc_block->values.xyz,pl_data);
39  if (sys.state == STATE_IDLE) {
40  if (plan_get_current_block() != NULL) {
43  st_wake_up();
44  }
46  }
47 
48  return(STATUS_OK);
49 }
plan_block_t * plan_get_current_block()
Returns address of first planner block, if available. Called by various main program functions...
Definition: planner.c:231
#define STATUS_TRAVEL_EXCEEDED
Definition: report.h:38
Planner data prototype. Must be used when passing new motions to the planner.
Definition: planner.h:78
uint8_t jog_execute(plan_line_data_t *pl_data, parser_block_t *gc_block)
Sets up valid jog motion received from g-code parser, checks for soft-limits, and executes the jog...
Definition: jog.c:24
#define BITFLAG_SOFT_LIMIT_ENABLE
Definition: settings.h:40
uint8_t state
Tracks the current system state of Grbl.
Definition: system.h:112
int32_t n
Line number.
Definition: gcode.h:185
void mc_line(float *target, plan_line_data_t *pl_data)
Execute linear motion in absolute millimeter coordinates. Feed rate given in millimeters/second.
gc_values_t values
Definition: gcode.h:217
uint8_t flags
Contains default boolean settings.
Definition: settings.h:92
system_t sys
Declare system global variable structure.
Definition: main.c:25
uint8_t system_check_travel_limits(float *target)
CoreXY calculation only. Returns x or y-axis "steps" based on CoreXY motor steps. ...
Definition: system.c:317
void st_prep_buffer()
Prepares step segment buffer. Continuously called from main program.
Definition: stepper.c:594
void st_wake_up()
BLOCK VELOCITY PROFILE DEFINITION.
Definition: stepper.c:199
int32_t line_number
Desired line number to report when executing.
Definition: planner.h:81
#define PL_COND_FLAG_NO_FEED_OVERRIDE
Motion does not honor feed override.
Definition: planner.h:35
settings_t settings
Definition: settings.c:24
float f
Feed.
Definition: gcode.h:182
float xyz[3]
X,Y,Z Translational axes.
Definition: gcode.h:191
parser_block_t gc_block
Definition: gcode.c:36
#define STATE_JOG
Jogging mode.
Definition: system.h:78
float feed_rate
Desired feed rate for line motion. Value is ignored, if rapid motion.
Definition: planner.h:79
uint8_t condition
Bitflag variable to indicate planner conditions. See defines above.
Definition: planner.h:82
plan_line_data_t * pl_data
Definition: gcode.c:859
#define STATUS_OK
Define Grbl status codes. Valid values (0-255)
Definition: report.h:23
#define STATE_IDLE
Define system state bit map. The state variable primarily tracks the individual functions.
Definition: system.h:72
#define bit_istrue(x, mask)
Definition: nuts_bolts.h:60