1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
|
/**
* 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/>.
*
*/
#include "../../../../inc/MarlinConfigPre.h"
#if HAS_TFT_LVGL_UI
#include "draw_ready_print.h"
#include "draw_tool.h"
#include <lv_conf.h>
#include "tft_lvgl_configuration.h"
#include "mks_hardware_test.h"
#include "draw_ui.h"
#include <lvgl.h>
#include "../../../../module/temperature.h"
#include "../../../../inc/MarlinConfig.h"
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
#include "../../../tft_io/touch_calibration.h"
#include "draw_touch_calibration.h"
#endif
#include <stdio.h>
extern lv_group_t* g;
static lv_obj_t *scr;
#if ENABLED(MKS_TEST)
uint8_t curent_disp_ui = 0;
#endif
enum {
ID_TOOL = 1,
ID_SET,
ID_PRINT
};
static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
lv_clear_ready_print();
switch (obj->mks_obj_id) {
case ID_TOOL:
lv_draw_tool();
break;
case ID_SET:
lv_draw_set();
break;
case ID_PRINT:
lv_draw_print_file();
break;
}
}
lv_obj_t *limit_info, *det_info;
lv_obj_t *tmc_state_info;
lv_style_t limit_style, det_style, tmc_state_style;
void disp_Limit_ok() {
limit_style.text.color.full = 0xFFFF;
lv_obj_set_style(limit_info, &limit_style);
lv_label_set_text(limit_info, "Limit:ok");
}
void disp_Limit_error() {
limit_style.text.color.full = 0xF800;
lv_obj_set_style(limit_info, &limit_style);
lv_label_set_text(limit_info, "Limit:error");
}
void disp_det_ok() {
det_style.text.color.full = 0xFFFF;
lv_obj_set_style(det_info, &det_style);
lv_label_set_text(det_info, "det:ok");
}
void disp_det_error() {
det_style.text.color.full = 0xF800;
lv_obj_set_style(det_info, &det_style);
lv_label_set_text(det_info, "det:error");
}
void disp_tmc_ok() {
tmc_state_style.text.color.full = 0xFFFF;
lv_obj_set_style(tmc_state_info, &tmc_state_style);
lv_label_set_text(tmc_state_info, "TMC CONNECTION OK");
}
void disp_tmc_error() {
tmc_state_style.text.color.full = 0xF800;
lv_obj_set_style(tmc_state_info, &tmc_state_style);
lv_label_set_text(tmc_state_info, "TMC CONNECTION ERROR");
}
lv_obj_t *e1, *e2, *e3, *bed;
void mks_disp_test() {
char buf[30] = {0};
sprintf_P(buf, PSTR("e1:%d"), (int)thermalManager.temp_hotend[0].celsius);
lv_label_set_text(e1, buf);
#if HAS_MULTI_HOTEND
sprintf_P(buf, PSTR("e2:%d"), (int)thermalManager.temp_hotend[1].celsius);
lv_label_set_text(e2, buf);
#endif
#if HAS_HEATED_BED
sprintf_P(buf, PSTR("bed:%d"), (int)thermalManager.temp_bed.celsius);
lv_label_set_text(bed, buf);
#endif
}
void lv_draw_ready_print(void) {
char buf[30] = {0};
lv_obj_t *buttonTool;
disp_state_stack._disp_index = 0;
ZERO(disp_state_stack._disp_state);
scr = lv_screen_create(PRINT_READY_UI, "");
if (mks_test_flag == 0x1E) {
// Create image buttons
buttonTool = lv_imgbtn_create(scr, "F:/bmp_tool.bin", event_handler, ID_TOOL);
lv_obj_set_pos(buttonTool, 360, 180);
lv_obj_t *label_tool = lv_label_create_empty(buttonTool);
if (gCfgItems.multiple_language) {
lv_label_set_text(label_tool, main_menu.tool);
lv_obj_align(label_tool, buttonTool, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
}
#if 1
e1 = lv_label_create_empty(scr);
lv_obj_set_pos(e1, 20, 20);
sprintf_P(buf, PSTR("e1: %d"), (int)thermalManager.temp_hotend[0].celsius);
lv_label_set_text(e1, buf);
#if HAS_MULTI_HOTEND
e2 = lv_label_create_empty(scr);
lv_obj_set_pos(e2, 20, 45);
sprintf_P(buf, PSTR("e1: %d"), (int)thermalManager.temp_hotend[1].celsius);
lv_label_set_text(e2, buf);
#endif
#if HAS_HEATED_BED
bed = lv_label_create_empty(scr);
lv_obj_set_pos(bed, 20, 95);
sprintf_P(buf, PSTR("bed: %d"), (int)thermalManager.temp_bed.celsius);
lv_label_set_text(bed, buf);
#endif
limit_info = lv_label_create_empty(scr);
lv_style_copy(&limit_style, &lv_style_scr);
limit_style.body.main_color.full = 0X0000;
limit_style.body.grad_color.full = 0X0000;
limit_style.text.color.full = 0Xffff;
lv_obj_set_style(limit_info, &limit_style);
lv_obj_set_pos(limit_info, 20, 120);
lv_label_set_text(limit_info, " ");
det_info = lv_label_create_empty(scr);
lv_style_copy(&det_style, &lv_style_scr);
det_style.body.main_color.full = 0X0000;
det_style.body.grad_color.full = 0X0000;
det_style.text.color.full = 0Xffff;
lv_obj_set_style(det_info, &det_style);
lv_obj_set_pos(det_info, 20, 145);
lv_label_set_text(det_info, " ");
tmc_state_info = lv_label_create_empty(scr);
lv_style_copy(&tmc_state_style, &lv_style_scr);
tmc_state_style.body.main_color.full = 0X0000;
tmc_state_style.body.grad_color.full = 0X0000;
tmc_state_style.text.color.full = 0Xffff;
lv_obj_set_style(tmc_state_info, &tmc_state_style);
lv_obj_set_pos(tmc_state_info, 20, 170);
lv_label_set_text(tmc_state_info, " ");
#endif // if 1
}
else {
lv_big_button_create(scr, "F:/bmp_tool.bin", main_menu.tool, 20, 90, event_handler, ID_TOOL);
lv_big_button_create(scr, "F:/bmp_set.bin", main_menu.set, 180, 90, event_handler, ID_SET);
lv_big_button_create(scr, "F:/bmp_printing.bin", main_menu.print, 340, 90, event_handler, ID_PRINT);
}
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
// If calibration is required, let's trigger it now, handles the case when there is default value in configuration files
if (!touch_calibration.calibration_loaded()) {
lv_clear_ready_print();
lv_draw_touch_calibration_screen();
}
#endif
}
void lv_clear_ready_print() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI
|