Bladeren bron

🎨 Misc. cleanup, string optimization

Scott Lahteine 3 jaren geleden
bovenliggende
commit
e2353be24f

+ 3
- 3
Marlin/Configuration.h Bestand weergeven

766
   #define PID_FUNCTIONAL_RANGE 10 // If the temperature difference between the target temperature and the actual temperature
766
   #define PID_FUNCTIONAL_RANGE 10 // If the temperature difference between the target temperature and the actual temperature
767
                                   // is more than PID_FUNCTIONAL_RANGE then the PID will be shut off and the heater will be set to min/max.
767
                                   // is more than PID_FUNCTIONAL_RANGE then the PID will be shut off and the heater will be set to min/max.
768
 
768
 
769
-  //#define PID_EDIT_MENU         // Add PID editing to the "Advanced Settings" menu. (~700 bytes of PROGMEM)
770
-  //#define PID_AUTOTUNE_MENU     // Add PID auto-tuning to the "Advanced Settings" menu. (~250 bytes of PROGMEM)
769
+  //#define PID_EDIT_MENU         // Add PID editing to the "Advanced Settings" menu. (~700 bytes of flash)
770
+  //#define PID_AUTOTUNE_MENU     // Add PID auto-tuning to the "Advanced Settings" menu. (~250 bytes of flash)
771
 #endif
771
 #endif
772
 
772
 
773
 // @section extruder
773
 // @section extruder
1970
  *   M502 - Revert settings to "factory" defaults. (Follow with M500 to init the EEPROM.)
1970
  *   M502 - Revert settings to "factory" defaults. (Follow with M500 to init the EEPROM.)
1971
  */
1971
  */
1972
 //#define EEPROM_SETTINGS     // Persistent storage with M500 and M501
1972
 //#define EEPROM_SETTINGS     // Persistent storage with M500 and M501
1973
-//#define DISABLE_M503        // Saves ~2700 bytes of PROGMEM. Disable for release!
1973
+//#define DISABLE_M503        // Saves ~2700 bytes of flash. Disable for release!
1974
 #define EEPROM_CHITCHAT       // Give feedback on EEPROM commands. Disable to save PROGMEM.
1974
 #define EEPROM_CHITCHAT       // Give feedback on EEPROM commands. Disable to save PROGMEM.
1975
 #define EEPROM_BOOT_SILENT    // Keep M503 quiet and only give errors during first load
1975
 #define EEPROM_BOOT_SILENT    // Keep M503 quiet and only give errors during first load
1976
 #if ENABLED(EEPROM_SETTINGS)
1976
 #if ENABLED(EEPROM_SETTINGS)

+ 6
- 2
Marlin/src/MarlinCore.cpp Bestand weergeven

412
   if (do_reset_timeout) gcode.reset_stepper_timeout(ms);
412
   if (do_reset_timeout) gcode.reset_stepper_timeout(ms);
413
 
413
 
414
   if (gcode.stepper_max_timed_out(ms)) {
414
   if (gcode.stepper_max_timed_out(ms)) {
415
-    SERIAL_ERROR_MSG(STR_KILL_INACTIVE_TIME, parser.command_ptr);
415
+    SERIAL_ERROR_START();
416
+    SERIAL_ECHOPGM(STR_KILL_PRE);
417
+    SERIAL_ECHOLNPGM(STR_KILL_INACTIVE_TIME, parser.command_ptr);
416
     kill();
418
     kill();
417
   }
419
   }
418
 
420
 
473
     // KILL the machine
475
     // KILL the machine
474
     // ----------------------------------------------------------------
476
     // ----------------------------------------------------------------
475
     if (killCount >= KILL_DELAY) {
477
     if (killCount >= KILL_DELAY) {
476
-      SERIAL_ERROR_MSG(STR_KILL_BUTTON);
478
+      SERIAL_ERROR_START();
479
+      SERIAL_ECHOPGM(STR_KILL_PRE);
480
+      SERIAL_ECHOLNPGM(STR_KILL_BUTTON);
477
       kill();
481
       kill();
478
     }
482
     }
479
   #endif
483
   #endif

+ 13
- 9
Marlin/src/core/language.h Bestand weergeven

