Quellcode durchsuchen

ExtUI Mesh Leveling Extensions (#13363)

InsanityAutomation vor 5 Jahren
Ursprung
Commit
c03df89921

+ 3
- 0
Marlin/src/feature/bedlevel/abl/abl.cpp Datei anzeigen

@@ -76,6 +76,9 @@ static void extrapolate_one_point(const uint8_t x, const uint8_t y, const int8_t
76 76
 
77 77
   // Take the average instead of the median
78 78
   z_values[x][y] = (a + b + c) / 3.0;
79
+  #if ENABLED(EXTENSIBLE_UI)
80
+    ExtUI::onMeshUpdate(x, y, z_values[x][y]);
81
+  #endif
79 82
 
80 83
   // Median is robust (ignores outliers).
81 84
   // z_values[x][y] = (a < b) ? ((b < c) ? b : (c < a) ? a : c)

+ 5
- 1
Marlin/src/feature/bedlevel/bedlevel.cpp Datei anzeigen

@@ -134,8 +134,12 @@ void reset_bed_level() {
134 134
     bilinear_start[X_AXIS] = bilinear_start[Y_AXIS] =
135 135
     bilinear_grid_spacing[X_AXIS] = bilinear_grid_spacing[Y_AXIS] = 0;
136 136
     for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
137
-      for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
137
+      for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) {
138 138
         z_values[x][y] = NAN;
139
+        #if ENABLED(EXTENSIBLE_UI)
140
+          ExtUI::onMeshUpdate(x, y, 0);
141
+        #endif
142
+      }
139 143
   #elif ABL_PLANAR
140 144
     planner.bed_level_matrix.set_to_identity();
141 145
   #endif

+ 5
- 0
Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.cpp Datei anzeigen

@@ -47,6 +47,11 @@
47 47
   void mesh_bed_leveling::reset() {
48 48
     z_offset = 0;
49 49
     ZERO(z_values);
50
+    #if ENABLED(EXTENSIBLE_UI)
51
+      for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
52
+        for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) 
53
+            ExtUI::onMeshUpdate(x, y, 0);
54
+    #endif
50 55
   }
51 56
 
52 57
   #if IS_CARTESIAN && DISABLED(SEGMENT_LEVELED_MOVES)

+ 8
- 0
Marlin/src/feature/bedlevel/ubl/ubl.cpp Datei anzeigen

@@ -129,6 +129,11 @@
129 129
       planner.set_z_fade_height(10.0);
130 130
     #endif
131 131
     ZERO(z_values);
132
+    #if ENABLED(EXTENSIBLE_UI)
133
+      for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
134
+        for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) 
135
+            ExtUI::onMeshUpdate(x, y, 0);
136
+    #endif
132 137
     if (was_enabled) report_current_position();
133 138
   }
134 139
 
@@ -141,6 +146,9 @@
141 146
     for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++) {
142 147
       for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) {
143 148
         z_values[x][y] = value;
149
+        #if ENABLED(EXTENSIBLE_UI)
150
+          ExtUI::onMeshUpdate(x, y, value);
151
+        #endif
144 152
       }
145 153
     }
146 154
   }

+ 54
- 3
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp Datei anzeigen

@@ -335,6 +335,9 @@
335 335
             break;            // No more invalid Mesh Points to populate
336 336
           }
337 337
           z_values[location.x_index][location.y_index] = NAN;
338
+          #if ENABLED(EXTENSIBLE_UI)
339
+            ExtUI::onMeshUpdate(location.x_index, location.y_index, 0);
340
+          #endif
338 341
           cnt++;
339 342
         }
340 343
       }
@@ -362,6 +365,9 @@
362 365
               const float p1 = 0.5f * (GRID_MAX_POINTS_X) - x,
363 366
                           p2 = 0.5f * (GRID_MAX_POINTS_Y) - y;
364 367
               z_values[x][y] += 2.0f * HYPOT(p1, p2);
368
+              #if ENABLED(EXTENSIBLE_UI)
369
+                ExtUI::onMeshUpdate(x, y, z_values[x][y]);
370
+              #endif
365 371
             }
366 372
           }
367 373
           break;
