Skip to content

Commit

Permalink
Add test, tramming.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Nov 27, 2020
1 parent 543e8b3 commit 4184f8a
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 34 deletions.
3 changes: 2 additions & 1 deletion Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -813,9 +813,10 @@
#define RESTORE_LEVELING_AFTER_G35 // Enable to restore leveling setup after operation
//#define REPORT_TRAMMING_MM // Report Z deviation (mm) for each point relative to the first

//#define ASSISTED_TRAMMING_WAIT_POSITION { X_CENTER, Y_CENTER, 30 } // Move the nozzle out of the way for adjustment

//#define ASSISTED_TRAMMING_MENU_ITEM // Add a menu item to run G35 Assisted Tramming (MarlinUI)
//#define ASSISTED_TRAMMING_WIZARD // Make the menu item open a Tramming Wizard sub-menu
//#define ASSISTED_TRAMMING_WAIT_POSITION { X_CENTER, Y_CENTER, 30 } // Move the nozzle out of the way for adjustment

/**
* Screw thread:
Expand Down
63 changes: 63 additions & 0 deletions Marlin/src/feature/tramming.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/

#include "../inc/MarlinConfigPre.h"

#if ENABLED(ASSISTED_TRAMMING)

#include "tramming.h"

#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../core/debug_out.h"

PGMSTR(point_name_1, TRAMMING_POINT_NAME_1);
PGMSTR(point_name_2, TRAMMING_POINT_NAME_2);
PGMSTR(point_name_3, TRAMMING_POINT_NAME_3);
#ifdef TRAMMING_POINT_NAME_4
PGMSTR(point_name_4, TRAMMING_POINT_NAME_4);
#ifdef TRAMMING_POINT_NAME_5
PGMSTR(point_name_5, TRAMMING_POINT_NAME_5);
#endif
#endif

PGM_P const tramming_point_name[] PROGMEM = {
point_name_1, point_name_2, point_name_3
#ifdef TRAMMING_POINT_NAME_4
, point_name_4
#ifdef TRAMMING_POINT_NAME_5
, point_name_5
#endif
#endif
};

#ifdef ASSISTED_TRAMMING_WAIT_POSITION

// Move to the defined wait position
void move_to_tramming_wait_pos() {
constexpr xyz_pos_t wait_pos = ASSISTED_TRAMMING_WAIT_POSITION;
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Moving away");
do_blocking_move_to(wait_pos, XY_PROBE_FEEDRATE_MM_S);
}

#endif

#endif // ASSISTED_TRAMMING
16 changes: 7 additions & 9 deletions Marlin/src/feature/tramming.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once

#include "../inc/MarlinConfigPre.h"
#include "../inc/MarlinConfig.h"

#if !WITHIN(TRAMMING_SCREW_THREAD, 30, 51) || TRAMMING_SCREW_THREAD % 10 > 1
#error "TRAMMING_SCREW_THREAD must be equal to 30, 31, 40, 41, 50, or 51."
Expand Down Expand Up @@ -58,11 +59,8 @@ static_assert(_NR_TRAM_NAMES >= G35_PROBE_COUNT, "Define enough TRAMMING_POINT_N

extern PGM_P const tramming_point_name[];

inline void move_to_tramming_wait_pos() {
#ifdef ASSISTED_TRAMMING_WAIT_POSITION
// Move XYZ to wait position
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Moving away");
const xyz_pos_t wait_pos = ASSISTED_TRAMMING_WAIT_POSITION;
do_blocking_move_to(wait_pos, XY_PROBE_FEEDRATE_MM_S);
#endif
}
#ifdef ASSISTED_TRAMMING_WAIT_POSITION
void move_to_tramming_wait_pos();
#else
inline void move_to_tramming_wait_pos() {}
#endif
20 changes: 0 additions & 20 deletions Marlin/src/gcode/bedlevel/G35.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,6 @@

#include "../../feature/tramming.h" // Validate

PGMSTR(point_name_1, TRAMMING_POINT_NAME_1);
PGMSTR(point_name_2, TRAMMING_POINT_NAME_2);
PGMSTR(point_name_3, TRAMMING_POINT_NAME_3);
#ifdef TRAMMING_POINT_NAME_4
PGMSTR(point_name_4, TRAMMING_POINT_NAME_4);
#ifdef TRAMMING_POINT_NAME_5
PGMSTR(point_name_5, TRAMMING_POINT_NAME_5);
#endif
#endif

PGM_P const tramming_point_name[] PROGMEM = {
point_name_1, point_name_2, point_name_3
#ifdef TRAMMING_POINT_NAME_4
, point_name_4
#ifdef TRAMMING_POINT_NAME_5
, point_name_5
#endif
#endif
};

/**
* G35: Read bed corners to help adjust bed screws
*
Expand Down
8 changes: 6 additions & 2 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -2156,8 +2156,12 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
/**
* G35 Assisted Tramming
*/
#if ENABLED(ASSISTED_TRAMMING) && !HAS_BED_PROBE
#error "ASSISTED_TRAMMING requires a bed probe."
#if ENABLED(ASSISTED_TRAMMING)
#if !HAS_BED_PROBE
#error "ASSISTED_TRAMMING requires a bed probe."
#elif BOTH(ASSISTED_TRAMMING_MENU_ITEM, ASSISTED_TRAMMING_WIZARD)
#error "Please select either ASSISTED_TRAMMING_MENU_ITEM or ASSISTED_TRAMMING_WIZARD, not both."
#endif
#endif

