From: Jim Morris Date: Fri, 21 Nov 2014 06:02:25 +0000 (-0800) Subject: use floorf isntead of floor X-Git-Url: https://git.hcoop.net/clinton/Smoothieware.git/commitdiff_plain/c8f4ee77e4b12186f0714ebee3d0e319fa516eaf?hp=9502f9d519c4c8fe56f8cfa0442048c2aa87371f use floorf isntead of floor --- diff --git a/src/libs/SlowTicker.h b/src/libs/SlowTicker.h index 133dd787..242273bf 100644 --- a/src/libs/SlowTicker.h +++ b/src/libs/SlowTicker.h @@ -36,7 +36,7 @@ class SlowTicker : public Module{ // TODO replace this with std::function() template 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; diff --git a/src/libs/StepTicker.cpp b/src/libs/StepTicker.cpp index 06f21d79..93472286 100644 --- a/src/libs/StepTicker.cpp +++ b/src/libs/StepTicker.cpp @@ -63,7 +63,7 @@ StepTicker::~StepTicker() { // 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 @@ -73,7 +73,7 @@ void StepTicker::set_frequency( float frequency ){ // 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; } diff --git a/src/modules/robot/Block.cpp b/src/modules/robot/Block.cpp index 060919d9..ff2a806d 100644 --- a/src/modules/robot/Block.cpp +++ b/src/modules/robot/Block.cpp @@ -109,7 +109,7 @@ void Block::calculate_trapezoid( float entryspeed, float exitspeed ) // 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; diff --git a/src/modules/robot/Robot.cpp b/src/modules/robot/Robot.cpp index c2283c43..e50bc8e6 100644 --- a/src/modules/robot/Robot.cpp +++ b/src/modules/robot/Robot.cpp @@ -780,7 +780,7 @@ void Robot::append_arc(Gcode *gcode, float target[], float offset[], float radiu 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; diff --git a/src/modules/tools/endstops/Endstops.cpp b/src/modules/tools/endstops/Endstops.cpp index 4f9131a2..75ce7e47 100644 --- a/src/modules/tools/endstops/Endstops.cpp +++ b/src/modules/tools/endstops/Endstops.cpp @@ -743,10 +743,10 @@ uint32_t Endstops::acceleration_tick(uint32_t dummy) 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; } diff --git a/src/modules/tools/extruder/Extruder.cpp b/src/modules/tools/extruder/Extruder.cpp index 1e9cc2f0..9cd5fec6 100644 --- a/src/modules/tools/extruder/Extruder.cpp +++ b/src/modules/tools/extruder/Extruder.cpp @@ -474,7 +474,7 @@ void Extruder::on_block_begin(void *argument) 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 @@ -500,7 +500,7 @@ void Extruder::on_block_begin(void *argument) 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 @@ -548,10 +548,10 @@ uint32_t Extruder::acceleration_tick(uint32_t dummy) 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 ) { diff --git a/src/modules/tools/zprobe/ZProbe.cpp b/src/modules/tools/zprobe/ZProbe.cpp index 6eab717c..46314f98 100644 --- a/src/modules/tools/zprobe/ZProbe.cpp +++ b/src/modules/tools/zprobe/ZProbe.cpp @@ -313,12 +313,12 @@ uint32_t ZProbe::acceleration_tick(uint32_t dummy) 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 ) {