Skip to content

Add Z Fade Height to M420 output if it is enabled #7042

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

Merged
merged 4 commits into from
Jun 19, 2017
Merged

Add Z Fade Height to M420 output if it is enabled #7042

merged 4 commits into from
Jun 19, 2017

Conversation

FHeilmann
Copy link
Contributor

When M420 is used, it echos the current state of the leveling.
With this change M420 will also echo the current value of the z fade height (if it is enabled).

This makes it easier to deduce what value the z fade height currently has.

Echo the z-fade height when M420 is called, if it is enabled.
@FHeilmann
Copy link
Contributor Author

FHeilmann commented Jun 12, 2017

One might also consider printing MSG_OFF instead of 0.0 by replacing

SERIAL_ECHOLNPAIR("Fade Height ", planner.z_fade_height);

with

SERIAL_ECHOLNPAIR("Fade Height ", planner.z_fade_height > 0.0 ? planner.z_fade_height : MSG_OFF);
let me know and I'll make the change.

@thinkyhead
Copy link
Member

thinkyhead commented Jun 19, 2017

I like this.

"OFF" is ok. It does make an extra piece of work for hosts though 😉 .

Watch out for that ternary. Its terms are not the same type, and the compiler will bark. You'll need two echos, possibly.

SERIAL_ECHOPGM("Fade Height ");
if (planner.z_fade_height > 0.0)
  SERIAL_ECHOLN(planner.z_fade_height);
else
  SERIAL_ECHOLNPGM(MSG_OFF);

@FHeilmann
Copy link
Contributor Author

I made the change as you suggested, I didn't know that the compiler wouldn't like a ternary like that. Good to know ;) Thanks for the heads up.

@thinkyhead
Copy link
Member

I didn't know that the compiler wouldn't like a ternary like that. Good to know ;)

Yeah, think of it like this: Everything in C returns a value with a certain type. For example, this valid line of C simply sends the value of my_value to nowhere:

my_value;

A ternary is like a mini function that returns a single value of some type. You're allowed to do this too, as long as the two functions return the same type:

my_cond ? function_one() : function_two();

If functions don't return the same type, you have to cast:

int answer = my_cond ? (int)function_one_return_bool() : function_two_return_int();

@thinkyhead thinkyhead merged commit 6dcf42f into MarlinFirmware:bugfix-1.1.x Jun 19, 2017
@FHeilmann FHeilmann deleted the patch-2 branch June 20, 2017 09:17
@fiveangle
Copy link
Contributor

You've just cleared up something that had perplexed me before Scott - thanks :)

damicreabox pushed a commit to damicreabox/Marlin that referenced this pull request Sep 14, 2018
* Add Z Fade Height to M420 Output

Echo the z-fade height when M420 is called, if it is enabled.

* Fix Whitespace

* Fix Compiler complaint

* Missing semi-colon
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.

3 participants