Browse Source

Touch UI Bed Mesh Screen refactor, enhancements (#21521)

- Split mesh view and edit screen into two screens
- The editor now live-updates the graphics
- Added Touch UI mesh progress feedback to `G26`
- Show positive / negative mesh values in different colors
Marcio T 3 years ago
parent
commit
75b790376d
No account linked to committer's email address

+ 4
- 4
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp View File

@@ -730,7 +730,7 @@ void unified_bed_leveling::shift_mesh_height() {
730 730
     uint8_t count = GRID_MAX_POINTS;
731 731
 
732 732
     mesh_index_pair best;
733
-    TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(best.pos, ExtUI::MESH_START));
733
+    TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(best.pos, ExtUI::G29_START));
734 734
     do {
735 735
       if (do_ubl_mesh_map) display_map(param.T_map_type);
736 736
 
@@ -755,14 +755,14 @@ void unified_bed_leveling::shift_mesh_height() {
755 755
         : find_closest_mesh_point_of_type(INVALID, nearby, true);
756 756
 
757 757
       if (best.pos.x >= 0) {    // mesh point found and is reachable by probe
758
-        TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(best.pos, ExtUI::PROBE_START));
758
+        TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(best.pos, ExtUI::G29_POINT_START));
759 759
         const float measured_z = probe.probe_at_point(
760 760
                       best.meshpos(),
761 761
                       stow_probe ? PROBE_PT_STOW : PROBE_PT_RAISE, param.V_verbosity
762 762
                     );
763 763
         z_values[best.pos.x][best.pos.y] = measured_z;
764 764
         #if ENABLED(EXTENSIBLE_UI)
765
-          ExtUI::onMeshUpdate(best.pos, ExtUI::PROBE_FINISH);
765
+          ExtUI::onMeshUpdate(best.pos, ExtUI::G29_POINT_FINISH);
766 766
           ExtUI::onMeshUpdate(best.pos, measured_z);
767 767
         #endif
768 768
       }
@@ -770,7 +770,7 @@ void unified_bed_leveling::shift_mesh_height() {
770 770
 
771 771
     } while (best.pos.x >= 0 && --count);
772 772
 
773
-    TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(best.pos, ExtUI::MESH_FINISH));
773
+    TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(best.pos, ExtUI::G29_FINISH));
774 774
 
775 775
     // Release UI during stow to allow for PAUSE_BEFORE_DEPLOY_STOW
776 776
     TERN_(HAS_LCD_MENU, ui.release());

+ 9
- 0
Marlin/src/gcode/bedlevel/G26.cpp View File

@@ -113,6 +113,10 @@
113 113
 #include "../../module/temperature.h"
114 114
 #include "../../lcd/marlinui.h"
115 115
 
116
+#if ENABLED(EXTENSIBLE_UI)
117
+  #include "../../lcd/extui/ui_api.h"
118
+#endif
119
+
116 120
 #if ENABLED(UBL_HILBERT_CURVE)
117 121
   #include "../../feature/bedlevel/hilbert_curve.h"
118 122
 #endif
@@ -725,11 +729,13 @@ void GcodeSuite::G26() {
725 729
   #endif // !ARC_SUPPORT
726 730
 
727 731
   mesh_index_pair location;
732
+  TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(location.pos, ExtUI::G26_START));
728 733
   do {
729 734
     // Find the nearest confluence
730 735
     location = g26.find_closest_circle_to_print(g26.continue_with_closest ? xy_pos_t(current_position) : g26.xy_pos);
731 736
 
732 737
     if (location.valid()) {
738
+      TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(location.pos, ExtUI::G26_POINT_START));
733 739
       const xy_pos_t circle = _GET_MESH_POS(location.pos);
734 740
 
735 741
       // If this mesh location is outside the printable radius, skip it.
@@ -845,6 +851,8 @@ void GcodeSuite::G26() {
845 851
       g26.connect_neighbor_with_line(location.pos,  1,  0);
846 852
       g26.connect_neighbor_with_line(location.pos,  0, -1);
847 853
       g26.connect_neighbor_with_line(location.pos,  0,  1);
854
+      planner.synchronize();
855
+      TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(location.pos, ExtUI::G26_POINT_FINISH));
848 856
       if (TERN0(HAS_LCD_MENU, user_canceled())) goto LEAVE;
849 857
     }
850 858
 
@@ -854,6 +862,7 @@ void GcodeSuite::G26() {
854 862
 
855 863
   LEAVE:
856 864
   ui.set_status_P(GET_TEXT(MSG_G26_LEAVING), -1);
865
+  TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(location, ExtUI::G26_FINISH));
857 866
 
858 867
   g26.retract_filament(destination);
859 868
   destination.z = Z_CLEARANCE_BETWEEN_PROBES;

+ 2
- 2
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/marlin_events.cpp View File

