Przeglądaj źródła

use progmem instead of sram for mesh_index_to_x/ypos array;

fix maximum mesh_index_ array size at 16 (15+1);
Brian 7 lat temu
rodzic
commit
f1a4758cef
5 zmienionych plików z 78 dodań i 56 usunięć
  1. 10
    10
      Marlin/G26_Mesh_Validation_Tool.cpp
  2. 6
    7
      Marlin/ubl.cpp
  3. 37
    16
      Marlin/ubl.h
  4. 17
    15
      Marlin/ubl_G29.cpp
  5. 8
    8
      Marlin/ubl_motion.cpp

+ 10
- 10
Marlin/G26_Mesh_Validation_Tool.cpp Wyświetl plik

@@ -256,8 +256,8 @@
256 256
         : find_closest_circle_to_print(x_pos, y_pos); // Find the closest Mesh Intersection to where we are now.
257 257
 
258 258
       if (location.x_index >= 0 && location.y_index >= 0) {
259
-        const float circle_x = ubl.mesh_index_to_xpos[location.x_index],
260
-                    circle_y = ubl.mesh_index_to_ypos[location.y_index];
259
+        const float circle_x = pgm_read_float(&(ubl.mesh_index_to_xpos[location.x_index])),
260
+                    circle_y = pgm_read_float(&(ubl.mesh_index_to_ypos[location.y_index]));
261 261
 
262 262
         // Let's do a couple of quick sanity checks.  We can pull this code out later if we never see it catch a problem
263 263
         #ifdef DELTA
@@ -399,8 +399,8 @@
399 399
     for (uint8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
400 400
       for (uint8_t j = 0; j < GRID_MAX_POINTS_Y; j++) {
401 401
         if (!is_bit_set(circle_flags, i, j)) {
402
-          const float mx = ubl.mesh_index_to_xpos[i],  // We found a circle that needs to be printed
403
-                      my = ubl.mesh_index_to_ypos[j];
402
+          const float mx = pgm_read_float(&(ubl.mesh_index_to_xpos[i])),  // We found a circle that needs to be printed
403
+                      my = pgm_read_float(&(ubl.mesh_index_to_ypos[j]));
404 404
 
405 405
           // Get the distance to this intersection
406 406
           float f = HYPOT(X - mx, Y - my);
@@ -444,11 +444,11 @@
444 444
               // We found two circles that need a horizontal line to connect them
445 445
               // Print it!
446 446
               //
447
-              sx = ubl.mesh_index_to_xpos[  i  ] + (SIZE_OF_INTERSECTION_CIRCLES - (SIZE_OF_CROSSHAIRS)); // right edge
448
-              ex = ubl.mesh_index_to_xpos[i + 1] - (SIZE_OF_INTERSECTION_CIRCLES - (SIZE_OF_CROSSHAIRS)); // left edge
447
+              sx = pgm_read_float(&(ubl.mesh_index_to_xpos[  i  ])) + (SIZE_OF_INTERSECTION_CIRCLES - (SIZE_OF_CROSSHAIRS)); // right edge
448
+              ex = pgm_read_float(&(ubl.mesh_index_to_xpos[i + 1])) - (SIZE_OF_INTERSECTION_CIRCLES - (SIZE_OF_CROSSHAIRS)); // left edge
449 449
 
450 450
               sx = constrain(sx, X_MIN_POS + 1, X_MAX_POS - 1);
451
-              sy = ey = constrain(ubl.mesh_index_to_ypos[j], Y_MIN_POS + 1, Y_MAX_POS - 1);
451
+              sy = ey = constrain(pgm_read_float(&(ubl.mesh_index_to_ypos[j])), Y_MIN_POS + 1, Y_MAX_POS - 1);
452 452
               ex = constrain(ex, X_MIN_POS + 1, X_MAX_POS - 1);
453 453
 
454 454
               if (ubl.g26_debug_flag) {
@@ -475,10 +475,10 @@
475 475
                 // We found two circles that need a vertical line to connect them
476 476
                 // Print it!
477 477
                 //
478
-                sy = ubl.mesh_index_to_ypos[  j  ] + (SIZE_OF_INTERSECTION_CIRCLES - (SIZE_OF_CROSSHAIRS)); // top edge
479
-                ey = ubl.mesh_index_to_ypos[j + 1] - (SIZE_OF_INTERSECTION_CIRCLES - (SIZE_OF_CROSSHAIRS)); // bottom edge
478
+                sy = pgm_read_float(&(ubl.mesh_index_to_ypos[  j  ])) + (SIZE_OF_INTERSECTION_CIRCLES - (SIZE_OF_CROSSHAIRS)); // top edge
479
+                ey = pgm_read_float(&(ubl.mesh_index_to_ypos[j + 1])) - (SIZE_OF_INTERSECTION_CIRCLES - (SIZE_OF_CROSSHAIRS)); // bottom edge
480 480
 
481
-                sx = ex = constrain(ubl.mesh_index_to_xpos[i], X_MIN_POS + 1, X_MAX_POS - 1);
481
+                sx = ex = constrain(pgm_read_float(&(ubl.mesh_index_to_xpos[i])), X_MIN_POS + 1, X_MAX_POS - 1);
482 482
                 sy = constrain(sy, Y_MIN_POS + 1, Y_MAX_POS - 1);
483 483
                 ey = constrain(ey, Y_MIN_POS + 1, Y_MAX_POS - 1);
484 484
 

+ 6
- 7
Marlin/ubl.cpp Wyświetl plik

@@ -60,9 +60,12 @@
60 60
   ubl_state unified_bed_leveling::state, unified_bed_leveling::pre_initialized;
61 61
 
62 62
   float unified_bed_leveling::z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y],
63
-        unified_bed_leveling::last_specified_z,
64
-        unified_bed_leveling::mesh_index_to_xpos[GRID_MAX_POINTS_X + 1], // +1 safety margin for now, until determinism prevails
65
-        unified_bed_leveling::mesh_index_to_ypos[GRID_MAX_POINTS_Y + 1];
63
+        unified_bed_leveling::last_specified_z;
64
+
65
+  // 15 is the maximum nubmer of grid points supported + 1 safety margin for now,
66
+  // until determinism prevails
67
+  constexpr float unified_bed_leveling::mesh_index_to_xpos[16],
68
+                  unified_bed_leveling::mesh_index_to_ypos[16];
66 69
 
67 70
   bool unified_bed_leveling::g26_debug_flag = false,
68 71
        unified_bed_leveling::has_control_of_lcd_panel = false;
@@ -72,10 +75,6 @@
72 75
   volatile int unified_bed_leveling::encoder_diff;
73 76
 
74 77
   unified_bed_leveling::unified_bed_leveling() {
75
-    for (uint8_t i = 0; i < COUNT(mesh_index_to_xpos); i++)
76
-      mesh_index_to_xpos[i] = UBL_MESH_MIN_X + i * (MESH_X_DIST);
77
-    for (uint8_t i = 0; i < COUNT(mesh_index_to_ypos); i++)
78
-      mesh_index_to_ypos[i] = UBL_MESH_MIN_Y + i * (MESH_Y_DIST);
79 78
     reset();
80 79
   }
81 80
 

+ 37
- 16
Marlin/ubl.h Wyświetl plik

@@ -119,12 +119,31 @@
119 119
 
120 120
       static ubl_state state, pre_initialized;
121 121
 
122
-      static float z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y],
123
-                   mesh_index_to_xpos[GRID_MAX_POINTS_X + 1], // +1 safety margin for now, until determinism prevails
124
-                   mesh_index_to_ypos[GRID_MAX_POINTS_Y + 1];
125
-
126
-      static bool g26_debug_flag,
127
-                  has_control_of_lcd_panel;
122
+      static float z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
123
+
124
+      // 15 is the maximum nubmer of grid points supported + 1 safety margin for now,
125
+      // until determinism prevails
126
+      constexpr static float mesh_index_to_xpos[16] PROGMEM = { UBL_MESH_MIN_X+0*(MESH_X_DIST),
127
+                                UBL_MESH_MIN_X+1*(MESH_X_DIST), UBL_MESH_MIN_X+2*(MESH_X_DIST),
128
+                                UBL_MESH_MIN_X+3*(MESH_X_DIST), UBL_MESH_MIN_X+4*(MESH_X_DIST),
129
+                                UBL_MESH_MIN_X+5*(MESH_X_DIST), UBL_MESH_MIN_X+6*(MESH_X_DIST),
130
+                                UBL_MESH_MIN_X+7*(MESH_X_DIST), UBL_MESH_MIN_X+8*(MESH_X_DIST),
131
+                                UBL_MESH_MIN_X+9*(MESH_X_DIST), UBL_MESH_MIN_X+10*(MESH_X_DIST),
132
+                                UBL_MESH_MIN_X+11*(MESH_X_DIST), UBL_MESH_MIN_X+12*(MESH_X_DIST),
133
+                                UBL_MESH_MIN_X+13*(MESH_X_DIST), UBL_MESH_MIN_X+14*(MESH_X_DIST),
134
+                                UBL_MESH_MIN_X+15*(MESH_X_DIST) };
135
+
136
+      constexpr static float mesh_index_to_ypos[16] PROGMEM = { UBL_MESH_MIN_Y+0*(MESH_Y_DIST),
137
+                                UBL_MESH_MIN_Y+1*(MESH_Y_DIST), UBL_MESH_MIN_Y+2*(MESH_Y_DIST),
138
+                                UBL_MESH_MIN_Y+3*(MESH_Y_DIST), UBL_MESH_MIN_Y+4*(MESH_Y_DIST),
139
+                                UBL_MESH_MIN_Y+5*(MESH_Y_DIST), UBL_MESH_MIN_Y+6*(MESH_Y_DIST),
140
+                                UBL_MESH_MIN_Y+7*(MESH_Y_DIST), UBL_MESH_MIN_Y+8*(MESH_Y_DIST),
141
+                                UBL_MESH_MIN_Y+9*(MESH_Y_DIST), UBL_MESH_MIN_Y+10*(MESH_Y_DIST),
142
+                                UBL_MESH_MIN_Y+11*(MESH_Y_DIST), UBL_MESH_MIN_Y+12*(MESH_Y_DIST),
143
+                                UBL_MESH_MIN_Y+13*(MESH_Y_DIST), UBL_MESH_MIN_Y+14*(MESH_Y_DIST),
144
+                                UBL_MESH_MIN_Y+15*(MESH_Y_DIST) };
145
+
146
+      static bool g26_debug_flag, has_control_of_lcd_panel;
128 147
 
129 148
       static int8_t eeprom_start;
130 149
 
@@ -204,7 +223,7 @@
204 223
           return NAN;
205 224
         }
206 225
 
207
-        const float xratio = (RAW_X_POSITION(lx0) - mesh_index_to_xpos[x1_i]) * (1.0 / (MESH_X_DIST)),
226
+        const float xratio = (RAW_X_POSITION(lx0) - pgm_read_float(&mesh_index_to_xpos[x1_i])) * (1.0 / (MESH_X_DIST)),
208 227
                     z1 = z_values[x1_i][yi];
209 228
 
210 229
         return z1 + xratio * (z_values[x1_i + 1][yi] - z1);
@@ -223,7 +242,7 @@
223 242
           return NAN;
224 243
         }
225 244
 
226
-        const float yratio = (RAW_Y_POSITION(ly0) - mesh_index_to_ypos[y1_i]) * (1.0 / (MESH_Y_DIST)),
245
+        const float yratio = (RAW_Y_POSITION(ly0) - pgm_read_float(&mesh_index_to_ypos[y1_i])) * (1.0 / (MESH_Y_DIST)),
227 246
                     z1 = z_values[xi][y1_i];
228 247
 
229 248
         return z1 + yratio * (z_values[xi][y1_i + 1] - z1);
@@ -254,14 +273,16 @@
254 273
         }
