mirror of
https://github.com/grblHAL/core.git
synced 2026-02-06 00:52:35 +08:00
Cleaned up the Switchcase coder after the debugging mess (thanks terje!) added the line for initilizing the acceleration_factor, renamed acceleration_profiles variable to acceleration_factor to match the rest of the code
This commit is contained in:
32
gcode.c
32
gcode.c
@@ -362,7 +362,7 @@ void gc_init (bool stop)
|
||||
ngc_modal_state_invalidate();
|
||||
#endif
|
||||
#if ENABLE_ACCELERATION_PROFILES
|
||||
gc_state.modal.acceleration_profile = 1.0f; // Initialize machine with 100% Profile
|
||||
gc_state.modal.acceleration_factor = 1.0f; // Initialize machine with 100% Profile
|
||||
#endif
|
||||
|
||||
// if(settings.flags.lathe_mode)
|
||||
@@ -2373,26 +2373,13 @@ status_code_t gc_execute_block (char *block)
|
||||
|
||||
#if ENABLE_ACCELERATION_PROFILES
|
||||
case NonModal_SetAccelerationProfile:
|
||||
if (gc_block.words.e) {
|
||||
if(gc_block.words.e)
|
||||
FAIL(Status_GcodeUnsupportedCommand);
|
||||
break;
|
||||
}
|
||||
else if (!gc_block.words.p) {
|
||||
gc_block.values.p = 1.0f;
|
||||
gc_state.modal.acceleration_profile = gc_block.values.p;
|
||||
gc_block.words.p = Off;
|
||||
break;
|
||||
}
|
||||
else if (gc_block.values.p < 1.0f) {
|
||||
FAIL(Status_NegativeValue);
|
||||
break;
|
||||
}
|
||||
else if (gc_block.values.p > 5.0f) {
|
||||
FAIL(Status_GcodeValueOutOfRange);
|
||||
break;
|
||||
}
|
||||
else
|
||||
gc_state.modal.acceleration_profile = gc_block.values.p;
|
||||
|
||||
if(gc_block.words.p && (gc_block.values.p < 1.0f || gc_block.values.p > 5.0f))
|
||||
FAIL(Status_GcodeValueOutOfRange);
|
||||
|
||||
gc_state.modal.acceleration_factor = lookupfactor(gc_block.words.p ? (uint8_t)gc_block.values.p - 1 : 0);
|
||||
gc_block.words.p = Off;
|
||||
break;
|
||||
#endif
|
||||
@@ -3067,6 +3054,9 @@ status_code_t gc_execute_block (char *block)
|
||||
memset(&plan_data, 0, sizeof(plan_line_data_t)); // Zero plan_data struct
|
||||
plan_data.offset_id = gc_state.offset_id;
|
||||
plan_data.condition.target_validated = plan_data.condition.target_valid = sys.soft_limits.mask == 0;
|
||||
#if ENABLE_ACCELERATION_PROFILES
|
||||
plan_data.acceleration_factor = gc_state.modal.acceleration_factor;
|
||||
#endif
|
||||
|
||||
// Intercept jog commands and complete error checking for valid jog commands and execute.
|
||||
// NOTE: G-code parser state is not updated, except the position to ensure sequential jog
|
||||
@@ -3857,7 +3847,7 @@ status_code_t gc_execute_block (char *block)
|
||||
gc_state.modal.override_ctrl.feed_rate_disable = Off;
|
||||
gc_state.modal.override_ctrl.spindle_rpm_disable = Off;
|
||||
#if ENABLE_ACCELERATION_PROFILES
|
||||
gc_state.modal.acceleration_profile = 1.0f;
|
||||
gc_state.modal.acceleration_factor = 1.0f;
|
||||
#endif
|
||||
|
||||
#if N_SYS_SPINDLE > 1
|
||||
|
||||
2
gcode.h
2
gcode.h
@@ -547,7 +547,7 @@ typedef struct {
|
||||
float feed_rate; //!< {F} NOTE: only set when saving modal state
|
||||
#endif
|
||||
#if ENABLE_ACCELERATION_PROFILES
|
||||
float acceleration_profile; //!< {G187} currently active acceleration profile
|
||||
float acceleration_factor; //!< {G187} currently active factor of acceleration profile
|
||||
#endif
|
||||
} gc_modal_t;
|
||||
|
||||
|
||||
@@ -528,7 +528,7 @@ bool plan_buffer_line (float *target, plan_line_data_t *pl_data)
|
||||
#if ENABLE_ACCELERATION_PROFILES // recalculate the acceleration limits when enabled.
|
||||
block->acceleration_factor = pl_data->acceleration_factor;
|
||||
#if ENABLE_JERK_ACCELERATION
|
||||
block->max_acceleration *= block->acceleration_factor;
|
||||
block->max_acceleration *= block->acceleration_factor;
|
||||
block->jerk *= block->acceleration_factor;
|
||||
#else
|
||||
block->acceleration *= block->acceleration_factor;
|
||||
@@ -739,6 +739,6 @@ void plan_data_init (plan_line_data_t *plan_data)
|
||||
plan_data->rate_multiplier = 1.0f;
|
||||
#endif
|
||||
#ifdef ENABLE_ACCELERATION_PROFILES
|
||||
plan_data->acceleration_factor = lookupfactor((int)gc_state.modal.acceleration_profile-1); //-1 for Array[0]
|
||||
plan_data->acceleration_factor = 1.0f;
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user