Browse Source

Merge pull request #6559 from thinkyhead/rc_more_optimal

Compact smart_fill_mesh slightly
Scott Lahteine 8 years ago
parent
commit
e1b85ff67b

+ 17
- 14
Marlin/G26_Mesh_Validation_Tool.cpp View File

126
   void set_destination_to_current();
126
   void set_destination_to_current();
127
   void set_current_to_destination();
127
   void set_current_to_destination();
128
   float code_value_float();
128
   float code_value_float();
129
+  float code_value_linear_units();
130
+  float code_value_axis_units(const AxisEnum axis);
129
   bool code_value_bool();
131
   bool code_value_bool();
130
   bool code_has_value();
132
   bool code_has_value();
131
   void lcd_init();
133
   void lcd_init();
164
                filament_diameter = FILAMENT,
166
                filament_diameter = FILAMENT,
165
                prime_length = PRIME_LENGTH,
167
                prime_length = PRIME_LENGTH,
166
                x_pos, y_pos,
168
                x_pos, y_pos,
167
-               bed_temp = BED_TEMP,
168
-               hotend_temp = HOTEND_TEMP,
169
                ooze_amount = OOZE_AMOUNT;
169
                ooze_amount = OOZE_AMOUNT;
170
 
170
 
171
+  static int16_t bed_temp = BED_TEMP,
172
+                 hotend_temp = HOTEND_TEMP;
173
+
171
   static int8_t prime_flag = 0;
174
   static int8_t prime_flag = 0;
172
 
175
 
173
   static bool keep_heaters_on = false;
176
   static bool keep_heaters_on = false;
379
 
382
 
380
     if (!keep_heaters_on) {
383
     if (!keep_heaters_on) {
381
       #if HAS_TEMP_BED
384
       #if HAS_TEMP_BED
382
-        thermalManager.setTargetBed(0.0);
385
+        thermalManager.setTargetBed(0);
383
       #endif
386
       #endif
384
-      thermalManager.setTargetHotend(0.0, 0);
387
+      thermalManager.setTargetHotend(0, 0);
385
     }
388
     }
386
   }
389
   }
387
 
390
 
640
     keep_heaters_on       = false;
643
     keep_heaters_on       = false;
641
 
644
 
