1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-12-14 14:31:33 +00:00
MarlinFirmware/Marlin/src/lcd/menu/menu_temperature.cpp

288 lines
8.6 KiB
C++
Raw Normal View History

2018-10-27 23:30:37 +00:00
/**
* Marlin 3D Printer Firmware
2020-02-03 14:00:57 +00:00
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
2018-10-27 23:30:37 +00:00
*
* Based on Sprinter and grbl.
2019-06-28 04:57:50 +00:00
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
2018-10-27 23:30:37 +00:00
*
* 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 <http://www.gnu.org/licenses/>.
*
*/
//
// Temperature Menu
//
#include "../../inc/MarlinConfigPre.h"
#if HAS_LCD_MENU
#include "menu.h"
#include "../../module/temperature.h"
#if FAN_COUNT > 1 || ENABLED(SINGLENOZZLE)
2018-10-27 23:30:37 +00:00
#include "../../module/motion.h"
#endif
#if ENABLED(SINGLENOZZLE)
#include "../../module/tool_change.h"
#endif
2018-10-28 07:59:21 +00:00
// Initialized by settings.load()
int16_t MarlinUI::preheat_hotend_temp[2], MarlinUI::preheat_bed_temp[2];
uint8_t MarlinUI::preheat_fan_speed[2];
2018-10-28 07:59:21 +00:00
2018-10-27 23:30:37 +00:00
//
// "Temperature" submenu items
//
2020-04-27 09:35:20 +00:00
void Temperature::lcd_preheat(const int16_t e, const int8_t indh, const int8_t indb) {
2020-04-20 04:56:55 +00:00
#if HAS_HOTEND
2020-04-27 09:35:20 +00:00
if (indh >= 0 && ui.preheat_hotend_temp[indh] > 0)
2020-04-27 12:53:58 +00:00
setTargetHotend(_MIN(thermalManager.heater_maxtemp[e] - HOTEND_OVERSHOOT, ui.preheat_hotend_temp[indh]), e);
2020-04-27 09:35:20 +00:00
#else
2020-04-27 12:53:58 +00:00
UNUSED(e); UNUSED(indh);
2019-09-10 07:20:49 +00:00
#endif
2018-10-27 23:30:37 +00:00
#if HAS_HEATED_BED
2020-04-27 09:41:18 +00:00
if (indb >= 0 && ui.preheat_bed_temp[indb] > 0) setTargetBed(ui.preheat_bed_temp[indb]);
2018-10-27 23:30:37 +00:00
#else
2020-04-27 09:35:20 +00:00
UNUSED(indb);
2018-10-27 23:30:37 +00:00
#endif
2020-04-27 09:35:20 +00:00
#if HAS_FAN
set_fan_speed((
#if FAN_COUNT > 1
2020-04-27 09:41:18 +00:00
active_extruder < FAN_COUNT ? active_extruder :
2020-04-27 09:35:20 +00:00
#endif
2020-04-27 11:27:54 +00:00
0), ui.preheat_fan_speed[indh]
2020-04-27 09:41:18 +00:00
);
2018-10-27 23:30:37 +00:00
#endif
ui.return_to_status();
2018-10-27 23:30:37 +00:00
}
#if HAS_TEMP_HOTEND
2020-04-27 09:41:18 +00:00
inline void _preheat_end(const uint8_t m, const uint8_t e) { thermalManager.lcd_preheat(e, m, -1); }
2018-10-27 23:30:37 +00:00
#if HAS_HEATED_BED
2020-04-27 09:41:18 +00:00
inline void _preheat_both(const uint8_t m, const uint8_t e) { thermalManager.lcd_preheat(e, m, m); }
2018-10-27 23:30:37 +00:00
#endif
#endif
#if HAS_HEATED_BED
2020-04-27 09:41:18 +00:00
inline void _preheat_bed(const uint8_t m) { thermalManager.lcd_preheat(-1, -1, m); }
#endif
2018-10-27 23:30:37 +00:00
#if HAS_TEMP_HOTEND || HAS_HEATED_BED
#define _PREHEAT_ITEMS(M,N) do{ \
ACTION_ITEM_N(N, MSG_PREHEAT_##M##_H, []{ _preheat_both(M-1, MenuItemBase::itemIndex); }); \
ACTION_ITEM_N(N, MSG_PREHEAT_##M##_END_E, []{ _preheat_end(M-1, MenuItemBase::itemIndex); }); \
}while(0)
2018-10-27 23:30:37 +00:00
#if HAS_HEATED_BED
#define PREHEAT_ITEMS(M,N) _PREHEAT_ITEMS(M,N)
#else
#define PREHEAT_ITEMS(M,N) \
ACTION_ITEM_N(N, MSG_PREHEAT_##M##_H, []{ _preheat_end(M-1, MenuItemBase::itemIndex); })
2018-10-27 23:30:37 +00:00
#endif
void menu_preheat_m1() {
START_MENU();
2019-10-03 10:38:30 +00:00
BACK_ITEM(MSG_TEMPERATURE);
2018-10-27 23:30:37 +00:00
#if HOTENDS == 1
#if HAS_HEATED_BED
2019-11-02 05:05:05 +00:00
ACTION_ITEM(MSG_PREHEAT_1, []{ _preheat_both(0, 0); });
ACTION_ITEM(MSG_PREHEAT_1_END, []{ _preheat_end(0, 0); });
2018-10-27 23:30:37 +00:00
#else
2019-11-02 05:05:05 +00:00
ACTION_ITEM(MSG_PREHEAT_1, []{ _preheat_end(0, 0); });
2018-10-27 23:30:37 +00:00
#endif
2020-04-20 04:56:55 +00:00
#elif HAS_MULTI_HOTEND
2018-10-27 23:30:37 +00:00
#if HAS_HEATED_BED
_PREHEAT_ITEMS(1,0);
2018-10-27 23:30:37 +00:00
#endif
2020-03-14 04:18:16 +00:00
LOOP_S_L_N(n, 1, HOTENDS) PREHEAT_ITEMS(1,n);
ACTION_ITEM(MSG_PREHEAT_1_ALL, []() {
2020-04-22 21:35:03 +00:00
TERN_(HAS_HEATED_BED, _preheat_bed(0));
HOTEND_LOOP() thermalManager.setTargetHotend(ui.preheat_hotend_temp[0], e);
});
2020-04-20 04:56:55 +00:00
#endif // HAS_MULTI_HOTEND
2018-10-27 23:30:37 +00:00
#if HAS_HEATED_BED
2019-11-02 05:05:05 +00:00
ACTION_ITEM(MSG_PREHEAT_1_BEDONLY, []{ _preheat_bed(0); });
2018-10-27 23:30:37 +00:00
#endif
END_MENU();
}
void menu_preheat_m2() {
START_MENU();
2019-10-03 10:38:30 +00:00
BACK_ITEM(MSG_TEMPERATURE);
2018-10-27 23:30:37 +00:00
#if HOTENDS == 1
#if HAS_HEATED_BED
2019-11-02 05:05:05 +00:00
ACTION_ITEM(MSG_PREHEAT_2, []{ _preheat_both(1, 0); });
ACTION_ITEM(MSG_PREHEAT_2_END, []{ _preheat_end(1, 0); });
2018-10-27 23:30:37 +00:00
#else
2019-11-02 05:05:05 +00:00
ACTION_ITEM(MSG_PREHEAT_2, []{ _preheat_end(1, 0); });
2018-10-27 23:30:37 +00:00
#endif
2020-04-20 04:56:55 +00:00
#elif HAS_MULTI_HOTEND
2018-10-27 23:30:37 +00:00
#if HAS_HEATED_BED
_PREHEAT_ITEMS(2,0);
2018-10-27 23:30:37 +00:00
#endif
2020-03-14 04:18:16 +00:00
LOOP_S_L_N(n, 1, HOTENDS) PREHEAT_ITEMS(2,n);
ACTION_ITEM(MSG_PREHEAT_2_ALL, []() {
2020-04-22 21:35:03 +00:00
TERN_(HAS_HEATED_BED, _preheat_bed(1));
HOTEND_LOOP() thermalManager.setTargetHotend(ui.preheat_hotend_temp[1], e);
});
2020-04-20 04:56:55 +00:00
#endif // HAS_MULTI_HOTEND
2018-10-27 23:30:37 +00:00
#if HAS_HEATED_BED
2019-11-02 05:05:05 +00:00
ACTION_ITEM(MSG_PREHEAT_2_BEDONLY, []{ _preheat_bed(1); });
2018-10-27 23:30:37 +00:00
#endif
END_MENU();
}
void lcd_cooldown() {
thermalManager.zero_fan_speeds();
2018-10-27 23:30:37 +00:00
thermalManager.disable_all_heaters();
ui.return_to_status();
2018-10-27 23:30:37 +00:00
}
#endif // HAS_TEMP_HOTEND || HAS_HEATED_BED
void menu_temperature() {
START_MENU();
2019-10-03 10:38:30 +00:00
BACK_ITEM(MSG_MAIN);
2018-10-27 23:30:37 +00:00
//
// Nozzle:
// Nozzle [1-5]:
//
#if HOTENDS == 1
2020-04-27 09:48:11 +00:00
EDIT_ITEM_FAST(int3, MSG_NOZZLE, &thermalManager.temp_hotend[0].target, 0, HEATER_0_MAXTEMP - HOTEND_OVERSHOOT, []{ thermalManager.start_watching_hotend(0); });
2020-04-20 04:56:55 +00:00
#elif HAS_MULTI_HOTEND
HOTEND_LOOP()
2020-04-27 12:53:58 +00:00
EDIT_ITEM_FAST_N(int3, e, MSG_NOZZLE_N, &thermalManager.temp_hotend[e].target, 0, thermalManager.heater_maxtemp[e] - HOTEND_OVERSHOOT, []{ thermalManager.start_watching_hotend(MenuItemBase::itemIndex); });
#endif
2018-10-27 23:30:37 +00:00
#if ENABLED(SINGLENOZZLE)
2020-04-27 09:48:11 +00:00
EDIT_ITEM_FAST(uint16_3, MSG_NOZZLE_STANDBY, &singlenozzle_temp[active_extruder ? 0 : 1], 0, HEATER_0_MAXTEMP - HOTEND_OVERSHOOT);
#endif
2018-10-27 23:30:37 +00:00
//
// Bed:
//
#if HAS_HEATED_BED
2020-04-27 09:41:18 +00:00
EDIT_ITEM_FAST(int3, MSG_BED, &thermalManager.temp_bed.target, 0, BED_MAX_TARGET, thermalManager.start_watching_bed);
#endif
//
// Chamber:
//
#if HAS_HEATED_CHAMBER
EDIT_ITEM_FAST(int3, MSG_CHAMBER, &thermalManager.temp_chamber.target, 0, CHAMBER_MAXTEMP - 10, thermalManager.start_watching_chamber);
2018-10-27 23:30:37 +00:00
#endif
//
// Fan Speed:
//
2020-04-27 09:41:18 +00:00
#if HAS_FAN
auto on_fan_update = []{
thermalManager.set_fan_speed(MenuItemBase::itemIndex, editable.uint8);
};
#if HAS_FAN1 || HAS_FAN2 || HAS_FAN3 || HAS_FAN4 || HAS_FAN5 || HAS_FAN6 || HAS_FAN7
auto fan_edit_items = [&](const uint8_t f) {
editable.uint8 = thermalManager.fan_speed[f];
EDIT_ITEM_FAST_N(percent, f, MSG_FAN_SPEED_N, &editable.uint8, 0, 255, on_fan_update);
#if ENABLED(EXTRA_FAN_SPEED)
EDIT_ITEM_FAST_N(percent, f, MSG_EXTRA_FAN_SPEED_N, &thermalManager.new_fan_speed[f], 3, 255);
#endif
};
#endif
#define SNFAN(N) (ENABLED(SINGLENOZZLE) && !HAS_FAN##N && EXTRUDERS > N)
#if SNFAN(1) || SNFAN(2) || SNFAN(3) || SNFAN(4) || SNFAN(5) || SNFAN(6) || SNFAN(7)
auto singlenozzle_item = [&](const uint8_t f) {
editable.uint8 = thermalManager.fan_speed[f];
EDIT_ITEM_FAST_N(percent, f, MSG_STORED_FAN_N, &editable.uint8, 0, 255, on_fan_update);
};
#endif
2018-10-27 23:30:37 +00:00
#if HAS_FAN0
editable.uint8 = thermalManager.fan_speed[0];
EDIT_ITEM_FAST_N(percent, 0, MSG_FIRST_FAN_SPEED, &editable.uint8, 0, 255, on_fan_update);
2018-10-27 23:30:37 +00:00
#if ENABLED(EXTRA_FAN_SPEED)
EDIT_ITEM_FAST_N(percent, 0, MSG_FIRST_EXTRA_FAN_SPEED, &thermalManager.new_fan_speed[0], 3, 255);
2018-10-27 23:30:37 +00:00
#endif
#endif
#if HAS_FAN1
fan_edit_items(1);
#elif SNFAN(1)
singlenozzle_item(1);
2018-10-27 23:30:37 +00:00
#endif
#if HAS_FAN2
fan_edit_items(2);
#elif SNFAN(2)
singlenozzle_item(1);
#endif
#if HAS_FAN3
fan_edit_items(3);
#elif SNFAN(3)
singlenozzle_item(1);
#endif
#if HAS_FAN4
fan_edit_items(4);
#elif SNFAN(4)
singlenozzle_item(1);
2018-10-27 23:30:37 +00:00
#endif
#if HAS_FAN5
fan_edit_items(5);
#elif SNFAN(5)
singlenozzle_item(1);
#endif
#if HAS_FAN6
fan_edit_items(6);
#elif SNFAN(6)
singlenozzle_item(1);
#endif
#if HAS_FAN7
fan_edit_items(7);
#elif SNFAN(7)
singlenozzle_item(1);
#endif
2020-04-27 09:41:18 +00:00
#endif // HAS_FAN
2018-10-27 23:30:37 +00:00
#if HAS_TEMP_HOTEND
//
// Preheat for Material 1 and 2
//
#if TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_3 != 0 || TEMP_SENSOR_4 != 0 || TEMP_SENSOR_5 != 0 || TEMP_SENSOR_6 != 0 || TEMP_SENSOR_7 != 0 || HAS_HEATED_BED
2019-10-03 10:38:30 +00:00
SUBMENU(MSG_PREHEAT_1, menu_preheat_m1);
SUBMENU(MSG_PREHEAT_2, menu_preheat_m2);
2018-10-27 23:30:37 +00:00
#else
2019-11-02 05:05:05 +00:00
ACTION_ITEM(MSG_PREHEAT_1, []{ _preheat_end(0, 0); });
ACTION_ITEM(MSG_PREHEAT_2, []{ _preheat_end(1, 0); });
2018-10-27 23:30:37 +00:00
#endif
2019-05-25 20:16:00 +00:00
//
// Cooldown
//
bool has_heat = false;
HOTEND_LOOP() if (thermalManager.temp_hotend[HOTEND_INDEX].target) { has_heat = true; break; }
2020-04-22 21:35:03 +00:00
if (TERN0(HAS_HEATED_BED, thermalManager.temp_bed.target)) has_heat = true;
2019-10-03 10:38:30 +00:00
if (has_heat) ACTION_ITEM(MSG_COOLDOWN, lcd_cooldown);
2018-10-27 23:30:37 +00:00
2019-05-25 20:16:00 +00:00
#endif // HAS_TEMP_HOTEND
2019-01-21 05:41:47 +00:00
2018-10-27 23:30:37 +00:00
END_MENU();
}
#endif // HAS_LCD_MENU