TFT percentage progress not updatet M73

Exactly what I needed! Thank you!

I'd like @lethuer to see if my change actually works before putting any more effort into forking the original plugin. I'm not sure if there would be more than one user!

I guess I need one more hint... After I edit the file, what do I have to do to get it "recompiled"?

you just have to restart OctoPrint's service.

Attached is (a zip file with) a modified __init__.py for the OctoPrint-M73Progress plugin.

m73progress.zip (1.5 KB)

I got carried away so it's more than a one line change. Instead of using nano to edit the file, use cp to copy this file into the location shown by @jneilliii in his response.

I kept the M73 command and added two M118 commands, one for "time left" and one for "data left". I was able to test this change on my LulzBot TAZ6 so I'm fairly confident that it will work on your printer. I'm sure you will let us know one way or the other!

1 Like

You are on your own to find a plugin to modify with this one :grin:

First of all I tried the test version mentioned above: How to send M118 A1 P0 action:notification Time Left hms (e.g. 02h04m06s)
I couln't make any comment here because the discussion is already closed.

I made comments about my experience here as proposed by @OllisGit : Feature-Request: Use M118 instead of M117 commands · Issue #252 · OllisGit/OctoPrint-DisplayLayerProgress · GitHub

Here a copy of my message:
I tested this test version for M118 provided by @OllisGit: Release V1.29.0.dev1 · OllisGit/OctoPrint-DisplayLayerProgress · GitHub
together with this small modification provided by @racSF: Feature-Request: Use M118 instead of M117 commands · Issue #252 · OllisGit/OctoPrint-DisplayLayerProgress · GitHub
and created a zip File with that which can be installed directly:
https://github.com/OllisGit/OctoPrint-DisplayLayerProgress/files/14804163/OctoPrint-DisplayLayerProgress-1.29.0.dev1_MissingHourMod_compressed.zip

I have configured this:
For print progress I used progress information: P0 A1 action:notification Data Left [progress]/100
Another possibility would be to use layer information: P0 A1 action:notification Data Left [current_layer]/[total_layers]

That's working for me AFTER uploading a file again (which includes M118 messages instead M117), so I would really like to get a stable version !
Otherwise changes would be gone with next update, which is provided:
image

Additionally I would like it would be possible to send three M118 messages to the printer:

M118 P0 A1 action:notification Time Left XXhYYmZZs
-> Updates Time Left Field
M118 P0 A1 action:notification Layer Left XX/YY
-> Updates Layer Left Field
M118 P0 A1 action:notification Data Left XX/YY
-> Updates Percentage Field + Progress Bar

But currently there are only 2 fields are available.
For me it wouldn't be neccessary to toggle between messeges, they could be send all at the same time.

One small downside:
Currently I additionally have installed an SSD1306 display together with this plugin:

With the modified "DisplayLayerProgress" plugin mentioned above on the display now "INIDICATOR-Layer1" is displayed.
I think the reason is that the plugin also uses M117 messages which are now completely replaced by M118.

Definitely more than one user (see my mentioned discussion above). I think anybody with an artillery printer (Genius / Sidewinder) would benefit from this :slight_smile:

Of course I installed your version, but I used another (maybe easier) way:
I downloaded the original M73 plugin: Release 0.2.1 · cesarvandevelde/OctoPrint-M73Progress · GitHub
Then I put in your modified file and created a new zip file: OctoPrint-M73Progress-0.2.1-M118.zip (764.8 KB)
Afterwards I installed this version like I did with the other test version mentioned above:
Pluginmanager -> "+ Mehr" -> "...von einer hochgeladenen Datei"

AWESOME, you did a great job !!!
In the terminal I can observe messages like this:

Send: N951 M73 P23 R26*29
Recv: echo: M73 Progress: 23%; Time left: 26m;
Recv: ok N951 P0 B3
Send: N952 M118 P0 A1 action:notification Time Left 00h26m00s * 96
Recv: //action:notification Time Left 00h26m00s
Recv: ok N952 P0 B3
Send: N953 M118 P0 A1 action:notification Data Left 23/100 * 9
Recv: //action:notification Data Left 23/100

Ragarding:

Send: N952 M118 P0 A1 action:notification Time Left 00h26m00s * 96

I think you have implemented leading 0h so that the remaining print time is not cut ?
This was a hint in the other test plugin: Feature-Request: Use M118 instead of M117 commands · Issue #252 · OllisGit/OctoPrint-DisplayLayerProgress · GitHub
For that there was this modification: Feature-Request: Use M118 instead of M117 commands · Issue #252 · OllisGit/OctoPrint-DisplayLayerProgress · GitHub
Or didn't you made any changes here and original M73 plugin already handles this correctly ?

Regarding:

Send: N953 M118 P0 A1 action:notification Data Left 23/100 * 9

