|
@@ -55,7 +55,7 @@
|
55
|
55
|
#include "ultralcd.h"
|
56
|
56
|
#include "language.h"
|
57
|
57
|
|
58
|
|
-#ifdef MESH_BED_LEVELING
|
|
58
|
+#if ENABLED(MESH_BED_LEVELING)
|
59
|
59
|
#include "mesh_bed_leveling.h"
|
60
|
60
|
#endif
|
61
|
61
|
|
|
@@ -77,7 +77,7 @@ float max_e_jerk;
|
77
|
77
|
float mintravelfeedrate;
|
78
|
78
|
unsigned long axis_steps_per_sqr_second[NUM_AXIS];
|
79
|
79
|
|
80
|
|
-#ifdef ENABLE_AUTO_BED_LEVELING
|
|
80
|
+#if ENABLED(ENABLE_AUTO_BED_LEVELING)
|
81
|
81
|
// Transform required to compensate for bed level
|
82
|
82
|
matrix_3x3 plan_bed_level_matrix = {
|
83
|
83
|
1.0, 0.0, 0.0,
|
|
@@ -86,7 +86,7 @@ unsigned long axis_steps_per_sqr_second[NUM_AXIS];
|
86
|
86
|
};
|
87
|
87
|
#endif // ENABLE_AUTO_BED_LEVELING
|
88
|
88
|
|
89
|
|
-#ifdef AUTOTEMP
|
|
89
|
+#if ENABLED(AUTOTEMP)
|
90
|
90
|
float autotemp_max = 250;
|
91
|
91
|
float autotemp_min = 210;
|
92
|
92
|
float autotemp_factor = 0.1;
|
|
@@ -121,7 +121,7 @@ unsigned char g_uc_extruder_last_move[4] = {0,0,0,0};
|
121
|
121
|
static long axis_segment_time[2][3] = { {MAX_FREQ_TIME+1,0,0}, {MAX_FREQ_TIME+1,0,0} };
|
122
|
122
|
#endif
|
123
|
123
|
|
124
|
|
-#ifdef FILAMENT_SENSOR
|
|
124
|
+#if ENABLED(FILAMENT_SENSOR)
|
125
|
125
|
static char meas_sample; //temporary variable to hold filament measurement sample
|
126
|
126
|
#endif
|
127
|
127
|
|
|
@@ -178,7 +178,7 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi
|
178
|
178
|
plateau_steps = 0;
|
179
|
179
|
}
|
180
|
180
|
|
181
|
|
-#ifdef ADVANCE
|
|
181
|
+#if ENABLED(ADVANCE)
|
182
|
182
|
volatile long initial_advance = block->advance * entry_factor * entry_factor;
|
183
|
183
|
volatile long final_advance = block->advance * exit_factor * exit_factor;
|
184
|
184
|
#endif // ADVANCE
|
|
@@ -191,7 +191,7 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi
|
191
|
191
|
block->decelerate_after = accelerate_steps+plateau_steps;
|
192
|
192
|
block->initial_rate = initial_rate;
|
193
|
193
|
block->final_rate = final_rate;
|
194
|
|
- #ifdef ADVANCE
|
|
194
|
+ #if ENABLED(ADVANCE)
|
195
|
195
|
block->initial_advance = initial_advance;
|
196
|
196
|
block->final_advance = final_advance;
|
197
|
197
|
#endif
|
|
@@ -361,7 +361,7 @@ void plan_init() {
|
361
|
361
|
}
|
362
|
362
|
|
363
|
363
|
|
364
|
|
-#ifdef AUTOTEMP
|
|
364
|
+#if ENABLED(AUTOTEMP)
|
365
|
365
|
void getHighESpeed() {
|
366
|
366
|
static float oldt = 0;
|
367
|
367
|
|
|
@@ -394,7 +394,7 @@ void plan_init() {
|
394
|
394
|
void check_axes_activity() {
|
395
|
395
|
unsigned char axis_active[NUM_AXIS] = { 0 },
|
396
|
396
|
tail_fan_speed = fanSpeed;
|
397
|
|
- #ifdef BARICUDA
|
|
397
|
+ #if ENABLED(BARICUDA)
|
398
|
398
|
unsigned char tail_valve_pressure = ValvePressure,
|
399
|
399
|
tail_e_to_p_pressure = EtoPPressure;
|
400
|
400
|
#endif
|
|
@@ -404,7 +404,7 @@ void check_axes_activity() {
|
404
|
404
|
if (blocks_queued()) {
|
405
|
405
|
uint8_t block_index = block_buffer_tail;
|
406
|
406
|
tail_fan_speed = block_buffer[block_index].fan_speed;
|
407
|
|
- #ifdef BARICUDA
|
|
407
|
+ #if ENABLED(BARICUDA)
|
408
|
408
|
block = &block_buffer[block_index];
|
409
|
409
|
tail_valve_pressure = block->valve_pressure;
|
410
|
410
|
tail_e_to_p_pressure = block->e_to_p_pressure;
|
|
@@ -441,23 +441,23 @@ void check_axes_activity() {
|
441
|
441
|
fan_kick_end = 0;
|
442
|
442
|
}
|
443
|
443
|
#endif //FAN_KICKSTART_TIME
|
444
|
|
- #ifdef FAN_MIN_PWM
|
|
444
|
+ #if ENABLED(FAN_MIN_PWM)
|
445
|
445
|
#define CALC_FAN_SPEED (tail_fan_speed ? ( FAN_MIN_PWM + (tail_fan_speed * (255 - FAN_MIN_PWM)) / 255 ) : 0)
|
446
|
446
|
#else
|
447
|
447
|
#define CALC_FAN_SPEED tail_fan_speed
|
448
|
448
|
#endif // FAN_MIN_PWM
|
449
|
|
- #ifdef FAN_SOFT_PWM
|
|
449
|
+ #if ENABLED(FAN_SOFT_PWM)
|
450
|
450
|
fanSpeedSoftPwm = CALC_FAN_SPEED;
|
451
|
451
|
#else
|
452
|
452
|
analogWrite(FAN_PIN, CALC_FAN_SPEED);
|
453
|
453
|
#endif // FAN_SOFT_PWM
|
454
|
454
|
#endif // HAS_FAN
|
455
|
455
|
|
456
|
|
- #ifdef AUTOTEMP
|
|
456
|
+ #if ENABLED(AUTOTEMP)
|
457
|
457
|
getHighESpeed();
|
458
|
458
|
#endif
|
459
|
459
|
|
460
|
|
- #ifdef BARICUDA
|
|
460
|
+ #if ENABLED(BARICUDA)
|
461
|
461
|
#if HAS_HEATER_1
|
462
|
462
|
analogWrite(HEATER_1_PIN,tail_valve_pressure);
|
463
|
463
|
#endif
|
|
@@ -472,7 +472,7 @@ float junction_deviation = 0.1;
|
472
|
472
|
// Add a new linear movement to the buffer. steps[X_AXIS], _y and _z is the absolute position in
|
473
|
473
|
// mm. Microseconds specify how many microseconds the move should take to perform. To aid acceleration
|
474
|
474
|
// calculation the caller must also provide the physical length of the line in millimeters.
|
475
|
|
-#if defined(ENABLE_AUTO_BED_LEVELING) || defined(MESH_BED_LEVELING)
|
|
475
|
+#if ENABLED(ENABLE_AUTO_BED_LEVELING) || ENABLED(MESH_BED_LEVELING)
|
476
|
476
|
void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate, const uint8_t extruder)
|
477
|
477
|
#else
|
478
|
478
|
void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate, const uint8_t extruder)
|
|
@@ -485,9 +485,9 @@ float junction_deviation = 0.1;
|
485
|
485
|
// Rest here until there is room in the buffer.
|
486
|
486
|
while (block_buffer_tail == next_buffer_head) idle();
|
487
|
487
|
|
488
|
|
- #ifdef MESH_BED_LEVELING
|
|
488
|
+ #if ENABLED(MESH_BED_LEVELING)
|
489
|
489
|
if (mbl.active) z += mbl.get_z(x, y);
|
490
|
|
- #elif defined(ENABLE_AUTO_BED_LEVELING)
|
|
490
|
+ #elif ENABLED(ENABLE_AUTO_BED_LEVELING)
|
491
|
491
|
apply_rotation_xyz(plan_bed_level_matrix, x, y, z);
|
492
|
492
|
#endif
|
493
|
493
|
|
|
@@ -510,7 +510,7 @@ float junction_deviation = 0.1;
|
510
|
510
|
|
511
|
511
|
float de = target[E_AXIS] - position[E_AXIS];
|
512
|
512
|
|
513
|
|
- #ifdef PREVENT_DANGEROUS_EXTRUDE
|
|
513
|
+ #if ENABLED(PREVENT_DANGEROUS_EXTRUDE)
|
514
|
514
|
if (de) {
|
515
|
515
|
if (degHotend(extruder) < extrude_min_temp) {
|
516
|
516
|
position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
|
|
@@ -518,7 +518,7 @@ float junction_deviation = 0.1;
|
518
|
518
|
SERIAL_ECHO_START;
|
519
|
519
|
SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP);
|
520
|
520
|
}
|
521
|
|
- #ifdef PREVENT_LENGTHY_EXTRUDE
|
|
521
|
+ #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
|
522
|
522
|
if (labs(de) > axis_steps_per_unit[E_AXIS] * EXTRUDE_MAXLENGTH) {
|
523
|
523
|
position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
|
524
|
524
|
de = 0; // no difference
|
|
@@ -536,7 +536,7 @@ float junction_deviation = 0.1;
|
536
|
536
|
block->busy = false;
|
537
|
537
|
|
538
|
538
|
// Number of steps for each axis
|
539
|
|
- #ifdef COREXY
|
|
539
|
+ #if ENABLED(COREXY)
|
540
|
540
|
// corexy planning
|
541
|
541
|
// these equations follow the form of the dA and dB equations on http://www.corexy.com/theory.html
|
542
|
542
|
block->steps[A_AXIS] = labs(dx + dy);
|
|
@@ -564,14 +564,14 @@ float junction_deviation = 0.1;
|
564
|
564
|
if (block->step_event_count <= dropsegments) return;
|
565
|
565
|
|
566
|
566
|
block->fan_speed = fanSpeed;
|
567
|
|
- #ifdef BARICUDA
|
|
567
|
+ #if ENABLED(BARICUDA)
|
568
|
568
|
block->valve_pressure = ValvePressure;
|
569
|
569
|
block->e_to_p_pressure = EtoPPressure;
|
570
|
570
|
#endif
|
571
|
571
|
|
572
|
572
|
// Compute direction bits for this block
|
573
|
573
|
uint8_t db = 0;
|
574
|
|
- #ifdef COREXY
|
|
574
|
+ #if ENABLED(COREXY)
|
575
|
575
|
if (dx < 0) db |= BIT(X_HEAD); // Save the real Extruder (head) direction in X Axis
|
576
|
576
|
if (dy < 0) db |= BIT(Y_HEAD); // ...and Y
|
577
|
577
|
if (dz < 0) db |= BIT(Z_AXIS);
|
|
@@ -594,7 +594,7 @@ float junction_deviation = 0.1;
|
594
|
594
|
block->active_extruder = extruder;
|
595
|
595
|
|
596
|
596
|
//enable active axes
|
597
|
|
- #ifdef COREXY
|
|
597
|
+ #if ENABLED(COREXY)
|
598
|
598
|
if (block->steps[A_AXIS] || block->steps[B_AXIS]) {
|
599
|
599
|
enable_x();
|
600
|
600
|
enable_y();
|
|
@@ -693,7 +693,7 @@ float junction_deviation = 0.1;
|
693
|
693
|
* So we need to create other 2 "AXIS", named X_HEAD and Y_HEAD, meaning the real displacement of the Head.
|
694
|
694
|
* Having the real displacement of the head, we can calculate the total movement length and apply the desired speed.
|
695
|
695
|
*/
|
696
|
|
- #ifdef COREXY
|
|
696
|
+ #if ENABLED(COREXY)
|
697
|
697
|
float delta_mm[6];
|
698
|
698
|
delta_mm[X_HEAD] = dx / axis_steps_per_unit[A_AXIS];
|
699
|
699
|
delta_mm[Y_HEAD] = dy / axis_steps_per_unit[B_AXIS];
|
|
@@ -720,9 +720,9 @@ float junction_deviation = 0.1;
|
720
|
720
|
}
|
721
|
721
|
else {
|
722
|
722
|
block->millimeters = sqrt(
|
723
|
|
- #ifdef COREXY
|
|
723
|
+ #if ENABLED(COREXY)
|
724
|
724
|
square(delta_mm[X_HEAD]) + square(delta_mm[Y_HEAD]) + square(delta_mm[Z_AXIS])
|
725
|
|
- #elif defined(COREXZ)
|
|
725
|
+ #elif ENABLED(COREXZ)
|
726
|
726
|
square(delta_mm[X_HEAD]) + square(delta_mm[Y_AXIS]) + square(delta_mm[Z_HEAD])
|
727
|
727
|
#else
|
728
|
728
|
square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS]) + square(delta_mm[Z_AXIS])
|
|
@@ -737,12 +737,12 @@ float junction_deviation = 0.1;
|
737
|
737
|
int moves_queued = movesplanned();
|
738
|
738
|
|
739
|
739
|
// Slow down when the buffer starts to empty, rather than wait at the corner for a buffer refill
|
740
|
|
- #if defined(OLD_SLOWDOWN) || defined(SLOWDOWN)
|
|
740
|
+ #if ENABLED(OLD_SLOWDOWN) || ENABLED(SLOWDOWN)
|
741
|
741
|
bool mq = moves_queued > 1 && moves_queued < BLOCK_BUFFER_SIZE / 2;
|
742
|
|
- #ifdef OLD_SLOWDOWN
|
|
742
|
+ #if ENABLED(OLD_SLOWDOWN)
|
743
|
743
|
if (mq) feed_rate *= 2.0 * moves_queued / BLOCK_BUFFER_SIZE;
|
744
|
744
|
#endif
|
745
|
|
- #ifdef SLOWDOWN
|
|
745
|
+ #if ENABLED(SLOWDOWN)
|
746
|
746
|
// segment time im micro seconds
|
747
|
747
|
unsigned long segment_time = lround(1000000.0/inverse_second);
|
748
|
748
|
if (mq) {
|
|
@@ -760,7 +760,7 @@ float junction_deviation = 0.1;
|
760
|
760
|
block->nominal_speed = block->millimeters * inverse_second; // (mm/sec) Always > 0
|
761
|
761
|
block->nominal_rate = ceil(block->step_event_count * inverse_second); // (step/sec) Always > 0
|
762
|
762
|
|
763
|
|
- #ifdef FILAMENT_SENSOR
|
|
763
|
+ #if ENABLED(FILAMENT_SENSOR)
|
764
|
764
|
//FMM update ring buffer used for delay with filament measurements
|
765
|
765
|
|
766
|
766
|
if (extruder == FILAMENT_SENSOR_EXTRUDER_NUM && delay_index2 > -1) { //only for extruder with filament sensor and if ring buffer is initialized
|
|
@@ -956,7 +956,7 @@ float junction_deviation = 0.1;
|
956
|
956
|
for (int i = 0; i < NUM_AXIS; i++) previous_speed[i] = current_speed[i];
|
957
|
957
|
previous_nominal_speed = block->nominal_speed;
|
958
|
958
|
|
959
|
|
- #ifdef ADVANCE
|
|
959
|
+ #if ENABLED(ADVANCE)
|
960
|
960
|
// Calculate advance rate
|
961
|
961
|
if (!bse || (!bsx && !bsy && !bsz)) {
|
962
|
962
|
block->advance_rate = 0;
|
|
@@ -991,7 +991,7 @@ float junction_deviation = 0.1;
|
991
|
991
|
|
992
|
992
|
} // plan_buffer_line()
|
993
|
993
|
|
994
|
|
-#if defined(ENABLE_AUTO_BED_LEVELING) && !defined(DELTA)
|
|
994
|
+#if ENABLED(ENABLE_AUTO_BED_LEVELING) && DISABLED(DELTA)
|
995
|
995
|
vector_3 plan_get_position() {
|
996
|
996
|
vector_3 position = vector_3(st_get_position_mm(X_AXIS), st_get_position_mm(Y_AXIS), st_get_position_mm(Z_AXIS));
|
997
|
997
|
|
|
@@ -1006,15 +1006,15 @@ float junction_deviation = 0.1;
|
1006
|
1006
|
}
|
1007
|
1007
|
#endif // ENABLE_AUTO_BED_LEVELING && !DELTA
|
1008
|
1008
|
|
1009
|
|
-#if defined(ENABLE_AUTO_BED_LEVELING) || defined(MESH_BED_LEVELING)
|
|
1009
|
+#if ENABLED(ENABLE_AUTO_BED_LEVELING) || ENABLED(MESH_BED_LEVELING)
|
1010
|
1010
|
void plan_set_position(float x, float y, float z, const float &e)
|
1011
|
1011
|
#else
|
1012
|
1012
|
void plan_set_position(const float &x, const float &y, const float &z, const float &e)
|
1013
|
1013
|
#endif // ENABLE_AUTO_BED_LEVELING || MESH_BED_LEVELING
|
1014
|
1014
|
{
|
1015
|
|
- #ifdef MESH_BED_LEVELING
|
|
1015
|
+ #if ENABLED(MESH_BED_LEVELING)
|
1016
|
1016
|
if (mbl.active) z += mbl.get_z(x, y);
|
1017
|
|
- #elif defined(ENABLE_AUTO_BED_LEVELING)
|
|
1017
|
+ #elif ENABLED(ENABLE_AUTO_BED_LEVELING)
|
1018
|
1018
|
apply_rotation_xyz(plan_bed_level_matrix, x, y, z);
|
1019
|
1019
|
#endif
|
1020
|
1020
|
|