// TODO replace this with std::function()
template<typename T> Hook* attach( uint32_t frequency, T *optr, uint32_t ( T::*fptr )( uint32_t ) ){
Hook* hook = new Hook();
- hook->interval = int(floor((SystemCoreClock/4)/frequency));
+ hook->interval = floorf((SystemCoreClock/4)/frequency);
hook->attach(optr, fptr);
hook->countdown = hook->interval;
// Set the base stepping frequency
void StepTicker::set_frequency( float frequency ){
this->frequency = frequency;
- this->period = int(floor((SystemCoreClock/4)/frequency)); // SystemCoreClock/4 = Timer increments in a second
+ this->period = floorf((SystemCoreClock/4)/frequency); // SystemCoreClock/4 = Timer increments in a second
LPC_TIM0->MR0 = this->period;
if( LPC_TIM0->TC > LPC_TIM0->MR0 ){
LPC_TIM0->TCR = 3; // Reset
// Set the reset delay
void StepTicker::set_reset_delay( float seconds ){
- this->delay = int(floor(float(SystemCoreClock/4)*( seconds ))); // SystemCoreClock/4 = Timer increments in a second
+ this->delay = floorf(float(SystemCoreClock/4)*( seconds )); // SystemCoreClock/4 = Timer increments in a second
LPC_TIM1->MR0 = this->delay;
}
// How many steps to accelerate and decelerate
float acceleration_per_second = this->rate_delta * THEKERNEL->stepper->get_acceleration_ticks_per_second(); // ( step/s^2)
int accelerate_steps = ceilf( this->estimate_acceleration_distance( this->initial_rate, this->nominal_rate, acceleration_per_second ) );
- int decelerate_steps = floor( this->estimate_acceleration_distance( this->nominal_rate, this->final_rate, -acceleration_per_second ) );
+ int decelerate_steps = floorf( this->estimate_acceleration_distance( this->nominal_rate, this->final_rate, -acceleration_per_second ) );
// Calculate the size of Plateau of Nominal Rate ( during which we don't accelerate nor decelerate, but just cruise )
int plateau_steps = this->steps_event_count - accelerate_steps - decelerate_steps;
this->distance_in_gcode_is_known( gcode );
// Figure out how many segments for this gcode
- uint16_t segments = floor(gcode->millimeters_of_travel / this->mm_per_arc_segment);
+ uint16_t segments = floorf(gcode->millimeters_of_travel / this->mm_per_arc_segment);
float theta_per_segment = angular_travel / segments;
float linear_per_segment = linear_travel / segments;
if( !STEPPER[c]->is_moving() ) continue;
uint32_t current_rate = STEPPER[c]->get_steps_per_second();
- uint32_t target_rate = int(floor(this->feed_rate[c]*STEPS_PER_MM(c)));
+ uint32_t target_rate = floorf(this->feed_rate[c]*STEPS_PER_MM(c));
float acc= (c==Z_AXIS) ? THEKERNEL->planner->get_z_acceleration() : THEKERNEL->planner->get_acceleration();
if( current_rate < target_rate ){
- uint32_t rate_increase = floor((acc/THEKERNEL->stepper->get_acceleration_ticks_per_second())*STEPS_PER_MM(c));
+ uint32_t rate_increase = floorf((acc/THEKERNEL->stepper->get_acceleration_ticks_per_second())*STEPS_PER_MM(c));
current_rate = min( target_rate, current_rate + rate_increase );
}
if( current_rate > target_rate ){ current_rate = target_rate; }
this->current_position += this->travel_distance ;
- int steps_to_step = abs(int(floor(this->steps_per_millimeter * (this->travel_distance + this->unstepped_distance) )));
+ int steps_to_step = abs(floorf(this->steps_per_millimeter * (this->travel_distance + this->unstepped_distance) ));
if ( this->travel_distance > 0 ) {
this->unstepped_distance += this->travel_distance - (steps_to_step / this->steps_per_millimeter); //catch any overflow
this->current_position += this->travel_distance;
- int steps_to_step = abs(int(floor(this->steps_per_millimeter * (this->travel_distance + this->unstepped_distance) )));
+ int steps_to_step = abs(floorf(this->steps_per_millimeter * (this->travel_distance + this->unstepped_distance) ));
if ( this->travel_distance > 0 ) {
this->unstepped_distance += this->travel_distance - (steps_to_step / this->steps_per_millimeter); //catch any overflow
if(!this->stepper_motor->is_moving()) return 0;
uint32_t current_rate = this->stepper_motor->get_steps_per_second();
- uint32_t target_rate = int(floor(this->feed_rate * this->steps_per_millimeter));
+ uint32_t target_rate = floorf(this->feed_rate * this->steps_per_millimeter);
if( current_rate < target_rate ) {
- uint32_t rate_increase = int(floor((this->acceleration / THEKERNEL->stepper->get_acceleration_ticks_per_second()) * this->steps_per_millimeter));
+ uint32_t rate_increase = floorf((this->acceleration / THEKERNEL->stepper->get_acceleration_ticks_per_second()) * this->steps_per_millimeter);
current_rate = min( target_rate, current_rate + rate_increase );
}
if( current_rate > target_rate ) {
void ZProbe::accelerate(int c)
{ uint32_t current_rate = STEPPER[c]->get_steps_per_second();
- uint32_t target_rate = int(floor(this->current_feedrate));
+ uint32_t target_rate = floorf(this->current_feedrate);
// Z may have a different acceleration to X and Y
float acc= (c==Z_AXIS) ? THEKERNEL->planner->get_z_acceleration() : THEKERNEL->planner->get_acceleration();
if( current_rate < target_rate ) {
- uint32_t rate_increase = floor((acc / THEKERNEL->stepper->get_acceleration_ticks_per_second()) * STEPS_PER_MM(c));
+ uint32_t rate_increase = floorf((acc / THEKERNEL->stepper->get_acceleration_ticks_per_second()) * STEPS_PER_MM(c));
current_rate = min( target_rate, current_rate + rate_increase );
}
if( current_rate > target_rate ) {