@@ -34,18 +34,18 @@ static bool EEPROM_writeData(uint8_t* pos, uint8_t* value, uint8_t size, const c
34
34
#ifdef DEBUG_EEPROM_WRITE
35
35
printf_P (PSTR (" EEPROM_WRITE_VAR addr=0x%04x size=0x%02x name=%s\n " ), pos, size, name);
36
36
#endif // DEBUG_EEPROM_WRITE
37
- while (size--)
38
- {
37
+ while (size--)
38
+ {
39
39
40
40
eeprom_update_byte (pos, *value);
41
41
if (eeprom_read_byte (pos) != *value) {
42
42
SERIAL_ECHOLNPGM (" EEPROM Error" );
43
43
return false ;
44
44
}
45
45
46
- pos++;
47
- value++;
48
- }
46
+ pos++;
47
+ value++;
48
+ }
49
49
return true ;
50
50
}
51
51
@@ -89,8 +89,8 @@ void Config_StoreSettings()
89
89
void Config_PrintSettings (uint8_t level)
90
90
{ // Always have this function, even with EEPROM_SETTINGS disabled, the current values will be shown
91
91
#ifdef TMC2130
92
- printf_P (PSTR (
93
- " %SSteps per unit:\n %S M92 X%.2f Y%.2f Z%.2f E%.2f\n "
92
+ printf_P (PSTR (
93
+ " %SSteps per unit:\n %S M92 X%.2f Y%.2f Z%.2f E%.2f\n "
94
94
" %SUStep resolution: \n %S M350 X%d Y%d Z%d E%d\n "
95
95
" %SMaximum feedrates - normal (mm/s):\n %S M203 X%.2f Y%.2f Z%.2f E%.2f\n "
96
96
" %SMaximum feedrates - stealth (mm/s):\n %S M203 X%.2f Y%.2f Z%.2f E%.2f\n "
@@ -125,50 +125,54 @@ void Config_PrintSettings(uint8_t level)
125
125
echomagic, echomagic, cs.minimumfeedrate , cs.mintravelfeedrate , cs.minsegmenttime , cs.max_jerk [X_AXIS], cs.max_jerk [Y_AXIS], cs.max_jerk [Z_AXIS], cs.max_jerk [E_AXIS],
126
126
echomagic, echomagic, cs.add_homing [X_AXIS], cs.add_homing [Y_AXIS], cs.add_homing [Z_AXIS]
127
127
#endif // TMC2130
128
- );
128
+ );
129
129
#ifdef PIDTEMP
130
- printf_P (PSTR (" %SPID settings:\n %S M301 P%.2f I%.2f D%.2f\n " ),
131
- echomagic, echomagic, cs.Kp , unscalePID_i (cs.Ki ), unscalePID_d (cs.Kd ));
130
+ printf_P (PSTR (" %SPID settings:\n %S M301 P%.2f I%.2f D%.2f\n " ),
131
+ echomagic, echomagic, cs.Kp , unscalePID_i (cs.Ki ), unscalePID_d (cs.Kd ));
132
132
#endif
133
133
#ifdef PIDTEMPBED
134
- printf_P (PSTR (" %SPID heatbed settings:\n %S M304 P%.2f I%.2f D%.2f\n " ),
135
- echomagic, echomagic, cs.bedKp , unscalePID_i (cs.bedKi ), unscalePID_d (cs.bedKd ));
134
+ printf_P (PSTR (" %SPID heatbed settings:\n %S M304 P%.2f I%.2f D%.2f\n " ),
135
+ echomagic, echomagic, cs.bedKp , unscalePID_i (cs.bedKi ), unscalePID_d (cs.bedKd ));
136
136
#endif
137
137
#ifdef FWRETRACT
138
- printf_P (PSTR (
139
- " %SRetract: S=Length (mm) F:Speed (mm/m) Z: ZLift (mm)\n %S M207 S%.2f F%.2f Z%.2f\n "
140
- " %SRecover: S=Extra length (mm) F:Speed (mm/m)\n %S M208 S%.2f F%.2f\n "
141
- " %SAuto-Retract: S=0 to disable, 1 to interpret extrude-only moves as retracts or recoveries\n %S M209 S%d\n "
142
- ),
143
- echomagic, echomagic, cs.retract_length , cs.retract_feedrate *60 , cs.retract_zlift ,
144
- echomagic, echomagic, cs.retract_recover_length , cs.retract_recover_feedrate *60 ,
145
- echomagic, echomagic, (cs.autoretract_enabled ? 1 : 0 )
146
- );
138
+ printf_P (PSTR (
139
+ " %SRetract: S=Length (mm) F:Speed (mm/m) Z: ZLift (mm)\n %S M207 S%.2f F%.2f Z%.2f\n "
140
+ " %SRecover: S=Extra length (mm) F:Speed (mm/m)\n %S M208 S%.2f F%.2f\n "
141
+ " %SAuto-Retract: S=0 to disable, 1 to interpret extrude-only moves as retracts or recoveries\n %S M209 S%d\n "
142
+ ),
143
+ echomagic, echomagic, cs.retract_length , cs.retract_feedrate *60 , cs.retract_zlift ,
144
+ echomagic, echomagic, cs.retract_recover_length , cs.retract_recover_feedrate *60 ,
145
+ echomagic, echomagic, (cs.autoretract_enabled ? 1 : 0 )
146
+ );
147
147
#if EXTRUDERS > 1
148
- printf_P (PSTR (" %SMulti-extruder settings:\n %S Swap retract length (mm): %.2f\n %S Swap rec. addl. length (mm): %.2f\n " ),
149
- echomagic, echomagic, retract_length_swap, echomagic, retract_recover_length_swap);
148
+ printf_P (PSTR (" %SMulti-extruder settings:\n %S Swap retract length (mm): %.2f\n %S Swap rec. addl. length (mm): %.2f\n " ),
149
+ echomagic, echomagic, retract_length_swap, echomagic, retract_recover_length_swap);
150
150
#endif
151
- if (cs.volumetric_enabled ) {
152
- printf_P (PSTR (" %SFilament settings:\n %S M200 D%.2f\n " ),
153
- echomagic, echomagic, cs.filament_size [0 ]);
151
+ if (cs.volumetric_enabled ) {
152
+ printf_P (PSTR (" %SFilament settings:\n %S M200 D%.2f\n " ),
153
+ echomagic, echomagic, cs.filament_size [0 ]);
154
154
#if EXTRUDERS > 1
155
- printf_P (PSTR (" %S M200 T1 D%.2f\n " ),
156
- echomagic, echomagic, cs.filament_size [1 ]);
155
+ printf_P (PSTR (" %S M200 T1 D%.2f\n " ),
156
+ echomagic, echomagic, cs.filament_size [1 ]);
157
157
#if EXTRUDERS > 2
158
- printf_P (PSTR (" %S M200 T1 D%.2f\n " ),
159
- echomagic, echomagic, cs.filament_size [2 ]);
158
+ printf_P (PSTR (" %S M200 T1 D%.2f\n " ),
159
+ echomagic, echomagic, cs.filament_size [2 ]);
160
160
#endif
161
161
#endif
162
162
} else {
163
163
printf_P (PSTR (" %SFilament settings: Disabled\n " ), echomagic);
164
164
}
165
165
#endif
166
- if (level >= 10 ) {
166
+ if (level >= 10 ) {
167
167
#ifdef LIN_ADVANCE
168
- printf_P (PSTR (" %SLinear advance settings:%S M900 K%.2f\n " ),
168
+ printf_P (PSTR (" %SLinear advance settings:%S M900 K%.2f\n " ),
169
169
echomagic, echomagic, extruder_advance_K);
170
170
#endif // LIN_ADVANCE
171
- }
171
+ }
172
+ // Arc Interpolation Settings
173
+ printf_P (PSTR (
174
+ " %SArc Settings: P:Max length(mm) S:Min length (mm) N:Corrections R:Min segments F:Segments/sec.\n %S M214 P%.2f S%.2f N%d R%d F%d\n " ),
175
+ echomagic, echomagic, cs.mm_per_arc_segment , cs.min_mm_per_arc_segment , cs.n_arc_correction , cs.min_arc_segments , cs.arc_segments_per_sec );
172
176
}
173
177
#endif
174
178
@@ -184,7 +188,7 @@ static_assert (false, "zprobe_zoffset was not initialized in printers in field t
184
188
" 0.0, if this is not acceptable, increment EEPROM_VERSION to force use default_conf" );
185
189
#endif
186
190
187
- static_assert (sizeof (M500_conf) == 196 , "sizeof(M500_conf) has changed, ensure that EEPROM_VERSION has been incremented, "
191
+ static_assert (sizeof (M500_conf) == 209 , "sizeof(M500_conf) has changed, ensure that EEPROM_VERSION has been incremented, "
188
192
"or if you added members in the end of struct, ensure that historically uninitialized values will be initialized."
189
193
"If this is caused by change to more then 8bit processor, decide whether make this struct packed to save EEPROM,"
190
194
"leave as it is to keep fast code, or reorder struct members to pack more tightly.");
@@ -233,6 +237,11 @@ static const M500_conf default_conf PROGMEM =
233
237
{16 ,16 ,16 ,16 },
234
238
#endif
235
239
DEFAULT_TRAVEL_ACCELERATION,
240
+ DEFAULT_MM_PER_ARC_SEGMENT,
241
+ DEFAULT_MIN_MM_PER_ARC_SEGMENT,
242
+ DEFAULT_N_ARC_CORRECTION,
243
+ DEFAULT_MIN_ARC_SEGMENTS,
244
+ DEFAULT_ARC_SEGMENTS_PER_SEC
236
245
};
237
246
238
247
@@ -252,7 +261,7 @@ static bool is_uninitialized(void* addr, uint8_t len)
252
261
// ! @retval false Failed. Default settings has been retrieved, because of older version or corrupted data.
253
262
bool Config_RetrieveSettings ()
254
263
{
255
- bool previous_settings_retrieved = true ;
264
+ bool previous_settings_retrieved = true ;
256
265
char ver[4 ]=EEPROM_VERSION;
257
266
EEPROM_readData (reinterpret_cast <uint8_t *>(EEPROM_M500_base->version ), reinterpret_cast <uint8_t *>(cs.version ), sizeof (cs.version ), " cs.version" ); // read stored version
258
267
// SERIAL_ECHOLN("Version: [" << ver << "] Stored version: [" << cs.version << "]");
@@ -262,7 +271,7 @@ bool Config_RetrieveSettings()
262
271
EEPROM_readData (reinterpret_cast <uint8_t *>(EEPROM_M500_base), reinterpret_cast <uint8_t *>(&cs), sizeof (cs), " cs" );
263
272
calculate_extruder_multipliers ();
264
273
265
- // if max_feedrate_silent and max_acceleration_units_per_sq_second_silent were never stored to eeprom, use default values:
274
+ // if max_feedrate_silent and max_acceleration_units_per_sq_second_silent were never stored to eeprom, use default values:
266
275
for (uint8_t i = 0 ; i < (sizeof (cs.max_feedrate_silent )/sizeof (cs.max_feedrate_silent [0 ])); ++i)
267
276
{
268
277
const uint32_t erased = 0xffffffff ;
@@ -273,74 +282,82 @@ bool Config_RetrieveSettings()
273
282
memcpy_P (&cs.max_acceleration_units_per_sq_second_silent [i],&default_conf.max_acceleration_units_per_sq_second_silent [i],sizeof (cs.max_acceleration_units_per_sq_second_silent [i]));
274
283
}
275
284
}
285
+ // Initialize arc interpolation settings if they are not already
286
+ if (is_uninitialized (&cs.mm_per_arc_segment , sizeof (cs.mm_per_arc_segment ))) cs.mm_per_arc_segment = default_conf.mm_per_arc_segment ;
287
+ if (is_uninitialized (&cs.min_mm_per_arc_segment , sizeof (cs.min_mm_per_arc_segment ))) cs.min_mm_per_arc_segment = default_conf.min_mm_per_arc_segment ;
288
+ if (is_uninitialized (&cs.n_arc_correction , sizeof (cs.n_arc_correction ))) cs.n_arc_correction = default_conf.n_arc_correction ;
289
+ if (is_uninitialized (&cs.min_arc_segments , sizeof (cs.min_arc_segments ))) cs.min_arc_segments = default_conf.min_arc_segments ;
290
+ if (is_uninitialized (&cs.arc_segments_per_sec , sizeof (cs.arc_segments_per_sec ))) cs.arc_segments_per_sec = default_conf.arc_segments_per_sec ;
291
+
276
292
277
293
#ifdef TMC2130
278
- for (uint8_t j = X_AXIS; j <= Y_AXIS; j++)
279
- {
280
- if (cs.max_feedrate_normal [j] > NORMAL_MAX_FEEDRATE_XY)
281
- cs.max_feedrate_normal [j] = NORMAL_MAX_FEEDRATE_XY;
282
- if (cs.max_feedrate_silent [j] > SILENT_MAX_FEEDRATE_XY)
283
- cs.max_feedrate_silent [j] = SILENT_MAX_FEEDRATE_XY;
284
- if (cs.max_acceleration_units_per_sq_second_normal [j] > NORMAL_MAX_ACCEL_XY)
285
- cs.max_acceleration_units_per_sq_second_normal [j] = NORMAL_MAX_ACCEL_XY;
286
- if (cs.max_acceleration_units_per_sq_second_silent [j] > SILENT_MAX_ACCEL_XY)
287
- cs.max_acceleration_units_per_sq_second_silent [j] = SILENT_MAX_ACCEL_XY;
288
- }
294
+ for (uint8_t j = X_AXIS; j <= Y_AXIS; j++)
295
+ {
296
+ if (cs.max_feedrate_normal [j] > NORMAL_MAX_FEEDRATE_XY)
297
+ cs.max_feedrate_normal [j] = NORMAL_MAX_FEEDRATE_XY;
298
+ if (cs.max_feedrate_silent [j] > SILENT_MAX_FEEDRATE_XY)
299
+ cs.max_feedrate_silent [j] = SILENT_MAX_FEEDRATE_XY;
300
+ if (cs.max_acceleration_units_per_sq_second_normal [j] > NORMAL_MAX_ACCEL_XY)
301
+ cs.max_acceleration_units_per_sq_second_normal [j] = NORMAL_MAX_ACCEL_XY;
302
+ if (cs.max_acceleration_units_per_sq_second_silent [j] > SILENT_MAX_ACCEL_XY)
303
+ cs.max_acceleration_units_per_sq_second_silent [j] = SILENT_MAX_ACCEL_XY;
304
+ }
289
305
290
- if (cs.axis_ustep_resolution [X_AXIS] == 0xff ){ cs.axis_ustep_resolution [X_AXIS] = TMC2130_USTEPS_XY; }
291
- if (cs.axis_ustep_resolution [Y_AXIS] == 0xff ){ cs.axis_ustep_resolution [Y_AXIS] = TMC2130_USTEPS_XY; }
292
- if (cs.axis_ustep_resolution [Z_AXIS] == 0xff ){ cs.axis_ustep_resolution [Z_AXIS] = TMC2130_USTEPS_Z; }
293
- if (cs.axis_ustep_resolution [E_AXIS] == 0xff ){ cs.axis_ustep_resolution [E_AXIS] = TMC2130_USTEPS_E; }
294
-
295
- tmc2130_set_res (X_AXIS, cs.axis_ustep_resolution [X_AXIS]);
296
- tmc2130_set_res (Y_AXIS, cs.axis_ustep_resolution [Y_AXIS]);
297
- tmc2130_set_res (Z_AXIS, cs.axis_ustep_resolution [Z_AXIS]);
298
- tmc2130_set_res (E_AXIS, cs.axis_ustep_resolution [E_AXIS]);
306
+ if (cs.axis_ustep_resolution [X_AXIS] == 0xff ){ cs.axis_ustep_resolution [X_AXIS] = TMC2130_USTEPS_XY; }
307
+ if (cs.axis_ustep_resolution [Y_AXIS] == 0xff ){ cs.axis_ustep_resolution [Y_AXIS] = TMC2130_USTEPS_XY; }
308
+ if (cs.axis_ustep_resolution [Z_AXIS] == 0xff ){ cs.axis_ustep_resolution [Z_AXIS] = TMC2130_USTEPS_Z; }
309
+ if (cs.axis_ustep_resolution [E_AXIS] == 0xff ){ cs.axis_ustep_resolution [E_AXIS] = TMC2130_USTEPS_E; }
310
+
311
+ tmc2130_set_res (X_AXIS, cs.axis_ustep_resolution [X_AXIS]);
312
+ tmc2130_set_res (Y_AXIS, cs.axis_ustep_resolution [Y_AXIS]);
313
+ tmc2130_set_res (Z_AXIS, cs.axis_ustep_resolution [Z_AXIS]);
314
+ tmc2130_set_res (E_AXIS, cs.axis_ustep_resolution [E_AXIS]);
299
315
#endif // TMC2130
300
316
301
317
if (is_uninitialized (&cs.travel_acceleration , sizeof (cs.travel_acceleration )))
302
318
cs.travel_acceleration = cs.acceleration ;
303
319
304
320
reset_acceleration_rates ();
305
321
306
- // Call updatePID (similar to when we have processed M301)
307
- updatePID ();
322
+ // Call updatePID (similar to when we have processed M301)
323
+ updatePID ();
308
324
SERIAL_ECHO_START;
309
325
SERIAL_ECHOLNPGM (" Stored settings retrieved" );
310
326
}
311
327
else
312
328
{
313
329
Config_ResetDefault ();
314
- // Return false to inform user that eeprom version was changed and firmware is using default hardcoded settings now.
315
- // In case that storing to eeprom was not used yet, do not inform user that hardcoded settings are used.
316
- if (eeprom_read_byte (reinterpret_cast <uint8_t *>(&(EEPROM_M500_base->version [0 ]))) != 0xFF ||
317
- eeprom_read_byte (reinterpret_cast <uint8_t *>(&(EEPROM_M500_base->version [1 ]))) != 0xFF ||
318
- eeprom_read_byte (reinterpret_cast <uint8_t *>(&(EEPROM_M500_base->version [2 ]))) != 0xFF )
319
- {
320
- previous_settings_retrieved = false ;
321
- }
330
+ // Return false to inform user that eeprom version was changed and firmware is using default hardcoded settings now.
331
+ // In case that storing to eeprom was not used yet, do not inform user that hardcoded settings are used.
332
+ if (eeprom_read_byte (reinterpret_cast <uint8_t *>(&(EEPROM_M500_base->version [0 ]))) != 0xFF ||
333
+ eeprom_read_byte (reinterpret_cast <uint8_t *>(&(EEPROM_M500_base->version [1 ]))) != 0xFF ||
334
+ eeprom_read_byte (reinterpret_cast <uint8_t *>(&(EEPROM_M500_base->version [2 ]))) != 0xFF )
335
+ {
336
+ previous_settings_retrieved = false ;
337
+ }
322
338
}
323
339
#ifdef EEPROM_CHITCHAT
324
340
Config_PrintSettings ();
325
341
#endif
326
- return previous_settings_retrieved;
342
+ return previous_settings_retrieved;
327
343
}
328
344
#endif
329
345
330
346
void Config_ResetDefault ()
331
347
{
332
348
memcpy_P (&cs,&default_conf, sizeof (cs));
333
349
334
- // steps per sq second need to be updated to agree with the units per sq second
350
+ // steps per sq second need to be updated to agree with the units per sq second
335
351
reset_acceleration_rates ();
336
352
337
353
#ifdef PIDTEMP
338
354
updatePID ();
339
355
#endif // PIDTEMP
340
356
341
- calculate_extruder_multipliers ();
357
+ calculate_extruder_multipliers ();
342
358
343
359
SERIAL_ECHO_START;
344
360
SERIAL_ECHOLNPGM (" Hardcoded Default Settings Loaded" );
345
361
346
362
}
363
+
0 commit comments