OctoPrint-DisplayLayerProgress icon indicating copy to clipboard operation
OctoPrint-DisplayLayerProgress copied to clipboard

Feature-Request: Use M118 instead of M117 commands

Open OllisGit opened this issue 3 years ago • 16 comments

Details see https://community.octoprint.org/t/how-to-send-m118-a1-p0-action-notification-time-left-hms-e-g-02h04m06s/41553

OllisGit avatar Feb 03 '22 21:02 OllisGit

A dev version that just replace all M117 comands with M118 is out: https://github.com/OllisGit/OctoPrint-DisplayLayerProgress/releases/tag/1.29.0.dev1

OllisGit avatar Feb 06 '22 19:02 OllisGit

Hy @OllisGit , Thank you for the version of Dev I started tested and I detected a small dysfunction in the remaining time. TFT is waiting for a non-truncated time format :

M118 A1 P0 action:notification Time Left hms (e.g. 00h16m06s)

Unfortunately when I use the [printtime_left] statement the time is cut example for a time remain 20 minutes 13second I receive 20m13s while I would have that I receive 00h20m13s

Is there a way to keep hours the minutes and seconds?

Thk :)

image

image

Pascal-m avatar Feb 07 '22 20:02 Pascal-m

Hi @Pascal-m, for seconds there is already a flag (in your case you need to disable it), but not for the leading minutes/hours. image

I need to implement this feature...do you need two digits or is one enough? I prefer one digit, like this 0d0h0m31s

OllisGit avatar Mar 23 '22 18:03 OllisGit

I need to implement this feature...do you need two digits or is one enough? I prefer one digit, like this 0d0h0m31s

I just tested this out by manually sending M118 commands via Octoprint Terminal. Sending the command M118 A1 P0 action:notification Time Left 1h1m10s and M118 A1 P0 action:notification Time Left 0h1m10s both properly updated the time remaining. So it appears there is no need for there to be two digits. Same goes for using M117, as I don't have the UART issue with my setup, so only the lack of hours when less than one hour remaining is an issue.

MehStrongBadMeh avatar Apr 04 '22 17:04 MehStrongBadMeh

hello sorry for the delay In the specification it takes 2 digits on the hour minute and second

example: 01h02m06s Or 00h09m04 Thx

Pascal-m avatar Apr 04 '22 19:04 Pascal-m

Hello OllosGit, good news, in the latest version of the TFT firmware, it accepts one digit now :) Do you think you can make the change? Thk Pascal

Hi @Pascal-m, for seconds there is already a flag (in your case you need to disable it), but not for the leading minutes/hours. image

I need to implement this feature...do you need two digits or is one enough? I prefer one digit, like this 0d0h0m31s

Pascal-m avatar Jun 05 '22 18:06 Pascal-m

Just to let you know, I am using 1.29.0.dev1 with the same use case and for layers and progress, it works well. I haven't dug into the time yet since there are only two notifications.

wd5gnr avatar Oct 15 '22 21:10 wd5gnr

Just to let you know, I am using 1.29.0.dev1 with the same use case and for layers and progress, it works well. I haven't dug into the time yet since there are only two notifications.

True - dataprogress is correctly set, when using

A1 P0 action:notification Data Left [current_layer]/[total_layers] as message pattern.

I can also confirm, that the issue with the missing leading hours still exists, would it be possible to implement it as option like the one mentioned by pascal-m ? For this I would use:

A1 P0 action:notification Time Left [printtime_left]

racSF avatar Oct 19 '22 23:10 racSF

I'll try to fit my needs by altering the file: "/home/pi/OctoPrint/venv/lib/python3.9/site-packages/octoprint_DisplayLayerProgress/stringUtils.py"

And change the secondsToText function to:

def secondsToText(secs, hideSeconds=False):
    result = ""
    days = secs // 86400
    hours = (secs - days * 86400) // 3600
    minutes = (secs - days * 86400 - hours * 3600) // 60
    seconds = secs - days * 86400 - hours * 3600 - minutes * 60
    if (hours > 0):
        if (hideSeconds == True):
            result = "{}h".format(hours) + "{}m".format(minutes)
        else:
            result = "{}h".format(hours) + "{}m".format(minutes) + "{}s".format(seconds)
    elif (minutes > 0):
        if (hideSeconds == True):
            result = "{}m".format(minutes)
        else:
            --->   result = "{}h".format(hours) + "{}m".format(minutes) + "{}s".format(seconds)
    elif (seconds >= 0):
            --->   result = "{}h".format(hours) + "{}m".format(minutes) + "{}s".format(seconds)

This should only help if you use the sidewinder - I'll test it maybe tommorrow ;)

racSF avatar Oct 20 '22 19:10 racSF

I could test it today - and the change worked as intended - just to beautify things up, here is my current secondsToText without any Arrows, symbols or whatever:

def secondsToText(secs, hideSeconds=False):
    result = ""
    days = secs // 86400
    hours = (secs - days * 86400) // 3600
    minutes = (secs - days * 86400 - hours * 3600) // 60
    seconds = secs - days * 86400 - hours * 3600 - minutes * 60
    if (hours > 0):
        if (hideSeconds == True):
            result = "{}h".format(hours) + "{}m".format(minutes)
        else:
            result = "{}h".format(hours) + "{}m".format(minutes) + "{}s".format(seconds)
    elif (minutes > 0):
        if (hideSeconds == True):
            result = "{}m".format(minutes)
        else:
            result = "{}h".format(hours) + "{}m".format(minutes) + "{}s".format(seconds)
    elif (seconds >= 0):
        result = "{}h".format(hours) + "{}m".format(minutes) + "{}s".format(seconds)
    return result

As mentioned earlier - this is not needed by most of the Marlins out there - but the Sidewinder X1 in team with the BTT TFT needs this approach - its a quick and dirty hack, which will most likely be destroyed on the next update of the plugin - maybe @OllisGit could implement a Sidewinder Checkbox within the options to force the formatting to always consist of HoursMinutesSeconds, no matter how many days or only minutes are left :)

racSF avatar Oct 24 '22 19:10 racSF

I'm also interested in this, could this be made possible with a variable like [printtime_left_incl_hours] ?

heinrichWeichert avatar Feb 20 '23 16:02 heinrichWeichert

That would be great, I am also interested. And maybe a checkbox "Use M118 instead of M117"?

raihei avatar Feb 20 '23 21:02 raihei