|
@@ -80,49 +80,46 @@ class Stepper {
|
80
|
80
|
|
81
|
81
|
public:
|
82
|
82
|
|
83
|
|
- block_t* current_block = NULL; // A pointer to the block currently being traced
|
|
83
|
+ static block_t* current_block; // A pointer to the block currently being traced
|
84
|
84
|
|
85
|
85
|
#if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
|
86
|
|
- bool abort_on_endstop_hit = false;
|
|
86
|
+ static bool abort_on_endstop_hit;
|
87
|
87
|
#endif
|
88
|
88
|
|
89
|
89
|
#if ENABLED(Z_DUAL_ENDSTOPS)
|
90
|
|
- bool performing_homing = false;
|
|
90
|
+ static bool performing_homing;
|
91
|
91
|
#endif
|
92
|
92
|
|
93
|
93
|
#if ENABLED(ADVANCE)
|
94
|
|
- long e_steps[4];
|
|
94
|
+ static long e_steps[4];
|
95
|
95
|
#endif
|
96
|
96
|
|
97
|
97
|
private:
|
98
|
98
|
|
99
|
|
- unsigned char last_direction_bits = 0; // The next stepping-bits to be output
|
100
|
|
- unsigned int cleaning_buffer_counter = 0;
|
|
99
|
+ static unsigned char last_direction_bits; // The next stepping-bits to be output
|
|
100
|
+ static unsigned int cleaning_buffer_counter;
|
101
|
101
|
|
102
|
102
|
#if ENABLED(Z_DUAL_ENDSTOPS)
|
103
|
|
- bool locked_z_motor = false,
|
104
|
|
- locked_z2_motor = false;
|
|
103
|
+ static bool locked_z_motor, locked_z2_motor;
|
105
|
104
|
#endif
|
106
|
105
|
|
107
|
106
|
// Counter variables for the Bresenham line tracer
|
108
|
|
- long counter_X = 0, counter_Y = 0, counter_Z = 0, counter_E = 0;
|
109
|
|
- volatile unsigned long step_events_completed = 0; // The number of step events executed in the current block
|
|
107
|
+ static long counter_X, counter_Y, counter_Z, counter_E;
|
|
108
|
+ static volatile unsigned long step_events_completed; // The number of step events executed in the current block
|
110
|
109
|
|
111
|
110
|
#if ENABLED(ADVANCE)
|
112
|
|
- unsigned char old_OCR0A;
|
113
|
|
- long advance_rate, advance, final_advance = 0;
|
114
|
|
- long old_advance = 0;
|
|
111
|
+ static unsigned char old_OCR0A;
|
|
112
|
+ static long advance_rate, advance, old_advance, final_advance;
|
115
|
113
|
#endif
|
116
|
114
|
|
117
|
|
- long acceleration_time, deceleration_time;
|
|
115
|
+ static long acceleration_time, deceleration_time;
|
118
|
116
|
//unsigned long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate, nominal_rate;
|
119
|
|
- unsigned short acc_step_rate; // needed for deceleration start point
|
120
|
|
- uint8_t step_loops;
|
121
|
|
- uint8_t step_loops_nominal;
|
122
|
|
- unsigned short OCR1A_nominal;
|
|
117
|
+ static unsigned short acc_step_rate; // needed for deceleration start point
|
|
118
|
+ static uint8_t step_loops, step_loops_nominal;
|
|
119
|
+ static unsigned short OCR1A_nominal;
|
123
|
120
|
|
124
|
|
- volatile long endstops_trigsteps[3];
|
125
|
|
- volatile long endstops_stepsTotal, endstops_stepsDone;
|
|
121
|
+ static volatile long endstops_trigsteps[3];
|
|
122
|
+ static volatile long endstops_stepsTotal, endstops_stepsDone;
|
126
|
123
|
|
127
|
124
|
#if HAS_MOTOR_CURRENT_PWM
|
128
|
125
|
#ifndef PWM_MOTOR_CURRENT
|
|
@@ -134,19 +131,19 @@ class Stepper {
|
134
|
131
|
//
|
135
|
132
|
// Positions of stepper motors, in step units
|
136
|
133
|
//
|
137
|
|
- volatile long count_position[NUM_AXIS] = { 0 };
|
|
134
|
+ static volatile long count_position[NUM_AXIS];
|
138
|
135
|
|
139
|
136
|
//
|
140
|
137
|
// Current direction of stepper motors (+1 or -1)
|
141
|
138
|
//
|
142
|
|
- volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1 };
|
|
139
|
+ static volatile signed char count_direction[NUM_AXIS];
|
143
|
140
|
|
144
|
141
|
public:
|
145
|
142
|
|
146
|
143
|
//
|
147
|
144
|
// Constructor / initializer
|
148
|
145
|
//
|
149
|
|
- Stepper() {};
|
|
146
|
+ Stepper() { };
|
150
|
147
|
|
151
|
148
|
//
|
152
|
149
|
// Initialize stepper hardware
|
|
@@ -157,10 +154,10 @@ class Stepper {
|
157
|
154
|
// Interrupt Service Routines
|
158
|
155
|
//
|
159
|
156
|
|
160
|
|
- void isr();
|
|
157
|
+ static void isr();
|
161
|
158
|
|
162
|
159
|
#if ENABLED(ADVANCE)
|
163
|
|
- void advance_isr();
|
|
160
|
+ static void advance_isr();
|
164
|
161
|
#endif
|
165
|
162
|
|
166
|
163
|
//
|
|
@@ -177,7 +174,7 @@ class Stepper {
|
177
|
174
|
//
|
178
|
175
|
// Set direction bits for all steppers
|
179
|
176
|
//
|
180
|
|
- void set_directions();
|
|
177
|
+ static void set_directions();
|
181
|
178
|
|
182
|
179
|
//
|
183
|
180
|
// Get the position of a stepper, in steps
|
|
@@ -213,7 +210,7 @@ class Stepper {
|
213
|
210
|
//
|
214
|
211
|
// The direction of a single motor
|
215
|
212
|
//
|
216
|
|
- FORCE_INLINE bool motor_direction(AxisEnum axis) { return TEST(last_direction_bits, axis); }
|
|
213
|
+ static FORCE_INLINE bool motor_direction(AxisEnum axis) { return TEST(last_direction_bits, axis); }
|
217
|
214
|
|
218
|
215
|
#if HAS_DIGIPOTSS
|
219
|
216
|
void digitalPotWrite(int address, int value);
|
|
@@ -251,7 +248,7 @@ class Stepper {
|
251
|
248
|
|
252
|
249
|
private:
|
253
|
250
|
|
254
|
|
- FORCE_INLINE unsigned short calc_timer(unsigned short step_rate) {
|
|
251
|
+ static FORCE_INLINE unsigned short calc_timer(unsigned short step_rate) {
|
255
|
252
|
unsigned short timer;
|
256
|
253
|
|
257
|
254
|
NOMORE(step_rate, MAX_STEP_FREQUENCY);
|
|
@@ -283,13 +280,17 @@ class Stepper {
|
283
|
280
|
timer = (unsigned short)pgm_read_word_near(table_address);
|
284
|
281
|
timer -= (((unsigned short)pgm_read_word_near(table_address + 2) * (unsigned char)(step_rate & 0x0007)) >> 3);
|
285
|
282
|
}
|
286
|
|
- if (timer < 100) { timer = 100; MYSERIAL.print(MSG_STEPPER_TOO_HIGH); MYSERIAL.println(step_rate); }//(20kHz this should never happen)
|
|
283
|
+ if (timer < 100) { // (20kHz - this should never happen)
|
|
284
|
+ timer = 100;
|
|
285
|
+ MYSERIAL.print(MSG_STEPPER_TOO_HIGH);
|
|
286
|
+ MYSERIAL.println(step_rate);
|
|
287
|
+ }
|
287
|
288
|
return timer;
|
288
|
289
|
}
|
289
|
290
|
|
290
|
291
|
// Initializes the trapezoid generator from the current block. Called whenever a new
|
291
|
292
|
// block begins.
|
292
|
|
- FORCE_INLINE void trapezoid_generator_reset() {
|
|
293
|
+ static FORCE_INLINE void trapezoid_generator_reset() {
|
293
|
294
|
|
294
|
295
|
static int8_t last_extruder = -1;
|
295
|
296
|
|