mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-09-02 10:53:01 +02:00
sys_pl_data_inflight -> mc_pl_data_inflight
It seemed pretty strange to have a variable that is only used in MotionControl.cpp with a name like sys_ . Now it is private to MotionControl.cpp
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
#include "Protocol.h"
|
||||
#include "System.h"
|
||||
#include "Uart.h"
|
||||
#include "MotionControl.h"
|
||||
|
||||
#include "WebUI/WifiConfig.h"
|
||||
#include "WebUI/InputBuffer.h"
|
||||
@@ -157,10 +158,7 @@ static void reset_variables() {
|
||||
plan_sync_position();
|
||||
gc_sync_position();
|
||||
report_init_message(CLIENT_ALL);
|
||||
|
||||
// used to keep track of a jog command sent to mc_line() so we can cancel it.
|
||||
// this is needed if a jogCancel comes along after we have already parsed a jog and it is in-flight.
|
||||
sys_pl_data_inflight = NULL;
|
||||
mc_init();
|
||||
}
|
||||
|
||||
void run_once() {
|
||||
|
@@ -42,6 +42,14 @@
|
||||
|
||||
GangMask ganged_mode = gangDual; // Run both motors at once
|
||||
|
||||
// mc_pl_data_inflight keeps track of a jog command sent to mc_line() so we can cancel it.
|
||||
// this is needed if a jogCancel comes along after we have already parsed a jog and it is in-flight.
|
||||
static volatile void* mc_pl_data_inflight; // holds a plan_line_data_t while cartesian_to_motors has taken ownership of a line motion
|
||||
|
||||
void mc_init() {
|
||||
mc_pl_data_inflight = NULL;
|
||||
}
|
||||
|
||||
// Execute linear motion in absolute millimeter coordinates. Feed rate given in millimeters/second
|
||||
// unless invert_feed_rate is true. Then the feed_rate means that the motion should be completed in
|
||||
// (1 minute)/feed_rate time.
|
||||
@@ -53,7 +61,7 @@ GangMask ganged_mode = gangDual; // Run both motors at once
|
||||
bool mc_line(float* target, plan_line_data_t* pl_data) {
|
||||
bool submitted_result = false;
|
||||
// store the plan data so it can be cancelled by the protocol system if needed
|
||||
sys_pl_data_inflight = pl_data;
|
||||
mc_pl_data_inflight = pl_data;
|
||||
|
||||
// If enabled, check for soft limit violations. Placed here all line motions are picked up
|
||||
// from everywhere in Grbl.
|
||||
@@ -66,7 +74,7 @@ bool mc_line(float* target, plan_line_data_t* pl_data) {
|
||||
}
|
||||
// If in check gcode mode, prevent motion by blocking planner. Soft limits still work.
|
||||
if (sys.state == State::CheckMode) {
|
||||
sys_pl_data_inflight = NULL;
|
||||
mc_pl_data_inflight = NULL;
|
||||
return submitted_result; // Bail, if system abort.
|
||||
}
|
||||
// NOTE: Backlash compensation may be installed here. It will need direction info to track when
|
||||
@@ -87,7 +95,7 @@ bool mc_line(float* target, plan_line_data_t* pl_data) {
|
||||
do {
|
||||
protocol_execute_realtime(); // Check for any run-time commands
|
||||
if (sys.abort) {
|
||||
sys_pl_data_inflight = NULL;
|
||||
mc_pl_data_inflight = NULL;
|
||||
return submitted_result; // Bail, if system abort.
|
||||
}
|
||||
if (plan_check_full_buffer()) {
|
||||
@@ -97,14 +105,20 @@ bool mc_line(float* target, plan_line_data_t* pl_data) {
|
||||
}
|
||||
} while (1);
|
||||
// Plan and queue motion into planner buffer
|
||||
if (sys_pl_data_inflight == pl_data) {
|
||||
if (mc_pl_data_inflight == pl_data) {
|
||||
plan_buffer_line(target, pl_data);
|
||||
submitted_result = true;
|
||||
}
|
||||
sys_pl_data_inflight = NULL;
|
||||
mc_pl_data_inflight = NULL;
|
||||
return submitted_result;
|
||||
}
|
||||
|
||||
void mc_cancel_jog() {
|
||||
if (mc_pl_data_inflight != NULL && ((plan_line_data_t*)mc_pl_data_inflight)->is_jog) {
|
||||
mc_pl_data_inflight = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool __attribute__((weak)) cartesian_to_motors(float* target, plan_line_data_t* pl_data, float* position) {
|
||||
return mc_line(target, pl_data);
|
||||
}
|
||||
|
@@ -74,6 +74,10 @@ void mc_parking_motion(float* parking_target, plan_line_data_t* pl_data);
|
||||
// Performs system reset. If in motion state, kills all motion and sets system alarm.
|
||||
void mc_reset();
|
||||
|
||||
void mc_cancel_jog();
|
||||
|
||||
void mc_init();
|
||||
|
||||
typedef uint8_t GangMask;
|
||||
const GangMask gangA = bit(0);
|
||||
const GangMask gangB = bit(1);
|
||||
|
@@ -1028,8 +1028,8 @@ static void protocol_exec_rt_suspend() {
|
||||
// if a jogCancel comes in and we have a jog "in-flight" (parsed and handed over to mc_line()),
|
||||
// then we need to cancel it before it reaches the planner. otherwise we may try to move way out of
|
||||
// normal bounds, especially with senders that issue a series of jog commands before sending a cancel.
|
||||
if (sys.suspend.bit.jogCancel && sys_pl_data_inflight != NULL && ((plan_line_data_t*)sys_pl_data_inflight)->is_jog) {
|
||||
sys_pl_data_inflight = NULL;
|
||||
if (sys.suspend.bit.jogCancel) {
|
||||
mc_cancel_jog();
|
||||
}
|
||||
// Block until initial hold is complete and the machine has stopped motion.
|
||||
if (sys.suspend.bit.holdComplete) {
|
||||
|
@@ -52,7 +52,6 @@ volatile bool rtButtonMacro0;
|
||||
volatile bool rtButtonMacro1;
|
||||
volatile bool rtButtonMacro2;
|
||||
volatile bool rtButtonMacro3;
|
||||
volatile void* sys_pl_data_inflight; // holds a plan_line_data_t while cartesian_to_motors has taken ownership of a line motion
|
||||
#ifdef DEBUG_REPORT_REALTIME
|
||||
volatile bool sys_rt_exec_debug;
|
||||
#endif
|
||||
|
@@ -134,7 +134,6 @@ extern volatile bool rtButtonMacro0;
|
||||
extern volatile bool rtButtonMacro1;
|
||||
extern volatile bool rtButtonMacro2;
|
||||
extern volatile bool rtButtonMacro3;
|
||||
extern volatile void* sys_pl_data_inflight; // holds a plan_line_data_t while cartesian_to_motors has taken ownership of a line motion
|
||||
#ifdef DEBUG_REPORT_REALTIME
|
||||
extern volatile bool sys_rt_exec_debug;
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user