255 274
 
256 275
         const float z1 = calc_z0(RAW_X_POSITION(lx0),
257
-                      mesh_index_to_xpos[cx], z_values[cx][cy],
258
-                      mesh_index_to_xpos[cx + 1], z_values[cx + 1][cy]),
259
-                    z2 = calc_z0(RAW_X_POSITION(lx0),
260
-                      mesh_index_to_xpos[cx], z_values[cx][cy + 1],
261
-                      mesh_index_to_xpos[cx + 1], z_values[cx + 1][cy + 1]);
262
-              float z0 = calc_z0(RAW_Y_POSITION(ly0),
263
-                  mesh_index_to_ypos[cy], z1,
264
-                  mesh_index_to_ypos[cy + 1], z2);
276
+                                 pgm_read_float(&mesh_index_to_xpos[cx]), z_values[cx][cy],
277
+                                 pgm_read_float(&mesh_index_to_xpos[cx + 1]), z_values[cx + 1][cy]);
278
+
279
+        const float z2 = calc_z0(RAW_X_POSITION(lx0),
280
+                                 pgm_read_float(&mesh_index_to_xpos[cx]), z_values[cx][cy + 1],
281
+                                 pgm_read_float(&mesh_index_to_xpos[cx + 1]), z_values[cx + 1][cy + 1]);
282
+
283
+        float z0 = calc_z0(RAW_Y_POSITION(ly0),
284
+                           pgm_read_float(&mesh_index_to_ypos[cy]), z1,
285
+                           pgm_read_float(&mesh_index_to_ypos[cy + 1]), z2);
265 286
 