@@ -370,6 +376,11 @@
370 376
           for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++) {  // Create a diagonal line several Mesh cells thick that is raised
371 377
             z_values[x][x] += 9.999f;
372 378
             z_values[x][x + (x < GRID_MAX_POINTS_Y - 1) ? 1 : -1] += 9.999f; // We want the altered line several mesh points thick
379
+            #if ENABLED(EXTENSIBLE_UI)
380
+              ExtUI::onMeshUpdate(x, x, z_values[x][x]);
381
+              ExtUI::onMeshUpdate(x, (x + (x < GRID_MAX_POINTS_Y - 1) ? 1 : -1), z_values[x][x + (x < GRID_MAX_POINTS_Y - 1) ? 1 : -1]);
382
+            #endif
383
+
373 384
           }
374 385
           break;
375 386
 
@@ -378,6 +389,9 @@
378 389
           for (uint8_t x = (GRID_MAX_POINTS_X) / 3; x < 2 * (GRID_MAX_POINTS_X) / 3; x++)   // Create a rectangular raised area in
379 390
             for (uint8_t y = (GRID_MAX_POINTS_Y) / 3; y < 2 * (GRID_MAX_POINTS_Y) / 3; y++) // the center of the bed
380 391
               z_values[x][y] += parser.seen('C') ? g29_constant : 9.99f;
392
+              #if ENABLED(EXTENSIBLE_UI)
393
+                ExtUI::onMeshUpdate(x, y, z_values[x][y]);
394
+              #endif
381 395
           break;
382 396
       }
383 397
     }
@@ -519,6 +533,9 @@
519 533
                   break; // No more invalid Mesh Points to populate
520 534
                 }
521 535
                 z_values[location.x_index][location.y_index] = g29_constant;
536
+                #if ENABLED(EXTENSIBLE_UI)
537
+                  ExtUI::onMeshUpdate(location.x_index, location.y_index, z_values[location.x_index][location.y_index]);
538
+                #endif
522 539
               }
523 540
             }
524 541
           }
@@ -681,15 +698,23 @@
681 698
     if (cflag)
682 699
       for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
683 700
         for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
684
-          if (!isnan(z_values[x][y]))
701
+          if (!isnan(z_values[x][y])) {
685 702
             z_values[x][y] -= mean + value;
703
+            #if ENABLED(EXTENSIBLE_UI)
704
+              ExtUI::onMeshUpdate(x, y, z_values[x][y]);
705
+            #endif
706
+          }
686 707
   }
687 708
 
688 709
   void unified_bed_leveling::shift_mesh_height() {
689 710
     for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
690 711
       for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
691
-        if (!isnan(z_values[x][y]))
712
+        if (!isnan(z_values[x][y])) {
692 713
           z_values[x][y] += g29_constant;
714
+          #if ENABLED(EXTENSIBLE_UI)
715
+            ExtUI::onMeshUpdate(x, y, z_values[x][y]);
716
+          #endif
717
+        }
693 718
   }
694 719
 
695 720
   #if HAS_BED_PROBE
@@ -736,6 +761,10 @@
736 761
 
737 762
           const float measured_z = probe_pt(rawx, rawy, stow_probe ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level); // TODO: Needs error handling
738 763
           z_values[location.x_index][location.y_index] = measured_z;
764
+          #if ENABLED(EXTENSIBLE_UI)
765
+            ExtUI::onMeshUpdate(location.x_index, location.y_index, measured_z);
766
+          #endif
767
+          
739 768
         }
740 769
         SERIAL_FLUSH(); // Prevent host M105 buffer overrun.
741 770
       } while (location.x_index >= 0 && --count);
@@ -894,6 +923,10 @@
894 923
         }
895 924
 
896 925
         z_values[location.x_index][location.y_index] = current_position[Z_AXIS] - thick;
926
+        #if ENABLED(EXTENSIBLE_UI)
927
+          ExtUI::onMeshUpdate(location.x_index, location.y_index, z_values[location.x_index][location.y_index]);
928
+        #endif
929
+
897 930
         if (g29_verbose_level > 2)
898 931
           SERIAL_ECHOLNPAIR_F("Mesh Point Measured at: ", z_values[location.x_index][location.y_index], 6);