/**
Expand Down
3 changes: 2 additions & 1 deletion buildroot/tests/DUE-tests
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ opt_set TEMP_SENSOR_BED 2
opt_set GRID_MAX_POINTS_X 16
opt_set FANMUX0_PIN 53
opt_enable S_CURVE_ACCELERATION EEPROM_SETTINGS GCODE_MACROS \
FIX_MOUNTED_PROBE Z_SAFE_HOMING CODEPENDENT_XY_HOMING ASSISTED_TRAMMING ASSISTED_TRAMMING_WIZARD \
FIX_MOUNTED_PROBE Z_SAFE_HOMING CODEPENDENT_XY_HOMING \
ASSISTED_TRAMMING ASSISTED_TRAMMING_WIZARD REPORT_TRAMMING_MM ASSISTED_TRAMMING_WAIT_POSITION \
EEPROM_SETTINGS SDSUPPORT BINARY_FILE_TRANSFER \
BLINKM PCA9533 PCA9632 RGB_LED RGB_LED_R_PIN RGB_LED_G_PIN RGB_LED_B_PIN LED_CONTROL_MENU \
NEOPIXEL_LED CASE_LIGHT_ENABLE CASE_LIGHT_USE_NEOPIXEL CASE_LIGHT_MENU \
Expand Down
3 changes: 2 additions & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ default_src_filter = +<src/*> -<src/config> -<src/HAL> +<src/HAL/shared>
-<src/feature/solenoid.cpp> -<src/gcode/control/M380_M381.cpp>
-<src/feature/spindle_laser.cpp> -<src/gcode/control/M3-M5.cpp>
-<src/feature/tmc_util.cpp> -<src/module/stepper/trinamic.cpp>
-<src/feature/tramming.cpp>
-<src/feature/twibus.cpp>
-<src/feature/z_stepper_align.cpp>
-<src/gcode/bedlevel/G26.cpp>
Expand Down Expand Up @@ -322,7 +323,7 @@ MECHANICAL_GANTRY_CAL.+ = src_filter=+<src/gcode/calibrate/G34.cpp>
Z_MULTI_ENDSTOPS = src_filter=+<src/gcode/calibrate/G34_M422.cpp>
Z_STEPPER_AUTO_ALIGN = src_filter=+<src/feature/z_stepper_align.cpp> +<src/gcode/calibrate/G34_M422.cpp>
G26_MESH_VALIDATION = src_filter=+<src/gcode/bedlevel/G26.cpp>
ASSISTED_TRAMMING = src_filter=+<src/gcode/bedlevel/G35.cpp>
ASSISTED_TRAMMING = src_filter=+<src/feature/tramming.cpp> +<src/gcode/bedlevel/G35.cpp>
HAS_MESH = src_filter=+<src/gcode/bedlevel/G42.cpp>
HAS_LEVELING = src_filter=+<src/gcode/bedlevel/M420.cpp>
DELTA_AUTO_CALIBRATION = src_filter=+<src/gcode/calibrate/G33.cpp>
Expand Down

0 comments on commit 4184f8a

Please sign in to comment.