Apply GRID_LOOP
This commit is contained in:
		@@ -49,8 +49,7 @@
 | 
				
			|||||||
  void unified_bed_leveling::report_current_mesh() {
 | 
					  void unified_bed_leveling::report_current_mesh() {
 | 
				
			||||||
    if (!leveling_is_valid()) return;
 | 
					    if (!leveling_is_valid()) return;
 | 
				
			||||||
    SERIAL_ECHO_MSG("  G29 I99");
 | 
					    SERIAL_ECHO_MSG("  G29 I99");
 | 
				
			||||||
    LOOP_L_N(x, GRID_MAX_POINTS_X)
 | 
					    GRID_LOOP(x, y)
 | 
				
			||||||
      for (uint8_t y = 0;  y < GRID_MAX_POINTS_Y; y++)
 | 
					 | 
				
			||||||
      if (!isnan(z_values[x][y])) {
 | 
					      if (!isnan(z_values[x][y])) {
 | 
				
			||||||
        SERIAL_ECHO_START();
 | 
					        SERIAL_ECHO_START();
 | 
				
			||||||
        SERIAL_ECHOPAIR("  M421 I", int(x), " J", int(y));
 | 
					        SERIAL_ECHOPAIR("  M421 I", int(x), " J", int(y));
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -155,17 +155,14 @@ void GcodeSuite::M420() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            // Get the sum and average of all mesh values
 | 
					            // Get the sum and average of all mesh values
 | 
				
			||||||
            float mesh_sum = 0;
 | 
					            float mesh_sum = 0;
 | 
				
			||||||
            for (uint8_t x = GRID_MAX_POINTS_X; x--;)
 | 
					            GRID_LOOP(x, y) mesh_sum += Z_VALUES(x, y);
 | 
				
			||||||
              for (uint8_t y = GRID_MAX_POINTS_Y; y--;)
 | 
					 | 
				
			||||||
                mesh_sum += Z_VALUES(x, y);
 | 
					 | 
				
			||||||
            const float zmean = mesh_sum / float(GRID_MAX_POINTS);
 | 
					            const float zmean = mesh_sum / float(GRID_MAX_POINTS);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          #else
 | 
					          #else
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Find the low and high mesh values
 | 
					            // Find the low and high mesh values
 | 
				
			||||||
            float lo_val = 100, hi_val = -100;
 | 
					            float lo_val = 100, hi_val = -100;
 | 
				
			||||||
            for (uint8_t x = GRID_MAX_POINTS_X; x--;)
 | 
					            GRID_LOOP(x, y) {
 | 
				
			||||||
              for (uint8_t y = GRID_MAX_POINTS_Y; y--;) {
 | 
					 | 
				
			||||||
              const float z = Z_VALUES(x, y);
 | 
					              const float z = Z_VALUES(x, y);
 | 
				
			||||||
              NOMORE(lo_val, z);
 | 
					              NOMORE(lo_val, z);
 | 
				
			||||||
              NOLESS(hi_val, z);
 | 
					              NOLESS(hi_val, z);
 | 
				
			||||||
@@ -179,8 +176,7 @@ void GcodeSuite::M420() {
 | 
				
			|||||||
          if (!NEAR_ZERO(zmean)) {
 | 
					          if (!NEAR_ZERO(zmean)) {
 | 
				
			||||||
            set_bed_leveling_enabled(false);
 | 
					            set_bed_leveling_enabled(false);
 | 
				
			||||||
            // Subtract the mean from all values
 | 
					            // Subtract the mean from all values
 | 
				
			||||||
            for (uint8_t x = GRID_MAX_POINTS_X; x--;)
 | 
					            GRID_LOOP(x, y) {
 | 
				
			||||||
              for (uint8_t y = GRID_MAX_POINTS_Y; y--;) {
 | 
					 | 
				
			||||||
              Z_VALUES(x, y) -= zmean;
 | 
					              Z_VALUES(x, y) -= zmean;
 | 
				
			||||||
              #if ENABLED(EXTENSIBLE_UI)
 | 
					              #if ENABLED(EXTENSIBLE_UI)
 | 
				
			||||||
                ExtUI::onMeshUpdate(x, y, Z_VALUES(x, y));
 | 
					                ExtUI::onMeshUpdate(x, y, Z_VALUES(x, y));
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user