MarlinFirmware / Marlin

Marlin is an optimized firmware for RepRap 3D printers based on the Arduino platform. Many commercial 3D printers come with Marlin installed. Check with your vendor if you need source code for your specific machine.
https://marlinfw.org
GNU General Public License v3.0
16.18k stars 19.21k forks source link

[FR] Extended M75 Command to support setting a filename #21393

Open mriscoc opened 3 years ago

mriscoc commented 3 years ago

Is your feature request related to a problem? Please describe.

When the print is started from a host with M75, there is no way of indicate the filename of the file to be printed.

Describe the feature you want

Extend the M75 command to support a string argument similar to the M117 command. When M75 is issued without any argument, it is interpreted as usual, but if an argument is added the text can be parsed to modify a filename variable and the display routines can then display it. I already implement this extension on my source code for the Ender3v2.

Simple example of implementation (needs to be optimized):

Octoprint Before print job starts G-code:

M75 HOST PRINT:{{ event.name }}

Code for the M75 command:

/**
 * M75: Start print timer
 */
void GcodeSuite::M75() {
  startOrResumeJob();

  TERN_(DWIN_CREALITY_LCD, DWIN_Print_Header((parser.string_arg && parser.string_arg[0]) ? parser.string_arg : (char*)"Host Print"));
}

Code for the Display:

void DWIN_Print_Header(const char *text = nullptr) {
  static char headertxt[31] = "";
  if (text!=nullptr) {
    const int8_t size = _MIN((unsigned) 30, strlen_P(text));
    LOOP_L_N(i, size) headertxt[i] = text[i];
    headertxt[size+1] = '\0';
  }    
  if (checkkey == PrintProcess)
    DWIN_Draw_CenteredString(false, false, font8x16, Color_White, Color_Bg_Black, MENU_CHR_W, 60, headertxt);
}

photo_2021-03-20_18-32-10

Sebazzz commented 3 years ago

Interesting!

 TERN_(DWIN_CREALITY_LCD, DWIN_Print_Header((parser.string_arg && parser.string_arg[0]) ? parser.string_arg : (char*)"Host Print"));

When not supplied, a nullptr should be passed. Then the receiver (DWIN, or perhaps an extui implementation) can then determine what to do with it.