Browse Source

Replace some float division with multiplication

Scott Lahteine 9 years ago
parent
commit
d8f2876753
5 changed files with 20 additions and 18 deletions
  1. 3
    3
      Marlin/Marlin_main.cpp
  2. 9
    7
      Marlin/planner.cpp
  3. 3
    3
      Marlin/stepper.cpp
  4. 4
    4
      Marlin/temperature.cpp
  5. 1
    1
      Marlin/ultralcd_impl_DOGM.h

+ 3
- 3
Marlin/Marlin_main.cpp View File

1332
       case TEMPUNIT_C:
1332
       case TEMPUNIT_C:
1333
         return code_value_float();
1333
         return code_value_float();
1334
       case TEMPUNIT_F:
1334
       case TEMPUNIT_F:
1335
-        return (code_value_float() - 32) / 1.8;
1335
+        return (code_value_float() - 32) * 0.5555555556;
1336
       case TEMPUNIT_K:
1336
       case TEMPUNIT_K:
1337
         return code_value_float() - 272.15;
1337
         return code_value_float() - 272.15;
1338
       default:
1338
       default:
1346
       case TEMPUNIT_K:
1346
       case TEMPUNIT_K:
1347
         return code_value_float();
1347
         return code_value_float();
1348
       case TEMPUNIT_F:
1348
       case TEMPUNIT_F:
1349
-        return code_value_float() / 1.8;
1349
+        return code_value_float() * 0.5555555556;
1350
       default:
1350
       default:
1351
         return code_value_float();
1351
         return code_value_float();
1352
     }
1352
     }
6141
   bool err = false;
6141
   bool err = false;
