Sergey Pastor / grbl1
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers jog.c Source File

jog.c

00001 /*
00002 jog.h - Jogging methods
00003 Part of Grbl
00004 
00005 Copyright (c) 2016 Sungeun K. Jeon for Gnea Research LLC
00006 
00007 Grbl is free software: you can redistribute it and/or modify
00008 it under the terms of the GNU General Public License as published by
00009 the Free Software Foundation, either version 3 of the License, or
00010 (at your option) any later version.
00011 
00012 Grbl is distributed in the hope that it will be useful,
00013 but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Grbl.  If not, see <http://www.gnu.org/licenses/>.
00019 */
00020 
00021 #include "grbl.h"
00022 
00023 
00024 // Sets up valid jog motion received from g-code parser, checks for soft-limits, and executes the jog.
00025 uint8_t jog_execute(plan_line_data_t *pl_data, parser_block_t *gc_block)
00026 {
00027   // Initialize planner data struct for jogging motions.
00028   // NOTE: Spindle and coolant are allowed to fully function with overrides during a jog.
00029   pl_data->feed_rate = gc_block->values.f;
00030   pl_data->condition |= PL_COND_FLAG_NO_FEED_OVERRIDE;
00031 #ifdef USE_LINE_NUMBERS
00032   pl_data->line_number = gc_block->values.n;
00033 #endif
00034 
00035   if (bit_istrue(settings.flags, BITFLAG_SOFT_LIMIT_ENABLE)) {
00036     if (system_check_travel_limits(gc_block->values.xyz)) { return(STATUS_TRAVEL_EXCEEDED); }
00037   }
00038 
00039   // Valid jog command. Plan, set state, and execute.
00040   mc_line(gc_block->values.xyz, pl_data);
00041   if (sys.state == STATE_IDLE) {
00042     if (plan_get_current_block() != NULL) { // Check if there is a block to execute.
00043       sys.state = STATE_JOG;
00044       st_prep_buffer();
00045       st_wake_up();  // NOTE: Manual start. No state machine required.
00046     }
00047   }
00048 
00049   return(STATUS_OK);
00050 }