Merge pull request #5908 from thinkyhead/rc_fix_slowdown

General minor cleanup
2.0.x
Scott Lahteine 8 years ago committed by GitHub
commit 9924199802

@ -661,18 +661,12 @@ static bool send_ok[BUFSIZE];
#define KEEPALIVE_STATE(n) ; #define KEEPALIVE_STATE(n) ;
#endif // HOST_KEEPALIVE_FEATURE #endif // HOST_KEEPALIVE_FEATURE
#define DEFINE_PGM_READ_ANY(type, reader) \ static inline float pgm_read_any(const float *p) { return pgm_read_float_near(p); }
static inline type pgm_read_any(const type *p) \ static inline signed char pgm_read_any(const signed char *p) { return pgm_read_byte_near(p); }
{ return pgm_read_##reader##_near(p); }
DEFINE_PGM_READ_ANY(float, float)
DEFINE_PGM_READ_ANY(signed char, byte)
#define XYZ_CONSTS_FROM_CONFIG(type, array, CONFIG) \ #define XYZ_CONSTS_FROM_CONFIG(type, array, CONFIG) \
static const PROGMEM type array##_P[XYZ] = \ static const PROGMEM type array##_P[XYZ] = { X_##CONFIG, Y_##CONFIG, Z_##CONFIG }; \
{ X_##CONFIG, Y_##CONFIG, Z_##CONFIG }; \ static inline type array(AxisEnum axis) { return pgm_read_any(&array##_P[axis]); }
static inline type array(int axis) \
{ return pgm_read_any(&array##_P[axis]); }
XYZ_CONSTS_FROM_CONFIG(float, base_min_pos, MIN_POS) XYZ_CONSTS_FROM_CONFIG(float, base_min_pos, MIN_POS)
XYZ_CONSTS_FROM_CONFIG(float, base_max_pos, MAX_POS) XYZ_CONSTS_FROM_CONFIG(float, base_max_pos, MAX_POS)
@ -848,12 +842,8 @@ static bool drain_injected_commands_P() {
cmd[sizeof(cmd) - 1] = '\0'; cmd[sizeof(cmd) - 1] = '\0';
while ((c = cmd[i]) && c != '\n') i++; // find the end of this gcode command while ((c = cmd[i]) && c != '\n') i++; // find the end of this gcode command
cmd[i] = '\0'; cmd[i] = '\0';
if (shove_and_echo_command(cmd)) { // success? if (shove_and_echo_command(cmd)) // success?
if (c) // newline char? injected_commands_P = c ? injected_commands_P + i + 1 : NULL; // next command or done
injected_commands_P += i + 1; // advance to the next command
else
injected_commands_P = NULL; // nul char? no more commands
}
} }
return (injected_commands_P != NULL); // return whether any more remain return (injected_commands_P != NULL); // return whether any more remain
} }

@ -942,7 +942,7 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
* Having the real displacement of the head, we can calculate the total movement length and apply the desired speed. * Having the real displacement of the head, we can calculate the total movement length and apply the desired speed.
*/ */
#if IS_CORE #if IS_CORE
float delta_mm[7]; float delta_mm[Z_HEAD + 1];
#if CORE_IS_XY #if CORE_IS_XY
delta_mm[X_HEAD] = da * steps_to_mm[A_AXIS]; delta_mm[X_HEAD] = da * steps_to_mm[A_AXIS];
delta_mm[Y_HEAD] = db * steps_to_mm[B_AXIS]; delta_mm[Y_HEAD] = db * steps_to_mm[B_AXIS];
@ -963,7 +963,7 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
delta_mm[C_AXIS] = CORESIGN(db - dc) * steps_to_mm[C_AXIS]; delta_mm[C_AXIS] = CORESIGN(db - dc) * steps_to_mm[C_AXIS];
#endif #endif
#else #else
float delta_mm[4]; float delta_mm[XYZE];
delta_mm[X_AXIS] = da * steps_to_mm[X_AXIS]; delta_mm[X_AXIS] = da * steps_to_mm[X_AXIS];
delta_mm[Y_AXIS] = db * steps_to_mm[Y_AXIS]; delta_mm[Y_AXIS] = db * steps_to_mm[Y_AXIS];
delta_mm[Z_AXIS] = dc * steps_to_mm[Z_AXIS]; delta_mm[Z_AXIS] = dc * steps_to_mm[Z_AXIS];
@ -995,10 +995,10 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
// Slow down when the buffer starts to empty, rather than wait at the corner for a buffer refill // Slow down when the buffer starts to empty, rather than wait at the corner for a buffer refill
#if ENABLED(SLOWDOWN) || ENABLED(ULTRA_LCD) || defined(XY_FREQUENCY_LIMIT) #if ENABLED(SLOWDOWN) || ENABLED(ULTRA_LCD) || defined(XY_FREQUENCY_LIMIT)
// Segment time im micro seconds
unsigned long segment_time = lround(1000000.0 / inverse_mm_s); unsigned long segment_time = lround(1000000.0 / inverse_mm_s);
#endif #endif
#if ENABLED(SLOWDOWN) #if ENABLED(SLOWDOWN)
// Segment time im micro seconds
if (moves_queued > 1 && moves_queued < (BLOCK_BUFFER_SIZE) / 2) { if (moves_queued > 1 && moves_queued < (BLOCK_BUFFER_SIZE) / 2) {
if (segment_time < min_segment_time) { if (segment_time < min_segment_time) {
// buffer is draining, add extra time. The amount of time added increases if the buffer is still emptied more. // buffer is draining, add extra time. The amount of time added increases if the buffer is still emptied more.

@ -414,9 +414,7 @@ class Planner {
#endif #endif
#if ENABLED(AUTOTEMP) #if ENABLED(AUTOTEMP)
static float autotemp_max; static float autotemp_min, autotemp_max, autotemp_factor;
static float autotemp_min;
static float autotemp_factor;
static bool autotemp_enabled; static bool autotemp_enabled;
static void getHighESpeed(); static void getHighESpeed();
static void autotemp_M104_M109(); static void autotemp_M104_M109();

@ -982,9 +982,6 @@ void Temperature::init() {
#if ENABLED(FAST_PWM_FAN) #if ENABLED(FAST_PWM_FAN)
setPwmFrequency(FAN_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8 setPwmFrequency(FAN_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8
#endif #endif
#if ENABLED(FAN_SOFT_PWM)
soft_pwm_fan[0] = fanSpeedSoftPwm[0] >> 1;
#endif
#endif #endif
#if HAS_FAN1 #if HAS_FAN1
@ -992,9 +989,6 @@ void Temperature::init() {
#if ENABLED(FAST_PWM_FAN) #if ENABLED(FAST_PWM_FAN)
setPwmFrequency(FAN1_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8 setPwmFrequency(FAN1_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8
#endif #endif
#if ENABLED(FAN_SOFT_PWM)
soft_pwm_fan[1] = fanSpeedSoftPwm[1] >> 1;
#endif
#endif #endif
#if HAS_FAN2 #if HAS_FAN2
@ -1002,9 +996,6 @@ void Temperature::init() {
#if ENABLED(FAST_PWM_FAN) #if ENABLED(FAST_PWM_FAN)
setPwmFrequency(FAN2_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8 setPwmFrequency(FAN2_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8
#endif #endif
#if ENABLED(FAN_SOFT_PWM)
soft_pwm_fan[2] = fanSpeedSoftPwm[2] >> 1;
#endif
#endif #endif
#if ENABLED(HEATER_0_USES_MAX6675) #if ENABLED(HEATER_0_USES_MAX6675)

Loading…
Cancel
Save