-
Notifications
You must be signed in to change notification settings - Fork 24
How does the plugin works
The following description gives you some insides about how the plugin works (with default-settings).
- If you upload a file via Web-UI or via OctoPrint-API (used by Slicers like CURA) each gcode line is scanned
- If a layer-comment is identified (e.g.
;LAYER:10
) an M117-command is added to the gcode. The result looks like this:
...
;LAYER:10
M117 INDICATOR-Layer10
...
-
The identification is done via a few regular expressions. E.g for CURA
;\s*LAYER:\s*([0-9]+).*
Some slicers are not able to include the layer number directly into the gcode, instead they just comment a beginning of a layer-section, like this:
;BEFORE_LAYER_CHANGE
. In that case the plugin counts the appearance of this text.The default settings include expressions for CURA, Simplify3D, ideaMakerIn, KISSlicer, Slic3r
-
ATTENTION: For performance reason the scanner only includes comments that where begins in column one of a line
Working Example:
; move to layer: 10 G1 X45.733 Y59.266
Not working:
G1 X45.733 Y59.266 ; move to layer: 10
-
HINT: You can disable the "adding-feature" during upload, but then your slicer needs to add the
M117 INDICATOR
into your gcode. -
HINT: If you disable/uninstall the plugin, the
M117 INDICATOR
commands were still in the uploaded files. You need to reupload the file, if you want to prevent thatINDICATOR-Layer
appears in your printer-display! -
But why did you do that??? Because during print OctoPrint doesn't provide the comments to the "plugin-processors", only real gcode. Thats the reason why I added this M117 Indicator GCode.
- The plugin listen on different events, parse the event-payload and send this informations to the UI, EventBus and also to the printer.
Here are the events:
- When print height changed (this is calculated based on G command and Z being present in your gcode)
- When layer number changed (this is calculated based on M117 INDICATOR-Layer in your gcode)
- When saving settings or OctoPrint UI requested it
- Every time if you have "Only while printing" checked and you are printing (this one is very dangerous)
- When print progress changed - I think it is disabled by default
- When feed rate changed (this is calculated based on G command and F being present in your gcode) - I think it is disabled by default
- When fan speed changed (this is calculated based on M106 in your gcode) - I think it is disabled by default
HINT: It is only sent, if the "display-message" is really changed. E.g. the display should only show layer and progress, like this 1/23 34%
. If the feedrate is changed 100.000times, it is not sent to the printer/UI.
-
Plugin use the following OctoPrint-Hooks
(see, https://docs.octoprint.org/en/master/plugins/hooks.html#octoprint-comm-protocol-gcode-phase and https://docs.octoprint.org/en/master/modules/plugin.html?highlight=on_print_progress#octoprint.plugin.types.ProgressPlugin.on_print_progress):
-
octoprint.comm.protocol.gcode.queuing
Method extracts layer-informations, other stuff like feedrate and dropsM117 INDICATOR
command. The extraction of the values is done in a async way, so queuing thread is not blocked. After all values were extracted the UI-Display (via websocket) and Printer-Display (via self._printer.commands) will be updated -
octoprint.comm.protocol.gcode.sent
acts like a M117-Comamnd listener. Each M117 command which is already sent to the printer will be grabed and send to the UI-Display (also in a async way) -
on_print_progress
just received the progress-value (0-100%). This value is send to UI-/Printer-Display
-
-
HINT: You can disable sending M117 Messages to the printer via Plugin-Settings, this could improve the data-transfer rate from OctoPrint to the Printer and could prevent blobs/stuttering.
If you print from SD-Card the plugin is not involved, because the GCode is not passed thru OctoPrint during print and can't analysed by the plugins -> no layer-informations could be displayed.
If you use large gcode files (>50MB) it could be necessary to add the Layer indicators via your slicer instead of during upload by the Raspi.
Turn off the checkbox in the settings Add Layer-Indicators during upload
go to Printer Settings, Custom G-code, Before layer change G-Code, and add (for example):
M117 INDICATOR-Layer[layer_num]
Unfortunately Cura doesn't support layer numbers during adding custom gcode...so I wrote a Cura PostProcesser Script. It is based on the default script 'Insert at layer change'.
- Download InsertAtLayerChangeEnhancement from here
- Copy the file to your Cura PostProcessingPlugin-Directory (next to InsertAtLayerChange.py)
MacOS: cura/Resources/plugins/plugins/PostProcessingPlugin
Windows: C:\Program Files\Ultimaker Cura [Version]\plugins\PostProcessingPlugin\scripts
- Restart/Start Cura
- Go to Extension / Post Processing / Modify G-Code ... and add
Insert at layer change (enhancement)
- Select
Before
- And enter:
M117 INDICATOR-Layer[layer_num]
After slicing and saving the file the gcode looks like this:
...
;LAYER_COUNT:44
M117 INDICATOR-Layer0
;LAYER:0
...
M117 INDICATOR-Layer1
;LAYER:1
...
....maybe you should read this as well. I found an other option without installation a new PostProcessing-Script ;-)
Just use the build in "Search and Replace" Script
- Search:
;Layer:
- Replace:
M117 INDICATOR-Layer
- Leave reg ex unchecked