642
     if (code_seen('B')) {
645
     if (code_seen('B')) {
643
-      bed_temp = code_value_float();
644
-      if (!WITHIN(bed_temp, 15.0, 140.0)) {
646
+      bed_temp = code_value_temp_abs();
647
+      if (!WITHIN(bed_temp, 15, 140)) {
645
         SERIAL_PROTOCOLLNPGM("?Specified bed temperature not plausible.");
648
         SERIAL_PROTOCOLLNPGM("?Specified bed temperature not plausible.");
646
         return UBL_ERR;
649
         return UBL_ERR;
647
       }
650
       }
650
     if (code_seen('C')) continue_with_closest++;
653
     if (code_seen('C')) continue_with_closest++;
651
 
654
 
652
     if (code_seen('L')) {
655
     if (code_seen('L')) {
653
-      layer_height = code_value_float();
656
+      layer_height = code_value_linear_units();
654
       if (!WITHIN(layer_height, 0.0, 2.0)) {
657
       if (!WITHIN(layer_height, 0.0, 2.0)) {
655
         SERIAL_PROTOCOLLNPGM("?Specified layer height not plausible.");
658
         SERIAL_PROTOCOLLNPGM("?Specified layer height not plausible.");
656
         return UBL_ERR;
659
         return UBL_ERR;
682
     if (code_seen('K')) keep_heaters_on++;
685
     if (code_seen('K')) keep_heaters_on++;
683
 
686
 
684
     if (code_seen('O') && code_has_value())
687
     if (code_seen('O') && code_has_value())
685
-      ooze_amount = code_value_float();
688
+      ooze_amount = code_value_linear_units();
686
 
689
 
687
     if (code_seen('P')) {
690
     if (code_seen('P')) {
688
       if (!code_has_value())
691
       if (!code_has_value())
689
         prime_flag = -1;
692
         prime_flag = -1;
690
       else {
693
       else {
691
         prime_flag++;
694
         prime_flag++;
692
-        prime_length = code_value_float();
695
+        prime_length = code_value_linear_units();
693
         if (!WITHIN(prime_length, 0.0, 25.0)) {
696
         if (!WITHIN(prime_length, 0.0, 25.0)) {
694
           SERIAL_PROTOCOLLNPGM("?Specified prime length not plausible.");
697
           SERIAL_PROTOCOLLNPGM("?Specified prime length not plausible.");
695
           return UBL_ERR;
698
           return UBL_ERR;
698
     }
701
     }
699
 
702
 
700
     if (code_seen('F')) {
703
     if (code_seen('F')) {
701
-      filament_diameter = code_value_float();
704
+      filament_diameter = code_value_linear_units();
702
       if (!WITHIN(filament_diameter, 1.0, 4.0)) {
705
       if (!WITHIN(filament_diameter, 1.0, 4.0)) {
703
         SERIAL_PROTOCOLLNPGM("?Specified filament size not plausible.");
706
         SERIAL_PROTOCOLLNPGM("?Specified filament size not plausible.");
704
         return UBL_ERR;
707
         return UBL_ERR;
711
     extrusion_multiplier *= filament_diameter * sq(nozzle) / sq(0.3); // Scale up by nozzle size
714
     extrusion_multiplier *= filament_diameter * sq(nozzle) / sq(0.3); // Scale up by nozzle size
712
 
715
 
713
     if (code_seen('H')) {
716
     if (code_seen('H')) {
714
-      hotend_temp = code_value_float();
715
-      if (!WITHIN(hotend_temp, 165.0, 280.0)) {
717
+      hotend_temp = code_value_temp_abs();
718
+      if (!WITHIN(hotend_temp, 165, 280)) {
716
         SERIAL_PROTOCOLLNPGM("?Specified nozzle temperature not plausible.");
719
         SERIAL_PROTOCOLLNPGM("?Specified nozzle temperature not plausible.");
717
         return UBL_ERR;
720
         return UBL_ERR;
718
       }
721
       }
727
     y_pos = current_position[Y_AXIS];
730
     y_pos = current_position[Y_AXIS];
728
 
731
 
729
     if (code_seen('X')) {
732
     if (code_seen('X')) {
730
-      x_pos = code_value_float();
733
+      x_pos = code_value_axis_units(X_AXIS);
731
       if (!WITHIN(x_pos, X_MIN_POS, X_MAX_POS)) {
734
       if (!WITHIN(x_pos, X_MIN_POS, X_MAX_POS)) {
732
         SERIAL_PROTOCOLLNPGM("?Specified X coordinate not plausible.");
735
         SERIAL_PROTOCOLLNPGM("?Specified X coordinate not plausible.");
733
         return UBL_ERR;
736
         return UBL_ERR;
736
     else
739
     else
737
 
740
 
738
     if (code_seen('Y')) {
741
     if (code_seen('Y')) {
739
-      y_pos = code_value_float();
742
+      y_pos = code_value_axis_units(Y_AXIS);
740
       if (!WITHIN(y_pos, Y_MIN_POS, Y_MAX_POS)) {
743
       if (!WITHIN(y_pos, Y_MIN_POS, Y_MAX_POS)) {
741
         SERIAL_PROTOCOLLNPGM("?Specified Y coordinate not plausible.");
744
         SERIAL_PROTOCOLLNPGM("?Specified Y coordinate not plausible.");
742
         return UBL_ERR;
745
         return UBL_ERR;

+ 1
- 1
Marlin/M100_Free_Mem_Chk.cpp View File

241
   SERIAL_ECHOPAIR("\n__brkval : ", hex_address(__brkval));
241
   SERIAL_ECHOPAIR("\n__brkval : ", hex_address(__brkval));
242
   SERIAL_ECHOPAIR("\n__bss_end : ", hex_address(&__bss_end));
242
   SERIAL_ECHOPAIR("\n__bss_end : ", hex_address(&__bss_end));
243
 
243
 
244
-  uint8_t *ptr = END_OF_HEAP(), *sp = top_of_stack();
244
+  char *ptr = END_OF_HEAP(), *sp = top_of_stack();
245
 
245
 
246
   SERIAL_ECHOPAIR("\nstart of free space : ", hex_address(ptr));
246
   SERIAL_ECHOPAIR("\nstart of free space : ", hex_address(ptr));
247
   SERIAL_ECHOLNPAIR("\nStack Pointer : ", hex_address(sp));
247
   SERIAL_ECHOLNPAIR("\nStack Pointer : ", hex_address(sp));

+ 13
- 3
Marlin/Marlin.h View File

290
 // GCode support for external objects
290
 // GCode support for external objects
291
 bool code_seen(char);
291
 bool code_seen(char);
292
 int code_value_int();
292
 int code_value_int();
293
-float code_value_temp_abs();
294
-float code_value_temp_diff();
293
+int16_t code_value_temp_abs();
294
+int16_t code_value_temp_diff();
295
+
296
+#if ENABLED(INCH_MODE_SUPPORT)
297
+  float code_value_linear_units();
298
+  float code_value_axis_units(const AxisEnum axis);
299
+  float code_value_per_axis_unit(const AxisEnum axis);
300
+#else
301
+  #define code_value_linear_units() code_value_float()
302
+  #define code_value_axis_units(A) code_value_float()
303
+  #define code_value_per_axis_unit(A) code_value_float()
304
+#endif
295
 
305
 
296
 #if IS_KINEMATIC
306
 #if IS_KINEMATIC
297
   extern float delta[ABC];
307
   extern float delta[ABC];
351
 #endif
361
 #endif
352
 
362
 
353
 #if FAN_COUNT > 0
363
 #if FAN_COUNT > 0
354
-  extern int fanSpeeds[FAN_COUNT];
364
+  extern int16_t fanSpeeds[FAN_COUNT];
355
 #endif
365
 #endif
356
 
366
 
357
 #if ENABLED(BARICUDA)
367
 #if ENABLED(BARICUDA)

+ 40
- 45
Marlin/Marlin_main.cpp View File

440
       soft_endstop_max[XYZ] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS };
440
       soft_endstop_max[XYZ] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS };
441
 
441
 
442
 #if FAN_COUNT > 0
442
 #if FAN_COUNT > 0
443
-  int fanSpeeds[FAN_COUNT] = { 0 };
443
+  int16_t fanSpeeds[FAN_COUNT] = { 0 };
444
 #endif
444
 #endif
445
 
445
 
446
 // The active extruder (tool). Set with T<extruder> command.
446
 // The active extruder (tool). Set with T<extruder> command.
1292
   inline float code_value_linear_units() { return code_value_float() * linear_unit_factor; }
1292
   inline float code_value_linear_units() { return code_value_float() * linear_unit_factor; }
1293
   inline float code_value_axis_units(const AxisEnum axis) { return code_value_float() * axis_unit_factor(axis); }
1293
   inline float code_value_axis_units(const AxisEnum axis) { return code_value_float() * axis_unit_factor(axis); }
1294
   inline float code_value_per_axis_unit(const AxisEnum axis) { return code_value_float() / axis_unit_factor(axis); }
1294
   inline float code_value_per_axis_unit(const AxisEnum axis) { return code_value_float() / axis_unit_factor(axis); }
1295
-
1296
-#else
1297
-
1298
-  #define code_value_linear_units() code_value_float()
1299
-  #define code_value_axis_units(A) code_value_float()
1300
-  #define code_value_per_axis_unit(A) code_value_float()
1301
-
1302
 #endif
1295
 #endif
1303
 
1296
 
1304
 #if ENABLED(TEMPERATURE_UNITS_SUPPORT)
1297
 #if ENABLED(TEMPERATURE_UNITS_SUPPORT)
1305
   inline void set_input_temp_units(TempUnit units) { input_temp_units = units; }
1298
   inline void set_input_temp_units(TempUnit units) { input_temp_units = units; }
1306
 
1299
 
1307
-  float code_value_temp_abs() {
1300
+  int16_t code_value_temp_abs() {
1308
     switch (input_temp_units) {
1301
     switch (input_temp_units) {
1309
-      case TEMPUNIT_C:
1310
-        return code_value_float();
1311
       case TEMPUNIT_F:
1302
       case TEMPUNIT_F:
1312
         return (code_value_float() - 32) * 0.5555555556;
1303
         return (code_value_float() - 32) * 0.5555555556;
1313
       case TEMPUNIT_K:
1304
       case TEMPUNIT_K:
1314
         return code_value_float() - 273.15;
1305
         return code_value_float() - 273.15;
1306
+      case TEMPUNIT_C:
1315
       default:
1307
       default:
1316
-        return code_value_float();
1308
+        return code_value_int();
1317
     }
1309
     }
1318
   }
1310
   }
1319
 
1311
 
1320
-  float code_value_temp_diff() {
1312
+  int16_t code_value_temp_diff() {
1321
     switch (input_temp_units) {
1313
     switch (input_temp_units) {
1322
       case TEMPUNIT_C:
1314
       case TEMPUNIT_C:
1323
       case TEMPUNIT_K:
1315
       case TEMPUNIT_K:
1329
     }
1321
     }
1330
   }
1322
   }
1331
 #else
1323
 #else
1332
-  float code_value_temp_abs() { return code_value_float(); }
1333
-  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(); }
1334
 #endif
1326
 #endif
1335
 
1327
 
1336
 FORCE_INLINE millis_t code_value_millis() { return code_value_ulong(); }
1328
 FORCE_INLINE millis_t code_value_millis() { return code_value_ulong(); }
1391
   static float raised_parked_position[XYZE];         // used in mode 1
1383
   static float raised_parked_position[XYZE];         // used in mode 1
1392
   static millis_t delayed_move_time = 0;             // used in mode 1
1384
   static millis_t delayed_move_time = 0;             // used in mode 1
1393
   static float duplicate_extruder_x_offset = DEFAULT_DUPLICATION_X_OFFSET; // used in mode 2
1385
   static float duplicate_extruder_x_offset = DEFAULT_DUPLICATION_X_OFFSET; // used in mode 2
1394
-  static float duplicate_extruder_temp_offset = 0;   // used in mode 2
1386
+  static int16_t duplicate_extruder_temp_offset = 0; // used in mode 2
1395
 
1387
 
1396
 #endif // DUAL_X_CARRIAGE
1388
 #endif // DUAL_X_CARRIAGE
1397
 
1389
 
2080
       void set_heaters_for_bltouch(const bool deploy) {
2072
       void set_heaters_for_bltouch(const bool deploy) {
2081
         static bool heaters_were_disabled = false;
2073
         static bool heaters_were_disabled = false;
2082
         static millis_t next_emi_protection = 0;
2074
         static millis_t next_emi_protection = 0;
2083
-        static float temps_at_entry[HOTENDS];
2075
+        static int16_t temps_at_entry[HOTENDS];
2084
 
2076
 
2085
         #if HAS_TEMP_BED
2077
         #if HAS_TEMP_BED
2086
-          static float bed_temp_at_entry;
2078
+          static int16_t bed_temp_at_entry;
2087
         #endif
2079
         #endif
2088
 
2080
 
2089
         // If called out of order or far apart something is seriously wrong
2081
         // If called out of order or far apart something is seriously wrong
2588
   /**
2580
   /**
2589
    * Extrapolate a single point from its neighbors
2581
    * Extrapolate a single point from its neighbors
2590
    */
2582
    */
2591
-  static void extrapolate_one_point(uint8_t x, uint8_t y, int8_t xdir, int8_t ydir) {
2583
+  static void extrapolate_one_point(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir) {
2592
     #if ENABLED(DEBUG_LEVELING_FEATURE)
2584
     #if ENABLED(DEBUG_LEVELING_FEATURE)
2593
       if (DEBUGGING(LEVELING)) {
2585
       if (DEBUGGING(LEVELING)) {
2594
         SERIAL_ECHOPGM("Extrapolate [");
2586
         SERIAL_ECHOPGM("Extrapolate [");
2611
     SERIAL_EOL;
2603
     SERIAL_EOL;
2612
 
2604
 
2613
     // Get X neighbors, Y neighbors, and XY neighbors
2605
     // Get X neighbors, Y neighbors, and XY neighbors
2614
-    float a1 = z_values[x + xdir][y], a2 = z_values[x + xdir * 2][y],
2615
-          b1 = z_values[x][y + ydir], b2 = z_values[x][y + ydir * 2],
2616
-          c1 = z_values[x + xdir][y + ydir], c2 = z_values[x + xdir * 2][y + ydir * 2];
2606
+    const uint8_t x1 = x + xdir, y1 = y + ydir, x2 = x1 + xdir, y2 = y1 + ydir;
2607
+    float a1 = z_values[x1][y ], a2 = z_values[x2][y ],
2608
+          b1 = z_values[x ][y1], b2 = z_values[x ][y2],
2609
+          c1 = z_values[x1][y1], c2 = z_values[x2][y2];
2617
 
2610
 
2618
     // Treat far unprobed points as zero, near as equal to far
2611
     // Treat far unprobed points as zero, near as equal to far
2619
     if (isnan(a2)) a2 = 0.0; if (isnan(a1)) a1 = a2;
2612
     if (isnan(a2)) a2 = 0.0; if (isnan(a1)) a1 = a2;
2647
    */
2640
    */
2648
   static void extrapolate_unprobed_bed_level() {
2641
   static void extrapolate_unprobed_bed_level() {
2649
     #ifdef HALF_IN_X
2642
     #ifdef HALF_IN_X
2650
-      const uint8_t ctrx2 = 0, xlen = GRID_MAX_POINTS_X - 1;
2643
+      constexpr uint8_t ctrx2 = 0, xlen = GRID_MAX_POINTS_X - 1;
2651
     #else
2644
     #else
2652
-      const uint8_t ctrx1 = (GRID_MAX_POINTS_X - 1) / 2, // left-of-center
2653
-                    ctrx2 = GRID_MAX_POINTS_X / 2,       // right-of-center
2654
-                    xlen = ctrx1;
2645
+      constexpr uint8_t ctrx1 = (GRID_MAX_POINTS_X - 1) / 2, // left-of-center
2646
+                        ctrx2 = (GRID_MAX_POINTS_X) / 2,     // right-of-center
2647
+                        xlen = ctrx1;
2655
     #endif
2648
     #endif
2656
 
2649
 
2657
     #ifdef HALF_IN_Y
2650
     #ifdef HALF_IN_Y
2658
-      const uint8_t ctry2 = 0, ylen = GRID_MAX_POINTS_Y - 1;
2651
+      constexpr uint8_t ctry2 = 0, ylen = GRID_MAX_POINTS_Y - 1;
2659
     #else
2652
     #else
2660
-      const uint8_t ctry1 = (GRID_MAX_POINTS_Y - 1) / 2, // top-of-center
2661
-                    ctry2 = GRID_MAX_POINTS_Y / 2,       // bottom-of-center
2662
-                    ylen = ctry1;
2653
+      constexpr uint8_t ctry1 = (GRID_MAX_POINTS_Y - 1) / 2, // top-of-center
2654
+                        ctry2 = (GRID_MAX_POINTS_Y) / 2,     // bottom-of-center
2655
+                        ylen = ctry1;
2663
     #endif
2656
     #endif
2664
 
2657
 
2665
     for (uint8_t xo = 0; xo <= xlen; xo++)
2658
     for (uint8_t xo = 0; xo <= xlen; xo++)
6477
   #endif
6470
   #endif
6478
 
6471
 
6479
   if (code_seen('S')) {
6472
   if (code_seen('S')) {
6480
-    thermalManager.setTargetHotend(code_value_temp_abs(), target_extruder);
6473
+    const int16_t temp = code_value_temp_abs();
6474
+    thermalManager.setTargetHotend(temp, target_extruder);
6481
     #if ENABLED(DUAL_X_CARRIAGE)
6475
     #if ENABLED(DUAL_X_CARRIAGE)
6482
       if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && target_extruder == 0)
6476
       if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && target_extruder == 0)
6483
-        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);
6484
     #endif
6478
     #endif
6485
 
6479
 
6486
     #if ENABLED(PRINTJOB_TIMER_AUTOSTART)
6480
     #if ENABLED(PRINTJOB_TIMER_AUTOSTART)
6490
        * standby mode, for instance in a dual extruder setup, without affecting
6484
        * standby mode, for instance in a dual extruder setup, without affecting
6491
        * the running print timer.
6485
        * the running print timer.
6492
        */
6486
        */
6493
-      if (code_value_temp_abs() <= (EXTRUDE_MINTEMP)/2) {
6487
+      if (code_value_temp_abs() <= (EXTRUDE_MINTEMP) / 2) {
6494
         print_job_timer.stop();
6488
         print_job_timer.stop();
6495
         LCD_MESSAGEPGM(WELCOME_MSG);
6489
         LCD_MESSAGEPGM(WELCOME_MSG);
6496
       }
6490
       }
6513
       SERIAL_PROTOCOLPGM(" /");
6507
       SERIAL_PROTOCOLPGM(" /");
6514
       SERIAL_PROTOCOL_F(thermalManager.degTargetHotend(target_extruder), 1);
6508
       SERIAL_PROTOCOL_F(thermalManager.degTargetHotend(target_extruder), 1);
6515
       #if ENABLED(SHOW_TEMP_ADC_VALUES)
6509
       #if ENABLED(SHOW_TEMP_ADC_VALUES)
6516
-        SERIAL_PROTOCOLPAIR(" (", thermalManager.current_temperature_raw[target_extruder] / OVERSAMPLENR);
6510
+        SERIAL_PROTOCOLPAIR(" (", thermalManager.rawHotendTemp(target_extruder) / OVERSAMPLENR);
6517
         SERIAL_PROTOCOLCHAR(')');
6511
         SERIAL_PROTOCOLCHAR(')');
6518
       #endif
6512
       #endif
6519
     #endif
6513
     #endif
6523
       SERIAL_PROTOCOLPGM(" /");
6517
       SERIAL_PROTOCOLPGM(" /");
6524
       SERIAL_PROTOCOL_F(thermalManager.degTargetBed(), 1);
6518
       SERIAL_PROTOCOL_F(thermalManager.degTargetBed(), 1);
6525
       #if ENABLED(SHOW_TEMP_ADC_VALUES)
6519
       #if ENABLED(SHOW_TEMP_ADC_VALUES)
6526
-        SERIAL_PROTOCOLPAIR(" (", thermalManager.current_temperature_bed_raw / OVERSAMPLENR);
6520
+        SERIAL_PROTOCOLPAIR(" (", thermalManager.rawBedTemp() / OVERSAMPLENR);
6527
         SERIAL_PROTOCOLCHAR(')');
6521
         SERIAL_PROTOCOLCHAR(')');
6528
       #endif
6522
       #endif
6529
     #endif
6523
     #endif
6535
         SERIAL_PROTOCOLPGM(" /");
6529
         SERIAL_PROTOCOLPGM(" /");
6536
         SERIAL_PROTOCOL_F(thermalManager.degTargetHotend(e), 1);
6530
         SERIAL_PROTOCOL_F(thermalManager.degTargetHotend(e), 1);
6537
         #if ENABLED(SHOW_TEMP_ADC_VALUES)
6531
         #if ENABLED(SHOW_TEMP_ADC_VALUES)
6538
-          SERIAL_PROTOCOLPAIR(" (", thermalManager.current_temperature_raw[e] / OVERSAMPLENR);
6532
+          SERIAL_PROTOCOLPAIR(" (", thermalManager.rawHotendTemp(e) / OVERSAMPLENR);
6539
           SERIAL_PROTOCOLCHAR(')');
6533
           SERIAL_PROTOCOLCHAR(')');
6540
         #endif
6534
         #endif
6541
       }
6535
       }
6671
 
6665
 
6672
   const bool no_wait_for_cooling = code_seen('S');
6666
   const bool no_wait_for_cooling = code_seen('S');
6673
   if (no_wait_for_cooling || code_seen('R')) {
6667
   if (no_wait_for_cooling || code_seen('R')) {
6674
-    thermalManager.setTargetHotend(code_value_temp_abs(), target_extruder);
6668
+    const int16_t temp = code_value_temp_abs();
6669
+    thermalManager.setTargetHotend(temp, target_extruder);
6675
     #if ENABLED(DUAL_X_CARRIAGE)
6670
     #if ENABLED(DUAL_X_CARRIAGE)
6676
       if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && target_extruder == 0)
6671
       if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && target_extruder == 0)
6677
-        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);
6678
     #endif
6673
     #endif
6679
 
6674
 
6680
     #if ENABLED(PRINTJOB_TIMER_AUTOSTART)
6675
     #if ENABLED(PRINTJOB_TIMER_AUTOSTART)
7202
   LOOP_XYZE(i) {
7197
   LOOP_XYZE(i) {
7203
     if (code_seen(axis_codes[i])) {
7198
     if (code_seen(axis_codes[i])) {
7204
       if (i == E_AXIS) {
7199
       if (i == E_AXIS) {
7205
-        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));
7206
         if (value < 20.0) {
7201
         if (value < 20.0) {
7207
           float factor = planner.axis_steps_per_mm[E_AXIS + TARGET_EXTRUDER] / value; // increase e constants if M92 E14 is given for netfab.
7202
           float factor = planner.axis_steps_per_mm[E_AXIS + TARGET_EXTRUDER] / value; // increase e constants if M92 E14 is given for netfab.
7208
           planner.max_jerk[E_AXIS] *= factor;
7203
           planner.max_jerk[E_AXIS] *= factor;
7212
         planner.axis_steps_per_mm[E_AXIS + TARGET_EXTRUDER] = value;
7207
         planner.axis_steps_per_mm[E_AXIS + TARGET_EXTRUDER] = value;
7213
       }
7208
       }
7214
       else {
7209
       else {
7215
-        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);
7216
       }
7211
       }
7217
     }
7212
     }
7218
   }
7213
   }
8106
  */
8101
  */
8107
 inline void gcode_M303() {
8102
 inline void gcode_M303() {
8108
   #if HAS_PID_HEATING
8103
   #if HAS_PID_HEATING
8109
-    int e = code_seen('E') ? code_value_int() : 0;
8110
-    int c = code_seen('C') ? code_value_int() : 5;
8111
-    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();
8112
 
8107
 
8113
-    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);
8114
 
8109
 
8115
     if (WITHIN(e, 0, HOTENDS - 1))
8110
     if (WITHIN(e, 0, HOTENDS - 1))
8116
       target_extruder = e;
8111
       target_extruder = e;
8747
 
8742
 
8748
     const millis_t nozzle_timeout = millis() + (millis_t)(FILAMENT_CHANGE_NOZZLE_TIMEOUT) * 1000UL;
8743
     const millis_t nozzle_timeout = millis() + (millis_t)(FILAMENT_CHANGE_NOZZLE_TIMEOUT) * 1000UL;
8749
     bool nozzle_timed_out = false;
8744
     bool nozzle_timed_out = false;
8750
-    float temps[4];
8751
 
8745
 
8752
     // Wait for filament insert by user and press button
8746
     // Wait for filament insert by user and press button
8753
     lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_INSERT);
8747
     lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_INSERT);
8758
 
8752
 
8759
     idle();
8753
     idle();
8760
 
8754
 
8755
+    int16_t temps[HOTENDS];
8761
     HOTEND_LOOP() temps[e] = thermalManager.target_temperature[e]; // Save nozzle temps
8756
     HOTEND_LOOP() temps[e] = thermalManager.target_temperature[e]; // Save nozzle temps
8762
 
8757
 
8763
     KEEPALIVE_STATE(PAUSED_FOR_USER);
8758
     KEEPALIVE_STATE(PAUSED_FOR_USER);

+ 1
- 4
Marlin/planner.cpp View File

387
 
387
 
388
     float t = autotemp_min + high * autotemp_factor;
388
     float t = autotemp_min + high * autotemp_factor;
389
     t = constrain(t, autotemp_min, autotemp_max);
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
     oldt = t;
391
     oldt = t;
395
     thermalManager.setTargetHotend(t, 0);
392
     thermalManager.setTargetHotend(t, 0);
396
   }
393
   }

+ 28
- 28
Marlin/temperature.cpp View File

64
 
64
 
65
 float Temperature::current_temperature[HOTENDS] = { 0.0 },
65
 float Temperature::current_temperature[HOTENDS] = { 0.0 },
66
       Temperature::current_temperature_bed = 0.0;
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
 #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
72
 #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
73
   float Temperature::redundant_temperature = 0.0;
73
   float Temperature::redundant_temperature = 0.0;
160
   millis_t Temperature::next_bed_check_ms;
160
   millis_t Temperature::next_bed_check_ms;
161
 #endif
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
 // Init min and max temp with extreme values to prevent false errors during startup
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
 #ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED
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
 #endif
174
 #endif
175
 
175
 
176
 #ifdef MILLISECONDS_PREHEAT_TIME
176
 #ifdef MILLISECONDS_PREHEAT_TIME
177
-  unsigned long Temperature::preheat_end_time[HOTENDS] = { 0 };
177
+  millis_t Temperature::preheat_end_time[HOTENDS] = { 0 };
178
 #endif
178
 #endif
179
 
179
 
180
 #ifdef BED_MINTEMP
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
 #endif
182
 #endif
183
 
183
 
184
 #ifdef BED_MAXTEMP
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
 #endif
186
 #endif
187
 
187
 
188
 #if ENABLED(FILAMENT_WIDTH_SENSOR)
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
 #endif
190
 #endif
191
 
191
 
192
 #if HAS_AUTO_FAN
192
 #if HAS_AUTO_FAN
1242
     millis_t Temperature::thermal_runaway_bed_timer;
1242
     millis_t Temperature::thermal_runaway_bed_timer;
1243
   #endif
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
     static float tr_target_temperature[HOTENDS + 1] = { 0.0 };
1247
     static float tr_target_temperature[HOTENDS + 1] = { 0.0 };
1248
 
1248
 
1252
         if (heater_id < 0) SERIAL_ECHOPGM("bed"); else SERIAL_ECHO(heater_id);
1252
         if (heater_id < 0) SERIAL_ECHOPGM("bed"); else SERIAL_ECHO(heater_id);
1253
         SERIAL_ECHOPAIR(" ;  State:", *state);
1253
         SERIAL_ECHOPAIR(" ;  State:", *state);
1254
         SERIAL_ECHOPAIR(" ;  Timer:", *timer);
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
         SERIAL_EOL;
1257
         SERIAL_EOL;
1258
     */
1258
     */
1259
 
1259
 
1260
     int heater_index = heater_id >= 0 ? heater_id : HOTENDS;
1260
     int heater_index = heater_id >= 0 ? heater_id : HOTENDS;
1261
 
1261
 
1262
     // If the target temperature changes, restart
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
     switch (*state) {
1268
     switch (*state) {
1270
       case TRInactive: break;
1270
       case TRInactive: break;
1271
       // When first heating, wait for the temperature to be reached then go to Stable state
1271
       // When first heating, wait for the temperature to be reached then go to Stable state
1272
       case TRFirstHeating:
1272
       case TRFirstHeating:
1273
-        if (temperature < tr_target_temperature[heater_index]) break;
1273
+        if (current < tr_target_temperature[heater_index]) break;
1274
         *state = TRStable;
1274
         *state = TRStable;
1275
       // While the temperature is stable watch for a bad temperature
1275
       // While the temperature is stable watch for a bad temperature
1276
       case TRStable:
1276
       case TRStable:
1277
-        if (temperature >= tr_target_temperature[heater_index] - hysteresis_degc) {
1277
+        if (current >= tr_target_temperature[heater_index] - hysteresis_degc) {
1278
           *timer = millis() + period_seconds * 1000UL;
1278
           *timer = millis() + period_seconds * 1000UL;
1279
           break;
1279
           break;
1280
         }
1280
         }
1961
     };
1961
     };
1962
 
1962
 
1963
     for (uint8_t e = 0; e < COUNT(temp_dir); e++) {
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
         #ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED
1967
         #ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED
1968
           if (++consecutive_low_temperature_error[e] >= MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED)
1968
           if (++consecutive_low_temperature_error[e] >= MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED)
1969
         #endif
1969
         #endif
1981
       #else
1981
       #else
1982
         #define GEBED >=
1982
         #define GEBED >=
1983
       #endif
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
     #endif
1986
     #endif
1987
 
1987
 
1988
   } // temp_count >= OVERSAMPLENR
1988
   } // temp_count >= OVERSAMPLENR

+ 30
- 30
Marlin/temperature.h View File

99
 
99
 
100
     static float current_temperature[HOTENDS],
100
     static float current_temperature[HOTENDS],
101
                  current_temperature_bed;
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
     static volatile bool in_temp_isr;
107
     static volatile bool in_temp_isr;
108
 
108
 
217
       static millis_t next_bed_check_ms;
217
       static millis_t next_bed_check_ms;
218
     #endif
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
     // Init min and max temp with extreme values to prevent false errors during startup
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
     #ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED
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
     #endif
231
     #endif
232
 
232
 
233
     #ifdef MILLISECONDS_PREHEAT_TIME
233
     #ifdef MILLISECONDS_PREHEAT_TIME
234
-      static unsigned long preheat_end_time[HOTENDS];
234
+      static millis_t preheat_end_time[HOTENDS];
235
     #endif
235
     #endif
236
 
236
 
237
     #ifdef BED_MINTEMP
237
     #ifdef BED_MINTEMP
238
-      static int bed_minttemp_raw;
238
+      static int16_t bed_minttemp_raw;
239
     #endif
239
     #endif
240
 
240
 
241
     #ifdef BED_MAXTEMP
241
     #ifdef BED_MAXTEMP
242
-      static int bed_maxttemp_raw;
242
+      static int16_t bed_maxttemp_raw;
243
     #endif
243
     #endif
244
 
244
 
245
     #if ENABLED(FILAMENT_WIDTH_SENSOR)
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
     #endif
247
     #endif
248
 
248
 
249
     #if HAS_AUTO_FAN
249
     #if HAS_AUTO_FAN
323
     //inline so that there is no performance decrease.
323
     //inline so that there is no performance decrease.
324
     //deg=degreeCelsius
324
     //deg=degreeCelsius
325
 
325
 
326
-    static float degHotend(uint8_t e) {
326
+    static int16_t degHotend(uint8_t e) {
327
       #if HOTENDS == 1
327
       #if HOTENDS == 1
328
         UNUSED(e);
328
         UNUSED(e);
329
       #endif
329
       #endif
330
       return current_temperature[HOTEND_INDEX];
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
     #if ENABLED(SHOW_TEMP_ADC_VALUES)
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
     #endif
342
     #endif
343
 
343
 
344
-    static float degTargetHotend(uint8_t e) {
344
+    static int16_t degTargetHotend(uint8_t e) {
345
       #if HOTENDS == 1
345
       #if HOTENDS == 1
346
         UNUSED(e);
346
         UNUSED(e);
347
       #endif
347
       #endif
348
       return target_temperature[HOTEND_INDEX];
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
     #if WATCH_HOTENDS
352
     #if WATCH_HOTENDS
353
       static void start_watching_heater(uint8_t e = 0);
353
       static void start_watching_heater(uint8_t e = 0);
357
       static void start_watching_bed();
357
       static void start_watching_bed();
358
     #endif
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
       #if HOTENDS == 1
361
       #if HOTENDS == 1
362
         UNUSED(e);
362
         UNUSED(e);
363
       #endif
363
       #endif
364
       #ifdef MILLISECONDS_PREHEAT_TIME
364
       #ifdef MILLISECONDS_PREHEAT_TIME
365
-        if (celsius == 0.0f)
365
+        if (celsius == 0)
366
           reset_preheat_time(HOTEND_INDEX);
366
           reset_preheat_time(HOTEND_INDEX);
367
-        else if (target_temperature[HOTEND_INDEX] == 0.0f)
367
+        else if (target_temperature[HOTEND_INDEX] == 0)
368
           start_preheat_time(HOTEND_INDEX);
368
           start_preheat_time(HOTEND_INDEX);
369
       #endif
369
       #endif
370
       target_temperature[HOTEND_INDEX] = celsius;
370
       target_temperature[HOTEND_INDEX] = celsius;
373
       #endif
373
       #endif
374
     }
374
     }
375
 
375
 
376
-    static void setTargetBed(const float& celsius) {
376
+    static void setTargetBed(const int16_t &celsius) {
377
       target_temperature_bed = celsius;
377
       target_temperature_bed = celsius;
378
       #if WATCH_THE_BED
378
       #if WATCH_THE_BED
379
         start_watching_bed();
379
         start_watching_bed();

+ 17
- 20
Marlin/ubl_G29.cpp View File

1522
     if (isnan(ubl.z_values[x][y]) && !isnan(ubl.z_values[x1][y1]) && !isnan(ubl.z_values[x2][y2])) {
1522
     if (isnan(ubl.z_values[x][y]) && !isnan(ubl.z_values[x1][y1]) && !isnan(ubl.z_values[x2][y2])) {
1523
       if (ubl.z_values[x1][y1] < ubl.z_values[x2][y2])                  // Angled downward?
1523
       if (ubl.z_values[x1][y1] < ubl.z_values[x2][y2])                  // Angled downward?
1524
         ubl.z_values[x][y] = ubl.z_values[x1][y1];                      // Use nearest (maybe a little too high.)
1524
         ubl.z_values[x][y] = ubl.z_values[x1][y1];                      // Use nearest (maybe a little too high.)
1525
-      else {
1526
-        const float diff = ubl.z_values[x1][y1] - ubl.z_values[x2][y2]; // Angled upward
1527
-        ubl.z_values[x][y] = ubl.z_values[x1][y1] + diff;               // Use closest plus difference
1528
-      }
1525
+      else
1526
+        ubl.z_values[x][y] = 2.0 * ubl.z_values[x1][y1] - ubl.z_values[x2][y2];   // Angled upward...
1529
       return true;
1527
       return true;
1530
     }
1528
     }
1531
     return false;
1529
     return false;
1533
 
1531
 
1534
   typedef struct { uint8_t sx, ex, sy, ey; bool yfirst; } smart_fill_info;
1532
   typedef struct { uint8_t sx, ex, sy, ey; bool yfirst; } smart_fill_info;
1535
 
1533
 
1536
-  void smart_fill_loop(const smart_fill_info &f) {
1537
-    if (f.yfirst) {
1538
-      const int8_t dir = f.ex > f.sx ? 1 : -1;
1539
-      for (uint8_t y = f.sy; y != f.ey; ++y)
1540
-        for (uint8_t x = f.sx; x != f.ex; x += dir)
1541
-          if (smart_fill_one(x, y, dir, 0)) break;
1542
-    }
1543
-    else {
1544
-      const int8_t dir = f.ey > f.sy ? 1 : -1;
1545
-       for (uint8_t x = f.sx; x != f.ex; ++x)
1546
-        for (uint8_t y = f.sy; y != f.ey; y += dir)
1547
-          if (smart_fill_one(x, y, 0, dir)) break;
1548
-    }
1549
-  }
1550
-
1551
   void smart_fill_mesh() {
1534
   void smart_fill_mesh() {
1552
     const smart_fill_info info[] = {
1535
     const smart_fill_info info[] = {
1553
       { 0, GRID_MAX_POINTS_X,      0, GRID_MAX_POINTS_Y - 2,  false },  // Bottom of the mesh looking up
1536
       { 0, GRID_MAX_POINTS_X,      0, GRID_MAX_POINTS_Y - 2,  false },  // Bottom of the mesh looking up
1555
       { 0, GRID_MAX_POINTS_X - 2,  0, GRID_MAX_POINTS_Y,      true  },  // Left side of the mesh looking right
1538
       { 0, GRID_MAX_POINTS_X - 2,  0, GRID_MAX_POINTS_Y,      true  },  // Left side of the mesh looking right
1556
       { GRID_MAX_POINTS_X - 1, 0,  0, GRID_MAX_POINTS_Y,      true  }   // Right side of the mesh looking left
1539
       { GRID_MAX_POINTS_X - 1, 0,  0, GRID_MAX_POINTS_Y,      true  }   // Right side of the mesh looking left
1557
     };
1540
     };
1558
-    for (uint8_t i = 0; i < COUNT(info); ++i) smart_fill_loop(info[i]);
1541
+    for (uint8_t i = 0; i < COUNT(info); ++i) {
1542
+      const smart_fill_info &f = info[i];
1543
+      if (f.yfirst) {
1544
+        const int8_t dir = f.ex > f.sx ? 1 : -1;
1545
+        for (uint8_t y = f.sy; y != f.ey; ++y)
1546
+          for (uint8_t x = f.sx; x != f.ex; x += dir)
1547
+            if (smart_fill_one(x, y, dir, 0)) break;
1548
+      }
1549
+      else {
1550
+        const int8_t dir = f.ey > f.sy ? 1 : -1;
1551
+         for (uint8_t x = f.sx; x != f.ex; ++x)
1552
+          for (uint8_t y = f.sy; y != f.ey; y += dir)
1553
+            if (smart_fill_one(x, y, 0, dir)) break;
1554
+      }
1555
+    }
1559
   }
1556
   }
1560
 
1557
 
1561
   void unified_bed_leveling::tilt_mesh_based_on_probed_grid(const bool do_ubl_mesh_map) {
1558
   void unified_bed_leveling::tilt_mesh_based_on_probed_grid(const bool do_ubl_mesh_map) {

+ 2
- 2
Marlin/ultralcd.cpp View File

1179
     }
1179
     }
1180
   #endif
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
    * "Prepare" submenu items
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
     if (temph > 0) thermalManager.setTargetHotend(min(heater_maxtemp[endnum], temph), endnum);
1190
     if (temph > 0) thermalManager.setTargetHotend(min(heater_maxtemp[endnum], temph), endnum);
1191
     #if TEMP_SENSOR_BED != 0
1191
     #if TEMP_SENSOR_BED != 0
1192
       if (tempb >= 0) thermalManager.setTargetBed(tempb);
1192
       if (tempb >= 0) thermalManager.setTargetBed(tempb);

Loading…
Cancel
Save