int main( void ) { while (time_ticks<(60*60*6*TICKS_SEC)) { uint32_t steps = ComputeStep(time_ticks); // printf("T %d %d\n", time_ticks, steps); if (steps>total_steps) { printf("go %d -> %d\n", total_steps, steps); total_steps = steps; } // printf("%d 0x%04x 0x%04x %d\n", time_ticks, prev_lookup_time, next_lookup_time, steps); ++time_ticks; } printf("max a %d\n",max_a); printf("max b %d\n",max_b); return 0; }
bool SkCornerPathEffect::filterPath(SkPath* dst, const SkPath& src, SkScalar* width) { if (fRadius == 0) return false; SkPath::Iter iter(src, false); SkPath::Verb verb, prevVerb = (SkPath::Verb)-1; SkPoint pts[4]; bool closed; SkPoint moveTo, lastCorner; SkVector firstStep, step; bool prevIsValid = true; // to avoid warnings moveTo.set(0, 0); firstStep.set(0, 0); lastCorner.set(0, 0); for (;;) { switch (verb = iter.next(pts)) { case SkPath::kMove_Verb: closed = iter.isClosedContour(); if (closed) { moveTo = pts[0]; prevIsValid = false; } else { dst->moveTo(pts[0]); prevIsValid = true; } break; case SkPath::kLine_Verb: { bool drawSegment = ComputeStep(pts[0], pts[1], fRadius, &step); // prev corner if (!prevIsValid) { dst->moveTo(moveTo + step); prevIsValid = true; } else { dst->quadTo(pts[0].fX, pts[0].fY, pts[0].fX + step.fX, pts[0].fY + step.fY); } if (drawSegment) { dst->lineTo(pts[1].fX - step.fX, pts[1].fY - step.fY); } lastCorner = pts[1]; prevIsValid = true; } break; case SkPath::kQuad_Verb: // TBD - just replicate the curve for now if (!prevIsValid) { dst->moveTo(pts[0]); prevIsValid = true; } dst->quadTo(pts[1], pts[2]); lastCorner = pts[2]; firstStep.set(0, 0); break; case SkPath::kCubic_Verb: if (!prevIsValid) { dst->moveTo(pts[0]); prevIsValid = true; } // TBD - just replicate the curve for now dst->cubicTo(pts[1], pts[2], pts[3]); lastCorner = pts[3]; firstStep.set(0, 0); break; case SkPath::kClose_Verb: if (firstStep.fX || firstStep.fY) dst->quadTo(lastCorner.fX, lastCorner.fY, lastCorner.fX + firstStep.fX, lastCorner.fY + firstStep.fY); dst->close(); break; case SkPath::kDone_Verb: goto DONE; } if (SkPath::kMove_Verb == prevVerb) firstStep = step; prevVerb = verb; } DONE: return true; }
bool PrintPlanner::queueMove(const Vec3& target) { BlockBuffer* backBuffer = getBackBuffer(); // Prepare the distance between the current location and the target, and normalize a unit vector for determining incremental extruder positions Vec3 direction = target - _position; float distance = direction.mag(); Vec3 unit = direction.normalized(); // Determine the fastest movement profile that this move can use int moveProfileIndex; for(moveProfileIndex = 0; moveProfileIndex < MOVEMENT_PROFILE_MAX && _config.movementProfiles[moveProfileIndex].minimumDistance > distance; moveProfileIndex++) {} if(moveProfileIndex == MOVEMENT_PROFILE_MAX) { printf("Error: No movement profile short enough to accomodate move\n"); return false; } else { printf("Using movement profile %i\n", moveProfileIndex); } MovementProfile* profile = &_config.movementProfiles[moveProfileIndex]; PositionProfile vars; // Cache some indices for quick lookups int constSpeedDuration = (distance - profile->minimumDistance) / profile->maxVelocity; int decelStart = profile->intervals[2] + constSpeedDuration; int thirdJerkUpper = decelStart + profile->intervals[3]; int fourthJerkLower = decelStart + profile->intervals[4]; int totalBlocks = decelStart + profile->intervals[5]; int blockIndex = 0; for(int i = 0; i < totalBlocks; i++) { // Is this block buffer full? if(blockIndex >= BLOCK_BUFFER_LENGTH) { // Commit this block buffer and move to the next one backBuffer->numberOfBlocks = blockIndex; commitBackBuffer(); backBuffer = getBackBuffer(); } // Determine whether our acceleration is ramping up, ramping down, or staying constant for this block float jerkDirection = 0; if(i < profile->intervals[0] || i >= fourthJerkLower) { jerkDirection = 1.0f; } else if( (i >= profile->intervals[1] && i < profile->intervals[2]) || (i >= decelStart && i < thirdJerkUpper) ) { jerkDirection = -1.0f; } // Iterate our position profile ComputeStep(_config, jerkDirection, vars); printf("\t[%i] ", i); vars.debug(); // Using our unit vector, project the new extruder location Vec3 newPosition = _position + (unit * vars.d); // Determine the new location of the steppers float heights[NUMBER_OF_AXES]; _solver.getHeightsAt(newPosition, heights); for(int j = STEPPER_A; j <= STEPPER_C; j++) { float delta = heights[j] - _stepperPosition[j]; if(fabs(_stepperProgress[j] + delta) >= (_config.zUnitsPerStep * 2)) { printf("ERROR: Speed too fast for stepper %i (will lag behind)\n", i); } _stepperProgress[j] += delta; _stepperPosition[j] = heights[j]; if (_stepperProgress[j] >= _config.zUnitsPerStep) { backBuffer->blocks[i].step[j] = true; backBuffer->blocks[i].forward[j] = true; _stepperProgress[j] -= _config.zUnitsPerStep; printf("\t\tStepper %i moves forward\n", j); } else if(_stepperProgress[j] <= -_config.zUnitsPerStep) { backBuffer->blocks[i].step[j] = true; backBuffer->blocks[i].forward[j] = false; _stepperProgress[j] += _config.zUnitsPerStep; printf("\t\tStepper %i moves backward\n", j); } else { backBuffer->blocks[i].step[j] = false; } } blockIndex++; } backBuffer->numberOfBlocks = blockIndex; commitBackBuffer(); return true; }