@@ -141,11 +141,11 @@ namespace ExtUI {
141 141
     void onMeshLevelingStart() {}
142 142
 
143 143
     void onMeshUpdate(const int8_t x, const int8_t y, const_float_t val) {
144
-      BedMeshScreen::onMeshUpdate(x, y, val);
144
+      BedMeshViewScreen::onMeshUpdate(x, y, val);
145 145
     }
146 146
 
147 147
     void onMeshUpdate(const int8_t x, const int8_t y, const ExtUI::probe_state_t state) {
148
-      BedMeshScreen::onMeshUpdate(x, y, state);
148
+      BedMeshViewScreen::onMeshUpdate(x, y, state);
149 149
     }
150 150
   #endif
151 151
 

Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_screen.cpp → Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_base.cpp View File

@@ -1,6 +1,6 @@
1
-/***********************
2
- * bed_mesh_screen.cpp *
3
- ***********************/
1
+/*********************
2
+ * bed_mesh_base.cpp *
3
+ *********************/
4 4
 
5 5
 /****************************************************************************
6 6
  *   Written By Marcio Teixeira 2020                                        *
@@ -21,43 +21,17 @@
21 21
 
22 22
 #include "../config.h"
23 23
 #include "screens.h"
24
-#include "screen_data.h"
25 24
 
26
-#ifdef FTDI_BED_MESH_SCREEN
25
+#ifdef FTDI_BED_MESH_BASE
27 26
 
28 27
 using namespace FTDI;
29
-using namespace Theme;
30
-using namespace ExtUI;
31 28
 
32
-constexpr static BedMeshScreenData &mydata = screen_data.BedMeshScreen;
33
-constexpr static float gaugeThickness = 0.25;
34
-
35
-#if ENABLED(TOUCH_UI_PORTRAIT)
36
-  #define GRID_COLS 3
37
-  #define GRID_ROWS 10
38
-
39
-  #define MESH_POS    BTN_POS(1, 2), BTN_SIZE(3,5)
40
-  #define MESSAGE_POS BTN_POS(1, 7), BTN_SIZE(3,1)
41
-  #define Z_LABEL_POS BTN_POS(1, 8), BTN_SIZE(1,1)
42
-  #define Z_VALUE_POS BTN_POS(2, 8), BTN_SIZE(2,1)
43
-  #define OKAY_POS    BTN_POS(1,10), BTN_SIZE(3,1)
44
-#else
45
-  #define GRID_COLS 5
46
-  #define GRID_ROWS 5
47
-
48
-  #define MESH_POS    BTN_POS(1,1), BTN_SIZE(3,5)
49
-  #define MESSAGE_POS BTN_POS(4,1), BTN_SIZE(2,1)
50
-  #define Z_LABEL_POS BTN_POS(4,2), BTN_SIZE(2,1)
51
-  #define Z_VALUE_POS BTN_POS(4,3), BTN_SIZE(2,1)
52
-  #define OKAY_POS    BTN_POS(4,5), BTN_SIZE(2,1)
53
-#endif
54
-
55
-void BedMeshScreen::drawMesh(int16_t x, int16_t y, int16_t w, int16_t h, ExtUI::bed_mesh_t data, uint8_t opts, float autoscale_max) {
29
+void BedMeshBase::_drawMesh(CommandProcessor &cmd, int16_t x, int16_t y, int16_t w, int16_t h, uint8_t opts, float autoscale_max, uint8_t highlightedTag, mesh_getter_ptr func, void *data) {
56 30
   constexpr uint8_t rows = GRID_MAX_POINTS_Y;
57 31
   constexpr uint8_t cols = GRID_MAX_POINTS_X;
58 32
 
59
-  #define VALUE(X,Y)  (data ? data[X][Y] : 0)
60
-  #define ISVAL(X,Y)  (data ? !isnan(VALUE(X,Y)) : true)
33
+  #define VALUE(X,Y)  (func ? func(X,Y,data) : 0)
34
+  #define ISVAL(X,Y)  (func ? !isnan(VALUE(X,Y)) : true)
61 35
   #define HEIGHT(X,Y) (ISVAL(X,Y) ? (VALUE(X,Y) - val_min) * scale_z : 0)
62 36
 
63 37
   // Compute the mean, min and max for the points
@@ -67,7 +41,7 @@ void BedMeshScreen::drawMesh(int16_t x, int16_t y, int16_t w, int16_t h, ExtUI::
67 41
   float   val_min  =  INFINITY;
68 42
   uint8_t val_cnt  = 0;
69 43
 
70
-  if (data && (opts & USE_AUTOSCALE)) {
44
+  if (opts & USE_AUTOSCALE) {
71 45
     for (uint8_t y = 0; y < rows; y++) {
72 46
       for (uint8_t x = 0; x < cols; x++) {
73 47
         if (ISVAL(x,y)) {
@@ -140,7 +114,6 @@ void BedMeshScreen::drawMesh(int16_t x, int16_t y, int16_t w, int16_t h, ExtUI::
140 114
 
141 115
   const uint16_t basePointSize = min(w,h) / max(cols,rows);
142 116
 
143
-  CommandProcessor cmd;
144 117
   cmd.cmd(SAVE_CONTEXT())
145 118
      .cmd(TAG_MASK(false))
146 119
      .cmd(SAVE_CONTEXT());
@@ -167,10 +140,14 @@ void BedMeshScreen::drawMesh(int16_t x, int16_t y, int16_t w, int16_t h, ExtUI::
167 140
       for (uint8_t x = 0; x < cols; x++) {
168 141
         if (ISVAL(x,y)) {
169 142
           if (opts & USE_COLORS) {
170
-            const float   val_dev  = VALUE(x, y) - val_mean;
171
-            const uint8_t neg_byte = sq(val_dev) / (val_dev < 0 ? sq_min : sq_max) * 0xFF;
172
-            const uint8_t pos_byte = 255 - neg_byte;
173
-            cmd.cmd(COLOR_RGB(pos_byte, pos_byte, 0xFF));
143
+            const float val_dev = sq(VALUE(x, y) - val_mean);
144
+            uint8_t r = 0, b = 0;
145
+            //*(VALUE(x, y) < 0 ? &r : &b) = val_dev / sq_min * 0xFF;
146
+            if (VALUE(x, y) < 0)
147
+              r = val_dev / sq_min * 0xFF;
148
+            else
149
+              b = val_dev / sq_max * 0xFF;
150
+            cmd.cmd(COLOR_RGB(0xFF - b, 0xFF - b - r, 0xFF - r));
174 151
           }
175 152
           cmd.cmd(VERTEX2F(TRANSFORM(x, y, HEIGHT(x, y))));
176 153
         }
@@ -198,7 +175,7 @@ void BedMeshScreen::drawMesh(int16_t x, int16_t y, int16_t w, int16_t h, ExtUI::
198 175
   }
199 176
 
200 177
   if (opts & USE_HIGHLIGHT) {
201
-    const uint8_t tag = mydata.highlightedTag;
178
+    const uint8_t tag = highlightedTag;
202 179
     xy_uint8_t pt;
203 180
     if (tagToPoint(tag, pt)) {
204 181
       cmd.cmd(COLOR_A(128))
@@ -211,184 +188,32 @@ void BedMeshScreen::drawMesh(int16_t x, int16_t y, int16_t w, int16_t h, ExtUI::
211 188
   cmd.cmd(RESTORE_CONTEXT());
212 189
 }
213 190
 
214
-uint8_t BedMeshScreen::pointToTag(uint8_t x, uint8_t y) {
215
-  return y * (GRID_MAX_POINTS_X) + x + 10;
191
+uint8_t BedMeshBase::pointToTag(uint8_t x, uint8_t y) {
192
+  return x >= 0 && x < GRID_MAX_POINTS_X && y >= 0 && y < GRID_MAX_POINTS_Y ? y * (GRID_MAX_POINTS_X) + x + 10 : 0;
216 193
 }
217 194
 
218
-bool BedMeshScreen::tagToPoint(uint8_t tag, xy_uint8_t &pt) {
195
+bool BedMeshBase::tagToPoint(uint8_t tag, xy_uint8_t &pt) {
219 196
   if (tag < 10) return false;
220 197
   pt.x = (tag - 10) % (GRID_MAX_POINTS_X);
221 198
   pt.y = (tag - 10) / (GRID_MAX_POINTS_X);
222 199
   return true;
223 200
 }
224 201
 
225
-void BedMeshScreen::onEntry() {
226
-  mydata.allowEditing = true;
227
-  mydata.highlightedTag = 0;
228
-  mydata.zAdjustment = 0;
229
-  mydata.count = GRID_MAX_POINTS;
230
-  mydata.message = mydata.MSG_NONE;
231
-  BaseScreen::onEntry();
232
-}
233
-
234
-float BedMeshScreen::getHighlightedValue(bool nanAsZero) {
235
-  xy_uint8_t pt;
236
-  if (tagToPoint(mydata.highlightedTag, pt)) {
237
-    const float val = ExtUI::getMeshPoint(pt);
238
-    return (isnan(val) && nanAsZero) ? 0 : val;
239
-  }
240
-  return NAN;
241
-}
242
-
243
-void BedMeshScreen::setHighlightedValue(float value) {
244
-  xy_uint8_t pt;
245
-  if (tagToPoint(mydata.highlightedTag, pt))
246
-    ExtUI::setMeshPoint(pt, value);
247
-}
248
-
249
-void BedMeshScreen::moveToHighlightedValue() {
250
-  xy_uint8_t pt;
251
-  if (tagToPoint(mydata.highlightedTag, pt))
252
-    ExtUI::moveToMeshPoint(pt, gaugeThickness + mydata.zAdjustment);
253
-}
254
-
255
-void BedMeshScreen::adjustHighlightedValue(float increment) {
256
-  mydata.zAdjustment += increment;
257
-  moveToHighlightedValue();
258
-}
259
-
260
-void BedMeshScreen::saveAdjustedHighlightedValue() {
261
-  if (mydata.zAdjustment) {
262
-    BedMeshScreen::setHighlightedValue(BedMeshScreen::getHighlightedValue(true) + mydata.zAdjustment);
263
-    mydata.zAdjustment = 0;
264
-  }
265
-}
266
-
267
-void BedMeshScreen::changeHighlightedValue(uint8_t tag) {
268
-  if (mydata.allowEditing) saveAdjustedHighlightedValue();
269
-  mydata.highlightedTag = tag;
270
-  if (mydata.allowEditing) moveToHighlightedValue();
271
-}
272
-
273
-void BedMeshScreen::drawHighlightedPointValue() {
274
-  CommandProcessor cmd;
275
-  cmd.font(Theme::font_medium)
276
-     .colors(normal_btn)
277
-     .text(Z_LABEL_POS, GET_TEXT_F(MSG_MESH_EDIT_Z))
278
-     .font(font_small);
279
-
280
-  if (mydata.allowEditing)
281
-    draw_adjuster(cmd, Z_VALUE_POS, 2, getHighlightedValue(true) + mydata.zAdjustment, GET_TEXT_F(MSG_UNITS_MM), 4, 3);
282
-  else
283
-    draw_adjuster_value(cmd, Z_VALUE_POS, getHighlightedValue(true) + mydata.zAdjustment, GET_TEXT_F(MSG_UNITS_MM), 4, 3);
284
-
285
-  cmd.colors(action_btn)
286
-     .tag(1).button(OKAY_POS, GET_TEXT_F(MSG_BUTTON_OKAY))
287
-     .tag(0);
288
-
289
-  switch (mydata.message) {
290
-    case mydata.MSG_MESH_COMPLETE:   cmd.text(MESSAGE_POS, GET_TEXT_F(MSG_BED_MAPPING_DONE)); break;
291
-    case mydata.MSG_MESH_INCOMPLETE: cmd.text(MESSAGE_POS, GET_TEXT_F(MSG_BED_MAPPING_INCOMPLETE)); break;
292
-    default: break;
293
-  }
294
-}
295
-
296
-void BedMeshScreen::onRedraw(draw_mode_t what) {
297
-  #define _INSET_POS(x,y,w,h) x + min(w,h)/10, y + min(w,h)/10, w - min(w,h)/5, h - min(w,h)/5
298
-  #define INSET_POS(pos) _INSET_POS(pos)
299
-
300
-  if (what & BACKGROUND) {
301
-    CommandProcessor cmd;
302
-    cmd.cmd(CLEAR_COLOR_RGB(bg_color))
303
-       .cmd(CLEAR(true,true,true));
304
-
305
-    // Draw the shadow and tags
306
-    cmd.cmd(COLOR_RGB(Theme::bed_mesh_shadow_rgb));
307
-    BedMeshScreen::drawMesh(INSET_POS(MESH_POS), nullptr, USE_POINTS | USE_TAGS);
308
-    cmd.cmd(COLOR_RGB(bg_text_enabled));
309
-  }
310
-
311
-  if (what & FOREGROUND) {
312
-    constexpr float autoscale_max_amplitude = 0.03;
313
-    const bool gotAllPoints = mydata.count >= GRID_MAX_POINTS;
314
-    if (gotAllPoints) {
315
-      drawHighlightedPointValue();
316
-    }
317
-    CommandProcessor cmd;
318
-    cmd.cmd(COLOR_RGB(Theme::bed_mesh_lines_rgb));
319
-    const float levelingProgress = sq(float(mydata.count) / GRID_MAX_POINTS);
320
-    BedMeshScreen::drawMesh(INSET_POS(MESH_POS), ExtUI::getMeshArray(),
321
-      USE_POINTS | USE_HIGHLIGHT | USE_AUTOSCALE | (gotAllPoints ? USE_COLORS : 0),
322
-      autoscale_max_amplitude * levelingProgress
323
-    );
324
-  }
325
-}
326
-
327
-bool BedMeshScreen::onTouchEnd(uint8_t tag) {
328
-  constexpr float increment = 0.01;
329
-  switch (tag) {
330
-    case 1:
331
-      saveAdjustedHighlightedValue();
332
-      injectCommands_P(PSTR("G29 S1"));
333
-      GOTO_PREVIOUS();
334
-      return true;
335
-    case 2: adjustHighlightedValue(-increment); break;
336
-    case 3: adjustHighlightedValue( increment); break;
337
-    default:
338
-        if (tag >= 10)
339
-            changeHighlightedValue(tag);
340
-        else
341
-            return false;
342
-  }
343
-  return true;
344
-}
345
-
346
-void BedMeshScreen::onMeshUpdate(const int8_t, const int8_t, const float) {
347
-  if (AT_SCREEN(BedMeshScreen))
348
-    onRefresh();
202
+void BedMeshBase::drawMeshBackground(CommandProcessor &cmd, int16_t x, int16_t y, int16_t w, int16_t h) {
203
+  cmd.cmd(COLOR_RGB(Theme::bed_mesh_shadow_rgb));
204
+  _drawMesh(cmd, x, y, w, h, USE_POINTS | USE_TAGS, 0.1, 0, nullptr, nullptr);
349 205
 }
350 206
 
351
-void BedMeshScreen::onMeshUpdate(const int8_t x, const int8_t y, const ExtUI::probe_state_t state) {
352
-  switch (state) {
353
-    case ExtUI::MESH_START:
354
-      mydata.allowEditing = false;
355
-      mydata.count = 0;
356
-      mydata.message = mydata.MSG_NONE;
357
-      break;
358
-    case ExtUI::MESH_FINISH:
359
-      if (mydata.count == GRID_MAX_POINTS && ExtUI::getMeshValid())
360
-        mydata.message = mydata.MSG_MESH_COMPLETE;
361
-      else
362
-        mydata.message = mydata.MSG_MESH_INCOMPLETE;
363
-      mydata.count = GRID_MAX_POINTS;
364
-      break;
365
-    case ExtUI::PROBE_START:
366
-      mydata.highlightedTag = pointToTag(x, y);
367
-      break;
368
-    case ExtUI::PROBE_FINISH:
369
-      mydata.count++;
370
-      break;
371
-  }
372
-  BedMeshScreen::onMeshUpdate(x, y, 0);
373
-}
374
-
375
-void BedMeshScreen::startMeshProbe() {
376
-  GOTO_SCREEN(BedMeshScreen);
377
-  mydata.allowEditing = false;
378
-  mydata.count = 0;
379
-  injectCommands_P(PSTR(BED_LEVELING_COMMANDS));
380
-}
381
-
382
-void BedMeshScreen::showMesh() {
383
-  GOTO_SCREEN(BedMeshScreen);
384
-  mydata.allowEditing = false;
385
-}
207
+void BedMeshBase::drawMeshForeground(CommandProcessor &cmd, int16_t x, int16_t y, int16_t w, int16_t h, mesh_getter_ptr func, void *data, uint8_t highlightedTag, float progress) {
208
+  constexpr float autoscale_max_amplitude = 0.03;
386 209
 
387
-void BedMeshScreen::showMeshEditor() {
388
-  SpinnerDialogBox::enqueueAndWait_P(ExtUI::isMachineHomed() ? F("M420 S1") : F("G28\nM420 S1"));
389
-  // After the spinner, go to this screen.
390
-  current_screen.forget();
391
-  PUSH_SCREEN(BedMeshScreen);
210
+  cmd.cmd(COLOR_RGB(Theme::bed_mesh_lines_rgb));
211
+  _drawMesh(cmd, x, y, w, h,
212
+    USE_POINTS | USE_HIGHLIGHT | USE_AUTOSCALE | (progress > 0.95 ? USE_COLORS : 0),
213
+    autoscale_max_amplitude * progress,
214
+    highlightedTag,
215
+    func, data
216
+  );
392 217
 }
393 218
 
394
-#endif // FTDI_BED_MESH_SCREEN
219
+#endif // FTDI_BED_MESH_BASE

+ 46
- 0
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_base.h View File

@@ -0,0 +1,46 @@
1
+/*******************
2
+ * bed_mesh_base.h *
3
+ *******************/
4
+
5
+/****************************************************************************
6
+ *   Written By Marcio Teixeira 2020                                        *
7
+ *                                                                          *
8
+ *   This program is free software: you can redistribute it and/or modify   *
9
+ *   it under the terms of the GNU General Public License as published by   *
10
+ *   the Free Software Foundation, either version 3 of the License, or      *
11
+ *   (at your option) any later version.                                    *
12
+ *                                                                          *
13
+ *   This program is distributed in the hope that it will be useful,        *
14
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
15
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
16
+ *   GNU General Public License for more details.                           *
17
+ *                                                                          *
18
+ *   To view a copy of the GNU General Public License, go to the following  *
19
+ *   location: <https://www.gnu.org/licenses/>.                             *
20
+ ****************************************************************************/
21
+
22
+#pragma once
23
+
24
+#define FTDI_BED_MESH_BASE
25
+
26
+class BedMeshBase : public BaseScreen {
27
+  protected:
28
+    typedef float (*mesh_getter_ptr)(uint8_t x, uint8_t y, void *data);
29
+
30
+  private:
31
+    enum MeshOpts {
32
+      USE_POINTS    = 0x01,
33
+      USE_COLORS    = 0x02,
34
+      USE_TAGS      = 0x04,
35
+      USE_HIGHLIGHT = 0x08,
36
+      USE_AUTOSCALE = 0x10
37
+    };
38
+
39
+    static void _drawMesh(CommandProcessor &, int16_t x, int16_t y, int16_t w, int16_t h, uint8_t opts, float autoscale_max, uint8_t highlightedTag, mesh_getter_ptr func, void *data);
40
+
41
+  protected:
42
+    static void drawMeshForeground(CommandProcessor &cmd, int16_t x, int16_t y, int16_t w, int16_t h, mesh_getter_ptr func, void *data, uint8_t highlightedTag = 0, float progress = 1.0);
43
+    static void drawMeshBackground(CommandProcessor &cmd, int16_t x, int16_t y, int16_t w, int16_t h);
44
+    static uint8_t pointToTag(uint8_t x, uint8_t y);
45
+    static bool tagToPoint(uint8_t tag, xy_uint8_t &pt);
46
+};

+ 186
- 0
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.cpp View File

@@ -0,0 +1,186 @@
1
+/****************************
2
+ * bed_mesh_edit_screen.cpp *
3
+ ****************************/
4
+
5
+/****************************************************************************
6
+ *   Written By Marcio Teixeira 2020                                        *
7
+ *                                                                          *
8
+ *   This program is free software: you can redistribute it and/or modify   *
9
+ *   it under the terms of the GNU General Public License as published by   *
10
+ *   the Free Software Foundation, either version 3 of the License, or      *
11
+ *   (at your option) any later version.                                    *
12
+ *                                                                          *
13
+ *   This program is distributed in the hope that it will be useful,        *
14
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
15
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
16
+ *   GNU General Public License for more details.                           *
17
+ *                                                                          *
18
+ *   To view a copy of the GNU General Public License, go to the following  *
19
+ *   location: <https://www.gnu.org/licenses/>.                             *
20
+ ****************************************************************************/
21
+
22
+#include "../config.h"
23
+#include "screens.h"
24
+#include "screen_data.h"
25
+
26
+#ifdef FTDI_BED_MESH_EDIT_SCREEN
27
+
28
+using namespace FTDI;
29
+using namespace Theme;
30
+using namespace ExtUI;
31
+
32
+constexpr static BedMeshEditScreenData &mydata = screen_data.BedMeshEditScreen;
33
+constexpr static float gaugeThickness = 0.25;
34
+
35
+#if ENABLED(TOUCH_UI_PORTRAIT)
36
+  #define GRID_COLS 3
37
+  #define GRID_ROWS 10
38
+
39
+  #define MESH_POS    BTN_POS(1, 2), BTN_SIZE(3,5)
40
+  #define MESSAGE_POS BTN_POS(1, 7), BTN_SIZE(3,1)
41
+  #define Z_LABEL_POS BTN_POS(1, 8), BTN_SIZE(1,1)
42
+  #define Z_VALUE_POS BTN_POS(2, 8), BTN_SIZE(2,1)
43
+  #define BACK_POS    BTN_POS(1,10), BTN_SIZE(2,1)
44
+  #define SAVE_POS    BTN_POS(3,10), BTN_SIZE(1,1)
45
+#else
46
+  #define GRID_COLS 5
47
+  #define GRID_ROWS 5
48
+
49
+  #define MESH_POS    BTN_POS(1,1), BTN_SIZE(3,5)
50
+  #define MESSAGE_POS BTN_POS(4,1), BTN_SIZE(2,1)
51
+  #define Z_LABEL_POS BTN_POS(4,2), BTN_SIZE(2,1)
52
+  #define Z_VALUE_POS BTN_POS(4,3), BTN_SIZE(2,1)
53
+  #define BACK_POS    BTN_POS(4,5), BTN_SIZE(1,1)
54
+  #define SAVE_POS    BTN_POS(5,5), BTN_SIZE(1,1)
55
+#endif
56
+
57
+static float meshGetter(uint8_t x, uint8_t y, void*) {
58
+  xy_uint8_t pos;
59
+  pos.x = x;
60
+  pos.y = y;
61
+  return ExtUI::getMeshPoint(pos) + (mydata.highlight.x != -1 && mydata.highlight == pos ? mydata.zAdjustment : 0);
62
+}
63
+
64
+void BedMeshEditScreen::onEntry() {
65
+  mydata.needSave = false;
66
+  mydata.highlight.x = -1;
67
+  mydata.zAdjustment = 0;
68
+  BaseScreen::onEntry();
69
+}
70
+
71
+float BedMeshEditScreen::getHighlightedValue() {
72
+  const float val = ExtUI::getMeshPoint(mydata.highlight);
73
+  return (isnan(val) ? 0 : val) + mydata.zAdjustment;
74
+}
75
+
76
+void BedMeshEditScreen::setHighlightedValue(float value) {
77
+  ExtUI::setMeshPoint(mydata.highlight, value);
78
+}
79
+
80
+void BedMeshEditScreen::moveToHighlightedValue() {
81
+  if (ExtUI::getMeshValid()) {
82
+    ExtUI::setLevelingActive(true);
83
+    ExtUI::moveToMeshPoint(mydata.highlight, gaugeThickness + mydata.zAdjustment);
84
+  }
85
+}
86
+
87
+void BedMeshEditScreen::adjustHighlightedValue(float increment) {
88
+  if(mydata.highlight.x != -1) {
89
+    mydata.zAdjustment += increment;
90
+    moveToHighlightedValue();
91
+    mydata.needSave = true;
92
+  }
93
+}
94
+
95
+void BedMeshEditScreen::saveAdjustedHighlightedValue() {
96
+  if (mydata.zAdjustment && mydata.highlight.x != -1) {
97
+    setHighlightedValue(getHighlightedValue());
98
+    mydata.zAdjustment = 0;
99
+  }
100
+}
101
+
102
+bool BedMeshEditScreen::changeHighlightedValue(uint8_t tag) {
103
+  saveAdjustedHighlightedValue();
104
+  if (tagToPoint(tag, mydata.highlight)) {
105
+    moveToHighlightedValue();
106
+    return true;
107
+  }
108
+  return false;
109
+}
110
+
111
+void BedMeshEditScreen::drawHighlightedPointValue() {
112
+  CommandProcessor cmd;
113
+  cmd.font(Theme::font_medium)
114
+     .colors(normal_btn)
115
+     .text(Z_LABEL_POS, GET_TEXT_F(MSG_MESH_EDIT_Z))
116
+     .font(font_small);
117
+  if(mydata.highlight.x != -1)
118
+    draw_adjuster(cmd, Z_VALUE_POS, 3, getHighlightedValue(), GET_TEXT_F(MSG_UNITS_MM), 4, 3);
119
+  cmd.colors(mydata.needSave ? normal_btn : action_btn)
120
+     .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_BACK))
121
+     .colors(mydata.needSave ? action_btn : normal_btn)
122
+     .enabled(mydata.needSave)
123
+     .tag(2).button(SAVE_POS, GET_TEXT_F(MSG_TOUCHMI_SAVE));
124
+}
125
+
126
+void BedMeshEditScreen::onRedraw(draw_mode_t what) {
127
+  #define _INSET_POS(x,y,w,h) x + min(w,h)/10, y + min(w,h)/10, w - min(w,h)/5, h - min(w,h)/5
128
+  #define INSET_POS(pos) _INSET_POS(pos)
129
+
130
+  CommandProcessor cmd;
131
+
132
+  if (what & BACKGROUND) {
133
+    cmd.cmd(CLEAR_COLOR_RGB(bg_color))
134
+       .cmd(CLEAR(true,true,true));
135
+    drawMeshBackground(cmd, INSET_POS(MESH_POS));
136
+  }
137
+
138
+  if (what & FOREGROUND) {
139
+    drawHighlightedPointValue();
140
+    drawMeshForeground(cmd, INSET_POS(MESH_POS), meshGetter, nullptr, pointToTag(mydata.highlight.x,mydata.highlight.y));
141
+  }
142
+}
143
+
144
+bool BedMeshEditScreen::onTouchHeld(uint8_t tag) {
145
+  constexpr float increment = 0.01;
146
+  switch (tag) {
147
+    case 3: adjustHighlightedValue(-increment); return true;
148
+    case 4: adjustHighlightedValue( increment); return true;
149
+  }
150
+  return false;
151
+}
152
+
153
+bool BedMeshEditScreen::onTouchEnd(uint8_t tag) {
154
+  switch (tag) {
155
+    case 1:
156
+      // On Cancel, reload saved mesh, discarding changes
157
+      GOTO_PREVIOUS();
158
+      injectCommands_P(PSTR("G29 L1"));
159
+      return true;
160
+    case 2:
161
+      saveAdjustedHighlightedValue();
162
+      injectCommands_P(PSTR("G29 S1"));
163
+      mydata.needSave = false;
164
+      return true;
165
+    case 3:
166
+    case 4:
167
+      return onTouchHeld(tag);
168
+    default: return changeHighlightedValue(tag);
169
+  }
170
+  return true;
171
+}
172
+
173
+void BedMeshEditScreen::show() {
174
+  // On entry, home if needed and save current mesh
175
+  if (!ExtUI::isMachineHomed()) {
176
+    SpinnerDialogBox::enqueueAndWait_P(F("G28\nG29 S1"));
177
+    // After the spinner, go to this screen.
178
+    current_screen.forget();
179
+    PUSH_SCREEN(BedMeshEditScreen);
180
+  } else {
181
+    injectCommands_P(PSTR("G29 S1"));
182
+    GOTO_SCREEN(BedMeshEditScreen);
183
+  }
184
+}
185
+
186
+#endif // FTDI_BED_MESH_EDIT_SCREEN

Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_screen.h → Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.h View File

