Merge pull request #2932 from espr14/PFW-1165-2

Calibration: Turn off speed optimization due to MK2.5 PFW-1165
This commit is contained in:
DRracer 2020-12-25 18:22:04 +01:00 committed by GitHub
commit d61cdf2b88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 87 additions and 150 deletions

View File

@ -423,58 +423,6 @@ void go_and_stop(uint8_t axis, int16_t dec, uint16_t &delay_us, uint16_t &steps)
--steps; --steps;
} }
/// Count number of zeros in the 32 byte array
/// If the number is less than 16, it moves @min_z up
/// Zeros make measuring faster but there cannot be too much
bool more_zeros(uint8_t* pixels, int16_t &min_z){
uint8_t hist[256];
uint8_t i = 0;
/// clear
do {
hist[i] = 0;
} while (i++ < 255);
/// fill
for (i = 0; i < 32; ++i){
++hist[pixels[i]];
}
// /// print histogram
// i = 0;
// DBG(_n("hist: "));
// do {
// DBG(_n("%d "), hist[i]);
// } while (i++ < 255);
// DBG(_n("\n"));
/// already more zeros on the line
if (hist[0] >= 16){
DBG(_n("zeros %d\n"), hist[0]);
return true;
}
/// find threshold
uint8_t sum = 0;
i = 0;
do {
sum += hist[i];
if (sum >= 16)
break;
} while (i++ < 255);
/// avoid too much zeros
if (sum >= 24)
--i;
DBG(_n("zeros %d, index %d\n"), sum, i);
// DBG(_n("min_z %d\n"), min_z);
min_z += i;
// DBG(_n("min_z %d\n"), min_z);
return false;
}
void xyzcal_scan_pixels_32x32_Zhop(int16_t cx, int16_t cy, int16_t min_z, int16_t max_z, uint16_t delay_us, uint8_t* pixels){ void xyzcal_scan_pixels_32x32_Zhop(int16_t cx, int16_t cy, int16_t min_z, int16_t max_z, uint16_t delay_us, uint8_t* pixels){
if (!pixels) if (!pixels)
return; return;
@ -485,10 +433,7 @@ void xyzcal_scan_pixels_32x32_Zhop(int16_t cx, int16_t cy, int16_t min_z, int16_
xyzcal_lineXYZ_to(cx - 1024, cy - 1024, min_z, delay_us, 0); xyzcal_lineXYZ_to(cx - 1024, cy - 1024, min_z, delay_us, 0);
int16_t start_z; int16_t start_z;
uint16_t steps_to_go; uint16_t steps_to_go;
/// available restarts (if needed)
uint8_t restarts = 2;
do {
for (uint8_t r = 0; r < 32; r++){ ///< Y axis for (uint8_t r = 0; r < 32; r++){ ///< Y axis
xyzcal_lineXYZ_to(_X, cy - 1024 + r * 64, z, delay_us, 0); xyzcal_lineXYZ_to(_X, cy - 1024 + r * 64, z, delay_us, 0);
for (int8_t d = 0; d < 2; ++d){ ///< direction for (int8_t d = 0; d < 2; ++d){ ///< direction
@ -589,16 +534,8 @@ void xyzcal_scan_pixels_32x32_Zhop(int16_t cx, int16_t cy, int16_t min_z, int16_
count_position[2] = z; count_position[2] = z;
} }
} }
/// do the min_z addjusting in the first row only
if (r == 0 && restarts){
if (more_zeros(pixels, min_z))
restarts = 0;
}
if (restarts)
break;
// DBG(_n("\n\n")); // DBG(_n("\n\n"));
} }
} while (restarts--);
} }
/// Returns rate of match /// Returns rate of match