@@ -255,28 +255,51 @@ static void axis_direction( uint8_t axis, uint8_t from_limit)
255
255
256
256
// Execute the actual homing operation. The hardware selected with the 'axis'
257
257
// variable must exist or we'll fail miserably, so filter before calling here!
258
- static void run_home_one_axis ( uint8_t axis )
258
+ static void run_home_one_axis ( uint8_t axis , uint32_t feed )
259
259
{
260
260
uint32_t fast_step_period = 75 ; // init to keep compiler happy
261
261
uint32_t slow_step_period = 250 ; // init to keep compiler happy
262
262
uint32_t max_pulses_on_axis = 0 ; // init to keep compiler happy
263
263
uint32_t max_pulses_for_release = 0 ; // init to keep compiler happy
264
264
uint8_t limit_switch_state = 0 ; // init to keep compiler happy
265
265
266
+ // TODO: handle undefined _MIN and _MAX values!
267
+
266
268
if (axis == home_x_min || axis == home_x_max ) {
269
+ #if 1
270
+ if (feed > MAXIMUM_FEEDRATE_X ) {
271
+ feed = MAXIMUM_FEEDRATE_X ;
272
+ }
273
+ fast_step_period = (uint32_t ) 1 + (60000000L / STEPS_PER_MM_X ) / feed ;
274
+ #else
267
275
fast_step_period = (uint32_t ) HOME_FAST_STEP_PERIOD_X ;
276
+ #endif
268
277
slow_step_period = (uint32_t ) HOME_SLOW_STEP_PERIOD_X ;
269
278
limit_switch_state = (axis & home_x_max ) ? x_max () : x_min ();
270
279
max_pulses_on_axis = (uint32_t )((X_MAX - X_MIN ) * STEPS_PER_MM_X );
271
280
max_pulses_for_release = (uint32_t )(RELEASE_DISTANCE * STEPS_PER_MM_X );
272
281
} else if (axis == home_y_min || axis == home_y_max ) {
282
+ #if 1
283
+ if (feed > MAXIMUM_FEEDRATE_Y ) {
284
+ feed = MAXIMUM_FEEDRATE_Y ;
285
+ }
286
+ fast_step_period = (uint32_t ) 1 + (60000000L / STEPS_PER_MM_Y ) / feed ;
287
+ #else
273
288
fast_step_period = (uint32_t ) HOME_FAST_STEP_PERIOD_Y ;
289
+ #endif
274
290
slow_step_period = (uint32_t ) HOME_SLOW_STEP_PERIOD_Y ;
275
291
limit_switch_state = (axis & home_y_max ) ? y_max () : y_min ();
276
292
max_pulses_on_axis = (uint32_t )((Y_MAX - Y_MIN ) * STEPS_PER_MM_Y );
277
293
max_pulses_for_release = (uint32_t )(RELEASE_DISTANCE * STEPS_PER_MM_Y );
278
294
} else if (axis == home_z_min || axis == home_z_max ) {
295
+ #if 1
296
+ if (feed > MAXIMUM_FEEDRATE_Z ) {
297
+ feed = MAXIMUM_FEEDRATE_Z ;
298
+ }
299
+ fast_step_period = (uint32_t ) 1 + (60000000L / STEPS_PER_MM_Z ) / feed ;
300
+ #else
279
301
fast_step_period = (uint32_t ) HOME_FAST_STEP_PERIOD_Z ;
302
+ #endif
280
303
slow_step_period = (uint32_t ) HOME_SLOW_STEP_PERIOD_Z ;
281
304
limit_switch_state = (axis & home_z_max ) ? z_max () : z_min ();
282
305
max_pulses_on_axis = (uint32_t )((Z_MAX - Z_MIN ) * STEPS_PER_MM_Z );
@@ -313,21 +336,21 @@ static void run_home_one_axis( uint8_t axis)
313
336
314
337
/// home the selected axis to the selected limit switch.
315
338
// keep all preprocessor configuration stuff at or below this level.
316
- static void home_one_axis ( uint8_t axis ) {
339
+ static void home_one_axis ( uint8_t axis , uint32_t feed ) {
317
340
318
341
// get ready for the action
319
342
power_on ();
320
343
queue_wait ();
321
344
322
345
// move to a limit switch or sensor
323
- run_home_one_axis ( axis );
346
+ run_home_one_axis ( axis , feed );
324
347
325
348
}
326
349
327
350
/// find X MIN endstop
328
- void home_x_negative () {
351
+ void home_x_negative ( uint32_t feed ) {
329
352
#if defined X_MIN_PIN
330
- home_one_axis ( home_x_min );
353
+ home_one_axis ( home_x_min , feed );
331
354
#endif
332
355
// reference 'home' position to current position
333
356
#ifdef X_MIN
@@ -340,9 +363,9 @@ void home_x_negative() {
340
363
}
341
364
342
365
/// find X_MAX endstop
343
- void home_x_positive () {
366
+ void home_x_positive ( uint32_t feed ) {
344
367
#if defined X_MAX_PIN
345
- home_one_axis ( home_x_max );
368
+ home_one_axis ( home_x_max , feed );
346
369
#endif
347
370
// reference 'home' position to current position
348
371
#ifdef X_MAX
@@ -355,9 +378,9 @@ void home_x_positive() {
355
378
}
356
379
357
380
/// find Y MIN endstop
358
- void home_y_negative () {
381
+ void home_y_negative ( uint32_t feed ) {
359
382
#if defined Y_MIN_PIN
360
- home_one_axis ( home_y_min );
383
+ home_one_axis ( home_y_min , feed );
361
384
#endif
362
385
// reference 'home' position to current position
363
386
#ifdef Y_MIN
@@ -370,9 +393,9 @@ void home_y_negative() {
370
393
}
371
394
372
395
/// find Y MAX endstop
373
- void home_y_positive () {
396
+ void home_y_positive ( uint32_t feed ) {
374
397
#if defined Y_MAX_PIN
375
- home_one_axis ( home_y_max );
398
+ home_one_axis ( home_y_max , feed );
376
399
#endif
377
400
// reference 'home' position to current position
378
401
#ifdef Y_MAX
@@ -385,9 +408,9 @@ void home_y_positive() {
385
408
}
386
409
387
410
/// find Z MIN endstop
388
- void home_z_negative () {
411
+ void home_z_negative ( uint32_t feed ) {
389
412
#if defined Z_MIN_PIN
390
- home_one_axis ( home_z_min );
413
+ home_one_axis ( home_z_min , feed );
391
414
#endif
392
415
// reference 'home' position to current position
393
416
#ifdef Z_MIN
@@ -400,9 +423,9 @@ void home_z_negative() {
400
423
}
401
424
402
425
/// find Z MAX endstop
403
- void home_z_positive () {
426
+ void home_z_positive ( uint32_t feed ) {
404
427
#if defined Z_MAX_PIN
405
- home_one_axis ( home_z_max );
428
+ home_one_axis ( home_z_max , feed );
406
429
#endif
407
430
// reference 'home' position to current position
408
431
#ifdef Z_MAX
0 commit comments