// Rotate the grid by rotation, keeping cell contents. // rotation must be a multiple of 90 degrees. // NOTE: due to partial cells, cell coverage in the rotated grid will be // inexact. This is why there is no Rotate for the generic BBGrid. // TODO(rays) investigate fixing this inaccuracy by moving the origin after // rotation. void IntGrid::Rotate(const FCOORD& rotation) { ASSERT_HOST(rotation.x() == 0.0f || rotation.y() == 0.0f); ICOORD old_bleft(bleft()); ICOORD old_tright(tright()); int old_width = gridwidth(); int old_height = gridheight(); TBOX box(bleft(), tright()); box.rotate(rotation); int* old_grid = grid_; grid_ = NULL; Init(gridsize(), box.botleft(), box.topright()); // Iterate over the old grid, copying data to the rotated position in the new. int oldi = 0; FCOORD x_step(rotation); x_step *= gridsize(); for (int oldy = 0; oldy < old_height; ++oldy) { FCOORD line_pos(old_bleft.x(), old_bleft.y() + gridsize() * oldy); line_pos.rotate(rotation); for (int oldx = 0; oldx < old_width; ++oldx, line_pos += x_step, ++oldi) { int grid_x, grid_y; GridCoords(static_cast<int>(line_pos.x() + 0.5), static_cast<int>(line_pos.y() + 0.5), &grid_x, &grid_y); grid_[grid_y * gridwidth() + grid_x] = old_grid[oldi]; } } delete [] old_grid; }
/// find X_MAX endstop void home_x_positive() { queue_wait(); #if defined X_MAX_PIN uint8_t denoise_count = 0; // home X x_enable(); // hit home hard x_direction(1); while (denoise_count < 8) { // denoise if (x_max()) denoise_count++; else denoise_count = 0; // step x_step(); delay(5); unstep(); // wait until next step time delay((uint32_t) (60.0 * 1000000.0 / STEPS_PER_M_X * 1000.0 / ((float) MAXIMUM_FEEDRATE_X))); } denoise_count = 0; // back off slowly x_direction(0); while (x_max() != 0) { // step x_step(); delay(5); unstep(); // wait until next step time delay((uint32_t) (60.0 * 1000000.0 / STEPS_PER_M_X * 1000.0 / ((float) SEARCH_FEEDRATE_X))); } // set X home TARGET t = {0, 0, 0, 0, 0}; // set position to MAX startpoint.X = current_position.X = (int32_t)(X_MAX * 1000.0); // go to zero t.F = MAXIMUM_FEEDRATE_X; enqueue(&t); #endif }
/// find X MIN endstop void home_x_negative() { queue_wait(); #if defined X_MIN_PIN uint8_t denoise_count = 0; // home X x_enable(); // hit home hard x_direction(0); while (denoise_count < 8) { // denoise if (x_min()) denoise_count++; else denoise_count = 0; // step x_step(); delay(5); unstep(); // wait until next step time delay((uint32_t) (60.0 * 1000000.0 / STEPS_PER_M_X * 1000.0 / ((float) MAXIMUM_FEEDRATE_X))); } denoise_count = 0; // back off slowly x_direction(1); while (x_min() != 0) { // step x_step(); delay(5); unstep(); // wait until next step time delay((uint32_t) (60.0 * 1000000.0 / STEPS_PER_M_X * 1000.0 / ((float) SEARCH_FEEDRATE_X))); } // set X home startpoint.X = current_position.X = 0; #endif }
void defiSite::print(FILE* f) const { fprintf(f, "Site '%p' %s\n", name(), orientStr()); fprintf(f, " DO X %g %g BY %g\n", x_orig(), x_num(), x_step()); fprintf(f, " DO Y %g %g BY %g\n", y_orig(), y_num(), y_step()); }