266 287
         #if ENABLED(DEBUG_LEVELING_FEATURE)
267 288
           if (DEBUGGING(MESH_ADJUST)) {

+ 17
- 15
Marlin/ubl_G29.cpp Wyświetl plik

@@ -757,8 +757,8 @@
757 757
       location = find_closest_mesh_point_of_type(INVALID, lx, ly, 1, NULL, do_furthest);  // the '1' says we want the location to be relative to the probe
758 758
       if (location.x_index >= 0 && location.y_index >= 0) {
759 759
 
760
-        const float rawx = ubl.mesh_index_to_xpos[location.x_index],
761
-                    rawy = ubl.mesh_index_to_ypos[location.y_index];
760
+        const float rawx = pgm_read_float(&(ubl.mesh_index_to_xpos[location.x_index])),
761
+                    rawy = pgm_read_float(&(ubl.mesh_index_to_ypos[location.y_index]));
762 762
 
763 763
         // TODO: Change to use `position_is_reachable` (for SCARA-compatibility)
764 764
         if (!WITHIN(rawx, MIN_PROBE_X, MAX_PROBE_X) || !WITHIN(rawy, MIN_PROBE_Y, MAX_PROBE_Y)) {
@@ -905,8 +905,8 @@
905 905
       // It doesn't matter if the probe can't reach the NAN location. This is a manual probe.
906 906
       if (location.x_index < 0 && location.y_index < 0) continue;
907 907
 
908
-      const float rawx = ubl.mesh_index_to_xpos[location.x_index],
909
-                  rawy = ubl.mesh_index_to_ypos[location.y_index];
908
+      const float rawx = pgm_read_float(&(ubl.mesh_index_to_xpos[location.x_index])),
909
+                  rawy = pgm_read_float(&(ubl.mesh_index_to_ypos[location.y_index]));
910 910
 
911 911
       // TODO: Change to use `position_is_reachable` (for SCARA-compatibility)
912 912
       if (!WITHIN(rawx, X_MIN_POS, X_MAX_POS) || !WITHIN(rawy, Y_MIN_POS, Y_MAX_POS)) {
@@ -1174,7 +1174,7 @@
1174 1174
 
1175 1175
     SERIAL_PROTOCOLPGM("X-Axis Mesh Points at: ");
1176 1176
     for (uint8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
1177
-      SERIAL_PROTOCOL_F(LOGICAL_X_POSITION(ubl.mesh_index_to_xpos[i]), 1);
1177
+      SERIAL_PROTOCOL_F(LOGICAL_X_POSITION(pgm_read_float(&(ubl.mesh_index_to_xpos[i]))), 1);
1178 1178
       SERIAL_PROTOCOLPGM("  ");
1179 1179
       safe_delay(50);
1180 1180
     }
@@ -1182,7 +1182,7 @@
1182 1182
 
1183 1183
     SERIAL_PROTOCOLPGM("Y-Axis Mesh Points at: ");
1184 1184
     for (uint8_t i = 0; i < GRID_MAX_POINTS_Y; i++) {
1185
-      SERIAL_PROTOCOL_F(LOGICAL_Y_POSITION(ubl.mesh_index_to_ypos[i]), 1);
1185
+      SERIAL_PROTOCOL_F(LOGICAL_Y_POSITION(pgm_read_float(&(ubl.mesh_index_to_ypos[i]))), 1);
1186 1186
       SERIAL_PROTOCOLPGM("  ");
1187 1187
       safe_delay(50);
1188 1188
     }
@@ -1320,8 +1320,8 @@
1320 1320
 
1321 1321
           // We only get here if we found a Mesh Point of the specified type
1322 1322
 
1323
-          const float rawx = ubl.mesh_index_to_xpos[i], // Check if we can probe this mesh location
1324
-                      rawy = ubl.mesh_index_to_ypos[j];
1323
+          const float rawx = pgm_read_float(&(ubl.mesh_index_to_xpos[i])), // Check if we can probe this mesh location
1324
+                      rawy = pgm_read_float(&(ubl.mesh_index_to_ypos[j]));
1325 1325
 
1326 1326
           // If using the probe as the reference there are some unreachable locations.
1327 1327
           // Prune them from the list and ignore them till the next Phase (manual nozzle probing).
@@ -1386,8 +1386,8 @@
1386 1386
       bit_clear(not_done, location.x_index, location.y_index);  // Mark this location as 'adjusted' so we will find a
1387 1387
                                                                 // different location the next time through the loop
1388 1388
 
1389
-      const float rawx = ubl.mesh_index_to_xpos[location.x_index],
1390
-                  rawy = ubl.mesh_index_to_ypos[location.y_index];
1389
+      const float rawx = pgm_read_float(&(ubl.mesh_index_to_xpos[location.x_index])),
1390
+                  rawy = pgm_read_float(&(ubl.mesh_index_to_ypos[location.y_index]));
1391 1391
 
1392 1392
       // TODO: Change to use `position_is_reachable` (for SCARA-compatibility)
1393 1393
       if (!WITHIN(rawx, X_MIN_POS, X_MAX_POS) || !WITHIN(rawy, Y_MIN_POS, Y_MAX_POS)) { // In theory, we don't need this check.
@@ -1482,7 +1482,8 @@
1482 1482
       //find min & max probeable points in the mesh
1483 1483
       for (xCount = 0; xCount < GRID_MAX_POINTS_X; xCount++) {
1484 1484
         for (yCount = 0; yCount < GRID_MAX_POINTS_Y; yCount++) {
1485
-          if (WITHIN(ubl.mesh_index_to_xpos[xCount], MIN_PROBE_X, MAX_PROBE_X) && WITHIN(ubl.mesh_index_to_ypos[yCount], MIN_PROBE_Y, MAX_PROBE_Y)) {
1485
+          if (WITHIN(pgm_read_float(&(ubl.mesh_index_to_xpos[xCount])), MIN_PROBE_X, MAX_PROBE_X) &&
1486
+              WITHIN(pgm_read_float(&(ubl.mesh_index_to_ypos[yCount])), MIN_PROBE_Y, MAX_PROBE_Y)) {
1486 1487
             NOMORE(x_min, xCount);
1487 1488
             NOLESS(x_max, xCount);
1488 1489
             NOMORE(y_min, yCount);
@@ -1577,11 +1578,12 @@
1577 1578
           }
1578 1579
           //SERIAL_ECHOPAIR("\nCheckpoint: ", 5);
1579 1580
 
1580
-          const float probeX = ubl.mesh_index_to_xpos[grid_G_index_to_xpos[xCount]],  //where we want the probe to be
1581
-          probeY = ubl.mesh_index_to_ypos[grid_G_index_to_ypos[yCount]];
1581
+          const float probeX = pgm_read_float(&(ubl.mesh_index_to_xpos[grid_G_index_to_xpos[xCount]])),  //where we want the probe to be
1582
+                      probeY = pgm_read_float(&(ubl.mesh_index_to_ypos[grid_G_index_to_ypos[yCount]]));
1582 1583
           //SERIAL_ECHOPAIR("\nCheckpoint: ", 6);
1583 1584
 
1584
-          const float measured_z = probe_pt(LOGICAL_X_POSITION(probeX), LOGICAL_Y_POSITION(probeY), code_seen('E'), (code_seen('V') && code_has_value()) ? code_value_int() : 0);  // takes into account the offsets
1585
+          const float measured_z = probe_pt(LOGICAL_X_POSITION(probeX), LOGICAL_Y_POSITION(probeY), code_seen('E'),
1586
+                                            (code_seen('V') && code_has_value()) ? code_value_int() : 0);  // takes into account the offsets
1585 1587
 
1586 1588
           //SERIAL_ECHOPAIR("\nmeasured_z: ", measured_z);
1587 1589
 
@@ -1595,7 +1597,7 @@
1595 1597
       restore_ubl_active_state_and_leave();
1596 1598
 
1597 1599
       // ?? ubl.has_control_of_lcd_panel = true;
1598
-      //do_blocking_move_to_xy(ubl.mesh_index_to_xpos[grid_G_index_to_xpos[0]], ubl.mesh_index_to_ypos[grid_G_index_to_ypos[0]]);
1600
+      //do_blocking_move_to_xy(pgm_read_float(&(ubl.mesh_index_to_xpos[grid_G_index_to_xpos[0]])),pgm_read_float(&(ubl.mesh_index_to_ypos[grid_G_index_to_ypos[0]])));
1599 1601
 
1600 1602
       // least squares code
1601 1603
       double xxx5[] = { 0,50,100,150,200,      20,70,120,165,195,     0,50,100,150,200,      0,55,100,150,200,      0,65,100,150,205 },

+ 8
- 8
Marlin/ubl_motion.cpp Wyświetl plik

@@ -154,7 +154,7 @@
154 154
        * to create a 1-over number for us. That will allow us to do a floating point multiply instead of a floating point divide.
155 155
        */
156 156
 
157
-      const float xratio = (RAW_X_POSITION(end[X_AXIS]) - ubl.mesh_index_to_xpos[cell_dest_xi]) * (1.0 / (MESH_X_DIST)),
157
+      const float xratio = (RAW_X_POSITION(end[X_AXIS]) - pgm_read_float(&(ubl.mesh_index_to_xpos[cell_dest_xi]))) * (1.0 / (MESH_X_DIST)),
158 158
                   z1 = ubl.z_values[cell_dest_xi    ][cell_dest_yi    ] + xratio *
159 159
                       (ubl.z_values[cell_dest_xi + 1][cell_dest_yi    ] - ubl.z_values[cell_dest_xi][cell_dest_yi    ]),
160 160
                   z2 = ubl.z_values[cell_dest_xi    ][cell_dest_yi + 1] + xratio *
@@ -163,7 +163,7 @@
163 163
       // we are done with the fractional X distance into the cell. Now with the two Z-Heights we have calculated, we
164 164
       // are going to apply the Y-Distance into the cell to interpolate the final Z correction.
165 165
 
166
-      const float yratio = (RAW_Y_POSITION(end[Y_AXIS]) - ubl.mesh_index_to_ypos[cell_dest_yi]) * (1.0 / (MESH_Y_DIST));
166
+      const float yratio = (RAW_Y_POSITION(end[Y_AXIS]) - pgm_read_float(&(ubl.mesh_index_to_ypos[cell_dest_yi]))) * (1.0 / (MESH_Y_DIST));
167 167
 
168 168
       float z0 = z1 + (z2 - z1) * yratio;
169 169
 
@@ -262,7 +262,7 @@
262 262
       current_yi += down_flag;  // Line is heading down, we just want to go to the bottom
263 263
       while (current_yi != cell_dest_yi + down_flag) {
264 264
         current_yi += dyi;
265
-        const float next_mesh_line_y = LOGICAL_Y_POSITION(ubl.mesh_index_to_ypos[current_yi]);
265
+        const float next_mesh_line_y = LOGICAL_Y_POSITION(pgm_read_float(&(ubl.mesh_index_to_ypos[current_yi])));
266 266
 
267 267
         /**
268 268
          * inf_m_flag? the slope of the line is infinite, we won't do the calculations
@@ -304,7 +304,7 @@
304 304
          */
305 305
         if (isnan(z0)) z0 = 0.0;
306 306
 
307
-        const float y = LOGICAL_Y_POSITION(ubl.mesh_index_to_ypos[current_yi]);
307
+        const float y = LOGICAL_Y_POSITION(pgm_read_float(&(ubl.mesh_index_to_ypos[current_yi])));
308 308
 
309 309
         /**
310 310
          * Without this check, it is possible for the algorithm to generate a zero length move in the case
@@ -353,7 +353,7 @@
353 353
                                 // edge of this cell for the first move.
354 354
       while (current_xi != cell_dest_xi + left_flag) {
355 355
         current_xi += dxi;
356
-        const float next_mesh_line_x = LOGICAL_X_POSITION(ubl.mesh_index_to_xpos[current_xi]),
356
+        const float next_mesh_line_x = LOGICAL_X_POSITION(pgm_read_float(&(ubl.mesh_index_to_xpos[current_xi]))),
357 357
                     y = m * next_mesh_line_x + c;   // Calculate X at the next Y mesh line
358 358
 
359 359
         float z0 = ubl.z_correction_for_y_on_vertical_mesh_line(y, current_xi, current_yi);
@@ -389,7 +389,7 @@
389 389
          */
390 390
         if (isnan(z0)) z0 = 0.0;
391 391
 
392
-        const float x = LOGICAL_X_POSITION(ubl.mesh_index_to_xpos[current_xi]);
392
+        const float x = LOGICAL_X_POSITION(pgm_read_float(&(ubl.mesh_index_to_xpos[current_xi])));
393 393
 
394 394
         /**
395 395
          * Without this check, it is possible for the algorithm to generate a zero length move in the case
@@ -439,8 +439,8 @@
439 439
 
440 440
     while (xi_cnt > 0 || yi_cnt > 0) {
441 441
 
442
-      const float next_mesh_line_x = LOGICAL_X_POSITION(ubl.mesh_index_to_xpos[current_xi + dxi]),
443
-                  next_mesh_line_y = LOGICAL_Y_POSITION(ubl.mesh_index_to_ypos[current_yi + dyi]),
442
+      const float next_mesh_line_x = LOGICAL_X_POSITION(pgm_read_float(&(ubl.mesh_index_to_xpos[current_xi + dxi]))),
443
+                  next_mesh_line_y = LOGICAL_Y_POSITION(pgm_read_float(&(ubl.mesh_index_to_ypos[current_yi + dyi]))),
444 444
                   y = m * next_mesh_line_x + c,   // Calculate Y at the next X mesh line
445 445
                   x = (next_mesh_line_y - c) / m; // Calculate X at the next Y mesh line
446 446
                                                   // (No need to worry about m being zero.

Ładowanie…
Anuluj
Zapisz