@@ -1,6 +1,6 @@
1
-/*********************
2
- * bed_mesh_screen.h *
3
- *********************/
1
+/**************************
2
+ * bed_mesh_edit_screen.h *
3
+ *************************/
4 4
 
5 5
 /****************************************************************************
6 6
  *   Written By Marcio Teixeira 2020                                        *
@@ -21,49 +21,28 @@
21 21
 
22 22
 #pragma once
23 23
 
24
-#define FTDI_BED_MESH_SCREEN
25
-#define FTDI_BED_MESH_SCREEN_CLASS BedMeshScreen
24
+#define FTDI_BED_MESH_EDIT_SCREEN
25
+#define FTDI_BED_MESH_EDIT_SCREEN_CLASS BedMeshEditScreen
26 26
 
27
-struct BedMeshScreenData {
28
-  enum : uint8_t {
29
-    MSG_NONE,
30
-    MSG_MESH_COMPLETE,
31
-    MSG_MESH_INCOMPLETE
32
-  } message;
33
-  uint8_t count;
34
-  uint8_t highlightedTag;
27
+struct BedMeshEditScreenData {
28
+  bool needSave;
29
+  xy_uint8_t highlight;
35 30
   float zAdjustment;
36
-  bool allowEditing;
37 31
 };
38 32
 
39
-class BedMeshScreen : public BaseScreen, public CachedScreen<BED_MESH_SCREEN_CACHE> {
33
+class BedMeshEditScreen : public BedMeshBase, public CachedScreen<BED_MESH_EDIT_SCREEN_CACHE> {
40 34
   private:
41
-    enum MeshOpts {
42
-      USE_POINTS    = 0x01,
43
-      USE_COLORS    = 0x02,
44
-      USE_TAGS      = 0x04,
45
-      USE_HIGHLIGHT = 0x08,
46
-      USE_AUTOSCALE = 0x10
47
-    };
48
-
49
-    static uint8_t pointToTag(uint8_t x, uint8_t y);
50
-    static bool tagToPoint(uint8_t tag, xy_uint8_t &pt);
51
-    static float getHighlightedValue(bool nanAsZero);
35
+    static float getHighlightedValue();
52 36
     static void setHighlightedValue(float value);
53 37
     static void moveToHighlightedValue();
54 38
     static void adjustHighlightedValue(float increment);
55 39
     static void saveAdjustedHighlightedValue();
56
-    static void changeHighlightedValue(uint8_t tag);
40
+    static bool changeHighlightedValue(uint8_t tag);
57 41
     static void drawHighlightedPointValue();
58
-    static void drawMesh(int16_t x, int16_t y, int16_t w, int16_t h, ExtUI::bed_mesh_t data, uint8_t opts, float autoscale_max = 0.1);
59 42
   public:
60
-    static void onMeshUpdate(const int8_t x, const int8_t y, const float val);
61
-    static void onMeshUpdate(const int8_t x, const int8_t y, const ExtUI::probe_state_t);
62 43
     static void onEntry();
63 44
     static void onRedraw(draw_mode_t);
45
+    static bool onTouchHeld(uint8_t tag);
64 46
     static bool onTouchEnd(uint8_t tag);
65
-
66
-    static void startMeshProbe();
67
-    static void showMesh();
68
-    static void showMeshEditor();
47
+    static void show();
69 48
 };

+ 172
- 0
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_view_screen.cpp View File

@@ -0,0 +1,172 @@
1
+/****************************
2
+ * bed_mesh_view_screen.cpp *
3
+ ****************************/
4
+
5
+/****************************************************************************
6
+ *   Written By Marcio Teixeira 2020                                        *
7
+ *                                                                          *
8
+ *   This program is free software: you can redistribute it and/or modify   *
9
+ *   it under the terms of the GNU General Public License as published by   *
10
+ *   the Free Software Foundation, either version 3 of the License, or      *
11
+ *   (at your option) any later version.                                    *
12
+ *                                                                          *
13
+ *   This program is distributed in the hope that it will be useful,        *
14
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
15
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
16
+ *   GNU General Public License for more details.                           *
17
+ *                                                                          *
18
+ *   To view a copy of the GNU General Public License, go to the following  *
19
+ *   location: <https://www.gnu.org/licenses/>.                             *
20
+ ****************************************************************************/
21
+
22
+#include "../config.h"
23
+#include "screens.h"
24
+#include "screen_data.h"
25
+
26
+#ifdef FTDI_BED_MESH_VIEW_SCREEN
27
+
28
+using namespace FTDI;
29
+using namespace Theme;
30
+using namespace ExtUI;
31
+
32
+constexpr static BedMeshViewScreenData &mydata = screen_data.BedMeshViewScreen;
33
+constexpr static float gaugeThickness = 0.25;
34
+
35
+#if ENABLED(TOUCH_UI_PORTRAIT)
36
+  #define GRID_COLS 3
37
+  #define GRID_ROWS 10
38
+
39
+  #define MESH_POS    BTN_POS(1, 2), BTN_SIZE(3,5)
40
+  #define MESSAGE_POS BTN_POS(1, 7), BTN_SIZE(3,1)
41
+  #define Z_LABEL_POS BTN_POS(1, 8), BTN_SIZE(1,1)
42
+  #define Z_VALUE_POS BTN_POS(2, 8), BTN_SIZE(2,1)
43
+  #define OKAY_POS    BTN_POS(1,10), BTN_SIZE(3,1)
44
+#else
45
+  #define GRID_COLS 5
46
+  #define GRID_ROWS 5
47
+
48
+  #define MESH_POS    BTN_POS(1,1), BTN_SIZE(3,5)
49
+  #define MESSAGE_POS BTN_POS(4,1), BTN_SIZE(2,1)
50
+  #define Z_LABEL_POS BTN_POS(4,2), BTN_SIZE(2,1)
51
+  #define Z_VALUE_POS BTN_POS(4,3), BTN_SIZE(2,1)
52
+  #define OKAY_POS    BTN_POS(4,5), BTN_SIZE(2,1)
53
+#endif
54
+
55
+static float meshGetter(uint8_t x, uint8_t y, void*) {
56
+  xy_uint8_t pos;
57
+  pos.x = x;
58
+  pos.y = y;  
59
+  return ExtUI::getMeshPoint(pos);
60
+}
61
+
62
+void BedMeshViewScreen::onEntry() {
63
+  mydata.highlight.x = -1;
64
+  mydata.count = GRID_MAX_POINTS;
65
+  mydata.message = nullptr;
66
+  BaseScreen::onEntry();
67
+}
68
+
69
+void BedMeshViewScreen::drawHighlightedPointValue() {
70
+  CommandProcessor cmd;
71
+  cmd.font(Theme::font_medium)
72
+     .colors(normal_btn)
73
+     .text(Z_LABEL_POS, GET_TEXT_F(MSG_MESH_EDIT_Z))
74
+     .font(font_small);
75
+
76
+  if(mydata.highlight.x != -1)
77
+    draw_adjuster_value(cmd, Z_VALUE_POS, ExtUI::getMeshPoint(mydata.highlight), GET_TEXT_F(MSG_UNITS_MM), 4, 3);
78
+
79
+  cmd.colors(action_btn)
80
+     .tag(1).button(OKAY_POS, GET_TEXT_F(MSG_BUTTON_OKAY))
81
+     .tag(0);
82
+
83
+  if(mydata.message) cmd.text(MESSAGE_POS, mydata.message);
84
+}
85
+
86
+void BedMeshViewScreen::onRedraw(draw_mode_t what) {
87
+  #define _INSET_POS(x,y,w,h) x + min(w,h)/10, y + min(w,h)/10, w - min(w,h)/5, h - min(w,h)/5
88
+  #define INSET_POS(pos) _INSET_POS(pos)
89
+
90
+  CommandProcessor cmd;
91
+
92
+  if (what & BACKGROUND) {
93
+    cmd.cmd(CLEAR_COLOR_RGB(bg_color))
94
+       .cmd(CLEAR(true,true,true));
95
+    drawMeshBackground(cmd, INSET_POS(MESH_POS));
96
+  }
97
+
98
+  if (what & FOREGROUND) {
99
+    const float progress = sq(float(mydata.count) / GRID_MAX_POINTS);
100
+    if (progress >= 1.0)
101
+      drawHighlightedPointValue();
102
+    drawMeshForeground(cmd, INSET_POS(MESH_POS), meshGetter, nullptr, pointToTag(mydata.highlight.x, mydata.highlight.y), progress);
103
+  }
104
+}
105
+
106
+bool BedMeshViewScreen::onTouchEnd(uint8_t tag) {
107
+  switch (tag) {
108
+    case 1: GOTO_PREVIOUS(); return true;
109
+    default: return tagToPoint(tag, mydata.highlight);
110
+  }
111
+  return true;
112
+}
113
+
114
+void BedMeshViewScreen::onMeshUpdate(const int8_t, const int8_t, const float) {
115
+  if (AT_SCREEN(BedMeshViewScreen)) {
116
+    onRefresh();
117
+    ExtUI::yield();
118
+  }
119
+}
120
+
121
+void BedMeshViewScreen::onMeshUpdate(const int8_t x, const int8_t y, const ExtUI::probe_state_t state) {
122
+  switch (state) {
123
+    case ExtUI::G29_START:
124
+      mydata.message = nullptr;
125
+      mydata.count = 0;
126
+      break;
127
+    case ExtUI::G29_FINISH:
128
+      if (mydata.count == GRID_MAX_POINTS && ExtUI::getMeshValid())
129
+        mydata.message = GET_TEXT_F(MSG_BED_MAPPING_DONE);
130
+      else
131
+        mydata.message = GET_TEXT_F(MSG_BED_MAPPING_INCOMPLETE);
132
+      mydata.count = GRID_MAX_POINTS;
133
+      break;
134
+    case ExtUI::G26_START:
135
+      GOTO_SCREEN(BedMeshViewScreen);
136
+      mydata.message = nullptr;
137
+      mydata.count = 0;
138
+      break;
139
+    case ExtUI::G26_FINISH:
140
+      GOTO_SCREEN(StatusScreen);
141
+      break;
142
+    case ExtUI::G29_POINT_START:
143
+    case ExtUI::G26_POINT_START:
144
+      mydata.highlight.x = x;
145
+      mydata.highlight.y = y;
146
+      break;
147
+    case ExtUI::G29_POINT_FINISH:
148
+    case ExtUI::G26_POINT_FINISH:
149
+      mydata.count++;
150
+      break;
151
+  }
152
+  BedMeshViewScreen::onMeshUpdate(x, y, 0);
153
+}
154
+
155
+void BedMeshViewScreen::doProbe() {
156
+  GOTO_SCREEN(BedMeshViewScreen);
157
+  mydata.count = 0;
158
+  injectCommands_P(PSTR(BED_LEVELING_COMMANDS));
159
+}
160
+
161
+void BedMeshViewScreen::doMeshValidation() {
162
+  mydata.count = 0;
163
+  GOTO_SCREEN(StatusScreen);
164
+  injectCommands_P(PSTR("G28 O\nM117 Heating...\nG26 R X0 Y0"));
165
+}
166
+
167
+void BedMeshViewScreen::show() {
168
+  injectCommands_P(PSTR("G29 L1"));
169
+  GOTO_SCREEN(BedMeshViewScreen);
170
+}
171
+
172
+#endif // FTDI_BED_MESH_VIEW_SCREEN

