Browse Source

Merge pull request #5908 from thinkyhead/rc_fix_slowdown

General minor cleanup
Scott Lahteine 8 years ago
parent
commit
9924199802
4 changed files with 10 additions and 31 deletions
  1. 6
    16
      Marlin/Marlin_main.cpp
  2. 3
    3
      Marlin/planner.cpp
  3. 1
    3
      Marlin/planner.h
  4. 0
    9
      Marlin/temperature.cpp

+ 6
- 16
Marlin/Marlin_main.cpp View File

@@ -661,18 +661,12 @@ static bool send_ok[BUFSIZE];
661 661
   #define KEEPALIVE_STATE(n) ;
662 662
 #endif // HOST_KEEPALIVE_FEATURE
663 663
 
664
-#define DEFINE_PGM_READ_ANY(type, reader)       \
665
-  static inline type pgm_read_any(const type *p)  \
666
-  { return pgm_read_##reader##_near(p); }
667
-
668
-DEFINE_PGM_READ_ANY(float,       float)
669
-DEFINE_PGM_READ_ANY(signed char, byte)
664
+static inline float pgm_read_any(const float *p) { return pgm_read_float_near(p); }
665
+static inline signed char pgm_read_any(const signed char *p) { return pgm_read_byte_near(p); }
670 666
 
671 667
 #define XYZ_CONSTS_FROM_CONFIG(type, array, CONFIG) \
672
-  static const PROGMEM type array##_P[XYZ] =        \
673
-      { X_##CONFIG, Y_##CONFIG, Z_##CONFIG };     \
674
-  static inline type array(int axis)          \
675
-  { return pgm_read_any(&array##_P[axis]); }
668
+  static const PROGMEM type array##_P[XYZ] = { X_##CONFIG, Y_##CONFIG, Z_##CONFIG }; \
669
+  static inline type array(AxisEnum axis) { return pgm_read_any(&array##_P[axis]); }
676 670
 
677 671
 XYZ_CONSTS_FROM_CONFIG(float, base_min_pos,   MIN_POS)
678 672
 XYZ_CONSTS_FROM_CONFIG(float, base_max_pos,   MAX_POS)
@@ -848,12 +842,8 @@ static bool drain_injected_commands_P() {
848 842
     cmd[sizeof(cmd) - 1] = '\0';
849 843
     while ((c = cmd[i]) && c != '\n') i++; // find the end of this gcode command
850 844
     cmd[i] = '\0';
851
-    if (shove_and_echo_command(cmd)) {     // success?
852
-      if (c)                               // newline char?
853
-        injected_commands_P += i + 1;      // advance to the next command
854
-      else
855
-        injected_commands_P = NULL;        // nul char? no more commands
856
-    }
845
+    if (shove_and_echo_command(cmd))       // success?
846
+      injected_commands_P = c ? injected_commands_P + i + 1 : NULL; // next command or done
857 847
   }
858 848
   return (injected_commands_P != NULL);    // return whether any more remain
859 849
 }

+ 3
- 3
Marlin/planner.cpp View File

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

+ 1
- 3
Marlin/planner.h View File

@@ -414,9 +414,7 @@ class Planner {
414 414
     #endif
415 415
 
416 416
     #if ENABLED(AUTOTEMP)
417
-      static float autotemp_max;
418
-      static float autotemp_min;
419
-      static float autotemp_factor;
417
+      static float autotemp_min, autotemp_max, autotemp_factor;
420 418
       static bool autotemp_enabled;
421 419
       static void getHighESpeed();
422 420
       static void autotemp_M104_M109();

+ 0
- 9
Marlin/temperature.cpp View File

@@ -982,9 +982,6 @@ void Temperature::init() {
982 982
     #if ENABLED(FAST_PWM_FAN)
983 983
       setPwmFrequency(FAN_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8
984 984
     #endif
985
-    #if ENABLED(FAN_SOFT_PWM)
986
-      soft_pwm_fan[0] = fanSpeedSoftPwm[0] >> 1;
987
-    #endif
988 985
   #endif
989 986
 
990 987
   #if HAS_FAN1
@@ -992,9 +989,6 @@ void Temperature::init() {
992 989
     #if ENABLED(FAST_PWM_FAN)
993 990
       setPwmFrequency(FAN1_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8
994 991
     #endif
995
-    #if ENABLED(FAN_SOFT_PWM)
996
-      soft_pwm_fan[1] = fanSpeedSoftPwm[1] >> 1;
997
-    #endif
998 992
   #endif
999 993
 
1000 994
   #if HAS_FAN2
@@ -1002,9 +996,6 @@ void Temperature::init() {
1002 996
     #if ENABLED(FAST_PWM_FAN)
1003 997
       setPwmFrequency(FAN2_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8
1004 998
     #endif
1005
-    #if ENABLED(FAN_SOFT_PWM)
1006
-      soft_pwm_fan[2] = fanSpeedSoftPwm[2] >> 1;
1007
-    #endif
1008 999
   #endif
1009 1000
 
1010 1001
   #if ENABLED(HEATER_0_USES_MAX6675)

Loading…
Cancel
Save