Browse Source

Prevent 'current' name conflict, if needed

Scott Lahteine 5 years ago
parent
commit
565a0e11ed

+ 2
- 3
Marlin/src/HAL/HAL_STM32_F4_F7/STM32F7/TMC2660.cpp View File

831
         SERIAL_ECHOPAIR("\n  Stall Guard value:", value);
831
         SERIAL_ECHOPAIR("\n  Stall Guard value:", value);
832
       }
832
       }
833
       else if (readout_config == READ_STALL_GUARD_AND_COOL_STEP) {
833
       else if (readout_config == READ_STALL_GUARD_AND_COOL_STEP) {
834
-        int16_t stallGuard = value & 0xF, current = value & 0x1F0;
835
-        SERIAL_ECHOPAIR("\n  Approx Stall Guard: ", stallGuard);
836
-        SERIAL_ECHOPAIR("\n  Current level", current);
834
+        SERIAL_ECHOPAIR("\n  Approx Stall Guard: ", value & 0xF);
835
+        SERIAL_ECHOPAIR("\n  Current level", value & 0x1F0);
837
       }
836
       }
838
     }
837
     }
839
   #endif
838
   #endif

+ 7
- 7
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp View File

757
       do {
757
       do {
758
         if (do_ubl_mesh_map) display_map(g29_map_type);
758
         if (do_ubl_mesh_map) display_map(g29_map_type);
759
 
759
 
760
-        const int current = (GRID_MAX_POINTS) - count + 1;
761
-        SERIAL_ECHOLNPAIR("\nProbing mesh point ", current, "/", int(GRID_MAX_POINTS), ".\n");
760
+        const int point_num = (GRID_MAX_POINTS) - count + 1;
761
+        SERIAL_ECHOLNPAIR("\nProbing mesh point ", point_num, "/", int(GRID_MAX_POINTS), ".\n");
762
         #if HAS_DISPLAY
762
         #if HAS_DISPLAY
763
-          ui.status_printf_P(0, PSTR(MSG_PROBING_MESH " %i/%i"), current, int(GRID_MAX_POINTS));
763
+          ui.status_printf_P(0, PSTR(MSG_PROBING_MESH " %i/%i"), point_num, int(GRID_MAX_POINTS));
764
         #endif
764
         #endif
765
 
765
 
766
         #if HAS_LCD_MENU
766
         #if HAS_LCD_MENU
1477
 
1477
 
1478
         bool zig_zag = false;
1478
         bool zig_zag = false;
1479
 
1479
 
1480
-        uint16_t total_points = g29_grid_size * g29_grid_size, current = 1;
1480
+        uint16_t total_points = g29_grid_size * g29_grid_size, point_num = 1;
1481
 
1481
 
1482
         for (uint8_t ix = 0; ix < g29_grid_size; ix++) {
1482
         for (uint8_t ix = 0; ix < g29_grid_size; ix++) {
1483
           const float rx = float(x_min) + ix * dx;
1483
           const float rx = float(x_min) + ix * dx;
1485
             const float ry = float(y_min) + dy * (zig_zag ? g29_grid_size - 1 - iy : iy);
1485
             const float ry = float(y_min) + dy * (zig_zag ? g29_grid_size - 1 - iy : iy);
1486
 
1486
 
1487
             if (!abort_flag) {
1487
             if (!abort_flag) {
1488
-              SERIAL_ECHOLNPAIR("Tilting mesh point ", current, "/", total_points, "\n");
1488
+              SERIAL_ECHOLNPAIR("Tilting mesh point ", point_num, "/", total_points, "\n");
1489
               #if HAS_DISPLAY
1489
               #if HAS_DISPLAY
1490
-                ui.status_printf_P(0, PSTR(MSG_LCD_TILTING_MESH " %i/%i"), current, total_points);
1490
+                ui.status_printf_P(0, PSTR(MSG_LCD_TILTING_MESH " %i/%i"), point_num, total_points);
1491
               #endif
1491
               #endif
1492
 
1492
 
1493
               measured_z = probe_pt(rx, ry, parser.seen('E') ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level); // TODO: Needs error handling
1493
               measured_z = probe_pt(rx, ry, parser.seen('E') ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level); // TODO: Needs error handling
1518
               incremental_LSF(&lsf_results, rx, ry, measured_z);
1518
               incremental_LSF(&lsf_results, rx, ry, measured_z);
1519
             }
1519
             }
1520
 
1520
 
1521
-            current++;
1521
+            point_num++;
1522
           }
1522
           }
1523
 
1523
 
1524
           zig_zag ^= true;
1524
           zig_zag ^= true;

+ 3
- 3
Marlin/src/lcd/extensible_ui/lib/dgus/DGUSDisplayDefinition.cpp View File

166
 
166
 
167
   // Temperature Data
167
   // Temperature Data
168
   #if HOTENDS >= 1
168
   #if HOTENDS >= 1
169
-    VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[0].current, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<0>),
169
+    VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[0].celsius, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<0>),
170
     VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[0].target, DGUSScreenVariableHandler::HandleTemperatureChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay),
170
     VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[0].target, DGUSScreenVariableHandler::HandleTemperatureChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay),
171
     VPHELPER(VP_Flowrate_E1, nullptr, DGUSScreenVariableHandler::HandleFlowRateChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay),
171
     VPHELPER(VP_Flowrate_E1, nullptr, DGUSScreenVariableHandler::HandleFlowRateChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay),
172
     VPHELPER(VP_EPos, &destination[3], nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<2>),
172
     VPHELPER(VP_EPos, &destination[3], nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<2>),
173
     VPHELPER(VP_MOVE_E1, nullptr, &DGUSScreenVariableHandler::HandleManualExtrude, nullptr),
173
     VPHELPER(VP_MOVE_E1, nullptr, &DGUSScreenVariableHandler::HandleManualExtrude, nullptr),
174
   #endif
174
   #endif
175
   #if HOTENDS >= 2
175
   #if HOTENDS >= 2