Here it's great that you are using same approach as I thought about:

Would it be possible to also include layer information ? Then I would have anything I need :slight_smile:
Maybe it would also be nice option to have the possibility to select if M118 messages should send instead or additionally to M73 ?! Maybe with a checkbox in the plugin settings ?

With your solution it is possible that additional plugins which also uses M117 messages aren't affected ! :wink: So my additional display just works like before if using the original "DisplayLayerProgress" plugin.

I modified only the one function listed below. The function inputs are progress 0-100 and time_left in minutes. The minutes value is divided by 60 to get hours and modulo by 60 to get minutes. The M118 command is formatted with 2 digits with leading zeros.

The proper thing to do is to modify the name of the plugin and then make any other modifications you want. I was tempted to remove the / 60 from line 72 and do that division in the _set_progress function so that the M118 could output hours, minutes, and seconds but I wanted to minimize my changes.

The OctoPrint-M73Progress plugin doesn't expose the layer information so adding an M118 command for layers would be significant work. It looks like you have enlisted the aid of @OllisGit and his OctoPrint-DisplayLayerProgress plugin so perhaps you can convince him to include this feature.

Again, I think the correct solution is to borrow code from both plugins and make your own plugin specifically for this printer / display combination.

    def _set_progress(self, progress, time_left=None):
        if time_left is None:
            gcode = "M73 P{:.0f}".format(progress)
            gcode2 = "M118 P0 A1 action:notification Time Left 00h00m00s"
        else:
            gcode = "M73 P{:.0f} R{:.0f}".format(progress, time_left)
            gcode2 = "M118 P0 A1 action:notification Time Left {:02.0f}h{:02.0f}m00s".format(time_left / 60,time_left % 60)

        gcode3 = "M118 P0 A1 action:notification Data Left {:.0f}/100".format(progress)

        self._printer.commands([gcode,gcode2,gcode3])

@lethuer,

After a little research, adding the M118 for layer information can be done in your slicer. See here for details.

One could also write a small post-processing script in your favorite language (mine would be Perl).

Yes sure you could insert layer info from the slicer. I found this notice in plug-in „DisplayLayerProgress“:

  • The layer information works only when the slicer adds “layer-indicator” to the g-code (CURA-Example as comments like ;LAYER:10). Then these indicators are parsed via a regular-expression.

Then the plug-in provides possibility to create messages with [current_layer] / [total_layers].
So in principle layer information is already available in gcode and it should be possible to include this in your modification „M73 Progress“ plugin aswell ?!

Side notice:
If I upload a gcode file to OctoPrint and download it afterwards I can observe that these layer informations are added (with M117 messages in original plug-in). I think this is done by the plugin automatically after uploading a file.

I agree, putting the M118 command in the layer change gcode of slicer is a better approach for the layer data, otherwise you'll have to rely on DisplayLayerProgress to do that for you. That plugin has been known to cause some issues in the past.

No why that ?! Layer indicators are already provided from the slicer in the original gcode and has nothing to do with DisplayLayerProgress plugin which only adds M117 messages.
For example I can find this lines in my gcode (even before uploading to octoprint), so any information should be there to use it in the plugin (as DisplayLayerProgress also does).
;LAYER_COUNT:85
;LAYER:1

I tried and found this:

My test gcode to insert is:
M118 P0 A1 action:notification Layer Left [layer_num]/[LAYER_COUNT]

Then I get exactly this in my gcode, but how to insert the numbers for [layer_num] and [LAYER_COUNT] ?

I assume you are asking me and the answer is no. The OctoPrint-M73Progress plugin doesn't look at the gcode file being printed, it just injects some gcode commands into the stream being set to the printer.

no, not exactly. because OctoPrint doesn't parse comments when it's sending the file to your printer. so adding the command in the slicer like below is the cleanest approach IMHO. Otherwise you have to do something like DisplayLayerProgress does it and process the file on selection or upload.

M118 P0 A1 action:notification Layer Left [layer_num]/[LAYER_COUNT]

However, you just figured out that Cura doesn't work the same as PrusaSlicer. Those tokens don't get replaced properly. It looks like OllisGit made a specific post-processing script to handle this use case: https://github.com/OllisGit/OctoPrint-DisplayLayerProgress/wiki/How-does-the-plugin-works#cura. You would have to modify that script to include total layer count somehow though as it appears that only the [layer_num] token is being replaced.

You haven't told us what slicer (and version) you are using but I'm going to guess some flavor of Cura.

Not all slicers have variables available in their post processing scripts. You have discovered, however, that your slicer outputs layer information so you just need to write a small program in your favorite language that does the following:

  1. Search for ";LAYER_COUNT:" and save the count.
  2. Search for ";LAYER:" and save the value.
  3. At each occurrence of ";LAYER" output the M118 command substituting value/count.

