Apply loop shorthand macros (#17159)
This commit is contained in:
@@ -115,8 +115,8 @@ void extrapolate_unprobed_bed_level() {
|
||||
ylen = ctry1;
|
||||
#endif
|
||||
|
||||
for (uint8_t xo = 0; xo <= xlen; xo++)
|
||||
for (uint8_t yo = 0; yo <= ylen; yo++) {
|
||||
LOOP_LE_N(xo, xlen)
|
||||
LOOP_LE_N(yo, ylen) {
|
||||
uint8_t x2 = ctrx2 + xo, y2 = ctry2 + yo;
|
||||
#ifndef HALF_IN_X
|
||||
const uint8_t x1 = ctrx1 - xo;
|
||||
@@ -209,8 +209,8 @@ void print_bilinear_leveling_grid() {
|
||||
|
||||
static float bed_level_virt_2cmr(const uint8_t x, const uint8_t y, const float &tx, const float &ty) {
|
||||
float row[4], column[4];
|
||||
for (uint8_t i = 0; i < 4; i++) {
|
||||
for (uint8_t j = 0; j < 4; j++) {
|
||||
LOOP_L_N(i, 4) {
|
||||
LOOP_L_N(j, 4) {
|
||||
column[j] = bed_level_virt_coord(i + x - 1, j + y - 1);
|
||||
}
|
||||
row[i] = bed_level_virt_cmr(column, 1, ty);
|
||||
@@ -221,11 +221,11 @@ void print_bilinear_leveling_grid() {
|
||||
void bed_level_virt_interpolate() {
|
||||
bilinear_grid_spacing_virt = bilinear_grid_spacing / (BILINEAR_SUBDIVISIONS);
|
||||
bilinear_grid_factor_virt = bilinear_grid_spacing_virt.reciprocal();
|
||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
||||
for (uint8_t ty = 0; ty < BILINEAR_SUBDIVISIONS; ty++)
|
||||
for (uint8_t tx = 0; tx < BILINEAR_SUBDIVISIONS; tx++) {
|
||||
if ((ty && y == GRID_MAX_POINTS_Y - 1) || (tx && x == GRID_MAX_POINTS_X - 1))
|
||||
LOOP_L_N(y, GRID_MAX_POINTS_Y)
|
||||
LOOP_L_N(x, GRID_MAX_POINTS_X)
|
||||
LOOP_L_N(ty, BILINEAR_SUBDIVISIONS)
|
||||
LOOP_L_N(tx, BILINEAR_SUBDIVISIONS) {
|
||||
if ((ty && y == (GRID_MAX_POINTS_Y) - 1) || (tx && x == (GRID_MAX_POINTS_X) - 1))
|
||||
continue;
|
||||
z_values_virt[x * (BILINEAR_SUBDIVISIONS) + tx][y * (BILINEAR_SUBDIVISIONS) + ty] =
|
||||
bed_level_virt_2cmr(
|
||||
|
@@ -143,13 +143,12 @@ void reset_bed_level() {
|
||||
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||
bilinear_start.reset();
|
||||
bilinear_grid_spacing.reset();
|
||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) {
|
||||
z_values[x][y] = NAN;
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
ExtUI::onMeshUpdate(x, y, 0);
|
||||
#endif
|
||||
}
|
||||
GRID_LOOP(x, y) {
|
||||
z_values[x][y] = NAN;
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
ExtUI::onMeshUpdate(x, y, 0);
|
||||
#endif
|
||||
}
|
||||
#elif ABL_PLANAR
|
||||
planner.bed_level_matrix.set_to_identity();
|
||||
#endif
|
||||
@@ -173,7 +172,7 @@ void reset_bed_level() {
|
||||
*/
|
||||
void print_2d_array(const uint8_t sx, const uint8_t sy, const uint8_t precision, element_2d_fn fn) {
|
||||
#ifndef SCAD_MESH_OUTPUT
|
||||
for (uint8_t x = 0; x < sx; x++) {
|
||||
LOOP_L_N(x, sx) {
|
||||
serial_spaces(precision + (x < 10 ? 3 : 2));
|
||||
SERIAL_ECHO(int(x));
|
||||
}
|
||||
@@ -182,14 +181,14 @@ void reset_bed_level() {
|
||||
#ifdef SCAD_MESH_OUTPUT
|
||||
SERIAL_ECHOLNPGM("measured_z = ["); // open 2D array
|
||||
#endif
|
||||
for (uint8_t y = 0; y < sy; y++) {
|
||||
LOOP_L_N(y, sy) {
|
||||
#ifdef SCAD_MESH_OUTPUT
|
||||
SERIAL_ECHOPGM(" ["); // open sub-array
|
||||
#else
|
||||
if (y < 10) SERIAL_CHAR(' ');
|
||||
SERIAL_ECHO(int(y));
|
||||
#endif
|
||||
for (uint8_t x = 0; x < sx; x++) {
|
||||
LOOP_L_N(x, sx) {
|
||||
SERIAL_CHAR(' ');
|
||||
const float offset = fn(x, y);
|
||||
if (!isnan(offset)) {
|
||||
@@ -202,7 +201,7 @@ void reset_bed_level() {
|
||||
SERIAL_CHAR(' ');
|
||||
SERIAL_ECHOPGM("NAN");
|
||||
#else
|
||||
for (uint8_t i = 0; i < precision + 3; i++)
|
||||
LOOP_L_N(i, precision + 3)
|
||||
SERIAL_CHAR(i ? '=' : ' ');
|
||||
#endif
|
||||
}
|
||||
|
@@ -40,9 +40,9 @@
|
||||
mesh_bed_leveling::index_to_ypos[GRID_MAX_POINTS_Y];
|
||||
|
||||
mesh_bed_leveling::mesh_bed_leveling() {
|
||||
for (uint8_t i = 0; i < GRID_MAX_POINTS_X; ++i)
|
||||
LOOP_L_N(i, GRID_MAX_POINTS_X)
|
||||
index_to_xpos[i] = MESH_MIN_X + i * (MESH_X_DIST);
|
||||
for (uint8_t i = 0; i < GRID_MAX_POINTS_Y; ++i)
|
||||
LOOP_L_N(i, GRID_MAX_POINTS_Y)
|
||||
index_to_ypos[i] = MESH_MIN_Y + i * (MESH_Y_DIST);
|
||||
reset();
|
||||
}
|
||||
@@ -51,9 +51,7 @@
|
||||
z_offset = 0;
|
||||
ZERO(z_values);
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
||||
ExtUI::onMeshUpdate(x, y, 0);
|
||||
GRID_LOOP(x, y) ExtUI::onMeshUpdate(x, y, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@@ -52,9 +52,7 @@ public:
|
||||
static void reset();
|
||||
|
||||
FORCE_INLINE static bool has_mesh() {
|
||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
||||
if (z_values[x][y]) return true;
|
||||
GRID_LOOP(x, y) if (z_values[x][y]) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -49,7 +49,7 @@
|
||||
void unified_bed_leveling::report_current_mesh() {
|
||||
if (!leveling_is_valid()) return;
|
||||
SERIAL_ECHO_MSG(" G29 I99");
|
||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
||||
LOOP_L_N(x, GRID_MAX_POINTS_X)
|
||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
||||
if (!isnan(z_values[x][y])) {
|
||||
SERIAL_ECHO_START();
|
||||
@@ -101,9 +101,7 @@
|
||||
storage_slot = -1;
|
||||
ZERO(z_values);
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
||||
ExtUI::onMeshUpdate(x, y, 0);
|
||||
GRID_LOOP(x, y) ExtUI::onMeshUpdate(x, y, 0);
|
||||
#endif
|
||||
if (was_enabled) report_current_position();
|
||||
}
|
||||
@@ -114,13 +112,11 @@
|
||||
}
|
||||
|
||||
void unified_bed_leveling::set_all_mesh_points_to_value(const float value) {
|
||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++) {
|
||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) {
|
||||
z_values[x][y] = value;
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
ExtUI::onMeshUpdate(x, y, value);
|
||||
#endif
|
||||
}
|
||||
GRID_LOOP(x, y) {
|
||||
z_values[x][y] = value;
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
ExtUI::onMeshUpdate(x, y, value);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,7 +186,7 @@
|
||||
}
|
||||
|
||||
// Row Values (I indexes)
|
||||
for (uint8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
|
||||
LOOP_L_N(i, GRID_MAX_POINTS_X) {
|
||||
|
||||
// Opening Brace or Space
|
||||
const bool is_current = i == curr.x && j == curr.y;
|
||||
|
@@ -298,9 +298,7 @@ class unified_bed_leveling {
|
||||
#endif
|
||||
|
||||
static inline bool mesh_is_valid() {
|
||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
||||
if (isnan(z_values[x][y])) return false;
|
||||
GRID_LOOP(x, y) if (isnan(z_values[x][y])) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -365,25 +365,23 @@
|
||||
#endif
|
||||
|
||||
case 0:
|
||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++) { // Create a bowl shape - similar to
|
||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) { // a poorly calibrated Delta.
|
||||
const float p1 = 0.5f * (GRID_MAX_POINTS_X) - x,
|
||||
p2 = 0.5f * (GRID_MAX_POINTS_Y) - y;
|
||||
z_values[x][y] += 2.0f * HYPOT(p1, p2);
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
ExtUI::onMeshUpdate(x, y, z_values[x][y]);
|
||||
#endif
|
||||
}
|
||||
GRID_LOOP(x, y) { // Create a bowl shape similar to a poorly-calibrated Delta
|
||||
const float p1 = 0.5f * (GRID_MAX_POINTS_X) - x,
|
||||
p2 = 0.5f * (GRID_MAX_POINTS_Y) - y;
|
||||
z_values[x][y] += 2.0f * HYPOT(p1, p2);
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
ExtUI::onMeshUpdate(x, y, z_values[x][y]);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++) { // Create a diagonal line several Mesh cells thick that is raised
|
||||
LOOP_L_N(x, GRID_MAX_POINTS_X) { // Create a diagonal line several Mesh cells thick that is raised
|
||||
z_values[x][x] += 9.999f;
|
||||
z_values[x][x + (x < GRID_MAX_POINTS_Y - 1) ? 1 : -1] += 9.999f; // We want the altered line several mesh points thick
|
||||
z_values[x][x + (x < (GRID_MAX_POINTS_Y) - 1) ? 1 : -1] += 9.999f; // We want the altered line several mesh points thick
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
ExtUI::onMeshUpdate(x, x, z_values[x][x]);
|
||||
ExtUI::onMeshUpdate(x, (x + (x < GRID_MAX_POINTS_Y - 1) ? 1 : -1), z_values[x][x + (x < GRID_MAX_POINTS_Y - 1) ? 1 : -1]);
|
||||
ExtUI::onMeshUpdate(x, (x + (x < (GRID_MAX_POINTS_Y) - 1) ? 1 : -1), z_values[x][x + (x < (GRID_MAX_POINTS_Y) - 1) ? 1 : -1]);
|
||||
#endif
|
||||
|
||||
}
|
||||
@@ -467,7 +465,7 @@
|
||||
//
|
||||
// Manually Probe Mesh in areas that can't be reached by the probe
|
||||
//
|
||||
SERIAL_ECHOLNPGM("Manually probing unreachable mesh locations.");
|
||||
SERIAL_ECHOLNPGM("Manually probing unreachable points.");
|
||||
do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
|
||||
|
||||
if (parser.seen('C') && !xy_seen) {
|
||||
@@ -537,9 +535,7 @@
|
||||
if (cpos.x < 0) {
|
||||
// No more REAL INVALID mesh points to populate, so we ASSUME
|
||||
// user meant to populate ALL INVALID mesh points to value
|
||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
||||
if (isnan(z_values[x][y])) z_values[x][y] = g29_constant;
|
||||
GRID_LOOP(x, y) if (isnan(z_values[x][y])) z_values[x][y] = g29_constant;
|
||||
break; // No more invalid Mesh Points to populate
|
||||
}
|
||||
else {
|
||||
@@ -696,12 +692,11 @@
|
||||
void unified_bed_leveling::adjust_mesh_to_mean(const bool cflag, const float value) {
|
||||
float sum = 0;
|
||||
int n = 0;
|
||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
||||
if (!isnan(z_values[x][y])) {
|
||||
sum += z_values[x][y];
|
||||
n++;
|
||||
}
|
||||
GRID_LOOP(x, y)
|
||||
if (!isnan(z_values[x][y])) {
|
||||
sum += z_values[x][y];
|
||||
n++;
|
||||
}
|
||||
|
||||
const float mean = sum / n;
|
||||
|
||||
@@ -709,10 +704,9 @@
|
||||
// Sum the squares of difference from mean
|
||||
//
|
||||
float sum_of_diff_squared = 0;
|
||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
||||
if (!isnan(z_values[x][y]))
|
||||
sum_of_diff_squared += sq(z_values[x][y] - mean);
|
||||
GRID_LOOP(x, y)
|
||||
if (!isnan(z_values[x][y]))
|
||||
sum_of_diff_squared += sq(z_values[x][y] - mean);
|
||||
|
||||
SERIAL_ECHOLNPAIR("# of samples: ", n);
|
||||
SERIAL_ECHOLNPAIR_F("Mean Mesh Height: ", mean, 6);
|
||||
@@ -721,27 +715,25 @@
|
||||
SERIAL_ECHOLNPAIR_F("Standard Deviation: ", sigma, 6);
|
||||
|
||||
if (cflag)
|
||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
||||
if (!isnan(z_values[x][y])) {
|
||||
z_values[x][y] -= mean + value;
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
ExtUI::onMeshUpdate(x, y, z_values[x][y]);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void unified_bed_leveling::shift_mesh_height() {
|
||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
||||
GRID_LOOP(x, y)
|
||||
if (!isnan(z_values[x][y])) {
|
||||
z_values[x][y] += g29_constant;
|
||||
z_values[x][y] -= mean + value;
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
ExtUI::onMeshUpdate(x, y, z_values[x][y]);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void unified_bed_leveling::shift_mesh_height() {
|
||||
GRID_LOOP(x, y)
|
||||
if (!isnan(z_values[x][y])) {
|
||||
z_values[x][y] += g29_constant;
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
ExtUI::onMeshUpdate(x, y, z_values[x][y]);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#if HAS_BED_PROBE
|
||||
/**
|
||||
* Probe all invalidated locations of the mesh that can be reached by the probe.
|
||||
@@ -1243,52 +1235,46 @@
|
||||
|
||||
mesh_index_pair farthest { -1, -1, -99999.99 };
|
||||
|
||||
for (int8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
|
||||
for (int8_t j = 0; j < GRID_MAX_POINTS_Y; j++) {
|
||||
GRID_LOOP(i, j) {
|
||||
if (!isnan(z_values[i][j])) continue; // Skip valid mesh points
|
||||
|
||||
if (isnan(z_values[i][j])) { // Invalid mesh point?
|
||||
// Skip unreachable points
|
||||
if (!probe.can_reach(mesh_index_to_xpos(i), mesh_index_to_ypos(j)))
|
||||
continue;
|
||||
|
||||
// Skip points the probe can't reach
|
||||
if (!probe.can_reach(mesh_index_to_xpos(i), mesh_index_to_ypos(j)))
|
||||
continue;
|
||||
found_a_NAN = true;
|
||||
|
||||
found_a_NAN = true;
|
||||
xy_int8_t near { -1, -1 };
|
||||
float d1, d2 = 99999.9f;
|
||||
GRID_LOOP(k, l) {
|
||||
if (isnan(z_values[k][l])) continue;
|
||||
|
||||
xy_int8_t near { -1, -1 };
|
||||
float d1, d2 = 99999.9f;
|
||||
for (int8_t k = 0; k < GRID_MAX_POINTS_X; k++) {
|
||||
for (int8_t l = 0; l < GRID_MAX_POINTS_Y; l++) {
|
||||
if (!isnan(z_values[k][l])) {
|
||||
found_a_real = true;
|
||||
found_a_real = true;
|
||||
|
||||
// Add in a random weighting factor that scrambles the probing of the
|
||||
// last half of the mesh (when every unprobed mesh point is one index
|
||||
// from a probed location).
|
||||
// Add in a random weighting factor that scrambles the probing of the
|
||||
// last half of the mesh (when every unprobed mesh point is one index
|
||||
// from a probed location).
|
||||
|
||||
d1 = HYPOT(i - k, j - l) + (1.0f / ((millis() % 47) + 13));
|
||||
d1 = HYPOT(i - k, j - l) + (1.0f / ((millis() % 47) + 13));
|
||||
|
||||
if (d1 < d2) { // Invalid mesh point (i,j) is closer to the defined point (k,l)
|
||||
d2 = d1;
|
||||
near.set(i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// At this point d2 should have the near defined mesh point to invalid mesh point (i,j)
|
||||
//
|
||||
|
||||
if (found_a_real && near.x >= 0 && d2 > farthest.distance) {
|
||||
farthest.pos = near; // Found an invalid location farther from the defined mesh point
|
||||
farthest.distance = d2;
|
||||
}
|
||||
if (d1 < d2) { // Invalid mesh point (i,j) is closer to the defined point (k,l)
|
||||
d2 = d1;
|
||||
near.set(i, j);
|
||||
}
|
||||
} // for j
|
||||
} // for i
|
||||
}
|
||||
|
||||
//
|
||||
// At this point d2 should have the near defined mesh point to invalid mesh point (i,j)
|
||||
//
|
||||
|
||||
if (found_a_real && near.x >= 0 && d2 > farthest.distance) {
|
||||
farthest.pos = near; // Found an invalid location farther from the defined mesh point
|
||||
farthest.distance = d2;
|
||||
}
|
||||
} // GRID_LOOP
|
||||
|
||||
if (!found_a_real && found_a_NAN) { // if the mesh is totally unpopulated, start the probing
|
||||
farthest.pos.set(GRID_MAX_POINTS_X / 2, GRID_MAX_POINTS_Y / 2);
|
||||
farthest.pos.set((GRID_MAX_POINTS_X) / 2, (GRID_MAX_POINTS_Y) / 2);
|
||||
farthest.distance = 1;
|
||||
}
|
||||
return farthest;
|
||||
@@ -1304,36 +1290,34 @@
|
||||
|
||||
float best_so_far = 99999.99f;
|
||||
|
||||
for (int8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
|
||||
for (int8_t j = 0; j < GRID_MAX_POINTS_Y; j++) {
|
||||
if ( (type == (isnan(z_values[i][j]) ? INVALID : REAL))
|
||||
|| (type == SET_IN_BITMAP && !done_flags->marked(i, j))
|
||||
) {
|
||||
// Found a Mesh Point of the specified type!
|
||||
const xy_pos_t mpos = { mesh_index_to_xpos(i), mesh_index_to_ypos(j) };
|
||||
GRID_LOOP(i, j) {
|
||||
if ( (type == (isnan(z_values[i][j]) ? INVALID : REAL))
|
||||
|| (type == SET_IN_BITMAP && !done_flags->marked(i, j))
|
||||
) {
|
||||
// Found a Mesh Point of the specified type!
|
||||
const xy_pos_t mpos = { mesh_index_to_xpos(i), mesh_index_to_ypos(j) };
|
||||
|
||||
// If using the probe as the reference there are some unreachable locations.
|
||||
// Also for round beds, there are grid points outside the bed the nozzle can't reach.
|
||||
// Prune them from the list and ignore them till the next Phase (manual nozzle probing).
|
||||
// If using the probe as the reference there are some unreachable locations.
|
||||
// Also for round beds, there are grid points outside the bed the nozzle can't reach.
|
||||
// Prune them from the list and ignore them till the next Phase (manual nozzle probing).
|
||||
|
||||
if (!(probe_relative ? probe.can_reach(mpos) : position_is_reachable(mpos)))
|
||||
continue;
|
||||
if (!(probe_relative ? probe.can_reach(mpos) : position_is_reachable(mpos)))
|
||||
continue;
|
||||
|
||||
// Reachable. Check if it's the best_so_far location to the nozzle.
|
||||
// Reachable. Check if it's the best_so_far location to the nozzle.
|
||||
|
||||
const xy_pos_t diff = current_position - mpos;
|
||||
const float distance = (ref - mpos).magnitude() + diff.magnitude() * 0.1f;
|
||||
const xy_pos_t diff = current_position - mpos;
|
||||
const float distance = (ref - mpos).magnitude() + diff.magnitude() * 0.1f;
|
||||
|
||||
// factor in the distance from the current location for the normal case
|
||||
// so the nozzle isn't running all over the bed.
|
||||
if (distance < best_so_far) {
|
||||
best_so_far = distance; // Found a closer location with the desired value type.
|
||||
closest.pos.set(i, j);
|
||||
closest.distance = best_so_far;
|
||||
}
|
||||
// factor in the distance from the current location for the normal case
|
||||
// so the nozzle isn't running all over the bed.
|
||||
if (distance < best_so_far) {
|
||||
best_so_far = distance; // Found a closer location with the desired value type.
|
||||
closest.pos.set(i, j);
|
||||
closest.distance = best_so_far;
|
||||
}
|
||||
} // for j
|
||||
} // for i
|
||||
}
|
||||
} // GRID_LOOP
|
||||
|
||||
return closest;
|
||||
}
|
||||
@@ -1373,7 +1357,7 @@
|
||||
info3 PROGMEM = { GRID_MAX_POINTS_X - 1, 0, 0, GRID_MAX_POINTS_Y, true }; // Right side of the mesh looking left
|
||||
static const smart_fill_info * const info[] PROGMEM = { &info0, &info1, &info2, &info3 };
|
||||
|
||||
for (uint8_t i = 0; i < COUNT(info); ++i) {
|
||||
LOOP_L_N(i, COUNT(info)) {
|
||||
const smart_fill_info *f = (smart_fill_info*)pgm_read_ptr(&info[i]);
|
||||
const int8_t sx = pgm_read_byte(&f->sx), sy = pgm_read_byte(&f->sy),
|
||||
ex = pgm_read_byte(&f->ex), ey = pgm_read_byte(&f->ey);
|
||||
@@ -1496,12 +1480,13 @@
|
||||
|
||||
bool zig_zag = false;
|
||||
|
||||
uint16_t total_points = g29_grid_size * g29_grid_size, point_num = 1;
|
||||
const uint16_t total_points = sq(g29_grid_size);
|
||||
uint16_t point_num = 1;
|
||||
|
||||
xy_pos_t rpos;
|
||||
for (uint8_t ix = 0; ix < g29_grid_size; ix++) {
|
||||
LOOP_L_N(ix, g29_grid_size) {
|
||||
rpos.x = x_min + ix * dx;
|
||||
for (int8_t iy = 0; iy < g29_grid_size; iy++) {
|
||||
LOOP_L_N(iy, g29_grid_size) {
|
||||
rpos.y = y_min + dy * (zig_zag ? g29_grid_size - 1 - iy : iy);
|
||||
|
||||
if (!abort_flag) {
|
||||
@@ -1569,39 +1554,37 @@
|
||||
|
||||
matrix_3x3 rotation = matrix_3x3::create_look_at(vector_3(lsf_results.A, lsf_results.B, 1));
|
||||
|
||||
for (uint8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
|
||||
for (uint8_t j = 0; j < GRID_MAX_POINTS_Y; j++) {
|
||||
float mx = mesh_index_to_xpos(i),
|
||||
my = mesh_index_to_ypos(j),
|
||||
mz = z_values[i][j];
|
||||
GRID_LOOP(i, j) {
|
||||
float mx = mesh_index_to_xpos(i),
|
||||
my = mesh_index_to_ypos(j),
|
||||
mz = z_values[i][j];
|
||||
|
||||
if (DEBUGGING(LEVELING)) {
|
||||
DEBUG_ECHOPAIR_F("before rotation = [", mx, 7);
|
||||
DEBUG_CHAR(',');
|
||||
DEBUG_ECHO_F(my, 7);
|
||||
DEBUG_CHAR(',');
|
||||
DEBUG_ECHO_F(mz, 7);
|
||||
DEBUG_ECHOPGM("] ---> ");
|
||||
DEBUG_DELAY(20);
|
||||
}
|
||||
|
||||
apply_rotation_xyz(rotation, mx, my, mz);
|
||||
|
||||
if (DEBUGGING(LEVELING)) {
|
||||
DEBUG_ECHOPAIR_F("after rotation = [", mx, 7);
|
||||
DEBUG_CHAR(',');
|
||||
DEBUG_ECHO_F(my, 7);
|
||||
DEBUG_CHAR(',');
|
||||
DEBUG_ECHO_F(mz, 7);
|
||||
DEBUG_ECHOLNPGM("]");
|
||||
DEBUG_DELAY(20);
|
||||
}
|
||||
|
||||
z_values[i][j] = mz - lsf_results.D;
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
ExtUI::onMeshUpdate(i, j, z_values[i][j]);
|
||||
#endif
|
||||
if (DEBUGGING(LEVELING)) {
|
||||
DEBUG_ECHOPAIR_F("before rotation = [", mx, 7);
|
||||
DEBUG_CHAR(',');
|
||||
DEBUG_ECHO_F(my, 7);
|
||||
DEBUG_CHAR(',');
|
||||
DEBUG_ECHO_F(mz, 7);
|
||||
DEBUG_ECHOPGM("] ---> ");
|
||||
DEBUG_DELAY(20);
|
||||
}
|
||||
|
||||
apply_rotation_xyz(rotation, mx, my, mz);
|
||||
|
||||
if (DEBUGGING(LEVELING)) {
|
||||
DEBUG_ECHOPAIR_F("after rotation = [", mx, 7);
|
||||
DEBUG_CHAR(',');
|
||||
DEBUG_ECHO_F(my, 7);
|
||||
DEBUG_CHAR(',');
|
||||
DEBUG_ECHO_F(mz, 7);
|
||||
DEBUG_ECHOLNPGM("]");
|
||||
DEBUG_DELAY(20);
|
||||
}
|
||||
|
||||
z_values[i][j] = mz - lsf_results.D;
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
ExtUI::onMeshUpdate(i, j, z_values[i][j]);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (DEBUGGING(LEVELING)) {
|
||||
@@ -1661,7 +1644,7 @@
|
||||
// being extrapolated so that nearby points will have greater influence on
|
||||
// the point being extrapolated. Then extrapolate the mesh point from WLSF.
|
||||
|
||||
static_assert(GRID_MAX_POINTS_Y <= 16, "GRID_MAX_POINTS_Y too big");
|
||||
static_assert((GRID_MAX_POINTS_Y) <= 16, "GRID_MAX_POINTS_Y too big");
|
||||
uint16_t bitmap[GRID_MAX_POINTS_X] = { 0 };
|
||||
struct linear_fit_data lsf_results;
|
||||
|
||||
@@ -1669,23 +1652,20 @@
|
||||
|
||||
const float weight_scaled = weight_factor * _MAX(MESH_X_DIST, MESH_Y_DIST);
|
||||
|
||||
for (uint8_t jx = 0; jx < GRID_MAX_POINTS_X; jx++)
|
||||
for (uint8_t jy = 0; jy < GRID_MAX_POINTS_Y; jy++)
|
||||
if (!isnan(z_values[jx][jy]))
|
||||
SBI(bitmap[jx], jy);
|
||||
GRID_LOOP(jx, jy) if (!isnan(z_values[jx][jy])) SBI(bitmap[jx], jy);
|
||||
|
||||
xy_pos_t ppos;
|
||||
for (uint8_t ix = 0; ix < GRID_MAX_POINTS_X; ix++) {
|
||||
LOOP_L_N(ix, GRID_MAX_POINTS_X) {
|
||||
ppos.x = mesh_index_to_xpos(ix);
|
||||
for (uint8_t iy = 0; iy < GRID_MAX_POINTS_Y; iy++) {
|
||||
LOOP_L_N(iy, GRID_MAX_POINTS_Y) {
|
||||
ppos.y = mesh_index_to_ypos(iy);
|
||||
if (isnan(z_values[ix][iy])) {
|
||||
// undefined mesh point at (ppos.x,ppos.y), compute weighted LSF from original valid mesh points.
|
||||
incremental_LSF_reset(&lsf_results);
|
||||
xy_pos_t rpos;
|
||||
for (uint8_t jx = 0; jx < GRID_MAX_POINTS_X; jx++) {
|
||||
LOOP_L_N(jx, GRID_MAX_POINTS_X) {
|
||||
rpos.x = mesh_index_to_xpos(jx);
|
||||
for (uint8_t jy = 0; jy < GRID_MAX_POINTS_Y; jy++) {
|
||||
LOOP_L_N(jy, GRID_MAX_POINTS_Y) {
|
||||
if (TEST(bitmap[jx], jy)) {
|
||||
rpos.y = mesh_index_to_ypos(jy);
|
||||
const float rz = z_values[jx][jy],
|
||||
@@ -1747,7 +1727,7 @@
|
||||
SERIAL_ECHOLNPAIR("MESH_Y_DIST ", MESH_Y_DIST); serial_delay(50);
|
||||
|
||||
SERIAL_ECHOPGM("X-Axis Mesh Points at: ");
|
||||
for (uint8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
|
||||
LOOP_L_N(i, GRID_MAX_POINTS_X) {
|
||||
SERIAL_ECHO_F(LOGICAL_X_POSITION(mesh_index_to_xpos(i)), 3);
|
||||
SERIAL_ECHOPGM(" ");
|
||||
serial_delay(25);
|
||||
@@ -1755,7 +1735,7 @@
|
||||
SERIAL_EOL();
|
||||
|
||||
SERIAL_ECHOPGM("Y-Axis Mesh Points at: ");
|
||||
for (uint8_t i = 0; i < GRID_MAX_POINTS_Y; i++) {
|
||||
LOOP_L_N(i, GRID_MAX_POINTS_Y) {
|
||||
SERIAL_ECHO_F(LOGICAL_Y_POSITION(mesh_index_to_ypos(i)), 3);
|
||||
SERIAL_ECHOPGM(" ");
|
||||
serial_delay(25);
|
||||
@@ -1840,13 +1820,12 @@
|
||||
|
||||
SERIAL_ECHOLNPAIR("Subtracting mesh in slot ", g29_storage_slot, " from current mesh.");
|
||||
|
||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) {
|
||||
z_values[x][y] -= tmp_z_values[x][y];
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
ExtUI::onMeshUpdate(x, y, z_values[x][y]);
|
||||
#endif
|
||||
}
|
||||
GRID_LOOP(x, y) {
|
||||
z_values[x][y] -= tmp_z_values[x][y];
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
ExtUI::onMeshUpdate(x, y, z_values[x][y]);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#endif // UBL_DEVEL_DEBUGGING
|
||||
|
@@ -92,11 +92,11 @@ void digipot_i2c_set_current(const uint8_t channel, const float current) {
|
||||
void digipot_i2c_init() {
|
||||
static const float digipot_motor_current[] PROGMEM = DIGIPOT_I2C_MOTOR_CURRENTS;
|
||||
|
||||
for (uint8_t i = 0; i < DIGIPOT_I2C_NUM_CHANNELS; i++)
|
||||
LOOP_L_N(i, DIGIPOT_I2C_NUM_CHANNELS)
|
||||
pots[i].i2c_init();
|
||||
|
||||
// setup initial currents as defined in Configuration_adv.h
|
||||
for (uint8_t i = 0; i < COUNT(digipot_motor_current); i++)
|
||||
LOOP_L_N(i, COUNT(digipot_motor_current))
|
||||
digipot_i2c_set_current(i, pgm_read_float(&digipot_motor_current[i]));
|
||||
}
|
||||
|
||||
|
@@ -83,7 +83,7 @@ void digipot_i2c_init() {
|
||||
#endif
|
||||
// setup initial currents as defined in Configuration_adv.h
|
||||
static const float digipot_motor_current[] PROGMEM = DIGIPOT_I2C_MOTOR_CURRENTS;
|
||||
for (uint8_t i = 0; i < COUNT(digipot_motor_current); i++)
|
||||
LOOP_L_N(i, COUNT(digipot_motor_current))
|
||||
digipot_i2c_set_current(i, pgm_read_float(&digipot_motor_current[i]));
|
||||
}
|
||||
|
||||
|
@@ -42,7 +42,7 @@ int8_t FilamentWidthSensor::ratios[MAX_MEASUREMENT_DELAY + 1], // Ring
|
||||
|
||||
void FilamentWidthSensor::init() {
|
||||
const int8_t ratio = sample_to_size_ratio();
|
||||
for (uint8_t i = 0; i < COUNT(ratios); ++i) ratios[i] = ratio;
|
||||
LOOP_L_N(i, COUNT(ratios)) ratios[i] = ratio;
|
||||
index_r = index_w = 0;
|
||||
}
|
||||
|
||||
|
@@ -73,7 +73,7 @@ void FWRetract::reset() {
|
||||
settings.swap_retract_recover_feedrate_mm_s = RETRACT_RECOVER_FEEDRATE_SWAP;
|
||||
current_hop = 0.0;
|
||||
|
||||
for (uint8_t i = 0; i < EXTRUDERS; ++i) {
|
||||
LOOP_L_N(i, EXTRUDERS) {
|
||||
retracted[i] = false;
|
||||
#if EXTRUDERS > 1
|
||||
retracted_swap[i] = false;
|
||||
@@ -117,7 +117,7 @@ void FWRetract::retract(const bool retracting
|
||||
" swapping ", swapping,
|
||||
" active extruder ", active_extruder
|
||||
);
|
||||
for (uint8_t i = 0; i < EXTRUDERS; ++i) {
|
||||
LOOP_L_N(i, EXTRUDERS) {
|
||||
SERIAL_ECHOLNPAIR("retracted[", i, "] ", retracted[i]);
|
||||
#if EXTRUDERS > 1
|
||||
SERIAL_ECHOLNPAIR("retracted_swap[", i, "] ", retracted_swap[i]);
|
||||
@@ -201,7 +201,7 @@ void FWRetract::retract(const bool retracting
|
||||
SERIAL_ECHOLNPAIR("retracting ", retracting);
|
||||
SERIAL_ECHOLNPAIR("swapping ", swapping);
|
||||
SERIAL_ECHOLNPAIR("active_extruder ", active_extruder);
|
||||
for (uint8_t i = 0; i < EXTRUDERS; ++i) {
|
||||
LOOP_L_N(i, EXTRUDERS) {
|
||||
SERIAL_ECHOLNPAIR("retracted[", i, "] ", retracted[i]);
|
||||
#if EXTRUDERS > 1
|
||||
SERIAL_ECHOLNPAIR("retracted_swap[", i, "] ", retracted_swap[i]);
|
||||
|
@@ -147,7 +147,7 @@ void Max7219::error(const char * const func, const int32_t v1, const int32_t v2/
|
||||
*/
|
||||
inline uint32_t flipped(const uint32_t bits, const uint8_t n_bytes) {
|
||||
uint32_t mask = 1, outbits = 0;
|
||||
for (uint8_t b = 0; b < n_bytes * 8; b++) {
|
||||
LOOP_L_N(b, n_bytes * 8) {
|
||||
outbits <<= 1;
|
||||
if (bits & mask) outbits |= 1;
|
||||
mask <<= 1;
|
||||
@@ -329,13 +329,13 @@ void Max7219::fill() {
|
||||
|
||||
void Max7219::clear_row(const uint8_t row) {
|
||||
if (row >= MAX7219_Y_LEDS) return error(PSTR("clear_row"), row);
|
||||
for (uint8_t x = 0; x < MAX7219_X_LEDS; x++) CLR_7219(x, row);
|
||||
LOOP_L_N(x, MAX7219_X_LEDS) CLR_7219(x, row);
|
||||
send_row(row);
|
||||
}
|
||||
|
||||
void Max7219::clear_column(const uint8_t col) {
|
||||
if (col >= MAX7219_X_LEDS) return error(PSTR("set_column"), col);
|
||||
for (uint8_t y = 0; y < MAX7219_Y_LEDS; y++) CLR_7219(col, y);
|
||||
LOOP_L_N(y, MAX7219_Y_LEDS) CLR_7219(col, y);
|
||||
send_column(col);
|
||||
}
|
||||
|
||||
@@ -347,7 +347,7 @@ void Max7219::clear_column(const uint8_t col) {
|
||||
void Max7219::set_row(const uint8_t row, const uint32_t val) {
|
||||
if (row >= MAX7219_Y_LEDS) return error(PSTR("set_row"), row);
|
||||
uint32_t mask = _BV32(MAX7219_X_LEDS - 1);
|
||||
for (uint8_t x = 0; x < MAX7219_X_LEDS; x++) {
|
||||
LOOP_L_N(x, MAX7219_X_LEDS) {
|
||||
if (val & mask) SET_7219(x, row); else CLR_7219(x, row);
|
||||
mask >>= 1;
|
||||
}
|
||||
@@ -362,7 +362,7 @@ void Max7219::set_row(const uint8_t row, const uint32_t val) {
|
||||
void Max7219::set_column(const uint8_t col, const uint32_t val) {
|
||||
if (col >= MAX7219_X_LEDS) return error(PSTR("set_column"), col);
|
||||
uint32_t mask = _BV32(MAX7219_Y_LEDS - 1);
|
||||
for (uint8_t y = 0; y < MAX7219_Y_LEDS; y++) {
|
||||
LOOP_L_N(y, MAX7219_Y_LEDS) {
|
||||
if (val & mask) SET_7219(col, y); else CLR_7219(col, y);
|
||||
mask >>= 1;
|
||||
}
|
||||
@@ -427,23 +427,23 @@ void Max7219::set_columns_32bits(const uint8_t x, uint32_t val) {
|
||||
|
||||
// Initialize the Max7219
|
||||
void Max7219::register_setup() {
|
||||
for (uint8_t i = 0; i < MAX7219_NUMBER_UNITS; i++)
|
||||
LOOP_L_N(i, MAX7219_NUMBER_UNITS)
|
||||
send(max7219_reg_scanLimit, 0x07);
|
||||
pulse_load(); // Tell the chips to load the clocked out data
|
||||
|
||||
for (uint8_t i = 0; i < MAX7219_NUMBER_UNITS; i++)
|
||||
LOOP_L_N(i, MAX7219_NUMBER_UNITS)
|
||||
send(max7219_reg_decodeMode, 0x00); // Using an led matrix (not digits)
|
||||
pulse_load(); // Tell the chips to load the clocked out data
|
||||
|
||||
for (uint8_t i = 0; i < MAX7219_NUMBER_UNITS; i++)
|
||||
LOOP_L_N(i, MAX7219_NUMBER_UNITS)
|
||||
send(max7219_reg_shutdown, 0x01); // Not in shutdown mode
|
||||
pulse_load(); // Tell the chips to load the clocked out data
|
||||
|
||||
for (uint8_t i = 0; i < MAX7219_NUMBER_UNITS; i++)
|
||||
LOOP_L_N(i, MAX7219_NUMBER_UNITS)
|
||||
send(max7219_reg_displayTest, 0x00); // No display test
|
||||
pulse_load(); // Tell the chips to load the clocked out data
|
||||
|
||||
for (uint8_t i = 0; i < MAX7219_NUMBER_UNITS; i++)
|
||||
LOOP_L_N(i, MAX7219_NUMBER_UNITS)
|
||||
send(max7219_reg_intensity, 0x01 & 0x0F); // The first 0x0F is the value you can set
|
||||
// Range: 0x00 to 0x0F
|
||||
pulse_load(); // Tell the chips to load the clocked out data
|
||||
@@ -537,7 +537,7 @@ void Max7219::init() {
|
||||
|
||||
register_setup();
|
||||
|
||||
for (uint8_t i = 0; i <= 7; i++) { // Empty registers to turn all LEDs off
|
||||
LOOP_LE_N(i, 7) { // Empty registers to turn all LEDs off
|
||||
led_line[i] = 0x00;
|
||||
send(max7219_reg_digit0 + i, 0);
|
||||
pulse_load(); // Tell the chips to load the clocked out data
|
||||
|
@@ -98,13 +98,13 @@ void Mixer::normalize(const uint8_t tool_index) {
|
||||
void Mixer::reset_vtools() {
|
||||
// Virtual Tools 0, 1, 2, 3 = Filament 1, 2, 3, 4, etc.
|
||||
// Every virtual tool gets a pure filament
|
||||
for (uint8_t t = 0; t < MIXING_VIRTUAL_TOOLS && t < MIXING_STEPPERS; t++)
|
||||
LOOP_L_N(t, MIXING_VIRTUAL_TOOLS && t < MIXING_STEPPERS)
|
||||
MIXER_STEPPER_LOOP(i)
|
||||
color[t][i] = (t == i) ? COLOR_A_MASK : 0;
|
||||
|
||||
// Remaining virtual tools are 100% filament 1
|
||||
#if MIXING_VIRTUAL_TOOLS > MIXING_STEPPERS
|
||||
for (uint8_t t = MIXING_STEPPERS; t < MIXING_VIRTUAL_TOOLS; t++)
|
||||
LOOP_S_L_N(t, MIXING_STEPPERS, MIXING_VIRTUAL_TOOLS)
|
||||
MIXER_STEPPER_LOOP(i)
|
||||
color[t][i] = (i == 0) ? COLOR_A_MASK : 0;
|
||||
#endif
|
||||
|
@@ -381,7 +381,7 @@ bool MMU2::rx_str_P(const char* str) {
|
||||
void MMU2::tx_str_P(const char* str) {
|
||||
clear_rx_buffer();
|
||||
uint8_t len = strlen_P(str);
|
||||
for (uint8_t i = 0; i < len; i++) mmuSerial.write(pgm_read_byte(str++));
|
||||
LOOP_L_N(i, len) mmuSerial.write(pgm_read_byte(str++));
|
||||
rx_buffer[0] = '\0';
|
||||
last_request = millis();
|
||||
}
|
||||
@@ -392,7 +392,7 @@ void MMU2::tx_str_P(const char* str) {
|
||||
void MMU2::tx_printf_P(const char* format, int argument = -1) {
|
||||
clear_rx_buffer();
|
||||
uint8_t len = sprintf_P(tx_buffer, format, argument);
|
||||
for (uint8_t i = 0; i < len; i++) mmuSerial.write(tx_buffer[i]);
|
||||
LOOP_L_N(i, len) mmuSerial.write(tx_buffer[i]);
|
||||
rx_buffer[0] = '\0';
|
||||
last_request = millis();
|
||||
}
|
||||
@@ -403,7 +403,7 @@ void MMU2::tx_printf_P(const char* format, int argument = -1) {
|
||||
void MMU2::tx_printf_P(const char* format, int argument1, int argument2) {
|
||||
clear_rx_buffer();
|
||||
uint8_t len = sprintf_P(tx_buffer, format, argument1, argument2);
|
||||
for (uint8_t i = 0; i < len; i++) mmuSerial.write(tx_buffer[i]);
|
||||
LOOP_L_N(i, len) mmuSerial.write(tx_buffer[i]);
|
||||
rx_buffer[0] = '\0';
|
||||
last_request = millis();
|
||||
}
|
||||
@@ -780,7 +780,7 @@ void MMU2::filament_runout() {
|
||||
|
||||
const E_Step* step = sequence;
|
||||
|
||||
for (uint8_t i = 0; i < steps; i++) {
|
||||
LOOP_L_N(i, steps) {
|
||||
const float es = pgm_read_float(&(step->extrude));
|
||||
const feedRate_t fr_mm_m = pgm_read_float(&(step->feedRate));
|
||||
|
||||
|
@@ -391,7 +391,7 @@ void PrintJobRecovery::resume() {
|
||||
|
||||
// Restore retract and hop state
|
||||
#if ENABLED(FWRETRACT)
|
||||
for (uint8_t e = 0; e < EXTRUDERS; e++) {
|
||||
LOOP_L_N(e, EXTRUDERS) {
|
||||
if (info.retract[e] != 0.0) {
|
||||
fwretract.current_retract[e] = info.retract[e];
|
||||
fwretract.retracted[e] = true;
|
||||
|
@@ -54,7 +54,7 @@ uint8_t ProbeTempComp::calib_idx; // = 0
|
||||
float ProbeTempComp::init_measurement; // = 0.0
|
||||
|
||||
void ProbeTempComp::clear_offsets(const TempSensorID tsi) {
|
||||
for (uint8_t i = 0; i < cali_info[tsi].measurements; ++i)
|
||||
LOOP_L_N(i, cali_info[tsi].measurements)
|
||||
sensor_z_offsets[tsi][i] = 0;
|
||||
calib_idx = 0;
|
||||
}
|
||||
@@ -66,7 +66,7 @@ bool ProbeTempComp::set_offset(const TempSensorID tsi, const uint8_t idx, const
|
||||
}
|
||||
|
||||
void ProbeTempComp::print_offsets() {
|
||||
for (uint8_t s = 0; s < TSI_COUNT; s++) {
|
||||
LOOP_L_N(s, TSI_COUNT) {
|
||||
float temp = cali_info[s].start_temp;
|
||||
for (int16_t i = -1; i < cali_info[s].measurements; ++i) {
|
||||
serialprintPGM(s == TSI_BED ? PSTR("Bed") :
|
||||
@@ -198,7 +198,7 @@ bool ProbeTempComp::linear_regression(const TempSensorID tsi, float &k, float &d
|
||||
sum_x2 = sq(start_temp),
|
||||
sum_xy = 0, sum_y = 0;
|
||||
|
||||
for (uint8_t i = 0; i < calib_idx; ++i) {
|
||||
LOOP_L_N(i, calib_idx) {
|
||||
const float xi = start_temp + (i + 1) * res_temp,
|
||||
yi = static_cast<float>(data[i]);
|
||||
sum_x += xi;
|
||||
|
@@ -184,7 +184,7 @@ class FilamentSensorBase {
|
||||
#ifdef FILAMENT_RUNOUT_SENSOR_DEBUG
|
||||
if (change) {
|
||||
SERIAL_ECHOPGM("Motion detected:");
|
||||
for (uint8_t e = 0; e < NUM_RUNOUT_SENSORS; e++)
|
||||
LOOP_L_N(e, NUM_RUNOUT_SENSORS)
|
||||
if (TEST(change, e)) SERIAL_CHAR(' ', '0' + e);
|
||||
SERIAL_EOL();
|
||||
}
|
||||
|
@@ -104,7 +104,7 @@ void TWIBus::echodata(uint8_t bytes, const char prefix[], uint8_t adr) {
|
||||
|
||||
void TWIBus::echobuffer(const char prefix[], uint8_t adr) {
|
||||
echoprefix(buffer_s, prefix, adr);
|
||||
for (uint8_t i = 0; i < buffer_s; i++) SERIAL_CHAR(buffer[i]);
|
||||
LOOP_L_N(i, buffer_s) SERIAL_CHAR(buffer[i]);
|
||||
SERIAL_EOL();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user