Browse Source

Treat temperature as integer, when possible

Scott Lahteine 7 years ago
parent
commit
2658cc707a
6 changed files with 89 additions and 91 deletions
  1. 1
    1
      Marlin/Marlin.h
  2. 27
    26
      Marlin/Marlin_main.cpp
  3. 1
    4
      Marlin/planner.cpp
  4. 28
    28
      Marlin/temperature.cpp
  5. 30
    30
      Marlin/temperature.h
  6. 2
    2
      Marlin/ultralcd.cpp

+ 1
- 1
Marlin/Marlin.h View File

@@ -361,7 +361,7 @@ int16_t code_value_temp_diff();
361 361
 #endif
362 362
 
363 363
 #if FAN_COUNT > 0
364
-  extern int fanSpeeds[FAN_COUNT];
364
+  extern int16_t fanSpeeds[FAN_COUNT];
365 365
 #endif
366 366
 
367 367
 #if ENABLED(BARICUDA)

+ 27
- 26
Marlin/Marlin_main.cpp View File

@@ -440,7 +440,7 @@ float soft_endstop_min[XYZ] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS },
440 440
       soft_endstop_max[XYZ] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS };
441 441
 
442 442
 #if FAN_COUNT > 0
443
-  int fanSpeeds[FAN_COUNT] = { 0 };
443
+  int16_t fanSpeeds[FAN_COUNT] = { 0 };
444 444
 #endif
445 445
 
446 446
 // The active extruder (tool). Set with T<extruder> command.
