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
   #define KEEPALIVE_STATE(n) ;
661
   #define KEEPALIVE_STATE(n) ;
662
 #endif // HOST_KEEPALIVE_FEATURE
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
 #define XYZ_CONSTS_FROM_CONFIG(type, array, CONFIG) \
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
 XYZ_CONSTS_FROM_CONFIG(float, base_min_pos,   MIN_POS)
671
 XYZ_CONSTS_FROM_CONFIG(float, base_min_pos,   MIN_POS)
678
 XYZ_CONSTS_FROM_CONFIG(float, base_max_pos,   MAX_POS)
672
 XYZ_CONSTS_FROM_CONFIG(float, base_max_pos,   MAX_POS)
848
     cmd[sizeof(cmd) - 1] = '\0';
842
     cmd[sizeof(cmd) - 1] = '\0';
849
     while ((c = cmd[i]) && c != '\n') i++; // find the end of this gcode command
843
     while ((c = cmd[i]) && c != '\n') i++; // find the end of this gcode command
850
     cmd[i] = '\0';
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
   return (injected_commands_P != NULL);    // return whether any more remain
848
   return (injected_commands_P != NULL);    // return whether any more remain
859
 }
849
 }

+ 3
- 3
Marlin/planner.cpp View File

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

+ 0
- 9
Marlin/temperature.cpp View File

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

Loading…
Cancel
Save