Explorar el Código

Basic UBL operations working on 32-bit platforms (#8024)

* 32-bit work for UBL

* Update FT i3-2020 reference file
Roxy-3D hace 8 años
padre
commit
5439358281

+ 2
- 2
Marlin/src/HAL/HAL_LPC1768/persistent_store_impl.cpp Ver fichero

@@ -21,7 +21,7 @@ FIL eeprom_file;
21 21
 bool access_start() {
22 22
   UINT file_size = 0,
23 23
        bytes_written = 0;
24
-  const char eeprom_zero = 0xFF;
24
+  const char eeprom_erase_value = 0xFF;
25 25
   MSC_Aquire_Lock();
26 26
   if (f_mount(&fat_fs, "", 1)) {
27 27
     MSC_Release_Lock();
@@ -35,7 +35,7 @@ bool access_start() {
35 35
   if (res == FR_OK) {
36 36
     f_lseek(&eeprom_file, file_size);
37 37
     while (file_size <= E2END && res == FR_OK) {
38
-      res = f_write(&eeprom_file, &eeprom_zero, 1, &bytes_written);
38
+      res = f_write(&eeprom_file, &eeprom_erase_value, 1, &bytes_written);
39 39
       file_size++;
40 40
     }
41 41
   }

+ 2
- 2
Marlin/src/config/examples/Folger Tech/i3-2020/Configuration.h Ver fichero

@@ -125,7 +125,7 @@
125 125
 
126 126
 // Optional custom name for your RepStrap or other custom machine
127 127
 // Displayed in the LCD "Ready" message
128
-#define CUSTOM_MACHINE_NAME "FT-2020 v3"
128
+#define CUSTOM_MACHINE_NAME "FT-2020 v4"
129 129
 
130 130
 // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines)
131 131
 // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4)
@@ -1677,7 +1677,7 @@
1677 1677
 // Servo deactivation
1678 1678
 //
1679 1679
 // With this option servos are powered only during movement, then turned off to prevent jitter.
1680
-#define DEACTIVATE_SERVOS_AFTER_MOVE
1680
+//#define DEACTIVATE_SERVOS_AFTER_MOVE
1681 1681
 
1682 1682
 /**
1683 1683
  * Filament Width Sensor

+ 1
- 1
Marlin/src/config/examples/Folger Tech/i3-2020/Configuration_adv.h Ver fichero

@@ -1338,7 +1338,7 @@
1338 1338
  * For clients that use a fixed-width font (like OctoPrint), leave this set to 1.0.
1339 1339
  * Otherwise, adjust according to your client and font.
1340 1340
  */
1341
-#define PROPORTIONAL_FONT_RATIO 1.5
1341
+#define PROPORTIONAL_FONT_RATIO 2.2
1342 1342
 
1343 1343
 /**
1344 1344
  * Spend 28 bytes of SRAM to optimize the GCode parser

+ 1
- 1
Marlin/src/feature/bedlevel/ubl/G26_Mesh_Validation_Tool.cpp Ver fichero

@@ -143,7 +143,7 @@
143 143
 // Private functions
144 144
 
145 145
 static uint16_t circle_flags[16], horizontal_mesh_line_flags[16], vertical_mesh_line_flags[16];
146
-float g26_e_axis_feedrate = 0.020,
146
+float g26_e_axis_feedrate = 0.025,
147 147
       random_deviation = 0.0;
148 148
 
149 149
 static bool g26_retracted = false; // Track the retracted state of the nozzle so mismatched

+ 2
- 1
Marlin/src/feature/bedlevel/ubl/ubl.h Ver fichero

@@ -141,7 +141,8 @@ class unified_bed_leveling {
141 141
     static void save_ubl_active_state_and_disable();
142 142
     static void restore_ubl_active_state_and_leave();
143 143
     static void display_map(const int);
144
-    static mesh_index_pair find_closest_mesh_point_of_type(const MeshPointType, const float&, const float&, const bool, uint16_t[16], bool);
144
+    static mesh_index_pair find_closest_mesh_point_of_type(const MeshPointType, const float&, const float&, const bool, uint16_t[16]);
145
+    static mesh_index_pair find_furthest_invalid_mesh_point();
145 146
     static void reset();
146 147
     static void invalidate();
147 148
     static void set_all_mesh_points_to_value(const float);

+ 87
- 46
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp Ver fichero

@@ -333,7 +333,7 @@
333 333
       else {
334 334
         while (g29_repetition_cnt--) {
335 335
           if (cnt > 20) { cnt = 0; idle(); }
336
-          const mesh_index_pair location = find_closest_mesh_point_of_type(REAL, g29_x_pos, g29_y_pos, USE_NOZZLE_AS_REFERENCE, NULL, false);
336
+          const mesh_index_pair location = find_closest_mesh_point_of_type(REAL, g29_x_pos, g29_y_pos, USE_NOZZLE_AS_REFERENCE, NULL);
337 337
           if (location.x_index < 0) {
338 338
             // No more REACHABLE mesh points to invalidate, so we ASSUME the user
339 339
             // meant to invalidate the ENTIRE mesh, which cannot be done with
@@ -529,7 +529,7 @@
529 529
             }
530 530
             else {
531 531
               while (g29_repetition_cnt--) {  // this only populates reachable mesh points near
532
-                const mesh_index_pair location = find_closest_mesh_point_of_type(INVALID, g29_x_pos, g29_y_pos, USE_NOZZLE_AS_REFERENCE, NULL, false);
532
+                const mesh_index_pair location = find_closest_mesh_point_of_type(INVALID, g29_x_pos, g29_y_pos, USE_NOZZLE_AS_REFERENCE, NULL);
533 533
                 if (location.x_index < 0) {
534 534
                   // No more REACHABLE INVALID mesh points to populate, so we ASSUME
535 535
                   // user meant to populate ALL INVALID mesh points to value
@@ -744,6 +744,8 @@
744 744
       uint16_t max_iterations = GRID_MAX_POINTS;
745 745
 
746 746
       do {
747
+        if (do_ubl_mesh_map) display_map(g29_map_type);
748
+
747 749
         #if ENABLED(NEWPANEL)
748 750
           if (ubl_lcd_clicked()) {
749 751
             SERIAL_PROTOCOLLNPGM("\nMesh only partially populated.\n");
@@ -757,7 +759,10 @@
757 759
           }
758 760
         #endif
759 761
 
760
-        location = find_closest_mesh_point_of_type(INVALID, lx, ly, USE_PROBE_AS_REFERENCE, NULL, close_or_far);
762
+        if (close_or_far)
763
+          location = find_furthest_invalid_mesh_point();
764
+        else
765
+          location = find_closest_mesh_point_of_type(INVALID, lx, ly, USE_PROBE_AS_REFERENCE, NULL);
761 766
 
762 767
         if (location.x_index >= 0) {    // mesh point found and is reachable by probe
763 768
           const float rawx = mesh_index_to_xpos(location.x_index),
@@ -767,8 +772,6 @@
767 772
           z_values[location.x_index][location.y_index] = measured_z;
768 773
         }
769 774
 
770
-        if (do_ubl_mesh_map) display_map(g29_map_type);
771
-
772 775
       } while (location.x_index >= 0 && --max_iterations);
773 776
 
774 777
       STOW_PROBE();
@@ -962,7 +965,7 @@
962 965
 
963 966
       mesh_index_pair location;
964 967
       do {
965
-        location = find_closest_mesh_point_of_type(INVALID, lx, ly, USE_NOZZLE_AS_REFERENCE, NULL, false);
968
+        location = find_closest_mesh_point_of_type(INVALID, lx, ly, USE_NOZZLE_AS_REFERENCE, NULL);
966 969
         // It doesn't matter if the probe can't reach the NAN location. This is a manual probe.
967 970
         if (location.x_index < 0 && location.y_index < 0) continue;
968 971
 
@@ -1289,7 +1292,7 @@
1289 1292
    */
1290 1293
   void unified_bed_leveling::g29_eeprom_dump() {
1291 1294
     unsigned char cccc;
1292
-    uint16_t kkkk;
1295
+    unsigned int  kkkk;  // Needs to be of unspecfied size to compile clean on all platforms
1293 1296
 
1294 1297
     SERIAL_ECHO_START();
1295 1298
     SERIAL_ECHOLNPGM("EEPROM Dump:");
@@ -1299,7 +1302,7 @@
1299 1302
       SERIAL_ECHOPGM(": ");
1300 1303
       for (uint16_t j = 0; j < 16; j++) {
1301 1304
         kkkk = i + j;
1302
-        eeprom_read_block(&cccc, (void *)kkkk, 1);
1305
+        eeprom_read_block(&cccc, (const void *) kkkk, sizeof(unsigned char));
1303 1306
         print_hex_byte(cccc);
1304 1307
         SERIAL_ECHO(' ');
1305 1308
       }
@@ -1345,18 +1348,84 @@
1345 1348
         z_values[x][y] -= tmp_z_values[x][y];
1346 1349
   }
1347 1350
 
1348
-  mesh_index_pair unified_bed_leveling::find_closest_mesh_point_of_type(const MeshPointType type, const float &lx, const float &ly, const bool probe_as_reference, uint16_t bits[16], const bool far_flag) {
1351
+
1352
+  mesh_index_pair unified_bed_leveling::find_furthest_invalid_mesh_point() {
1353
+
1354
+    bool found_a_NAN  = false;
1355
+    bool found_a_real = false;
1349 1356
     mesh_index_pair out_mesh;
1350 1357
     out_mesh.x_index = out_mesh.y_index = -1;
1358
+    out_mesh.distance = -99999.99;
1359
+
1360
+    for (int8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
1361
+      for (int8_t j = 0; j < GRID_MAX_POINTS_Y; j++) {
1362
+
1363
+        if ( isnan(z_values[i][j])) { // Check to see if this location holds an invalid mesh point
1364
+
1365
+          const float mx = mesh_index_to_xpos(i),
1366
+                      my = mesh_index_to_ypos(j);
1367
+
1368
+          if ( !position_is_reachable_by_probe_raw_xy(mx, my))  // make sure the probe can get to the mesh point
1369
+            continue;
1370
+
1371
+          found_a_NAN = true;
1372
+
1373
+          int8_t closest_x=-1, closest_y=-1;
1374
+          float d1, d2 = 99999.9;
1375
+          for (int8_t k = 0; k < GRID_MAX_POINTS_X; k++) {
1376
+            for (int8_t l = 0; l < GRID_MAX_POINTS_Y; l++) {
1377
+              if (!isnan(z_values[k][l])) {
1378
+                found_a_real = true;
1379
+
1380
+          // Add in a random weighting factor that scrambles the probing of the
1381
+          // last half of the mesh (when every unprobed mesh point is one index
1382
+          // from a probed location).
1383
+
1384
+                d1 = HYPOT(i - k, j - l) + (1.0 / ((millis() % 47) + 13));
1385
+
1386
+                if (d1 < d2) {    // found a closer distance from invalid mesh point at (i,j) to defined mesh point at (k,l)
1387
+                  d2 = d1;       // found a closer location with
1388
+                  closest_x = i;    // an assigned mesh point value
1389
+                  closest_y = j;
1390
+                }
1391
+              }
1392
+            }
1393
+          }
1394
+
1395
+          //
1396
+          // at this point d2 should have the closest defined mesh point to invalid mesh point (i,j)
1397
+          //
1398
+
1399
+          if (found_a_real && (closest_x >= 0) && (d2 > out_mesh.distance)) {
1400
+            out_mesh.distance = d2;         // found an invalid location with a greater distance
1401
+            out_mesh.x_index = closest_x;   // to a defined mesh point
1402
+            out_mesh.y_index = closest_y;
1403
+          }
1404
+        }
1405
+      } // for j
1406
+    } // for i
1407
+
1408
+    if (!found_a_real && found_a_NAN) {        // if the mesh is totally unpopulated, start the probing
1409
+      out_mesh.x_index = GRID_MAX_POINTS_X / 2;
1410
+      out_mesh.y_index = GRID_MAX_POINTS_Y / 2;
1411
+      out_mesh.distance = 1.0;
1412
+    }
1413
+    return out_mesh;
1414
+  }
1415
+
1416
+  mesh_index_pair unified_bed_leveling::find_closest_mesh_point_of_type(const MeshPointType type, const float &lx, const float &ly, const bool probe_as_reference, uint16_t bits[16]) {
1417
+    mesh_index_pair out_mesh;
1418
+    out_mesh.x_index = out_mesh.y_index = -1;
1419
+    out_mesh.distance = -99999.9;
1351 1420
 
1352 1421
     // Get our reference position. Either the nozzle or probe location.
1353 1422
     const float px = RAW_X_POSITION(lx) - (probe_as_reference == USE_PROBE_AS_REFERENCE ? X_PROBE_OFFSET_FROM_EXTRUDER : 0),
1354 1423
                 py = RAW_Y_POSITION(ly) - (probe_as_reference == USE_PROBE_AS_REFERENCE ? Y_PROBE_OFFSET_FROM_EXTRUDER : 0);
1355 1424
 
1356
-    float best_so_far = far_flag ? -99999.99 : 99999.99;
1425
+    float best_so_far = 99999.99;
1357 1426
 
1358
-    for (uint8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
1359
-      for (uint8_t j = 0; j < GRID_MAX_POINTS_Y; j++) {
1427
+    for (int8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
1428
+      for (int8_t j = 0; j < GRID_MAX_POINTS_Y; j++) {
1360 1429
 
1361 1430
         if ( (type == INVALID && isnan(z_values[i][j]))  // Check to see if this location holds the right thing
1362 1431
           || (type == REAL && !isnan(z_values[i][j]))
@@ -1376,35 +1445,14 @@
1376 1445
             continue;
1377 1446
 
1378 1447
           // Reachable. Check if it's the best_so_far location to the nozzle.
1379
-          // Add in a weighting factor that considers the current location of the nozzle.
1380 1448
 
1381 1449
           float distance = HYPOT(px - mx, py - my);
1382 1450
 
1383
-          /**
1384
-           * If doing the far_flag action, we want to be as far as possible
1385
-           * from the starting point and from any other probed points. We
1386
-           * want the next point spread out and filling in any blank spaces
1387
-           * in the mesh. So we add in some of the distance to every probed
1388
-           * point we can find.
1389
-           */
1390
-          if (far_flag) {
1391
-            for (uint8_t k = 0; k < GRID_MAX_POINTS_X; k++) {
1392
-              for (uint8_t l = 0; l < GRID_MAX_POINTS_Y; l++) {
1393
-                if (i != k && j != l && !isnan(z_values[k][l])) {
1394
-                  //distance += pow((float) abs(i - k) * (MESH_X_DIST), 2) + pow((float) abs(j - l) * (MESH_Y_DIST), 2);  // working here
1395
-                  distance += HYPOT(MESH_X_DIST, MESH_Y_DIST) / log(HYPOT((i - k) * (MESH_X_DIST) + .001, (j - l) * (MESH_Y_DIST)) + .001);
1396
-                }
1397
-              }
1398
-            }
1399
-          }
1400
-          else
1401 1451
           // factor in the distance from the current location for the normal case
1402 1452
           // so the nozzle isn't running all over the bed.
1403
-            distance += HYPOT(raw_x - mx, raw_y - my) * 0.1;
1404
-
1405
-          // if far_flag, look for farthest point
1406
-          if (far_flag == (distance > best_so_far) && distance != best_so_far) {
1407
-            best_so_far = distance;   // We found a closer/farther location with
1453
+          distance += HYPOT(raw_x - mx, raw_y - my) * 0.1;
1454
+          if (distance < best_so_far) {
1455
+            best_so_far = distance;   // We found a closer location with
1408 1456
             out_mesh.x_index = i;     // the specified type of mesh value.
1409 1457
             out_mesh.y_index = j;
1410 1458
             out_mesh.distance = best_so_far;
@@ -1412,7 +1460,6 @@
1412 1460
         }
1413 1461
       } // for j
1414 1462
     } // for i
1415
-
1416 1463
     return out_mesh;
1417 1464
   }
1418 1465
 
@@ -1448,7 +1495,7 @@
1448 1495
       uint16_t not_done[16];
1449 1496
       memset(not_done, 0xFF, sizeof(not_done));
1450 1497
       do {
1451
-        location = find_closest_mesh_point_of_type(SET_IN_BITMAP, lx, ly, USE_NOZZLE_AS_REFERENCE, not_done, false);
1498
+        location = find_closest_mesh_point_of_type(SET_IN_BITMAP, lx, ly, USE_NOZZLE_AS_REFERENCE, not_done);
1452 1499
 
1453 1500
         if (location.x_index < 0) break; // stop when we can't find any more reachable points.
1454 1501
 
@@ -1572,16 +1619,10 @@
1572 1619
       info3 PROGMEM = { GRID_MAX_POINTS_X - 1, 0,  0, GRID_MAX_POINTS_Y,      true  };  // Right side of the mesh looking left
1573 1620
     static const smart_fill_info * const info[] PROGMEM = { &info0, &info1, &info2, &info3 };
1574 1621
 
1575
-    // static const smart_fill_info info[] PROGMEM = {
1576
-    //   { 0, GRID_MAX_POINTS_X,      0, GRID_MAX_POINTS_Y - 2,  false } PROGMEM,  // Bottom of the mesh looking up
1577
-    //   { 0, GRID_MAX_POINTS_X,      GRID_MAX_POINTS_Y - 1, 0,  false } PROGMEM,  // Top of the mesh looking down
1578
-    //   { 0, GRID_MAX_POINTS_X - 2,  0, GRID_MAX_POINTS_Y,      true  } PROGMEM,  // Left side of the mesh looking right
1579
-    //   { GRID_MAX_POINTS_X - 1, 0,  0, GRID_MAX_POINTS_Y,      true  } PROGMEM   // Right side of the mesh looking left
1580
-    // };
1581 1622
     for (uint8_t i = 0; i < COUNT(info); ++i) {
1582 1623
       const smart_fill_info *f = (smart_fill_info*)pgm_read_ptr(&info[i]);
1583
-      const int8_t sx = pgm_read_word(&f->sx), sy = pgm_read_word(&f->sy),
1584
-                   ex = pgm_read_word(&f->ex), ey = pgm_read_word(&f->ey);
1624
+      const int8_t sx = pgm_read_byte(&f->sx), sy = pgm_read_byte(&f->sy),
1625
+                   ex = pgm_read_byte(&f->ex), ey = pgm_read_byte(&f->ey);
1585 1626
       if (pgm_read_byte(&f->yfirst)) {
1586 1627
         const int8_t dir = ex > sx ? 1 : -1;
1587 1628
         for (uint8_t y = sy; y != ey; ++y)

+ 1
- 1
Marlin/src/gcode/bedlevel/ubl/M421.cpp Ver fichero

@@ -49,7 +49,7 @@ void GcodeSuite::M421() {
49 49
              hasQ = !hasZ && parser.seen('Q');
50 50
 
51 51
   if (hasC) {
52
-    const mesh_index_pair location = ubl.find_closest_mesh_point_of_type(REAL, current_position[X_AXIS], current_position[Y_AXIS], USE_NOZZLE_AS_REFERENCE, NULL, false);
52
+    const mesh_index_pair location = ubl.find_closest_mesh_point_of_type(REAL, current_position[X_AXIS], current_position[Y_AXIS], USE_NOZZLE_AS_REFERENCE, NULL);
53 53
     ix = location.x_index;
54 54
     iy = location.y_index;
55 55
   }

+ 4
- 4
Marlin/src/gcode/calibrate/M48.cpp Ver fichero

@@ -137,13 +137,13 @@ void GcodeSuite::M48() {
137 137
     for (uint8_t n = 0; n < n_samples; n++) {
138 138
       if (n_legs) {
139 139
         const int dir = (random(0, 10) > 5.0) ? -1 : 1;  // clockwise or counter clockwise
140
-        float angle = random(0.0, 360.0);
140
+        float angle = random(0, 360);
141 141
         const float radius = random(
142 142
           #if ENABLED(DELTA)
143
-            0.1250000000 * (DELTA_PROBEABLE_RADIUS),
144
-            0.3333333333 * (DELTA_PROBEABLE_RADIUS)
143
+            (int) (0.1250000000 * (DELTA_PROBEABLE_RADIUS)),
144
+            (int) (0.3333333333 * (DELTA_PROBEABLE_RADIUS))
145 145
           #else
146
-            5.0, 0.125 * min(X_BED_SIZE, Y_BED_SIZE)
146
+            (int) 5.0, (int) (0.125 * min(X_BED_SIZE, Y_BED_SIZE))
147 147
           #endif
148 148
         );
149 149
 

+ 1
- 1
Marlin/src/gcode/parser.h Ver fichero

@@ -294,7 +294,7 @@ public:
294 294
 
295 295
   // Provide simple value accessors with default option
296 296
   FORCE_INLINE static float    floatval(const char c, const float dval=0.0)   { return seenval(c) ? value_float()        : dval; }
297
-  FORCE_INLINE static bool     boolval(const char c)                          { return seenval(c) ? value_bool()      : seen(c); }
297
+  FORCE_INLINE static bool     boolval(const char c)                          { return seenval(c) ? value_bool()         : seen(c); }
298 298
   FORCE_INLINE static uint8_t  byteval(const char c, const uint8_t dval=0)    { return seenval(c) ? value_byte()         : dval; }
299 299
   FORCE_INLINE static int16_t  intval(const char c, const int16_t dval=0)     { return seenval(c) ? value_int()          : dval; }
300 300
   FORCE_INLINE static uint16_t ushortval(const char c, const uint16_t dval=0) { return seenval(c) ? value_ushort()       : dval; }

Loading…
Cancelar
Guardar