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
15.94k stars 19.08k forks source link

[FR] Home Offset Here for a specific Axis #27011

Open Elias-Ta opened 3 weeks ago

Elias-Ta commented 3 weeks ago

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

No response

Are you looking for hardware support?

No response

Describe the feature you want

I need to set Homing offset for a single axis in the current position, this can be usefull in cnc mode if I want to set the zero position for Z_axis based on thikness of the work area (usualy I use the milling head to make the work area or the bed flat)

Additional context

In M206_M428.cpp I changed the function void GcodeSuite::M428() to make it as following, and I think it's working as I need, now by sending G428 Z the machine will set homing offset at the current position only for Z axis. Maybe this feature can be added to the original code as well if others need it.

void GcodeSuite::M428() {
  if (homing_needed_error()) return;

  xyz_float_t diff;
  LOOP_NUM_AXES(i) {
    if (parser.seen_test(AXIS_CHAR(i))){
      diff[i] = base_home_pos((AxisEnum)i) - current_position[i];
      if (!WITHIN(diff[i], -20, 20) && home_dir((AxisEnum)i) > 0)
        diff[i] = -current_position[i];
      if (!WITHIN(diff[i], -20, 20)) {
        SERIAL_ERROR_MSG(STR_ERR_M428_TOO_FAR);
        LCD_ALERTMESSAGE(MSG_ERR_M428_TOO_FAR);
        ERR_BUZZ();
        return;
      }
    }
    else {diff[i] = 0;}

  }

  LOOP_NUM_AXES(i) set_home_offset((AxisEnum)i, diff[i]);
  report_current_position();
  LCD_MESSAGE(MSG_HOME_OFFSETS_APPLIED);
  OKAY_BUZZ();
}
thisiskeithb commented 3 weeks ago

Maybe this feature can be added to the original code as well if others need it.

It would be useful if you could submit a Pull Request so it could be reviewed.

Elias-Ta commented 3 weeks ago

Alright, I made a pull request #27015