|
@@ -143,6 +143,8 @@ volatile bool feedmultiplychanged=false;
|
143
|
143
|
volatile int extrudemultiply=100; //100->1 200->2
|
144
|
144
|
float current_position[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0 };
|
145
|
145
|
float add_homeing[3]={0,0,0};
|
|
146
|
+float min_pos[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS };
|
|
147
|
+float max_pos[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS };
|
146
|
148
|
uint8_t active_extruder = 0;
|
147
|
149
|
unsigned char FanSpeed=0;
|
148
|
150
|
|
|
@@ -543,6 +545,28 @@ bool code_seen(char code)
|
543
|
545
|
return (strchr_pointer != NULL); //Return True if a character was found
|
544
|
546
|
}
|
545
|
547
|
|
|
548
|
+#define DEFINE_PGM_READ_ANY(type, reader) \
|
|
549
|
+ static inline type pgm_read_any(const type *p) \
|
|
550
|
+ { return pgm_read_##reader##_near(p); }
|
|
551
|
+
|
|
552
|
+DEFINE_PGM_READ_ANY(float, float);
|
|
553
|
+
|
|
554
|
+#define XYZ_CONSTS_FROM_CONFIG(type, array, CONFIG) \
|
|
555
|
+static const PROGMEM type array##_P[3] = \
|
|
556
|
+ { X_##CONFIG, Y_##CONFIG, Z_##CONFIG }; \
|
|
557
|
+static inline type array(int axis) \
|
|
558
|
+ { return pgm_read_any(&array##_P[axis]); }
|
|
559
|
+
|
|
560
|
+XYZ_CONSTS_FROM_CONFIG(float, base_min_pos, MIN_POS);
|
|
561
|
+XYZ_CONSTS_FROM_CONFIG(float, base_max_pos, MAX_POS);
|
|
562
|
+XYZ_CONSTS_FROM_CONFIG(float, base_home_pos, HOME_POS);
|
|
563
|
+
|
|
564
|
+static void axis_is_at_home(int axis) {
|
|
565
|
+ current_position[axis] = base_home_pos(axis) + add_homeing[axis];
|
|
566
|
+ min_pos[axis] = base_min_pos(axis) + add_homeing[axis];
|
|
567
|
+ max_pos[axis] = base_max_pos(axis) + add_homeing[axis];
|
|
568
|
+}
|
|
569
|
+
|
546
|
570
|
#define HOMEAXIS(LETTER) \
|
547
|
571
|
if ((LETTER##_MIN_PIN > -1 && LETTER##_HOME_DIR==-1) || (LETTER##_MAX_PIN > -1 && LETTER##_HOME_DIR==1))\
|
548
|
572
|
{ \
|
|
@@ -564,8 +588,8 @@ bool code_seen(char code)
|
564
|
588
|
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); \
|
565
|
589
|
st_synchronize();\
|
566
|
590
|
\
|
567
|
|
- current_position[LETTER##_AXIS] = LETTER##_HOME_POS;\
|
568
|
|
- destination[LETTER##_AXIS] = current_position[LETTER##_AXIS];\
|
|
591
|
+ axis_is_at_home(LETTER##_AXIS); \
|
|
592
|
+ destination[LETTER##_AXIS] = current_position[LETTER##_AXIS]; \
|
569
|
593
|
feedrate = 0.0;\
|
570
|
594
|
endstops_hit_on_purpose();\
|
571
|
595
|
}
|
|
@@ -678,8 +702,8 @@ void process_commands()
|
678
|
702
|
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
|
679
|
703
|
st_synchronize();
|
680
|
704
|
|
681
|
|
- current_position[X_AXIS] = X_HOME_POS;
|
682
|
|
- current_position[Y_AXIS] = Y_HOME_POS;
|
|
705
|
+ axis_is_at_home(X_AXIS);
|
|
706
|
+ axis_is_at_home(Y_AXIS);
|
683
|
707
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
684
|
708
|
destination[X_AXIS] = current_position[X_AXIS];
|
685
|
709
|
destination[Y_AXIS] = current_position[Y_AXIS];
|
|
@@ -1544,15 +1568,15 @@ void get_arc_coordinates()
|
1544
|
1568
|
void clamp_to_software_endstops(float target[3])
|
1545
|
1569
|
{
|
1546
|
1570
|
if (min_software_endstops) {
|
1547
|
|
- if (target[X_AXIS] < X_MIN_POS) target[X_AXIS] = X_MIN_POS;
|
1548
|
|
- if (target[Y_AXIS] < Y_MIN_POS) target[Y_AXIS] = Y_MIN_POS;
|
1549
|
|
- if (target[Z_AXIS] < Z_MIN_POS) target[Z_AXIS] = Z_MIN_POS;
|
|
1571
|
+ if (target[X_AXIS] < min_pos[X_AXIS]) target[X_AXIS] = min_pos[X_AXIS];
|
|
1572
|
+ if (target[Y_AXIS] < min_pos[Y_AXIS]) target[Y_AXIS] = min_pos[Y_AXIS];
|
|
1573
|
+ if (target[Z_AXIS] < min_pos[Z_AXIS]) target[Z_AXIS] = min_pos[Z_AXIS];
|
1550
|
1574
|
}
|
1551
|
1575
|
|
1552
|
1576
|
if (max_software_endstops) {
|
1553
|
|
- if (target[X_AXIS] > X_MAX_POS) target[X_AXIS] = X_MAX_POS;
|
1554
|
|
- if (target[Y_AXIS] > Y_MAX_POS) target[Y_AXIS] = Y_MAX_POS;
|
1555
|
|
- if (target[Z_AXIS] > Z_MAX_POS) target[Z_AXIS] = Z_MAX_POS;
|
|
1577
|
+ if (target[X_AXIS] > max_pos[X_AXIS]) target[X_AXIS] = max_pos[X_AXIS];
|
|
1578
|
+ if (target[Y_AXIS] > max_pos[Y_AXIS]) target[Y_AXIS] = max_pos[Y_AXIS];
|
|
1579
|
+ if (target[Z_AXIS] > max_pos[Z_AXIS]) target[Z_AXIS] = max_pos[Z_AXIS];
|
1556
|
1580
|
}
|
1557
|
1581
|
}
|
1558
|
1582
|
|