Bladeren bron

Move temperature reporting to Temperature class

Scott Lahteine 6 jaren geleden
bovenliggende
commit
5d01a2f467
5 gewijzigde bestanden met toevoegingen van 115 en 101 verwijderingen
  1. 2
    2
      Marlin/G26_Mesh_Validation_Tool.cpp
  2. 0
    4
      Marlin/Marlin.h
  3. 7
    95
      Marlin/Marlin_main.cpp
  4. 92
    0
      Marlin/temperature.cpp
  5. 14
    0
      Marlin/temperature.h

+ 2
- 2
Marlin/G26_Mesh_Validation_Tool.cpp Bestand weergeven

@@ -519,7 +519,7 @@
519 519
 
520 520
             if (ELAPSED(millis(), next)) {
521 521
               next = millis() + 5000UL;
522
-              print_heaterstates();
522
+              thermalManager.print_heaterstates();
523 523
               SERIAL_EOL();
524 524
             }
525 525
             idle();
@@ -541,7 +541,7 @@
541 541
 
542 542
       if (ELAPSED(millis(), next)) {
543 543
         next = millis() + 5000UL;
544
-        print_heaterstates();
544
+        thermalManager.print_heaterstates();
545 545
         SERIAL_EOL();
546 546
       }
547 547
       idle();

+ 0
- 4
Marlin/Marlin.h Bestand weergeven

@@ -457,10 +457,6 @@ void report_current_position();
457 457
 // Handling multiple extruders pins
458 458
 extern uint8_t active_extruder;
459 459
 
460
-#if HAS_TEMP_HOTEND || HAS_TEMP_BED
461
-  void print_heaterstates();
462
-#endif
463
-
464 460
 #if ENABLED(MIXING_EXTRUDER)
465 461
   extern float mixing_factor[MIXING_STEPPERS];
466 462
 #endif

+ 7
- 95
Marlin/Marlin_main.cpp Bestand weergeven

@@ -519,7 +519,7 @@ static millis_t stepper_inactive_time = (DEFAULT_STEPPER_DEACTIVE_TIME) * 1000UL
519 519
   #define BUZZ(d,f) NOOP
520 520
 #endif
521 521
 
522
-static uint8_t target_extruder;
522
+uint8_t target_extruder;
523 523
 
524 524
 #if HAS_BED_PROBE
525 525
   float zprobe_zoffset; // Initialized by settings.load()
@@ -7570,80 +7570,6 @@ inline void gcode_M104() {
7570 7570
   #endif
7571 7571
 }
7572 7572
 
