luc-github / ESP3D-WEBUI

A Web UI for ESP8266 or ESP32 based boards connected to 3D printers / CNC
GNU General Public License v3.0
734 stars 303 forks source link

Add support for various Marlin message types #293

Closed MonoAnji closed 1 year ago

MonoAnji commented 1 year ago

The changes add support for the following Marlin features

luc-github commented 1 year ago

Hi can you explain how esp3d catch the M73 and M106 commands ? they are commands - not report

also you only handle some syntax is that normal ? M106 P0 S255 not M106 S255 P0 same for M73 ...

nice theme by the way and good catch for duplicate chamber

MonoAnji commented 1 year ago

Of course, I should've added that straight away.

Changes in Marlin (Configuration_adv.h)

#define REPORT_FAN_CHANGE this will make Marlin actually echo (interestingly without echo:) changes to the fan speed just as if it was a command.

  #define M73_REPORT                                  // Report M73 values to host
  #if BOTH(M73_REPORT, SDSUPPORT)
    //#define M73_REPORT_SD_ONLY          // Report only when printing from SD
  #endif

The #define M73_REPORT makes marlin send out messages with status updates to the host or basically just out to serial, so I can see the progress in ESP3D-WEBUI. I'm printing from an SD card in a TFT connected via serial, so there is no SD_STATUS on the actual board. But the M73 report uses the print timer as a source for progress (SD_STATUS is just bytes in the gcode file anyway if I remember correctly). So this gave me a way to actually see that there's a print job running via the WEB-UI by parsing that message.

Regarding the M106 and M73 formats: I honestly just added it exactly the way it was sent by Marlin

Marlin/src/module/temperature.cpp#L429

  #if ENABLED(REPORT_FAN_CHANGE)
    /**
     * Report print fan speed for a target extruder
     */
    void Temperature::report_fan_speed(const uint8_t fan) {
      if (fan >= FAN_COUNT) return;
      PORT_REDIRECT(SerialMask::All);
      SERIAL_ECHOLNPGM("M106 P", fan, " S", fan_speed[fan]);
    }
  #endif

Marlin/src/gcode/lcd/M73.cpp#L76

  #if ENABLED(M73_REPORT)
    if (TERN1(M73_REPORT_SD_ONLY, IS_SD_PRINTING())) {
      SERIAL_ECHO_START();
      SERIAL_ECHOPGM(" M73");
      #if ENABLED(SET_PROGRESS_PERCENT)
        SERIAL_ECHOPGM(" Progress: ", TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(ui.get_progress_permyriad()), ui.get_progress_percent()), "%;");
      #endif
      #if ENABLED(SET_REMAINING_TIME)
        SERIAL_ECHOPGM(" Time left: ", ui.remaining_time / 60, "m;");
      #endif
      #if ENABLED(SET_INTERACTION_TIME)
        SERIAL_ECHOPGM(" Change: ", ui.interaction_time / 60, "m;");
      #endif
      SERIAL_EOL();
    }
  #endif

Thank you by the way, feel free to include the theme or change it or use stuff from it if you want ;)

luc-github commented 1 year ago

Thank you for the clarification - I never tried these auto reports - good to know - thank you

luc-github commented 1 year ago

merged thank you

luc-github commented 1 year ago

@all-contributors please add @MonoAnji for code fix of code improvement

allcontributors[bot] commented 1 year ago

@luc-github

I've put up a pull request to add @MonoAnji! :tada: