Преглед на файлове

Conserve 58 bytes of flash by returning by reference.

Marek Bel преди 6 години
родител
ревизия
d6aa149cfa
променени са 3 файла, в които са добавени 9 реда и са изтрити 10 реда
  1. 2 4
      Firmware/mesh_bed_calibration.cpp
  2. 2 2
      Firmware/mesh_bed_calibration.h
  3. 5 4
      Firmware/ultralcd.cpp

+ 2 - 4
Firmware/mesh_bed_calibration.cpp

@@ -2960,8 +2960,7 @@ void babystep_reset()
       babystepLoadZ = 0;    
 }
 
-DistanceMin count_xyz_details() {
-    DistanceMin distanceMin;
+void count_xyz_details(float (&distanceMin)[2]) {
 	float cntr[2] = {
 		eeprom_read_float((float*)(EEPROM_BED_CALIBRATION_CENTER + 0)),
 		eeprom_read_float((float*)(EEPROM_BED_CALIBRATION_CENTER + 4))
@@ -2981,8 +2980,7 @@ DistanceMin count_xyz_details() {
 #endif
 	for (uint8_t mesh_point = 0; mesh_point < 2; ++mesh_point) {
 		float y = vec_x[1] * pgm_read_float(bed_ref_points_4 + mesh_point * 2) + vec_y[1] * pgm_read_float(bed_ref_points_4 + mesh_point * 2 + 1) + cntr[1];
-		distanceMin.d[mesh_point] = (y - Y_MIN_POS_CALIBRATION_POINT_OUT_OF_REACH);
+		distanceMin[mesh_point] = (y - Y_MIN_POS_CALIBRATION_POINT_OUT_OF_REACH);
 	}
-	return distanceMin;
 }
 

+ 2 - 2
Firmware/mesh_bed_calibration.h

@@ -181,8 +181,8 @@ extern void babystep_undo();
 
 // Reset the current babystep counter without moving the axes.
 extern void babystep_reset();
-typedef struct{ float d[2];} DistanceMin;
-extern DistanceMin count_xyz_details();
+
+extern void count_xyz_details(float (&distanceMin)[2]);
 extern bool sample_z();
 
 #endif /* MESH_BED_CALIBRATION_H */

+ 5 - 4
Firmware/ultralcd.cpp

@@ -2295,13 +2295,14 @@ static void lcd_menu_xyz_y_min()
     lcd_print_at_PGM(0, 2, MSG_LEFT);
     lcd_print_at_PGM(0, 3, MSG_RIGHT);
 
-    DistanceMin distanceMin = count_xyz_details();
+    float distanceMin[2];
+    count_xyz_details(distanceMin);
 
     for (int i = 0; i < 2; i++) {
-        if(distanceMin.d[i] < 200) {
+        if(distanceMin[i] < 200) {
             lcd_print_at_PGM(11, i + 2, PSTR(""));
-            lcd.print(distanceMin.d[i]);
-            lcd_print_at_PGM((distanceMin.d[i] < 0) ? 17 : 16, i + 2, PSTR("mm"));
+            lcd.print(distanceMin[i]);
+            lcd_print_at_PGM((distanceMin[i] < 0) ? 17 : 16, i + 2, PSTR("mm"));
         } else lcd_print_at_PGM(11, i + 2, PSTR("N/A"));
     }
     if (lcd_clicked())