Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General cleanup of G33 #6533

Merged
merged 3 commits into from
May 2, 2017

Conversation

thinkyhead
Copy link
Member

@thinkyhead thinkyhead commented May 1, 2017

Cleanup of #6523

  • Apply meaningful names to booleans
  • Sanity-check parameter values

*/
inline void gcode_G33() {

stepper.synchronize();
if (axis_unhomed_error(true, true, true)) return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The procedure starts with homing the printer, so this test is not quit required

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling gcode_G28 directly is contraindicated, so we simply require homing ahead of any commands that require it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to call the homing procedure. The calibration procedure needs to home the printer at each iteration otherwise there is no way the printer knows at what position it is after tweaking the end-stops and delta height. It just does not work without homing.

set_bed_leveling_enabled(false);
#endif
const int8_t p_value = code_seen('P') ? code_value_int() : DELTA_CALIBRATION_DEFAULT_POINTS;
if (!WITHIN(p_value, -7, 7)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

within (p_value, 1 , 7)

I changed that at your request that no negative values may be used; the further testing relies on that fact.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

** I'm trying to follow here, so what happens if someone enters P-5 -> p_value = -5

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right. I missed that the negative-ness of the initial parameter had been changed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this:
if (!WITHIN(probe_points, 1, 7)) {

probe_mode = (code_seen('T') && probe_mode > 2 ? -probe_mode : probe_mode);

int8_t verbose_level = (code_seen('V') ? code_value_byte() : 1);
int8_t probe_mode = WITHIN(p_value, 1, 7) ? p_value : DELTA_CALIBRATION_DEFAULT_POINTS;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

** P-5 -> probe_mode is set to DELTA_CALIBRATION_DEFAULT_POINTS

Copy link
Contributor

@LVD-AC LVD-AC May 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No further testing on probe_points is necessary:

int8_t probe_mode = probe_points;


gcode_G28();
const uint8_t probe_points = abs(probe_mode);
Copy link
Contributor

@LVD-AC LVD-AC May 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P-5 -> probe_points is set to abs(DELTA_CALIBRATION_DEFAULT_POINTS) and further testing is done with probe_points.

IMO this unnecessary complicating things and confusing. I think it is better only to allow positive values to the P parameter and assign it directly to probe_points. Then this line can be deleted.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was already there. I just moved it up a few lines.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and delete this indeed

#if PLANNER_LEVELING
set_bed_leveling_enabled(false);
#endif
const int8_t p_value = code_seen('P') ? code_value_int() : DELTA_CALIBRATION_DEFAULT_POINTS;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make that :
const int8_t probe_points = code_seen('P') ? code_value_int() : DELTA_CALIBRATION_DEFAULT_POINTS;

@thinkyhead thinkyhead force-pushed the rc_autocal_patches branch 4 times, most recently from 0001ce6 to d86660f Compare May 1, 2017 20:03
@thinkyhead
Copy link
Member Author

Some developers have been ignoring the embargo on directly calling GCode handler functions, so I've just added home_all_axes as an alternative to gcode_G28 for code that wants to home unceremoniously. Of course, it's just a pass-through to gcode_G28 currently.

const bool pp_height_only = probe_points == 1,
pp_center_and_towers = probe_points == 2,
pp_all_positions = probe_points == 3,
pp_5_points = probe_points == 5,
Copy link
Contributor

@LVD-AC LVD-AC May 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion if you prefer descriptive names:
==1 pp_center_only
==2 pp_towers_or_opposites
==3 pp_towers_and_opposites
(==4 pp_all_single_circle)
==5 pp_all_double_circle
==6 pp_all_triple_circle
==7 pp_all_quadruple_circle
'> 2 pp_with_tower_angles
'> 3 pp_with_intermediates
'> 4 pp_with_multi_circles

* V Verbose level:
* V0 Dry-run mode. Report settings and probe results. No calibration.
* V1 Report settings
* V2 Report settings and probe results
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

stepper.synchronize();
const int8_t probe_points = code_seen('P') ? code_value_int() : DELTA_CALIBRATION_DEFAULT_POINTS;
if (!WITHIN(probe_points, 1, 7)) {
SERIAL_PROTOCOLLNPGM("?(P)oints is implausible (1 to 7).");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


int8_t verbose_level = (code_seen('V') ? code_value_byte() : 1);
const char negating_parameter = pp_height_only ? 'A' : pp_center_and_towers ? 'O' : 'T';
int8_t probe_mode = code_seen(negating_parameter) && code_value_bool() ? -probe_points : probe_points;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@thinkyhead
Copy link
Member Author

Ok, I think I'm done massaging this now… I'll let it cool off for an hour or two, merge it later…


gcode_G28();
home_all_axes();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

if (pp_greather_3 && !pp_equals_5) // average intermediates to tower and opposites
for (uint8_t axis = 1; axis < 13; axis += 2)
if (points_over_3) // average intermediates to tower and opposites
for (uint8_t axis = 1; axis <= 11; axis += 2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you mean, but for future maintenance I would prefer you left '<13' or change all to '<=12' that magic number actually means do a full circle no matter what the step is by which axis is increased.

int8_t pp = (code_seen('P') ? code_value_int() : DELTA_CALIBRATION_DEFAULT_POINTS),
probe_mode = (WITHIN(pp, 1, 7) ? pp : DELTA_CALIBRATION_DEFAULT_POINTS);
const char negating_parameter = pp_height_only ? 'A' : pp_center_and_towers ? 'O' : 'T';
int8_t probe_mode = code_seen(negating_parameter) && code_value_bool() ? -probe_points : probe_points;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

pp_7_points = probe_points == 7,
probe_extra_center = probe_points > 2,
point_averaging = probe_points > 3,
points_over_4 = probe_points > 4;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, sorry this is meaningless! It is not the center points that make the fundamental difference in the different probe grids, it is the radius points...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should it be changed to?

const bool pp_height_only = probe_points == 1,
pp_center_and_towers = probe_points == 2,
pp_all_positions = probe_points == 3,
pp_5_points = probe_points == 5,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll give it another try to make some sense out of it:
==5 pp_double_circle
==6 pp_triple_circle (in fact it probes 6 centre points so the name "all_except_center" is misleading)
==7 pp_quadruple_circle
'>2 pp_seven_point_calibration
'>3 pp_intermedate_averaging
'>4 pp_circle_averaging

Copy link
Contributor

@LVD-AC LVD-AC May 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try to explain: I do averaging in 2 directions (like X and Y on Cartesians) but for Delta's that would be X=more points than just towers and opposite to the towers on the same circle (starts at n>3) and Y=varying the radius of the probe circle (starts at n>4). So your pick, you could replace "double_circle" in the above names to "double_radius" etc and "radial_averaging" or even "radii_averaging" (love the double Latin i, sounds more posh) and replace "intermediate_averaging" with "rotational_averaging" or "axial_averaging" or something of the sort, I do not mind as long as it makes sense.

Copy link
Contributor

@LVD-AC LVD-AC May 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PS: may I suggest that in the >n names only you leave out the leading pp_. That will help me (and others) to distinguish between the names that have only one value (==n) with leading pp_ or a set of values (>n) without leading pp_.

==5 pp_double_radius
==6 pp_tripple_radius
==7 pp_quadruple_radius

'>2 seven_point_calibration
'>3 axial_averaging
'>4 radial_averaging

@thinkyhead thinkyhead force-pushed the rc_autocal_patches branch 4 times, most recently from 5ffe867 to 718f7cb Compare May 1, 2017 22:04
do_circle_x4 = probe_points == 7,
probe_extra_center = probe_points >= 3,
point_averaging = probe_points >= 4,
points_over_4 = probe_points >= 5;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you insist on focusing on the centre points have it your way and make it:

'>=3 : probe_3_extra_center
'>=5 : probe_6_extra_centre

I can live with that, I'm Belgian where surrealisme is not an art movement but a way of life.

Copy link
Member Author

@thinkyhead thinkyhead May 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about probe_center_plus_3 and probe_center_plus_6? Does that accurately convey the meaning?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

surrealisme is not an art movement but a way of life

Ah, so that explains the levitating apple in this function.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Steve Jobs must have had some Belgian roots...

@thinkyhead thinkyhead force-pushed the rc_autocal_patches branch 2 times, most recently from 6c0706a to 320eda5 Compare May 2, 2017 18:54
LVD-AC and others added 3 commits May 2, 2017 15:47
- update comment section
- redefined P5 grid
- minor clean to probe radius routine
- updated EEPROM version to V37 according remark in MarlinFirmware#6517
@thinkyhead thinkyhead merged commit 0803c9d into MarlinFirmware:RCBugFix May 2, 2017
@thinkyhead thinkyhead deleted the rc_autocal_patches branch May 2, 2017 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants