2020-09-21 01:55:02 +00:00
|
|
|
/**
|
|
|
|
* 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/>.
|
|
|
|
*
|
|
|
|
*/
|
2021-05-06 09:17:59 +00:00
|
|
|
#include "../../../inc/MarlinConfigPre.h"
|
2020-09-21 01:55:02 +00:00
|
|
|
|
|
|
|
#if HAS_TFT_LVGL_UI
|
|
|
|
|
|
|
|
#include "draw_ui.h"
|
2020-10-21 17:45:27 +00:00
|
|
|
#include <lv_conf.h>
|
2020-09-21 01:55:02 +00:00
|
|
|
|
2021-05-06 09:17:59 +00:00
|
|
|
#include "../../../module/temperature.h"
|
|
|
|
#include "../../../gcode/gcode.h"
|
|
|
|
#include "../../../module/motion.h"
|
|
|
|
#include "../../../module/planner.h"
|
|
|
|
#include "../../../inc/MarlinConfig.h"
|
2020-09-21 01:55:02 +00:00
|
|
|
|
2020-10-23 01:22:17 +00:00
|
|
|
extern lv_group_t *g;
|
|
|
|
static lv_obj_t *scr;
|
|
|
|
static lv_obj_t *buttonType;
|
2020-09-21 01:55:02 +00:00
|
|
|
static lv_obj_t *labelType;
|
2020-10-23 01:22:17 +00:00
|
|
|
static lv_obj_t *tempText1;
|
2020-09-21 01:55:02 +00:00
|
|
|
|
2020-10-24 04:37:45 +00:00
|
|
|
enum {
|
|
|
|
ID_FILAMNT_IN = 1,
|
|
|
|
ID_FILAMNT_OUT,
|
|
|
|
ID_FILAMNT_TYPE,
|
|
|
|
ID_FILAMNT_RETURN
|
|
|
|
};
|
2020-09-21 01:55:02 +00:00
|
|
|
|
2020-10-24 04:37:45 +00:00
|
|
|
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
|
|
|
if (event != LV_EVENT_RELEASED) return;
|
2020-09-21 01:55:02 +00:00
|
|
|
switch (obj->mks_obj_id) {
|
|
|
|
case ID_FILAMNT_IN:
|
2021-01-17 02:43:46 +00:00
|
|
|
uiCfg.filament_load_heat_flg = true;
|
2021-07-30 04:40:27 +00:00
|
|
|
if (ABS(thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.wholeDegHotend(uiCfg.extruderIndex)) <= 1
|
2021-04-24 01:19:23 +00:00
|
|
|
|| gCfgItems.filament_limit_temp <= thermalManager.wholeDegHotend(uiCfg.extruderIndex)) {
|
2020-10-24 04:37:45 +00:00
|
|
|
lv_clear_filament_change();
|
|
|
|
lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED);
|
2020-09-21 01:55:02 +00:00
|
|
|
}
|
2020-10-24 04:37:45 +00:00
|
|
|
else {
|
|
|
|
lv_clear_filament_change();
|
|
|
|
lv_draw_dialog(DIALOG_TYPE_FILAMENT_LOAD_HEAT);
|
2021-03-19 21:41:47 +00:00
|
|
|
if (thermalManager.degTargetHotend(uiCfg.extruderIndex) < gCfgItems.filament_limit_temp) {
|
|
|
|
thermalManager.setTargetHotend(gCfgItems.filament_limit_temp, uiCfg.extruderIndex);
|
2021-03-06 15:04:05 +00:00
|
|
|
thermalManager.start_watching_hotend(uiCfg.extruderIndex);
|
2020-09-21 01:55:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ID_FILAMNT_OUT:
|
2021-01-17 02:43:46 +00:00
|
|
|
uiCfg.filament_unload_heat_flg = true;
|
2021-03-06 15:04:05 +00:00
|
|
|
if (thermalManager.degTargetHotend(uiCfg.extruderIndex)
|
2021-07-30 04:40:27 +00:00
|
|
|
&& (ABS(thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.wholeDegHotend(uiCfg.extruderIndex)) <= 1
|
2021-04-24 01:19:23 +00:00
|
|
|
|| thermalManager.wholeDegHotend(uiCfg.extruderIndex) >= gCfgItems.filament_limit_temp)
|
2020-10-24 04:37:45 +00:00
|
|
|
) {
|
|
|
|
lv_clear_filament_change();
|
|
|
|
lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED);
|
2020-09-21 01:55:02 +00:00
|
|
|
}
|
2020-10-24 04:37:45 +00:00
|
|
|
else {
|
|
|
|
lv_clear_filament_change();
|
|
|
|
lv_draw_dialog(DIALOG_TYPE_FILAMENT_UNLOAD_HEAT);
|
2021-03-19 21:41:47 +00:00
|
|
|
if (thermalManager.degTargetHotend(uiCfg.extruderIndex) < gCfgItems.filament_limit_temp) {
|
|
|
|
thermalManager.setTargetHotend(gCfgItems.filament_limit_temp, uiCfg.extruderIndex);
|
2021-03-06 15:04:05 +00:00
|
|
|
thermalManager.start_watching_hotend(uiCfg.extruderIndex);
|
2020-09-21 01:55:02 +00:00
|
|
|
}
|
2020-10-24 04:37:45 +00:00
|
|
|
filament_sprayer_temp();
|
2020-09-21 01:55:02 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ID_FILAMNT_TYPE:
|
2020-10-24 04:37:45 +00:00
|
|
|
#if HAS_MULTI_EXTRUDER
|
2021-03-06 15:04:05 +00:00
|
|
|
uiCfg.extruderIndex = !uiCfg.extruderIndex;
|
2020-10-24 04:37:45 +00:00
|
|
|
#endif
|
|
|
|
disp_filament_type();
|
2020-09-21 01:55:02 +00:00
|
|
|
break;
|
|
|
|
case ID_FILAMNT_RETURN:
|
2020-10-24 04:37:45 +00:00
|
|
|
#if HAS_MULTI_EXTRUDER
|
|
|
|
if (uiCfg.print_state != IDLE && uiCfg.print_state != REPRINTED)
|
2021-03-06 15:04:05 +00:00
|
|
|
gcode.process_subcommands_now_P(uiCfg.extruderIndexBak == 1 ? PSTR("T1") : PSTR("T0"));
|
2020-10-24 04:37:45 +00:00
|
|
|
#endif
|
|
|
|
feedrate_mm_s = (float)uiCfg.moveSpeed_bak;
|
|
|
|
if (uiCfg.print_state == PAUSED)
|
|
|
|
planner.set_e_position_mm((destination.e = current_position.e = uiCfg.current_e_position_bak));
|
2021-03-06 15:04:05 +00:00
|
|
|
thermalManager.setTargetHotend(uiCfg.hotendTargetTempBak, uiCfg.extruderIndex);
|
2020-10-24 04:37:45 +00:00
|
|
|
|
|
|
|
clear_cur_ui();
|
|
|
|
draw_return_ui();
|
2020-09-21 01:55:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-14 06:23:56 +00:00
|
|
|
void lv_draw_filament_change() {
|
2020-10-24 22:28:31 +00:00
|
|
|
scr = lv_screen_create(FILAMENTCHANGE_UI);
|
2020-09-21 01:55:02 +00:00
|
|
|
// Create an Image button
|
2020-10-24 04:37:45 +00:00
|
|
|
lv_obj_t *buttonIn = lv_big_button_create(scr, "F:/bmp_in.bin", filament_menu.in, INTERVAL_V, titleHeight, event_handler, ID_FILAMNT_IN);
|
2020-09-21 01:55:02 +00:00
|
|
|
lv_obj_clear_protect(buttonIn, LV_PROTECT_FOLLOW);
|
2020-10-24 04:37:45 +00:00
|
|
|
lv_big_button_create(scr, "F:/bmp_out.bin", filament_menu.out, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_FILAMNT_OUT);
|
2020-09-21 01:55:02 +00:00
|
|
|
|
2020-10-24 04:37:45 +00:00
|
|
|
buttonType = lv_imgbtn_create(scr, nullptr, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_FILAMNT_TYPE);
|
2020-09-21 01:55:02 +00:00
|
|
|
#if HAS_ROTARY_ENCODER
|
|
|
|
if (gCfgItems.encoder_enable) {
|
2020-10-23 01:22:17 +00:00
|
|
|
lv_group_add_obj(g, buttonType);
|
2020-09-21 01:55:02 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2020-10-24 04:37:45 +00:00
|
|
|
lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_FILAMNT_RETURN);
|
|
|
|
|
|
|
|
// Create labels on the image buttons
|
|
|
|
labelType = lv_label_create_empty(buttonType);
|
|
|
|
|
2020-09-21 01:55:02 +00:00
|
|
|
disp_filament_type();
|
|
|
|
|
2020-10-23 01:22:17 +00:00
|
|
|
tempText1 = lv_label_create_empty(scr);
|
2020-09-21 01:55:02 +00:00
|
|
|
lv_obj_set_style(tempText1, &tft_style_label_rel);
|
|
|
|
disp_filament_temp();
|
|
|
|
}
|
|
|
|
|
|
|
|
void disp_filament_type() {
|
2021-03-06 15:04:05 +00:00
|
|
|
if (uiCfg.extruderIndex == 1) {
|
2020-10-23 01:22:17 +00:00
|
|
|
lv_imgbtn_set_src_both(buttonType, "F:/bmp_extru2.bin");
|
2020-10-21 17:45:27 +00:00
|
|
|
if (gCfgItems.multiple_language) {
|
2020-09-21 01:55:02 +00:00
|
|
|
lv_label_set_text(labelType, preheat_menu.ext2);
|
2020-10-23 01:22:17 +00:00
|
|
|
lv_obj_align(labelType, buttonType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
2020-09-21 01:55:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2020-10-23 01:22:17 +00:00
|
|
|
lv_imgbtn_set_src_both(buttonType, "F:/bmp_extru1.bin");
|
2020-10-21 17:45:27 +00:00
|
|
|
if (gCfgItems.multiple_language) {
|
2020-09-21 01:55:02 +00:00
|
|
|
lv_label_set_text(labelType, preheat_menu.ext1);
|
2020-10-23 01:22:17 +00:00
|
|
|
lv_obj_align(labelType, buttonType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
2020-09-21 01:55:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void disp_filament_temp() {
|
|
|
|
char buf[20] = {0};
|
|
|
|
|
|
|
|
public_buf_l[0] = '\0';
|
|
|
|
|
2021-03-06 15:04:05 +00:00
|
|
|
strcat(public_buf_l, uiCfg.extruderIndex < 1 ? preheat_menu.ext1 : preheat_menu.ext2);
|
2021-04-24 01:19:23 +00:00
|
|
|
sprintf(buf, preheat_menu.value_state, thermalManager.wholeDegHotend(uiCfg.extruderIndex), thermalManager.degTargetHotend(uiCfg.extruderIndex));
|
2020-09-21 01:55:02 +00:00
|
|
|
|
|
|
|
strcat_P(public_buf_l, PSTR(": "));
|
|
|
|
strcat(public_buf_l, buf);
|
|
|
|
lv_label_set_text(tempText1, public_buf_l);
|
2020-10-24 04:37:45 +00:00
|
|
|
lv_obj_align(tempText1, nullptr, LV_ALIGN_CENTER, 0, -50);
|
2020-09-21 01:55:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void lv_clear_filament_change() {
|
|
|
|
#if HAS_ROTARY_ENCODER
|
|
|
|
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
|
|
|
#endif
|
|
|
|
lv_obj_del(scr);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // HAS_TFT_LVGL_UI
|