Cooler (for Laser) - M143, M193 (#21255)

This commit is contained in:
Mike La Spina
2021-03-06 14:13:28 -06:00
committed by GitHub
parent 87bef13a4c
commit b95e548ddb
41 changed files with 1041 additions and 125 deletions

View File

@ -78,6 +78,16 @@
#define STATUS_CUTTER_WIDTH 0
#endif
//
// Laser Cooler
//
#if !STATUS_COOLER_WIDTH && HAS_COOLER
#include "status/cooler.h"
#endif
#ifndef STATUS_COOLER_WIDTH
#define STATUS_COOLER_WIDTH 0
#endif
//
// Bed
//
@ -498,6 +508,47 @@
#endif
//
// Cooler Bitmap Properties
//
#ifndef STATUS_COOLER_BYTEWIDTH
#define STATUS_COOLER_BYTEWIDTH BW(STATUS_COOLER_WIDTH)
#endif
#if STATUS_COOLER_WIDTH
#ifndef STATUS_COOLER_X
#define STATUS_COOLER_X (LCD_PIXEL_WIDTH - (STATUS_COOLER_BYTEWIDTH + STATUS_FAN_BYTEWIDTH + STATUS_CUTTER_BYTEWIDTH) * 8)
#endif
#ifndef STATUS_COOLER_HEIGHT
#ifdef STATUS_COOLER_ANIM
#define STATUS_COOLER_HEIGHT(S) ((S) ? sizeof(status_cooler_on_bmp) / (STATUS_COOLER_BYTEWIDTH) : sizeof(status_cooler_bmp) / (STATUS_COOLER_BYTEWIDTH))
#else
#define STATUS_COOLER_HEIGHT(S) (sizeof(status_cooler_bmp) / (STATUS_COOLER_BYTEWIDTH))
#endif
#endif
#ifndef STATUS_COOLER_Y
#define STATUS_COOLER_Y(S) (18 - STATUS_COOLER_HEIGHT(S))
#endif
#ifndef STATUS_COOLER_TEXT_X
#define STATUS_COOLER_TEXT_X (STATUS_COOLER_X + 8)
#endif
static_assert(
sizeof(status_cooler_bmp) == (STATUS_COOLER_BYTEWIDTH) * (STATUS_COOLER_HEIGHT(0)),
"Status cooler bitmap (status_cooler_bmp) dimensions don't match data."
);
#ifdef STATUS_COOLER_ANIM
static_assert(
sizeof(status_cooler_on_bmp) == (STATUS_COOLER_BYTEWIDTH) * (STATUS_COOLER_HEIGHT(1)),
"Status cooler bitmap (status_cooler_on_bmp) dimensions don't match data."
);
#endif
#endif
//
// Bed Bitmap Properties
//
@ -585,6 +636,10 @@
#if HAS_CUTTER && !DO_DRAW_BED
#define DO_DRAW_CUTTER 1
#endif
#if HAS_COOLER
#define DO_DRAW_COOLER 1
#endif
#if HAS_TEMP_CHAMBER && STATUS_CHAMBER_WIDTH && HOTENDS <= 4
#define DO_DRAW_CHAMBER 1
#endif
@ -603,6 +658,9 @@
#if BOTH(DO_DRAW_CUTTER, STATUS_CUTTER_ANIM)
#define ANIM_CUTTER 1
#endif
#if BOTH(DO_DRAW_COOLER, STATUS_COOLER_ANIM)
#define ANIM_COOLER 1
#endif
#if ANIM_HOTEND || ANIM_BED || ANIM_CHAMBER || ANIM_CUTTER
#define ANIM_HBCC 1
#endif

View File

@ -0,0 +1,70 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
//
// lcd/dogm/status/cooler.h - Status Screen Laser Cooler bitmaps
//
#define STATUS_COOLER_WIDTH 16
#ifdef STATUS_COOLER_ANIM
const unsigned char status_cooler_on_bmp[] PROGMEM = {
B00010000,B00001000,
B00010010,B01001001,
B01010100,B00101010,
B00111000,B00011100,
B11111110,B11111111,
B00111000,B00011100,
B01010100,B00101010,
B10010000,B10001001,
B00010000,B10000000,
B00000100,B10010000,
B00000010,B10100000,
B00000001,B11000000,
B00011111,B11111100,
B00000001,B11000000,
B00000010,B10100000,
B00000100,B10010000
};
#endif
const unsigned char status_cooler_bmp[] PROGMEM = {
B00010000,B00001000,
B00010010,B01001001,
B01010100,B00101010,
B00101000,B00010100,
B11000111,B01100011,
B00101000,B00010100,
B01010100,B00101010,
B10010000,B10001001,
B00010000,B10000000,
B00000100,B10010000,
B00000010,B10100000,
B00000001,B01000000,
B00011110,B00111100,
B00000001,B01000000,
B00000010,B10100000,
B00000100,B10010000
};

View File

@ -86,6 +86,7 @@
HEATBIT_HOTEND,
HEATBIT_BED = HOTENDS,
HEATBIT_CHAMBER,
HEATBIT_COOLER,
HEATBIT_CUTTER
};
IF<(HEATBIT_CUTTER > 7), uint16_t, uint8_t>::type heat_bits;
@ -111,6 +112,11 @@
#else
#define CUTTER_ALT() false
#endif
#if ANIM_COOLER
#define COOLER_ALT(N) TEST(heat_bits, HEATBIT_COOLER)
#else
#define COOLER_ALT() false
#endif
#if DO_DRAW_HOTENDS
#define MAX_HOTEND_DRAW _MIN(HOTENDS, ((LCD_PIXEL_WIDTH - (STATUS_LOGO_BYTEWIDTH + STATUS_FAN_BYTEWIDTH) * 8) / (STATUS_HEATERS_XSPACE)))
@ -361,18 +367,22 @@ FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, cons
#endif // DO_DRAW_BED
#if DO_DRAW_CHAMBER
FORCE_INLINE void _draw_chamber_status() {
#if HAS_HEATED_CHAMBER
if (PAGE_UNDER(7))
_draw_centered_temp(thermalManager.degTargetChamber() + 0.5f, STATUS_CHAMBER_TEXT_X, 7);
#endif
if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1))
_draw_centered_temp(thermalManager.degChamber() + 0.5f, STATUS_CHAMBER_TEXT_X, 28);
}
#endif
#endif // DO_DRAW_CHAMBER
#if DO_DRAW_COOLER
FORCE_INLINE void _draw_cooler_status() {
if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1))
_draw_centered_temp(thermalManager.degCooler(), STATUS_COOLER_TEXT_X, 28);
}
#endif
//
// Before homing, blink '123' <-> '???'.
@ -447,6 +457,9 @@ void MarlinUI::draw_status_screen() {
#if DO_DRAW_CHAMBER && HAS_HEATED_CHAMBER
if (thermalManager.isHeatingChamber()) SBI(new_bits, HEATBIT_CHAMBER);
#endif
#if DO_DRAW_COOLER && HAS_COOLER
if (thermalManager.isLaserCooling()) SBI(new_bits, HEATBIT_COOLER);
#endif
if (TERN0(ANIM_CUTTER, cutter.enabled())) SBI(new_bits, HEATBIT_CUTTER);
heat_bits = new_bits;
#endif
@ -631,12 +644,28 @@ void MarlinUI::draw_status_screen() {
}
#endif
// Laser Cooler
#if DO_DRAW_COOLER
#if ANIM_COOLER
#define COOLER_BITMAP(S) ((S) ? status_cooler_bmp : status_cooler_on_bmp)
#else
#define COOLER_BITMAP(S) status_cooler_bmp
#endif
const uint8_t coolery = STATUS_COOLER_Y(COOLER_ALT()),
coolerh = STATUS_COOLER_HEIGHT(COOLER_ALT());
if (PAGE_CONTAINS(coolery, coolery + coolerh - 1))
u8g.drawBitmapP(STATUS_COOLER_X, coolery, STATUS_COOLER_BYTEWIDTH, coolerh, COOLER_BITMAP(COOLER_ALT()));
#endif
// Heated Bed
TERN_(DO_DRAW_BED, _draw_bed_status(blink));
// Heated Chamber
TERN_(DO_DRAW_CHAMBER, _draw_chamber_status());
// Cooler
TERN_(DO_DRAW_COOLER, _draw_cooler_status());
// Fan, if a bitmap was provided
#if DO_DRAW_FAN
if (PAGE_CONTAINS(STATUS_FAN_TEXT_Y - INFO_FONT_ASCENT, STATUS_FAN_TEXT_Y - 1)) {

View File

@ -176,6 +176,7 @@ namespace ExtUI {
case BED: thermalManager.reset_bed_idle_timer(); return;
#endif
TERN_(HAS_HEATED_CHAMBER, case CHAMBER: return); // Chamber has no idle timer
TERN_(HAS_COOLER, case COOLER: return); // Cooler has no idle timer
default:
TERN_(HAS_HOTEND, thermalManager.reset_hotend_idle_timer(heater - H0));
break;
@ -904,22 +905,23 @@ namespace ExtUI {
value *= TOUCH_UI_LCD_TEMP_SCALING;
#endif
enableHeater(heater);
#if HAS_HEATED_CHAMBER
if (heater == CHAMBER)
thermalManager.setTargetChamber(LROUND(constrain(value, 0, CHAMBER_MAXTEMP - 10)));
else
#endif
#if HAS_HEATED_BED
if (heater == BED)
thermalManager.setTargetBed(LROUND(constrain(value, 0, BED_MAX_TARGET)));
else
#endif
{
switch (heater) {
#if HAS_HEATED_CHAMBER
case CHAMBER: thermalManager.setTargetChamber(LROUND(constrain(value, 0, CHAMBER_MAXTEMP - 10))); break;
#endif
#if HAS_COOLER
case COOLER: thermalManager.setTargetCooler(LROUND(constrain(value, 0, COOLER_MAXTEMP))); break;
#endif
#if HAS_HEATED_BED
case BED: thermalManager.setTargetBed(LROUND(constrain(value, 0, BED_MAX_TARGET))); break;
#endif
default: {
#if HAS_HOTEND
const int16_t e = heater - H0;
thermalManager.setTargetHotend(LROUND(constrain(value, 0, thermalManager.heater_maxtemp[e] - HOTEND_OVERSHOOT)), e);
#endif
}
} break;
}
}
void setTargetTemp_celsius(float value, const extruder_t extruder) {

View File

@ -55,7 +55,7 @@ namespace ExtUI {
enum axis_t : uint8_t { X, Y, Z, X2, Y2, Z2, Z3, Z4 };
enum extruder_t : uint8_t { E0, E1, E2, E3, E4, E5, E6, E7 };
enum heater_t : uint8_t { H0, H1, H2, H3, H4, H5, BED, CHAMBER };
enum heater_t : uint8_t { H0, H1, H2, H3, H4, H5, BED, CHAMBER, COOLER };
enum fan_t : uint8_t { FAN0, FAN1, FAN2, FAN3, FAN4, FAN5, FAN6, FAN7 };
enum result_t : uint8_t { PID_BAD_EXTRUDER_NUM, PID_TEMP_TOO_HIGH, PID_TUNING_TIMEOUT, PID_DONE };

View File

@ -276,6 +276,9 @@ namespace Language_en {
PROGMEM Language_Str MSG_NOZZLE_STANDBY = _UxGT("Nozzle Standby");
PROGMEM Language_Str MSG_BED = _UxGT("Bed");
PROGMEM Language_Str MSG_CHAMBER = _UxGT("Enclosure");
PROGMEM Language_Str MSG_COOLER = _UxGT("Laser Coolant");
PROGMEM Language_Str MSG_COOLER_TOGGLE = _UxGT("Toggle Cooler");
PROGMEM Language_Str MSG_LASER = _UxGT("Laser");
PROGMEM Language_Str MSG_FAN_SPEED = _UxGT("Fan Speed");
PROGMEM Language_Str MSG_FAN_SPEED_N = _UxGT("Fan Speed ~");
PROGMEM Language_Str MSG_STORED_FAN_N = _UxGT("Stored Fan ~");
@ -482,6 +485,8 @@ namespace Language_en {
PROGMEM Language_Str MSG_THERMAL_RUNAWAY = _UxGT("THERMAL RUNAWAY");
PROGMEM Language_Str MSG_THERMAL_RUNAWAY_BED = _UxGT("BED THERMAL RUNAWAY");
PROGMEM Language_Str MSG_THERMAL_RUNAWAY_CHAMBER = _UxGT("CHAMBER T. RUNAWAY");
PROGMEM Language_Str MSG_THERMAL_RUNAWAY_COOLER = _UxGT("Cooler Runaway");
PROGMEM Language_Str MSG_COOLING_FAILED = _UxGT("Cooling Failed");
PROGMEM Language_Str MSG_ERR_MAXTEMP = _UxGT("Err: MAXTEMP");
PROGMEM Language_Str MSG_ERR_MINTEMP = _UxGT("Err: MINTEMP");
PROGMEM Language_Str MSG_HALTED = _UxGT("PRINTER HALTED");
@ -497,6 +502,7 @@ namespace Language_en {
PROGMEM Language_Str MSG_PROBE_COOLING = _UxGT("Probe Cooling...");
PROGMEM Language_Str MSG_CHAMBER_HEATING = _UxGT("Chamber Heating...");
PROGMEM Language_Str MSG_CHAMBER_COOLING = _UxGT("Chamber Cooling...");
PROGMEM Language_Str MSG_LASER_COOLING = _UxGT("Laser Cooling...");
PROGMEM Language_Str MSG_DELTA_CALIBRATE = _UxGT("Delta Calibration");
PROGMEM Language_Str MSG_DELTA_CALIBRATE_X = _UxGT("Calibrate X");
PROGMEM Language_Str MSG_DELTA_CALIBRATE_Y = _UxGT("Calibrate Y");

View File

@ -195,6 +195,16 @@ void menu_info_thermistors() {
STATIC_ITEM(TERN(WATCH_CHAMBER, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT);
#endif
#if HAS_COOLER
#undef THERMISTOR_ID
#define THERMISTOR_ID TEMP_SENSOR_COOLER
#include "../thermistornames.h"
STATIC_ITEM_P(PSTR("COOL: " THERMISTOR_NAME), SS_INVERT);
PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(COOLER_MINTEMP), SS_LEFT);
PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(COOLER_MAXTEMP), SS_LEFT);
STATIC_ITEM(TERN(WATCH_COOLER, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT);
#endif
END_SCREEN();
}

View File

@ -35,6 +35,10 @@
#include "../../module/motion.h"
#endif
#if HAS_COOLER
#include "../../feature/cooler.h"
#endif
#if ENABLED(SINGLENOZZLE_STANDBY_TEMP)
#include "../../module/tool_change.h"
#endif
@ -68,6 +72,10 @@ void Temperature::lcd_preheat(const int16_t e, const int8_t indh, const int8_t i
#if HAS_HEATED_BED
inline void _preheat_bed(const uint8_t m) { thermalManager.lcd_preheat(-1, -1, m); }
#endif
#if HAS_COOLER
inline void _precool_laser(const uint8_t m, const uint8_t e) { thermalManager.lcd_preheat(e, m, -1); }
void do_precool_laser_m() { _precool_laser(editable.int8, thermalManager.temp_cooler.target); }
#endif
#if HAS_TEMP_HOTEND && HAS_HEATED_BED
inline void _preheat_both(const uint8_t m, const uint8_t e) { thermalManager.lcd_preheat(e, m, m); }
@ -143,6 +151,10 @@ void menu_temperature() {
#endif
#endif
#if HAS_COOLER
if (thermalManager.temp_cooler.target == 0) thermalManager.temp_cooler.target = COOLER_DEFAULT_TEMP;
#endif
START_MENU();
BACK_ITEM(MSG_MAIN);
@ -176,6 +188,15 @@ void menu_temperature() {
EDIT_ITEM_FAST(int3, MSG_CHAMBER, &thermalManager.temp_chamber.target, 0, CHAMBER_MAXTEMP - 10, thermalManager.start_watching_chamber);
#endif
//
// Cooler:
//
#if HAS_COOLER
editable.state = cooler.is_enabled();
EDIT_ITEM(bool, MSG_COOLER(TOGGLE), &cooler.state, []{ if (editable.state) cooler.disable(); else cooler.enable(); });
EDIT_ITEM_FAST(int3, MSG_COOLER, &thermalManager.temp_cooler.target, COOLER_MINTEMP + 2, COOLER_MAXTEMP - 2, thermalManager.start_watching_cooler);
#endif
//
// Fan Speed:
//
@ -232,7 +253,7 @@ void menu_temperature() {
editable.int8 = m;
#if HOTENDS > 1 || HAS_HEATED_BED
SUBMENU_S(ui.get_preheat_label(m), MSG_PREHEAT_M, menu_preheat_m);
#else
#elif HAS_HOTEND
ACTION_ITEM_S(ui.get_preheat_label(m), MSG_PREHEAT_M, do_preheat_end_m);
#endif
}

View File

@ -94,6 +94,9 @@
#ifndef COLOR_CHAMBER
#define COLOR_CHAMBER COLOR_DARK_ORANGE
#endif
#ifndef COLOR_COOLER
#define COLOR_COOLER COLOR_DARK_ORANGE
#endif
#ifndef COLOR_FAN
#define COLOR_FAN COLOR_AQUA
#endif

View File

@ -202,6 +202,12 @@ void Touch::touch(touch_control_t *control) {
MenuItem_int3::action((const char *)GET_TEXT_F(MSG_CHAMBER), &thermalManager.temp_chamber.target, 0, CHAMBER_MAXTEMP - 10, thermalManager.start_watching_chamber);
}
#endif
#if HAS_COOLER
else if (heater == H_COOLER) {
MenuItem_int3::action((const char *)GET_TEXT_F(MSG_COOLER), &thermalManager.temp_cooler.target, 0, COOLER_MAXTEMP - 8, thermalManager.start_watching_cooler);
}
#endif
break;
case FAN:
ui.clear_lcd();

View File

@ -136,6 +136,12 @@ void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) {
#endif
}
#endif
#if HAS_TEMP_COOLER
else if (Heater == H_COOLER) {
currentTemperature = thermalManager.degCooler();
targetTemperature = TERN(HAS_COOLER, thermalManager.degTargetCooler(), ABSOLUTE_ZERO);
}
#endif
else return;
TERN_(TOUCH_SCREEN, if (targetTemperature >= 0) touch.add_control(HEATER, x, y, 64, 100, Heater));
@ -159,6 +165,13 @@ void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) {
image = targetTemperature > 0 ? imgChamberHeated : imgChamber;
}
#endif
#if HAS_TEMP_COOLER
else if (Heater == H_COOLER) {
if (currentTemperature <= 26) Color = COLOR_COLD;
if (currentTemperature > 26) Color = COLOR_RED;
image = targetTemperature > 26 ? imgCoolerHot : imgCooler;
}
#endif
tft.add_image(0, 18, image, Color);

View File

@ -136,6 +136,12 @@ void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) {
#endif
}
#endif
#if HAS_TEMP_COOLER
else if (Heater == H_COOLER) {
currentTemperature = thermalManager.degCooler();
targetTemperature = TERN(HAS_COOLER, thermalManager.degTargetCooler(), ABSOLUTE_ZERO);
}
#endif
else return;
TERN_(TOUCH_SCREEN, if (targetTemperature >= 0) touch.add_control(HEATER, x, y, 80, 120, Heater));

View File

@ -62,6 +62,10 @@ void menu_item(const uint8_t row, bool sel = false);
#define ITEM_CHAMBER 2
#define ITEM_FAN 3
#define ITEMS_COUNT 4
#elif HAS_TEMP_COOLER
#define ITEM_COOLER 0
#define ITEM_FAN 1
#define ITEMS_COUNT 2
#elif HOTENDS > 1
#define ITEM_E0 0
#define ITEM_E1 1