899 932
         SERIAL_FLUSH(); // Prevent host M105 buffer overrun.
@@ -994,6 +1027,9 @@
994 1027
         if (click_and_hold(abort_fine_tune)) goto FINE_TUNE_EXIT;   // If the click is held down, abort editing
995 1028
 
996 1029
         z_values[location.x_index][location.y_index] = new_z;       // Save the updated Z value
1030
+        #if ENABLED(EXTENSIBLE_UI)
1031
+          ExtUI::onMeshUpdate(location.x_index, location.y_index, new_z);
1032
+        #endif
997 1033
 
998 1034
         serial_delay(20);                                           // No switch noise
999 1035
         ui.refresh();
@@ -1298,6 +1334,11 @@
1298 1334
         z_values[x][y] = z_values[x1][y1];                      // Use nearest (maybe a little too high.)
1299 1335
       else
1300 1336
         z_values[x][y] = 2.0f * z_values[x1][y1] - z_values[x2][y2];   // Angled upward...
1337
+
1338
+      #if ENABLED(EXTENSIBLE_UI)
1339
+        ExtUI::onMeshUpdate(x, y, z_values[x][y]);
1340
+      #endif
1341
+
1301 1342
       return true;
1302 1343
     }
1303 1344
     return false;
@@ -1510,6 +1551,9 @@
1510 1551
           #endif
1511 1552
 
1512 1553
           z_values[i][j] = z_tmp - lsf_results.D;
1554
+          #if ENABLED(EXTENSIBLE_UI)
1555
+            ExtUI::onMeshUpdate(i, j, z_values[i][j]);
1556
+          #endif
1513 1557
         }
1514 1558
       }
1515 1559
 
@@ -1619,6 +1663,9 @@
1619 1663
             }
1620 1664
             const float ez = -lsf_results.D - lsf_results.A * px - lsf_results.B * py;
1621 1665
             z_values[ix][iy] = ez;
1666
+            #if ENABLED(EXTENSIBLE_UI)
1667
+              ExtUI::onMeshUpdate(ix, iy, z_values[ix][iy]);
1668
+            #endif
1622 1669
             idle();   // housekeeping
1623 1670
           }
1624 1671
         }
@@ -1757,8 +1804,12 @@
1757 1804
       SERIAL_ECHOLNPAIR("Subtracting mesh in slot ", g29_storage_slot, " from current mesh.");
1758 1805
 
1759 1806
       for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
1760
-        for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
1807
+        for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) {
1761 1808
           z_values[x][y] -= tmp_z_values[x][y];
1809
+          #if ENABLED(EXTENSIBLE_UI)
1810
+            ExtUI::onMeshUpdate(x, y, z_values[x][y]);
1811
+          #endif
1812
+        }
1762 1813
     }
1763 1814
 
1764 1815
   #endif // UBL_DEVEL_DEBUGGING

+ 8
- 1
Marlin/src/gcode/bedlevel/M420.cpp Datei anzeigen

@@ -66,8 +66,12 @@ void GcodeSuite::M420() {
66 66
         bilinear_grid_spacing[Y_AXIS] = (MAX_PROBE_Y - (MIN_PROBE_Y)) / (GRID_MAX_POINTS_Y - 1);
67 67
       #endif
68 68
       for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
69
-        for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
69
+        for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) {
70 70
           Z_VALUES(x, y) = 0.001 * random(-200, 200);
71
+          #if ENABLED(EXTENSIBLE_UI)
72
+            ExtUI::onMeshUpdate(x, y, Z_VALUES(x, y));
73
+          #endif
74
+        }
71 75
       SERIAL_ECHOPGM("Simulated " STRINGIFY(GRID_MAX_POINTS_X) "x" STRINGIFY(GRID_MAX_POINTS_X) " mesh ");
72 76
       SERIAL_ECHOPAIR(" (", MIN_PROBE_X);
73 77
       SERIAL_CHAR(','); SERIAL_ECHO(MIN_PROBE_Y);