6142
   LOOP_XYZ(i) {
6142
   LOOP_XYZ(i) {
6143
     if (axis_homed[i]) {
6143
     if (axis_homed[i]) {
6144
-      float base = (current_position[i] > (sw_endstop_min[i] + sw_endstop_max[i]) / 2) ? base_home_pos(i) : 0,
6144
+      float base = (current_position[i] > (sw_endstop_min[i] + sw_endstop_max[i]) * 0.5) ? base_home_pos(i) : 0,
6145
             diff = current_position[i] - LOGICAL_POSITION(base, i);
6145
             diff = current_position[i] - LOGICAL_POSITION(base, i);
6146
       if (diff > -20 && diff < 20) {
6146
       if (diff > -20 && diff < 20) {
6147
         set_home_offset((AxisEnum)i, home_offset[i] - diff);
6147
         set_home_offset((AxisEnum)i, home_offset[i] - diff);

+ 9
- 7
Marlin/planner.cpp View File

814
       delta_mm[Z_AXIS] = dz * steps_to_mm[Z_AXIS];
814
       delta_mm[Z_AXIS] = dz * steps_to_mm[Z_AXIS];
815
     #endif
815
     #endif
816
   #endif
816
   #endif
817
-  delta_mm[E_AXIS] = (de * steps_to_mm[E_AXIS]) * volumetric_multiplier[extruder] * extruder_multiplier[extruder] / 100.0;
817
+  delta_mm[E_AXIS] = 0.01 * (de * steps_to_mm[E_AXIS]) * volumetric_multiplier[extruder] * extruder_multiplier[extruder];
818
 
818
 
819
   if (block->steps[X_AXIS] <= dropsegments && block->steps[Y_AXIS] <= dropsegments && block->steps[Z_AXIS] <= dropsegments) {
819
   if (block->steps[X_AXIS] <= dropsegments && block->steps[Y_AXIS] <= dropsegments && block->steps[Z_AXIS] <= dropsegments) {
820
     block->millimeters = fabs(delta_mm[E_AXIS]);
820
     block->millimeters = fabs(delta_mm[E_AXIS]);
888
         while (filwidth_delay_dist >= MMD_MM) filwidth_delay_dist -= MMD_MM;
888
         while (filwidth_delay_dist >= MMD_MM) filwidth_delay_dist -= MMD_MM;
889
 
889
 
890
         // Convert into an index into the measurement array
890
         // Convert into an index into the measurement array
891
-        filwidth_delay_index1 = (int)(filwidth_delay_dist / 10.0 + 0.0001);
891
+        filwidth_delay_index1 = (int)(filwidth_delay_dist * 0.1 + 0.0001);
892
 
892
 
893
         // If the index has changed (must have gone forward)...
893
         // If the index has changed (must have gone forward)...
894
         if (filwidth_delay_index1 != filwidth_delay_index2) {
894
         if (filwidth_delay_index1 != filwidth_delay_index2) {
975
       block->acceleration_steps_per_s2 = (max_acceleration_steps_per_s2[E_AXIS] * block->step_event_count) / block->steps[E_AXIS];
975
       block->acceleration_steps_per_s2 = (max_acceleration_steps_per_s2[E_AXIS] * block->step_event_count) / block->steps[E_AXIS];
976
   }
976
   }
977
   block->acceleration = block->acceleration_steps_per_s2 / steps_per_mm;
977
   block->acceleration = block->acceleration_steps_per_s2 / steps_per_mm;
978
-  block->acceleration_rate = (long)(block->acceleration_steps_per_s2 * 16777216.0 / ((F_CPU) / 8.0));
978
+  block->acceleration_rate = (long)(block->acceleration_steps_per_s2 * 16777216.0 / ((F_CPU) * 0.125));
979
 
979
 
980
   #if 0  // Use old jerk for now
980
   #if 0  // Use old jerk for now
981
 
981
 
1021
   #endif
1021
   #endif
1022
 
1022
 
1023
   // Start with a safe speed
1023
   // Start with a safe speed
1024
-  float vmax_junction = max_xy_jerk / 2;
1025
-  float vmax_junction_factor = 1.0;
1026
-  float mz2 = max_z_jerk / 2, me2 = max_e_jerk / 2;
1027
-  float csz = current_speed[Z_AXIS], cse = current_speed[E_AXIS];
1024
+  float vmax_junction = max_xy_jerk * 0.5,
1025
+        vmax_junction_factor = 1.0,
1026
+        mz2 = max_z_jerk * 0.5,
1027
+        me2 = max_e_jerk * 0.5,
1028
+        csz = current_speed[Z_AXIS],
1029
+        cse = current_speed[E_AXIS];
1028
   if (fabs(csz) > mz2) vmax_junction = min(vmax_junction, mz2);
1030
   if (fabs(csz) > mz2) vmax_junction = min(vmax_junction, mz2);
1029
   if (fabs(cse) > me2) vmax_junction = min(vmax_junction, me2);
1031
   if (fabs(cse) > me2) vmax_junction = min(vmax_junction, me2);
1030
   vmax_junction = min(vmax_junction, block->nominal_speed);
1032
   vmax_junction = min(vmax_junction, block->nominal_speed);

+ 3
- 3
Marlin/stepper.cpp View File

944
       CRITICAL_SECTION_END;
944
       CRITICAL_SECTION_END;
945
       // ((a1+a2)+(a1-a2))/2 -> (a1+a2+a1-a2)/2 -> (a1+a1)/2 -> a1
945
       // ((a1+a2)+(a1-a2))/2 -> (a1+a2+a1-a2)/2 -> (a1+a1)/2 -> a1
946
       // ((a1+a2)-(a1-a2))/2 -> (a1+a2-a1+a2)/2 -> (a2+a2)/2 -> a2
946
       // ((a1+a2)-(a1-a2))/2 -> (a1+a2-a1+a2)/2 -> (a2+a2)/2 -> a2
947
-      axis_steps = (pos1 + ((axis == CORE_AXIS_1) ? pos2 : -pos2)) / 2.0f;
947
+      axis_steps = (pos1 + ((axis == CORE_AXIS_1) ? pos2 : -pos2)) * 0.5f;
948
     }
948
     }
949
     else
949
     else
950
       axis_steps = position(axis);
950
       axis_steps = position(axis);
973
 
973
 
974
     float axis_pos = count_position[axis];
974
     float axis_pos = count_position[axis];
975
     if (axis == CORE_AXIS_1)
975
     if (axis == CORE_AXIS_1)
976
-      axis_pos = (axis_pos + count_position[CORE_AXIS_2]) / 2;
976
+      axis_pos = (axis_pos + count_position[CORE_AXIS_2]) * 0.5;
977
     else if (axis == CORE_AXIS_2)
977
     else if (axis == CORE_AXIS_2)
978
-      axis_pos = (count_position[CORE_AXIS_1] - axis_pos) / 2;
978
+      axis_pos = (count_position[CORE_AXIS_1] - axis_pos) * 0.5;
979
     endstops_trigsteps[axis] = axis_pos;
979
     endstops_trigsteps[axis] = axis_pos;
980
 
980
 
981
   #else // !COREXY && !COREXZ && !COREYZ
981
   #else // !COREXY && !COREXZ && !COREYZ

+ 4
- 4
Marlin/temperature.cpp View File

319
               SERIAL_PROTOCOLPAIR(MSG_T_MIN, min);
319
               SERIAL_PROTOCOLPAIR(MSG_T_MIN, min);
320
               SERIAL_PROTOCOLPAIR(MSG_T_MAX, max);
320
               SERIAL_PROTOCOLPAIR(MSG_T_MAX, max);
321
               if (cycles > 2) {
321
               if (cycles > 2) {
322
-                Ku = (4.0 * d) / (3.14159265 * (max - min) / 2.0);
323
-                Tu = ((float)(t_low + t_high) / 1000.0);
322
+                Ku = (4.0 * d) / (3.14159265 * (max - min) * 0.5);
323
+                Tu = ((float)(t_low + t_high) * 0.001);
324
                 SERIAL_PROTOCOLPAIR(MSG_KU, Ku);
324
                 SERIAL_PROTOCOLPAIR(MSG_KU, Ku);
325
                 SERIAL_PROTOCOLPAIR(MSG_TU, Tu);
325
                 SERIAL_PROTOCOLPAIR(MSG_TU, Tu);
326
                 workKp = 0.6 * Ku;
326
                 workKp = 0.6 * Ku;
327
                 workKi = 2 * workKp / Tu;
327
                 workKi = 2 * workKp / Tu;
328
-                workKd = workKp * Tu / 8;
328
+                workKd = workKp * Tu * 0.125;
329
                 SERIAL_PROTOCOLLNPGM(MSG_CLASSIC_PID);
329
                 SERIAL_PROTOCOLLNPGM(MSG_CLASSIC_PID);
330
                 SERIAL_PROTOCOLPAIR(MSG_KP, workKp);
330
                 SERIAL_PROTOCOLPAIR(MSG_KP, workKp);
331
                 SERIAL_PROTOCOLPAIR(MSG_KI, workKi);
331
                 SERIAL_PROTOCOLPAIR(MSG_KI, workKi);
753
       // Get the delayed info and add 100 to reconstitute to a percent of
753
       // Get the delayed info and add 100 to reconstitute to a percent of
754
       // the nominal filament diameter then square it to get an area
754
       // the nominal filament diameter then square it to get an area
755
       meas_shift_index = constrain(meas_shift_index, 0, MAX_MEASUREMENT_DELAY);
755
       meas_shift_index = constrain(meas_shift_index, 0, MAX_MEASUREMENT_DELAY);
756
-      float vm = pow((measurement_delay[meas_shift_index] + 100.0) / 100.0, 2);
756
+      float vm = pow((measurement_delay[meas_shift_index] + 100.0) * 0.01, 2);
757
       NOLESS(vm, 0.01);
757
       NOLESS(vm, 0.01);
758
       volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = vm;
758
       volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = vm;
759
     }
759
     }

+ 1
- 1
Marlin/ultralcd_impl_DOGM.h View File

385
     // SD Card Progress bar and clock
385
     // SD Card Progress bar and clock
386
     if (IS_SD_PRINTING) {
386
     if (IS_SD_PRINTING) {
387
       // Progress bar solid part
387
       // Progress bar solid part
388
-      u8g.drawBox(55, 50, (unsigned int)(71.f * card.percentDone() / 100.f), 2 - (TALL_FONT_CORRECTION));
388
+      u8g.drawBox(55, 50, (unsigned int)(71 * card.percentDone() * 0.01), 2 - (TALL_FONT_CORRECTION));
389
     }
389
     }
390
 
390
 
391
     u8g.setPrintPos(80,48);
391
     u8g.setPrintPos(80,48);

Loading…
Cancel
Save