7573
-#if HAS_TEMP_HOTEND || HAS_TEMP_BED
7574
-
7575
-  void print_heater_state(const float &c, const float &t,
7576
-    #if ENABLED(SHOW_TEMP_ADC_VALUES)
7577
-      const float r,
7578
-    #endif
7579
-    const int8_t e=-2
7580
-  ) {
7581
-    #if !(HAS_TEMP_BED && HAS_TEMP_HOTEND) && HOTENDS <= 1
7582
-      UNUSED(e);
7583
-    #endif
7584
-
7585
-    SERIAL_PROTOCOLCHAR(' ');
7586
-    SERIAL_PROTOCOLCHAR(
7587
-      #if HAS_TEMP_BED && HAS_TEMP_HOTEND
7588
-        e == -1 ? 'B' : 'T'
7589
-      #elif HAS_TEMP_HOTEND
7590
-        'T'
7591
-      #else
7592
-        'B'
7593
-      #endif
7594
-    );
7595
-    #if HOTENDS > 1
7596
-      if (e >= 0) SERIAL_PROTOCOLCHAR('0' + e);
7597
-    #endif
7598
-    SERIAL_PROTOCOLCHAR(':');
7599
-    SERIAL_PROTOCOL(c);
7600
-    SERIAL_PROTOCOLPAIR(" /" , t);
7601
-    #if ENABLED(SHOW_TEMP_ADC_VALUES)
7602
-      SERIAL_PROTOCOLPAIR(" (", r / OVERSAMPLENR);
7603
-      SERIAL_PROTOCOLCHAR(')');
7604
-    #endif
7605
-  }
7606
-
7607
-  void print_heaterstates() {
7608
-    #if HAS_TEMP_HOTEND
7609
-      print_heater_state(thermalManager.degHotend(target_extruder), thermalManager.degTargetHotend(target_extruder)
7610
-        #if ENABLED(SHOW_TEMP_ADC_VALUES)
7611
-          , thermalManager.rawHotendTemp(target_extruder)
7612
-        #endif
7613
-      );
7614
-    #endif
7615
-    #if HAS_TEMP_BED
7616
-      print_heater_state(thermalManager.degBed(), thermalManager.degTargetBed(),
7617
-        #if ENABLED(SHOW_TEMP_ADC_VALUES)
7618
-          thermalManager.rawBedTemp(),
7619
-        #endif
7620
-        -1 // BED
7621
-      );
7622
-    #endif
7623
-    #if HOTENDS > 1
7624
-      HOTEND_LOOP() print_heater_state(thermalManager.degHotend(e), thermalManager.degTargetHotend(e),
7625
-        #if ENABLED(SHOW_TEMP_ADC_VALUES)
7626
-          thermalManager.rawHotendTemp(e),
7627
-        #endif
7628
-        e
7629
-      );
7630
-    #endif
7631
-    SERIAL_PROTOCOLPGM(" @:");
7632
-    SERIAL_PROTOCOL(thermalManager.getHeaterPower(target_extruder));
7633
-    #if HAS_TEMP_BED
7634
-      SERIAL_PROTOCOLPGM(" B@:");
7635
-      SERIAL_PROTOCOL(thermalManager.getHeaterPower(-1));
7636
-    #endif
7637
-    #if HOTENDS > 1
7638
-      HOTEND_LOOP() {
7639
-        SERIAL_PROTOCOLPAIR(" @", e);
7640
-        SERIAL_PROTOCOLCHAR(':');
7641
-        SERIAL_PROTOCOL(thermalManager.getHeaterPower(e));
7642
-      }
7643
-    #endif
7644
-  }
7645
-#endif
7646
-
7647 7573
 /**
7648 7574
  * M105: Read hot end and bed temperature
7649 7575
  */
