|
@@ -1593,24 +1593,33 @@
|
1593
|
1593
|
typedef struct { uint8_t sx, ex, sy, ey; bool yfirst; } smart_fill_info;
|
1594
|
1594
|
|
1595
|
1595
|
void unified_bed_leveling::smart_fill_mesh() {
|
1596
|
|
- const smart_fill_info info[] = {
|
1597
|
|
- { 0, GRID_MAX_POINTS_X, 0, GRID_MAX_POINTS_Y - 2, false }, // Bottom of the mesh looking up
|
1598
|
|
- { 0, GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y - 1, 0, false }, // Top of the mesh looking down
|
1599
|
|
- { 0, GRID_MAX_POINTS_X - 2, 0, GRID_MAX_POINTS_Y, true }, // Left side of the mesh looking right
|
1600
|
|
- { GRID_MAX_POINTS_X - 1, 0, 0, GRID_MAX_POINTS_Y, true } // Right side of the mesh looking left
|
1601
|
|
- };
|
|
1596
|
+ static const smart_fill_info
|
|
1597
|
+ info0 PROGMEM = { 0, GRID_MAX_POINTS_X, 0, GRID_MAX_POINTS_Y - 2, false }, // Bottom of the mesh looking up
|
|
1598
|
+ info1 PROGMEM = { 0, GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y - 1, 0, false }, // Top of the mesh looking down
|
|
1599
|
+ info2 PROGMEM = { 0, GRID_MAX_POINTS_X - 2, 0, GRID_MAX_POINTS_Y, true }, // Left side of the mesh looking right
|
|
1600
|
+ info3 PROGMEM = { GRID_MAX_POINTS_X - 1, 0, 0, GRID_MAX_POINTS_Y, true }; // Right side of the mesh looking left
|
|
1601
|
+ static const smart_fill_info * const info[] PROGMEM = { &info0, &info1, &info2, &info3 };
|
|
1602
|
+
|
|
1603
|
+ // static const smart_fill_info info[] PROGMEM = {
|
|
1604
|
+ // { 0, GRID_MAX_POINTS_X, 0, GRID_MAX_POINTS_Y - 2, false } PROGMEM, // Bottom of the mesh looking up
|
|
1605
|
+ // { 0, GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y - 1, 0, false } PROGMEM, // Top of the mesh looking down
|
|
1606
|
+ // { 0, GRID_MAX_POINTS_X - 2, 0, GRID_MAX_POINTS_Y, true } PROGMEM, // Left side of the mesh looking right
|
|
1607
|
+ // { GRID_MAX_POINTS_X - 1, 0, 0, GRID_MAX_POINTS_Y, true } PROGMEM // Right side of the mesh looking left
|
|
1608
|
+ // };
|
1602
|
1609
|
for (uint8_t i = 0; i < COUNT(info); ++i) {
|
1603
|
|
- const smart_fill_info &f = info[i];
|
1604
|
|
- if (f.yfirst) {
|
1605
|
|
- const int8_t dir = f.ex > f.sx ? 1 : -1;
|
1606
|
|
- for (uint8_t y = f.sy; y != f.ey; ++y)
|
1607
|
|
- for (uint8_t x = f.sx; x != f.ex; x += dir)
|
|
1610
|
+ const smart_fill_info *f = (smart_fill_info*)pgm_read_word(&info[i]);
|
|
1611
|
+ const int8_t sx = pgm_read_word(&f->sx), sy = pgm_read_word(&f->sy),
|
|
1612
|
+ ex = pgm_read_word(&f->ex), ey = pgm_read_word(&f->ey);
|
|
1613
|
+ if (pgm_read_byte(&f->yfirst)) {
|
|
1614
|
+ const int8_t dir = ex > sx ? 1 : -1;
|
|
1615
|
+ for (uint8_t y = sy; y != ey; ++y)
|
|
1616
|
+ for (uint8_t x = sx; x != ex; x += dir)
|
1608
|
1617
|
if (smart_fill_one(x, y, dir, 0)) break;
|
1609
|
1618
|
}
|
1610
|
1619
|
else {
|
1611
|
|
- const int8_t dir = f.ey > f.sy ? 1 : -1;
|
1612
|
|
- for (uint8_t x = f.sx; x != f.ex; ++x)
|
1613
|
|
- for (uint8_t y = f.sy; y != f.ey; y += dir)
|
|
1620
|
+ const int8_t dir = ey > sy ? 1 : -1;
|
|
1621
|
+ for (uint8_t x = sx; x != ex; ++x)
|
|
1622
|
+ for (uint8_t y = sy; y != ey; y += dir)
|
1614
|
1623
|
if (smart_fill_one(x, y, 0, dir)) break;
|
1615
|
1624
|
}
|
1616
|
1625
|
}
|