Robin nano V2, TFT LVGL UI parameters, and more (#18500)

This commit is contained in:
MKS-Sean
2020-07-25 13:52:07 +08:00
committed by Scott Lahteine
parent c5ec80d6c7
commit d20d459132
90 changed files with 11656 additions and 4119 deletions

View File

@@ -21,7 +21,7 @@
*/
#include "../../../../inc/MarlinConfigPre.h"
#if ENABLED(TFT_LVGL_UI)
#if HAS_TFT_LVGL_UI
#include "lv_conf.h"
#include "draw_ui.h"
@@ -53,7 +53,7 @@ static lv_obj_t * buttonPause, *buttonOperat, *buttonStop;
static lv_obj_t* labelBed;
#endif
#define ID_PAUSE 1
#define ID_PAUSE 1
#define ID_STOP 2
#define ID_OPTION 3
@@ -74,36 +74,36 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
else if (event == LV_EVENT_RELEASED) {
if (gcode_preview_over != 1) {
if (uiCfg.print_state == WORKING) {
//#if ENABLED(PARK_HEAD_ON_PAUSE)
//queue.inject_P(PSTR("M25 P\nM24"));
// #if ENABLED(PARK_HEAD_ON_PAUSE)
// queue.inject_P(PSTR("M25 P\nM24"));
#if ENABLED(SDSUPPORT)
//queue.inject_P(PSTR("M25\nG91\nG1 Z10\nG90"));
// queue.inject_P(PSTR("M25\nG91\nG1 Z10\nG90"));
card.pauseSDPrint();
stop_print_time();
uiCfg.print_state = PAUSING;
#endif
lv_obj_set_event_cb_mks(buttonPause, event_handler, ID_PAUSE, "bmp_Pause.bin", 0);
lv_obj_set_event_cb_mks(buttonPause, event_handler, ID_PAUSE, "bmp_resume.bin", 0);
lv_label_set_text(labelPause, printing_menu.resume);
lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0);
}
else if (uiCfg.print_state == PAUSED) {
uiCfg.print_state = RESUMING;
//if (IS_SD_PAUSED())queue.inject_P(PSTR("M24"));// queue.inject_P(M24_STR);
lv_obj_set_event_cb_mks(obj, event_handler, ID_PAUSE, "bmp_Resume.bin", 0);
// if (IS_SD_PAUSED())queue.inject_P(PSTR("M24"));// queue.inject_P(M24_STR);
lv_obj_set_event_cb_mks(obj, event_handler, ID_PAUSE, "bmp_pause.bin", 0);
lv_label_set_text(labelPause, printing_menu.pause);
lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0);
}
#if ENABLED(POWER_LOSS_RECOVERY)
else if (uiCfg.print_state == REPRINTING) {
uiCfg.print_state = REPRINTED;
lv_obj_set_event_cb_mks(obj, event_handler, ID_PAUSE, "bmp_Resume.bin", 0);
lv_label_set_text(labelPause, printing_menu.pause);
lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0);
//recovery.resume();
print_time.minutes = recovery.info.print_job_elapsed / 60;
print_time.seconds = recovery.info.print_job_elapsed % 60;
print_time.hours = print_time.minutes / 60;
}
else if (uiCfg.print_state == REPRINTING) {
uiCfg.print_state = REPRINTED;
lv_obj_set_event_cb_mks(obj, event_handler, ID_PAUSE, "bmp_pause.bin", 0);
lv_label_set_text(labelPause, printing_menu.pause);
lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0);
// recovery.resume();
print_time.minutes = recovery.info.print_job_elapsed / 60;
print_time.seconds = recovery.info.print_job_elapsed % 60;
print_time.hours = print_time.minutes / 60;
}
#endif
}
}
@@ -127,7 +127,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
else if (event == LV_EVENT_RELEASED) {
if (gcode_preview_over != 1) {
lv_obj_del(scr);
lv_draw_opration();
lv_draw_operation();
}
}
break;
@@ -146,14 +146,14 @@ void lv_draw_printing(void) {
scr = lv_obj_create(NULL, NULL);
//static lv_style_t tool_style;
// static lv_style_t tool_style;
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
lv_obj_t * title = lv_label_create(scr, NULL);
lv_obj_set_style(title, &tft_style_lable_rel);
lv_obj_set_style(title, &tft_style_label_rel);
lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS);
lv_label_set_text(title, creat_title_text());
@@ -172,74 +172,74 @@ void lv_draw_printing(void) {
#endif
buttonFanstate = lv_imgbtn_create(scr, NULL);
buttonZpos = lv_imgbtn_create(scr, NULL);
buttonPause = lv_imgbtn_create(scr, NULL);
buttonStop = lv_imgbtn_create(scr, NULL);
buttonOperat = lv_imgbtn_create(scr, NULL);
buttonTime = lv_imgbtn_create(scr, NULL);
buttonZpos = lv_imgbtn_create(scr, NULL);
buttonPause = lv_imgbtn_create(scr, NULL);
buttonStop = lv_imgbtn_create(scr, NULL);
buttonOperat = lv_imgbtn_create(scr, NULL);
buttonTime = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonExt1, event_handler, 0, "bmp_Ext1_state.bin", 0);
lv_obj_set_event_cb_mks(buttonExt1, event_handler, 0, "bmp_ext1_state.bin", 0);
lv_imgbtn_set_src(buttonExt1, LV_BTN_STATE_REL, &bmp_pic_45x45);
lv_imgbtn_set_src(buttonExt1, LV_BTN_STATE_PR, &bmp_pic_45x45);
lv_imgbtn_set_style(buttonExt1, LV_BTN_STATE_PR, &tft_style_lable_pre);
lv_imgbtn_set_style(buttonExt1, LV_BTN_STATE_REL, &tft_style_lable_rel);
lv_imgbtn_set_style(buttonExt1, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonExt1, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_clear_protect(buttonExt1, LV_PROTECT_FOLLOW);
#if 1
if (EXTRUDERS == 2) {
lv_obj_set_event_cb_mks(buttonExt2, event_handler, 0, "bmp_Ext2_state.bin", 0);
lv_imgbtn_set_src(buttonExt2, LV_BTN_STATE_REL, &bmp_pic_45x45);
lv_imgbtn_set_src(buttonExt2, LV_BTN_STATE_PR, &bmp_pic_45x45);
lv_imgbtn_set_style(buttonExt2, LV_BTN_STATE_PR, &tft_style_lable_pre);
lv_imgbtn_set_style(buttonExt2, LV_BTN_STATE_REL, &tft_style_lable_rel);
}
#if HAS_HEATED_BED
lv_obj_set_event_cb_mks(buttonBedstate, event_handler, 0, "bmp_Bed_state.bin", 0);
lv_imgbtn_set_src(buttonBedstate, LV_BTN_STATE_REL, &bmp_pic_45x45);
lv_imgbtn_set_src(buttonBedstate, LV_BTN_STATE_PR, &bmp_pic_45x45);
lv_imgbtn_set_style(buttonBedstate, LV_BTN_STATE_PR, &tft_style_lable_pre);
lv_imgbtn_set_style(buttonBedstate, LV_BTN_STATE_REL, &tft_style_lable_rel);
#endif
if (EXTRUDERS == 2) {
lv_obj_set_event_cb_mks(buttonExt2, event_handler, 0, "bmp_ext2_state.bin", 0);
lv_imgbtn_set_src(buttonExt2, LV_BTN_STATE_REL, &bmp_pic_45x45);
lv_imgbtn_set_src(buttonExt2, LV_BTN_STATE_PR, &bmp_pic_45x45);
lv_imgbtn_set_style(buttonExt2, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonExt2, LV_BTN_STATE_REL, &tft_style_label_rel);
}
#if HAS_HEATED_BED
lv_obj_set_event_cb_mks(buttonBedstate, event_handler, 0, "bmp_bed_state.bin", 0);
lv_imgbtn_set_src(buttonBedstate, LV_BTN_STATE_REL, &bmp_pic_45x45);
lv_imgbtn_set_src(buttonBedstate, LV_BTN_STATE_PR, &bmp_pic_45x45);
lv_imgbtn_set_style(buttonBedstate, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonBedstate, LV_BTN_STATE_REL, &tft_style_label_rel);
#endif
lv_obj_set_event_cb_mks(buttonFanstate, event_handler, 0, "bmp_Fan_state.bin", 0);
lv_imgbtn_set_src(buttonFanstate, LV_BTN_STATE_REL, &bmp_pic_45x45);
lv_imgbtn_set_src(buttonFanstate, LV_BTN_STATE_PR, &bmp_pic_45x45);
lv_imgbtn_set_style(buttonFanstate, LV_BTN_STATE_PR, &tft_style_lable_pre);
lv_imgbtn_set_style(buttonFanstate, LV_BTN_STATE_REL, &tft_style_lable_rel);
lv_obj_set_event_cb_mks(buttonFanstate, event_handler, 0, "bmp_fan_state.bin", 0);
lv_imgbtn_set_src(buttonFanstate, LV_BTN_STATE_REL, &bmp_pic_45x45);
lv_imgbtn_set_src(buttonFanstate, LV_BTN_STATE_PR, &bmp_pic_45x45);
lv_imgbtn_set_style(buttonFanstate, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonFanstate, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonTime, event_handler, 0, "bmp_Time_state.bin", 0);
lv_imgbtn_set_src(buttonTime, LV_BTN_STATE_REL, &bmp_pic_45x45);
lv_imgbtn_set_src(buttonTime, LV_BTN_STATE_PR, &bmp_pic_45x45);
lv_imgbtn_set_style(buttonTime, LV_BTN_STATE_PR, &tft_style_lable_pre);
lv_imgbtn_set_style(buttonTime, LV_BTN_STATE_REL, &tft_style_lable_rel);
lv_obj_set_event_cb_mks(buttonTime, event_handler, 0, "bmp_time_state.bin", 0);
lv_imgbtn_set_src(buttonTime, LV_BTN_STATE_REL, &bmp_pic_45x45);
lv_imgbtn_set_src(buttonTime, LV_BTN_STATE_PR, &bmp_pic_45x45);
lv_imgbtn_set_style(buttonTime, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonTime, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonZpos, event_handler, 0, "bmp_Zpos_state.bin", 0);
lv_imgbtn_set_src(buttonZpos, LV_BTN_STATE_REL, &bmp_pic_45x45);
lv_imgbtn_set_src(buttonZpos, LV_BTN_STATE_PR, &bmp_pic_45x45);
lv_imgbtn_set_style(buttonZpos, LV_BTN_STATE_PR, &tft_style_lable_pre);
lv_imgbtn_set_style(buttonZpos, LV_BTN_STATE_REL, &tft_style_lable_rel);
lv_obj_set_event_cb_mks(buttonZpos, event_handler, 0, "bmp_zpos_state.bin", 0);
lv_imgbtn_set_src(buttonZpos, LV_BTN_STATE_REL, &bmp_pic_45x45);
lv_imgbtn_set_src(buttonZpos, LV_BTN_STATE_PR, &bmp_pic_45x45);
lv_imgbtn_set_style(buttonZpos, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonZpos, LV_BTN_STATE_REL, &tft_style_label_rel);
if (uiCfg.print_state == WORKING)
lv_obj_set_event_cb_mks(buttonPause, event_handler, ID_PAUSE, "bmp_Resume.bin", 0);
else
lv_obj_set_event_cb_mks(buttonPause, event_handler, ID_PAUSE, "bmp_Pause.bin", 0);
if (uiCfg.print_state == WORKING)
lv_obj_set_event_cb_mks(buttonPause, event_handler, ID_PAUSE, "bmp_pause.bin", 0);
else
lv_obj_set_event_cb_mks(buttonPause, event_handler, ID_PAUSE, "bmp_resume.bin", 0);
lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_REL, &bmp_pic_150x80);
lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_PR, &bmp_pic_150x80);
lv_imgbtn_set_style(buttonPause, LV_BTN_STATE_PR, &tft_style_lable_pre);
lv_imgbtn_set_style(buttonPause, LV_BTN_STATE_REL, &tft_style_lable_rel);
lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_REL, &bmp_pic_150x80);
lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_PR, &bmp_pic_150x80);
lv_imgbtn_set_style(buttonPause, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonPause, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonStop, event_handler, ID_STOP, "bmp_Stop.bin", 0);
lv_imgbtn_set_src(buttonStop, LV_BTN_STATE_REL, &bmp_pic_150x80);
lv_imgbtn_set_src(buttonStop, LV_BTN_STATE_PR, &bmp_pic_150x80);
lv_imgbtn_set_style(buttonStop, LV_BTN_STATE_PR, &tft_style_lable_pre);
lv_imgbtn_set_style(buttonStop, LV_BTN_STATE_REL, &tft_style_lable_rel);
lv_obj_set_event_cb_mks(buttonStop, event_handler, ID_STOP, "bmp_stop.bin", 0);
lv_imgbtn_set_src(buttonStop, LV_BTN_STATE_REL, &bmp_pic_150x80);
lv_imgbtn_set_src(buttonStop, LV_BTN_STATE_PR, &bmp_pic_150x80);
lv_imgbtn_set_style(buttonStop, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonStop, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonOperat, event_handler, ID_OPTION, "bmp_Operate.bin", 0);
lv_imgbtn_set_src(buttonOperat, LV_BTN_STATE_REL, &bmp_pic_150x80);
lv_imgbtn_set_src(buttonOperat, LV_BTN_STATE_PR, &bmp_pic_150x80);
lv_imgbtn_set_style(buttonOperat, LV_BTN_STATE_PR, &tft_style_lable_pre);
lv_imgbtn_set_style(buttonOperat, LV_BTN_STATE_REL, &tft_style_lable_rel);
#endif
lv_obj_set_event_cb_mks(buttonOperat, event_handler, ID_OPTION, "bmp_operate.bin", 0);
lv_imgbtn_set_src(buttonOperat, LV_BTN_STATE_REL, &bmp_pic_150x80);
lv_imgbtn_set_src(buttonOperat, LV_BTN_STATE_PR, &bmp_pic_150x80);
lv_imgbtn_set_style(buttonOperat, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonOperat, LV_BTN_STATE_REL, &tft_style_label_rel);
#endif // if 1
lv_obj_set_pos(buttonExt1, 205, 136);
if (EXTRUDERS == 2)
@@ -272,35 +272,35 @@ void lv_draw_printing(void) {
lv_btn_set_layout(buttonOperat, LV_LAYOUT_OFF);
labelExt1 = lv_label_create(scr, NULL);
lv_obj_set_style(labelExt1, &tft_style_lable_rel);
lv_obj_set_style(labelExt1, &tft_style_label_rel);
lv_obj_set_pos(labelExt1, 250, 146);
if (EXTRUDERS == 2) {
labelExt2 = lv_label_create(scr, NULL);
lv_obj_set_style(labelExt2, &tft_style_lable_rel);
lv_obj_set_style(labelExt2, &tft_style_label_rel);
lv_obj_set_pos(labelExt2, 395, 146);
}
#if HAS_HEATED_BED
labelBed = lv_label_create(scr, NULL);
lv_obj_set_style(labelBed, &tft_style_lable_rel);
lv_obj_set_style(labelBed, &tft_style_label_rel);
lv_obj_set_pos(labelBed, 250, 196);
#endif
labelFan = lv_label_create(scr, NULL);
lv_obj_set_style(labelFan, &tft_style_lable_rel);
lv_obj_set_style(labelFan, &tft_style_label_rel);
lv_obj_set_pos(labelFan, 395, 196);
labelZpos = lv_label_create(scr, NULL);
lv_obj_set_style(labelZpos, &tft_style_lable_rel);
lv_obj_set_style(labelZpos, &tft_style_label_rel);
lv_obj_set_pos(labelZpos, 395, 96);
labelTime = lv_label_create(scr, NULL);
lv_obj_set_style(labelTime, &tft_style_lable_rel);
lv_obj_set_style(labelTime, &tft_style_label_rel);
lv_obj_set_pos(labelTime, 250, 96);
labelPause = lv_label_create(buttonPause, NULL);
labelStop = lv_label_create(buttonStop, NULL);
labelPause = lv_label_create(buttonPause, NULL);
labelStop = lv_label_create(buttonStop, NULL);
labelOperat = lv_label_create(buttonOperat, NULL);
if (gCfgItems.multiple_language != 0) {
@@ -318,11 +318,11 @@ void lv_draw_printing(void) {
}
lv_style_copy(&lv_bar_style_indic, &lv_style_pretty_color);
lv_bar_style_indic.text.color = lv_color_hex3(0xADF);
lv_bar_style_indic.image.color = lv_color_hex3(0xADF);
lv_bar_style_indic.line.color = lv_color_hex3(0xADF);
lv_bar_style_indic.body.main_color = lv_color_hex3(0xADF);
lv_bar_style_indic.body.grad_color = lv_color_hex3(0xADF);
lv_bar_style_indic.text.color = lv_color_hex3(0xADF);
lv_bar_style_indic.image.color = lv_color_hex3(0xADF);
lv_bar_style_indic.line.color = lv_color_hex3(0xADF);
lv_bar_style_indic.body.main_color = lv_color_hex3(0xADF);
lv_bar_style_indic.body.grad_color = lv_color_hex3(0xADF);
lv_bar_style_indic.body.border.color = lv_color_hex3(0xADF);
bar1 = lv_bar_create(scr, NULL);
@@ -340,12 +340,12 @@ void lv_draw_printing(void) {
}
void disp_ext_temp() {
memset(public_buf_l, 0, sizeof(public_buf_l));
ZERO(public_buf_l);
sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.temp_hotend[0].celsius, (int)thermalManager.temp_hotend[0].target);
lv_label_set_text(labelExt1, public_buf_l);
if (EXTRUDERS == 2) {
memset(public_buf_l, 0, sizeof(public_buf_l));
ZERO(public_buf_l);
sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.temp_hotend[1].celsius, (int)thermalManager.temp_hotend[1].target);
lv_label_set_text(labelExt2, public_buf_l);
}
@@ -353,42 +353,42 @@ void disp_ext_temp() {
void disp_bed_temp() {
#if HAS_HEATED_BED
memset(public_buf_l, 0, sizeof(public_buf_l));
ZERO(public_buf_l);
sprintf(public_buf_l, printing_menu.bed_temp, (int)thermalManager.temp_bed.celsius, (int)thermalManager.temp_bed.target);
lv_label_set_text(labelBed, public_buf_l);
#endif
}
void disp_fan_speed() {
memset(public_buf_l, 0, sizeof(public_buf_l));
sprintf(public_buf_l, "%3d", thermalManager.fan_speed[0]);
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%3d"), thermalManager.fan_speed[0]);
lv_label_set_text(labelFan, public_buf_l);
}
void disp_print_time() {
memset(public_buf_l, 0, sizeof(public_buf_l));
ZERO(public_buf_l);
#if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME)
const uint32_t r = ui.get_remaining_time();
sprintf(public_buf_l, "%02d:%02d R", r / 3600, (r % 3600) / 60);
sprintf_P(public_buf_l, PSTR("%02d:%02d R"), r / 3600, (r % 3600) / 60);
#else
sprintf(public_buf_l, "%d%d:%d%d:%d%d", print_time.hours / 10, print_time.hours % 10, print_time.minutes / 10, print_time.minutes % 10, print_time.seconds / 10, print_time.seconds % 10);
sprintf_P(public_buf_l, PSTR("%d%d:%d%d:%d%d"), print_time.hours / 10, print_time.hours % 10, print_time.minutes / 10, print_time.minutes % 10, print_time.seconds / 10, print_time.seconds % 10);
#endif
lv_label_set_text(labelTime, public_buf_l);
}
void disp_fan_Zpos() {
memset(public_buf_l, 0, sizeof(public_buf_l));
sprintf(public_buf_l, "%.3f", current_position[Z_AXIS]);
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%.3f"), current_position[Z_AXIS]);
lv_label_set_text(labelZpos, public_buf_l);
}
void reset_print_time() {
//print_time.days = 0;
print_time.hours = 0;
// print_time.days = 0;
print_time.hours = 0;
print_time.minutes = 0;
print_time.seconds = 0;
print_time.ms_10 = 0;
//print_time.start = 1;
print_time.ms_10 = 0;
// print_time.start = 1;
}
void start_print_time() { print_time.start = 1; }
@@ -411,7 +411,7 @@ void setProBarRate() {
#endif
rate = (rate_tmp_r - (PREVIEW_SIZE + To_pre_view)) * 100 / (gCfgItems.curFilesize - (PREVIEW_SIZE + To_pre_view));
}
//gCurFileState.totalSend = rate;
// gCurFileState.totalSend = rate;
if (rate <= 0) return;
@@ -440,4 +440,4 @@ void setProBarRate() {
void lv_clear_printing() { lv_obj_del(scr); }
#endif // TFT_LVGL_UI
#endif // HAS_TFT_LVGL_UI