2020-06-16 02:05:33 +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
|
2020-07-23 03:20:14 +00:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2020-06-16 02:05:33 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include "../../../../inc/MarlinConfigPre.h"
|
|
|
|
|
2020-07-25 05:52:07 +00:00
|
|
|
#if HAS_TFT_LVGL_UI
|
2020-06-16 02:05:33 +00:00
|
|
|
|
|
|
|
#include "draw_ui.h"
|
2020-10-21 17:45:27 +00:00
|
|
|
#include <lv_conf.h>
|
2020-06-16 02:05:33 +00:00
|
|
|
//#include "../lvgl/src/lv_objx/lv_imgbtn.h"
|
|
|
|
//#include "../lvgl/src/lv_objx/lv_img.h"
|
|
|
|
//#include "../lvgl/src/lv_core/lv_disp.h"
|
|
|
|
//#include "../lvgl/src/lv_core/lv_refr.h"
|
|
|
|
|
2020-09-21 01:55:02 +00:00
|
|
|
#include "../../../../module/temperature.h"
|
|
|
|
#include "../../../../module/motion.h"
|
|
|
|
#include "../../../../sd/cardreader.h"
|
2020-10-21 17:45:27 +00:00
|
|
|
#include "../../../../inc/MarlinConfig.h"
|
2020-06-16 02:05:33 +00:00
|
|
|
|
2020-10-24 04:37:45 +00:00
|
|
|
extern lv_group_t *g;
|
|
|
|
static lv_obj_t *scr;
|
|
|
|
|
|
|
|
enum {
|
|
|
|
ID_O_PRE_HEAT = 1,
|
|
|
|
ID_O_EXTRUCT,
|
|
|
|
ID_O_MOV,
|
|
|
|
ID_O_FILAMENT,
|
|
|
|
ID_O_SPEED,
|
|
|
|
ID_O_RETURN,
|
|
|
|
ID_O_FAN,
|
|
|
|
ID_O_POWER_OFF,
|
|
|
|
ID_O_BABY_STEP
|
|
|
|
};
|
2020-06-16 02:05:33 +00:00
|
|
|
|
|
|
|
static lv_obj_t *label_PowerOff;
|
|
|
|
static lv_obj_t *buttonPowerOff;
|
|
|
|
|
2020-09-21 01:55:02 +00:00
|
|
|
extern feedRate_t feedrate_mm_s;
|
|
|
|
|
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-06-16 02:05:33 +00:00
|
|
|
switch (obj->mks_obj_id) {
|
|
|
|
case ID_O_PRE_HEAT:
|
2020-10-24 04:37:45 +00:00
|
|
|
lv_clear_operation();
|
|
|
|
lv_draw_preHeat();
|
2020-06-16 02:05:33 +00:00
|
|
|
break;
|
|
|
|
case ID_O_EXTRUCT:
|
2020-10-24 04:37:45 +00:00
|
|
|
lv_clear_operation();
|
|
|
|
lv_draw_extrusion();
|
2020-06-16 02:05:33 +00:00
|
|
|
break;
|
|
|
|
case ID_O_MOV:
|
2020-10-24 04:37:45 +00:00
|
|
|
lv_clear_operation();
|
|
|
|
lv_draw_move_motor();
|
2020-06-16 02:05:33 +00:00
|
|
|
break;
|
|
|
|
case ID_O_FILAMENT:
|
2020-10-24 04:37:45 +00:00
|
|
|
#if HAS_MULTI_EXTRUDER
|
|
|
|
uiCfg.curSprayerChoose_bak = active_extruder;
|
|
|
|
#endif
|
|
|
|
if (uiCfg.print_state == WORKING) {
|
|
|
|
#if ENABLED(SDSUPPORT)
|
|
|
|
card.pauseSDPrint();
|
|
|
|
stop_print_time();
|
|
|
|
uiCfg.print_state = PAUSING;
|
2020-09-21 01:55:02 +00:00
|
|
|
#endif
|
2020-06-16 02:05:33 +00:00
|
|
|
}
|
2020-10-24 04:37:45 +00:00
|
|
|
uiCfg.moveSpeed_bak = (uint16_t)feedrate_mm_s;
|
|
|
|
uiCfg.desireSprayerTempBak = thermalManager.temp_hotend[active_extruder].target;
|
|
|
|
lv_clear_operation();
|
|
|
|
lv_draw_filament_change();
|
2020-06-16 02:05:33 +00:00
|
|
|
break;
|
|
|
|
case ID_O_FAN:
|
2020-10-24 04:37:45 +00:00
|
|
|
lv_clear_operation();
|
|
|
|
lv_draw_fan();
|
2020-06-16 02:05:33 +00:00
|
|
|
break;
|
|
|
|
case ID_O_SPEED:
|
2020-10-24 04:37:45 +00:00
|
|
|
lv_clear_operation();
|
|
|
|
lv_draw_change_speed();
|
2020-06-16 02:05:33 +00:00
|
|
|
break;
|
|
|
|
case ID_O_RETURN:
|
2020-10-24 04:37:45 +00:00
|
|
|
clear_cur_ui();
|
|
|
|
draw_return_ui();
|
2020-06-16 02:05:33 +00:00
|
|
|
break;
|
|
|
|
case ID_O_POWER_OFF:
|
2020-10-24 04:37:45 +00:00
|
|
|
if (gCfgItems.finish_power_off) {
|
|
|
|
gCfgItems.finish_power_off = false;
|
|
|
|
lv_imgbtn_set_src_both(buttonPowerOff, "F:/bmp_manual_off.bin");
|
|
|
|
lv_label_set_text(label_PowerOff, printing_more_menu.manual);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
gCfgItems.finish_power_off = true;
|
|
|
|
lv_imgbtn_set_src_both(buttonPowerOff, "F:/bmp_auto_off.bin");
|
|
|
|
lv_label_set_text(label_PowerOff, printing_more_menu.auto_close);
|
|
|
|
}
|
|
|
|
lv_obj_align(label_PowerOff, buttonPowerOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
|
|
|
lv_obj_refresh_ext_draw_pad(label_PowerOff);
|
|
|
|
update_spi_flash();
|
2020-06-16 02:05:33 +00:00
|
|
|
break;
|
2020-09-21 01:55:02 +00:00
|
|
|
case ID_O_BABY_STEP:
|
2020-10-24 04:37:45 +00:00
|
|
|
lv_clear_operation();
|
|
|
|
lv_draw_baby_stepping();
|
2020-09-21 01:55:02 +00:00
|
|
|
break;
|
2020-06-16 02:05:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-25 05:52:07 +00:00
|
|
|
void lv_draw_operation(void) {
|
2020-10-24 04:37:45 +00:00
|
|
|
lv_obj_t *buttonExtrusion = nullptr, *buttonSpeed = nullptr,
|
|
|
|
*buttonBack = nullptr,
|
|
|
|
*labelPreHeat = nullptr, *labelExtrusion = nullptr,
|
|
|
|
*label_Back = nullptr, *label_Speed = nullptr, *label_Fan = nullptr,
|
|
|
|
*buttonMove = nullptr, *label_Move = nullptr,
|
|
|
|
*buttonBabyStep = nullptr, *label_BabyStep = nullptr,
|
|
|
|
*label_Filament = nullptr;
|
2020-06-16 02:05:33 +00:00
|
|
|
|
2020-10-24 22:28:31 +00:00
|
|
|
scr = lv_screen_create(OPERATE_UI);
|
2020-06-16 02:05:33 +00:00
|
|
|
|
2020-09-21 01:55:02 +00:00
|
|
|
// Create image buttons
|
2020-10-24 04:37:45 +00:00
|
|
|
lv_obj_t *buttonPreHeat = lv_imgbtn_create(scr, "F:/bmp_temp.bin", INTERVAL_V, titleHeight, event_handler, ID_O_PRE_HEAT);
|
|
|
|
lv_obj_t *buttonFilament = lv_imgbtn_create(scr, "F:/bmp_filamentchange.bin", BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_O_FILAMENT);
|
|
|
|
lv_obj_t *buttonFan = lv_imgbtn_create(scr, "F:/bmp_fan.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_O_FAN);
|
2020-10-23 01:22:17 +00:00
|
|
|
buttonPowerOff = lv_imgbtn_create(scr, gCfgItems.finish_power_off ? "F:/bmp_auto_off.bin" : "F:/bmp_manual_off.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_O_POWER_OFF);
|
2020-09-21 01:55:02 +00:00
|
|
|
|
2020-10-23 01:22:17 +00:00
|
|
|
#if HAS_ROTARY_ENCODER
|
|
|
|
if (gCfgItems.encoder_enable) {
|
|
|
|
lv_group_add_obj(g, buttonPreHeat);
|
|
|
|
lv_group_add_obj(g, buttonFilament);
|
|
|
|
lv_group_add_obj(g, buttonFan);
|
|
|
|
lv_group_add_obj(g, buttonPowerOff);
|
2020-09-21 01:55:02 +00:00
|
|
|
}
|
2020-10-23 01:22:17 +00:00
|
|
|
#endif
|
2020-09-21 01:55:02 +00:00
|
|
|
|
2020-10-23 01:22:17 +00:00
|
|
|
if (uiCfg.print_state != WORKING) {
|
|
|
|
buttonExtrusion = lv_imgbtn_create(scr, "F:/bmp_extrude_opr.bin", INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_O_EXTRUCT);
|
|
|
|
buttonMove = lv_imgbtn_create(scr, "F:/bmp_move_opr.bin", BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_O_MOV);
|
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, buttonExtrusion);
|
|
|
|
lv_group_add_obj(g, buttonMove);
|
2020-09-21 01:55:02 +00:00
|
|
|
}
|
|
|
|
#endif
|
2020-10-23 01:22:17 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
buttonSpeed = lv_imgbtn_create(scr, "F:/bmp_speed.bin", INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_O_SPEED);
|
|
|
|
buttonBabyStep = lv_imgbtn_create(scr, "F:/bmp_mov.bin", BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_O_BABY_STEP);
|
|
|
|
#if HAS_ROTARY_ENCODER
|
|
|
|
if (gCfgItems.encoder_enable) {
|
|
|
|
lv_group_add_obj(g, buttonSpeed);
|
|
|
|
lv_group_add_obj(g, buttonBabyStep);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2020-06-16 02:05:33 +00:00
|
|
|
|
2020-10-23 01:22:17 +00:00
|
|
|
buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_O_RETURN);
|
2020-06-16 02:05:33 +00:00
|
|
|
|
2020-09-21 01:55:02 +00:00
|
|
|
#if HAS_ROTARY_ENCODER
|
|
|
|
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
|
|
|
|
#endif
|
2020-06-16 02:05:33 +00:00
|
|
|
|
2020-09-21 01:55:02 +00:00
|
|
|
// Create labels on the image buttons
|
2020-10-23 01:22:17 +00:00
|
|
|
labelPreHeat = lv_label_create_empty(buttonPreHeat);
|
|
|
|
label_Filament = lv_label_create_empty(buttonFilament);
|
|
|
|
label_Fan = lv_label_create_empty(buttonFan);
|
|
|
|
label_PowerOff = lv_label_create_empty(buttonPowerOff);
|
2020-06-16 02:05:33 +00:00
|
|
|
|
2020-07-25 05:52:07 +00:00
|
|
|
if (uiCfg.print_state != WORKING) {
|
|
|
|
/*
|
2020-10-23 01:22:17 +00:00
|
|
|
label_Filament = lv_label_create_empty(buttonFilament);
|
2020-07-25 05:52:07 +00:00
|
|
|
} else {
|
|
|
|
*/
|
2020-10-23 01:22:17 +00:00
|
|
|
labelExtrusion = lv_label_create_empty(buttonExtrusion);
|
|
|
|
label_Move = lv_label_create_empty(buttonMove);
|
2020-09-21 01:55:02 +00:00
|
|
|
}
|
|
|
|
else {
|
2020-10-23 01:22:17 +00:00
|
|
|
label_Speed = lv_label_create_empty(buttonSpeed);
|
|
|
|
label_BabyStep = lv_label_create_empty(buttonBabyStep);
|
2020-06-16 02:05:33 +00:00
|
|
|
}
|
2020-10-23 01:22:17 +00:00
|
|
|
label_Back = lv_label_create_empty(buttonBack);
|
2020-06-16 02:05:33 +00:00
|
|
|
|
2020-10-21 17:45:27 +00:00
|
|
|
if (gCfgItems.multiple_language) {
|
2020-06-16 02:05:33 +00:00
|
|
|
lv_label_set_text(labelPreHeat, operation_menu.temp);
|
|
|
|
lv_obj_align(labelPreHeat, buttonPreHeat, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
|
|
|
|
2020-09-21 01:55:02 +00:00
|
|
|
lv_label_set_text(label_Filament, operation_menu.filament);
|
|
|
|
lv_obj_align(label_Filament, buttonFilament, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
2020-06-16 02:05:33 +00:00
|
|
|
|
|
|
|
lv_label_set_text(label_Fan, operation_menu.fan);
|
|
|
|
lv_obj_align(label_Fan, buttonFan, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
|
|
|
|
2020-10-21 17:45:27 +00:00
|
|
|
if (gCfgItems.finish_power_off)
|
2020-09-21 01:55:02 +00:00
|
|
|
lv_label_set_text(label_PowerOff, printing_more_menu.auto_close);
|
|
|
|
else
|
|
|
|
lv_label_set_text(label_PowerOff, printing_more_menu.manual);
|
|
|
|
lv_obj_align(label_PowerOff, buttonPowerOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
2020-06-16 02:05:33 +00:00
|
|
|
|
|
|
|
if (uiCfg.print_state != WORKING) {
|
2020-07-25 05:52:07 +00:00
|
|
|
/*
|
|
|
|
lv_label_set_text(label_Filament, operation_menu.filament);
|
|
|
|
lv_obj_align(label_Filament, buttonFilament, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET);
|
|
|
|
} else {
|
|
|
|
*/
|
2020-09-21 01:55:02 +00:00
|
|
|
lv_label_set_text(labelExtrusion, operation_menu.extr);
|
|
|
|
lv_obj_align(labelExtrusion, buttonExtrusion, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
|
|
|
|
2020-06-16 02:05:33 +00:00
|
|
|
lv_label_set_text(label_Move, operation_menu.move);
|
|
|
|
lv_obj_align(label_Move, buttonMove, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
|
|
|
}
|
2020-09-21 01:55:02 +00:00
|
|
|
else {
|
|
|
|
lv_label_set_text(label_Speed, operation_menu.speed);
|
|
|
|
lv_obj_align(label_Speed, buttonSpeed, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
2020-06-16 02:05:33 +00:00
|
|
|
|
2020-09-21 01:55:02 +00:00
|
|
|
lv_label_set_text(label_BabyStep, operation_menu.babystep);
|
|
|
|
lv_obj_align(label_BabyStep, buttonBabyStep, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
|
|
|
}
|
2020-06-16 02:05:33 +00:00
|
|
|
|
|
|
|
lv_label_set_text(label_Back, common_menu.text_back);
|
|
|
|
lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-21 01:55:02 +00:00
|
|
|
void lv_clear_operation() {
|
|
|
|
#if HAS_ROTARY_ENCODER
|
|
|
|
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
|
|
|
#endif
|
|
|
|
lv_obj_del(scr);
|
|
|
|
}
|
2020-06-16 02:05:33 +00:00
|
|
|
|
2020-07-25 05:52:07 +00:00
|
|
|
#endif // HAS_TFT_LVGL_UI
|