Kaynağa Gözat

Merge pull request #6811 from thinkyhead/bf_temp_float_stuff

Restore current temp accessors to float
Scott Lahteine 7 yıl önce
ebeveyn
işleme
c2ca85aeb2
3 değiştirilmiş dosya ile 31 ekleme ve 52 silme
  1. 4
    4
      Marlin/Marlin_main.cpp
  2. 21
    42
      Marlin/temperature.cpp
  3. 6
    6
      Marlin/temperature.h

+ 4
- 4
Marlin/Marlin_main.cpp Dosyayı Görüntüle

@@ -6684,7 +6684,8 @@ inline void gcode_M104() {
6684 6684
       }
6685 6685
     #endif
6686 6686
 
6687
-    if (code_value_temp_abs() > thermalManager.degHotend(target_extruder)) lcd_status_printf_P(0, PSTR("E%i %s"), target_extruder + 1, MSG_HEATING);
6687
+    if (code_value_temp_abs() > thermalManager.degHotend(target_extruder))
6688
+      lcd_status_printf_P(0, PSTR("E%i %s"), target_extruder + 1, MSG_HEATING);
6688 6689
   }
6689 6690
 
6690 6691
   #if ENABLED(AUTOTEMP)
@@ -8290,7 +8291,7 @@ inline void gcode_M226() {
8290 8291
       // Report current state
8291 8292
       SERIAL_ECHO_START;
8292 8293
       SERIAL_ECHOPAIR("Cold extrudes are ", (thermalManager.allow_cold_extrude ? "en" : "dis"));
8293
-      SERIAL_ECHOPAIR("abled (min temp ", int(thermalManager.extrude_min_temp + 0.5));
8294
+      SERIAL_ECHOPAIR("abled (min temp ", thermalManager.extrude_min_temp);
8294 8295
       SERIAL_ECHOLNPGM("C)");
8295 8296
     }
8296 8297
   }
@@ -11909,9 +11910,8 @@ void prepare_move_to_destination() {
11909 11910
       #if HAS_TEMP_BED
11910 11911
         max_temp = MAX3(max_temp, thermalManager.degTargetBed(), thermalManager.degBed());
11911 11912
       #endif
11912
-      HOTEND_LOOP() {
11913
+      HOTEND_LOOP()
11913 11914
         max_temp = MAX3(max_temp, thermalManager.degHotend(e), thermalManager.degTargetHotend(e));
11914
-      }
11915 11915
       bool new_led = (max_temp > 55.0) ? true : (max_temp < 54.0) ? false : red_led;
11916 11916
       if (new_led != red_led) {
11917 11917
         red_led = new_led;

+ 21
- 42
Marlin/temperature.cpp Dosyayı Görüntüle

@@ -103,24 +103,24 @@ int16_t Temperature::current_temperature_raw[HOTENDS] = { 0 },
103 103
 #endif
104 104
 
105 105
 #if WATCH_HOTENDS
106
-  int Temperature::watch_target_temp[HOTENDS] = { 0 };
106
+  uint16_t Temperature::watch_target_temp[HOTENDS] = { 0 };
107 107
   millis_t Temperature::watch_heater_next_ms[HOTENDS] = { 0 };
108 108
 #endif
109 109
 
110 110
 #if WATCH_THE_BED
111
-  int Temperature::watch_target_bed_temp = 0;
111
+  uint16_t Temperature::watch_target_bed_temp = 0;
112 112
   millis_t Temperature::watch_bed_next_ms = 0;
113 113
 #endif
114 114
 
115 115
 #if ENABLED(PREVENT_COLD_EXTRUSION)
116 116
   bool Temperature::allow_cold_extrude = false;
117
-  float Temperature::extrude_min_temp = EXTRUDE_MINTEMP;
117
+  uint16_t Temperature::extrude_min_temp = EXTRUDE_MINTEMP;
118 118
 #endif
119 119
 
120 120
 // private:
121 121
 
122 122
 #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
123
-  int Temperature::redundant_temperature_raw = 0;
123
+  uint16_t Temperature::redundant_temperature_raw = 0;
124 124
   float Temperature::redundant_temperature = 0.0;
125 125
 #endif
126 126
 
@@ -695,66 +695,47 @@ void Temperature::manage_heater() {
695 695
   updateTemperaturesFromRawValues(); // also resets the watchdog
696 696
 
697 697
   #if ENABLED(HEATER_0_USES_MAX6675)
698
-    if (current_temperature[0] > min(HEATER_0_MAXTEMP, MAX6675_TMAX - 1)) max_temp_error(0);
699
-    if (current_temperature[0] < max(HEATER_0_MINTEMP, MAX6675_TMIN + 0.01)) min_temp_error(0);
698
+    if (current_temperature[0] > min(HEATER_0_MAXTEMP, MAX6675_TMAX - 1.0)) max_temp_error(0);
699
+    if (current_temperature[0] < max(HEATER_0_MINTEMP, MAX6675_TMIN + .01)) min_temp_error(0);
700 700
   #endif
701 701
 
702 702
   #if WATCH_HOTENDS || WATCH_THE_BED || DISABLED(PIDTEMPBED) || HAS_AUTO_FAN
703 703
     millis_t ms = millis();
704 704
   #endif
705 705
 
706
-  // Loop through all hotends
707 706
   HOTEND_LOOP() {
708 707
 
709 708
     #if ENABLED(THERMAL_PROTECTION_HOTENDS)
709
+      // Check for thermal runaway
710 710
       thermal_runaway_protection(&thermal_runaway_state_machine[e], &thermal_runaway_timer[e], current_temperature[e], target_temperature[e], e, THERMAL_PROTECTION_PERIOD, THERMAL_PROTECTION_HYSTERESIS);
711 711
     #endif
712 712
 
713
-    float pid_output = get_pid_output(e);
713
+    soft_pwm_amount[e] = (current_temperature[e] > minttemp[e] || is_preheating(e)) && current_temperature[e] < maxttemp[e] ? (int)get_pid_output(e) >> 1 : 0;
714 714
 
715
-    // Check if temperature is within the correct range
716
-    soft_pwm_amount[e] = (current_temperature[e] > minttemp[e] || is_preheating(e)) && current_temperature[e] < maxttemp[e] ? (int)pid_output >> 1 : 0;
717
-
718
-    // Check if the temperature is failing to increase
719 715
     #if WATCH_HOTENDS
720
-
721
-      // Is it time to check this extruder's heater?
722
-      if (watch_heater_next_ms[e] && ELAPSED(ms, watch_heater_next_ms[e])) {
723
-        // Has it failed to increase enough?
724
-        if (degHotend(e) < watch_target_temp[e]) {
725
-          // Stop!
716
+      // Make sure temperature is increasing
717
+      if (watch_heater_next_ms[e] && ELAPSED(ms, watch_heater_next_ms[e])) { // Time to check this extruder?
718
+        if (degHotend(e) < watch_target_temp[e])                             // Failed to increase enough?
726 719
           _temp_error(e, PSTR(MSG_T_HEATING_FAILED), PSTR(MSG_HEATING_FAILED_LCD));
727
-        }
728
-        else {
729
-          // Start again if the target is still far off
720
+        else                                                                 // Start again if the target is still far off
730 721
           start_watching_heater(e);
731
-        }
732 722
       }
723
+    #endif
733 724
 
734
-    #endif // THERMAL_PROTECTION_HOTENDS
735
-
736
-    // Check if the temperature is failing to increase
737 725
     #if WATCH_THE_BED
738
-
739
-      // Is it time to check the bed?
740
-      if (watch_bed_next_ms && ELAPSED(ms, watch_bed_next_ms)) {
741
-        // Has it failed to increase enough?
742
-        if (degBed() < watch_target_bed_temp) {
743
-          // Stop!
726
+      // Make sure temperature is increasing
727
+      if (watch_bed_next_ms && ELAPSED(ms, watch_bed_next_ms)) {        // Time to check the bed?
728
+        if (degBed() < watch_target_bed_temp)                           // Failed to increase enough?
744 729
           _temp_error(-1, PSTR(MSG_T_HEATING_FAILED), PSTR(MSG_HEATING_FAILED_LCD));
745
-        }
746
-        else {
747
-          // Start again if the target is still far off
730
+        else                                                            // Start again if the target is still far off
748 731
           start_watching_bed();
749
-        }
750 732
       }
751
-
752
-    #endif // THERMAL_PROTECTION_HOTENDS
733
+    #endif
753 734
 
754 735
     #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
755
-      if (fabs(current_temperature[0] - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF) {
736
+      // Make sure measured temperatures are close together
737
+      if (fabs(current_temperature[0] - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF)
756 738
         _temp_error(0, PSTR(MSG_REDUNDANCY), PSTR(MSG_ERR_REDUNDANT_TEMP));
757
-      }
758 739
     #endif
759 740
 
760 741
   } // HOTEND_LOOP
@@ -792,9 +773,7 @@ void Temperature::manage_heater() {
792 773
     #endif
793 774
 
794 775
     #if ENABLED(PIDTEMPBED)
795
-      float pid_output = get_pid_output_bed();
796
-
797
-      soft_pwm_amount_bed = WITHIN(current_temperature_bed, BED_MINTEMP, BED_MAXTEMP) ? (int)pid_output >> 1 : 0;
776
+      soft_pwm_amount_bed = WITHIN(current_temperature_bed, BED_MINTEMP, BED_MAXTEMP) ? (int)get_pid_output_bed() >> 1 : 0;
798 777
 
799 778
     #elif ENABLED(BED_LIMIT_SWITCHING)
800 779
       // Check if temperature is within the correct band

+ 6
- 6
Marlin/temperature.h Dosyayı Görüntüle

@@ -158,18 +158,18 @@ class Temperature {
158 158
     #endif
159 159
 
160 160
     #if WATCH_HOTENDS
161
-      static int watch_target_temp[HOTENDS];
161
+      static uint16_t watch_target_temp[HOTENDS];
162 162
       static millis_t watch_heater_next_ms[HOTENDS];
163 163
     #endif
164 164
 
165 165
     #if WATCH_THE_BED
166
-      static int watch_target_bed_temp;
166
+      static uint16_t watch_target_bed_temp;
167 167
       static millis_t watch_bed_next_ms;
168 168
     #endif
169 169
 
170 170
     #if ENABLED(PREVENT_COLD_EXTRUSION)
171 171
       static bool allow_cold_extrude;
172
-      static float extrude_min_temp;
172
+      static uint16_t extrude_min_temp;
173 173
       static bool tooColdToExtrude(uint8_t e) {
174 174
         #if HOTENDS == 1
175 175
           UNUSED(e);
@@ -183,7 +183,7 @@ class Temperature {
183 183
   private:
184 184
 
185 185
     #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
186
-      static int redundant_temperature_raw;
186
+      static uint16_t redundant_temperature_raw;
187 187
       static float redundant_temperature;
188 188
     #endif
189 189
 
@@ -327,13 +327,13 @@ class Temperature {
327 327
     //inline so that there is no performance decrease.
328 328
     //deg=degreeCelsius
329 329
 
330
-    static int16_t degHotend(uint8_t e) {
330
+    static float degHotend(uint8_t e) {
331 331
       #if HOTENDS == 1
332 332
         UNUSED(e);
333 333
       #endif
334 334
       return current_temperature[HOTEND_INDEX];
335 335
     }
336
-    static int16_t degBed() { return current_temperature_bed; }
336
+    static float degBed() { return current_temperature_bed; }
337 337
 
338 338
     #if ENABLED(SHOW_TEMP_ADC_VALUES)
339 339
       static int16_t rawHotendTemp(uint8_t e) {

Loading…
İptal
Kaydet