@@ -176,6 +180,9 @@ void GcodeSuite::M420() {
176 180
             #if ENABLED(ABL_BILINEAR_SUBDIVISION)
177 181
               bed_level_virt_interpolate();
178 182
             #endif
183
+            #if ENABLED(EXTENSIBLE_UI)
184
+              ExtUI::onMeshUpdate(x, y, Z_VALUES(x, y));
185
+            #endif
179 186
           }
180 187
 
181 188
         #endif

+ 9
- 0
Marlin/src/gcode/bedlevel/abl/G29.cpp Datei anzeigen

@@ -321,6 +321,9 @@ G29_TYPE GcodeSuite::G29() {
321 321
           #if ENABLED(ABL_BILINEAR_SUBDIVISION)
322 322
             bed_level_virt_interpolate();
323 323
           #endif
324
+          #if ENABLED(EXTENSIBLE_UI)
325
+            ExtUI::onMeshUpdate(i, j, rz);
326
+          #endif
324 327
           set_bed_leveling_enabled(abl_should_enable);
325 328
           if (abl_should_enable) report_current_position();
326 329
         }
@@ -548,6 +551,9 @@ G29_TYPE GcodeSuite::G29() {
548 551
       #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
549 552
 
550 553
         z_values[xCount][yCount] = measured_z + zoffset;
554
+        #if ENABLED(EXTENSIBLE_UI)
555
+          ExtUI::onMeshUpdate(xCount, yCount, z_values[xCount][yCount]);
556
+        #endif
551 557
 
552 558
         #if ENABLED(DEBUG_LEVELING_FEATURE)
553 559
           if (DEBUGGING(LEVELING)) {
@@ -723,6 +729,9 @@ G29_TYPE GcodeSuite::G29() {
723 729
           #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
724 730
 
725 731
             z_values[xCount][yCount] = measured_z + zoffset;
732
+            #if ENABLED(EXTENSIBLE_UI)
733
+              ExtUI::onMeshUpdate(xCount, yCount, z_values[xCount][yCount]);
734
+            #endif
726 735
 
727 736
           #endif
728 737
 

+ 3
- 0
Marlin/src/gcode/bedlevel/abl/M421.cpp Datei anzeigen

@@ -54,6 +54,9 @@ void GcodeSuite::M421() {
54 54
     #if ENABLED(ABL_BILINEAR_SUBDIVISION)
55 55
       bed_level_virt_interpolate();
56 56
     #endif
57
+    #if ENABLED(EXTENSIBLE_UI)
58
+      ExtUI::onMeshUpdate(ix, iy, z_values[ix][iy]);
59
+    #endif
57 60
   }
58 61
 }
59 62
 

+ 5
- 1
Marlin/src/gcode/bedlevel/mbl/G29.cpp Datei anzeigen

@@ -173,8 +173,12 @@ void GcodeSuite::G29() {
173 173
       else
174 174
         return echo_not_entered('J');
175 175
 
176
-      if (parser.seenval('Z'))
176
+      if (parser.seenval('Z')) {
177 177
         mbl.z_values[ix][iy] = parser.value_linear_units();
178
+        #if ENABLED(EXTENSIBLE_UI)
179
+          ExtUI::onMeshUpdate(ix, iy, mbl.z_values[ix][iy]);
180
+        #endif
181
+      }
178 182
       else
179 183
         return echo_not_entered('Z');
180 184
       break;

+ 5
- 1
Marlin/src/gcode/bedlevel/ubl/M421.cpp Datei anzeigen

@@ -60,8 +60,12 @@ void GcodeSuite::M421() {
60 60
     SERIAL_ERROR_MSG(MSG_ERR_M421_PARAMETERS);
61 61
   else if (!WITHIN(ix, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(iy, 0, GRID_MAX_POINTS_Y - 1))
62 62
     SERIAL_ERROR_MSG(MSG_ERR_MESH_XY);
63
-  else
63
+  else {
64 64
     ubl.z_values[ix][iy] = hasN ? NAN : parser.value_linear_units() + (hasQ ? ubl.z_values[ix][iy] : 0);
65
+    #if ENABLED(EXTENSIBLE_UI)
66
+      ExtUI::onMeshUpdate(ix, iy, ubl.z_values[ix][iy]);
67
+    #endif
68
+  }
65 69
 }
66 70
 
67 71
 #endif // AUTO_BED_LEVELING_UBL

+ 21
- 0
Marlin/src/lcd/extensible_ui/ui_api.cpp Datei anzeigen

@@ -577,6 +577,27 @@ namespace ExtUI {
577 577
     return elapsed.value;
578 578
   }
579 579
 
580
+  #if HAS_LEVELING
581
+    bool getLevelingActive() { return planner.leveling_active; }
582
+    void setLevelingActive(const bool state) { set_bed_leveling_enabled(state) }
583
+    #if HAS_MESH
584
+      bool getMeshValid() { return leveling_is_valid(); }
585
+      bed_mesh_t getMeshArray() { return Z_VALUES; }
586
+      void setMeshPoint(const uint8_t xpos, const uint8_t ypos, const float zoff) {
587
+        if (WITHIN(xpos, 0, GRID_MAX_POINTS_X) && WITHIN(ypos, 0, GRID_MAX_POINTS_Y)) {
588
+          Z_VALUES(xpos, ypos) = zoff;
589
+          #if ENABLED(ABL_BILINEAR_SUBDIVISION)
590
+            bed_level_virt_interpolate();
591
+          #endif
592
+        }
593
+      }
594
+    #endif
595
+  #endif
596
+
597
+  #if ENABLED(HOST_PROMPT_SUPPORT)
598
+    void setHostResponse(const uint8_t response) { host_response_handler(response); }
599
+  #endif
600
+
580 601
   #if ENABLED(PRINTCOUNTER)
581 602
     char* getTotalPrints_str(char buffer[21])    { strcpy(buffer,i16tostr3left(print_job_timer.getStats().totalPrints));    return buffer; }
582 603
     char* getFinishedPrints_str(char buffer[21]) { strcpy(buffer,i16tostr3left(print_job_timer.getStats().finishedPrints)); return buffer; }

+ 16
- 0
Marlin/src/lcd/extensible_ui/ui_api.h Datei anzeigen

@@ -90,6 +90,22 @@ namespace ExtUI {
90 90
   float getFeedrate_percent();
91 91
   uint8_t getProgress_percent();
92 92
   uint32_t getProgress_seconds_elapsed();
93
+  
94
+  #if HAS_LEVELING
95
+    bool getLevelingActive();
96
+    void setLevelingActive(const bool);
97
+    #if HAS_MESH
98
+      typedef float (&bed_mesh_t)[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
99
+      bool getMeshValid();
100
+      bed_mesh_t getMeshArray();
101
+      void setMeshPoint(const uint8_t xpos, const uint8_t ypos, const float zval);
102
+      void onMeshUpdate(const uint8_t xpos, const uint8_t ypos, const float zval);
103
+    #endif
104
+  #endif
105
+
106
+  #if ENABLED(HOST_PROMPT_SUPPORT)
107
+    void setHostResponse(const uint8_t);
108
+  #endif
93 109
 
94 110
   #if ENABLED(PRINTCOUNTER)
95 111
     char* getTotalPrints_str(char buffer[21]);

+ 1
- 1
buildroot/share/tests/megaatmega2560-tests Datei anzeigen

@@ -42,7 +42,7 @@ opt_enable PIDTEMPBED FIX_MOUNTED_PROBE Z_SAFE_HOMING \
42 42
            MAX7219_DEBUG LED_CONTROL_MENU CASE_LIGHT_ENABLE CASE_LIGHT_USE_NEOPIXEL CODEPENDENT_XY_HOMING BACKLASH_COMPENSATION BACKLASH_GCODE
43 43
 opt_enable SLOW_PWM_HEATERS THERMAL_PROTECTION_CHAMBER
44 44
 opt_set TEMP_SENSOR_CHAMBER 3
45
-opt_add CHAMBER_HEATER_PIN 45
45
+opt_set CHAMBER_HEATER_PIN 45
46 46
 exec_test $1 $2 "RAMPS with 2 extruders, RRDFGSC, Linear ABL, LEDs, and many options"
47 47
 
48 48
 #

Laden…
Abbrechen
Speichern