Here's one in Perl:

#!/usr/bin/perl
#
# AddM118.pl by Brad Morgan
#
use warnings;

my $file1 = $ARGV[0] or die "Need to put input file name on the command line\n";
# Open input file.
open(my $data, '<', $file1) or die "Could not open '$file1' $!\n";

my $file2 = $ARGV[1] or die "Need to put output file name the command line\n";
# Open output file.
open(my $out, '>', $file2) or die "Could not open '$file2' $!\n";

while ($line = <$data>) {
	print $out $line;
	if ($line =~ m%;LAYER_COUNT:([0-9]*)%) {
		$layer_count = $1;
	} elsif ($line =~ m%;LAYER:([0-9]*)%) {
		$layer = $1;
		print $out "M118 P0 A1 action:notification Layer Left $layer/$layer_count\n";
	}
} # end while

# Clean up
close $data;
close $out;

Ah okay, thank's for explanation !

Probably the argumentation could be like this: About time and progress OctoPrint knows better than the firmware, so this info ("time left" / "data left") should be provided by a plugin there.
But layer information are provided from the slicer so the "layer left" info should be inserted there... Otherwise there have to be done some analysing of the gcode which in principle is also possible of course...

I installed the modified script:


My used statement here is: "M118 P0 A1 action:notification Layer Left [layer_num]/[LAYER_COUNT]", with that I get, so I agree that even this script has to be modified to consider [LAYER_COUNT] information.
M118 P0 A1 action:notification Layer Left 1/[LAYER_COUNT]

Currently Cura 5.6.0


Only short notice in between:
Found out that script "Display Progress On LCD" has also possibilities to include M118 commands !
But also only for "time left" and "data left":

M118 A1 P0 action:notification Time Left 0h25m05s
M118 A1 P0 action:notification Data Left 13/100

"layer left" is also missing here...

Found this pull request: Display Info on LCD by GregValiant · Pull Request #15866 · Ultimaker/Cura · GitHub
Seems there has been made same action on plugins "DisplayFilenameAndLayerOnLCD" and "DisplayProgressOnLCD" to combine and probably add functionalties in new plugin "DisplayInfoOnLCD" which is now part of main since 3 months (Cura 5.6.0 release was Nov 28, 2023):
Cura/plugins/PostProcessingPlugin/scripts at main · Ultimaker/Cura · GitHub

I copied this to my cura installation and with this settings


I get something like this in gcode
M118 Layer 2 of 82
Against my hope "M118 A1 P0 action:notification Layer Left" isn't inserted here

In principle with the old addin "DisplayProgressOnLCD" it was also possible to include the statements "time left" and "data left" with this settings:
image

M118 A1 P0 action:notification Time Left 0h26m29s
M118 A1 P0 action:notification Data Left 8/100

A made some experiments with the new available plugin and noted my obervations here:

taking a look at the merged post processing script it would probably be pretty easy to merge the logic from that one into OllisGit's version.

# Created by Wayne Porter

from ..Script import Script

class InsertAtLayerChangeEnhancement(Script):
    def __init__(self):
        super().__init__()

    def getSettingDataString(self):
        return """{
            "name": "Insert at layer change (enhancement)",
            "key": "InsertAtLayerChangeEnhancement",
            "metadata": {},
            "version": 2,
            "settings":
            {
                "insert_location":
                {
                    "label": "When to insert",
                    "description": "Whether to insert code before or after layer change.",
                    "type": "enum",
                    "options": {"before": "Before", "after": "After"},
                    "default_value": "before"
                },
                "gcode_to_add":
                {
                    "label": "GCODE to insert.",
                    "description": "GCODE to add before or after layer change. You can add '[layer_num]' as a placeholder for the current layer number",
                    "type": "str",
                    "default_value": ""
                }
            }
        }"""

    def execute(self, data):
        gcode_to_add = self.getSettingValueByKey("gcode_to_add") + "\n"
        max_layer = 0
        for layer in data:
            # Check that a layer is being printed
            lines = layer.split("\n")
            for line in lines:
                if line.startswith(";LAYER_COUNT:"):
                    max_layer = line
                    max_layer = max_layer.split(":")[1]
                if ";LAYER:" in line:
                    index = data.index(layer)
                    layerNumber = line[7:]
                    newGcode_to_add = gcode_to_add.replace("[layer_num]", layerNumber).replace("[layer_count]",max_layer)
                    if self.getSettingValueByKey("insert_location") == "before":
                        layer = newGcode_to_add + layer
                    else:
                        layer = layer + newGcode_to_add

                    data[index] = layer
                    break
        return data

and set your text to be

M118 P0 A1 action:notification Layer Left [layer_num]/[layer_count]

above code untested....

1 Like