Преглед изворни кода

Fix, clean up FTDI EVE Touch UI (#20466)

Co-Authored-By: Marcio T. <mlt4356-github@yahoo.com>
Scott Lahteine пре 4 година
родитељ
комит
20073246bb

+ 66
- 91
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/change_filament_screen.cpp Прегледај датотеку

31
 using namespace FTDI;
31
 using namespace FTDI;
32
 using namespace Theme;
32
 using namespace Theme;
33
 
33
 
34
+#ifdef TOUCH_UI_PORTRAIT
35
+  #define GRID_COLS 2
36
+  #define GRID_ROWS 11
37
+  #define E_TEMP_POS           BTN_POS(2,7),  BTN_SIZE(1,1)
38
+  #define E_TEMP_LBL_POS       BTN_POS(1,7),  BTN_SIZE(1,1)
39
+  #define UNLD_LABL_POS        BTN_POS(1,8),  BTN_SIZE(1,1)
40
+  #define LOAD_LABL_POS        BTN_POS(2,8),  BTN_SIZE(1,1)
41
+  #define UNLD_MOMN_POS        BTN_POS(1,9),  BTN_SIZE(1,1)
42
+  #define LOAD_MOMN_POS        BTN_POS(2,9),  BTN_SIZE(1,1)
43
+  #define UNLD_CONT_POS        BTN_POS(1,10), BTN_SIZE(1,1)
44
+  #define LOAD_CONT_POS        BTN_POS(2,10), BTN_SIZE(1,1)
45
+  #define BACK_POS             BTN_POS(1,11), BTN_SIZE(2,1)
46
+#else
47
+  #define GRID_COLS 4
48
+  #define GRID_ROWS 6
49
+  #define E_TEMP_POS           BTN_POS(3,2),  BTN_SIZE(2,1)
50
+  #define E_TEMP_LBL_POS       BTN_POS(3,1),  BTN_SIZE(2,1)
51
+  #define UNLD_LABL_POS        BTN_POS(3,3),  BTN_SIZE(1,1)
52
+  #define LOAD_LABL_POS        BTN_POS(4,3),  BTN_SIZE(1,1)
53
+  #define UNLD_MOMN_POS        BTN_POS(3,4),  BTN_SIZE(1,1)
54
+  #define LOAD_MOMN_POS        BTN_POS(4,4),  BTN_SIZE(1,1)
55
+  #define UNLD_CONT_POS        BTN_POS(3,5),  BTN_SIZE(1,1)
56
+  #define LOAD_CONT_POS        BTN_POS(4,5),  BTN_SIZE(1,1)
57
+  #define BACK_POS             BTN_POS(3,6),  BTN_SIZE(2,1)
58
+#endif
59
+#define REMOVAL_TEMP_LBL_POS   BTN_POS(1,3),  BTN_SIZE(2,1)
60
+#define GRADIENT_POS           BTN_POS(1,4),  BTN_SIZE(1,3)
61
+#define LOW_TEMP_POS           BTN_POS(2,6),  BTN_SIZE(1,1)
62
+#define MED_TEMP_POS           BTN_POS(2,5),  BTN_SIZE(1,1)
63
+#define HIG_TEMP_POS           BTN_POS(2,4),  BTN_SIZE(1,1)
64
+#define HEATING_LBL_POS        BTN_POS(1,6),  BTN_SIZE(1,1)
65
+#define CAUTION_LBL_POS        BTN_POS(1,4),  BTN_SIZE(1,1)
66
+#define HOT_LBL_POS            BTN_POS(1,6),  BTN_SIZE(1,1)
67
+#define E_SEL_LBL_POS          BTN_POS(1,1),  BTN_SIZE(2,1)
68
+#define E1_SEL_POS             BTN_POS(1,2),  BTN_SIZE(1,1)
69
+#define E2_SEL_POS             BTN_POS(2,2),  BTN_SIZE(1,1)
70
+
34
 #define COOL_TEMP  40
71
 #define COOL_TEMP  40
35
 #define LOW_TEMP  180
72
 #define LOW_TEMP  180
36
 #define MED_TEMP  200
73
 #define MED_TEMP  200
101
 void ChangeFilamentScreen::onRedraw(draw_mode_t what) {
138
 void ChangeFilamentScreen::onRedraw(draw_mode_t what) {
102
   CommandProcessor cmd;
139
   CommandProcessor cmd;
103
 
140
 
104
-  #if ENABLED(TOUCH_UI_PORTRAIT)
105
-    #define GRID_COLS 2
106
-    #define GRID_ROWS 11
107
-  #else
108
-    #define GRID_COLS 4
109
-    #define GRID_ROWS 6
110
-  #endif
111
-
112
   if (what & BACKGROUND) {
141
   if (what & BACKGROUND) {
113
     cmd.cmd(CLEAR_COLOR_RGB(bg_color))
142
     cmd.cmd(CLEAR_COLOR_RGB(bg_color))
114
        .cmd(CLEAR(true,true,true))
143
        .cmd(CLEAR(true,true,true))
115
        .cmd(COLOR_RGB(bg_text_enabled))
144
        .cmd(COLOR_RGB(bg_text_enabled))
116
        .tag(0)
145
        .tag(0)
117
-    #if ENABLED(TOUCH_UI_PORTRAIT)
118
-       .font(font_large)
119
-    #else
120
-       .font(font_medium)
121
-    #endif
122
-       .text(BTN_POS(1,1), BTN_SIZE(2,1), GET_TEXT_F(MSG_EXTRUDER_SELECTION))
123
-    #if ENABLED(TOUCH_UI_PORTRAIT)
124
-       .text(BTN_POS(1,7), BTN_SIZE(1,1), GET_TEXT_F(MSG_CURRENT_TEMPERATURE))
125
-    #else
126
-       .text(BTN_POS(3,1), BTN_SIZE(2,1), GET_TEXT_F(MSG_CURRENT_TEMPERATURE))
127
-       .font(font_small)
128
-    #endif
129
-       .text(BTN_POS(1,3), BTN_SIZE(2,1), GET_TEXT_F(MSG_REMOVAL_TEMPERATURE));
130
-    drawTempGradient(BTN_POS(1,4), BTN_SIZE(1,3));
146
+       .font(TERN(TOUCH_UI_PORTRAIT, font_large, font_medium))
147
+       .text(E_SEL_LBL_POS, GET_TEXT_F(MSG_EXTRUDER_SELECTION))
148
+       .text(E_TEMP_LBL_POS, GET_TEXT_F(MSG_CURRENT_TEMPERATURE))
149
+       .text(REMOVAL_TEMP_LBL_POS, GET_TEXT_F(MSG_REMOVAL_TEMPERATURE));
150
+    drawTempGradient(GRADIENT_POS);
131
   }
151
   }
132
 
152
 
133
   if (what & FOREGROUND) {
153
   if (what & FOREGROUND) {
154
+    char str[15];
134
     const extruder_t e = getExtruder();
155
     const extruder_t e = getExtruder();
135
 
156
 
136
-    char e_str[15];
137
     if (isHeaterIdle(e))
157
     if (isHeaterIdle(e))
138
-      format_temp_and_idle(e_str, getActualTemp_celsius(e));
158
+      format_temp_and_idle(str, getActualTemp_celsius(e));
139
     else
159
     else
140
-      format_temp_and_temp(e_str, getActualTemp_celsius(e), getTargetTemp_celsius(e));
160
+      format_temp_and_temp(str, getActualTemp_celsius(e), getTargetTemp_celsius(e));
141
 
161
 
142
     const rgb_t tcol = getWarmColor(getActualTemp_celsius(e), COOL_TEMP, LOW_TEMP, MED_TEMP, HIGH_TEMP);
162
     const rgb_t tcol = getWarmColor(getActualTemp_celsius(e), COOL_TEMP, LOW_TEMP, MED_TEMP, HIGH_TEMP);
143
     cmd.cmd(COLOR_RGB(tcol))
163
     cmd.cmd(COLOR_RGB(tcol))
144
        .tag(15)
164
        .tag(15)
145
-    #if ENABLED(TOUCH_UI_PORTRAIT)
146
-       .rectangle(BTN_POS(2,7), BTN_SIZE(1,1))
147
-    #else
148
-       .rectangle(BTN_POS(3,2), BTN_SIZE(2,1))
149
-    #endif
165
+       .rectangle(E_TEMP_POS)
150
        .cmd(COLOR_RGB(tcol.luminance() > 128 ? 0x000000 : 0xFFFFFF))
166
        .cmd(COLOR_RGB(tcol.luminance() > 128 ? 0x000000 : 0xFFFFFF))
151
        .font(font_medium)
167
        .font(font_medium)
152
-    #if ENABLED(TOUCH_UI_PORTRAIT)
153
-       .text(BTN_POS(2,7), BTN_SIZE(1,1), e_str)
154
-    #else
155
-       .text(BTN_POS(3,2), BTN_SIZE(2,1), e_str)
156
-    #endif
168
+       .text(E_TEMP_POS, str)
157
        .colors(normal_btn);
169
        .colors(normal_btn);
158
 
170
 
159
     const bool t_ok = getActualTemp_celsius(e) > getSoftenTemp() - 10;
171
     const bool t_ok = getActualTemp_celsius(e) > getSoftenTemp() - 10;
160
 
172
 
161
     if (screen_data.ChangeFilamentScreen.t_tag && !t_ok) {
173
     if (screen_data.ChangeFilamentScreen.t_tag && !t_ok) {
162
-      cmd.text(BTN_POS(1,6), BTN_SIZE(1,1), GET_TEXT_F(MSG_HEATING));
174
+      cmd.text(HEATING_LBL_POS, GET_TEXT_F(MSG_HEATING));
163
     } else if (getActualTemp_celsius(e) > 100) {
175
     } else if (getActualTemp_celsius(e) > 100) {
164
       cmd.cmd(COLOR_RGB(0xFF0000))
176
       cmd.cmd(COLOR_RGB(0xFF0000))
165
-         .text(BTN_POS(1,4), BTN_SIZE(1,1), GET_TEXT_F(MSG_CAUTION))
177
+         .text(CAUTION_LBL_POS, GET_TEXT_F(MSG_CAUTION))
166
          .colors(normal_btn)
178
          .colors(normal_btn)
167
-         .text(BTN_POS(1,6), BTN_SIZE(1,1), GET_TEXT_F(MSG_HOT));
179
+         .text(HOT_LBL_POS, GET_TEXT_F(MSG_HOT));
168
     }
180
     }
169
 
181
 
170
     #define TOG_STYLE(A) colors(A ? action_btn : normal_btn)
182
     #define TOG_STYLE(A) colors(A ? action_btn : normal_btn)
177
       const bool tog11 = screen_data.ChangeFilamentScreen.e_tag == 11;
189
       const bool tog11 = screen_data.ChangeFilamentScreen.e_tag == 11;
178
     #endif
190
     #endif
179
 
191
 
180
-    #if ENABLED(TOUCH_UI_PORTRAIT)
181
-      cmd.font(font_large)
182
-    #else
183
-      cmd.font(font_medium)
184
-    #endif
185
-       .TOG_STYLE(tog10)
186
-       .tag(10)          .button (BTN_POS(1,2), BTN_SIZE(1,1), F("1"))
192
+    cmd.TOG_STYLE(tog10)
193
+       .tag(10).button (E1_SEL_POS, F("1"))
187
     #if HOTENDS < 2
194
     #if HOTENDS < 2
188
        .enabled(false)
195
        .enabled(false)
189
     #else
196
     #else
190
        .TOG_STYLE(tog11)
197
        .TOG_STYLE(tog11)
191
     #endif
198
     #endif
192
-       .tag(11)          .button (BTN_POS(2,2), BTN_SIZE(1,1), F("2"));
199
+       .tag(11).button (E2_SEL_POS, F("2"));
193
 
200
 
194
     if (!t_ok) reset_menu_timeout();
201
     if (!t_ok) reset_menu_timeout();
195
 
202
 
196
     const bool tog7 = screen_data.ChangeFilamentScreen.repeat_tag == 7;
203
     const bool tog7 = screen_data.ChangeFilamentScreen.repeat_tag == 7;
197
     const bool tog8 = screen_data.ChangeFilamentScreen.repeat_tag == 8;
204
     const bool tog8 = screen_data.ChangeFilamentScreen.repeat_tag == 8;
198
 
205
 
199
-
200
-    cmd.font(
201
-      #if ENABLED(TOUCH_UI_PORTRAIT)
202
-        font_large
203
-      #else
204
-        font_small
205
-      #endif
206
-    );
207
-
208
     {
206
     {
209
       char str[30];
207
       char str[30];
210
-
211
       format_temp(str, LOW_TEMP);
208
       format_temp(str, LOW_TEMP);
212
-      cmd.tag(2) .TOG_STYLE(tog2) .button (BTN_POS(2,6), BTN_SIZE(1,1), str);
209
+      cmd.tag(2) .TOG_STYLE(tog2).button (LOW_TEMP_POS, str);
213
 
210
 
214
       format_temp(str, MED_TEMP);
211
       format_temp(str, MED_TEMP);
215
-      cmd.tag(3) .TOG_STYLE(tog3) .button (BTN_POS(2,5), BTN_SIZE(1,1), str);
212
+      cmd.tag(3) .TOG_STYLE(tog3).button (MED_TEMP_POS, str);
216
 
213
 
217
       format_temp(str, HIGH_TEMP);
214
       format_temp(str, HIGH_TEMP);
218
-      cmd.tag(4) .TOG_STYLE(tog4) .button (BTN_POS(2,4), BTN_SIZE(1,1), str);
215
+      cmd.tag(4) .TOG_STYLE(tog4).button (HIG_TEMP_POS, str);
219
     }
216
     }
220
-    cmd.colors(normal_btn)
221
-
222
-    // Add tags to color gradient
223
-    .cmd(COLOR_MASK(0,0,0,0))
224
-    .tag(2) .rectangle(BTN_POS(1,6), BTN_SIZE(1,1))
225
-    .tag(3) .rectangle(BTN_POS(1,5), BTN_SIZE(1,1))
226
-    .tag(4) .rectangle(BTN_POS(1,4), BTN_SIZE(1,1))
227
-    .cmd(COLOR_MASK(1,1,1,1))
228
-
229
-    .cmd(COLOR_RGB(t_ok ? bg_text_enabled : bg_text_disabled))
230
-    #if ENABLED(TOUCH_UI_PORTRAIT)
231
-       .font(font_large)
232
-       .tag(0)                              .text   (BTN_POS(1,8),  BTN_SIZE(1,1), GET_TEXT_F(MSG_UNLOAD_FILAMENT))
233
-                                            .text   (BTN_POS(2,8),  BTN_SIZE(1,1), GET_TEXT_F(MSG_LOAD_FILAMENT))
234
-       .tag(5)                .enabled(t_ok).button (BTN_POS(1,9),  BTN_SIZE(1,1), GET_TEXT_F(MSG_MOMENTARY))
235
-       .tag(6)                .enabled(t_ok).button (BTN_POS(2,9),  BTN_SIZE(1,1), GET_TEXT_F(MSG_MOMENTARY))
236
-       .tag(7).TOG_STYLE(tog7).enabled(t_ok).button (BTN_POS(1,10), BTN_SIZE(1,1), GET_TEXT_F(MSG_CONTINUOUS))
237
-       .tag(8).TOG_STYLE(tog8).enabled(t_ok).button (BTN_POS(2,10), BTN_SIZE(1,1), GET_TEXT_F(MSG_CONTINUOUS))
238
-       .tag(1).colors(action_btn)           .button (BTN_POS(1,11), BTN_SIZE(2,1), GET_TEXT_F(MSG_BACK));
239
-    #else
240
-       .font(font_small)
241
-       .tag(0)                              .text   (BTN_POS(3,3),  BTN_SIZE(1,1), GET_TEXT_F(MSG_UNLOAD_FILAMENT))
242
-                                            .text   (BTN_POS(4,3),  BTN_SIZE(1,1), GET_TEXT_F(MSG_LOAD_FILAMENT))
243
-       .tag(5)                .enabled(t_ok).button (BTN_POS(3,4),  BTN_SIZE(1,1), GET_TEXT_F(MSG_MOMENTARY))
244
-       .tag(6)                .enabled(t_ok).button (BTN_POS(4,4),  BTN_SIZE(1,1), GET_TEXT_F(MSG_MOMENTARY))
245
-       .tag(7).TOG_STYLE(tog7).enabled(t_ok).button (BTN_POS(3,5),  BTN_SIZE(1,1), GET_TEXT_F(MSG_CONTINUOUS))
246
-       .tag(8).TOG_STYLE(tog8).enabled(t_ok).button (BTN_POS(4,5),  BTN_SIZE(1,1), GET_TEXT_F(MSG_CONTINUOUS))
247
-       .font(font_medium)
248
-       .tag(1).colors(action_btn)           .button (BTN_POS(3,6),  BTN_SIZE(2,1), GET_TEXT_F(MSG_BACK));
249
-    #endif
217
+
218
+    cmd.cmd(COLOR_RGB(t_ok ? bg_text_enabled : bg_text_disabled))
219
+       .tag(0)                              .text   (UNLD_LABL_POS, GET_TEXT_F(MSG_UNLOAD_FILAMENT))
220
+                                            .text   (LOAD_LABL_POS, GET_TEXT_F(MSG_LOAD_FILAMENT))
221
+       .colors(normal_btn)
222
+       .tag(5)                .enabled(t_ok).button (UNLD_MOMN_POS, GET_TEXT_F(MSG_MOMENTARY))
223
+       .tag(6)                .enabled(t_ok).button (LOAD_MOMN_POS, GET_TEXT_F(MSG_MOMENTARY))
224
+       .tag(7).TOG_STYLE(tog7).enabled(t_ok).button (UNLD_CONT_POS, GET_TEXT_F(MSG_CONTINUOUS))
225
+       .tag(8).TOG_STYLE(tog8).enabled(t_ok).button (LOAD_CONT_POS, GET_TEXT_F(MSG_CONTINUOUS))
226
+       .tag(1).colors(action_btn)           .button (BACK_POS, GET_TEXT_F(MSG_BACK));
250
   }
227
   }
251
-  #undef GRID_COLS
252
-  #undef GRID_ROWS
253
 }
228
 }
254
 
229
 
255
 uint8_t ChangeFilamentScreen::getSoftenTemp() {
230
 uint8_t ChangeFilamentScreen::getSoftenTemp() {

+ 8
- 2
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/status_screen.cpp Прегледај датотеку

352
 }
352
 }
353
 
353
 
354
 void StatusScreen::setStatusMessage(const char* message) {
354
 void StatusScreen::setStatusMessage(const char* message) {
355
+  if (CommandProcessor::is_processing()) {
356
+    #if ENABLED(TOUCH_UI_DEBUG)
357
+      SERIAL_ECHO_MSG("Cannot update status message, command processor busy");
358
+    #endif
359
+    return;
360
+  }
361
+
355
   CommandProcessor cmd;
362
   CommandProcessor cmd;
356
   cmd.cmd(CMD_DLSTART)
363
   cmd.cmd(CMD_DLSTART)
357
      .cmd(CLEAR_COLOR_RGB(Theme::bg_color))
364
      .cmd(CLEAR_COLOR_RGB(Theme::bg_color))
366
   storeBackground();
373
   storeBackground();
367
 
374
 
368
   #if ENABLED(TOUCH_UI_DEBUG)
375
   #if ENABLED(TOUCH_UI_DEBUG)
369
-    SERIAL_ECHO_START();
370
-    SERIAL_ECHOLNPAIR("New status message: ", message);
376
+    SERIAL_ECHO_MSG("New status message: ", message);
371
   #endif
377
   #endif
372
 
378
 
373
   if (AT_SCREEN(StatusScreen)) {
379
   if (AT_SCREEN(StatusScreen)) {

+ 3
- 0
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/touch_calibration_screen.cpp Прегледај датотеку

85
 void TouchCalibrationScreen::onIdle() {
85
 void TouchCalibrationScreen::onIdle() {
86
   if (!CLCD::is_touching() && !CommandProcessor::is_processing()) {
86
   if (!CLCD::is_touching() && !CommandProcessor::is_processing()) {
87
     GOTO_PREVIOUS();
87
     GOTO_PREVIOUS();
88
+    #if ENABLED(TOUCH_UI_DEBUG)
89
+      SERIAL_ECHO_MSG("Calibration routine finished");
90
+    #endif
88
   }
91
   }
89
 }
92
 }
90
 
93
 

Loading…
Откажи
Сачувај