Преглед на файлове

Slight size reduction by adding idle()

Scott Lahteine преди 9 години
родител
ревизия
d76a01194d
променени са 4 файла, в които са добавени 27 реда и са изтрити 47 реда
  1. 2
    0
      Marlin/Marlin.h
  2. 20
    34
      Marlin/Marlin_main.cpp
  3. 1
    5
      Marlin/planner.cpp
  4. 4
    8
      Marlin/stepper.cpp

+ 2
- 0
Marlin/Marlin.h Целия файл

@@ -116,6 +116,8 @@ FORCE_INLINE void serialprintPGM(const char *str) {
116 116
 
117 117
 void get_command();
118 118
 
119
+void idle(); // the standard idle routine calls manage_inactivity(false)
120
+
119 121
 void manage_inactivity(bool ignore_stepper_queue=false);
120 122
 
121 123
 #if defined(DUAL_X_CARRIAGE) && HAS_X_ENABLE && HAS_X2_ENABLE

+ 20
- 34
Marlin/Marlin_main.cpp Целия файл

@@ -726,11 +726,8 @@ void loop() {
726 726
     commands_in_queue--;
727 727
     cmd_queue_index_r = (cmd_queue_index_r + 1) % BUFSIZE;
728 728
   }
729
-  // Check heater every n milliseconds
730
-  manage_heater();
731
-  manage_inactivity();
732 729
   checkHitEndstops();
733
-  lcd_update();
730
+  idle();
734 731
 }
735 732
 
736 733
 void gcode_line_error(const char *err, bool doFlush=true) {
@@ -1998,11 +1995,7 @@ inline void gcode_G4() {
1998 1995
 
1999 1996
   if (!lcd_hasstatus()) LCD_MESSAGEPGM(MSG_DWELL);
2000 1997
 
2001
-  while (millis() < codenum) {
2002
-    manage_heater();
2003
-    manage_inactivity();
2004
-    lcd_update();
2005
-  }
1998
+  while (millis() < codenum) idle();
2006 1999
 }
2007 2000
 
2008 2001
 #ifdef FWRETRACT
@@ -2682,9 +2675,7 @@ inline void gcode_G28() {
2682 2675
 
2683 2676
           probePointCounter++;
2684 2677
 
2685
-          manage_heater();
2686
-          manage_inactivity();
2687
-          lcd_update();
2678
+          idle();
2688 2679
 
2689 2680
         } //xProbe
2690 2681
       } //yProbe
@@ -2885,21 +2876,13 @@ inline void gcode_G92() {
2885 2876
     st_synchronize();
2886 2877
     refresh_cmd_timeout();
2887 2878
     if (codenum > 0) {
2888
-      codenum += previous_cmd_ms;  // keep track of when we started waiting
2889
-      while(millis() < codenum && !lcd_clicked()) {
2890
-        manage_heater();
2891
-        manage_inactivity();
2892
-        lcd_update();
2893
-      }
2879
+      codenum += previous_cmd_ms;  // wait until this time for a click
2880
+      while (millis() < codenum && !lcd_clicked()) idle();
2894 2881
       lcd_ignore_click(false);
2895 2882
     }
2896 2883
     else {
2897 2884
       if (!lcd_detected()) return;
2898
-      while (!lcd_clicked()) {
2899
-        manage_heater();
2900
-        manage_inactivity();
2901
-        lcd_update();
2902
-      }
2885
+      while (!lcd_clicked()) idle();
2903 2886
     }
2904 2887
     if (IS_SD_PRINTING)
2905 2888
       LCD_MESSAGEPGM(MSG_RESUMING);
@@ -3525,9 +3508,9 @@ inline void gcode_M109() {
3525 3508
         #endif
3526 3509
         temp_ms = millis();
3527 3510
       }
3528
-      manage_heater();
3529
-      manage_inactivity();
3530
-      lcd_update();
3511
+
3512
+      idle();
3513
+
3531 3514
       #ifdef TEMP_RESIDENCY_TIME
3532 3515
         // start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first time
3533 3516
         // or when current temp falls outside the hysteresis after target temp was reached
@@ -3575,9 +3558,7 @@ inline void gcode_M109() {
3575 3558
         SERIAL_PROTOCOL_F(degBed(), 1);
3576 3559
         SERIAL_EOL;
3577 3560
       }
3578
-      manage_heater();
3579
-      manage_inactivity();
3580
-      lcd_update();
3561
+      idle();
3581 3562
     }
3582 3563
     LCD_MESSAGEPGM(MSG_BED_DONE);
3583 3564
     refresh_cmd_timeout();
@@ -4262,11 +4243,7 @@ inline void gcode_M226() {
4262 4243
             break;
4263 4244
         }
4264 4245
 
4265
-        while(digitalRead(pin_number) != target) {
4266
-          manage_heater();
4267
-          manage_inactivity();
4268
-          lcd_update();
4269
-        }
4246
+        while (digitalRead(pin_number) != target) idle();
4270 4247
 
4271 4248
       } // pin_number > -1
4272 4249
     } // pin_state -1 0 1
@@ -6254,6 +6231,15 @@ void disable_all_steppers() {
6254 6231
 }
6255 6232
 
6256 6233
 /**
6234
+ * Standard idle routine keeps the machine alive
6235
+ */
6236
+void idle() {
6237
+  manage_heater();
6238
+  manage_inactivity();
6239
+  lcd_update();
6240
+}
6241
+
6242
+/**
6257 6243
  * Manage several activities:
6258 6244
  *  - Check for Filament Runout
6259 6245
  *  - Keep the command buffer full

+ 1
- 5
Marlin/planner.cpp Целия файл

@@ -478,11 +478,7 @@ float junction_deviation = 0.1;
478 478
 
479 479
   // If the buffer is full: good! That means we are well ahead of the robot. 
480 480
   // Rest here until there is room in the buffer.
481
-  while(block_buffer_tail == next_buffer_head) {
482
-    manage_heater(); 
483
-    manage_inactivity(); 
484
-    lcd_update();
485
-  }
481
+  while (block_buffer_tail == next_buffer_head) idle();
486 482
 
487 483
   #ifdef MESH_BED_LEVELING
488 484
     if (mbl.active) z += mbl.get_z(x, y);

+ 4
- 8
Marlin/stepper.cpp Целия файл

@@ -1046,14 +1046,10 @@ void st_init() {
1046 1046
 }
1047 1047
 
1048 1048
 
1049
-// Block until all buffered steps are executed
1050
-void st_synchronize() {
1051
-  while (blocks_queued()) {
1052
-    manage_heater();
1053
-    manage_inactivity();
1054
-    lcd_update();
1055
-  }
1056
-}
1049
+/**
1050
+ * Block until all buffered steps are executed
1051
+ */
1052
+void st_synchronize() { while (blocks_queued()) idle(); }
1057 1053
 
1058 1054
 void st_set_position(const long &x, const long &y, const long &z, const long &e) {
1059 1055
   CRITICAL_SECTION_START;

Loading…
Отказ
Запис