Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9240bf2

Browse files
lukasradekthinkyhead
authored andcommittedApr 8, 2023
🔧 Up to 9 tramming points (MarlinFirmware#25293)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
1 parent 121011b commit 9240bf2

File tree

5 files changed

+44
-59
lines changed

5 files changed

+44
-59
lines changed
 

‎Marlin/Configuration_adv.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@
10341034
//#define ASSISTED_TRAMMING
10351035
#if ENABLED(ASSISTED_TRAMMING)
10361036

1037-
// Define positions for probe points.
1037+
// Define from 3 to 9 points to probe.
10381038
#define TRAMMING_POINT_XY { { 20, 20 }, { 180, 20 }, { 180, 180 }, { 20, 180 } }
10391039

10401040
// Define position names for probe points.

‎Marlin/src/core/macros.h

+13
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,19 @@
717717
#define RREPEAT2_S(S,N,OP,V...) EVAL1024(_RREPEAT2(S,SUB##S(N),OP,V))
718718
#define RREPEAT2(N,OP,V...) RREPEAT2_S(0,N,OP,V)
719719

720+
// Emit a list of N OP(I) items with ascending counter.
721+
#define _REPLIST(_RPT_I,_RPT_N,_RPT_OP) \
722+
_RPT_OP(_RPT_I) \
723+
IF_ELSE(SUB1(_RPT_N)) \
724+
( , DEFER2(__REPLIST)()(ADD1(_RPT_I),SUB1(_RPT_N),_RPT_OP) ) \
725+
( /* Do nothing */ )
726+
#define __REPLIST() _REPLIST
727+
728+
// Repeat a macro, comma-separated, passing S...N-1.
729+
#define REPLIST_S(S,N,OP) EVAL(_REPLIST(S,SUB##S(N),OP))
730+
#define REPLIST(N,OP) REPLIST_S(0,N,OP)
731+
#define REPLIST_1(N,OP) REPLIST_S(1,INCREMENT(N),OP)
732+
720733
// Call OP(A) with each item as an argument
721734
#define _MAP(_MAP_OP,A,V...) \
722735
_MAP_OP(A) \

‎Marlin/src/feature/tramming.cpp

+4-24
Original file line numberDiff line numberDiff line change
@@ -29,31 +29,11 @@
2929
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
3030
#include "../core/debug_out.h"
3131

32-
PGMSTR(point_name_1, TRAMMING_POINT_NAME_1);
33-
PGMSTR(point_name_2, TRAMMING_POINT_NAME_2);
34-
PGMSTR(point_name_3, TRAMMING_POINT_NAME_3);
35-
#ifdef TRAMMING_POINT_NAME_4
36-
PGMSTR(point_name_4, TRAMMING_POINT_NAME_4);
37-
#ifdef TRAMMING_POINT_NAME_5
38-
PGMSTR(point_name_5, TRAMMING_POINT_NAME_5);
39-
#ifdef TRAMMING_POINT_NAME_6
40-
PGMSTR(point_name_6, TRAMMING_POINT_NAME_6);
41-
#endif
42-
#endif
43-
#endif
32+
#define _TRAM_NAME_DEF(N) PGMSTR(point_name_##N, TRAMMING_POINT_NAME_##N);
33+
#define _TRAM_NAME_ITEM(N) point_name_##N
34+
REPEAT_1(_NR_TRAM_NAMES, _TRAM_NAME_DEF)
4435

45-
PGM_P const tramming_point_name[] PROGMEM = {
46-
point_name_1, point_name_2, point_name_3
47-
#ifdef TRAMMING_POINT_NAME_4
48-
, point_name_4
49-
#ifdef TRAMMING_POINT_NAME_5
50-
, point_name_5
51-
#ifdef TRAMMING_POINT_NAME_6
52-
, point_name_6
53-
#endif
54-
#endif
55-
#endif
56-
};
36+
PGM_P const tramming_point_name[] PROGMEM = { REPLIST_1(_NR_TRAM_NAMES, _TRAM_NAME_ITEM) };
5737

5838
#ifdef ASSISTED_TRAMMING_WAIT_POSITION
5939

‎Marlin/src/feature/tramming.h

+24-33
Original file line numberDiff line numberDiff line change
@@ -31,43 +31,34 @@
3131
constexpr xy_pos_t tramming_points[] = TRAMMING_POINT_XY;
3232

3333
#define G35_PROBE_COUNT COUNT(tramming_points)
34-
static_assert(WITHIN(G35_PROBE_COUNT, 3, 6), "TRAMMING_POINT_XY requires between 3 and 6 XY positions.");
34+
static_assert(WITHIN(G35_PROBE_COUNT, 3, 9), "TRAMMING_POINT_XY requires between 3 and 9 XY positions.");
3535

36-
#define VALIDATE_TRAMMING_POINT(N) static_assert(N >= G35_PROBE_COUNT || Probe::build_time::can_reach(tramming_points[N]), \
37-
"TRAMMING_POINT_XY point " STRINGIFY(N) " is not reachable with the default NOZZLE_TO_PROBE offset and PROBING_MARGIN.")
38-
VALIDATE_TRAMMING_POINT(0); VALIDATE_TRAMMING_POINT(1); VALIDATE_TRAMMING_POINT(2); VALIDATE_TRAMMING_POINT(3); VALIDATE_TRAMMING_POINT(4); VALIDATE_TRAMMING_POINT(5);
39-
40-
extern const char point_name_1[], point_name_2[], point_name_3[]
41-
#ifdef TRAMMING_POINT_NAME_4
42-
, point_name_4[]
43-
#ifdef TRAMMING_POINT_NAME_5
44-
, point_name_5[]
45-
#ifdef TRAMMING_POINT_NAME_6
46-
, point_name_6[]
47-
#endif
48-
#endif
49-
#endif
50-
;
51-
52-
#define _NR_TRAM_NAMES 2
53-
#ifdef TRAMMING_POINT_NAME_3
54-
#undef _NR_TRAM_NAMES
36+
#ifdef TRAMMING_POINT_NAME_9
37+
#define _NR_TRAM_NAMES 9
38+
#elif defined(TRAMMING_POINT_NAME_8)
39+
#define _NR_TRAM_NAMES 8
40+
#elif defined(TRAMMING_POINT_NAME_7)
41+
#define _NR_TRAM_NAMES 7
42+
#elif defined(TRAMMING_POINT_NAME_6)
43+
#define _NR_TRAM_NAMES 6
44+
#elif defined(TRAMMING_POINT_NAME_5)
45+
#define _NR_TRAM_NAMES 5
46+
#elif defined(TRAMMING_POINT_NAME_4)
47+
#define _NR_TRAM_NAMES 4
48+
#elif defined(TRAMMING_POINT_NAME_3)
5549
#define _NR_TRAM_NAMES 3
56-
#ifdef TRAMMING_POINT_NAME_4
57-
#undef _NR_TRAM_NAMES
58-
#define _NR_TRAM_NAMES 4
59-
#ifdef TRAMMING_POINT_NAME_5
60-
#undef _NR_TRAM_NAMES
61-
#define _NR_TRAM_NAMES 5
62-
#ifdef TRAMMING_POINT_NAME_6
63-
#undef _NR_TRAM_NAMES
64-
#define _NR_TRAM_NAMES 6
65-
#endif
66-
#endif
67-
#endif
50+
#else
51+
#define _NR_TRAM_NAMES 0
6852
#endif
53+
6954
static_assert(_NR_TRAM_NAMES >= G35_PROBE_COUNT, "Define enough TRAMMING_POINT_NAME_s for all TRAMMING_POINT_XY entries.");
70-
#undef _NR_TRAM_NAMES
55+
56+
#define _TRAM_NAME_PTR(N) point_name_##N[]
57+
extern const char REPLIST_1(_NR_TRAM_NAMES, _TRAM_NAME_PTR);
58+
59+
#define _CHECK_TRAM_POINT(N) static_assert(Probe::build_time::can_reach(tramming_points[N]), "TRAMMING_POINT_XY point " STRINGIFY(N) " is not reachable with the default NOZZLE_TO_PROBE offset and PROBING_MARGIN.");
60+
REPEAT(_NR_TRAM_NAMES, _CHECK_TRAM_POINT)
61+
#undef _CHECK_TRAM_POINT
7162

