Browse Source

Move temperature reporting to Temperature class

Scott Lahteine 7 years ago
parent
commit
5d01a2f467
5 changed files with 115 additions and 101 deletions
  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 View File

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

+ 0
- 4
Marlin/Marlin.h View File

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

+ 7
- 95
Marlin/Marlin_main.cpp View File

519
   #define BUZZ(d,f) NOOP
519
   #define BUZZ(d,f) NOOP
520
 #endif
520
 #endif
521
 
521
 
522
-static uint8_t target_extruder;
522
+uint8_t target_extruder;
523
 
523
 
524
 #if HAS_BED_PROBE
524
 #if HAS_BED_PROBE
525
   float zprobe_zoffset; // Initialized by settings.load()
525
   float zprobe_zoffset; // Initialized by settings.load()
7570
   #endif
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
  * M105: Read hot end and bed temperature
7574
  * M105: Read hot end and bed temperature
7649
  */
7575
  */
7652
 
7578
 
7653
   #if HAS_TEMP_HOTEND || HAS_TEMP_BED
7579
   #if HAS_TEMP_HOTEND || HAS_TEMP_BED
7654
     SERIAL_PROTOCOLPGM(MSG_OK);
7580
     SERIAL_PROTOCOLPGM(MSG_OK);
7655
-    print_heaterstates();
7581
+    thermalManager.print_heaterstates();
7656
   #else // !HAS_TEMP_HOTEND && !HAS_TEMP_BED
7582
   #else // !HAS_TEMP_HOTEND && !HAS_TEMP_BED
7657
     SERIAL_ERROR_START();
7583
     SERIAL_ERROR_START();
7658
     SERIAL_ERRORLNPGM(MSG_ERR_NO_THERMISTORS);
7584
     SERIAL_ERRORLNPGM(MSG_ERR_NO_THERMISTORS);
7663
 
7589
 
7664
 #if ENABLED(AUTO_REPORT_TEMPERATURES) && (HAS_TEMP_HOTEND || HAS_TEMP_BED)
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
    * M155: Set temperature auto-report interval. M155 S<seconds>
7593
    * M155: Set temperature auto-report interval. M155 S<seconds>
7671
    */
7594
    */
7672
   inline void gcode_M155() {
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
 #endif // AUTO_REPORT_TEMPERATURES
7600
 #endif // AUTO_REPORT_TEMPERATURES
7851
     now = millis();
7763
     now = millis();
7852
     if (ELAPSED(now, next_temp_ms)) { //Print temp & remaining time every 1s while waiting
7764
     if (ELAPSED(now, next_temp_ms)) { //Print temp & remaining time every 1s while waiting
7853
       next_temp_ms = now + 1000UL;
7765
       next_temp_ms = now + 1000UL;
7854
-      print_heaterstates();
7766
+      thermalManager.print_heaterstates();
7855
       #if TEMP_RESIDENCY_TIME > 0
7767
       #if TEMP_RESIDENCY_TIME > 0
7856
         SERIAL_PROTOCOLPGM(" W:");
7768
         SERIAL_PROTOCOLPGM(" W:");
7857
         if (residency_start_ms)
7769
         if (residency_start_ms)
7988
       now = millis();
7900
       now = millis();
7989
       if (ELAPSED(now, next_temp_ms)) { //Print Temp Reading every 1 second while heating up.
7901
       if (ELAPSED(now, next_temp_ms)) { //Print Temp Reading every 1 second while heating up.
7990
         next_temp_ms = now + 1000UL;
7902
         next_temp_ms = now + 1000UL;
7991
-        print_heaterstates();
7903
+        thermalManager.print_heaterstates();
7992
         #if TEMP_BED_RESIDENCY_TIME > 0
7904
         #if TEMP_BED_RESIDENCY_TIME > 0
7993
           SERIAL_PROTOCOLPGM(" W:");
7905
           SERIAL_PROTOCOLPGM(" W:");
7994
           if (residency_start_ms)
7906
           if (residency_start_ms)
13672
   host_keepalive();
13584
   host_keepalive();
13673
 
13585
 
13674
   #if ENABLED(AUTO_REPORT_TEMPERATURES) && (HAS_TEMP_HOTEND || HAS_TEMP_BED)
13586
   #if ENABLED(AUTO_REPORT_TEMPERATURES) && (HAS_TEMP_HOTEND || HAS_TEMP_BED)
13675
-    auto_report_temperatures();
13587
+    thermalManager.auto_report_temperatures();
13676
   #endif
13588
   #endif
13677
 
13589
 
13678
   manage_inactivity(
13590
   manage_inactivity(

+ 92
- 0
Marlin/temperature.cpp View File

2186
   in_temp_isr = false;
2186
   in_temp_isr = false;
2187
   SBI(TIMSK0, OCIE0B); //re-enable Temperature ISR
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 View File

539
       #endif
539
       #endif
540
     #endif
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
   private:
556
   private:
543
 
557
 
544
     static void set_current_temp_raw();
558
     static void set_current_temp_raw();

Loading…
Cancel
Save