|
@@ -51,6 +51,10 @@
|
51
|
51
|
#include "../feature/emergency_parser.h"
|
52
|
52
|
#endif
|
53
|
53
|
|
|
54
|
+#if ENABLED(PRINTER_EVENT_LEDS)
|
|
55
|
+ #include "../feature/leds/leds.h"
|
|
56
|
+#endif
|
|
57
|
+
|
54
|
58
|
#if HOTEND_USES_THERMISTOR
|
55
|
59
|
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
|
56
|
60
|
static void* heater_ttbl_map[2] = { (void*)HEATER_0_TEMPTABLE, (void*)HEATER_1_TEMPTABLE };
|
|
@@ -2412,4 +2416,248 @@ void Temperature::isr() {
|
2412
|
2416
|
|
2413
|
2417
|
#endif // AUTO_REPORT_TEMPERATURES
|
2414
|
2418
|
|
|
2419
|
+ #if HAS_TEMP_HOTEND
|
|
2420
|
+
|
|
2421
|
+ #ifndef MIN_COOLING_SLOPE_DEG
|
|
2422
|
+ #define MIN_COOLING_SLOPE_DEG 1.50
|
|
2423
|
+ #endif
|
|
2424
|
+ #ifndef MIN_COOLING_SLOPE_TIME
|
|
2425
|
+ #define MIN_COOLING_SLOPE_TIME 60
|
|
2426
|
+ #endif
|
|
2427
|
+
|
|
2428
|
+ bool Temperature::wait_for_hotend(const uint8_t target_extruder, const bool no_wait_for_cooling/*=true*/) {
|
|
2429
|
+ #if TEMP_RESIDENCY_TIME > 0
|
|
2430
|
+ millis_t residency_start_ms = 0;
|
|
2431
|
+ // Loop until the temperature has stabilized
|
|
2432
|
+ #define TEMP_CONDITIONS (!residency_start_ms || PENDING(now, residency_start_ms + (TEMP_RESIDENCY_TIME) * 1000UL))
|
|
2433
|
+ #else
|
|
2434
|
+ // Loop until the temperature is very close target
|
|
2435
|
+ #define TEMP_CONDITIONS (wants_to_cool ? isCoolingHotend(target_extruder) : isHeatingHotend(target_extruder))
|
|
2436
|
+ #endif
|
|
2437
|
+
|
|
2438
|
+ #if DISABLED(BUSY_WHILE_HEATING)
|
|
2439
|
+ #if ENABLED(HOST_KEEPALIVE_FEATURE)
|
|
2440
|
+ const MarlinBusyState old_busy_state = gcode.busy_state;
|
|
2441
|
+ #endif
|
|
2442
|
+ KEEPALIVE_STATE(NOT_BUSY);
|
|
2443
|
+ #endif
|
|
2444
|
+
|
|
2445
|
+ #if ENABLED(PRINTER_EVENT_LEDS)
|
|
2446
|
+ const float start_temp = degHotend(target_extruder);
|
|
2447
|
+ uint8_t old_blue = 0;
|
|
2448
|
+ #endif
|
|
2449
|
+
|
|
2450
|
+ float target_temp = -1.0, old_temp = 9999.0;
|
|
2451
|
+ bool wants_to_cool = false;
|
|
2452
|
+ wait_for_heatup = true;
|
|
2453
|
+ millis_t now, next_temp_ms = 0, next_cool_check_ms = 0;
|
|
2454
|
+ do {
|
|
2455
|
+ // Target temperature might be changed during the loop
|
|
2456
|
+ if (target_temp != degTargetHotend(target_extruder)) {
|
|
2457
|
+ wants_to_cool = isCoolingHotend(target_extruder);
|
|
2458
|
+ target_temp = degTargetHotend(target_extruder);
|
|
2459
|
+
|
|
2460
|
+ // Exit if S<lower>, continue if S<higher>, R<lower>, or R<higher>
|
|
2461
|
+ if (no_wait_for_cooling && wants_to_cool) break;
|
|
2462
|
+ }
|
|
2463
|
+
|
|
2464
|
+ now = millis();
|
|
2465
|
+ if (ELAPSED(now, next_temp_ms)) { //Print temp & remaining time every 1s while waiting
|
|
2466
|
+ next_temp_ms = now + 1000UL;
|
|
2467
|
+ print_heaterstates();
|
|
2468
|
+ #if TEMP_RESIDENCY_TIME > 0
|
|
2469
|
+ SERIAL_PROTOCOLPGM(" W:");
|
|
2470
|
+ if (residency_start_ms)
|
|
2471
|
+ SERIAL_PROTOCOL(long((((TEMP_RESIDENCY_TIME) * 1000UL) - (now - residency_start_ms)) / 1000UL));
|
|
2472
|
+ else
|
|
2473
|
+ SERIAL_PROTOCOLCHAR('?');
|
|
2474
|
+ #endif
|
|
2475
|
+ SERIAL_EOL();
|
|
2476
|
+ }
|
|
2477
|
+
|
|
2478
|
+ idle();
|
|
2479
|
+ gcode.reset_stepper_timeout(); // Keep steppers powered
|
|
2480
|
+
|
|
2481
|
+ const float temp = degHotend(target_extruder);
|
|
2482
|
+
|
|
2483
|
+ #if ENABLED(PRINTER_EVENT_LEDS)
|
|
2484
|
+ // Gradually change LED strip from violet to red as nozzle heats up
|
|
2485
|
+ if (!wants_to_cool) {
|
|
2486
|
+ const uint8_t blue = map(constrain(temp, start_temp, target_temp), start_temp, target_temp, 255, 0);
|
|
2487
|
+ if (blue != old_blue) {
|
|
2488
|
+ old_blue = blue;
|
|
2489
|
+ leds.set_color(
|
|
2490
|
+ MakeLEDColor(255, 0, blue, 0, pixels.getBrightness())
|
|
2491
|
+ #if ENABLED(NEOPIXEL_IS_SEQUENTIAL)
|
|
2492
|
+ , true
|
|
2493
|
+ #endif
|
|
2494
|
+ );
|
|
2495
|
+ }
|
|
2496
|
+ }
|
|
2497
|
+ #endif
|
|
2498
|
+
|
|
2499
|
+ #if TEMP_RESIDENCY_TIME > 0
|
|
2500
|
+
|
|
2501
|
+ const float temp_diff = ABS(target_temp - temp);
|
|
2502
|
+
|
|
2503
|
+ if (!residency_start_ms) {
|
|
2504
|
+ // Start the TEMP_RESIDENCY_TIME timer when we reach target temp for the first time.
|
|
2505
|
+ if (temp_diff < TEMP_WINDOW) residency_start_ms = now;
|
|
2506
|
+ }
|
|
2507
|
+ else if (temp_diff > TEMP_HYSTERESIS) {
|
|
2508
|
+ // Restart the timer whenever the temperature falls outside the hysteresis.
|
|
2509
|
+ residency_start_ms = now;
|
|
2510
|
+ }
|
|
2511
|
+
|
|
2512
|
+ #endif
|
|
2513
|
+
|
|
2514
|
+ // Prevent a wait-forever situation if R is misused i.e. M109 R0
|
|
2515
|
+ if (wants_to_cool) {
|
|
2516
|
+ // break after MIN_COOLING_SLOPE_TIME seconds
|
|
2517
|
+ // if the temperature did not drop at least MIN_COOLING_SLOPE_DEG
|
|
2518
|
+ if (!next_cool_check_ms || ELAPSED(now, next_cool_check_ms)) {
|
|
2519
|
+ if (old_temp - temp < float(MIN_COOLING_SLOPE_DEG)) break;
|
|
2520
|
+ next_cool_check_ms = now + 1000UL * MIN_COOLING_SLOPE_TIME;
|
|
2521
|
+ old_temp = temp;
|
|
2522
|
+ }
|
|
2523
|
+ }
|
|
2524
|
+
|
|
2525
|
+ } while (wait_for_heatup && TEMP_CONDITIONS);
|
|
2526
|
+
|
|
2527
|
+ if (wait_for_heatup) {
|
|
2528
|
+ lcd_reset_status();
|
|
2529
|
+ #if ENABLED(PRINTER_EVENT_LEDS)
|
|
2530
|
+ leds.set_white();
|
|
2531
|
+ #endif
|
|
2532
|
+ }
|
|
2533
|
+
|
|
2534
|
+ #if DISABLED(BUSY_WHILE_HEATING) && ENABLED(HOST_KEEPALIVE_FEATURE)
|
|
2535
|
+ gcode.busy_state = old_busy_state;
|
|
2536
|
+ #endif
|
|
2537
|
+
|
|
2538
|
+ return wait_for_heatup;
|
|
2539
|
+ }
|
|
2540
|
+
|
|
2541
|
+ #endif // HAS_TEMP_HOTEND
|
|
2542
|
+
|
|
2543
|
+ #if HAS_HEATED_BED
|
|
2544
|
+
|
|
2545
|
+ #ifndef MIN_COOLING_SLOPE_DEG_BED
|
|
2546
|
+ #define MIN_COOLING_SLOPE_DEG_BED 1.50
|
|
2547
|
+ #endif
|
|
2548
|
+ #ifndef MIN_COOLING_SLOPE_TIME_BED
|
|
2549
|
+ #define MIN_COOLING_SLOPE_TIME_BED 60
|
|
2550
|
+ #endif
|
|
2551
|
+
|
|
2552
|
+ void Temperature::wait_for_bed(const bool no_wait_for_cooling) {
|
|
2553
|
+ #if TEMP_BED_RESIDENCY_TIME > 0
|
|
2554
|
+ millis_t residency_start_ms = 0;
|
|
2555
|
+ // Loop until the temperature has stabilized
|
|
2556
|
+ #define TEMP_BED_CONDITIONS (!residency_start_ms || PENDING(now, residency_start_ms + (TEMP_BED_RESIDENCY_TIME) * 1000UL))
|
|
2557
|
+ #else
|
|
2558
|
+ // Loop until the temperature is very close target
|
|
2559
|
+ #define TEMP_BED_CONDITIONS (wants_to_cool ? isCoolingBed() : isHeatingBed())
|
|
2560
|
+ #endif
|
|
2561
|
+
|
|
2562
|
+ float target_temp = -1, old_temp = 9999;
|
|
2563
|
+ bool wants_to_cool = false;
|
|
2564
|
+ wait_for_heatup = true;
|
|
2565
|
+ millis_t now, next_temp_ms = 0, next_cool_check_ms = 0;
|
|
2566
|
+
|
|
2567
|
+ #if DISABLED(BUSY_WHILE_HEATING)
|
|
2568
|
+ #if ENABLED(HOST_KEEPALIVE_FEATURE)
|
|
2569
|
+ const MarlinBusyState old_busy_state = gcode.busy_state;
|
|
2570
|
+ #endif
|
|
2571
|
+ KEEPALIVE_STATE(NOT_BUSY);
|
|
2572
|
+ #endif
|
|
2573
|
+
|
|
2574
|
+ gcode.target_extruder = active_extruder; // for print_heaterstates
|
|
2575
|
+
|
|
2576
|
+ #if ENABLED(PRINTER_EVENT_LEDS)
|
|
2577
|
+ const float start_temp = degBed();
|
|
2578
|
+ uint8_t old_red = 127;
|
|
2579
|
+ #endif
|
|
2580
|
+
|
|
2581
|
+ do {
|
|
2582
|
+ // Target temperature might be changed during the loop
|
|
2583
|
+ if (target_temp != degTargetBed()) {
|
|
2584
|
+ wants_to_cool = isCoolingBed();
|
|
2585
|
+ target_temp = degTargetBed();
|
|
2586
|
+
|
|
2587
|
+ // Exit if S<lower>, continue if S<higher>, R<lower>, or R<higher>
|
|
2588
|
+ if (no_wait_for_cooling && wants_to_cool) break;
|
|
2589
|
+ }
|
|
2590
|
+
|
|
2591
|
+ now = millis();
|
|
2592
|
+ if (ELAPSED(now, next_temp_ms)) { //Print Temp Reading every 1 second while heating up.
|
|
2593
|
+ next_temp_ms = now + 1000UL;
|
|
2594
|
+ print_heaterstates();
|
|
2595
|
+ #if TEMP_BED_RESIDENCY_TIME > 0
|
|
2596
|
+ SERIAL_PROTOCOLPGM(" W:");
|
|
2597
|
+ if (residency_start_ms)
|
|
2598
|
+ SERIAL_PROTOCOL(long((((TEMP_BED_RESIDENCY_TIME) * 1000UL) - (now - residency_start_ms)) / 1000UL));
|
|
2599
|
+ else
|
|
2600
|
+ SERIAL_PROTOCOLCHAR('?');
|
|
2601
|
+ #endif
|
|
2602
|
+ SERIAL_EOL();
|
|
2603
|
+ }
|
|
2604
|
+
|
|
2605
|
+ idle();
|
|
2606
|
+ gcode.reset_stepper_timeout(); // Keep steppers powered
|
|
2607
|
+
|
|
2608
|
+ const float temp = degBed();
|
|
2609
|
+
|
|
2610
|
+ #if ENABLED(PRINTER_EVENT_LEDS)
|
|
2611
|
+ // Gradually change LED strip from blue to violet as bed heats up
|
|
2612
|
+ if (!wants_to_cool) {
|
|
2613
|
+ const uint8_t red = map(constrain(temp, start_temp, target_temp), start_temp, target_temp, 0, 255);
|
|
2614
|
+ if (red != old_red) {
|
|
2615
|
+ old_red = red;
|
|
2616
|
+ leds.set_color(
|
|
2617
|
+ MakeLEDColor(red, 0, 255, 0, pixels.getBrightness())
|
|
2618
|
+ #if ENABLED(NEOPIXEL_IS_SEQUENTIAL)
|
|
2619
|
+ , true
|
|
2620
|
+ #endif
|
|
2621
|
+ );
|
|
2622
|
+ }
|
|
2623
|
+ }
|
|
2624
|
+ #endif
|
|
2625
|
+
|
|
2626
|
+ #if TEMP_BED_RESIDENCY_TIME > 0
|
|
2627
|
+
|
|
2628
|
+ const float temp_diff = ABS(target_temp - temp);
|
|
2629
|
+
|
|
2630
|
+ if (!residency_start_ms) {
|
|
2631
|
+ // Start the TEMP_BED_RESIDENCY_TIME timer when we reach target temp for the first time.
|
|
2632
|
+ if (temp_diff < TEMP_BED_WINDOW) residency_start_ms = now;
|
|
2633
|
+ }
|
|
2634
|
+ else if (temp_diff > TEMP_BED_HYSTERESIS) {
|
|
2635
|
+ // Restart the timer whenever the temperature falls outside the hysteresis.
|
|
2636
|
+ residency_start_ms = now;
|
|
2637
|
+ }
|
|
2638
|
+
|
|
2639
|
+ #endif // TEMP_BED_RESIDENCY_TIME > 0
|
|
2640
|
+
|
|
2641
|
+ // Prevent a wait-forever situation if R is misused i.e. M190 R0
|
|
2642
|
+ if (wants_to_cool) {
|
|
2643
|
+ // Break after MIN_COOLING_SLOPE_TIME_BED seconds
|
|
2644
|
+ // if the temperature did not drop at least MIN_COOLING_SLOPE_DEG_BED
|
|
2645
|
+ if (!next_cool_check_ms || ELAPSED(now, next_cool_check_ms)) {
|
|
2646
|
+ if (old_temp - temp < float(MIN_COOLING_SLOPE_DEG_BED)) break;
|
|
2647
|
+ next_cool_check_ms = now + 1000UL * MIN_COOLING_SLOPE_TIME_BED;
|
|
2648
|
+ old_temp = temp;
|
|
2649
|
+ }
|
|
2650
|
+ }
|
|
2651
|
+
|
|
2652
|
+ } while (wait_for_heatup && TEMP_BED_CONDITIONS);
|
|
2653
|
+
|
|
2654
|
+ if (wait_for_heatup) lcd_reset_status();
|
|
2655
|
+
|
|
2656
|
+ #if DISABLED(BUSY_WHILE_HEATING) && ENABLED(HOST_KEEPALIVE_FEATURE)
|
|
2657
|
+ gcode.busy_state = old_busy_state;
|
|
2658
|
+ #endif
|
|
2659
|
+ }
|
|
2660
|
+
|
|
2661
|
+ #endif // HAS_HEATED_BED
|
|
2662
|
+
|
2415
|
2663
|
#endif // HAS_TEMP_SENSOR
|