199
 #define STR_FILAMENT_CHANGE_INSERT_M108     "Insert filament and send M108"
199
 #define STR_FILAMENT_CHANGE_INSERT_M108     "Insert filament and send M108"
200
 #define STR_FILAMENT_CHANGE_WAIT_M108       "Send M108 to resume"
200
 #define STR_FILAMENT_CHANGE_WAIT_M108       "Send M108 to resume"
201
 
201
 
202
-#define STR_STOP_BLTOUCH                    "!! STOP called because of BLTouch error - restart with M999"
203
-#define STR_STOP_UNHOMED                    "!! STOP called because of unhomed error - restart with M999"
204
-#define STR_KILL_INACTIVE_TIME              "!! KILL caused by too much inactive time - current command: "
205
-#define STR_KILL_BUTTON                     "!! KILL caused by KILL button/pin"
202
+#define STR_STOP_PRE                        "!! STOP called because of "
203
+#define STR_STOP_POST                       " error - restart with M999"
204
+#define STR_STOP_BLTOUCH                    "BLTouch"
205
+#define STR_STOP_UNHOMED                    "unhomed"
206
+#define STR_KILL_PRE                        "!! KILL caused by "
207
+#define STR_KILL_INACTIVE_TIME              "too much inactive time - current command: "
208
+#define STR_KILL_BUTTON                     "KILL button/pin"
206
 
209
 
207
 // temperature.cpp strings
210
 // temperature.cpp strings
208
-#define STR_PID_AUTOTUNE_START              "PID Autotune start"
209
-#define STR_PID_BAD_HEATER_ID               "PID Autotune failed! Bad heater id"
210
-#define STR_PID_TEMP_TOO_HIGH               "PID Autotune failed! Temperature too high"
211
-#define STR_PID_TIMEOUT                     "PID Autotune failed! timeout"
211
+#define STR_PID_AUTOTUNE                    "PID Autotune"
212
+#define STR_PID_AUTOTUNE_START              " start"
213
+#define STR_PID_BAD_HEATER_ID               " failed! Bad heater id"
214
+#define STR_PID_TEMP_TOO_HIGH               " failed! Temperature too high"
215
+#define STR_PID_TIMEOUT                     " failed! timeout"
212
 #define STR_BIAS                            " bias: "
216
 #define STR_BIAS                            " bias: "
213
 #define STR_D_COLON                         " d: "
217
 #define STR_D_COLON                         " d: "
214
 #define STR_T_MIN                           " min: "
218
 #define STR_T_MIN                           " min: "
219
 #define STR_KP                              " Kp: "
223
 #define STR_KP                              " Kp: "
220
 #define STR_KI                              " Ki: "
224
 #define STR_KI                              " Ki: "
221
 #define STR_KD                              " Kd: "
225
 #define STR_KD                              " Kd: "
222
-#define STR_PID_AUTOTUNE_FINISHED           "PID Autotune finished! Put the last Kp, Ki and Kd constants from below into Configuration.h"
226
+#define STR_PID_AUTOTUNE_FINISHED           " finished! Put the last Kp, Ki and Kd constants from below into Configuration.h"
223
 #define STR_PID_DEBUG                       " PID_DEBUG "
227
 #define STR_PID_DEBUG                       " PID_DEBUG "
224
 #define STR_PID_DEBUG_INPUT                 ": Input "
228
 #define STR_PID_DEBUG_INPUT                 ": Input "
225
 #define STR_PID_DEBUG_OUTPUT                " Output "
229
 #define STR_PID_DEBUG_OUTPUT                " Output "

+ 4
- 11
Marlin/src/feature/bltouch.cpp Bestand weergeven

111
     // Last attempt to DEPLOY
111
     // Last attempt to DEPLOY
112
     if (_deploy_query_alarm()) {
112
     if (_deploy_query_alarm()) {
113
       // The deploy might have failed or the probe is actually triggered (nozzle too low?) again
113
       // The deploy might have failed or the probe is actually triggered (nozzle too low?) again
114
-      if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("BLTouch Recovery Failed");
115
-
116
-      SERIAL_ERROR_MSG(STR_STOP_BLTOUCH);  // Tell the user something is wrong, needs action
117
-      stop();                              // but it's not too bad, no need to kill, allow restart
118
-
114
+      if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("BLTouch Deploy Failed");
115
+      probe.probe_error_stop();            // Something is wrong, needs action, but not too bad, allow restart
119
       return true;                         // Tell our caller we goofed in case he cares to know
116
       return true;                         // Tell our caller we goofed in case he cares to know
120
     }
117
     }
