22
22
23
23
#include " ../../inc/MarlinConfig.h"
24
24
25
+ /* *
26
+ * M360 Report Printer Configuration - Repetier Firmware
27
+ * See https://github.com/repetier/Repetier-Firmware/blob/master/src/ArduinoAVR/Repetier/Printer.cpp
28
+ */
25
29
#if ENABLED(REPETIER_GCODE_M360)
26
30
27
31
#include " ../gcode.h"
33
37
#include " ../../module/temperature.h"
34
38
#endif
35
39
36
- static void config_prefix (PGM_P const name, PGM_P const pref=nullptr , const int8_t ind=-1 ) {
40
+ #include < cstddef>
41
+
42
+ struct ProgStr {
43
+ PGM_P ptr;
44
+ constexpr ProgStr (PGM_P p) : ptr(p) {}
45
+ ProgStr (FSTR_P f) : ptr(FTOP(f)) {}
46
+ ProgStr (std::nullptr_t ) : ptr(nullptr ) {}
47
+
48
+ constexpr operator PGM_P () const { return ptr; }
49
+ constexpr explicit operator bool () const { return ptr != nullptr ; }
50
+ };
51
+
52
+ static void config_prefix (ProgStr name, ProgStr pref=nullptr , int8_t ind=-1 ) {
37
53
SERIAL_ECHOPGM (" Config:" );
38
- if (pref) SERIAL_ECHOPGM_P (pref);
54
+ if (pref) SERIAL_ECHOPGM_P (static_cast <PGM_P>( pref) );
39
55
if (ind >= 0 ) { SERIAL_ECHO (ind); SERIAL_CHAR (' :' ); }
40
- SERIAL_ECHOPGM_P (name, C (' :' ));
56
+ SERIAL_ECHOPGM_P (static_cast <PGM_P>( name) , C (' :' ));
41
57
}
42
- static void config_line (PGM_P const name, const float val, PGM_P const pref=nullptr , const int8_t ind=-1 ) {
58
+
59
+ template <typename T>
60
+ static void config_line (ProgStr name, const T val, ProgStr pref=nullptr , int8_t ind=-1 ) {
43
61
config_prefix (name, pref, ind);
44
62
SERIAL_ECHOLN (val);
45
63
}
46
- static void config_line (FSTR_P const name, const float val, FSTR_P const pref=nullptr , const int8_t ind=-1 ) {
47
- config_line (FTOP (name), val, FTOP (pref), ind);
48
- }
49
- static void config_line_e (const int8_t e, PGM_P const name, const float val) {
64
+
65
+ template <typename T>
66
+ static void config_line_e (int8_t e, ProgStr name, const T val) {
50
67
config_line (name, val, PSTR (" Extr." ), e + 1 );
51
68
}
52
- static void config_line_e (const int8_t e, FSTR_P const name, const float val) {
53
- config_line_e (e, FTOP (name), val);
54
- }
55
-
56
69
/* *
57
70
* M360: Report Firmware configuration
58
71
* in RepRapFirmware-compatible format
59
72
*/
60
73
void GcodeSuite::M360 () {
61
- PGMSTR (X_STR, " X" );
62
- PGMSTR (Y_STR, " Y" );
63
- PGMSTR (Z_STR, " Z" );
64
- #if ANY(CLASSIC_JERK, HAS_LINEAR_E_JERK)
65
- PGMSTR (JERK_STR, " Jerk" );
66
- #endif
67
-
68
74
//
69
75
// Basics and Enabled items
70
76
//
71
77
config_line (F (" Baudrate" ), BAUDRATE);
72
78
config_line (F (" InputBuffer" ), MAX_CMD_SIZE);
73
79
config_line (F (" PrintlineCache" ), BUFSIZE);
74
- config_line (F (" MixingExtruder" ), ENABLED (MIXING_EXTRUDER));
75
- config_line (F (" SDCard" ), ENABLED (HAS_MEDIA));
76
- config_line (F (" Fan" ), ENABLED (HAS_FAN));
77
- config_line (F (" LCD" ), ENABLED (HAS_DISPLAY));
80
+ config_line (F (" MixingExtruder" ), bool ( ENABLED (MIXING_EXTRUDER) ));
81
+ config_line (F (" SDCard" ), bool ( ENABLED (HAS_MEDIA) ));
82
+ config_line (F (" Fan" ), bool ( ENABLED (HAS_FAN) ));
83
+ config_line (F (" LCD" ), bool ( ENABLED (HAS_DISPLAY) ));
78
84
config_line (F (" SoftwarePowerSwitch" ), 1 );
79
- config_line (F (" SupportLocalFilamentchange" ), ENABLED (ADVANCED_PAUSE_FEATURE));
80
- config_line (F (" CaseLights" ), ENABLED (CASE_LIGHT_ENABLE));
81
- config_line (F (" ZProbe" ), ENABLED (HAS_BED_PROBE));
82
- config_line (F (" Autolevel" ), ENABLED (HAS_LEVELING));
83
- config_line (F (" EEPROM" ), ENABLED (EEPROM_SETTINGS));
85
+ config_line (F (" SupportLocalFilamentchange" ), bool (ENABLED (ADVANCED_PAUSE_FEATURE)));
86
+ config_line (F (" CaseLights" ), bool (ENABLED (CASE_LIGHT_ENABLE)));
87
+ config_line (F (" ZProbe" ), bool (ENABLED (HAS_BED_PROBE)));
88
+ config_line (F (" Autolevel" ), bool (ENABLED (HAS_LEVELING)));
89
+ config_line (F (" EEPROM" ), bool (ENABLED (EEPROM_SETTINGS)));
90
+
91
+ //
92
+ // Axis letters, in PROGMEM
93
+ //
94
+ #define _DEFINE_A_STR (Q ) PGMSTR(Q##_STR, STR_##Q);
95
+ MAIN_AXIS_MAP (_DEFINE_A_STR);
84
96
85
97
//
86
98
// Homing Directions
87
99
//
88
100
PGMSTR (H_DIR_STR, " HomeDir" );
89
- config_line (H_DIR_STR, X_HOME_DIR, X_STR);
90
- config_line (H_DIR_STR, Y_HOME_DIR, Y_STR);
91
- config_line (H_DIR_STR, Z_HOME_DIR, Z_STR);
101
+ #if X_HOME_DIR
102
+ config_line (H_DIR_STR, X_HOME_DIR, X_STR);
103
+ #endif
104
+ #if Y_HOME_DIR
105
+ config_line (H_DIR_STR, Y_HOME_DIR, Y_STR);
106
+ #endif
107
+ #if Z_HOME_DIR
108
+ config_line (H_DIR_STR, Z_HOME_DIR, Z_STR);
109
+ #endif
110
+ #if I_HOME_DIR
111
+ config_line (H_DIR_STR, I_HOME_DIR, I_STR);
112
+ #endif
113
+ #if J_HOME_DIR
114
+ config_line (H_DIR_STR, J_HOME_DIR, J_STR);
115
+ #endif
116
+ #if K_HOME_DIR
117
+ config_line (H_DIR_STR, K_HOME_DIR, K_STR);
118
+ #endif
119
+ #if U_HOME_DIR
120
+ config_line (H_DIR_STR, U_HOME_DIR, U_STR);
121
+ #endif
122
+ #if V_HOME_DIR
123
+ config_line (H_DIR_STR, V_HOME_DIR, V_STR);
124
+ #endif
125
+ #if W_HOME_DIR
126
+ config_line (H_DIR_STR, W_HOME_DIR, W_STR);
127
+ #endif
128
+
129
+ #if ANY(CLASSIC_JERK, HAS_LINEAR_E_JERK)
130
+ PGMSTR (JERK_STR, " Jerk" );
131
+ #endif
92
132
93
133
//
94
134
// XYZ Axis Jerk
95
135
//
96
136
#if ENABLED(CLASSIC_JERK)
97
- if (planner.max_jerk .x == planner.max_jerk .y )
98
- config_line (F (" XY" ), planner.max_jerk .x , FPSTR (JERK_STR));
137
+ #define _REPORT_JERK (Q ) config_line(Q##_STR, planner.max_jerk.Q, JERK_STR);
138
+ if (TERN0 (HAS_Y_AXIS, planner.max_jerk .x == planner.max_jerk .y ))
139
+ config_line (F (" XY" ), planner.max_jerk .x , JERK_STR);
99
140
else {
100
- config_line (X_STR, planner. max_jerk . x , JERK_STR );
101
- config_line (Y_STR, planner. max_jerk . y , JERK_STR );
141
+ TERN_ (HAS_X_AXIS, _REPORT_JERK (X) );
142
+ TERN_ (HAS_Y_AXIS, _REPORT_JERK (Y) );
102
143
}
103
- config_line (Z_STR, planner.max_jerk .z , JERK_STR);
144
+ TERN_ (HAS_Z_AXIS, config_line (Z_STR, planner.max_jerk .z , JERK_STR));
145
+ SECONDARY_AXIS_MAP (_REPORT_JERK);
104
146
#endif
105
147
106
148
//
@@ -112,53 +154,62 @@ void GcodeSuite::M360() {
112
154
PGMSTR (UNRET_STR, " RetractionUndo" );
113
155
PGMSTR (SPEED_STR, " Speed" );
114
156
// M10 Retract with swap (long) moves
115
- config_line (F (" Length" ), fwretract.settings .retract_length , FPSTR (RET_STR));
157
+ config_line (F (" Length" ), fwretract.settings .retract_length , RET_STR);
158
+ config_line (F (" LongLength" ), fwretract.settings .swap_retract_length , RET_STR);
116
159
config_line (SPEED_STR, fwretract.settings .retract_feedrate_mm_s , RET_STR);
117
- config_line (F (" ZLift" ), fwretract.settings .retract_zraise , FPSTR (RET_STR));
118
- config_line (F (" LongLength" ), fwretract.settings .swap_retract_length , FPSTR (RET_STR));
160
+ config_line (F (" ZLift" ), fwretract.settings .retract_zraise , RET_STR);
119
161
// M11 Recover (undo) with swap (long) moves
162
+ config_line (F (" ExtraLength" ), fwretract.settings .retract_recover_extra , UNRET_STR);
163
+ config_line (F (" ExtraLongLength" ), fwretract.settings .swap_retract_recover_extra , UNRET_STR);
120
164
config_line (SPEED_STR, fwretract.settings .retract_recover_feedrate_mm_s , UNRET_STR);
121
- config_line (F (" ExtraLength" ), fwretract.settings .retract_recover_extra , FPSTR (UNRET_STR));
122
- config_line (F (" ExtraLongLength" ), fwretract.settings .swap_retract_recover_extra , FPSTR (UNRET_STR));
123
- config_line (F (" LongSpeed" ), fwretract.settings .swap_retract_recover_feedrate_mm_s , FPSTR (UNRET_STR));
165
+ config_line (F (" LongSpeed" ), fwretract.settings .swap_retract_recover_feedrate_mm_s , UNRET_STR);
124
166
#endif
125
167
126
168
//
127
169
// Workspace boundaries
128
170
//
129
- const xyz_pos_t dmin = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS } ,
130
- dmax = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS } ;
171
+ const xyz_pos_t dmin = NUM_AXIS_ARRAY ( X_MIN_POS, Y_MIN_POS, Z_MIN_POS, I_MIN_POS, J_MIN_POS, K_MIN_POS, U_MIN_POS, V_MIN_POS, W_MIN_POS) ,
172
+ dmax = NUM_AXIS_ARRAY ( X_MAX_POS, Y_MAX_POS, Z_MAX_POS, I_MAX_POS, J_MAX_POS, K_MAX_POS, U_MAX_POS, V_MAX_POS, W_MAX_POS) ;
131
173
xyz_pos_t cmin = dmin, cmax = dmax;
132
174
apply_motion_limits (cmin);
133
175
apply_motion_limits (cmax);
134
176
const xyz_pos_t wmin = cmin.asLogical (), wmax = cmax.asLogical ();
135
177
136
178
PGMSTR (MIN_STR, " Min" );
179
+ #define _REPORT_MIN (Q ) config_line(MIN_STR, wmin.Q, Q##_STR);
180
+ MAIN_AXIS_MAP (_REPORT_MIN);
181
+
137
182
PGMSTR (MAX_STR, " Max" );
183
+ #define _REPORT_MAX (Q ) config_line(MAX_STR, wmax.Q, Q##_STR);
184
+ MAIN_AXIS_MAP (_REPORT_MAX);
185
+
138
186
PGMSTR (SIZE_STR, " Size" );
139
- config_line (MIN_STR, wmin.x , X_STR );
140
- config_line (MIN_STR, wmin. y , Y_STR );
141
- config_line (MIN_STR, wmin. z , Z_STR);
142
- config_line (MAX_STR, wmax. x , X_STR);
143
- config_line (MAX_STR, wmax. y , Y_STR);
144
- config_line (MAX_STR, wmax. z , Z_STR);
145
- config_line (SIZE_STR, wmax. x - wmin. x , X_STR );
146
- config_line (SIZE_STR, wmax. y - wmin. y , Y_STR );
147
- config_line (SIZE_STR, wmax. z - wmin. z , Z_STR );
187
+ # define _REPORT_SIZE ( Q ) config_line(SIZE_STR, wmax.Q - wmin.Q, Q##_STR );
188
+ MAIN_AXIS_MAP (_REPORT_SIZE );
189
+
190
+ //
191
+ // Axis Steps per mm
192
+ //
193
+ PGMSTR (S_MM_STR, " Steps/mm " );
194
+ # define _REPORT_S_MM ( Q ) config_line(S_MM_STR, planner.settings.axis_steps_per_mm[_AXIS(Q)], Q##_STR );
195
+ MAIN_AXIS_MAP (_REPORT_S_MM );
148
196
149
197
//
150
198
// Print and Travel Acceleration
151
199
//
152
- #define _ACCEL (A,B ) _MIN(planner.settings.max_acceleration_mm_per_s2[A##_AXIS], planner.settings.B)
200
+ #define _ACCEL (Q,B ) _MIN(planner.settings.max_acceleration_mm_per_s2[Q##_AXIS], planner.settings.B)
201
+
153
202
PGMSTR (P_ACC_STR, " PrintAccel" );
203
+ #define _REPORT_P_ACC (Q ) config_line(P_ACC_STR, _ACCEL(Q, acceleration), Q##_STR);
204
+ MAIN_AXIS_MAP (_REPORT_P_ACC);
205
+
154
206
PGMSTR (T_ACC_STR, " TravelAccel" );
155
- config_line (P_ACC_STR, _ACCEL (X, acceleration), X_STR);
156
- config_line (P_ACC_STR, _ACCEL (Y, acceleration), Y_STR);
157
- config_line (P_ACC_STR, _ACCEL (Z, acceleration), Z_STR);
158
- config_line (T_ACC_STR, _ACCEL (X, travel_acceleration), X_STR);
159
- config_line (T_ACC_STR, _ACCEL (Y, travel_acceleration), Y_STR);
160
- config_line (T_ACC_STR, _ACCEL (Z, travel_acceleration), Z_STR);
207
+ #define _REPORT_T_ACC (Q ) config_line(T_ACC_STR, _ACCEL(Q, travel_acceleration), Q##_STR);
208
+ MAIN_AXIS_MAP (_REPORT_T_ACC);
161
209
210
+ //
211
+ // Printer Type
212
+ //
162
213
config_prefix (PSTR (" PrinterType" ));
163
214
SERIAL_ECHOLNPGM (
164
215
TERN_ (DELTA, " Delta" )
@@ -189,12 +240,12 @@ void GcodeSuite::M360() {
189
240
#elif ENABLED(CLASSIC_JERK)
190
241
config_line_e (e, JERK_STR, planner.max_jerk .e );
191
242
#endif
192
- config_line_e (e, F (" MaxSpeed" ), planner.settings .max_feedrate_mm_s [E_AXIS_N (e)]);
193
243
config_line_e (e, F (" Acceleration" ), planner.settings .max_acceleration_mm_per_s2 [E_AXIS_N (e)]);
244
+ config_line_e (e, F (" MaxSpeed" ), planner.settings .max_feedrate_mm_s [E_AXIS_N (e)]);
194
245
config_line_e (e, F (" Diameter" ), TERN (NO_VOLUMETRICS, DEFAULT_NOMINAL_FILAMENT_DIA, planner.filament_size [e]));
195
246
config_line_e (e, F (" MaxTemp" ), thermalManager.hotend_maxtemp [e]);
196
247
}
197
248
#endif
198
249
}
199
250
200
- #endif
251
+ #endif // REPETIER_GCODE_M360
0 commit comments