Kaynağa Gözat

Replace some float division with multiplication

Scott Lahteine 8 yıl önce
ebeveyn
işleme
d8f2876753

+ 3
- 3
Marlin/Marlin_main.cpp Dosyayı Görüntüle

@@ -1332,7 +1332,7 @@ inline bool code_value_bool() { return code_value_byte() > 0; }
1332 1332
       case TEMPUNIT_C:
1333 1333
         return code_value_float();
1334 1334
       case TEMPUNIT_F:
1335
-        return (code_value_float() - 32) / 1.8;
1335
+        return (code_value_float() - 32) * 0.5555555556;
1336 1336
       case TEMPUNIT_K:
1337 1337
         return code_value_float() - 272.15;
1338 1338
       default:
@@ -1346,7 +1346,7 @@ inline bool code_value_bool() { return code_value_byte() > 0; }
1346 1346
       case TEMPUNIT_K:
1347 1347
         return code_value_float();
1348 1348
       case TEMPUNIT_F:
1349
-        return code_value_float() / 1.8;
1349
+        return code_value_float() * 0.5555555556;
1350 1350
       default:
1351 1351
         return code_value_float();
1352 1352
     }
@@ -6141,7 +6141,7 @@ inline void gcode_M428() {
6141 6141
   bool err = false;
6142 6142
   LOOP_XYZ(i) {
6143 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 6145
             diff = current_position[i] - LOGICAL_POSITION(base, i);
6146 6146
       if (diff > -20 && diff < 20) {
6147 6147
         set_home_offset((AxisEnum)i, home_offset[i] - diff);

+ 9
- 7
Marlin/planner.cpp Dosyayı Görüntüle

@@ -814,7 +814,7 @@ void Planner::check_axes_activity() {
814 814
       delta_mm[Z_AXIS] = dz * steps_to_mm[Z_AXIS];
815 815
     #endif
816 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 819
   if (block->steps[X_AXIS] <= dropsegments && block->steps[Y_AXIS] <= dropsegments && block->steps[Z_AXIS] <= dropsegments) {
820 820
     block->millimeters = fabs(delta_mm[E_AXIS]);
@@ -888,7 +888,7 @@ void Planner::check_axes_activity() {
888 888
         while (filwidth_delay_dist >= MMD_MM) filwidth_delay_dist -= MMD_MM;
889 889
 
890 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 893
         // If the index has changed (must have gone forward)...
894 894
         if (filwidth_delay_index1 != filwidth_delay_index2) {
@@ -975,7 +975,7 @@ void Planner::check_axes_activity() {
975 975
       block->acceleration_steps_per_s2 = (max_acceleration_steps_per_s2[E_AXIS] * block->step_event_count) / block->steps[E_AXIS];
976 976
   }
977 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 980
   #if 0  // Use old jerk for now
981 981
 
@@ -1021,10 +1021,12 @@ void Planner::check_axes_activity() {
1021 1021
   #endif
1022 1022
 
1023 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 1030
   if (fabs(csz) > mz2) vmax_junction = min(vmax_junction, mz2);
1029 1031
   if (fabs(cse) > me2) vmax_junction = min(vmax_junction, me2);
1030 1032
   vmax_junction = min(vmax_junction, block->nominal_speed);

+ 3
- 3
Marlin/stepper.cpp Dosyayı Görüntüle

@@ -944,7 +944,7 @@ float Stepper::get_axis_position_mm(AxisEnum axis) {
944 944
       CRITICAL_SECTION_END;
945 945
       // ((a1+a2)+(a1-a2))/2 -> (a1+a2+a1-a2)/2 -> (a1+a1)/2 -> a1
946 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 949
     else
950 950
       axis_steps = position(axis);
@@ -973,9 +973,9 @@ void Stepper::endstop_triggered(AxisEnum axis) {
973 973
 
974 974
     float axis_pos = count_position[axis];
975 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 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 979
     endstops_trigsteps[axis] = axis_pos;
980 980
 
981 981
   #else // !COREXY && !COREXZ && !COREYZ

+ 4
- 4
Marlin/temperature.cpp Dosyayı Görüntüle

@@ -319,13 +319,13 @@ unsigned char Temperature::soft_pwm[HOTENDS];
319 319
               SERIAL_PROTOCOLPAIR(MSG_T_MIN, min);
320 320
               SERIAL_PROTOCOLPAIR(MSG_T_MAX, max);
321 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 324
                 SERIAL_PROTOCOLPAIR(MSG_KU, Ku);
325 325
                 SERIAL_PROTOCOLPAIR(MSG_TU, Tu);
326 326
                 workKp = 0.6 * Ku;
327 327
                 workKi = 2 * workKp / Tu;
328
-                workKd = workKp * Tu / 8;
328
+                workKd = workKp * Tu * 0.125;
329 329
                 SERIAL_PROTOCOLLNPGM(MSG_CLASSIC_PID);
330 330
                 SERIAL_PROTOCOLPAIR(MSG_KP, workKp);
331 331
                 SERIAL_PROTOCOLPAIR(MSG_KI, workKi);
@@ -753,7 +753,7 @@ void Temperature::manage_heater() {
753 753
       // Get the delayed info and add 100 to reconstitute to a percent of
754 754
       // the nominal filament diameter then square it to get an area
755 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 757
       NOLESS(vm, 0.01);
758 758
       volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = vm;
759 759
     }

+ 1
- 1
Marlin/ultralcd_impl_DOGM.h Dosyayı Görüntüle

@@ -385,7 +385,7 @@ static void lcd_implementation_status_screen() {
385 385
     // SD Card Progress bar and clock
386 386
     if (IS_SD_PRINTING) {
387 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 391
     u8g.setPrintPos(80,48);

Loading…
İptal
Kaydet