121
   }
118
   }
153
                                            // But one more STOW will catch that
150
                                            // But one more STOW will catch that
154
     // Last attempt to STOW
151
     // Last attempt to STOW
155
     if (_stow_query_alarm()) {             // so if there is now STILL an ALARM condition:
152
     if (_stow_query_alarm()) {             // so if there is now STILL an ALARM condition:
156
-
157
-      if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("BLTouch Recovery Failed");
158
-
159
-      SERIAL_ERROR_MSG(STR_STOP_BLTOUCH);  // Tell the user something is wrong, needs action
160
-      stop();                              // but it's not too bad, no need to kill, allow restart
161
-
153
+      if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("BLTouch Stow Failed");
154
+      probe.probe_error_stop();            // Something is wrong, needs action, but not too bad, allow restart
162
       return true;                         // Tell our caller we goofed in case he cares to know
155
       return true;                         // Tell our caller we goofed in case he cares to know
163
     }
156
     }
164
   }
157
   }

+ 1
- 0
Marlin/src/gcode/temp/M303.cpp Bestand weergeven

71
       case H_CHAMBER: default_temp = PREHEAT_1_TEMP_CHAMBER; break;
71
       case H_CHAMBER: default_temp = PREHEAT_1_TEMP_CHAMBER; break;
72
     #endif
72
     #endif
73
     default:
73
     default:
74
+      SERIAL_ECHOPGM(STR_PID_AUTOTUNE);
74
       SERIAL_ECHOLNPGM(STR_PID_BAD_HEATER_ID);
75
       SERIAL_ECHOLNPGM(STR_PID_BAD_HEATER_ID);
75
       TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_BAD_EXTRUDER_NUM));
76
       TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_BAD_EXTRUDER_NUM));
76
       TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_BAD_EXTRUDER_NUM));
77
       TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_BAD_EXTRUDER_NUM));

+ 4
- 8
Marlin/src/inc/SanityCheck.h Bestand weergeven

2960
 #if ENABLED(DWIN_CREALITY_LCD)
2960
 #if ENABLED(DWIN_CREALITY_LCD)
2961
   #if DISABLED(SDSUPPORT)
2961
   #if DISABLED(SDSUPPORT)
2962
     #error "DWIN_CREALITY_LCD requires SDSUPPORT to be enabled."
2962
     #error "DWIN_CREALITY_LCD requires SDSUPPORT to be enabled."
2963
-  #elif ENABLED(PID_EDIT_MENU)
2964
-    #error "DWIN_CREALITY_LCD does not support PID_EDIT_MENU."
2965
-  #elif ENABLED(PID_AUTOTUNE_MENU)
2966
-    #error "DWIN_CREALITY_LCD does not support PID_AUTOTUNE_MENU."
2963
+  #elif EITHER(PID_EDIT_MENU, PID_AUTOTUNE_MENU)
2964
+    #error "DWIN_CREALITY_LCD does not support PID_EDIT_MENU or PID_AUTOTUNE_MENU."
2967
   #elif ENABLED(LEVEL_BED_CORNERS)
2965
   #elif ENABLED(LEVEL_BED_CORNERS)
2968
     #error "DWIN_CREALITY_LCD does not support LEVEL_BED_CORNERS."
2966
     #error "DWIN_CREALITY_LCD does not support LEVEL_BED_CORNERS."
2969
   #elif BOTH(LCD_BED_LEVELING, PROBE_MANUALLY)
2967
   #elif BOTH(LCD_BED_LEVELING, PROBE_MANUALLY)
2972
 #elif ENABLED(DWIN_LCD_PROUI)
2970
 #elif ENABLED(DWIN_LCD_PROUI)
2973
   #if DISABLED(SDSUPPORT)
2971
   #if DISABLED(SDSUPPORT)
2974
     #error "DWIN_LCD_PROUI requires SDSUPPORT to be enabled."
