Преглед изворни кода

Merge pull request #2170 from thinkyhead/beep_M600_elsewise

Slight size reduction by adding idle()
AnHardt пре 10 година
родитељ
комит
9d2a980bcf
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
 
116
 
117
 void get_command();
117
 void get_command();
118
 
118
 
119
+void idle(); // the standard idle routine calls manage_inactivity(false)
120
+
119
 void manage_inactivity(bool ignore_stepper_queue=false);
121
 void manage_inactivity(bool ignore_stepper_queue=false);
120
 
122
 
121
 #if defined(DUAL_X_CARRIAGE) && HAS_X_ENABLE && HAS_X2_ENABLE
123
 #if defined(DUAL_X_CARRIAGE) && HAS_X_ENABLE && HAS_X2_ENABLE

+ 20
- 34
Marlin/Marlin_main.cpp Прегледај датотеку

726
     commands_in_queue--;
726
     commands_in_queue--;
727
     cmd_queue_index_r = (cmd_queue_index_r + 1) % BUFSIZE;
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
   checkHitEndstops();
729
   checkHitEndstops();
733
-  lcd_update();
730
+  idle();
734
 }
731
 }
735
 
732
 
736
 void gcode_line_error(const char *err, bool doFlush=true) {
733
 void gcode_line_error(const char *err, bool doFlush=true) {
1998
 
1995
 
1999
   if (!lcd_hasstatus()) LCD_MESSAGEPGM(MSG_DWELL);
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
 #ifdef FWRETRACT
2001
 #ifdef FWRETRACT
2682
 
2675
 
2683
           probePointCounter++;
2676
           probePointCounter++;
2684
 
2677
 
2685
-          manage_heater();
2686
-          manage_inactivity();
2687
-          lcd_update();
2678
+          idle();
2688
 
2679
 
2689
         } //xProbe
2680
         } //xProbe
2690
       } //yProbe
2681
       } //yProbe
2885
     st_synchronize();
2876
     st_synchronize();
2886
     refresh_cmd_timeout();
2877
     refresh_cmd_timeout();
2887
     if (codenum > 0) {
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
       lcd_ignore_click(false);
2881
       lcd_ignore_click(false);
2895
     }
2882
     }
2896
     else {
2883
     else {
2897
       if (!lcd_detected()) return;
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
     if (IS_SD_PRINTING)
2887
     if (IS_SD_PRINTING)
2905
       LCD_MESSAGEPGM(MSG_RESUMING);
2888
       LCD_MESSAGEPGM(MSG_RESUMING);
3522
         #endif
3505
         #endif
3523
         temp_ms = millis();
3506
         temp_ms = millis();
3524
       }
3507
       }
3525
-      manage_heater();
3526
-      manage_inactivity();
3527
-      lcd_update();
3508
+
3509
+      idle();
3510
+
3528
       #ifdef TEMP_RESIDENCY_TIME
3511
       #ifdef TEMP_RESIDENCY_TIME
3529
         // start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first time
3512
         // start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first time
3530
         // or when current temp falls outside the hysteresis after target temp was reached
3513
         // or when current temp falls outside the hysteresis after target temp was reached
3572
         SERIAL_PROTOCOL_F(degBed(), 1);
3555
         SERIAL_PROTOCOL_F(degBed(), 1);
3573
         SERIAL_EOL;
3556
         SERIAL_EOL;
3574
       }
3557
       }
3575
-      manage_heater();
3576
-      manage_inactivity();
3577
-      lcd_update();
3558
+      idle();
3578
     }
3559
     }
3579
     LCD_MESSAGEPGM(MSG_BED_DONE);
3560
     LCD_MESSAGEPGM(MSG_BED_DONE);
3580
     refresh_cmd_timeout();
3561
     refresh_cmd_timeout();
4253
             break;
4234
             break;
4254
         }
4235
         }
4255
 
4236
 
4256
-        while(digitalRead(pin_number) != target) {
4257
-          manage_heater();
4258
-          manage_inactivity();
4259
-          lcd_update();
4260
-        }
4237
+        while (digitalRead(pin_number) != target) idle();
4261
 
4238
 
4262
       } // pin_number > -1
4239
       } // pin_number > -1
4263
     } // pin_state -1 0 1
4240
     } // pin_state -1 0 1
6243
 }
6220
 }
6244
 
6221
 
6245
 /**
6222
 /**
6223
+ * Standard idle routine keeps the machine alive
6224
+ */
6225
+void idle() {
6226
+  manage_heater();
6227
+  manage_inactivity();
6228
+  lcd_update();
6229
+}
6230
+
6231
+/**
6246
  * Manage several activities:
6232
  * Manage several activities:
6247
  *  - Check for Filament Runout
6233
  *  - Check for Filament Runout
6248
  *  - Keep the command buffer full
6234
  *  - Keep the command buffer full

+ 1
- 5
Marlin/planner.cpp Прегледај датотеку

478
 
478
 
479
   // If the buffer is full: good! That means we are well ahead of the robot. 
479
   // If the buffer is full: good! That means we are well ahead of the robot. 
480
   // Rest here until there is room in the buffer.
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
   #ifdef MESH_BED_LEVELING
483
   #ifdef MESH_BED_LEVELING
488
     if (mbl.active) z += mbl.get_z(x, y);
484
     if (mbl.active) z += mbl.get_z(x, y);

+ 4
- 8
Marlin/stepper.cpp Прегледај датотеку

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
 void st_set_position(const long &x, const long &y, const long &z, const long &e) {
1054
 void st_set_position(const long &x, const long &y, const long &z, const long &e) {
1059
   CRITICAL_SECTION_START;
1055
   CRITICAL_SECTION_START;

Loading…
Откажи
Сачувај