Conserve 58 bytes of flash by returning by reference.

This commit is contained in:
Marek Bel 2018-04-19 00:15:08 +02:00
parent ae08788c99
commit d6aa149cfa
3 changed files with 9 additions and 10 deletions

View file

@ -2960,8 +2960,7 @@ void babystep_reset()
babystepLoadZ = 0; babystepLoadZ = 0;
} }
DistanceMin count_xyz_details() { void count_xyz_details(float (&distanceMin)[2]) {
DistanceMin distanceMin;
float cntr[2] = { float cntr[2] = {
eeprom_read_float((float*)(EEPROM_BED_CALIBRATION_CENTER + 0)), eeprom_read_float((float*)(EEPROM_BED_CALIBRATION_CENTER + 0)),
eeprom_read_float((float*)(EEPROM_BED_CALIBRATION_CENTER + 4)) eeprom_read_float((float*)(EEPROM_BED_CALIBRATION_CENTER + 4))
@ -2981,8 +2980,7 @@ DistanceMin count_xyz_details() {
#endif #endif
for (uint8_t mesh_point = 0; mesh_point < 2; ++mesh_point) { 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]; 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;
} }

View file

@ -181,8 +181,8 @@ extern void babystep_undo();
// Reset the current babystep counter without moving the axes. // Reset the current babystep counter without moving the axes.
extern void babystep_reset(); 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(); extern bool sample_z();
#endif /* MESH_BED_CALIBRATION_H */ #endif /* MESH_BED_CALIBRATION_H */

View file

@ -2295,13 +2295,14 @@ static void lcd_menu_xyz_y_min()
lcd_print_at_PGM(0, 2, MSG_LEFT); lcd_print_at_PGM(0, 2, MSG_LEFT);
lcd_print_at_PGM(0, 3, MSG_RIGHT); 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++) { 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_at_PGM(11, i + 2, PSTR(""));
lcd.print(distanceMin.d[i]); lcd.print(distanceMin[i]);
lcd_print_at_PGM((distanceMin.d[i] < 0) ? 17 : 16, i + 2, PSTR("mm")); lcd_print_at_PGM((distanceMin[i] < 0) ? 17 : 16, i + 2, PSTR("mm"));
} else lcd_print_at_PGM(11, i + 2, PSTR("N/A")); } else lcd_print_at_PGM(11, i + 2, PSTR("N/A"));
} }
if (lcd_clicked()) if (lcd_clicked())