diff --git a/gcode.c b/gcode.c index 7f6b495..b691687 100644 --- a/gcode.c +++ b/gcode.c @@ -325,6 +325,9 @@ void gc_init (void) #if NGC_PARAMETERS_ENABLE ngc_modal_state_invalidate(); #endif +#if ENABLE_ACCELERATION_PROFILES + gc_state.modal.activeaccelprofile = 1.0f; // Initialize machine with 100% Profile +#endif // if(settings.flags.lathe_mode) // gc_state.modal.plane_select = PlaneSelect_ZX; @@ -2448,13 +2451,16 @@ status_code_t gc_execute_block (char *block) #if ENABLE_ACCELERATION_PROFILES case NonModal_SetAccelerationProfile: - if (!gc_block.values.p){ + if (gc_block.words.e){ + FAIL(Status_GcodeUnsupportedCommand); + break;} + else if (!gc_block.word.p){ gc_block.values.p = 1.0f;} else if (gc_block.values.p < 1.0f){ FAIL(Status_NegativeValue);} else if (gc_block.values.p > 5.0f){ FAIL(Status_GcodeValueOutOfRange);} - ActiveAccelProfile = gc_block.values.p; + gc_state.modal.activeaccelprofile = gc_block.values.p; break; #endif default: @@ -3874,6 +3880,9 @@ status_code_t gc_execute_block (char *block) gc_state.modal.coolant = (coolant_state_t){0}; 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.activeaccelprofile = 1.0f; + #endif idx = N_SYS_SPINDLE; spindle_ptrs_t *spindle; diff --git a/planner.c b/planner.c index ab8372e..0799e7a 100644 --- a/planner.c +++ b/planner.c @@ -349,7 +349,7 @@ static inline float limit_acceleration_by_axis_maximum (float *unit_vec) limit_value = min(limit_value, fabsf(settings.axis[idx].acceleration / unit_vec[idx])); } while(idx); #if ENABLE_ACCELERATION_PROFILES - limit_value *= LookupProfile(ActiveAccelProfile); + limit_value *= lookupprofile(gc_state.modal.activeaccelprofile); #endif return limit_value; } @@ -365,7 +365,7 @@ static inline float limit_jerk_by_axis_maximum (float *unit_vec) limit_value = min(limit_value, fabsf(settings.axis[idx].jerk / unit_vec[idx])); } while(idx); #if ENABLE_ACCELERATION_PROFILES - limit_value *= LookupProfile(ActiveAccelProfile); + limit_value *= lookupprofile(gc_state.modal.activeaccelprofile); #endif return limit_value; } diff --git a/settings.c b/settings.c index ae05b7c..b307888 100644 --- a/settings.c +++ b/settings.c @@ -805,7 +805,7 @@ PROGMEM static const setting_descr_t setting_descr[] = { #if ENABLE_JERK_ACCELERATION { Setting_AxisJerk, "Maximum rate of acceleration change - smoothes out acceleration profile up to max axis acceleration.\\n\\n" "Minimum value of x10 Acceleration setting to ensure decent acceleration times.\\n" - "Maximum is calcualted by current acceleration and stepper segment time.\\n" + "Maximum is calculated by current acceleration and stepper segment time.\\n" "At Maximum value motion is effectively trapezoidal instead of constant jerk.\\n\\n" "Can be increased by adjusting ACCELERATION_TICKS_PER_SECOND to a larger value before compiling."}, #endif @@ -932,10 +932,8 @@ bool settings_override_acceleration (uint8_t axis, float acceleration) } #if ENABLE_ACCELERATION_PROFILES -ActiveAccelProfile = 1; // Initialize machine with 100% Profile - //Acceleration Profiles for G187 P[x] in percent of maximum machine acceleration. -float LookupProfile(uint8_t Profile) { +float lookupprofile(uint8_t profile) { static const float lookup[5] = { 1.0f, // 100% - Roughing - Max Acceleration Default 0.8f, // 80% - Semi Roughing @@ -943,8 +941,7 @@ float LookupProfile(uint8_t Profile) { 0.4f, // 40% - Finish 0.2f, // 20% - Slow AF Mode }; - Profile = lookup[Profile]; - return Profile; + return lookup[profile]; } #endif