+ 48
- 0
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_view_screen.h View File

@@ -0,0 +1,48 @@
1
+/**************************
2
+ * bed_mesh_view_screen.h *
3
+ *************************/
4
+
5
+/****************************************************************************
6
+ *   Written By Marcio Teixeira 2020                                        *
7
+ *                                                                          *
8
+ *   This program is free software: you can redistribute it and/or modify   *
9
+ *   it under the terms of the GNU General Public License as published by   *
10
+ *   the Free Software Foundation, either version 3 of the License, or      *
11
+ *   (at your option) any later version.                                    *
12
+ *                                                                          *
13
+ *   This program is distributed in the hope that it will be useful,        *
14
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
15
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
16
+ *   GNU General Public License for more details.                           *
17
+ *                                                                          *
18
+ *   To view a copy of the GNU General Public License, go to the following  *
19
+ *   location: <https://www.gnu.org/licenses/>.                             *
20
+ ****************************************************************************/
21
+
22
+#pragma once
23
+
24
+#define FTDI_BED_MESH_VIEW_SCREEN
25
+#define FTDI_BED_MESH_VIEW_SCREEN_CLASS BedMeshViewScreen
26
+
27
+struct BedMeshViewScreenData {
28
+  progmem_str message;
29
+  uint8_t count;
30
+  xy_uint8_t highlight;
31
+};
32
+
33
+class BedMeshViewScreen : public BedMeshBase, public CachedScreen<BED_MESH_VIEW_SCREEN_CACHE> {
34
+  private:
35
+    static float getHighlightedValue();
36
+    static bool changeHighlightedValue(uint8_t tag);
37
+    static void drawHighlightedPointValue();
38
+  public:
39
+    static void onMeshUpdate(const int8_t x, const int8_t y, const float val);
40
+    static void onMeshUpdate(const int8_t x, const int8_t y, const ExtUI::probe_state_t);
41
+    static void onEntry();
42
+    static void onRedraw(draw_mode_t);
43
+    static bool onTouchEnd(uint8_t tag);
44
+
45
+    static void doProbe();
46
+    static void doMeshValidation();
47
+    static void show();
48
+};

