prusa3d / Prusa-Firmware

Firmware for Original Prusa i3 3D printer by PrusaResearch
GNU General Public License v3.0
2.01k stars 1.05k forks source link

PFW-1536: Reprint function implemented for MK3S/MK3S+ #4510

Closed 3d-gussner closed 9 months ago

3d-gussner commented 9 months ago

Cherry picked from https://github.com/prusa3d/Prusa-Firmware/pull/4462 as rebase is a pain and broke things. This PR is a the same than #3071 but using the current repository of my fork of your firmware

Kudos to @jfestrada for the idea and original PR.

To support this functionality I have added a extern bool variable which can be read/set from cmdqueue.cpp and ultralcd.cpp so when the card reader reaches the EOF the variable isPrintFinished will be set to true and the main menu will show the REPRINT option. How do I know which file we need to reprint? All the information needed to perform the reprint was stored on the EEPROM in case of a power panic and the fw recover this information in order to start the print from SD again, so using that information the function reprint_from_eeprom() has been implemented.

Translations:

3d-gussner commented 9 months ago

@jfestrada Please review this PR.

github-actions[bot] commented 9 months ago

All values in bytes. Δ Delta to base

Target ΔFlash ΔSRAM Used Flash Used SRAM Free Flash Free SRAM
MK3S_MULTILANG 478 0 247236 5656 6716 2536
MK3_MULTILANG 478 0 246518 5663 7434 2529
jfestrada commented 9 months ago

I hope to be able to review it today night

jfestrada commented 9 months ago

I miss this code on the last part of the function __lcdui_print_percent_done__

    enableReprint = true;
    if(usb_timer.running())
    {
        enableReprintUSB = true;
    }else
    {
        enableReprintUSB = false;
    }

This is the initialization of the reprint variables in order to control the behavior of the Reprint menu action.

3d-gussner commented 9 months ago

I miss this code on the last part of the function lcdui_print_percent_done

    enableReprint = true;
    if(usb_timer.running())
    {
        enableReprintUSB = true;
    }else
    {
        enableReprintUSB = false;
    }

This is the initialization of the reprint variables in order to control the behavior of the Reprint menu action.

@jfestrada Thanks for the review. I use now the PrinterState to show the menu. For some reason my last commit wasn't included. See https://github.com/prusa3d/Prusa-Firmware/pull/4510/commits/d9d42a06781977bd19dcf63f929ad90d6640c28f

jfestrada commented 9 months ago

I miss this code on the last part of the function lcdui_print_percent_done

    enableReprint = true;
    if(usb_timer.running())
    {
        enableReprintUSB = true;
    }else
    {
        enableReprintUSB = false;
    }

This is the initialization of the reprint variables in order to control the behavior of the Reprint menu action.

@jfestrada Thanks for the review. I use now the PrinterState to show the menu. For some reason my last commit wasn't included. See d9d42a0

Ok, I see, then everything should be ready.

3d-gussner commented 9 months ago

@jfestrada Is it okay that we merge this copy of your great PR to reduce the commit numbers? Thanks again for providing the PR.

jfestrada commented 9 months ago

@jfestrada Is it okay that we merge this copy of your great PR to reduce the commit numbers? Thanks again for providing the PR.

Yes of course, go ahead with the merge!!

3d-gussner commented 9 months ago

@jfestrada While testing few other PrusaLink/OctoPrint related things, I have seen in the octoprint actions documentation that a // action:start will re-start the last selected file. Also the Reprint menu of a finished host print should not be shown if the host isn't pining the printer with M79

What do you think of these changes?

--- a/Firmware/messages.cpp
+++ b/Firmware/messages.cpp
-const char MSG_OCTOPRINT_REPRINT[] PROGMEM_N1 = "// action:reprint"; ////
+const char MSG_OCTOPRINT_START[] PROGMEM_N1 = "// action:start"; ////

--- a/Firmware/messages.h
+++ b/Firmware/messages.h
-extern const char MSG_OCTOPRINT_REPRINT[];
+extern const char MSG_OCTOPRINT_START[];

--- a/Firmware/ultralcd.cpp
+++ b/Firmware/ultralcd.cpp

-        } else if (GetPrinterState() == PrinterState::HostPrintingFinished) {
+        } else if ((GetPrinterState() == PrinterState::HostPrintingFinished) && M79_timer_get_status())  {

-    SERIAL_PROTOCOLLNRPGM(MSG_OCTOPRINT_REPRINT);
+    SERIAL_PROTOCOLLNRPGM(MSG_OCTOPRINT_START);

I tested this with MK404 sim and Octoprint and works well.

jfestrada commented 9 months ago

With the documentation on my hand I would say that will works out of the box so will be better than deal with a new plugin in order to define the "action". The only concern is about the behavior if you don't have any file selected on octoprint, but that will not happen at least that you restart Octoprint and in that case the printer will reconnect and restart so the reprint menu will disappear. To my mind this change will works and will save some bits.

3d-gussner commented 9 months ago

Yes it will not work if Octoprint restarts as no file is selected. Still an improvement for a working and stable OctoPrint. Only requirement we defined for PrusaLink/PrusaConnect is that the printer needs to be "pinged" to enable some host related menus and messages. So for Octoprint would be a Plugin needed that pings the printer that the host is alive with gcode M79.

M79 is used to ping the printer:

3d-gussner commented 9 months ago

@jfestrada Just tested the change

  1. a quick OP print
  2. Reprint and let it finish
  3. restart OP
  4. connect OP
  5. Reprint shown as I have in GCODE scripts some additional changes like M79 S"OP" in after printer connected a. It sends // action:start but OctoPrint just ignores it
mhouse1 commented 9 months ago

thank you, been waiting for this for a long time, will make operating a print farm much easier.