浏览代码

🩹 Fix PRINTCOUNTER with EXTRUDERS 0 (#24063)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
Christian Piper 2 年前
父节点
当前提交
3905234b0d
没有帐户链接到提交者的电子邮件
共有 4 个文件被更改,包括 43 次插入35 次删除
  1. 1
    1
      Marlin/src/gcode/gcode.cpp
  2. 28
    19
      Marlin/src/module/printcounter.cpp
  3. 13
    14
      Marlin/src/module/printcounter.h
  4. 1
    1
      buildroot/tests/mega2560

+ 1
- 1
Marlin/src/gcode/gcode.cpp 查看文件

@@ -210,7 +210,7 @@ void GcodeSuite::get_destination_from_command() {
210 210
   if (parser.floatval('F') > 0)
211 211
     feedrate_mm_s = parser.value_feedrate();
212 212
 
213
-  #if ENABLED(PRINTCOUNTER)
213
+  #if BOTH(PRINTCOUNTER, HAS_EXTRUDERS)
214 214
     if (!DEBUGGING(DRYRUN) && !skip_move)
215 215
       print_job_timer.incFilamentUsed(destination.e - current_position.e);
216 216
   #endif

+ 28
- 19
Marlin/src/module/printcounter.cpp 查看文件

@@ -80,30 +80,36 @@ millis_t PrintCounter::deltaDuration() {
80 80
   return lastDuration - tmp;
81 81
 }
82 82
 
83
-void PrintCounter::incFilamentUsed(float const &amount) {
84
-  TERN_(DEBUG_PRINTCOUNTER, debug(PSTR("incFilamentUsed")));
83
+#if HAS_EXTRUDERS
84
+  void PrintCounter::incFilamentUsed(float const &amount) {
85
+    TERN_(DEBUG_PRINTCOUNTER, debug(PSTR("incFilamentUsed")));
85 86
 
86
-  // Refuses to update data if object is not loaded
87
-  if (!isLoaded()) return;
87
+    // Refuses to update data if object is not loaded
88
+    if (!isLoaded()) return;
88 89
 
89
-  data.filamentUsed += amount; // mm
90
-}
90
+    data.filamentUsed += amount; // mm
91
+  }
92
+#endif
91 93
 
92 94
 void PrintCounter::initStats() {
93 95
   TERN_(DEBUG_PRINTCOUNTER, debug(PSTR("initStats")));
94 96
 
95 97
   loaded = true;
96
-  data = { 0, 0, 0, 0, 0.0
97
-    #if HAS_SERVICE_INTERVALS
98
-      #if SERVICE_INTERVAL_1 > 0
99
-        , SERVICE_INTERVAL_SEC_1
100
-      #endif
101
-      #if SERVICE_INTERVAL_2 > 0
102
-        , SERVICE_INTERVAL_SEC_2
103
-      #endif
104
-      #if SERVICE_INTERVAL_3 > 0
105
-        , SERVICE_INTERVAL_SEC_3
106
-      #endif
98
+
99
+  data = {
100
+      .totalPrints = 0
101
+    , .finishedPrints = 0
102
+    , .printTime = 0
103
+    , .longestPrint = 0
104
+    OPTARG(HAS_EXTRUDERS, .filamentUsed = 0.0)
105
+    #if SERVICE_INTERVAL_1 > 0
106
+      , .nextService1 = SERVICE_INTERVAL_SEC_1
107
+    #endif
108
+    #if SERVICE_INTERVAL_2 > 0
109
+      , .nextService2 = SERVICE_INTERVAL_SEC_2
110
+    #endif
111
+    #if SERVICE_INTERVAL_3 > 0
112
+      , .nextService3 = SERVICE_INTERVAL_SEC_3
107 113
     #endif
108 114
   };
109 115
 
@@ -210,8 +216,11 @@ void PrintCounter::showStats() {
210 216
     SERIAL_CHAR(')');
211 217
   #endif
212 218
 
213
-  SERIAL_ECHOPGM("\n" STR_STATS "Filament used: ", data.filamentUsed / 1000);
214
-  SERIAL_CHAR('m');
219
+  #if HAS_EXTRUDERS
220
+    SERIAL_ECHOPGM("\n" STR_STATS "Filament used: ", data.filamentUsed / 1000);
221
+    SERIAL_CHAR('m');
222
+  #endif
223
+
215 224
   SERIAL_EOL();
216 225
 
217 226
   #if SERVICE_INTERVAL_1 > 0

+ 13
- 14
Marlin/src/module/printcounter.h 查看文件

@@ -37,7 +37,9 @@ struct printStatistics {    // 16 bytes
37 37
   uint16_t finishedPrints;  // Number of complete prints
38 38
   uint32_t printTime;       // Accumulated printing time
39 39
   uint32_t longestPrint;    // Longest successful print job
40
-  float    filamentUsed;    // Accumulated filament consumed in mm
40
+  #if HAS_EXTRUDERS
41
+    float  filamentUsed;    // Accumulated filament consumed in mm
42
+  #endif
41 43
   #if SERVICE_INTERVAL_1 > 0
42 44
     uint32_t nextService1;  // Service intervals (or placeholders)
43 45
   #endif
@@ -52,12 +54,7 @@ struct printStatistics {    // 16 bytes
52 54
 class PrintCounter: public Stopwatch {
53 55
   private:
54 56
     typedef Stopwatch super;
55
-
56
-    #if EITHER(USE_WIRED_EEPROM, CPU_32_BIT)
57
-      typedef uint32_t eeprom_address_t;
58
-    #else
59
-      typedef uint16_t eeprom_address_t;
60
-    #endif
57
+    typedef IF<EITHER(USE_WIRED_EEPROM, CPU_32_BIT), uint32_t, uint16_t>::type eeprom_address_t;
61 58
 
62 59
     static printStatistics data;
63 60
 
@@ -124,13 +121,15 @@ class PrintCounter: public Stopwatch {
124 121
      */
125 122
     FORCE_INLINE static bool isLoaded() { return loaded; }
126 123
 
127
-    /**
128
-     * @brief Increment the total filament used
129
-     * @details The total filament used counter will be incremented by "amount".
130
-     *
131
-     * @param amount The amount of filament used in mm
132
-     */
133
-    static void incFilamentUsed(float const &amount);
124
+    #if HAS_EXTRUDERS
125
+      /**
126
+       * @brief Increment the total filament used
127
+       * @details The total filament used counter will be incremented by "amount".
128
+       *
129
+       * @param amount The amount of filament used in mm
130
+       */
131
+      static void incFilamentUsed(float const &amount);
132
+    #endif
134 133
 
135 134
     /**
136 135
      * @brief Reset the Print Statistics

+ 1
- 1
buildroot/tests/mega2560 查看文件

@@ -193,7 +193,7 @@ opt_set MOTHERBOARD BOARD_RAMPS_14_EFB EXTRUDERS 0 LCD_LANGUAGE en TEMP_SENSOR_C
193 193
         DEFAULT_MAX_ACCELERATION '{ 3000, 3000, 100 }' \
194 194
         MANUAL_FEEDRATE '{ 50*60, 50*60, 4*60 }' \
195 195
         AXIS_RELATIVE_MODES '{ false, false, false }'
196
-opt_enable REPRAP_DISCOUNT_SMART_CONTROLLER SDSUPPORT EEPROM_SETTINGS EEPROM_BOOT_SILENT EEPROM_AUTO_INIT \
196
+opt_enable REPRAP_DISCOUNT_SMART_CONTROLLER SDSUPPORT EEPROM_SETTINGS EEPROM_BOOT_SILENT EEPROM_AUTO_INIT PRINTCOUNTER \
197 197
            LASER_FEATURE AIR_EVACUATION AIR_EVACUATION_PIN AIR_ASSIST AIR_ASSIST_PIN LASER_COOLANT_FLOW_METER I2C_AMMETER
198 198
 exec_test $1 $2 "MEGA2560 RAMPS | Laser Feature | Air Evacuation | Air Assist | Cooler | Flowmeter | 44780 LCD " "$3"
199 199
 

正在加载...
取消
保存