7263
extern PGM_P const tramming_point_name[];
7364

‎buildroot/tests/DUE

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ opt_set MOTHERBOARD BOARD_RAMPS4DUE_EFB \
1212
TEMP_SENSOR_0 -2 TEMP_SENSOR_BED 2 \
1313
GRID_MAX_POINTS_X 16 \
1414
E0_AUTO_FAN_PIN 8 FANMUX0_PIN 53 EXTRUDER_AUTO_FAN_SPEED 100 \
15-
TEMP_SENSOR_CHAMBER 3 TEMP_CHAMBER_PIN 6 HEATER_CHAMBER_PIN 45
15+
TEMP_SENSOR_CHAMBER 3 TEMP_CHAMBER_PIN 6 HEATER_CHAMBER_PIN 45 \
16+
TRAMMING_POINT_XY '{{20,20},{20,20},{20,20},{20,20},{20,20}}' TRAMMING_POINT_NAME_5 '"Point 5"'
1617
opt_enable S_CURVE_ACCELERATION EEPROM_SETTINGS GCODE_MACROS \
1718
FIX_MOUNTED_PROBE Z_SAFE_HOMING CODEPENDENT_XY_HOMING \
1819
ASSISTED_TRAMMING REPORT_TRAMMING_MM ASSISTED_TRAMMING_WAIT_POSITION \

0 commit comments

Comments
 (0)
Please sign in to comment.