176
-    VPHELPER(VP_T_E2_I, &thermalManager.temp_hotend[1].current, nullptr, DGUSLCD_SendFloatAsLongValueToDisplay<0>),
176
+    VPHELPER(VP_T_E2_I, &thermalManager.temp_hotend[1].celsius, nullptr, DGUSLCD_SendFloatAsLongValueToDisplay<0>),
177
     VPHELPER(VP_T_E2_S, &thermalManager.temp_hotend[1].target, DGUSScreenVariableHandler::HandleTemperatureChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay),
177
     VPHELPER(VP_T_E2_S, &thermalManager.temp_hotend[1].target, DGUSScreenVariableHandler::HandleTemperatureChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay),
178
     VPHELPER(VP_Flowrate_E2, nullptr, DGUSScreenVariableHandler::HandleFlowRateChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay),
178
     VPHELPER(VP_Flowrate_E2, nullptr, DGUSScreenVariableHandler::HandleFlowRateChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay),
179
     VPHELPER(VP_MOVE_E2, nullptr, &DGUSScreenVariableHandler::HandleManualExtrude, nullptr),
179
     VPHELPER(VP_MOVE_E2, nullptr, &DGUSScreenVariableHandler::HandleManualExtrude, nullptr),
182
     #error More than 2 Hotends currently not implemented on the Display UI design.
182
     #error More than 2 Hotends currently not implemented on the Display UI design.
183
   #endif
183
   #endif
184
   #if HAS_HEATED_BED
184
   #if HAS_HEATED_BED
185
-    VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.current, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<0>),
185
+    VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<0>),
186
     VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, DGUSScreenVariableHandler::HandleTemperatureChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay),
186
     VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, DGUSScreenVariableHandler::HandleTemperatureChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay),
187
   #endif
187
   #endif
188
 
188
 

+ 19
- 19
Marlin/src/module/planner.cpp View File

994
   //  pass will never modify the values at the tail.
994
   //  pass will never modify the values at the tail.
995
   uint8_t block_index = block_buffer_planned;
995
   uint8_t block_index = block_buffer_planned;
996
 
996
 
997
-  block_t *current;
997
+  block_t *block;
998
   const block_t * previous = nullptr;
998
   const block_t * previous = nullptr;
999
   while (block_index != block_buffer_head) {
999
   while (block_index != block_buffer_head) {
1000
 
1000
 
1001
     // Perform the forward pass
1001
     // Perform the forward pass
1002
-    current = &block_buffer[block_index];
1002
+    block = &block_buffer[block_index];
1003
 
1003
 
1004
     // Skip SYNC blocks
1004
     // Skip SYNC blocks
1005
-    if (!TEST(current->flag, BLOCK_BIT_SYNC_POSITION)) {
1005
+    if (!TEST(block->flag, BLOCK_BIT_SYNC_POSITION)) {
1006
       // If there's no previous block or the previous block is not
1006
       // If there's no previous block or the previous block is not
1007
       // BUSY (thus, modifiable) run the forward_pass_kernel. Otherwise,
1007
       // BUSY (thus, modifiable) run the forward_pass_kernel. Otherwise,
1008
       // the previous block became BUSY, so assume the current block's
1008
       // the previous block became BUSY, so assume the current block's
1009
       // entry speed can't be altered (since that would also require
1009
       // entry speed can't be altered (since that would also require
1010
       // updating the exit speed of the previous block).
1010
       // updating the exit speed of the previous block).
1011
       if (!previous || !stepper.is_block_busy(previous))
1011
       if (!previous || !stepper.is_block_busy(previous))
1012
-        forward_pass_kernel(previous, current, block_index);
1013
-      previous = current;
1012
+        forward_pass_kernel(previous, block, block_index);
1013
+      previous = block;
1014
     }
1014
     }
1015
     // Advance to the previous
1015
     // Advance to the previous
1016
     block_index = next_block_index(block_index);
1016
     block_index = next_block_index(block_index);
1045
   }
1045
   }
1046
 
1046
 
1047
   // Go from the tail (currently executed block) to the first block, without including it)
1047
   // Go from the tail (currently executed block) to the first block, without including it)
1048
-  block_t *current = nullptr, *next = nullptr;
1048
+  block_t *block = nullptr, *next = nullptr;
1049
   float current_entry_speed = 0.0, next_entry_speed = 0.0;
1049
   float current_entry_speed = 0.0, next_entry_speed = 0.0;