2972
     #error "DWIN_LCD_PROUI requires SDSUPPORT to be enabled."
2975
-  #elif ENABLED(PID_EDIT_MENU)
2976
-    #error "DWIN_LCD_PROUI does not support PID_EDIT_MENU."
2977
-  #elif ENABLED(PID_AUTOTUNE_MENU)
2978
-    #error "DWIN_LCD_PROUI does not support PID_AUTOTUNE_MENU."
2973
+  #elif EITHER(PID_EDIT_MENU, PID_AUTOTUNE_MENU)
2974
+    #error "DWIN_LCD_PROUI does not support PID_EDIT_MENU or PID_AUTOTUNE_MENU."
2979
   #elif ENABLED(LEVEL_BED_CORNERS)
2975
   #elif ENABLED(LEVEL_BED_CORNERS)
2980
     #error "DWIN_LCD_PROUI does not support LEVEL_BED_CORNERS."
2976
     #error "DWIN_LCD_PROUI does not support LEVEL_BED_CORNERS."
2981
   #elif BOTH(LCD_BED_LEVELING, PROBE_MANUALLY)
2977
   #elif BOTH(LCD_BED_LEVELING, PROBE_MANUALLY)

+ 2
- 1
Marlin/src/lcd/menu/menu_advanced.cpp Bestand weergeven

