From d6aa149cfa37de60b8d5a50d2cee15cb1fd9a6ee Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Thu, 19 Apr 2018 00:15:08 +0200 Subject: [PATCH] Conserve 58 bytes of flash by returning by reference. --- Firmware/mesh_bed_calibration.cpp | 6 ++---- Firmware/mesh_bed_calibration.h | 4 ++-- Firmware/ultralcd.cpp | 9 +++++---- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp index 907136b6..b8296662 100644 --- a/Firmware/mesh_bed_calibration.cpp +++ b/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; } diff --git a/Firmware/mesh_bed_calibration.h b/Firmware/mesh_bed_calibration.h index 34def34a..d1fa6523 100644 --- a/Firmware/mesh_bed_calibration.h +++ b/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 */ diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index ac5d3bcf..32f03f80 100644 --- a/Firmware/ultralcd.cpp +++ b/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())