1. About
  2. Features
  3. Explore

I want to add auto bed leveling before each print. When I enable auto bed level in configuration.h, it only shows auto bed in menu. I found this code in cardreader.cpp

void CardReader::openAndPrintFile(const char *name) { char cmd[4 + strlen(name) + 1]; // Room for "M23 ", filename, and null sprintf_P(cmd, PSTR("M23 %s"), name); for (char *c = &cmd[4]; *c; c++) *c = tolower(*c); enqueue_and_echo_command(cmd); enqueue_and_echo_commands_P(PSTR("M24")); } 

and changed it to

void CardReader::openAndPrintFile(const char *name) { char cmd[4 + strlen(name) + 1]; // Room for "M23 ", filename, and null sprintf_P(cmd, PSTR("M23 %s"), name); for (char *c = &cmd[4]; *c; c++) *c = tolower(*c); enqueue_and_echo_command("G28"); enqueue_and_echo_command("G29"); enqueue_and_echo_command(cmd); enqueue_and_echo_commands_P(PSTR("M24")); } 

Now before each print, the printer does auto bedding two times but when print starts the auto bedding is ignored and printer acts like before doing auto bed.

Please help me solve this.

I'm using Marlin Firmware 1.1.0.

1 Answer 1

Rather than modifying the firmware to handle this, have you considered a pre-processing script on your computer, greping for a G29 in the G-code, then adding a G28/G29 pair at the start of the file if no G29 is found?