Browse Source

Replace some float division with multiplication

pull/1/head
Scott Lahteine 8 years ago
parent
commit
d8f2876753
  1. 6
      Marlin/Marlin_main.cpp
  2. 16
      Marlin/planner.cpp
  3. 6
      Marlin/stepper.cpp
  4. 8
      Marlin/temperature.cpp
  5. 2
      Marlin/ultralcd_impl_DOGM.h

6
Marlin/Marlin_main.cpp

@ -1332,7 +1332,7 @@ inline bool code_value_bool() { return code_value_byte() > 0; }
case TEMPUNIT_C:
return code_value_float();
case TEMPUNIT_F:
return (code_value_float() - 32) / 1.8;
return (code_value_float() - 32) * 0.5555555556;
case TEMPUNIT_K:
return code_value_float() - 272.15;
default:
@ -1346,7 +1346,7 @@ inline bool code_value_bool() { return code_value_byte() > 0; }
case TEMPUNIT_K:
return code_value_float();
case TEMPUNIT_F:
return code_value_float() / 1.8;
return code_value_float() * 0.5555555556;
default:
return code_value_float();
}
@ -6141,7 +6141,7 @@ inline void gcode_M428() {
bool err = false;
LOOP_XYZ(i) {
if (axis_homed[i]) {
float base = (current_position[i] > (sw_endstop_min[i] + sw_endstop_max[i]) / 2) ? base_home_pos(i) : 0,
float base = (current_position[i] > (sw_endstop_min[i] + sw_endstop_max[i]) * 0.5) ? base_home_pos(i) : 0,
diff = current_position[i] - LOGICAL_POSITION(base, i);
if (diff > -20 && diff < 20) {
set_home_offset((AxisEnum)i, home_offset[i] - diff);

16
Marlin/planner.cpp

@ -814,7 +814,7 @@ void Planner::check_axes_activity() {
delta_mm[Z_AXIS] = dz * steps_to_mm[Z_AXIS];
#endif
#endif
delta_mm[E_AXIS] = (de * steps_to_mm[E_AXIS]) * volumetric_multiplier[extruder] * extruder_multiplier[extruder] / 100.0;
delta_mm[E_AXIS] = 0.01 * (de * steps_to_mm[E_AXIS]) * volumetric_multiplier[extruder] * extruder_multiplier[extruder];
if (block->steps[X_AXIS] <= dropsegments && block->steps[Y_AXIS] <= dropsegments && block->steps[Z_AXIS] <= dropsegments) {
block->millimeters = fabs(delta_mm[E_AXIS]);
@ -888,7 +888,7 @@ void Planner::check_axes_activity() {
while (filwidth_delay_dist >= MMD_MM) filwidth_delay_dist -= MMD_MM;
// Convert into an index into the measurement array
filwidth_delay_index1 = (int)(filwidth_delay_dist / 10.0 + 0.0001);
filwidth_delay_index1 = (int)(filwidth_delay_dist * 0.1 + 0.0001);
// If the index has changed (must have gone forward)...
if (filwidth_delay_index1 != filwidth_delay_index2) {
@ -975,7 +975,7 @@ void Planner::check_axes_activity() {
block->acceleration_steps_per_s2 = (max_acceleration_steps_per_s2[E_AXIS] * block->step_event_count) / block->steps[E_AXIS];
}
block->acceleration = block->acceleration_steps_per_s2 / steps_per_mm;
block->acceleration_rate = (long)(block->acceleration_steps_per_s2 * 16777216.0 / ((F_CPU) / 8.0));
block->acceleration_rate = (long)(block->acceleration_steps_per_s2 * 16777216.0 / ((F_CPU) * 0.125));
#if 0 // Use old jerk for now
@ -1021,10 +1021,12 @@ void Planner::check_axes_activity() {
#endif
// Start with a safe speed
float vmax_junction = max_xy_jerk / 2;
float vmax_junction_factor = 1.0;
float mz2 = max_z_jerk / 2, me2 = max_e_jerk / 2;
float csz = current_speed[Z_AXIS], cse = current_speed[E_AXIS];
float vmax_junction = max_xy_jerk * 0.5,
vmax_junction_factor = 1.0,
mz2 = max_z_jerk * 0.5,
me2 = max_e_jerk * 0.5,
csz = current_speed[Z_AXIS],
cse = current_speed[E_AXIS];
if (fabs(csz) > mz2) vmax_junction = min(vmax_junction, mz2);
if (fabs(cse) > me2) vmax_junction = min(vmax_junction, me2);
vmax_junction = min(vmax_junction, block->nominal_speed);

6
Marlin/stepper.cpp

@ -944,7 +944,7 @@ float Stepper::get_axis_position_mm(AxisEnum axis) {
CRITICAL_SECTION_END;
// ((a1+a2)+(a1-a2))/2 -> (a1+a2+a1-a2)/2 -> (a1+a1)/2 -> a1
// ((a1+a2)-(a1-a2))/2 -> (a1+a2-a1+a2)/2 -> (a2+a2)/2 -> a2
axis_steps = (pos1 + ((axis == CORE_AXIS_1) ? pos2 : -pos2)) / 2.0f;
axis_steps = (pos1 + ((axis == CORE_AXIS_1) ? pos2 : -pos2)) * 0.5f;
}
else
axis_steps = position(axis);
@ -973,9 +973,9 @@ void Stepper::endstop_triggered(AxisEnum axis) {
float axis_pos = count_position[axis];
if (axis == CORE_AXIS_1)
axis_pos = (axis_pos + count_position[CORE_AXIS_2]) / 2;
axis_pos = (axis_pos + count_position[CORE_AXIS_2]) * 0.5;
else if (axis == CORE_AXIS_2)
axis_pos = (count_position[CORE_AXIS_1] - axis_pos) / 2;
axis_pos = (count_position[CORE_AXIS_1] - axis_pos) * 0.5;
endstops_trigsteps[axis] = axis_pos;
#else // !COREXY && !COREXZ && !COREYZ

8
Marlin/temperature.cpp

@ -319,13 +319,13 @@ unsigned char Temperature::soft_pwm[HOTENDS];
SERIAL_PROTOCOLPAIR(MSG_T_MIN, min);
SERIAL_PROTOCOLPAIR(MSG_T_MAX, max);
if (cycles > 2) {
Ku = (4.0 * d) / (3.14159265 * (max - min) / 2.0);
Tu = ((float)(t_low + t_high) / 1000.0);
Ku = (4.0 * d) / (3.14159265 * (max - min) * 0.5);
Tu = ((float)(t_low + t_high) * 0.001);
SERIAL_PROTOCOLPAIR(MSG_KU, Ku);
SERIAL_PROTOCOLPAIR(MSG_TU, Tu);
workKp = 0.6 * Ku;
workKi = 2 * workKp / Tu;
workKd = workKp * Tu / 8;
workKd = workKp * Tu * 0.125;
SERIAL_PROTOCOLLNPGM(MSG_CLASSIC_PID);
SERIAL_PROTOCOLPAIR(MSG_KP, workKp);
SERIAL_PROTOCOLPAIR(MSG_KI, workKi);
@ -753,7 +753,7 @@ void Temperature::manage_heater() {
// Get the delayed info and add 100 to reconstitute to a percent of
// the nominal filament diameter then square it to get an area
meas_shift_index = constrain(meas_shift_index, 0, MAX_MEASUREMENT_DELAY);
float vm = pow((measurement_delay[meas_shift_index] + 100.0) / 100.0, 2);
float vm = pow((measurement_delay[meas_shift_index] + 100.0) * 0.01, 2);
NOLESS(vm, 0.01);
volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = vm;
}

2
Marlin/ultralcd_impl_DOGM.h

@ -385,7 +385,7 @@ static void lcd_implementation_status_screen() {
// SD Card Progress bar and clock
if (IS_SD_PRINTING) {
// Progress bar solid part
u8g.drawBox(55, 50, (unsigned int)(71.f * card.percentDone() / 100.f), 2 - (TALL_FONT_CORRECTION));
u8g.drawBox(55, 50, (unsigned int)(71 * card.percentDone() * 0.01), 2 - (TALL_FONT_CORRECTION));
}
u8g.setPrintPos(80,48);

Loading…
Cancel
Save