-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
add SET_PRINT_STATS_INFO
G-Code for pass slicer variables to Klipper
#5726
add SET_PRINT_STATS_INFO
G-Code for pass slicer variables to Klipper
#5726
Conversation
This adds a gcode called LAYER that can be used insight the slicer to pass the total layer count and current layer information. Signed-off-by: Stefan Dej <[email protected]>
a small addition and good idea from @pedrolamas: it would be also possible to add this gcode via moonraker preprocessor (like the exclude object gcode). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks ok for me
Thanks. I don't really have an opinion on this (other than the command should probably be more descriptive). I'd like to see others comment on this. It is a bit unusual for us to create a command just to standardize the command name. -Kevin |
Hello Kevin, first sorry for the following wall of text but I feel it is needed to clarify the motivation of that PR. The reason is not to standardize the command name, the real reason is to standardize the variables that are needed by the UI to show that information.
These are needed by the UIs to accurate show the total and current layer the print is at. I know we can argue now if that information is useful or needed but the simple fact is that many users want to have these information shown in the UI and requested it at fluidd and Mainsail. I personally startet than to analyze if klipper itself could generate these information by analyzing the gcode file while loading it at print start. This method has for me the following downsides:
We than came to the conclusion the best place to do it is the slicer as it knows when it adds a real layer change and should also know what the current and total layer is. And regardless if the user adds a call of a GCODE (or macro) in the layer change gcode section or by a postprocessor done in moonraker that will give us the most accurate information. I know that this could be done with a custom macro (In this case 2 as we would need an override of SDCARD_RESET_FILE). But to be honest the UI would need to do a lot of extra stuff to secure against the case that the 2 variables above are missing. Also the experience with fluidd.cfg/mainsail.cfg and timelapse.cfg (all containing necessary setups and macros) has shown that many user struggling with simple tasks like adding them or run in problems as we need to do overrides to existing GCODEs that generates conflicts in there own config that they are not able to solve. In the end the only reason for the GCODE Layer is to fill the 2 status variable that then can be safely used by the UI, but for the UIs it is important to have these standardize place to read these information. We at Mainsail where the opinion that LAYER is a good name for it but if you know a better one changing it would be a piece of cake Best regards Alex |
As @zellneralex has very well pointed out, in Fluidd we experienced the same type of questions (and bugs!) regarding Current Layer Number & Total Layers Count. I like the idea behind this PR: the new I'm not entirely sure of the name of the command though... as this is under the Having said that, makes me wonder if a more generic approach should be explored: today we need the Layer Number & Count, tomorrow... who knows? Why not make this a way for the slicer to pass metadata (key-value pairs) to Klipper that can then be retrieved by the UI? |
@pedrolamas as much I like the idea of a general key value parser as an engineer as much I fear it from the user to UI perspective . But in general it would be a good idea to parse slicer metadata inside klipper so that the user can use them inside the macros and I have seen PRs about that already. e.g. #4935 and you know how it ended ;-) |
A bit different as I don't want Klipper to parse anything, but to provide a command that would allow the slicer to directly pass metadata to Klipper... but in the end, I guess it might fall under the same category! 😁 |
Thanks for the explanation. So, to summarize:
Did I understand the above correctly? If a new command is added to Klipper, what is expected to generate the command? Are users expected to modify the slicer config to emit them, are slicer developers expected to change the code to emit it, or is a post-processing step expected to alter the g-code to emit it? -Kevin |
I believe there are two options there:
|
@KevinOConnor yes you summarize it correct and @pedrolamas already mentioned the 2 method that normally can be done. In case of SuperSlicer we might get it also included in the the slicer but I do not believe any other slicer will do it. The user already needs to add stuff to there slicer to be able to use timelapse or to get metadata that moonraker can extract while uploading the gcode files. |
@pedrolamas and @zellneralex have already explained/completed most of this very well. the name |
Thank you for your contribution to Klipper. Unfortunately, a reviewer has not assigned themselves to this GitHub Pull Request. All Pull Requests are reviewed before merging, and a reviewer will need to volunteer. Further information is available at: https://www.klipper3d.org/CONTRIBUTING.html There are some steps that you can take now:
Unfortunately, if a reviewer does not assign themselves to this GitHub Pull Request then it will be automatically closed. If this happens, then it is a good idea to move further discussion to the Klipper Discourse server. Reviewers can reach out on that forum to let you know if they are interested and when they are available. Best regards, PS: I'm just an automated script, not a human being. |
In case it helps the discussion along, I've had this layer tracking functionality in my own macros for a while. I use it to schedule events at layer changes, such as pauses that don't mar exterior perimeters, or future temperature and fan (changes beyond the typical first layer stuff). All of that functionality can of course be done through the macro system, but I agree that the big gap is integrating with the UI. If I'm scheduling these events on a live print I inevitably have to use the console, since the UI's layers are an estimate that's often wrong (as @zellneralex described). However, this is the sort of thing that would integrate very nicely with the UI if it had accurate layer state. I also have a few thoughts to add on the implementation:
|
Thanks for the feedback. I don't really have an opinion on this. I'm okay with adding the support if it is desired by the UIs. I'd suggest some changes though:
@Arksine may have comments as the original author of the print_stats.py module. Cheers, |
8f55bdb
to
f6058c8
Compare
# Conflicts: # docs/G-Codes.md
Signed-off-by: Stefan Dej <[email protected]>
…ENT_LAYER attribute Signed-off-by: Stefan Dej <[email protected]>
Signed-off-by: Stefan Dej <[email protected]>
Signed-off-by: Stefan Dej <[email protected]>
Signed-off-by: Stefan Dej <[email protected]>
Signed-off-by: Stefan Dej <[email protected]>
Thanks for your feedback! I have implemented all the modifications and this is the new G-Code for PrusaSlicer:
|
Thanks. It looks fine to me. As a minor thing, it seems odd that calling I'll give a few more days to see if others have comments. If there are no further comments I'll look to commit. -Kevin |
…ER are exists Signed-off-by: Stefan Dej <[email protected]>
Signed-off-by: Stefan Dej <[email protected]>
Signed-off-by: Stefan Dej <[email protected]>
@KevinOConnor updated this PR to make it fit for the future for more attributes and now current_layer will only be updated when it is set or when you set a new total_layer. @jschuh thx for your snipped. i only add a check, if one value is None. |
LGTM, I just tested the latest code and worked as expected! @meteyou might be good to update the PR title (and maybe the initial post text?) |
Why make a klipper specific gcode command when most slicers aleary put this info as gcode comments. You can check out my fork for an alternative approach where gcode.py broadcasts all gcode comments as an event, and a gcode_metadata module parses them based on the slicer used. This also allows for using the print time predictions put by the slicer. Unfortunately my implementation is more intertwined with the virtual_sdcard implementation etc. and cannot easily be merged. Maybe a stripped down version can be implemented into mainline klipper. I can certainly help with that. |
LAYER
G-Code for consistent layer countSET_PRINT_STATS_INFO
G-Code for pass slicer variables to Klipper
@pedrolamas thx! i updated the title and the description @D4SK parsing comments feels wrong to me. i would rather build some kind of preprocessor into moonraker that converts the comments to gcode and then have klipper process it. |
Thanks. -Kevin |
* rp2040: Suppress spurious gcc v12 array bounds warning Signed-off-by: Kevin O'Connor <[email protected]> * z_thermal_adjust: get_temp hotfix M105 expects get_temp method. Module crashes when gcode_id parameter is set and M105 called. Add methods as hotfix. Signed-off-by: Robert Pazdzior <[email protected]> * print_stats: add `SET_PRINT_STATS_INFO` G-Code for pass slicer variables to Klipper (Klipper3d#5726) This adds a gcode command that can be used insight the slicer to pass the total layer count and current layer information. Signed-off-by: Stefan Dej <[email protected]> * spi_flash: Add SKR2, SKR3 and Creality 4.2.2/7 to spi_flash (Klipper3d#5807) As discussed with Arksine, he has created new working settings for the Creality 4.2.x boards as the original 4.2.7 entry did not work, plus addition of SKR2 and SKR3. Tested on 4.2.2 and SKR2 and SKR3EZ. These are using the new skip_verify functionality that was recently merged due to them using SDIO Also removed a double definition for `monster8` it was in main definitions and aliased. Signed-off-by: James Hartley <[email protected]> * config: Update generic-th3d-ezboard-lite-v2.0.cfg (Klipper3d#5785) Corrected the build instructions for the TH3D EZBoard V2 to include the command to convert Klipper.elf to a SREC bin format named firmware.bin. The SREC format is required for the bootloader installed on the board. Signed-off-by: Anthony Dellett <[email protected]> * config: Add BigTreeTech Manta M4P & M8P board (Klipper3d#5812) Signed-off-by: Alan.Ma from BigTreeTech <[email protected]> * test: Add btt manta config files to printers.test Signed-off-by: Kevin O'Connor <[email protected]> * stm32: Minor code movement in fdcan.c Signed-off-by: Kevin O'Connor <[email protected]> * stm32: No need for fdcan_ram global pointer in fdcan.c Signed-off-by: Kevin O'Connor <[email protected]> * stm32: Protect message ram with barrier() calls instead of voltaile in fdcan.c Signed-off-by: Kevin O'Connor <[email protected]> * lib: Remove unused gcc/ directories from samd21 and samd51 directories Signed-off-by: Kevin O'Connor <[email protected]> * lib: Add atmel same51 and same54 build definitions This also replaces the samd51 component files with the definitions from the same54 repository. Signed-off-by: Kevin O'Connor <[email protected]> * atsamd: Add Kconfig definitions for same51j19 and same54p20 chips Signed-off-by: Kevin O'Connor <[email protected]> * atsamd: Move bootloader_request() from usbserial.c to main.c Signed-off-by: Kevin O'Connor <[email protected]> * atsamd: Add support CANbus on ATSAME5x chips Signed-off-by: Kevin O'Connor <[email protected]> * config: Update duet3 mini config to recommend compiling for SAME54P20 Signed-off-by: Kevin O'Connor <[email protected]> * lib: Update to latest can2040 code Fix gpio function selection for PIO1 usage. Minor variable name changes. Allow scheduling tx "matched" event after a crc match. Allow for up to 5 passive bits after unstuf_clear_state(). Pause PIO "rx" bit reception after 10 passive bits. Signal the CPU to process data every 10 read bits. Signed-off-by: Kevin O'Connor <[email protected]> * workflows: Lock comments on old PRs (no activity in a year) Signed-off-by: Kevin O'Connor <[email protected]> * spi_flash: Update to fix SKR-3 config (Klipper3d#5827) it seems I made an error with my code for the SKR 3, and I copied the code from the wrong host , this PR fixes that. I have just retested with the right code and works as expected, this is confirmed by @adelyser who brought the issue to my attention. Signed-off-by: James Hartley <[email protected]> * stm32: Remove incorrect "spi3" definition from stm32h7 Signed-off-by: Kevin O'Connor <[email protected]> * toolhead: Capture current junction_deviation in a Move class If a maximum acceleration is changed between two consecutive moves, this allows to correctly compute the junction velocity between them. Signed-off-by: Dmitry Butyugin <[email protected]> * stm32: Enable instruction and data cache on stm32h7 Signed-off-by: Konstantin Vogel <[email protected]> * docs: Add step rate benchmark for stm32h7 Signed-off-by: Konstantin Vogel <[email protected]> Signed-off-by: Kevin O'Connor <[email protected]> * config: Add Artillery Sidewinder X2 2022 stock printer.cfg (Klipper3d#5810) Works for unmodified stock Artillery Sidewinder X2, year 2022 with Artillery Ruby v1.2 mainboard. All by default connected things are working fine. Build firmware with architecture STM32F401 with "No bootloader". Other settings keep ther defaults Signed-off-by: Frank Roth <[email protected]> * docs: Add a note about fixing underlying bugs in CONTRIBUTING.md Signed-off-by: Kevin O'Connor <[email protected]> * adxl345: Apply correct scaling for X,Y and Z axes According to ADXL345/ADXL343 datasheets, at 3.3V supply voltage, which is most frequent in the various boards, the sensitivity of X and Y axes changes to 265 LSB/g from 256 LSB/g at 2.5V. Signed-off-by: Dmitry Butyugin <[email protected]> * stm32: fix USART ORE status flag handling If an USART RX overrun happened on a stm32g0/f0/h7, the ORE flag would get set by hardware. This flag would also trigger an interrupt. The problem was that this flag was never cleared on these 3 mcu families since the ORE flag clear sequence is different to all of the older chips. Since the ORE flag is not used in any meaningful way anyway, it was disabled during the init sequence. Signed-off-by: Alex Voinea <[email protected]> * stm32: Use stm32f0_serial.c on stm32h7 chips The stm32h7 uses similar usart hardware as the stm32f0 and stm32g0 chips. Use the same code implementation for all these chips. Signed-off-by: Kevin O'Connor <[email protected]> * stm32: Use consistent memory position/size on stm32h743 Use the same memory start address and size on both stm32h750 and stm32h743. Signed-off-by: Kevin O'Connor <[email protected]> * menu: Conditional display of common Control utils This will hide features in the Klipper Display menu that isn't applicable for the machine, therefore we can add extra alignment tools in the Control menu as well. Also conditionally displays Setup/Calibration options. Signed-off-by: Nickolas Grigoriadis <[email protected]> * fdcan: Remove spurious executable flag on fdcan.c
These features are based on the idea of @pedrolamas. You can use it in combination with the Klipper3d/klipper#5726 to easily do a PAUSE or M600 either at the next layer change or a defined Layer# Signed-off-by: Alex Zellner <[email protected]>
…les to Klipper (Klipper3d#5726) This adds a gcode command that can be used insight the slicer to pass the total layer count and current layer information. Signed-off-by: Stefan Dej <[email protected]>
* Feature: pause_next_layer & pause_at_layer These features are based on the idea of @pedrolamas. You can use it in combination with the Klipper3d/klipper#5726 to easily do a PAUSE or M600 either at the next layer change or a defined Layer# Signed-off-by: Alex Zellner <[email protected]>
…les to Klipper (Klipper3d#5726) This adds a gcode command that can be used insight the slicer to pass the total layer count and current layer information. Signed-off-by: Stefan Dej <[email protected]>
how does it work with cura? I can't get it to work. |
|
…les to Klipper (Klipper3d#5726) This adds a gcode command that can be used insight the slicer to pass the total layer count and current layer information. Signed-off-by: Stefan Dej <[email protected]>
…les to Klipper (Klipper3d#5726) This adds a gcode command that can be used insight the slicer to pass the total layer count and current layer information. Signed-off-by: Stefan Dej <[email protected]>
…les to Klipper (#5726) This adds a gcode command that can be used insight the slicer to pass the total layer count and current layer information. Signed-off-by: Stefan Dej <[email protected]>
This adds a gcode called
SET_PRINT_STATS_INFO
that can be used insight the slicer to pass variables like the total layer count and current layer information to Klipper.This would, of course, also be possible with a macro, but I would prefer an integration in Klipper, as this solution is then automatically available for every client.
To use the layer count, you have to include it in the "Custom G-code" in the slicer. Perhaps SuperSlicer integrate this directly.
Example for PrusaSlicer:
The TOTAL_LAYER and CURRENT_LAYER will be automatic reset in
SDCARD_RESET_FILE
.Thx to @zellneralex for the main idea/implementation!