@@ -1297,20 +1297,19 @@ inline bool code_value_bool() { return !code_has_value() || code_value_byte() >
1297 1297
 #if ENABLED(TEMPERATURE_UNITS_SUPPORT)
1298 1298
   inline void set_input_temp_units(TempUnit units) { input_temp_units = units; }
1299 1299
 
1300
-  float code_value_temp_abs() {
1300
+  int16_t code_value_temp_abs() {
1301 1301
     switch (input_temp_units) {
1302
-      case TEMPUNIT_C:
1303
-        return code_value_float();
1304 1302
       case TEMPUNIT_F:
1305 1303
         return (code_value_float() - 32) * 0.5555555556;
1306 1304
       case TEMPUNIT_K:
1307 1305
         return code_value_float() - 273.15;
1306
+      case TEMPUNIT_C:
1308 1307
       default:
1309
-        return code_value_float();
1308
+        return code_value_int();
1310 1309
     }
1311 1310
   }
1312 1311
 
1313
-  float code_value_temp_diff() {
1312
+  int16_t code_value_temp_diff() {
1314 1313
     switch (input_temp_units) {
1315 1314
       case TEMPUNIT_C:
1316 1315
       case TEMPUNIT_K:
@@ -1322,8 +1321,8 @@ inline bool code_value_bool() { return !code_has_value() || code_value_byte() >
1322 1321
     }
1323 1322
   }
1324 1323
 #else
1325
-  float code_value_temp_abs() { return code_value_float(); }
1326
-  float code_value_temp_diff() { return code_value_float(); }
1324
+  int16_t code_value_temp_abs() { return code_value_int(); }
1325
+  int16_t code_value_temp_diff() { return code_value_int(); }
1327 1326
 #endif
1328 1327
 
1329 1328
 FORCE_INLINE millis_t code_value_millis() { return code_value_ulong(); }
@@ -1384,7 +1383,7 @@ bool get_target_extruder_from_command(int code) {
1384 1383
   static float raised_parked_position[XYZE];         // used in mode 1
1385 1384
   static millis_t delayed_move_time = 0;             // used in mode 1
1386 1385
   static float duplicate_extruder_x_offset = DEFAULT_DUPLICATION_X_OFFSET; // used in mode 2
1387
-  static float duplicate_extruder_temp_offset = 0;   // used in mode 2
1386
+  static int16_t duplicate_extruder_temp_offset = 0; // used in mode 2
1388 1387
 
1389 1388
 #endif // DUAL_X_CARRIAGE
1390 1389
 
@@ -2073,10 +2072,10 @@ static void clean_up_after_endstop_or_probe_move() {
2073 2072
       void set_heaters_for_bltouch(const bool deploy) {
2074 2073
         static bool heaters_were_disabled = false;
2075 2074
         static millis_t next_emi_protection = 0;
2076
-        static float temps_at_entry[HOTENDS];
2075
+        static int16_t temps_at_entry[HOTENDS];
2077 2076
 
2078 2077
         #if HAS_TEMP_BED
2079
-          static float bed_temp_at_entry;
2078
+          static int16_t bed_temp_at_entry;
2080 2079
         #endif
2081 2080
 
2082 2081
         // If called out of order or far apart something is seriously wrong
@@ -6471,10 +6470,11 @@ inline void gcode_M104() {
6471 6470
   #endif
6472 6471
 
6473 6472
   if (code_seen('S')) {
6474
-    thermalManager.setTargetHotend(code_value_temp_abs(), target_extruder);
6473
+    const int16_t temp = code_value_temp_abs();
6474
+    thermalManager.setTargetHotend(temp, target_extruder);
6475 6475
     #if ENABLED(DUAL_X_CARRIAGE)
6476 6476
       if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && target_extruder == 0)
6477
-        thermalManager.setTargetHotend(code_value_temp_abs() == 0.0 ? 0.0 : code_value_temp_abs() + duplicate_extruder_temp_offset, 1);
6477
+        thermalManager.setTargetHotend(temp ? temp + duplicate_extruder_temp_offset : 0, 1);
6478 6478
     #endif
6479 6479
 
6480 6480
     #if ENABLED(PRINTJOB_TIMER_AUTOSTART)
@@ -6484,7 +6484,7 @@ inline void gcode_M104() {
6484 6484
        * standby mode, for instance in a dual extruder setup, without affecting
6485 6485
        * the running print timer.
6486 6486
        */
6487
-      if (code_value_temp_abs() <= (EXTRUDE_MINTEMP)/2) {
6487
+      if (code_value_temp_abs() <= (EXTRUDE_MINTEMP) / 2) {
6488 6488
         print_job_timer.stop();
6489 6489
         LCD_MESSAGEPGM(WELCOME_MSG);
6490 6490
       }
@@ -6507,7 +6507,7 @@ inline void gcode_M104() {
6507 6507
       SERIAL_PROTOCOLPGM(" /");
6508 6508
       SERIAL_PROTOCOL_F(thermalManager.degTargetHotend(target_extruder), 1);
6509 6509
       #if ENABLED(SHOW_TEMP_ADC_VALUES)
6510
-        SERIAL_PROTOCOLPAIR(" (", thermalManager.current_temperature_raw[target_extruder] / OVERSAMPLENR);
6510
+        SERIAL_PROTOCOLPAIR(" (", thermalManager.rawHotendTemp(target_extruder) / OVERSAMPLENR);
6511 6511
         SERIAL_PROTOCOLCHAR(')');
6512 6512
       #endif
6513 6513
     #endif
@@ -6517,7 +6517,7 @@ inline void gcode_M104() {
6517 6517
       SERIAL_PROTOCOLPGM(" /");
6518 6518
       SERIAL_PROTOCOL_F(thermalManager.degTargetBed(), 1);
6519 6519
       #if ENABLED(SHOW_TEMP_ADC_VALUES)
6520
-        SERIAL_PROTOCOLPAIR(" (", thermalManager.current_temperature_bed_raw / OVERSAMPLENR);
6520
+        SERIAL_PROTOCOLPAIR(" (", thermalManager.rawBedTemp() / OVERSAMPLENR);
6521 6521
         SERIAL_PROTOCOLCHAR(')');
6522 6522
       #endif
6523 6523
     #endif
@@ -6529,7 +6529,7 @@ inline void gcode_M104() {
6529 6529
         SERIAL_PROTOCOLPGM(" /");
6530 6530
         SERIAL_PROTOCOL_F(thermalManager.degTargetHotend(e), 1);
6531 6531
         #if ENABLED(SHOW_TEMP_ADC_VALUES)
6532
-          SERIAL_PROTOCOLPAIR(" (", thermalManager.current_temperature_raw[e] / OVERSAMPLENR);
6532
+          SERIAL_PROTOCOLPAIR(" (", thermalManager.rawHotendTemp(e) / OVERSAMPLENR);
6533 6533
           SERIAL_PROTOCOLCHAR(')');
6534 6534
         #endif
6535 6535
       }
@@ -6665,10 +6665,11 @@ inline void gcode_M109() {
6665 6665
 
6666 6666
   const bool no_wait_for_cooling = code_seen('S');
6667 6667
   if (no_wait_for_cooling || code_seen('R')) {
6668
-    thermalManager.setTargetHotend(code_value_temp_abs(), target_extruder);
6668
+    const int16_t temp = code_value_temp_abs();
6669
+    thermalManager.setTargetHotend(temp, target_extruder);
6669 6670
     #if ENABLED(DUAL_X_CARRIAGE)
6670 6671
       if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && target_extruder == 0)
6671
-        thermalManager.setTargetHotend(code_value_temp_abs() == 0.0 ? 0.0 : code_value_temp_abs() + duplicate_extruder_temp_offset, 1);
6672
+        thermalManager.setTargetHotend(temp ? temp + duplicate_extruder_temp_offset : 0, 1);
6672 6673
     #endif
6673 6674
 
6674 6675
     #if ENABLED(PRINTJOB_TIMER_AUTOSTART)
@@ -7196,7 +7197,7 @@ inline void gcode_M92() {
7196 7197
   LOOP_XYZE(i) {
7197 7198
     if (code_seen(axis_codes[i])) {
7198 7199
       if (i == E_AXIS) {
7199
-        const float value = code_value_per_axis_unit(E_AXIS + TARGET_EXTRUDER);
7200
+        const float value = code_value_per_axis_unit((AxisEnum)(E_AXIS + TARGET_EXTRUDER));
7200 7201
         if (value < 20.0) {
7201 7202
           float factor = planner.axis_steps_per_mm[E_AXIS + TARGET_EXTRUDER] / value; // increase e constants if M92 E14 is given for netfab.
7202 7203
           planner.max_jerk[E_AXIS] *= factor;
@@ -7206,7 +7207,7 @@ inline void gcode_M92() {
7206 7207
         planner.axis_steps_per_mm[E_AXIS + TARGET_EXTRUDER] = value;
7207 7208
       }
7208 7209
       else {
7209
-        planner.axis_steps_per_mm[i] = code_value_per_axis_unit(i);
7210
+        planner.axis_steps_per_mm[i] = code_value_per_axis_unit((AxisEnum)i);
7210 7211
       }
7211 7212
     }
7212 7213
   }
@@ -8100,11 +8101,11 @@ inline void gcode_M226() {
8100 8101
  */
8101 8102
 inline void gcode_M303() {
8102 8103
   #if HAS_PID_HEATING
8103
-    int e = code_seen('E') ? code_value_int() : 0;
8104
-    int c = code_seen('C') ? code_value_int() : 5;
8105
-    bool u = code_seen('U') && code_value_bool();
8104
+    const int e = code_seen('E') ? code_value_int() : 0,
8105
+              c = code_seen('C') ? code_value_int() : 5;
8106
+    const bool u = code_seen('U') && code_value_bool();
8106 8107
 
8107
-    float temp = code_seen('S') ? code_value_temp_abs() : (e < 0 ? 70.0 : 150.0);
8108
+    int16_t temp = code_seen('S') ? code_value_temp_abs() : (e < 0 ? 70 : 150);
8108 8109
 
8109 8110
     if (WITHIN(e, 0, HOTENDS - 1))
8110 8111
       target_extruder = e;
@@ -8741,7 +8742,6 @@ inline void gcode_M503() {
8741 8742
 
8742 8743
     const millis_t nozzle_timeout = millis() + (millis_t)(FILAMENT_CHANGE_NOZZLE_TIMEOUT) * 1000UL;
8743 8744
     bool nozzle_timed_out = false;
8744
-    float temps[4];
8745 8745
 
8746 8746
     // Wait for filament insert by user and press button
8747 8747
     lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_INSERT);
@@ -8752,6 +8752,7 @@ inline void gcode_M503() {
8752 8752
 
8753 8753
     idle();
8754 8754
 
8755
+    int16_t temps[HOTENDS];
8755 8756
     HOTEND_LOOP() temps[e] = thermalManager.target_temperature[e]; // Save nozzle temps
8756 8757
 
8757 8758
     KEEPALIVE_STATE(PAUSED_FOR_USER);

+ 1
- 4
Marlin/planner.cpp View File

@@ -387,10 +387,7 @@ void Planner::recalculate() {
387 387
 
388 388
     float t = autotemp_min + high * autotemp_factor;
389 389
     t = constrain(t, autotemp_min, autotemp_max);
390
-    if (oldt > t) {
391
-      t *= (1 - (AUTOTEMP_OLDWEIGHT));
392
-      t += (AUTOTEMP_OLDWEIGHT) * oldt;
393
-    }
390
+    if (t < oldt) t = t * (1 - (AUTOTEMP_OLDWEIGHT)) + oldt * (AUTOTEMP_OLDWEIGHT);
394 391
     oldt = t;
395 392
     thermalManager.setTargetHotend(t, 0);
396 393
   }

+ 28
- 28
Marlin/temperature.cpp View File

@@ -64,10 +64,10 @@ Temperature thermalManager;
64 64
 
65 65
 float Temperature::current_temperature[HOTENDS] = { 0.0 },
66 66
       Temperature::current_temperature_bed = 0.0;
67
-int   Temperature::current_temperature_raw[HOTENDS] = { 0 },
68
-      Temperature::target_temperature[HOTENDS] = { 0 },
69
-      Temperature::current_temperature_bed_raw = 0,
70
-      Temperature::target_temperature_bed = 0;
67
+int16_t Temperature::current_temperature_raw[HOTENDS] = { 0 },
68
+        Temperature::target_temperature[HOTENDS] = { 0 },
69
+        Temperature::current_temperature_bed_raw = 0,
70
+        Temperature::target_temperature_bed = 0;
71 71
 
72 72
 #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
73 73
   float Temperature::redundant_temperature = 0.0;
@@ -160,33 +160,33 @@ volatile bool Temperature::temp_meas_ready = false;
160 160
   millis_t Temperature::next_bed_check_ms;
161 161
 #endif
162 162
 
163
-unsigned long Temperature::raw_temp_value[MAX_EXTRUDERS] = { 0 };
164
-unsigned long Temperature::raw_temp_bed_value = 0;
163
+uint16_t Temperature::raw_temp_value[MAX_EXTRUDERS] = { 0 },
164
+         Temperature::raw_temp_bed_value = 0;
165 165
 
166 166
 // Init min and max temp with extreme values to prevent false errors during startup
167
-int Temperature::minttemp_raw[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_RAW_LO_TEMP , HEATER_1_RAW_LO_TEMP , HEATER_2_RAW_LO_TEMP, HEATER_3_RAW_LO_TEMP, HEATER_4_RAW_LO_TEMP),
168
-    Temperature::maxttemp_raw[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_RAW_HI_TEMP , HEATER_1_RAW_HI_TEMP , HEATER_2_RAW_HI_TEMP, HEATER_3_RAW_HI_TEMP, HEATER_4_RAW_HI_TEMP),
169
-    Temperature::minttemp[HOTENDS] = { 0 },
170
-    Temperature::maxttemp[HOTENDS] = ARRAY_BY_HOTENDS1(16383);
167
+int16_t Temperature::minttemp_raw[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_RAW_LO_TEMP , HEATER_1_RAW_LO_TEMP , HEATER_2_RAW_LO_TEMP, HEATER_3_RAW_LO_TEMP, HEATER_4_RAW_LO_TEMP),
168
+        Temperature::maxttemp_raw[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_RAW_HI_TEMP , HEATER_1_RAW_HI_TEMP , HEATER_2_RAW_HI_TEMP, HEATER_3_RAW_HI_TEMP, HEATER_4_RAW_HI_TEMP),
169
+        Temperature::minttemp[HOTENDS] = { 0 },
170
+        Temperature::maxttemp[HOTENDS] = ARRAY_BY_HOTENDS1(16383);
171 171
 
172 172
 #ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED
173
-  int Temperature::consecutive_low_temperature_error[HOTENDS] = { 0 };
173
+  uint8_t Temperature::consecutive_low_temperature_error[HOTENDS] = { 0 };
174 174
 #endif
175 175
 
176 176
 #ifdef MILLISECONDS_PREHEAT_TIME
177
-  unsigned long Temperature::preheat_end_time[HOTENDS] = { 0 };
177
+  millis_t Temperature::preheat_end_time[HOTENDS] = { 0 };
178 178
 #endif
179 179
 
180 180
 #ifdef BED_MINTEMP
181
-  int Temperature::bed_minttemp_raw = HEATER_BED_RAW_LO_TEMP;
181
+  int16_t Temperature::bed_minttemp_raw = HEATER_BED_RAW_LO_TEMP;
182 182
 #endif
183 183
 
184 184
 #ifdef BED_MAXTEMP
185
-  int Temperature::bed_maxttemp_raw = HEATER_BED_RAW_HI_TEMP;
185
+  int16_t Temperature::bed_maxttemp_raw = HEATER_BED_RAW_HI_TEMP;
186 186
 #endif
187 187
 
188 188
 #if ENABLED(FILAMENT_WIDTH_SENSOR)
189
-  int Temperature::meas_shift_index;  // Index of a delayed sample in buffer
189
+  int16_t Temperature::meas_shift_index;  // Index of a delayed sample in buffer
190 190
 #endif
191 191
 
192 192
 #if HAS_AUTO_FAN
@@ -1242,7 +1242,7 @@ void Temperature::init() {
1242 1242
     millis_t Temperature::thermal_runaway_bed_timer;
1243 1243
   #endif
1244 1244
 
1245
-  void Temperature::thermal_runaway_protection(Temperature::TRState* state, millis_t* timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc) {
1245
+  void Temperature::thermal_runaway_protection(Temperature::TRState* state, millis_t* timer, float current, float target, int heater_id, int period_seconds, int hysteresis_degc) {
1246 1246
 
1247 1247
     static float tr_target_temperature[HOTENDS + 1] = { 0.0 };
1248 1248
 
@@ -1252,17 +1252,17 @@ void Temperature::init() {
1252 1252
         if (heater_id < 0) SERIAL_ECHOPGM("bed"); else SERIAL_ECHO(heater_id);
1253 1253
         SERIAL_ECHOPAIR(" ;  State:", *state);
1254 1254
         SERIAL_ECHOPAIR(" ;  Timer:", *timer);
1255
-        SERIAL_ECHOPAIR(" ;  Temperature:", temperature);
1256
-        SERIAL_ECHOPAIR(" ;  Target Temp:", target_temperature);
1255
+        SERIAL_ECHOPAIR(" ;  Temperature:", current);
1256
+        SERIAL_ECHOPAIR(" ;  Target Temp:", target);
1257 1257
         SERIAL_EOL;
1258 1258
     */
1259 1259
 
1260 1260
     int heater_index = heater_id >= 0 ? heater_id : HOTENDS;
1261 1261
 
1262 1262
     // If the target temperature changes, restart
1263
-    if (tr_target_temperature[heater_index] != target_temperature) {
1264
-      tr_target_temperature[heater_index] = target_temperature;
1265
-      *state = target_temperature > 0 ? TRFirstHeating : TRInactive;
1263
+    if (tr_target_temperature[heater_index] != target) {
1264
+      tr_target_temperature[heater_index] = target;
1265
+      *state = target > 0 ? TRFirstHeating : TRInactive;
1266 1266
     }
1267 1267
 
1268 1268
     switch (*state) {
@@ -1270,11 +1270,11 @@ void Temperature::init() {
1270 1270
       case TRInactive: break;
1271 1271
       // When first heating, wait for the temperature to be reached then go to Stable state
1272 1272
       case TRFirstHeating:
1273
-        if (temperature < tr_target_temperature[heater_index]) break;
1273
+        if (current < tr_target_temperature[heater_index]) break;
1274 1274
         *state = TRStable;
1275 1275
       // While the temperature is stable watch for a bad temperature
1276 1276
       case TRStable:
1277
-        if (temperature >= tr_target_temperature[heater_index] - hysteresis_degc) {
1277
+        if (current >= tr_target_temperature[heater_index] - hysteresis_degc) {
1278 1278
           *timer = millis() + period_seconds * 1000UL;
1279 1279
           break;
1280 1280
         }
@@ -1961,9 +1961,9 @@ void Temperature::isr() {
1961 1961
     };
1962 1962
 
1963 1963
     for (uint8_t e = 0; e < COUNT(temp_dir); e++) {
1964
-      const int tdir = temp_dir[e], rawtemp = current_temperature_raw[e] * tdir;
1965
-      if (rawtemp > maxttemp_raw[e] * tdir && target_temperature[e] > 0.0f) max_temp_error(e);
1966
-      if (rawtemp < minttemp_raw[e] * tdir && !is_preheating(e) && target_temperature[e] > 0.0f) {
1964
+      const int16_t tdir = temp_dir[e], rawtemp = current_temperature_raw[e] * tdir;
1965
+      if (rawtemp > maxttemp_raw[e] * tdir && target_temperature[e] > 0) max_temp_error(e);
1966
+      if (rawtemp < minttemp_raw[e] * tdir && !is_preheating(e) && target_temperature[e] > 0) {
1967 1967
         #ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED
1968 1968
           if (++consecutive_low_temperature_error[e] >= MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED)
1969 1969
         #endif
@@ -1981,8 +1981,8 @@ void Temperature::isr() {
1981 1981
       #else
1982 1982
         #define GEBED >=
1983 1983
       #endif
1984
-      if (current_temperature_bed_raw GEBED bed_maxttemp_raw && target_temperature_bed > 0.0f) max_temp_error(-1);
1985
-      if (bed_minttemp_raw GEBED current_temperature_bed_raw && target_temperature_bed > 0.0f) min_temp_error(-1);
1984
+      if (current_temperature_bed_raw GEBED bed_maxttemp_raw && target_temperature_bed > 0) max_temp_error(-1);
1985
+      if (bed_minttemp_raw GEBED current_temperature_bed_raw && target_temperature_bed > 0) min_temp_error(-1);
1986 1986
     #endif
1987 1987
 
1988 1988
   } // temp_count >= OVERSAMPLENR

+ 30
- 30
Marlin/temperature.h View File

@@ -99,10 +99,10 @@ class Temperature {
99 99
 
100 100
     static float current_temperature[HOTENDS],
101 101
                  current_temperature_bed;
102
-    static int   current_temperature_raw[HOTENDS],
103
-                 target_temperature[HOTENDS],
104
-                 current_temperature_bed_raw,
105
-                 target_temperature_bed;
102
+    static int16_t current_temperature_raw[HOTENDS],
103
+                   target_temperature[HOTENDS],
104
+                   current_temperature_bed_raw,
105
+                   target_temperature_bed;
106 106
 
107 107
     static volatile bool in_temp_isr;
108 108
 
@@ -217,33 +217,33 @@ class Temperature {
217 217
       static millis_t next_bed_check_ms;
218 218
     #endif
219 219
 
220
-    static unsigned long raw_temp_value[MAX_EXTRUDERS],
221
-                         raw_temp_bed_value;
220
+    static uint16_t raw_temp_value[MAX_EXTRUDERS],
221
+                    raw_temp_bed_value;
222 222
 
223 223
     // Init min and max temp with extreme values to prevent false errors during startup
224
-    static int minttemp_raw[HOTENDS],
225
-               maxttemp_raw[HOTENDS],
226
-               minttemp[HOTENDS],
227
-               maxttemp[HOTENDS];
224
+    static int16_t minttemp_raw[HOTENDS],
225
+                   maxttemp_raw[HOTENDS],
226
+                   minttemp[HOTENDS],
227
+                   maxttemp[HOTENDS];
228 228
 
229 229
     #ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED
230
-      static int consecutive_low_temperature_error[HOTENDS];
230
+      static uint8_t consecutive_low_temperature_error[HOTENDS];
231 231
     #endif
232 232
 
233 233
     #ifdef MILLISECONDS_PREHEAT_TIME
234
-      static unsigned long preheat_end_time[HOTENDS];
234
+      static millis_t preheat_end_time[HOTENDS];
235 235
     #endif
236 236
 
237 237
     #ifdef BED_MINTEMP
238
-      static int bed_minttemp_raw;
238
+      static int16_t bed_minttemp_raw;
239 239
     #endif
240 240
 
241 241
     #ifdef BED_MAXTEMP
242
-      static int bed_maxttemp_raw;
242
+      static int16_t bed_maxttemp_raw;
243 243
     #endif
244 244
 
245 245
     #if ENABLED(FILAMENT_WIDTH_SENSOR)
246
-      static int meas_shift_index;  // Index of a delayed sample in buffer
246
+      static int16_t meas_shift_index;  // Index of a delayed sample in buffer
247 247
     #endif
248 248
 
249 249
     #if HAS_AUTO_FAN
@@ -323,31 +323,31 @@ class Temperature {
323 323
     //inline so that there is no performance decrease.
324 324
     //deg=degreeCelsius
325 325
 
326
-    static float degHotend(uint8_t e) {
326
+    static int16_t degHotend(uint8_t e) {
327 327
       #if HOTENDS == 1
328 328
         UNUSED(e);
329 329
       #endif
330 330
       return current_temperature[HOTEND_INDEX];
331 331
     }
332
-    static float degBed() { return current_temperature_bed; }
332
+    static int16_t degBed() { return current_temperature_bed; }
333 333
 
334 334
     #if ENABLED(SHOW_TEMP_ADC_VALUES)
335
-    static float rawHotendTemp(uint8_t e) {
336
-      #if HOTENDS == 1
337
-        UNUSED(e);
338
-      #endif
339
-      return current_temperature_raw[HOTEND_INDEX];
340
-    }
341
-    static float rawBedTemp() { return current_temperature_bed_raw; }
335
+      static int16_t rawHotendTemp(uint8_t e) {
336
+        #if HOTENDS == 1
337
+          UNUSED(e);
338
+        #endif
339
+        return current_temperature_raw[HOTEND_INDEX];
340
+      }
341
+      static int16_t rawBedTemp() { return current_temperature_bed_raw; }
342 342
     #endif
343 343
 
344
-    static float degTargetHotend(uint8_t e) {
344
+    static int16_t degTargetHotend(uint8_t e) {
345 345
       #if HOTENDS == 1
346 346
         UNUSED(e);
347 347
       #endif
348 348
       return target_temperature[HOTEND_INDEX];
349 349
     }
350
-    static float degTargetBed() { return target_temperature_bed; }
350
+    static int16_t degTargetBed() { return target_temperature_bed; }
351 351
 
352 352
     #if WATCH_HOTENDS
353 353
       static void start_watching_heater(uint8_t e = 0);
@@ -357,14 +357,14 @@ class Temperature {
357 357
       static void start_watching_bed();
358 358
     #endif
359 359
 
360
-    static void setTargetHotend(const float& celsius, uint8_t e) {
360
+    static void setTargetHotend(const int16_t &celsius, uint8_t e) {
361 361
       #if HOTENDS == 1
362 362
         UNUSED(e);
363 363
       #endif
364 364
       #ifdef MILLISECONDS_PREHEAT_TIME
365
-        if (celsius == 0.0f)
365
+        if (celsius == 0)
366 366
           reset_preheat_time(HOTEND_INDEX);
367
-        else if (target_temperature[HOTEND_INDEX] == 0.0f)
367
+        else if (target_temperature[HOTEND_INDEX] == 0)
368 368
           start_preheat_time(HOTEND_INDEX);
369 369
       #endif
370 370
       target_temperature[HOTEND_INDEX] = celsius;
@@ -373,7 +373,7 @@ class Temperature {
373 373
       #endif
374 374
     }
375 375
 
376
-    static void setTargetBed(const float& celsius) {
376
+    static void setTargetBed(const int16_t &celsius) {
377 377
       target_temperature_bed = celsius;
378 378
       #if WATCH_THE_BED
379 379
         start_watching_bed();

+ 2
- 2
Marlin/ultralcd.cpp View File

@@ -1179,14 +1179,14 @@ void kill_screen(const char* lcd_msg) {
1179 1179
     }
1180 1180
   #endif
1181 1181
 
1182
-  constexpr int heater_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP);
1182
+  constexpr int16_t heater_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP);
1183 1183
 
1184 1184
   /**
1185 1185
    *
1186 1186
    * "Prepare" submenu items
1187 1187
    *
1188 1188
    */
1189
-  void _lcd_preheat(int endnum, const float temph, const float tempb, const int fan) {
1189
+  void _lcd_preheat(const int endnum, const int16_t temph, const int16_t tempb, const int16_t fan) {
1190 1190
     if (temph > 0) thermalManager.setTargetHotend(min(heater_maxtemp[endnum], temph), endnum);
1191 1191
     #if TEMP_SENSOR_BED != 0
1192 1192
       if (tempb >= 0) thermalManager.setTargetBed(tempb);

Loading…
Cancel
Save