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

New macros variable - layer_used_filament #4380

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

shm-dmitry
Copy link

I cant include my code in update_print_stats_and_format_filament_stats on GCode.cpp:1221 because this code executes after file exported.
So I added status variable total_used_filament_before_current_layer - this variable contains length of each filament used by printer after code in BEFORE LAYER CHANGE step executed.
This variable is not filled in case of BEFORE LAYER CHANGE custom gcode is empty for optimization reasons, because new macros variable exists in this step only.

This pull request related to issue 4367.

@supermerill
Copy link
Owner

Thanks. I'll merge it shortly.

This variable is not filled in case of BEFORE LAYER CHANGE custom gcode is empty for optimization reasons, because new macros variable exists in this step only.

So, we can also check to see if the custom gcode contains the string total_used_filament_before_current_layer ?

@shm-dmitry
Copy link
Author

@supermerill , I can include IF to check is custom GCODE contains layer_used_filament parameter, I didn't it because I don't see same code for other parameters.
But I can do it in case you find it necessary.

@supermerill
Copy link
Owner

supermerill commented Aug 2, 2024

You said that you only fill it if necessary, "for optimization reasons". I was just wondering if this optimisation can't be even higher.
It's not done for the other, because there isn't any (long) computation needed to set the value.

@shm-dmitry
Copy link
Author

@supermerill , what I was talking about: the macros layer_used_filament only appears in BEFORE_LAYER_CHANGE. So, there is no reason to calculate temporary variables if this CUSTOM GCODE is empty. This is a very simple check, and it already exists in the source code.

Yes, I can verify that this CUSTOM GCODE contains the layer_used_filament macro, and perform the calculation only when it exists.
But this decision have some overhead. I can do it using 2 ways:

  • check "substring contains" at line 3097. But this search also required some resources at each level, thus, the benefits of this solution will be questionable.
  • include some bool variable somewere and execute "substring contains" check once. This would be the best solution if all macros have the same mechanics. Without this, this variable will look redundant. But I can do it if you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants