Luigi Santivetti | 69972f9 | 2019-11-12 22:55:40 +0000 | [diff] [blame] | 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 | |
| 23 | |
| 24 | // Sets up valid jog motion received from g-code parser, checks for soft-limits, and executes the jog. |
| 25 | uint8_t jog_execute(plan_line_data_t *pl_data, parser_block_t *gc_block) |
| 26 | { |
| 27 | // Initialize planner data struct for jogging motions. |
| 28 | // NOTE: Spindle and coolant are allowed to fully function with overrides during a jog. |
| 29 | pl_data->feed_rate = gc_block->values.f; |
| 30 | pl_data->condition |= PL_COND_FLAG_NO_FEED_OVERRIDE; |
| 31 | #ifdef USE_LINE_NUMBERS |
| 32 | pl_data->line_number = gc_block->values.n; |
| 33 | #endif |
| 34 | |
| 35 | if (bit_istrue(settings.flags,BITFLAG_SOFT_LIMIT_ENABLE)) { |
| 36 | if (system_check_travel_limits(gc_block->values.xyz)) { return(STATUS_TRAVEL_EXCEEDED); } |
| 37 | } |
| 38 | |
| 39 | // Valid jog command. Plan, set state, and execute. |
| 40 | mc_line(gc_block->values.xyz,pl_data); |
| 41 | if (sys.state == STATE_IDLE) { |
| 42 | if (plan_get_current_block() != NULL) { // Check if there is a block to execute. |
| 43 | sys.state = STATE_JOG; |
| 44 | st_prep_buffer(); |
| 45 | st_wake_up(); // NOTE: Manual start. No state machine required. |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | return(STATUS_OK); |
| 50 | } |