@@ -7652,7 +7578,7 @@ inline void gcode_M105() {
7652 7578
 
7653 7579
   #if HAS_TEMP_HOTEND || HAS_TEMP_BED
7654 7580
     SERIAL_PROTOCOLPGM(MSG_OK);
7655
-    print_heaterstates();
7581
+    thermalManager.print_heaterstates();
7656 7582
   #else // !HAS_TEMP_HOTEND && !HAS_TEMP_BED
7657 7583
     SERIAL_ERROR_START();
7658 7584
     SERIAL_ERRORLNPGM(MSG_ERR_NO_THERMISTORS);
@@ -7663,26 +7589,12 @@ inline void gcode_M105() {
7663 7589
 
7664 7590
 #if ENABLED(AUTO_REPORT_TEMPERATURES) && (HAS_TEMP_HOTEND || HAS_TEMP_BED)
7665 7591
 
7666
-  static uint8_t auto_report_temp_interval;
7667
-  static millis_t next_temp_report_ms;
7668
-
7669 7592
   /**
7670 7593
    * M155: Set temperature auto-report interval. M155 S<seconds>
7671 7594
    */
7672 7595
   inline void gcode_M155() {
7673
-    if (parser.seenval('S')) {
7674
-      auto_report_temp_interval = parser.value_byte();
7675
-      NOMORE(auto_report_temp_interval, 60);
7676
-      next_temp_report_ms = millis() + 1000UL * auto_report_temp_interval;
7677
-    }
7678
-  }
7679
-
7680
-  inline void auto_report_temperatures() {
7681
-    if (auto_report_temp_interval && ELAPSED(millis(), next_temp_report_ms)) {
7682
-      next_temp_report_ms = millis() + 1000UL * auto_report_temp_interval;
7683
-      print_heaterstates();
7684
-      SERIAL_EOL();
7685
-    }
7596
+    if (parser.seenval('S'))
7597
+      thermalManager.set_auto_report_interval(parser.value_byte());
7686 7598
   }
7687 7599
 
7688 7600
 #endif // AUTO_REPORT_TEMPERATURES
@@ -7851,7 +7763,7 @@ inline void gcode_M109() {
7851 7763
     now = millis();
7852 7764
     if (ELAPSED(now, next_temp_ms)) { //Print temp & remaining time every 1s while waiting
7853 7765
       next_temp_ms = now + 1000UL;
7854
-      print_heaterstates();
7766
+      thermalManager.print_heaterstates();
7855 7767
       #if TEMP_RESIDENCY_TIME > 0
7856 7768
         SERIAL_PROTOCOLPGM(" W:");
7857 7769
         if (residency_start_ms)
@@ -7988,7 +7900,7 @@ inline void gcode_M109() {
7988 7900
       now = millis();
7989 7901
       if (ELAPSED(now, next_temp_ms)) { //Print Temp Reading every 1 second while heating up.
7990 7902
         next_temp_ms = now + 1000UL;
7991
-        print_heaterstates();
7903
+        thermalManager.print_heaterstates();
7992 7904
         #if TEMP_BED_RESIDENCY_TIME > 0
7993 7905
           SERIAL_PROTOCOLPGM(" W:");
7994 7906
           if (residency_start_ms)
@@ -13672,7 +13584,7 @@ void idle(
13672 13584
   host_keepalive();
13673 13585
 
13674 13586
   #if ENABLED(AUTO_REPORT_TEMPERATURES) && (HAS_TEMP_HOTEND || HAS_TEMP_BED)
13675
-    auto_report_temperatures();
13587
+    thermalManager.auto_report_temperatures();
13676 13588
   #endif
13677 13589
 
13678 13590
   manage_inactivity(

+ 92
- 0
Marlin/temperature.cpp Bestand weergeven

@@ -2186,3 +2186,95 @@ void Temperature::isr() {
2186 2186
   in_temp_isr = false;
2187 2187
   SBI(TIMSK0, OCIE0B); //re-enable Temperature ISR
2188 2188
 }
2189
+
2190
+#if HAS_TEMP_HOTEND || HAS_TEMP_BED
2191
+
2192
+  void print_heater_state(const float &c, const float &t,
2193
+    #if ENABLED(SHOW_TEMP_ADC_VALUES)
2194
+      const float r,
2195
+    #endif
2196
+    const int8_t e=-2
2197
+  ) {
2198
+    #if !(HAS_TEMP_BED && HAS_TEMP_HOTEND) && HOTENDS <= 1
2199
+      UNUSED(e);
2200
+    #endif
2201
+
2202
+    SERIAL_PROTOCOLCHAR(' ');
2203
+    SERIAL_PROTOCOLCHAR(
2204
+      #if HAS_TEMP_BED && HAS_TEMP_HOTEND
2205
+        e == -1 ? 'B' : 'T'
2206
+      #elif HAS_TEMP_HOTEND
2207
+        'T'
2208
+      #else
2209
+        'B'
2210
+      #endif
2211
+    );
2212
+    #if HOTENDS > 1
2213
+      if (e >= 0) SERIAL_PROTOCOLCHAR('0' + e);
2214
+    #endif
2215
+    SERIAL_PROTOCOLCHAR(':');
2216
+    SERIAL_PROTOCOL(c);
2217
+    SERIAL_PROTOCOLPAIR(" /" , t);
2218
+    #if ENABLED(SHOW_TEMP_ADC_VALUES)
2219
+      SERIAL_PROTOCOLPAIR(" (", r / OVERSAMPLENR);
2220
+      SERIAL_PROTOCOLCHAR(')');
2221
+    #endif
2222
+  }
2223
+
2224
+  extern uint8_t target_extruder;
2225
+
2226
+  void Temperature::print_heaterstates() {
2227
+    #if HAS_TEMP_HOTEND
2228
+      print_heater_state(degHotend(target_extruder), degTargetHotend(target_extruder)
2229
+        #if ENABLED(SHOW_TEMP_ADC_VALUES)
2230
+          , rawHotendTemp(target_extruder)
2231
+        #endif
2232
+      );
2233
+    #endif
2234
+    #if HAS_TEMP_BED
2235
+      print_heater_state(degBed(), degTargetBed()
2236
+        #if ENABLED(SHOW_TEMP_ADC_VALUES)
2237
+          , rawBedTemp()
2238
+        #endif
2239
+        , -1 // BED
2240
+      );
2241
+    #endif
2242
+    #if HOTENDS > 1
2243
+      HOTEND_LOOP() print_heater_state(degHotend(e), degTargetHotend(e)
2244
+        #if ENABLED(SHOW_TEMP_ADC_VALUES)
2245
+          , rawHotendTemp(e)
2246
+        #endif
2247
+        , e
2248
+      );
2249
+    #endif
2250
+    SERIAL_PROTOCOLPGM(" @:");
2251
+    SERIAL_PROTOCOL(getHeaterPower(target_extruder));
2252
+    #if HAS_TEMP_BED
2253
+      SERIAL_PROTOCOLPGM(" B@:");
2254
+      SERIAL_PROTOCOL(getHeaterPower(-1));
2255
+    #endif
2256
+    #if HOTENDS > 1
2257
+      HOTEND_LOOP() {
2258
+        SERIAL_PROTOCOLPAIR(" @", e);
2259
+        SERIAL_PROTOCOLCHAR(':');
2260
+        SERIAL_PROTOCOL(getHeaterPower(e));
2261
+      }
2262
+    #endif
2263
+  }
2264
+
2265
+  #if ENABLED(AUTO_REPORT_TEMPERATURES)
2266
+
2267
+    uint8_t Temperature::auto_report_temp_interval;
2268
+    millis_t Temperature::next_temp_report_ms;
2269
+
2270
+    void Temperature::auto_report_temperatures() {
2271
+      if (auto_report_temp_interval && ELAPSED(millis(), next_temp_report_ms)) {
2272
+        next_temp_report_ms = millis() + 1000UL * auto_report_temp_interval;
2273
+        print_heaterstates();
2274
+        SERIAL_EOL();
2275
+      }
2276
+    }
2277
+
2278
+  #endif // AUTO_REPORT_TEMPERATURES
2279
+
2280
+#endif // HAS_TEMP_HOTEND || HAS_TEMP_BED

+ 14
- 0
Marlin/temperature.h Bestand weergeven

@@ -539,6 +539,20 @@ class Temperature {
539 539
       #endif
540 540
     #endif
541 541
 
542
+    #if HAS_TEMP_HOTEND || HAS_TEMP_BED
543
+      static void print_heaterstates();
544
+      #if ENABLED(AUTO_REPORT_TEMPERATURES)
545
+        static uint8_t auto_report_temp_interval;
546
+        static millis_t next_temp_report_ms;
547
+        static void auto_report_temperatures(void);
548
+        FORCE_INLINE void set_auto_report_interval(uint8_t v) {
549
+          NOMORE(v, 60);
550
+          auto_report_temp_interval = v;
551
+          next_temp_report_ms = millis() + 1000UL * v;
552
+        }
553
+      #endif
554
+    #endif
555
+
542 556
   private:
543 557
 
544 558
     static void set_current_temp_raw();

Laden…
Annuleren
Opslaan