chiark / gitweb /
refresh (create temporary patch)
[marlin.git] / patches / refresh-temp
1 Bottom: 681cec9bc49d48ceecfc6d5e9eff1c4f7f623fc6
2 Top:    eaaf908848a4a0cd0e69f559ed75c700974fc20f
3 Author: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 Date:   2012-08-11 01:35:49 +0100
5
6 Refresh of m206-always-use-homing-homeing
7
8 ---
9
10 diff --git a/Marlin/Marlin.h b/Marlin/Marlin.h
11 index 75b57d0..b465d85 100644
12 --- a/Marlin/Marlin.h
13 +++ b/Marlin/Marlin.h
14 @@ -184,6 +184,8 @@ extern float homing_feedrate[];
15  extern bool axis_relative_modes[];
16  extern float current_position[NUM_AXIS] ;
17  extern float add_homeing[3];
18 +extern float min_pos[3];
19 +extern float max_pos[3];
20  extern unsigned char FanSpeed;
21  
22  // Handling multiple extruders pins
23 diff --git a/Marlin/Marlin.pde b/Marlin/Marlin.pde
24 index 5268a3d..c153298 100644
25 --- a/Marlin/Marlin.pde
26 +++ b/Marlin/Marlin.pde
27 @@ -143,6 +143,8 @@ volatile bool feedmultiplychanged=false;
28  volatile int extrudemultiply=100; //100->1 200->2
29  float current_position[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0 };
30  float add_homeing[3]={0,0,0};
31 +float min_pos[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS };
32 +float max_pos[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS };
33  uint8_t active_extruder = 0;
34  unsigned char FanSpeed=0;
35  
36 @@ -543,6 +545,28 @@ bool code_seen(char code)
37    return (strchr_pointer != NULL);  //Return True if a character was found
38  }
39  
40 +#define DEFINE_PGM_READ_ANY(type, reader)              \
41 +    static inline float pgm_read_any(const type *p)    \
42 +       { return pgm_read_##reader##_near(p); }
43 +
44 +DEFINE_PGM_READ_ANY(float,       float);
45 +
46 +#define XYZ_CONSTS_FROM_CONFIG(type, array, CONFIG)    \
47 +static const PROGMEM type array##_P[3] =               \
48 +    { X_##CONFIG, Y_##CONFIG, Z_##CONFIG };            \
49 +static inline type array(int axis)                     \
50 +    { return pgm_read_any(&array##_P[axis]); }
51 +
52 +XYZ_CONSTS_FROM_CONFIG(float, base_min_pos,    MIN_POS);
53 +XYZ_CONSTS_FROM_CONFIG(float, base_max_pos,    MAX_POS);
54 +XYZ_CONSTS_FROM_CONFIG(float, base_home_pos,   HOME_POS);
55 +
56 +static void axis_is_at_home(int axis) {
57 +  current_position[axis] = base_home_pos(axis) + add_homeing[axis];
58 +  min_pos[axis] =          base_min_pos(axis) + add_homeing[axis];
59 +  max_pos[axis] =          base_max_pos(axis) + add_homeing[axis];
60 +}
61 +
62  #define HOMEAXIS(LETTER) \
63    if ((LETTER##_MIN_PIN > -1 && LETTER##_HOME_DIR==-1) || (LETTER##_MAX_PIN > -1 && LETTER##_HOME_DIR==1))\
64      { \
65 @@ -564,8 +588,8 @@ bool code_seen(char code)
66      plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); \
67      st_synchronize();\
68      \
69 -    current_position[LETTER##_AXIS] = LETTER##_HOME_POS;\
70 -    destination[LETTER##_AXIS] = current_position[LETTER##_AXIS];\
71 +    axis_is_at_home(LETTER##_AXIS);                                    \
72 +    destination[LETTER##_AXIS] = current_position[LETTER##_AXIS]; \
73      feedrate = 0.0;\
74      endstops_hit_on_purpose();\
75    }
76 @@ -678,8 +702,8 @@ void process_commands()
77          plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
78          st_synchronize();
79      
80 -        current_position[X_AXIS] = X_HOME_POS;
81 -        current_position[Y_AXIS] = Y_HOME_POS;
82 +        axis_is_at_home(X_AXIS);
83 +        axis_is_at_home(Y_AXIS);
84          plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
85          destination[X_AXIS] = current_position[X_AXIS];
86          destination[Y_AXIS] = current_position[Y_AXIS];
87 @@ -1544,15 +1568,15 @@ void get_arc_coordinates()
88  void clamp_to_software_endstops(float target[3])
89  {
90    if (min_software_endstops) {
91 -    if (target[X_AXIS] < X_MIN_POS) target[X_AXIS] = X_MIN_POS;
92 -    if (target[Y_AXIS] < Y_MIN_POS) target[Y_AXIS] = Y_MIN_POS;
93 -    if (target[Z_AXIS] < Z_MIN_POS) target[Z_AXIS] = Z_MIN_POS;
94 +    if (target[X_AXIS] < min_pos[X_AXIS]) target[X_AXIS] = min_pos[X_AXIS];
95 +    if (target[Y_AXIS] < min_pos[Y_AXIS]) target[Y_AXIS] = min_pos[Y_AXIS];
96 +    if (target[Z_AXIS] < min_pos[Z_AXIS]) target[Z_AXIS] = min_pos[Z_AXIS];
97    }
98  
99    if (max_software_endstops) {
100 -    if (target[X_AXIS] > X_MAX_POS) target[X_AXIS] = X_MAX_POS;
101 -    if (target[Y_AXIS] > Y_MAX_POS) target[Y_AXIS] = Y_MAX_POS;
102 -    if (target[Z_AXIS] > Z_MAX_POS) target[Z_AXIS] = Z_MAX_POS;
103 +    if (target[X_AXIS] > max_pos[X_AXIS]) target[X_AXIS] = max_pos[X_AXIS];
104 +    if (target[Y_AXIS] > max_pos[Y_AXIS]) target[Y_AXIS] = max_pos[Y_AXIS];
105 +    if (target[Z_AXIS] > max_pos[Z_AXIS]) target[Z_AXIS] = max_pos[Z_AXIS];
106    }
107  }
108  
109 diff --git a/README.md b/README.md
110 index 86dd93d..fb2c189 100644
111 --- a/README.md
112 +++ b/README.md
113 @@ -152,6 +152,7 @@ Movement variables:
114  *   M202 - Set max acceleration in units/s^2 for travel moves (M202 X1000 Y1000) Unused in Marlin!!\r
115  *   M203 - Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in mm/sec\r
116  *   M204 - Set default acceleration: S normal moves T filament only moves (M204 S3000 T7000) im mm/sec^2  also sets minimum segment time in ms (B20000) to prevent buffer underruns and M20 minimum feedrate\r
117 +*   M206 - set home offsets.  This sets the X,Y,Z coordinates of the endstops (and is added to the {X,Y,Z}_HOME_POS configuration options (and is also added to the coordinates, if any, provided to G82, as with earlier firmware)\r
118  *   M220 - set build speed mulitplying S:factor in percent ; aka "realtime tuneing in the gcode". So you can slow down if you have islands in one height-range, and speed up otherwise.\r
119  *   M221 - set the extrude multiplying S:factor in percent\r
120  *   M400 - Finish all buffered moves.