256
   void menu_advanced_temperature() {
256
   void menu_advanced_temperature() {
257
     START_MENU();
257
     START_MENU();
258
     BACK_ITEM(MSG_ADVANCED_SETTINGS);
258
     BACK_ITEM(MSG_ADVANCED_SETTINGS);
259
+
259
     //
260
     //
260
     // Autotemp, Min, Max, Fact
261
     // Autotemp, Min, Max, Fact
261
     //
262
     //
325
 
326
 
326
       HOTEND_PID_EDIT_MENU_ITEMS(0);
327
       HOTEND_PID_EDIT_MENU_ITEMS(0);
327
       #if ENABLED(PID_PARAMS_PER_HOTEND)
328
       #if ENABLED(PID_PARAMS_PER_HOTEND)
328
-        REPEAT_S(1, HOTENDS, HOTEND_PID_EDIT_MENU_ITEMS)
329
+        REPEAT_S(1, HOTENDS, HOTEND_PID_EDIT_MENU_ITEMS);
329
       #endif
330
       #endif
330
     #endif
331
     #endif
331
 
332
 

+ 18
- 7
Marlin/src/module/probe.cpp Bestand weergeven

416
 #endif
416
 #endif
417
 
417
 
418
 /**
418
 /**
419
+ * Print an error and stop()
420
+ */
421
+void Probe::probe_error_stop() {
422
+  SERIAL_ERROR_START();
423
+  SERIAL_ECHOPGM(STR_STOP_PRE);
424
+  #if EITHER(Z_PROBE_SLED, Z_PROBE_ALLEN_KEY)
425
+    SERIAL_ECHOPGM(STR_STOP_UNHOMED);
426
+  #elif ENABLED(BLTOUCH)
427
+    SERIAL_ECHOPGM(STR_STOP_BLTOUCH);
428
+  #endif
429
+  SERIAL_ECHOLNPGM(STR_STOP_POST);
430
+  stop();
431
+}
432
+
433
+/**
419
  * Attempt to deploy or stow the probe
434
  * Attempt to deploy or stow the probe
420
  *
435
  *
421
  * Return TRUE if the probe could not be deployed/stowed
436
  * Return TRUE if the probe could not be deployed/stowed
443
 
458
 
444
   #if EITHER(Z_PROBE_SLED, Z_PROBE_ALLEN_KEY)
459
   #if EITHER(Z_PROBE_SLED, Z_PROBE_ALLEN_KEY)
445
     if (homing_needed_error(TERN_(Z_PROBE_SLED, _BV(X_AXIS)))) {
460
     if (homing_needed_error(TERN_(Z_PROBE_SLED, _BV(X_AXIS)))) {
446
-      SERIAL_ERROR_MSG(STR_STOP_UNHOMED);
447
-      stop();
461
+      probe_error_stop();
448
       return true;
462
       return true;
449
     }
463
     }
450
   #endif
464
   #endif
484
 }
498
 }
485
 
499
 
486
 /**
500
 /**
487
- * @brief Used by run_z_probe to do a single Z probe move.
501
+ * @brief Move down until the probe triggers or the low limit is reached
502
+ *        Used by run_z_probe to do a single Z probe move.
488
  *
503
  *
489
  * @param  z        Z destination
504
  * @param  z        Z destination
490
  * @param  fr_mm_s  Feedrate in mm/s
505
  * @param  fr_mm_s  Feedrate in mm/s
491
  * @return true to indicate an error
506
  * @return true to indicate an error
492
- */
493
-
494
-/**
495
- * @brief Move down until the probe triggers or the low limit is reached
496
  *
507
  *
497
  * @details Used by run_z_probe to get each bed Z height measurement.
508
  * @details Used by run_z_probe to get each bed Z height measurement.
498
  *          Sets current_position.z to the height where the probe triggered
509
  *          Sets current_position.z to the height where the probe triggered

+ 2
- 0
Marlin/src/module/probe.h Bestand weergeven

78
       static void preheat_for_probing(const celsius_t hotend_temp, const celsius_t bed_temp);
78
       static void preheat_for_probing(const celsius_t hotend_temp, const celsius_t bed_temp);
79
     #endif
79
     #endif
80
 
80
 
81
+    static void probe_error_stop();
82
+
81
     static bool set_deployed(const bool deploy);
83
     static bool set_deployed(const bool deploy);
82
 
84
 
83
     #if IS_KINEMATIC
85
     #if IS_KINEMATIC

+ 20
- 16
Marlin/src/module/temperature.cpp Bestand weergeven

632
     TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(isbed ? PID_BED_START : PID_EXTR_START));
632
     TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(isbed ? PID_BED_START : PID_EXTR_START));
633
 
633
 
634
     if (target > GHV(CHAMBER_MAX_TARGET, BED_MAX_TARGET, temp_range[heater_id].maxtemp - (HOTEND_OVERSHOOT))) {
634
     if (target > GHV(CHAMBER_MAX_TARGET, BED_MAX_TARGET, temp_range[heater_id].maxtemp - (HOTEND_OVERSHOOT))) {
635
+      SERIAL_ECHOPGM(STR_PID_AUTOTUNE);
635
       SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH);
636
       SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH);
636
       TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH));
637
       TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH));
637
       TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_TEMP_TOO_HIGH));
638
       TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_TEMP_TOO_HIGH));
639
       return;
640
       return;
640
     }
641
     }
641
 
642
 
643
+    SERIAL_ECHOPGM(STR_PID_AUTOTUNE);
642
     SERIAL_ECHOLNPGM(STR_PID_AUTOTUNE_START);
644
     SERIAL_ECHOLNPGM(STR_PID_AUTOTUNE_START);
643
 
645
 
644
     disable_all_heaters();
646
     disable_all_heaters();
654
 
656
 
655
     TERN_(NO_FAN_SLOWING_IN_PID_TUNING, adaptive_fan_slowing = false);
657
     TERN_(NO_FAN_SLOWING_IN_PID_TUNING, adaptive_fan_slowing = false);
656
 
658
 
657
-    // PID Tuning loop
658
-    wait_for_heatup = true; // Can be interrupted with M108
659
     LCD_MESSAGE(MSG_HEATING);
659
     LCD_MESSAGE(MSG_HEATING);
660
-    while (wait_for_heatup) {
660
+
661
+    // PID Tuning loop
662
+    wait_for_heatup = true;
663
+    while (wait_for_heatup) { // Can be interrupted with M108
661
 
664
 
662
       const millis_t ms = millis();
665
       const millis_t ms = millis();
663
 
666
 
723
         #define MAX_OVERSHOOT_PID_AUTOTUNE 30
726
         #define MAX_OVERSHOOT_PID_AUTOTUNE 30
724
       #endif
727
       #endif
725
       if (current_temp > target + MAX_OVERSHOOT_PID_AUTOTUNE) {
728
       if (current_temp > target + MAX_OVERSHOOT_PID_AUTOTUNE) {
729
+        SERIAL_ECHOPGM(STR_PID_AUTOTUNE);
726
         SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH);
730
         SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH);
727
         TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH));
731
         TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH));
728
         TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_TEMP_TOO_HIGH));
732
         TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_TEMP_TOO_HIGH));
765
         TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_TUNING_TIMEOUT));
769
         TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_TUNING_TIMEOUT));
766
         TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TUNING_TIMEOUT));
770
         TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TUNING_TIMEOUT));
767
         TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_TIMEOUT)));
771
         TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_TIMEOUT)));
772
+        SERIAL_ECHOPGM(STR_PID_AUTOTUNE);
768
         SERIAL_ECHOLNPGM(STR_PID_TIMEOUT);
773
         SERIAL_ECHOLNPGM(STR_PID_TIMEOUT);
769
         break;
774
         break;
770
       }
775
       }
771
 
776
 
772
       if (cycles > ncycles && cycles > 2) {
777
       if (cycles > ncycles && cycles > 2) {
778
+        SERIAL_ECHOPGM(STR_PID_AUTOTUNE);
773
         SERIAL_ECHOLNPGM(STR_PID_AUTOTUNE_FINISHED);
779
         SERIAL_ECHOLNPGM(STR_PID_AUTOTUNE_FINISHED);
774
         TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_AUTOTUNE_DONE)));
780
         TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_AUTOTUNE_DONE)));
775
 
781
 
869
     MPC_t& constants = hotend.constants;
875
     MPC_t& constants = hotend.constants;
870
 
876
 
871
     // move to center of bed, just above bed height and cool with max fan
877
     // move to center of bed, just above bed height and cool with max fan
872
-    SERIAL_ECHOLNPGM("Moving to tuning position");
873
     TERN_(HAS_FAN, zero_fan_speeds());
878
     TERN_(HAS_FAN, zero_fan_speeds());
874
     disable_all_heaters();
879
     disable_all_heaters();
875
     TERN_(HAS_FAN, set_fan_speed(ANY(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 255));
880
     TERN_(HAS_FAN, set_fan_speed(ANY(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 255));
896
         next_test_ms += 10000UL;
901
         next_test_ms += 10000UL;
897
       }
902
       }
898
     }
903
     }
904
+
899
     TERN_(HAS_FAN, set_fan_speed(ANY(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 0));
905
     TERN_(HAS_FAN, set_fan_speed(ANY(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 0));
900
     TERN_(HAS_FAN, planner.sync_fan_speeds(fan_speed));
906
     TERN_(HAS_FAN, planner.sync_fan_speeds(fan_speed));
901
 
907
 
903
 
909
 
904
     SERIAL_ECHOLNPGM("Heating to 200C");
910
     SERIAL_ECHOLNPGM("Heating to 200C");
905
     hotend.soft_pwm_amount = MPC_MAX >> 1;
911
     hotend.soft_pwm_amount = MPC_MAX >> 1;
906
-    const millis_t heat_start_time = ms;
907
-    next_test_ms = ms;
912
+    const millis_t heat_start_time = next_test_ms = ms;
908
     celsius_float_t temp_samples[16];
913
     celsius_float_t temp_samples[16];
909
     uint8_t sample_count = 0;
914
     uint8_t sample_count = 0;
910
     uint16_t sample_distance = 1;
915
     uint16_t sample_distance = 1;
935
     }
940
     }
936
     hotend.soft_pwm_amount = 0;
941
     hotend.soft_pwm_amount = 0;
937
 
942
 
938
-    // calculate physical constants from three equally spaced samples
943
+    // Calculate physical constants from three equally-spaced samples
939
     sample_count = (sample_count + 1) / 2 * 2 - 1;
944
     sample_count = (sample_count + 1) / 2 * 2 - 1;
940
     const float t1 = temp_samples[0],
945
     const float t1 = temp_samples[0],
941
                 t2 = temp_samples[(sample_count - 1) >> 1],
946
                 t2 = temp_samples[(sample_count - 1) >> 1],
951
     hotend.modeled_block_temp = asymp_temp + (ambient_temp - asymp_temp) * exp(-block_responsiveness * (ms - heat_start_time) / 1000.0f);
956
     hotend.modeled_block_temp = asymp_temp + (ambient_temp - asymp_temp) * exp(-block_responsiveness * (ms - heat_start_time) / 1000.0f);
952
     hotend.modeled_sensor_temp = current_temp;
957
     hotend.modeled_sensor_temp = current_temp;
953
 
958
 
954
-    // let the system stabilise under MPC control then get a better measure of ambient loss without and with fan
959
+    // Allow the system to stabilize under MPC, then get a better measure of ambient loss with and without fan
955
     SERIAL_ECHOLNPGM("Measuring ambient heatloss at target ", hotend.modeled_block_temp);
960
     SERIAL_ECHOLNPGM("Measuring ambient heatloss at target ", hotend.modeled_block_temp);
956
     hotend.target = hotend.modeled_block_temp;
961
     hotend.target = hotend.modeled_block_temp;
957
     next_test_ms = ms + MPC_dT * 1000;
962
     next_test_ms = ms + MPC_dT * 1000;
958
-    constexpr millis_t settle_time = 20000UL,
959
-                       test_length = 20000UL;
963
+    constexpr millis_t settle_time = 20000UL, test_duration = 20000UL;
960
     millis_t settle_end_ms = ms + settle_time,
964
     millis_t settle_end_ms = ms + settle_time,
961
-             test_end_ms = settle_end_ms + test_length;
965
+             test_end_ms = settle_end_ms + test_duration;
962
     float total_energy_fan0 = 0.0f;
966
     float total_energy_fan0 = 0.0f;
963
     #if HAS_FAN
967
     #if HAS_FAN
964
       bool fan0_done = false;
968
       bool fan0_done = false;
981
             set_fan_speed(ANY(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 255);
985
             set_fan_speed(ANY(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 255);
982
             planner.sync_fan_speeds(fan_speed);
986
             planner.sync_fan_speeds(fan_speed);
983
             settle_end_ms = ms + settle_time;
987
             settle_end_ms = ms + settle_time;
984
-            test_end_ms = settle_end_ms + test_length;
988
+            test_end_ms = settle_end_ms + test_duration;
985
             fan0_done = true;
989
             fan0_done = true;
986
           }
990
           }
987
           else if (ELAPSED(ms, settle_end_ms) && !ELAPSED(ms, test_end_ms))
991
           else if (ELAPSED(ms, settle_end_ms) && !ELAPSED(ms, test_end_ms))
999
       }
1003
       }
1000
     }
1004
     }
1001
 
1005
 
1002
-    const float power_fan0 = total_energy_fan0 * 1000 / test_length;
1006
+    const float power_fan0 = total_energy_fan0 * 1000 / test_duration;
1003
     constants.ambient_xfer_coeff_fan0 = power_fan0 / (hotend.target - ambient_temp);
1007
     constants.ambient_xfer_coeff_fan0 = power_fan0 / (hotend.target - ambient_temp);
1004
 
1008
 
1005
     #if HAS_FAN
1009
     #if HAS_FAN
1006
-      const float power_fan255 = total_energy_fan255 * 1000 / test_length,
1010
+      const float power_fan255 = total_energy_fan255 * 1000 / test_duration,
1007
                   ambient_xfer_coeff_fan255 = power_fan255 / (hotend.target - ambient_temp);
1011
                   ambient_xfer_coeff_fan255 = power_fan255 / (hotend.target - ambient_temp);
1008
       constants.fan255_adjustment = ambient_xfer_coeff_fan255 - constants.ambient_xfer_coeff_fan0;
1012
       constants.fan255_adjustment = ambient_xfer_coeff_fan255 - constants.ambient_xfer_coeff_fan0;
1009
     #endif
1013
     #endif
1369
       #endif
1373
       #endif
1370
 
1374
 
1371
     #elif ENABLED(MPCTEMP)
1375
     #elif ENABLED(MPCTEMP)
1372
-      MPCHeaterInfo& hotend = temp_hotend[ee];
1373
-      MPC_t& constants = hotend.constants;
1376
+      MPCHeaterInfo &hotend = temp_hotend[ee];
1377
+      MPC_t &constants = hotend.constants;
1374
 
1378
 
1375
       // At startup, initialize modeled temperatures
1379
       // At startup, initialize modeled temperatures
1376
       if (isnan(hotend.modeled_block_temp)) {
1380
       if (isnan(hotend.modeled_block_temp)) {

Laden…
Annuleren
Opslaan