1050
   while (block_index != head_block_index) {
1050
   while (block_index != head_block_index) {
1051
 
1051
 
1055
     if (!TEST(next->flag, BLOCK_BIT_SYNC_POSITION)) {
1055
     if (!TEST(next->flag, BLOCK_BIT_SYNC_POSITION)) {
1056
       next_entry_speed = SQRT(next->entry_speed_sqr);
1056
       next_entry_speed = SQRT(next->entry_speed_sqr);
1057
 
1057
 
1058
-      if (current) {
1058
+      if (block) {
1059
         // Recalculate if current block entry or exit junction speed has changed.
1059
         // Recalculate if current block entry or exit junction speed has changed.
1060
-        if (TEST(current->flag, BLOCK_BIT_RECALCULATE) || TEST(next->flag, BLOCK_BIT_RECALCULATE)) {
1060
+        if (TEST(block->flag, BLOCK_BIT_RECALCULATE) || TEST(next->flag, BLOCK_BIT_RECALCULATE)) {
1061
 
1061
 
1062
           // Mark the current block as RECALCULATE, to protect it from the Stepper ISR running it.
1062
           // Mark the current block as RECALCULATE, to protect it from the Stepper ISR running it.
1063
           // Note that due to the above condition, there's a chance the current block isn't marked as
1063
           // Note that due to the above condition, there's a chance the current block isn't marked as
1064
           // RECALCULATE yet, but the next one is. That's the reason for the following line.
1064
           // RECALCULATE yet, but the next one is. That's the reason for the following line.
1065
-          SBI(current->flag, BLOCK_BIT_RECALCULATE);
1065
+          SBI(block->flag, BLOCK_BIT_RECALCULATE);
1066
 
1066
 
1067
           // But there is an inherent race condition here, as the block maybe
1067
           // But there is an inherent race condition here, as the block maybe
1068
           // became BUSY, just before it was marked as RECALCULATE, so check
1068
           // became BUSY, just before it was marked as RECALCULATE, so check
1069
           // if that is the case!
1069
           // if that is the case!
1070
-          if (!stepper.is_block_busy(current)) {
1070
+          if (!stepper.is_block_busy(block)) {
1071
             // Block is not BUSY, we won the race against the Stepper ISR:
1071
             // Block is not BUSY, we won the race against the Stepper ISR:
1072
 
1072
 
1073
             // NOTE: Entry and exit factors always > 0 by all previous logic operations.
1073
             // NOTE: Entry and exit factors always > 0 by all previous logic operations.
1074
-            const float current_nominal_speed = SQRT(current->nominal_speed_sqr),
1074
+            const float current_nominal_speed = SQRT(block->nominal_speed_sqr),
1075
                         nomr = 1.0f / current_nominal_speed;
1075
                         nomr = 1.0f / current_nominal_speed;
1076
-            calculate_trapezoid_for_block(current, current_entry_speed * nomr, next_entry_speed * nomr);
1076
+            calculate_trapezoid_for_block(block, current_entry_speed * nomr, next_entry_speed * nomr);
1077
             #if ENABLED(LIN_ADVANCE)
1077
             #if ENABLED(LIN_ADVANCE)
1078
-              if (current->use_advance_lead) {
1079
-                const float comp = current->e_D_ratio * extruder_advance_K[active_extruder] * settings.axis_steps_per_mm[E_AXIS];
1080
-                current->max_adv_steps = current_nominal_speed * comp;
1081
-                current->final_adv_steps = next_entry_speed * comp;
1078
+              if (block->use_advance_lead) {
1079
+                const float comp = block->e_D_ratio * extruder_advance_K[active_extruder] * settings.axis_steps_per_mm[E_AXIS];
1080
+                block->max_adv_steps = current_nominal_speed * comp;
1081
+                block->final_adv_steps = next_entry_speed * comp;
1082
               }
1082
               }
1083
             #endif
1083
             #endif
1084
           }
1084
           }
1085
 
1085
 
1086
           // Reset current only to ensure next trapezoid is computed - The
1086
           // Reset current only to ensure next trapezoid is computed - The
1087
           // stepper is free to use the block from now on.
1087
           // stepper is free to use the block from now on.
1088
-          CBI(current->flag, BLOCK_BIT_RECALCULATE);
1088
+          CBI(block->flag, BLOCK_BIT_RECALCULATE);
1089
         }
1089
         }
1090
       }
1090
       }
1091
 
1091
 
1092
-      current = next;
1092
+      block = next;
1093
       current_entry_speed = next_entry_speed;
1093
       current_entry_speed = next_entry_speed;
1094
     }
1094
     }
1095
 
1095
 
1107
     // But there is an inherent race condition here, as the block maybe
1107
     // But there is an inherent race condition here, as the block maybe
1108
     // became BUSY, just before it was marked as RECALCULATE, so check
1108
     // became BUSY, just before it was marked as RECALCULATE, so check
1109
     // if that is the case!
1109
     // if that is the case!
1110
-    if (!stepper.is_block_busy(current)) {
1110
+    if (!stepper.is_block_busy(block)) {
1111
       // Block is not BUSY, we won the race against the Stepper ISR:
1111
       // Block is not BUSY, we won the race against the Stepper ISR:
1112
 
1112
 
1113
       const float next_nominal_speed = SQRT(next->nominal_speed_sqr),
1113
       const float next_nominal_speed = SQRT(next->nominal_speed_sqr),

+ 46
- 46
Marlin/src/module/temperature.cpp View File

346
    * temperature to succeed.
346
    * temperature to succeed.
347
    */
347
    */
348
   void Temperature::PID_autotune(const float &target, const heater_ind_t heater, const int8_t ncycles, const bool set_result/*=false*/) {
348
   void Temperature::PID_autotune(const float &target, const heater_ind_t heater, const int8_t ncycles, const bool set_result/*=false*/) {
349
-    float current = 0.0;
349
+    float current_temp = 0.0;
350
     int cycles = 0;
350
     int cycles = 0;
351
     bool heating = true;
351
     bool heating = true;
352
 
352
 
410
 
410
 
411
     wait_for_heatup = true; // Can be interrupted with M108
411
     wait_for_heatup = true; // Can be interrupted with M108
412
     #if ENABLED(PRINTER_EVENT_LEDS)
412
     #if ENABLED(PRINTER_EVENT_LEDS)
413
-      const float start_temp = GHV(temp_bed.current, temp_hotend[heater].current);
413
+      const float start_temp = GHV(temp_bed.celsius, temp_hotend[heater].celsius);
414
       LEDColor color = ONHEATINGSTART();
414
       LEDColor color = ONHEATINGSTART();
415
     #endif
415
     #endif
416
 
416
 
427
         updateTemperaturesFromRawValues();
427
         updateTemperaturesFromRawValues();
428
 
428
 
429
         // Get the current temperature and constrain it
429
         // Get the current temperature and constrain it
430
-        current = GHV(temp_bed.current, temp_hotend[heater].current);
431
-        NOLESS(maxT, current);
432
-        NOMORE(minT, current);
430
+        current_temp = GHV(temp_bed.celsius, temp_hotend[heater].celsius);
431
+        NOLESS(maxT, current_temp);
432
+        NOMORE(minT, current_temp);
433
 
433
 
434
         #if ENABLED(PRINTER_EVENT_LEDS)
434
         #if ENABLED(PRINTER_EVENT_LEDS)
435
-          ONHEATING(start_temp, current, target);
435
+          ONHEATING(start_temp, current_temp, target);
436
         #endif
436
         #endif
437
 
437
 
438
         #if HAS_AUTO_FAN
438
         #if HAS_AUTO_FAN
442
           }
442
           }
443
         #endif
443
         #endif
444
 
444
 
445
-        if (heating && current > target) {
445
+        if (heating && current_temp > target) {
446
           if (ELAPSED(ms, t2 + 5000UL)) {
446
           if (ELAPSED(ms, t2 + 5000UL)) {
447
             heating = false;
447
             heating = false;
448
             SHV((bias - d) >> 1, (bias - d) >> 1);
448
             SHV((bias - d) >> 1, (bias - d) >> 1);
452
           }
452
           }
453
         }
453
         }
454
 
454
 
455
-        if (!heating && current < target) {
455
+        if (!heating && current_temp < target) {
456
           if (ELAPSED(ms, t1 + 5000UL)) {
456
           if (ELAPSED(ms, t1 + 5000UL)) {
457
             heating = true;
457
             heating = true;
458
             t2 = ms;
458
             t2 = ms;
510
       #ifndef MAX_OVERSHOOT_PID_AUTOTUNE
510
       #ifndef MAX_OVERSHOOT_PID_AUTOTUNE
511
         #define MAX_OVERSHOOT_PID_AUTOTUNE 20
511
         #define MAX_OVERSHOOT_PID_AUTOTUNE 20
512
       #endif
512
       #endif
513
-      if (current > target + MAX_OVERSHOOT_PID_AUTOTUNE) {
513
+      if (current_temp > target + MAX_OVERSHOOT_PID_AUTOTUNE) {
514
         SERIAL_ECHOLNPGM(MSG_PID_TEMP_TOO_HIGH);
514
         SERIAL_ECHOLNPGM(MSG_PID_TEMP_TOO_HIGH);
515
         break;
515
         break;
516
       }
516
       }
535
             #endif
535
             #endif
536
           ) {
536
           ) {
537
             if (!heated) {                                          // If not yet reached target...
537
             if (!heated) {                                          // If not yet reached target...
538
-              if (current > next_watch_temp) {                      // Over the watch temp?
539
-                next_watch_temp = current + watch_temp_increase;    // - set the next temp to watch for
538
+              if (current_temp > next_watch_temp) {                      // Over the watch temp?
539
+                next_watch_temp = current_temp + watch_temp_increase;    // - set the next temp to watch for
540
                 temp_change_ms = ms + watch_temp_period * 1000UL;   // - move the expiration timer up
540
                 temp_change_ms = ms + watch_temp_period * 1000UL;   // - move the expiration timer up
541
-                if (current > watch_temp_target) heated = true;     // - Flag if target temperature reached
541
+                if (current_temp > watch_temp_target) heated = true;     // - Flag if target temperature reached
542
               }
542
               }
543
               else if (ELAPSED(ms, temp_change_ms))                 // Watch timer expired
543
               else if (ELAPSED(ms, temp_change_ms))                 // Watch timer expired
544
                 _temp_error(heater, PSTR(MSG_T_HEATING_FAILED), TEMP_ERR_PSTR(MSG_HEATING_FAILED_LCD, heater));
544
                 _temp_error(heater, PSTR(MSG_T_HEATING_FAILED), TEMP_ERR_PSTR(MSG_HEATING_FAILED_LCD, heater));
545
             }
545
             }
546
-            else if (current < target - (MAX_OVERSHOOT_PID_AUTOTUNE)) // Heated, then temperature fell too far?
546
+            else if (current_temp < target - (MAX_OVERSHOOT_PID_AUTOTUNE)) // Heated, then temperature fell too far?
547
               _temp_error(heater, PSTR(MSG_T_THERMAL_RUNAWAY), TEMP_ERR_PSTR(MSG_THERMAL_RUNAWAY, heater));
547
               _temp_error(heater, PSTR(MSG_T_THERMAL_RUNAWAY), TEMP_ERR_PSTR(MSG_THERMAL_RUNAWAY, heater));
548
           }
548
           }
549
         #endif
549
         #endif
685
     uint8_t fanState = 0;
685
     uint8_t fanState = 0;
686
 
686
 
687
     HOTEND_LOOP()
687
     HOTEND_LOOP()
688
-      if (temp_hotend[e].current >= EXTRUDER_AUTO_FAN_TEMPERATURE)
688
+      if (temp_hotend[e].celsius >= EXTRUDER_AUTO_FAN_TEMPERATURE)
689
         SBI(fanState, pgm_read_byte(&fanBit[e]));
689
         SBI(fanState, pgm_read_byte(&fanBit[e]));
690
 
690
 
691
     #if HAS_AUTO_CHAMBER_FAN
691
     #if HAS_AUTO_CHAMBER_FAN
692
-      if (temp_chamber.current >= CHAMBER_AUTO_FAN_TEMPERATURE)
692
+      if (temp_chamber.celsius >= CHAMBER_AUTO_FAN_TEMPERATURE)
693
         SBI(fanState, pgm_read_byte(&fanBit[CHAMBER_FAN_INDEX]));
693
         SBI(fanState, pgm_read_byte(&fanBit[CHAMBER_FAN_INDEX]));
694
     #endif
694
     #endif
695
 
695
 
831
       static float temp_iState[HOTENDS] = { 0 },
831
       static float temp_iState[HOTENDS] = { 0 },
832
                    temp_dState[HOTENDS] = { 0 };
832
                    temp_dState[HOTENDS] = { 0 };
833
       static bool pid_reset[HOTENDS] = { false };
833
       static bool pid_reset[HOTENDS] = { false };
834
-      const float pid_error = temp_hotend[ee].target - temp_hotend[ee].current;
834
+      const float pid_error = temp_hotend[ee].target - temp_hotend[ee].celsius;
835
 
835
 
836
       if (temp_hotend[ee].target == 0
836
       if (temp_hotend[ee].target == 0
837
         || pid_error < -(PID_FUNCTIONAL_RANGE)
837
         || pid_error < -(PID_FUNCTIONAL_RANGE)
853
           pid_reset[ee] = false;
853
           pid_reset[ee] = false;
854
         }
854
         }
855
 
855
 
856
-        work_pid[ee].Kd = work_pid[ee].Kd + PID_K2 * (PID_PARAM(Kd, ee) * (temp_dState[ee] - temp_hotend[ee].current) - work_pid[ee].Kd);
856
+        work_pid[ee].Kd = work_pid[ee].Kd + PID_K2 * (PID_PARAM(Kd, ee) * (temp_dState[ee] - temp_hotend[ee].celsius) - work_pid[ee].Kd);
857
         const float max_power_over_i_gain = float(PID_MAX) / PID_PARAM(Ki, ee) - float(MIN_POWER);
857
         const float max_power_over_i_gain = float(PID_MAX) / PID_PARAM(Ki, ee) - float(MIN_POWER);
858
         temp_iState[ee] = constrain(temp_iState[ee] + pid_error, 0, max_power_over_i_gain);
858
         temp_iState[ee] = constrain(temp_iState[ee] + pid_error, 0, max_power_over_i_gain);
859
         work_pid[ee].Kp = PID_PARAM(Kp, ee) * pid_error;
859
         work_pid[ee].Kp = PID_PARAM(Kp, ee) * pid_error;
880
 
880
 
881
         LIMIT(pid_output, 0, PID_MAX);
881
         LIMIT(pid_output, 0, PID_MAX);
882
       }
882
       }
883
-      temp_dState[ee] = temp_hotend[ee].current;
883
+      temp_dState[ee] = temp_hotend[ee].celsius;
884
 
884
 
885
     #else // PID_OPENLOOP
885
     #else // PID_OPENLOOP
886
 
886
 
893
         SERIAL_ECHO_START();
893
         SERIAL_ECHO_START();
894
         SERIAL_ECHOPAIR(
894
         SERIAL_ECHOPAIR(
895
           MSG_PID_DEBUG, ee,
895
           MSG_PID_DEBUG, ee,
896
-          MSG_PID_DEBUG_INPUT, temp_hotend[ee].current,
896
+          MSG_PID_DEBUG_INPUT, temp_hotend[ee].celsius,
897
           MSG_PID_DEBUG_OUTPUT, pid_output
897
           MSG_PID_DEBUG_OUTPUT, pid_output
898
         );
898
         );
899
         #if DISABLED(PID_OPENLOOP)
899
         #if DISABLED(PID_OPENLOOP)
917
     #else
917
     #else
918
       #define _TIMED_OUT_TEST false
918
       #define _TIMED_OUT_TEST false
919
     #endif
919
     #endif
920
-    pid_output = (!_TIMED_OUT_TEST && temp_hotend[ee].current < temp_hotend[ee].target) ? BANG_MAX : 0;
920
+    pid_output = (!_TIMED_OUT_TEST && temp_hotend[ee].celsius < temp_hotend[ee].target) ? BANG_MAX : 0;
921
     #undef _TIMED_OUT_TEST
921
     #undef _TIMED_OUT_TEST
922
 
922
 
923
   #endif
923
   #endif
936
       static bool pid_reset = true;
936
       static bool pid_reset = true;
937
       float pid_output = 0;
937
       float pid_output = 0;
938
       const float max_power_over_i_gain = float(MAX_BED_POWER) / temp_bed.pid.Ki - float(MIN_BED_POWER),
938
       const float max_power_over_i_gain = float(MAX_BED_POWER) / temp_bed.pid.Ki - float(MIN_BED_POWER),
939
-                  pid_error = temp_bed.target - temp_bed.current;
939
+                  pid_error = temp_bed.target - temp_bed.celsius;
940
 
940
 
941
       if (!temp_bed.target || pid_error < -(PID_FUNCTIONAL_RANGE)) {
941
       if (!temp_bed.target || pid_error < -(PID_FUNCTIONAL_RANGE)) {
942
         pid_output = 0;
942
         pid_output = 0;
957
 
957
 
958
         work_pid.Kp = temp_bed.pid.Kp * pid_error;
958
         work_pid.Kp = temp_bed.pid.Kp * pid_error;
959
         work_pid.Ki = temp_bed.pid.Ki * temp_iState;
959
         work_pid.Ki = temp_bed.pid.Ki * temp_iState;
960
-        work_pid.Kd = work_pid.Kd + PID_K2 * (temp_bed.pid.Kd * (temp_dState - temp_bed.current) - work_pid.Kd);
960
+        work_pid.Kd = work_pid.Kd + PID_K2 * (temp_bed.pid.Kd * (temp_dState - temp_bed.celsius) - work_pid.Kd);
961
 
961
 
962
-        temp_dState = temp_bed.current;
962
+        temp_dState = temp_bed.celsius;
963
 
963
 
964
         pid_output = constrain(work_pid.Kp + work_pid.Ki + work_pid.Kd + float(MIN_BED_POWER), 0, MAX_BED_POWER);
964
         pid_output = constrain(work_pid.Kp + work_pid.Ki + work_pid.Kd + float(MIN_BED_POWER), 0, MAX_BED_POWER);
965
       }
965
       }
973
     #if ENABLED(PID_BED_DEBUG)
973
     #if ENABLED(PID_BED_DEBUG)
974
       SERIAL_ECHO_START();
974
       SERIAL_ECHO_START();
975
       SERIAL_ECHOLNPAIR(
975
       SERIAL_ECHOLNPAIR(
976
-        " PID_BED_DEBUG : Input ", temp_bed.current, " Output ", pid_output,
976
+        " PID_BED_DEBUG : Input ", temp_bed.celsius, " Output ", pid_output,
977
         #if DISABLED(PID_OPENLOOP)
977
         #if DISABLED(PID_OPENLOOP)
978
           MSG_PID_DEBUG_PTERM, work_pid.Kp,
978
           MSG_PID_DEBUG_PTERM, work_pid.Kp,
979
           MSG_PID_DEBUG_ITERM, work_pid.Ki,
979
           MSG_PID_DEBUG_ITERM, work_pid.Ki,
1016
   updateTemperaturesFromRawValues(); // also resets the watchdog
1016
   updateTemperaturesFromRawValues(); // also resets the watchdog
1017
 
1017
 
1018
   #if ENABLED(HEATER_0_USES_MAX6675)
1018
   #if ENABLED(HEATER_0_USES_MAX6675)
1019
-    if (temp_hotend[0].current > _MIN(HEATER_0_MAXTEMP, HEATER_0_MAX6675_TMAX - 1.0)) max_temp_error(H_E0);
1020
-    if (temp_hotend[0].current < _MAX(HEATER_0_MINTEMP, HEATER_0_MAX6675_TMIN + .01)) min_temp_error(H_E0);
1019
+    if (temp_hotend[0].celsius > _MIN(HEATER_0_MAXTEMP, HEATER_0_MAX6675_TMAX - 1.0)) max_temp_error(H_E0);
1020
+    if (temp_hotend[0].celsius < _MAX(HEATER_0_MINTEMP, HEATER_0_MAX6675_TMIN + .01)) min_temp_error(H_E0);
1021
   #endif
1021
   #endif
1022
 
1022
 
1023
   #if ENABLED(HEATER_1_USES_MAX6675)
1023
   #if ENABLED(HEATER_1_USES_MAX6675)
1024
-    if (temp_hotend[1].current > _MIN(HEATER_1_MAXTEMP, HEATER_1_MAX6675_TMAX - 1.0)) max_temp_error(H_E1);
1025
-    if (temp_hotend[1].current < _MAX(HEATER_1_MINTEMP, HEATER_1_MAX6675_TMIN + .01)) min_temp_error(H_E1);
1024
+    if (temp_hotend[1].celsius > _MIN(HEATER_1_MAXTEMP, HEATER_1_MAX6675_TMAX - 1.0)) max_temp_error(H_E1);
1025
+    if (temp_hotend[1].celsius < _MAX(HEATER_1_MINTEMP, HEATER_1_MAX6675_TMIN + .01)) min_temp_error(H_E1);
1026
   #endif
1026
   #endif
1027
 
1027
 
1028
   #if HAS_THERMAL_PROTECTION || DISABLED(PIDTEMPBED) || HAS_AUTO_FAN || HEATER_IDLE_HANDLER
1028
   #if HAS_THERMAL_PROTECTION || DISABLED(PIDTEMPBED) || HAS_AUTO_FAN || HEATER_IDLE_HANDLER
1041
 
1041
 
1042
     #if ENABLED(THERMAL_PROTECTION_HOTENDS)
1042
     #if ENABLED(THERMAL_PROTECTION_HOTENDS)
1043
       // Check for thermal runaway
1043
       // Check for thermal runaway
1044
-      thermal_runaway_protection(tr_state_machine[e], temp_hotend[e].current, temp_hotend[e].target, (heater_ind_t)e, THERMAL_PROTECTION_PERIOD, THERMAL_PROTECTION_HYSTERESIS);
1044
+      thermal_runaway_protection(tr_state_machine[e], temp_hotend[e].celsius, temp_hotend[e].target, (heater_ind_t)e, THERMAL_PROTECTION_PERIOD, THERMAL_PROTECTION_HYSTERESIS);
1045
     #endif
1045
     #endif
1046
 
1046
 
1047
-    temp_hotend[e].soft_pwm_amount = (temp_hotend[e].current > temp_range[e].mintemp || is_preheating(e)) && temp_hotend[e].current < temp_range[e].maxtemp ? (int)get_pid_output_hotend(e) >> 1 : 0;
1047
+    temp_hotend[e].soft_pwm_amount = (temp_hotend[e].celsius > temp_range[e].mintemp || is_preheating(e)) && temp_hotend[e].celsius < temp_range[e].maxtemp ? (int)get_pid_output_hotend(e) >> 1 : 0;
1048
 
1048
 
1049
     #if WATCH_HOTENDS
1049
     #if WATCH_HOTENDS
1050
       // Make sure temperature is increasing
1050
       // Make sure temperature is increasing
1058
 
1058
 
1059
     #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
1059
     #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
1060
       // Make sure measured temperatures are close together
1060
       // Make sure measured temperatures are close together
1061
-      if (ABS(temp_hotend[0].current - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF)
1061
+      if (ABS(temp_hotend[0].celsius - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF)
1062
         _temp_error(H_E0, PSTR(MSG_REDUNDANCY), PSTR(MSG_ERR_REDUNDANT_TEMP));
1062
         _temp_error(H_E0, PSTR(MSG_REDUNDANCY), PSTR(MSG_ERR_REDUNDANT_TEMP));
1063
     #endif
1063
     #endif
1064
 
1064
 
1120
       #endif
1120
       #endif
1121
 
1121
 
1122
       #if HAS_THERMALLY_PROTECTED_BED
1122
       #if HAS_THERMALLY_PROTECTED_BED
1123
-        thermal_runaway_protection(tr_state_machine_bed, temp_bed.current, temp_bed.target, H_BED, THERMAL_PROTECTION_BED_PERIOD, THERMAL_PROTECTION_BED_HYSTERESIS);
1123
+        thermal_runaway_protection(tr_state_machine_bed, temp_bed.celsius, temp_bed.target, H_BED, THERMAL_PROTECTION_BED_PERIOD, THERMAL_PROTECTION_BED_HYSTERESIS);
1124
       #endif
1124
       #endif
1125
 
1125
 
1126
       #if HEATER_IDLE_HANDLER
1126
       #if HEATER_IDLE_HANDLER
1134
       #endif
1134
       #endif
1135
       {
1135
       {
1136
         #if ENABLED(PIDTEMPBED)
1136
         #if ENABLED(PIDTEMPBED)
1137
-          temp_bed.soft_pwm_amount = WITHIN(temp_bed.current, BED_MINTEMP, BED_MAXTEMP) ? (int)get_pid_output_bed() >> 1 : 0;
1137
+          temp_bed.soft_pwm_amount = WITHIN(temp_bed.celsius, BED_MINTEMP, BED_MAXTEMP) ? (int)get_pid_output_bed() >> 1 : 0;
1138
         #else
1138
         #else
1139
           // Check if temperature is within the correct band
1139
           // Check if temperature is within the correct band
1140
-          if (WITHIN(temp_bed.current, BED_MINTEMP, BED_MAXTEMP)) {
1140
+          if (WITHIN(temp_bed.celsius, BED_MINTEMP, BED_MAXTEMP)) {
1141
             #if ENABLED(BED_LIMIT_SWITCHING)
1141
             #if ENABLED(BED_LIMIT_SWITCHING)
1142
-              if (temp_bed.current >= temp_bed.target + BED_HYSTERESIS)
1142
+              if (temp_bed.celsius >= temp_bed.target + BED_HYSTERESIS)
1143
                 temp_bed.soft_pwm_amount = 0;
1143
                 temp_bed.soft_pwm_amount = 0;
1144
-              else if (temp_bed.current <= temp_bed.target - (BED_HYSTERESIS))
1144
+              else if (temp_bed.celsius <= temp_bed.target - (BED_HYSTERESIS))
1145
                 temp_bed.soft_pwm_amount = MAX_BED_POWER >> 1;
1145
                 temp_bed.soft_pwm_amount = MAX_BED_POWER >> 1;
1146
             #else // !PIDTEMPBED && !BED_LIMIT_SWITCHING
1146
             #else // !PIDTEMPBED && !BED_LIMIT_SWITCHING
1147
-              temp_bed.soft_pwm_amount = temp_bed.current < temp_bed.target ? MAX_BED_POWER >> 1 : 0;
1147
+              temp_bed.soft_pwm_amount = temp_bed.celsius < temp_bed.target ? MAX_BED_POWER >> 1 : 0;
1148
             #endif
1148
             #endif
1149
           }
1149
           }
1150
           else {
1150
           else {
1182
     if (ELAPSED(ms, next_chamber_check_ms)) {
1182
     if (ELAPSED(ms, next_chamber_check_ms)) {
1183
       next_chamber_check_ms = ms + CHAMBER_CHECK_INTERVAL;
1183
       next_chamber_check_ms = ms + CHAMBER_CHECK_INTERVAL;
1184
 
1184
 
1185
-      if (WITHIN(temp_chamber.current, CHAMBER_MINTEMP, CHAMBER_MAXTEMP)) {
1185
+      if (WITHIN(temp_chamber.celsius, CHAMBER_MINTEMP, CHAMBER_MAXTEMP)) {
1186
         #if ENABLED(CHAMBER_LIMIT_SWITCHING)
1186
         #if ENABLED(CHAMBER_LIMIT_SWITCHING)
1187
-          if (temp_chamber.current >= temp_chamber.target + TEMP_CHAMBER_HYSTERESIS)
1187
+          if (temp_chamber.celsius >= temp_chamber.target + TEMP_CHAMBER_HYSTERESIS)
1188
             temp_chamber.soft_pwm_amount = 0;
1188
             temp_chamber.soft_pwm_amount = 0;
1189
-          else if (temp_chamber.current <= temp_chamber.target - (TEMP_CHAMBER_HYSTERESIS))
1189
+          else if (temp_chamber.celsius <= temp_chamber.target - (TEMP_CHAMBER_HYSTERESIS))
1190
             temp_chamber.soft_pwm_amount = MAX_CHAMBER_POWER >> 1;
1190
             temp_chamber.soft_pwm_amount = MAX_CHAMBER_POWER >> 1;
1191
         #else
1191
         #else
1192
-          temp_chamber.soft_pwm_amount = temp_chamber.current < temp_chamber.target ? MAX_CHAMBER_POWER >> 1 : 0;
1192
+          temp_chamber.soft_pwm_amount = temp_chamber.celsius < temp_chamber.target ? MAX_CHAMBER_POWER >> 1 : 0;
1193
         #endif
1193
         #endif
1194
       }
1194
       }
1195
       else {
1195
       else {
1198
       }
1198
       }
1199
 
1199
 
1200
       #if ENABLED(THERMAL_PROTECTION_CHAMBER)
1200
       #if ENABLED(THERMAL_PROTECTION_CHAMBER)
1201
-        thermal_runaway_protection(tr_state_machine_chamber, temp_chamber.current, temp_chamber.target, H_CHAMBER, THERMAL_PROTECTION_CHAMBER_PERIOD, THERMAL_PROTECTION_CHAMBER_HYSTERESIS);
1201
+        thermal_runaway_protection(tr_state_machine_chamber, temp_chamber.celsius, temp_chamber.target, H_CHAMBER, THERMAL_PROTECTION_CHAMBER_PERIOD, THERMAL_PROTECTION_CHAMBER_HYSTERESIS);
1202
       #endif
1202
       #endif
1203
     }
1203
     }
1204
 
1204
 
1205
     // TODO: Implement true PID pwm
1205
     // TODO: Implement true PID pwm
1206
-    //temp_bed.soft_pwm_amount = WITHIN(temp_chamber.current, CHAMBER_MINTEMP, CHAMBER_MAXTEMP) ? (int)get_pid_output_chamber() >> 1 : 0;
1206
+    //temp_bed.soft_pwm_amount = WITHIN(temp_chamber.celsius, CHAMBER_MINTEMP, CHAMBER_MAXTEMP) ? (int)get_pid_output_chamber() >> 1 : 0;
1207
 
1207
 
1208
   #endif // HAS_HEATED_CHAMBER
1208
   #endif // HAS_HEATED_CHAMBER
1209
 }
1209
 }
1500
   #if ENABLED(HEATER_1_USES_MAX6675)
1500
   #if ENABLED(HEATER_1_USES_MAX6675)
1501
     temp_hotend[1].raw = READ_MAX6675(1);
1501
     temp_hotend[1].raw = READ_MAX6675(1);
1502
   #endif
1502
   #endif
1503
-  HOTEND_LOOP() temp_hotend[e].current = analog_to_celsius_hotend(temp_hotend[e].raw, e);
1503
+  HOTEND_LOOP() temp_hotend[e].celsius = analog_to_celsius_hotend(temp_hotend[e].raw, e);
1504
   #if HAS_HEATED_BED
1504
   #if HAS_HEATED_BED
1505
-    temp_bed.current = analog_to_celsius_bed(temp_bed.raw);
1505
+    temp_bed.celsius = analog_to_celsius_bed(temp_bed.raw);
1506
   #endif
1506
   #endif
1507
   #if HAS_TEMP_CHAMBER
1507
   #if HAS_TEMP_CHAMBER
1508
-    temp_chamber.current = analog_to_celsius_chamber(temp_chamber.raw);
1508
+    temp_chamber.celsius = analog_to_celsius_chamber(temp_chamber.raw);
1509
   #endif
1509
   #endif
1510
   #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
1510
   #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
1511
     redundant_temperature = analog_to_celsius_hotend(redundant_temperature_raw, 1);
1511
     redundant_temperature = analog_to_celsius_hotend(redundant_temperature_raw, 1);

+ 10
- 10
Marlin/src/module/temperature.h View File

158
 typedef struct TempInfo {
158
 typedef struct TempInfo {
159
   uint16_t acc;
159
   uint16_t acc;
160
   int16_t raw;
160
   int16_t raw;
161
-  float current;
161
+  float celsius;
162
   inline void reset() { acc = 0; }
162
   inline void reset() { acc = 0; }
163
   inline void sample(const uint16_t s) { acc += s; }
163
   inline void sample(const uint16_t s) { acc += s; }
164
   inline void update() { raw = acc; }
164
   inline void update() { raw = acc; }
577
 
577
 
578
     FORCE_INLINE static float degHotend(const uint8_t e) {
578
     FORCE_INLINE static float degHotend(const uint8_t e) {
579
       E_UNUSED();
579
       E_UNUSED();
580
-      return temp_hotend[HOTEND_INDEX].current;
580
+      return temp_hotend[HOTEND_INDEX].celsius;
581
     }
581
     }
582
 
582
 
583
     #if ENABLED(SHOW_TEMP_ADC_VALUES)
583
     #if ENABLED(SHOW_TEMP_ADC_VALUES)
625
 
625
 
626
     FORCE_INLINE static bool isHeatingHotend(const uint8_t e) {
626
     FORCE_INLINE static bool isHeatingHotend(const uint8_t e) {
627
       E_UNUSED();
627
       E_UNUSED();
628
-      return temp_hotend[HOTEND_INDEX].target > temp_hotend[HOTEND_INDEX].current;
628
+      return temp_hotend[HOTEND_INDEX].target > temp_hotend[HOTEND_INDEX].celsius;
629
     }
629
     }
630
 
630
 
631
     FORCE_INLINE static bool isCoolingHotend(const uint8_t e) {
631
     FORCE_INLINE static bool isCoolingHotend(const uint8_t e) {
632
       E_UNUSED();
632
       E_UNUSED();
633
-      return temp_hotend[HOTEND_INDEX].target < temp_hotend[HOTEND_INDEX].current;
633
+      return temp_hotend[HOTEND_INDEX].target < temp_hotend[HOTEND_INDEX].celsius;
634
     }
634
     }
635
 
635
 
636
     #if HAS_TEMP_HOTEND
636
     #if HAS_TEMP_HOTEND
650
       #if ENABLED(SHOW_TEMP_ADC_VALUES)
650
       #if ENABLED(SHOW_TEMP_ADC_VALUES)
651
         FORCE_INLINE static int16_t rawBedTemp()  { return temp_bed.raw; }
651
         FORCE_INLINE static int16_t rawBedTemp()  { return temp_bed.raw; }
652
       #endif
652
       #endif
653
-      FORCE_INLINE static float degBed()          { return temp_bed.current; }
653
+      FORCE_INLINE static float degBed()          { return temp_bed.celsius; }
654
       FORCE_INLINE static int16_t degTargetBed()  { return temp_bed.target; }
654
       FORCE_INLINE static int16_t degTargetBed()  { return temp_bed.target; }
655
-      FORCE_INLINE static bool isHeatingBed()     { return temp_bed.target > temp_bed.current; }
656
-      FORCE_INLINE static bool isCoolingBed()     { return temp_bed.target < temp_bed.current; }
655
+      FORCE_INLINE static bool isHeatingBed()     { return temp_bed.target > temp_bed.celsius; }
656
+      FORCE_INLINE static bool isCoolingBed()     { return temp_bed.target < temp_bed.celsius; }
657
 
657
 
658
       #if WATCH_BED
658
       #if WATCH_BED
659
         static void start_watching_bed();
659
         static void start_watching_bed();
687
       #if ENABLED(SHOW_TEMP_ADC_VALUES)
687
       #if ENABLED(SHOW_TEMP_ADC_VALUES)
688
         FORCE_INLINE static int16_t rawChamberTemp()    { return temp_chamber.raw; }
688
         FORCE_INLINE static int16_t rawChamberTemp()    { return temp_chamber.raw; }
689
       #endif
689
       #endif
690
-      FORCE_INLINE static float degChamber()            { return temp_chamber.current; }
690
+      FORCE_INLINE static float degChamber()            { return temp_chamber.celsius; }
691
       #if HAS_HEATED_CHAMBER
691
       #if HAS_HEATED_CHAMBER
692
         FORCE_INLINE static int16_t degTargetChamber()  { return temp_chamber.target; }
692
         FORCE_INLINE static int16_t degTargetChamber()  { return temp_chamber.target; }
693
-        FORCE_INLINE static bool isHeatingChamber()     { return temp_chamber.target > temp_chamber.current; }
694
-        FORCE_INLINE static bool isCoolingChamber()     { return temp_chamber.target < temp_chamber.current; }
693
+        FORCE_INLINE static bool isHeatingChamber()     { return temp_chamber.target > temp_chamber.celsius; }
694
+        FORCE_INLINE static bool isCoolingChamber()     { return temp_chamber.target < temp_chamber.celsius; }
695
 
695
 
696
         static bool wait_for_chamber(const bool no_wait_for_cooling=true);
696
         static bool wait_for_chamber(const bool no_wait_for_cooling=true);
697
       #endif
697
       #endif

Loading…
Cancel
Save