+ 4
- 7
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/leveling_menu.cpp View File

@@ -111,20 +111,17 @@ bool LevelingMenu::onTouchEnd(uint8_t tag) {
111 111
       #define BED_LEVELING_COMMANDS "G29"
112 112
     #endif
113 113
     #if ENABLED(AUTO_BED_LEVELING_UBL)
114
-      BedMeshScreen::startMeshProbe();
114
+      BedMeshViewScreen::doProbe();
115 115
     #else
116 116
       SpinnerDialogBox::enqueueAndWait_P(F(BED_LEVELING_COMMANDS));
117 117
     #endif
118 118
     break;
119 119
     #if ENABLED(AUTO_BED_LEVELING_UBL)
120
-    case 4: BedMeshScreen::showMesh(); break;
121
-    case 5: BedMeshScreen::showMeshEditor(); break;
120
+    case 4: BedMeshViewScreen::show(); break;
121
+    case 5: BedMeshEditScreen::show(); break;
122 122
     #endif
123 123
     #if ENABLED(G26_MESH_VALIDATION)
124
-    case 6:
125
-      GOTO_SCREEN(StatusScreen);
126
-      injectCommands_P(PSTR("M117 Printing Test Pattern\nG28 O\nG26 R"));
127
-      break;
124
+    case 6: BedMeshViewScreen::doMeshValidation(); break;
128 125
     #endif
129 126
     #if ENABLED(BLTOUCH)
130 127
     case 7: injectCommands_P(PSTR("M280 P0 S60")); break;

+ 2
- 1
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screen_data.h View File

@@ -55,7 +55,8 @@ union screen_data_t {
55 55
   DECL_DATA_IF_INCLUDED(FTDI_CHANGE_FILAMENT_SCREEN)
56 56
   DECL_DATA_IF_INCLUDED(FTDI_FILES_SCREEN)
57 57
   DECL_DATA_IF_INCLUDED(FTDI_MOVE_AXIS_SCREEN)
58
-  DECL_DATA_IF_INCLUDED(FTDI_BED_MESH_SCREEN)
58
+  DECL_DATA_IF_INCLUDED(FTDI_BED_MESH_VIEW_SCREEN)
59
+  DECL_DATA_IF_INCLUDED(FTDI_BED_MESH_EDIT_SCREEN)
59 60
   DECL_DATA_IF_INCLUDED(FTDI_STRESS_TEST_SCREEN)
60 61
   DECL_DATA_IF_INCLUDED(FTDI_COCOA_PREHEAT_SCREEN)
61 62
   DECL_DATA_IF_INCLUDED(FTDI_COCOA_LOAD_CHOCOLATE_SCREEN)

+ 2
- 1
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screens.cpp View File

@@ -75,7 +75,8 @@ SCREEN_TABLE {
75 75
   DECL_SCREEN_IF_INCLUDED(FTDI_STEPPER_BUMP_SENSITIVITY_SCREEN)
76 76
   DECL_SCREEN_IF_INCLUDED(FTDI_LEVELING_MENU)
77 77
   DECL_SCREEN_IF_INCLUDED(FTDI_Z_OFFSET_SCREEN)
78
-  DECL_SCREEN_IF_INCLUDED(FTDI_BED_MESH_SCREEN)
78
+  DECL_SCREEN_IF_INCLUDED(FTDI_BED_MESH_VIEW_SCREEN)
79
+  DECL_SCREEN_IF_INCLUDED(FTDI_BED_MESH_EDIT_SCREEN)
79 80
   DECL_SCREEN_IF_INCLUDED(FTDI_NOZZLE_OFFSETS_SCREEN)
80 81
   DECL_SCREEN_IF_INCLUDED(FTDI_BACKLASH_COMP_SCREEN)
81 82
   DECL_SCREEN_IF_INCLUDED(FTDI_FEEDRATE_PERCENT_SCREEN)

+ 5
- 2
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screens.h View File

@@ -61,7 +61,8 @@ enum {
61 61
       ZOFFSET_SCREEN_CACHE,
62 62
     #endif
63 63
     #if HAS_MESH
64
-      BED_MESH_SCREEN_CACHE,
64
+      BED_MESH_VIEW_SCREEN_CACHE,
65
+      BED_MESH_EDIT_SCREEN_CACHE,
65 66
     #endif
66 67
   #endif
67 68
   #if ENABLED(BABYSTEPPING)
@@ -206,7 +207,9 @@ enum {
206 207
     #include "z_offset_screen.h"
207 208
   #endif
208 209
   #if HAS_MESH
209
-    #include "bed_mesh_screen.h"
210
+    #include "bed_mesh_base.h"
211
+    #include "bed_mesh_view_screen.h"
212
+    #include "bed_mesh_edit_screen.h"
210 213
   #endif
211 214
 #endif
212 215
 

+ 8
- 4
Marlin/src/lcd/extui/ui_api.h View File

@@ -168,10 +168,14 @@ namespace ExtUI {
168 168
       inline void onMeshUpdate(const xy_int8_t &pos, const_float_t zval) { onMeshUpdate(pos.x, pos.y, zval); }
169 169
 
170 170
       typedef enum : uint8_t {
171
-        MESH_START,    // Prior to start of probe
172
-        MESH_FINISH,   // Following probe of all points
173
-        PROBE_START,   // Beginning probe of grid location
174
-        PROBE_FINISH   // Finished probe of grid location
171
+        G29_START,        // Prior to start of probe
172
+        G29_FINISH,       // Following probe of all points
173
+        G29_POINT_START,  // Beginning probe of grid location
174
+        G29_POINT_FINISH, // Finished probe of grid location
175
+        G26_START,
176
+        G26_FINISH,
177
+        G26_POINT_START,
178
+        G26_POINT_FINISH
175 179
       } probe_state_t;
176 180
       void onMeshUpdate(const int8_t xpos, const int8_t ypos, probe_state_t state);
177 181
       inline void onMeshUpdate(const xy_int8_t &pos, probe_state_t state) { onMeshUpdate(pos.x, pos.y, state); }

Loading…
Cancel
Save